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

Handle multiple phone number formats in search #2232

Merged
merged 7 commits into from
Jul 30, 2024
Merged

Handle multiple phone number formats in search #2232

merged 7 commits into from
Jul 30, 2024

Conversation

bamader
Copy link
Collaborator

@bamader bamader commented Jul 24, 2024

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.

Copy link
Collaborator

@DanPaseltiner DanPaseltiner left a 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.

Comment on lines 37 to 45
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;
}

Copy link
Collaborator

@DanPaseltiner DanPaseltiner Jul 25, 2024

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.

Copy link
Collaborator Author

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.

Copy link
Collaborator

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.

Copy link
Collaborator

@robertandremitchell robertandremitchell left a comment

Choose a reason for hiding this comment

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

looks good!

@bamader bamader added this pull request to the merge queue Jul 30, 2024
Merged via the queue into main with commit b68f6d7 Jul 30, 2024
11 checks passed
@bamader bamader deleted the query-phone branch July 30, 2024 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement phone number search
3 participants