Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(#8204): Add feature to support adding phone number when registering patients #8369

Merged
merged 61 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from 56 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
13e3133
Added sms form in app settings, trigger in registration and unit test…
PrjShrestha May 16, 2023
0db854d
Reverting registration.js tests
PrjShrestha May 16, 2023
6ab0253
registration.js add phone number function added
PrjShrestha May 16, 2023
439cb8b
Added phone_number parser using google lib and changed app settings t…
May 18, 2023
1184519
phone number length validation
May 19, 2023
61de363
Added support for phone number and concrete unit tests
May 31, 2023
0ffa8c8
Added add_age trigger as well as country code validadtion at registra…
May 31, 2023
4a89954
Added sms parser tests and registration.js phone number funciton
Jun 1, 2023
3977367
registration test for valid phone number
Jun 14, 2023
49086cf
added phone number and age adding code to addpatient funtion in regis…
PrjShrestha Jun 29, 2023
86e53ed
registration unit tests
PrjShrestha Jul 6, 2023
ae62cc2
added unit test to test that patient isn't created when phone is wrong
PrjShrestha Jul 6, 2023
0185462
removed debugger and console.log
PrjShrestha Jul 6, 2023
614a763
eslint issue fixes 1
PrjShrestha Jul 6, 2023
ad94523
eslint Fixes 2
PrjShrestha Jul 6, 2023
e2fa163
confirming to eslint standards to pass build
PrjShrestha Jul 10, 2023
3e607ed
ident fix
PrjShrestha Jul 11, 2023
2639a19
Reverted app settigns added phone duplicate turn of on on appsettings.
PrjShrestha Jul 14, 2023
5a447b7
registration.js false positive and negative fix
PrjShrestha Jul 14, 2023
08f7158
added duplicate phone optional logic and changed phone number to norm…
PrjShrestha Jul 19, 2023
4cef416
"making double quotes to single quote from from-definition"
PrjShrestha Jul 19, 2023
b2e617c
unique phone check in both registration and validation.js
PrjShrestha Jul 24, 2023
db5b54c
Fixed validation.js function
PrjShrestha Jul 24, 2023
1abff00
Doing validation for unique in before transition is run
PrjShrestha Jul 25, 2023
3eb6a9d
added tests for unique phone validation
PrjShrestha Jul 25, 2023
1480334
eslint fixes
PrjShrestha Jul 26, 2023
e7a2e66
Changes to smsparser after reading form from form definitions
PrjShrestha Jul 26, 2023
495a874
Added translations and dynamic error messaging tried to fix registrat…
PrjShrestha Jul 26, 2023
551c4a2
Removing it.only
PrjShrestha Jul 26, 2023
9c59f40
Update tests/integration/sentinel/transitions/registration.spec.js
1yuv Jul 26, 2023
4ce8a19
code reivew changes mainly translations
PrjShrestha Jul 27, 2023
72ec2f0
Merge branch '8204' of https://github.com/PrjShrestha/cht-core into 8204
PrjShrestha Jul 27, 2023
ef55ff5
code review changes
PrjShrestha Jul 27, 2023
12c59de
Apply suggestions from code review
1yuv Jul 31, 2023
222cafa
Code reivew changes
PrjShrestha Jul 31, 2023
a544cf6
Merge branch '8204' of https://github.com/PrjShrestha/cht-core into 8204
PrjShrestha Jul 31, 2023
82c9b7d
renamed file test-stubs and changed references
PrjShrestha Jul 31, 2023
b4894fa
Merge branch 'master' into 8204
PrjShrestha Aug 1, 2023
4d629cc
Update shared-libs/transitions/src/transitions/registration.js Camel …
PrjShrestha Aug 2, 2023
1ec2430
Code review changes
PrjShrestha Aug 2, 2023
8c79231
Merge branch 'master' into 8204
PrjShrestha Aug 2, 2023
95374aa
eslint fixes
PrjShrestha Aug 3, 2023
46a4f2a
Code reivew changes form-definitions and code comments
PrjShrestha Aug 4, 2023
a4b55af
passed invalid phone number form sms parser and added valid phone val…
PrjShrestha Aug 8, 2023
b5378f4
phone validation in add_patient itself
PrjShrestha Aug 8, 2023
a88e85b
Implemented suggestion to remove add_phone_number trigger and do the …
PrjShrestha Aug 8, 2023
807caf4
Changed sms parser tests and made sms parser return invalid number in…
PrjShrestha Aug 8, 2023
1bf6514
added null checks on getpatientphonefield function
PrjShrestha Aug 8, 2023
3f35ad1
added null check on formdef
PrjShrestha Aug 8, 2023
85d2065
Checking if updated config fixes problem, cannot run unit tests locally
PrjShrestha Aug 8, 2023
470601c
Apply suggestions from Diana's code review
PrjShrestha Aug 9, 2023
7f266e2
code review changes
PrjShrestha Aug 9, 2023
5123c8a
added null checks to see if it passes tests
PrjShrestha Aug 10, 2023
f076a63
Added tests to test add_patient trigger changes
PrjShrestha Aug 10, 2023
325efed
Code review feedbacks and added unit test for getphonefield function …
PrjShrestha Aug 10, 2023
c05ab7a
Upgraded eslint versoin to ecma for optional chaining support, added …
PrjShrestha Aug 10, 2023
e06fbe9
Merge branch 'master' into 8204
PrjShrestha Aug 15, 2023
45d74b5
Resolve commit
PrjShrestha Aug 15, 2023
c5eacaf
Aded nepali phone number support
PrjShrestha Aug 15, 2023
49a05b3
used const value instead or reading from object
PrjShrestha Aug 15, 2023
9e3116f
Adding comment to trigger build run
PrjShrestha Aug 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions api/resources/translations/messages-en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,7 @@ messages.f.report_accepted = Thank you for flagging {{patient_name}} ({{patient_
messages.f.report_accepted_parent = {{patient_name}} ({{patient_id}}) was flagged by {{contact.name}} ({{contact.phone}}) for further attention.
messages.generic.no_provided_patient_id = External ID number support is configured, but is not found on document in the configured location.
messages.generic.provided_patient_id_not_unique = The provided ID number is already used.
messages.generic.provided_phone_not_valid = The provided phone is not valid.
messages.generic.registration_accepted = Thank you {{contact.name}} for registering {{patient_name}}. Their ID is {{patient_id}}.
messages.generic.registration_not_found = No person with ID number '{{patient_id}}' found. Verify the ID and resend the message.
messages.generic.report_accepted = Thank you {{contact.name}}, {{form}} for {{patient_name}} ({{patient_id}}) has been recorded.
Expand Down
3 changes: 2 additions & 1 deletion api/resources/translations/messages-ne.properties
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,8 @@ messages.errors.patient.missing =
messages.f.report_accepted =
messages.f.report_accepted_parent =
messages.generic.no_provided_patient_id =
messages.generic.provided_patient_id_not_unique =
messages.generic.provided_patient_id_not_unique = तपाइँले पठाउनुभएको आईडी पहिल्यै प्रयोगमा छ।
messages.generic.provided_phone_not_valid = तपाइँले पठाउनुभएको फोन नम्बर मिलेन । फेरी प्रयास गर्नुहोस्।
messages.generic.registration_accepted =
messages.generic.registration_not_found =
messages.generic.report_accepted =
Expand Down
16 changes: 15 additions & 1 deletion api/src/services/report/smsparser.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const textformsParser = require('./textforms-parser');
const logger = require('../../logger');
const moment = require('moment');
const bs = require('bikram-sambat');
const phoneNumberParser = require('@medic/phone-number');

const MUVUKU_REGEX = /^\s*([A-Za-z]?\d)!.+!.+/;
// matches invisible characters that can mess up our parsing
Expand Down Expand Up @@ -209,9 +210,22 @@ const fieldParsers = {
month: (raw) => {
// keep months integers, not their list value.
return parseNum(stripInvisibleCharacters(raw));
},
phone_number: (raw) => {
const formattedAndValidatedPhone = phoneNumberParser.normalize(config.getAll(), raw);
if (formattedAndValidatedPhone) {
return formattedAndValidatedPhone;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PrjShrestha , would you mind adding Nepali digit supporting code for this type as well? Here's the sample PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}
logger.warn(`The provided phone number ${raw} is invalid`);

// Returning raw here becuase what to do with invalid phone
// is defined in transitions so error will be thrown there if required.
// Warning is logged just in case.
return raw;
}
};

//selects parser by field type and parses and validates the given data.
exports.parseField = (field, raw, key) => {
const parser = fieldParsers[field.type];
if (!parser) {
Expand Down Expand Up @@ -281,7 +295,7 @@ exports.parse = (def, doc) => {
}
}

if(aggregateBSDateField) {
if (aggregateBSDateField) {
let bsYear;
let bsMonth = 1;
let bsDay = 1;
Expand Down
13 changes: 13 additions & 0 deletions api/tests/form-definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -791,5 +791,18 @@ exports.forms = {
required: true
}
}
},
NP: {
meta: {
code: 'NP'
},
fields: {
patient_age: {
type: 'integer'
},
phone_number: {
type: 'phone_number'
}
}
}
};
Loading