-
Notifications
You must be signed in to change notification settings - Fork 14
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
Handle multiple phone number formats in search #2232
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks really great, but we need to make sure that we can handle phone numbers when provided via either the UI or API.
export function FormatPhoneAsDigits(givenPhone: string) { | ||
// Start by getting rid of all existing separators for a clean slate | ||
const newPhone: string = givenPhone.replace(/\D/g, ""); | ||
if (newPhone.length != 10) { | ||
return givenPhone; | ||
} | ||
return newPhone; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should move this functionality into the query service or utils so that it is available for use on the API side of things as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh duh, I was so focused on the different formats I forgot the API side. I'll get it sorted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries! I was starring at this for a while before I realized what was bugging me about it. We are building two interfaces that expose the same functionality so we just need to keep that in mind with structuring the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good!
PULL REQUEST
Summary
This PR handles the MVP of phone number formatting for our query search; the phone number passed in the search field gets stripped to just be digits, and then based on some profiling of the most common formatting schemes present in HAPI, Epic, and Cerner, we spit back out an array of possible formattings with some combinations of spaces, dashes, and parentheticals. These all get logically
OR
'ed in the query URL search proper.Related Issue
Fixes #1840
Additional Information
The idea for this approach came out of some conversations with Dan, but the idea is to basically take a much wider shotgun-style approach to hitting phone numbers, since the big FHIR servers all enforce exact only matching on the telecom field (that means we need to perfectly hit how they distribute all their delimiters, parentheses, etc.). We're making the choice right now to kind of ignore country code parsing--eventually, we'll want to have a separate country code field that starts off with a default value of 1 (for US numbers) because then we can more explicitly handle country digits. If we tried to handle it now, we run into some very hairy and not-worth-it-to-sort-out cases. For example, there's no way to tell if a number with 10 digits includes a country code and omits local-area routing, or if it's some other partial phone number, etc. So we're just gonna ignore it for this PR. Later on though, we can also use the country code text input field for switch-statement logic to check different formatting options more common to international numbers. That code will just have to come after we have a country code box.