-
Notifications
You must be signed in to change notification settings - Fork 15
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
fix: add pager (and others) to contact info #2936
Changes from 11 commits
96fd5e1
e83f0cc
239f496
8e1b8a3
ec1cf90
7bfb92d
7b04236
8b19376
d704fac
8fff3a0
89c1505
67b3c02
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -563,36 +563,64 @@ export const removeHtmlElements = (element: string): string => { | |
return element.replace(regex, ""); | ||
}; | ||
|
||
const contactSortOrder = [ | ||
"phone", | ||
"fax", | ||
"sms", | ||
"pager", | ||
"url", | ||
"email", | ||
"other", | ||
"", | ||
]; | ||
|
||
/** | ||
* Converts contact points into an array of phone numbers and emails | ||
* Sorts an array of contact points in display order (`contactSortOrder`). | ||
* @param contactPoints - array of contact points | ||
* @returns array of phone numbers and emails | ||
* @returns sorted array of contact points | ||
*/ | ||
const sortContacts = (contactPoints: ContactPoint[]): ContactPoint[] => { | ||
return contactPoints.sort((a, b) => { | ||
const aInd = | ||
contactSortOrder.indexOf(a.system ?? "") ?? contactSortOrder.length; | ||
const bInd = | ||
contactSortOrder.indexOf(b.system ?? "") ?? contactSortOrder.length; | ||
return aInd - bInd; | ||
}); | ||
}; | ||
|
||
/** | ||
* Converts contact points into an array of phone numbers and emails and returns them | ||
* in a consistent sort order for display. | ||
* @param contactPoints - array of contact points | ||
* @returns string of formatted and sorted phone numbers and emails | ||
*/ | ||
export const formatContactPoint = ( | ||
contactPoints: ContactPoint[] | undefined, | ||
): string[] => { | ||
): string => { | ||
if (!contactPoints || !contactPoints.length) { | ||
return []; | ||
return ""; | ||
} | ||
const contactArr: string[] = []; | ||
for (const contactPoint of contactPoints) { | ||
if (contactPoint.system === "phone" && contactPoint.value) { | ||
const phoneNumberUse = toSentenceCase(contactPoint.use); | ||
contactArr.push( | ||
[phoneNumberUse, formatPhoneNumber(contactPoint.value)] | ||
.filter((c) => c) | ||
.join(": "), | ||
); | ||
} else if (contactPoint.system === "email" && contactPoint.value) { | ||
contactArr.push(contactPoint.value); | ||
} else if (contactPoint.system === "fax" && contactPoint.value) { | ||
const faxNumberUse = toSentenceCase(contactPoint.use ?? ""); | ||
for (const { system, value, use } of sortContacts(contactPoints)) { | ||
// No value, nothing to format/show | ||
if (!value) continue; | ||
|
||
if (system === "phone") { | ||
const phoneNumberUse = toSentenceCase(use); | ||
contactArr.push( | ||
[faxNumberUse, "Fax:", formatPhoneNumber(contactPoint.value ?? "")] | ||
.join(" ") | ||
.trim(), | ||
[phoneNumberUse, formatPhoneNumber(value)].filter((c) => c).join(": "), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, because There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ooh, good call! Thanks!! |
||
); | ||
} else if (system === "email") { | ||
contactArr.push(value); | ||
} else { | ||
const _use = toSentenceCase(use ?? ""); | ||
const _system = toSentenceCase(system ?? ""); | ||
const _value = ["fax", "pager", "sms"].includes(system as string) | ||
? formatPhoneNumber(value) | ||
: value; | ||
contactArr.push([_use, `${_system}:`, _value].join(" ").trim()); | ||
} | ||
} | ||
return contactArr; | ||
return contactArr.join("\n"); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build | ||
|
||
# Download FHIR-Converter | ||
RUN git clone https://github.com/skylight-hq/FHIR-Converter.git --branch v7.0-skylight-11 --single-branch /build/FHIR-Converter | ||
RUN git clone https://github.com/skylight-hq/FHIR-Converter.git --branch mcm/fix-pager --single-branch /build/FHIR-Converter | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't think you meant to commit this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh you might've left this in temporarily for testing -- TY! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sorry about that - I usually leave a comment to myself to update it to a released version before merging
mcmcgrath13 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
WORKDIR /build/FHIR-Converter | ||
|
||
|
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.
Could you add a JSDoc for this helper function?
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.
added!