{"action":"created","comment":{"url":"https://api.github.com/repos/simpledotorg/simple-android/pulls/comments/219449987","pull_request_review_id":157628914,"id":219449987,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxOTQ0OTk4Nw==","diff_hunk":"@@ -76,21 +90,117 @@ class PatientSearchScreenController @Inject constructor(\n         }\n   }\n \n+  private fun validateQuery(): ObservableTransformer<UiEvent, UiEvent> {\n+    return ObservableTransformer { events ->\n+      val nameChanges = events\n+          .ofType<SearchQueryNameChanged>()\n+          .map { it.name.trim() }\n+\n+      val ageChanges = events\n+          .ofType<SearchQueryAgeChanged>()\n+          .map { it.ageString.trim() }\n+\n+      val dateOfBirthChanges = events\n+          .ofType<SearchQueryDateOfBirthChanged>()\n+          .map { it.dateOfBirth.trim() }\n+\n+      val validationErrors = events.ofType<SearchClicked>()\n+          .withLatestFrom(nameChanges, ageChanges, dateOfBirthChanges) { _, name, age, dob -> Triple(name, age, dob) }\n+          .map { (name, age, dateOfBirth) ->\n+            val errors = mutableListOf<PatientSearchValidationError>()\n+\n+            if (dateOfBirth.isNullOrBlank() && age.isNullOrBlank()) {\n+              errors += BOTH_DATEOFBIRTH_AND_AGE_ABSENT\n+\n+            } else if (dateOfBirth?.isNotBlank() == true && age?.isNotBlank() == true) {\n+              errors += BOTH_DATEOFBIRTH_AND_AGE_PRESENT\n+\n+            } else if (dateOfBirth.isNotBlank()) {\n+              val dobValidationResult = dobValidator.validate(dateOfBirth)\n+              errors += when (dobValidationResult) {\n+                DateOfBirthFormatValidator.Result.INVALID_PATTERN -> listOf(INVALID_DATE_OF_BIRTH)\n+                DateOfBirthFormatValidator.Result.DATE_IS_IN_FUTURE -> listOf(DATE_OF_BIRTH_IN_FUTURE)\n+                DateOfBirthFormatValidator.Result.VALID -> listOf()\n+              }\n+            }\n+            if (name.isBlank()) {\n+              errors += FULL_NAME_EMPTY\n+            }\n+            SearchQueryValidated(errors)\n+          }\n+\n+      events.mergeWith(validationErrors)\n+    }\n+  }\n+\n+  private fun showValidationErrors(events: Observable<UiEvent>): Observable<UiChange> {\n+    return events.ofType<SearchQueryValidated>()\n+        .distinctUntilChanged()\n+        .flatMapIterable { it.validationErrors }\n+        .doOnNext { Analytics.reportInputValidationError(it.analyticsName) }\n+        .map {\n+          { ui: Ui ->\n+            when (it) {\n+              FULL_NAME_EMPTY -> ui.setEmptyFullNameErrorVisible(true)\n+              BOTH_DATEOFBIRTH_AND_AGE_ABSENT -> ui.setEmptyDateOfBirthAndAgeErrorVisible(true)\n+              INVALID_DATE_OF_BIRTH -> ui.setInvalidDateOfBirthErrorVisible(true)\n+              DATE_OF_BIRTH_IN_FUTURE -> ui.setDateOfBirthIsInFutureErrorVisible(true)\n+","path":"app/src/main/java/org/simple/clinic/search/PatientSearchScreenController.kt","position":118,"original_position":104,"commit_id":"05565df7340ee9abc89a4acf4414712f87c36b9d","original_commit_id":"e0c86be7eaf5437ceeee48fd14827d968e6c6059","user":{"login":"vinaysshenoy","id":1978065,"node_id":"MDQ6VXNlcjE5NzgwNjU=","avatar_url":"https://avatars0.githubusercontent.com/u/1978065?v=4","gravatar_id":"","url":"https://api.github.com/users/vinaysshenoy","html_url":"https://github.com/vinaysshenoy","followers_url":"https://api.github.com/users/vinaysshenoy/followers","following_url":"https://api.github.com/users/vinaysshenoy/following{/other_user}","gists_url":"https://api.github.com/users/vinaysshenoy/gists{/gist_id}","starred_url":"https://api.github.com/users/vinaysshenoy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vinaysshenoy/subscriptions","organizations_url":"https://api.github.com/users/vinaysshenoy/orgs","repos_url":"https://api.github.com/users/vinaysshenoy/repos","events_url":"https://api.github.com/users/vinaysshenoy/events{/privacy}","received_events_url":"https://api.github.com/users/vinaysshenoy/received_events","type":"User","site_admin":false},"body":"Unnecessary line?","created_at":"2018-09-21T10:15:46Z","updated_at":"2018-09-21T10:15:46Z","html_url":"https://github.com/simpledotorg/simple-android/pull/264#discussion_r219449987","pull_request_url":"https://api.github.com/repos/simpledotorg/simple-android/pulls/264","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/simpledotorg/simple-android/pulls/comments/219449987"},"html":{"href":"https://github.com/simpledotorg/simple-android/pull/264#discussion_r219449987"},"pull_request":{"href":"https://api.github.com/repos/simpledotorg/simple-android/pulls/264"}}},"pull_request":{"url":"https://api.github.com/repos/simpledotorg/simple-android/pulls/264","id":216922155,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE2OTIyMTU1","html_url":"https://github.com/simpledotorg/simple-android/pull/264","diff_url":"https://github.com/simpledotorg/simple-android/pull/264.diff","patch_url":"https://github.com/simpledotorg/simple-android/pull/264.patch","issue_url":"https://api.github.com/repos/simpledotorg/simple-android/issues/264","number":264,"state":"open","locked":false,"title":"Finish the new patient lookup flow","user":{"login":"saket","id":2387680,"node_id":"MDQ6VXNlcjIzODc2ODA=","avatar_url":"https://avatars3.githubusercontent.com/u/2387680?v=4","gravatar_id":"","url":"https://api.github.com/users/saket","html_url":"https://github.com/saket","followers_url":"https://api.github.com/users/saket/followers","following_url":"https://api.github.com/users/saket/following{/other_user}","gists_url":"https://api.github.com/users/saket/gists{/gist_id}","starred_url":"https://api.github.com/users/saket/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saket/subscriptions","organizations_url":"https://api.github.com/users/saket/orgs","repos_url":"https://api.github.com/users/saket/repos","events_url":"https://api.github.com/users/saket/events{/privacy}","received_events_url":"https://api.github.com/users/saket/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-09-20T10:31:58Z","updated_at":"2018-09-21T10:15:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fcfee062b66c41be8dde4324b4a8a7bbd13b0aa8","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/simpledotorg/simple-android/pulls/264/commits","review_comments_url":"https://api.github.com/repos/simpledotorg/simple-android/pulls/264/comments","review_comment_url":"https://api.github.com/repos/simpledotorg/simple-android/pulls/comments{/number}","comments_url":"https://api.github.com/repos/simpledotorg/simple-android/issues/264/comments","statuses_url":"https://api.github.com/repos/simpledotorg/simple-android/statuses/05565df7340ee9abc89a4acf4414712f87c36b9d","head":{"label":"simpledotorg:sn/20sep-patient-lookup","ref":"sn/20sep-patient-lookup","sha":"05565df7340ee9abc89a4acf4414712f87c36b9d","user":{"login":"simpledotorg","id":40570251,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQwNTcwMjUx","avatar_url":"https://avatars0.githubusercontent.com/u/40570251?v=4","gravatar_id":"","url":"https://api.github.com/users/simpledotorg","html_url":"https://github.com/simpledotorg","followers_url":"https://api.github.com/users/simpledotorg/followers","following_url":"https://api.github.com/users/simpledotorg/following{/other_user}","gists_url":"https://api.github.com/users/simpledotorg/gists{/gist_id}","starred_url":"https://api.github.com/users/simpledotorg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simpledotorg/subscriptions","organizations_url":"https://api.github.com/users/simpledotorg/orgs","repos_url":"https://api.github.com/users/simpledotorg/repos","events_url":"https://api.github.com/users/simpledotorg/events{/privacy}","received_events_url":"https://api.github.com/users/simpledotorg/received_events","type":"Organization","site_admin":false},"repo":{"id":132515649,"node_id":"MDEwOlJlcG9zaXRvcnkxMzI1MTU2NDk=","name":"simple-android","full_name":"simpledotorg/simple-android","private":false,"owner":{"login":"simpledotorg","id":40570251,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQwNTcwMjUx","avatar_url":"https://avatars0.githubusercontent.com/u/40570251?v=4","gravatar_id":"","url":"https://api.github.com/users/simpledotorg","html_url":"https://github.com/simpledotorg","followers_url":"https://api.github.com/users/simpledotorg/followers","following_url":"https://api.github.com/users/simpledotorg/following{/other_user}","gists_url":"https://api.github.com/users/simpledotorg/gists{/gist_id}","starred_url":"https://api.github.com/users/simpledotorg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simpledotorg/subscriptions","organizations_url":"https://api.github.com/users/simpledotorg/orgs","repos_url":"https://api.github.com/users/simpledotorg/repos","events_url":"https://api.github.com/users/simpledotorg/events{/privacy}","received_events_url":"https://api.github.com/users/simpledotorg/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/simpledotorg/simple-android","description":"An Android app for recording blood pressure measurements","fork":false,"url":"https://api.github.com/repos/simpledotorg/simple-android","forks_url":"https://api.github.com/repos/simpledotorg/simple-android/forks","keys_url":"https://api.github.com/repos/simpledotorg/simple-android/keys{/key_id}","collaborators_url":"https://api.github.com/repos/simpledotorg/simple-android/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/simpledotorg/simple-android/teams","hooks_url":"https://api.github.com/repos/simpledotorg/simple-android/hooks","issue_events_url":"https://api.github.com/repos/simpledotorg/simple-android/issues/events{/number}","events_url":"https://api.github.com/repos/simpledotorg/simple-android/events","assignees_url":"https://api.github.com/repos/simpledotorg/simple-android/assignees{/user}","branches_url":"https://api.github.com/repos/simpledotorg/simple-android/branches{/branch}","tags_url":"https://api.github.com/repos/simpledotorg/simple-android/tags","blobs_url":"https://api.github.com/repos/simpledotorg/simple-android/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/simpledotorg/simple-android/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/simpledotorg/simple-android/git/refs{/sha}","trees_url":"https://api.github.com/repos/simpledotorg/simple-android/git/trees{/sha}","statuses_url":"https://api.github.com/repos/simpledotorg/simple-android/statuses/{sha}","languages_url":"https://api.github.com/repos/simpledotorg/simple-android/languages","stargazers_url":"https://api.github.com/repos/simpledotorg/simple-android/stargazers","contributors_url":"https://api.github.com/repos/simpledotorg/simple-android/contributors","subscribers_url":"https://api.github.com/repos/simpledotorg/simple-android/subscribers","subscription_url":"https://api.github.com/repos/simpledotorg/simple-android/subscription","commits_url":"https://api.github.com/repos/simpledotorg/simple-android/commits{/sha}","git_commits_url":"https://api.github.com/repos/simpledotorg/simple-android/git/commits{/sha}","comments_url":"https://api.github.com/repos/simpledotorg/simple-android/comments{/number}","issue_comment_url":"https://api.github.com/repos/simpledotorg/simple-android/issues/comments{/number}","contents_url":"https://api.github.com/repos/simpledotorg/simple-android/contents/{+path}","compare_url":"https://api.github.com/repos/simpledotorg/simple-android/compare/{base}...{head}","merges_url":"https://api.github.com/repos/simpledotorg/simple-android/merges","archive_url":"https://api.github.com/repos/simpledotorg/simple-android/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/simpledotorg/simple-android/downloads","issues_url":"https://api.github.com/repos/simpledotorg/simple-android/issues{/number}","pulls_url":"https://api.github.com/repos/simpledotorg/simple-android/pulls{/number}","milestones_url":"https://api.github.com/repos/simpledotorg/simple-android/milestones{/number}","notifications_url":"https://api.github.com/repos/simpledotorg/simple-android/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/simpledotorg/simple-android/labels{/name}","releases_url":"https://api.github.com/repos/simpledotorg/simple-android/releases{/id}","deployments_url":"https://api.github.com/repos/simpledotorg/simple-android/deployments","created_at":"2018-05-07T20:56:54Z","updated_at":"2018-09-21T08:46:58Z","pushed_at":"2018-09-21T09:34:34Z","git_url":"git://github.com/simpledotorg/simple-android.git","ssh_url":"git@github.com:simpledotorg/simple-android.git","clone_url":"https://github.com/simpledotorg/simple-android.git","svn_url":"https://github.com/simpledotorg/simple-android","homepage":"https://www.simple.org","size":4811,"stargazers_count":23,"watchers_count":23,"language":"Kotlin","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"archived":false,"open_issues_count":71,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":3,"open_issues":71,"watchers":23,"default_branch":"master"}},"base":{"label":"simpledotorg:master","ref":"master","sha":"2496ad0018aee2a5e25f4498f8c1e4c76329f8c1","user":{"login":"simpledotorg","id":40570251,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQwNTcwMjUx","avatar_url":"https://avatars0.githubusercontent.com/u/40570251?v=4","gravatar_id":"","url":"https://api.github.com/users/simpledotorg","html_url":"https://github.com/simpledotorg","followers_url":"https://api.github.com/users/simpledotorg/followers","following_url":"https://api.github.com/users/simpledotorg/following{/other_user}","gists_url":"https://api.github.com/users/simpledotorg/gists{/gist_id}","starred_url":"https://api.github.com/users/simpledotorg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simpledotorg/subscriptions","organizations_url":"https://api.github.com/users/simpledotorg/orgs","repos_url":"https://api.github.com/users/simpledotorg/repos","events_url":"https://api.github.com/users/simpledotorg/events{/privacy}","received_events_url":"https://api.github.com/users/simpledotorg/received_events","type":"Organization","site_admin":false},"repo":{"id":132515649,"node_id":"MDEwOlJlcG9zaXRvcnkxMzI1MTU2NDk=","name":"simple-android","full_name":"simpledotorg/simple-android","private":false,"owner":{"login":"simpledotorg","id":40570251,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQwNTcwMjUx","avatar_url":"https://avatars0.githubusercontent.com/u/40570251?v=4","gravatar_id":"","url":"https://api.github.com/users/simpledotorg","html_url":"https://github.com/simpledotorg","followers_url":"https://api.github.com/users/simpledotorg/followers","following_url":"https://api.github.com/users/simpledotorg/following{/other_user}","gists_url":"https://api.github.com/users/simpledotorg/gists{/gist_id}","starred_url":"https://api.github.com/users/simpledotorg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simpledotorg/subscriptions","organizations_url":"https://api.github.com/users/simpledotorg/orgs","repos_url":"https://api.github.com/users/simpledotorg/repos","events_url":"https://api.github.com/users/simpledotorg/events{/privacy}","received_events_url":"https://api.github.com/users/simpledotorg/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/simpledotorg/simple-android","description":"An Android app for recording blood pressure measurements","fork":false,"url":"https://api.github.com/repos/simpledotorg/simple-android","forks_url":"https://api.github.com/repos/simpledotorg/simple-android/forks","keys_url":"https://api.github.com/repos/simpledotorg/simple-android/keys{/key_id}","collaborators_url":"https://api.github.com/repos/simpledotorg/simple-android/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/simpledotorg/simple-android/teams","hooks_url":"https://api.github.com/repos/simpledotorg/simple-android/hooks","issue_events_url":"https://api.github.com/repos/simpledotorg/simple-android/issues/events{/number}","events_url":"https://api.github.com/repos/simpledotorg/simple-android/events","assignees_url":"https://api.github.com/repos/simpledotorg/simple-android/assignees{/user}","branches_url":"https://api.github.com/repos/simpledotorg/simple-android/branches{/branch}","tags_url":"https://api.github.com/repos/simpledotorg/simple-android/tags","blobs_url":"https://api.github.com/repos/simpledotorg/simple-android/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/simpledotorg/simple-android/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/simpledotorg/simple-android/git/refs{/sha}","trees_url":"https://api.github.com/repos/simpledotorg/simple-android/git/trees{/sha}","statuses_url":"https://api.github.com/repos/simpledotorg/simple-android/statuses/{sha}","languages_url":"https://api.github.com/repos/simpledotorg/simple-android/languages","stargazers_url":"https://api.github.com/repos/simpledotorg/simple-android/stargazers","contributors_url":"https://api.github.com/repos/simpledotorg/simple-android/contributors","subscribers_url":"https://api.github.com/repos/simpledotorg/simple-android/subscribers","subscription_url":"https://api.github.com/repos/simpledotorg/simple-android/subscription","commits_url":"https://api.github.com/repos/simpledotorg/simple-android/commits{/sha}","git_commits_url":"https://api.github.com/repos/simpledotorg/simple-android/git/commits{/sha}","comments_url":"https://api.github.com/repos/simpledotorg/simple-android/comments{/number}","issue_comment_url":"https://api.github.com/repos/simpledotorg/simple-android/issues/comments{/number}","contents_url":"https://api.github.com/repos/simpledotorg/simple-android/contents/{+path}","compare_url":"https://api.github.com/repos/simpledotorg/simple-android/compare/{base}...{head}","merges_url":"https://api.github.com/repos/simpledotorg/simple-android/merges","archive_url":"https://api.github.com/repos/simpledotorg/simple-android/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/simpledotorg/simple-android/downloads","issues_url":"https://api.github.com/repos/simpledotorg/simple-android/issues{/number}","pulls_url":"https://api.github.com/repos/simpledotorg/simple-android/pulls{/number}","milestones_url":"https://api.github.com/repos/simpledotorg/simple-android/milestones{/number}","notifications_url":"https://api.github.com/repos/simpledotorg/simple-android/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/simpledotorg/simple-android/labels{/name}","releases_url":"https://api.github.com/repos/simpledotorg/simple-android/releases{/id}","deployments_url":"https://api.github.com/repos/simpledotorg/simple-android/deployments","created_at":"2018-05-07T20:56:54Z","updated_at":"2018-09-21T08:46:58Z","pushed_at":"2018-09-21T09:34:34Z","git_url":"git://github.com/simpledotorg/simple-android.git","ssh_url":"git@github.com:simpledotorg/simple-android.git","clone_url":"https://github.com/simpledotorg/simple-android.git","svn_url":"https://github.com/simpledotorg/simple-android","homepage":"https://www.simple.org","size":4811,"stargazers_count":23,"watchers_count":23,"language":"Kotlin","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"archived":false,"open_issues_count":71,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":3,"open_issues":71,"watchers":23,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/simpledotorg/simple-android/pulls/264"},"html":{"href":"https://github.com/simpledotorg/simple-android/pull/264"},"issue":{"href":"https://api.github.com/repos/simpledotorg/simple-android/issues/264"},"comments":{"href":"https://api.github.com/repos/simpledotorg/simple-android/issues/264/comments"},"review_comments":{"href":"https://api.github.com/repos/simpledotorg/simple-android/pulls/264/comments"},"review_comment":{"href":"https://api.github.com/repos/simpledotorg/simple-android/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/simpledotorg/simple-android/pulls/264/commits"},"statuses":{"href":"https://api.github.com/repos/simpledotorg/simple-android/statuses/05565df7340ee9abc89a4acf4414712f87c36b9d"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"vinaysshenoy"}}