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

add mutiple names and addresses #2911

Merged
merged 8 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
15 changes: 11 additions & 4 deletions containers/ecr-viewer/src/app/services/evaluateFhirDataService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,18 @@ export const evaluatePatientName = (

if (nameList.length > 0) {
if (isPatientBanner) {
return nameList.map((name) => {
if (name.use === "official") {
if (nameList.length == 1) {
return formatName(
nameList[0].given,
nameList[0].family,
nameList[0].prefix,
nameList[0].suffix,
);
} else {
const name = nameList.find((name) => name.use === "official");
lina-roth marked this conversation as resolved.
Show resolved Hide resolved
if (name)
return formatName(name.given, name.family, name.prefix, name.suffix);
}
})[0];
}
} else if (nameList.length == 1) {
return nameList.map((name) => {
return formatName(name.given, name.family, name.prefix, name.suffix);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ describe("Evaluate Patient Name", () => {
);
expect(actual).toEqual("ABEL CASTILLO");
});
it("should return all 3 of the names", () => {
it("should return all 2 of the names", () => {
const actual = evaluatePatientName(
BundlePatientMultiple as unknown as Bundle,
mappings,
Expand All @@ -337,4 +337,12 @@ describe("Evaluate Patient Name", () => {
);
expect(actual).toEqual("ABEL CASTILLO");
});
it("should only return the official name for the banner", () => {
const actual = evaluatePatientName(
BundleWithPatient as unknown as Bundle,
mappings,
true,
);
expect(actual).toEqual("ABEL CASTILLO");
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ const PatientBanner = ({ bundle, mappings }: PatientBannerProps) => {
return (
<div className="patient-banner">
<span className="patient-banner-name">
{bundle && mappings
? evaluatePatientName(bundle, mappings, true)?.[0]
: ""}
{bundle && mappings ? evaluatePatientName(bundle, mappings, true) : ""}
mcmcgrath13 marked this conversation as resolved.
Show resolved Hide resolved
</span>
<span className="patient-banner-dob">
{bundle && mappings
Expand Down
Loading