{"action":"created","comment":{"url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/pulls/comments/70955283","id":70955283,"diff_hunk":"@@ -57,42 +126,78 @@ go.app = function() {\n \n         self.add(\"state_start\", function(name) {\n             self.im.user.answers = {};  // reset answers\n-            return self.states.create(\"state_check_details\");\n-        });\n-\n-        // interstitial - checks details already saved in db\n-        self.add(\"state_check_details\", function(name) {\n-            return self.states.create(\"state_consent\");\n-            // msisdn should be registered and active(?) on MomConnect...\n-            /*.search_by_address({\"msisdn\": self.im.user.addr}, self.im, null)\n-                .then(function(search) {\n-                    // check whether user is already registered\n-                    if (search.results.length > 0) {  // add necessary conditions to check\n-                        var identity = search.results[0];\n-                        console.log(identity);\n-\n-                        // check if lang, consent and dob already stored and set\n-                        self.im.set_lang(identity.extra.language_choice);\n-                        self.im.user.set_answer(\"consent\", identity.extra.consent);\n-                        self.im.user.set_answer(\"dob\", identity.extra.dob;\n-\n-                        // !consent_already_given\n-                        if (self.im.user.consent) {\n-                            return self.states.create(\"state_consent\", dob_already_stored);\n-                        }\n \n-                        // !dob_already_stored\n-                        if (self.im.user.dob) {\n-                            return self.states.create(\"state_birth_year\");\n-                        }\n+            return self.states.create(\"state_check_PMTCT_subscription\");\n+        });\n \n-                        return self.states.create(\"state_hiv_messages\");\n+        // interstitial\n+        self.add(\"state_check_PMTCT_subscription\", function(name) {\n+            var msisdn = utils.normalize_msisdn(self.im.user.addr, '27');\n+            self.im.user.set_answer(\"msisdn\", msisdn);\n+\n+            return is.get_or_create_identity({\"msisdn\": msisdn})\n+                .then(function(identity) {\n+                    if (identity.details.pmtct) {  // on new system and PMTCT?\n+                        // optout\n+                        return self.states.create(\"state_optout_reason_menu\");\n+                    } else {  // register\n+                        return sbm.has_active_subscription(identity.id)","path":"src/ussd_pmtct.js","position":136,"original_position":136,"commit_id":"b4674a9befdbec249da1e3cee0473312064a9547","original_commit_id":"b4674a9befdbec249da1e3cee0473312064a9547","user":{"login":"gsvr","id":3907663,"avatar_url":"https://avatars.githubusercontent.com/u/3907663?v=3","gravatar_id":"","url":"https://api.github.com/users/gsvr","html_url":"https://github.com/gsvr","followers_url":"https://api.github.com/users/gsvr/followers","following_url":"https://api.github.com/users/gsvr/following{/other_user}","gists_url":"https://api.github.com/users/gsvr/gists{/gist_id}","starred_url":"https://api.github.com/users/gsvr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gsvr/subscriptions","organizations_url":"https://api.github.com/users/gsvr/orgs","repos_url":"https://api.github.com/users/gsvr/repos","events_url":"https://api.github.com/users/gsvr/events{/privacy}","received_events_url":"https://api.github.com/users/gsvr/received_events","type":"User","site_admin":false},"body":"This will cause us headaches in the future if we're not careful. I'm okay with letting it slide for now for the demo since the only active subscriptions in the new system will be PMTCT subscriptions, but we really should be checking for an active PMTCT subscription, not just any active subscription.  Put a Todo in here and open an issue for that and we'll handle it next week.","created_at":"2016-07-15T10:55:36Z","updated_at":"2016-07-15T10:55:36Z","html_url":"https://github.com/praekeltfoundation/ndoh-jsbox/pull/7#discussion_r70955283","pull_request_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/pulls/7","_links":{"self":{"href":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/pulls/comments/70955283"},"html":{"href":"https://github.com/praekeltfoundation/ndoh-jsbox/pull/7#discussion_r70955283"},"pull_request":{"href":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/pulls/7"}}},"pull_request":{"url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/pulls/7","id":77229065,"html_url":"https://github.com/praekeltfoundation/ndoh-jsbox/pull/7","diff_url":"https://github.com/praekeltfoundation/ndoh-jsbox/pull/7.diff","patch_url":"https://github.com/praekeltfoundation/ndoh-jsbox/pull/7.patch","issue_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/issues/7","number":7,"state":"open","locked":false,"title":"Add PMTCT registration utils and functionality","user":{"login":"NicolaasDieBaas","id":16633608,"avatar_url":"https://avatars.githubusercontent.com/u/16633608?v=3","gravatar_id":"","url":"https://api.github.com/users/NicolaasDieBaas","html_url":"https://github.com/NicolaasDieBaas","followers_url":"https://api.github.com/users/NicolaasDieBaas/followers","following_url":"https://api.github.com/users/NicolaasDieBaas/following{/other_user}","gists_url":"https://api.github.com/users/NicolaasDieBaas/gists{/gist_id}","starred_url":"https://api.github.com/users/NicolaasDieBaas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NicolaasDieBaas/subscriptions","organizations_url":"https://api.github.com/users/NicolaasDieBaas/orgs","repos_url":"https://api.github.com/users/NicolaasDieBaas/repos","events_url":"https://api.github.com/users/NicolaasDieBaas/events{/privacy}","received_events_url":"https://api.github.com/users/NicolaasDieBaas/received_events","type":"User","site_admin":false},"body":"- [x] assess functionality requirements\r\n  - [x] service api calls\r\n  - [x] util functions\r\n- [ ] validation & error handling","created_at":"2016-07-13T04:35:39Z","updated_at":"2016-07-15T10:55:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"40512942905b5c38be5ea09937ae41c2bccace83","assignee":{"login":"NicolaasDieBaas","id":16633608,"avatar_url":"https://avatars.githubusercontent.com/u/16633608?v=3","gravatar_id":"","url":"https://api.github.com/users/NicolaasDieBaas","html_url":"https://github.com/NicolaasDieBaas","followers_url":"https://api.github.com/users/NicolaasDieBaas/followers","following_url":"https://api.github.com/users/NicolaasDieBaas/following{/other_user}","gists_url":"https://api.github.com/users/NicolaasDieBaas/gists{/gist_id}","starred_url":"https://api.github.com/users/NicolaasDieBaas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NicolaasDieBaas/subscriptions","organizations_url":"https://api.github.com/users/NicolaasDieBaas/orgs","repos_url":"https://api.github.com/users/NicolaasDieBaas/repos","events_url":"https://api.github.com/users/NicolaasDieBaas/events{/privacy}","received_events_url":"https://api.github.com/users/NicolaasDieBaas/received_events","type":"User","site_admin":false},"assignees":[{"login":"NicolaasDieBaas","id":16633608,"avatar_url":"https://avatars.githubusercontent.com/u/16633608?v=3","gravatar_id":"","url":"https://api.github.com/users/NicolaasDieBaas","html_url":"https://github.com/NicolaasDieBaas","followers_url":"https://api.github.com/users/NicolaasDieBaas/followers","following_url":"https://api.github.com/users/NicolaasDieBaas/following{/other_user}","gists_url":"https://api.github.com/users/NicolaasDieBaas/gists{/gist_id}","starred_url":"https://api.github.com/users/NicolaasDieBaas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NicolaasDieBaas/subscriptions","organizations_url":"https://api.github.com/users/NicolaasDieBaas/orgs","repos_url":"https://api.github.com/users/NicolaasDieBaas/repos","events_url":"https://api.github.com/users/NicolaasDieBaas/events{/privacy}","received_events_url":"https://api.github.com/users/NicolaasDieBaas/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/pulls/7/commits","review_comments_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/pulls/7/comments","review_comment_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/pulls/comments{/number}","comments_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/issues/7/comments","statuses_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/statuses/b4674a9befdbec249da1e3cee0473312064a9547","head":{"label":"praekeltfoundation:feature/issue-7-add-pmtct-utils","ref":"feature/issue-7-add-pmtct-utils","sha":"b4674a9befdbec249da1e3cee0473312064a9547","user":{"login":"praekeltfoundation","id":15786759,"avatar_url":"https://avatars.githubusercontent.com/u/15786759?v=3","gravatar_id":"","url":"https://api.github.com/users/praekeltfoundation","html_url":"https://github.com/praekeltfoundation","followers_url":"https://api.github.com/users/praekeltfoundation/followers","following_url":"https://api.github.com/users/praekeltfoundation/following{/other_user}","gists_url":"https://api.github.com/users/praekeltfoundation/gists{/gist_id}","starred_url":"https://api.github.com/users/praekeltfoundation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/praekeltfoundation/subscriptions","organizations_url":"https://api.github.com/users/praekeltfoundation/orgs","repos_url":"https://api.github.com/users/praekeltfoundation/repos","events_url":"https://api.github.com/users/praekeltfoundation/events{/privacy}","received_events_url":"https://api.github.com/users/praekeltfoundation/received_events","type":"Organization","site_admin":false},"repo":{"id":61732866,"name":"ndoh-jsbox","full_name":"praekeltfoundation/ndoh-jsbox","owner":{"login":"praekeltfoundation","id":15786759,"avatar_url":"https://avatars.githubusercontent.com/u/15786759?v=3","gravatar_id":"","url":"https://api.github.com/users/praekeltfoundation","html_url":"https://github.com/praekeltfoundation","followers_url":"https://api.github.com/users/praekeltfoundation/followers","following_url":"https://api.github.com/users/praekeltfoundation/following{/other_user}","gists_url":"https://api.github.com/users/praekeltfoundation/gists{/gist_id}","starred_url":"https://api.github.com/users/praekeltfoundation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/praekeltfoundation/subscriptions","organizations_url":"https://api.github.com/users/praekeltfoundation/orgs","repos_url":"https://api.github.com/users/praekeltfoundation/repos","events_url":"https://api.github.com/users/praekeltfoundation/events{/privacy}","received_events_url":"https://api.github.com/users/praekeltfoundation/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/praekeltfoundation/ndoh-jsbox","description":null,"fork":false,"url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox","forks_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/forks","keys_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/keys{/key_id}","collaborators_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/teams","hooks_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/hooks","issue_events_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/issues/events{/number}","events_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/events","assignees_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/assignees{/user}","branches_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/branches{/branch}","tags_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/tags","blobs_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/git/refs{/sha}","trees_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/git/trees{/sha}","statuses_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/statuses/{sha}","languages_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/languages","stargazers_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/stargazers","contributors_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/contributors","subscribers_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/subscribers","subscription_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/subscription","commits_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/commits{/sha}","git_commits_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/git/commits{/sha}","comments_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/comments{/number}","issue_comment_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/issues/comments{/number}","contents_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/contents/{+path}","compare_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/compare/{base}...{head}","merges_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/merges","archive_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/downloads","issues_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/issues{/number}","pulls_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/pulls{/number}","milestones_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/milestones{/number}","notifications_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/labels{/name}","releases_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/releases{/id}","deployments_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/deployments","created_at":"2016-06-22T16:05:38Z","updated_at":"2016-07-08T07:22:12Z","pushed_at":"2016-07-14T21:17:10Z","git_url":"git://github.com/praekeltfoundation/ndoh-jsbox.git","ssh_url":"git@github.com:praekeltfoundation/ndoh-jsbox.git","clone_url":"https://github.com/praekeltfoundation/ndoh-jsbox.git","svn_url":"https://github.com/praekeltfoundation/ndoh-jsbox","homepage":null,"size":173,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":0,"default_branch":"develop"}},"base":{"label":"praekeltfoundation:develop","ref":"develop","sha":"d5c5073c6299559667941c81f41829a6724c7948","user":{"login":"praekeltfoundation","id":15786759,"avatar_url":"https://avatars.githubusercontent.com/u/15786759?v=3","gravatar_id":"","url":"https://api.github.com/users/praekeltfoundation","html_url":"https://github.com/praekeltfoundation","followers_url":"https://api.github.com/users/praekeltfoundation/followers","following_url":"https://api.github.com/users/praekeltfoundation/following{/other_user}","gists_url":"https://api.github.com/users/praekeltfoundation/gists{/gist_id}","starred_url":"https://api.github.com/users/praekeltfoundation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/praekeltfoundation/subscriptions","organizations_url":"https://api.github.com/users/praekeltfoundation/orgs","repos_url":"https://api.github.com/users/praekeltfoundation/repos","events_url":"https://api.github.com/users/praekeltfoundation/events{/privacy}","received_events_url":"https://api.github.com/users/praekeltfoundation/received_events","type":"Organization","site_admin":false},"repo":{"id":61732866,"name":"ndoh-jsbox","full_name":"praekeltfoundation/ndoh-jsbox","owner":{"login":"praekeltfoundation","id":15786759,"avatar_url":"https://avatars.githubusercontent.com/u/15786759?v=3","gravatar_id":"","url":"https://api.github.com/users/praekeltfoundation","html_url":"https://github.com/praekeltfoundation","followers_url":"https://api.github.com/users/praekeltfoundation/followers","following_url":"https://api.github.com/users/praekeltfoundation/following{/other_user}","gists_url":"https://api.github.com/users/praekeltfoundation/gists{/gist_id}","starred_url":"https://api.github.com/users/praekeltfoundation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/praekeltfoundation/subscriptions","organizations_url":"https://api.github.com/users/praekeltfoundation/orgs","repos_url":"https://api.github.com/users/praekeltfoundation/repos","events_url":"https://api.github.com/users/praekeltfoundation/events{/privacy}","received_events_url":"https://api.github.com/users/praekeltfoundation/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/praekeltfoundation/ndoh-jsbox","description":null,"fork":false,"url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox","forks_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/forks","keys_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/keys{/key_id}","collaborators_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/teams","hooks_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/hooks","issue_events_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/issues/events{/number}","events_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/events","assignees_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/assignees{/user}","branches_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/branches{/branch}","tags_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/tags","blobs_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/git/refs{/sha}","trees_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/git/trees{/sha}","statuses_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/statuses/{sha}","languages_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/languages","stargazers_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/stargazers","contributors_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/contributors","subscribers_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/subscribers","subscription_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/subscription","commits_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/commits{/sha}","git_commits_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/git/commits{/sha}","comments_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/comments{/number}","issue_comment_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/issues/comments{/number}","contents_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/contents/{+path}","compare_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/compare/{base}...{head}","merges_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/merges","archive_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/downloads","issues_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/issues{/number}","pulls_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/pulls{/number}","milestones_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/milestones{/number}","notifications_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/labels{/name}","releases_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/releases{/id}","deployments_url":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/deployments","created_at":"2016-06-22T16:05:38Z","updated_at":"2016-07-08T07:22:12Z","pushed_at":"2016-07-14T21:17:10Z","git_url":"git://github.com/praekeltfoundation/ndoh-jsbox.git","ssh_url":"git@github.com:praekeltfoundation/ndoh-jsbox.git","clone_url":"https://github.com/praekeltfoundation/ndoh-jsbox.git","svn_url":"https://github.com/praekeltfoundation/ndoh-jsbox","homepage":null,"size":173,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/pulls/7"},"html":{"href":"https://github.com/praekeltfoundation/ndoh-jsbox/pull/7"},"issue":{"href":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/issues/7"},"comments":{"href":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/issues/7/comments"},"review_comments":{"href":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/pulls/7/comments"},"review_comment":{"href":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/pulls/7/commits"},"statuses":{"href":"https://api.github.com/repos/praekeltfoundation/ndoh-jsbox/statuses/b4674a9befdbec249da1e3cee0473312064a9547"}}}}
{"actor":{"display_login":"gsvr"}}