Skip to content

Commit

Permalink
Add optional chaining for facility contact address (#2672)
Browse files Browse the repository at this point in the history
* add optional chaining for facility contact address

* change empty value to undefined

* remove misc log

* update encounter and facility fields to snapshot tests
  • Loading branch information
angelathe authored Oct 7, 2024
1 parent 0bcf852 commit 8953e77
Show file tree
Hide file tree
Showing 6 changed files with 230 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ export const evaluateEcrMetadata = (

const eicrReleaseVersion = (fhirBundle: any, mappings: any) => {
const releaseVersion = evaluate(fhirBundle, mappings.eicrReleaseVersion)[0];
console.log(releaseVersion);
if (releaseVersion === "2016-12-01") {
return "R1.1 (2016-12-01)";
} else if (releaseVersion === "2021-01-01") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,8 @@ export const evaluateFacilityData = (
referenceString = facilityContactAddressRef[0].reference;
}
const facilityContactAddress = referenceString
? evaluateReference(fhirBundle, mappings, referenceString).address[0]
: "";
? evaluateReference(fhirBundle, mappings, referenceString)?.address?.[0]
: undefined;

const facilityData = [
{
Expand All @@ -394,11 +394,11 @@ export const evaluateFacilityData = (
{
title: "Facility Contact Address",
value: formatAddress(
facilityContactAddress.line,
facilityContactAddress.city,
facilityContactAddress.state,
facilityContactAddress.postalCode,
facilityContactAddress.country,
facilityContactAddress?.line,
facilityContactAddress?.city,
facilityContactAddress?.state,
facilityContactAddress?.postalCode,
facilityContactAddress?.country,
),
},
{
Expand Down
18 changes: 14 additions & 4 deletions containers/ecr-viewer/src/app/tests/components/Encounter.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,28 @@ describe("Encounter", () => {
},
];
const facilityData = [
{
title: "Facility ID",
value: "2.16.840.1.113883.4.6",
},
{
title: "Facility Name",
value: "PRM- Palmdale Regional Medical Center",
},
{
title: "Facility Address",
value:
"5001 North Mount Washington Circle Drive\nNorth Canton, MA 02740",
},
{
title: "Facility Contact Address",
value:
"5001 North Mount Washington Circle Drive\nNorth Canton, MA 02740",
},
{
title: "Facility Type",
value: "Healthcare Provider",
},
{
title: "Facility ID",
value: "2.16.840.1.113883.4.6",
},
];
const providerData = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,47 @@ describe("UnavailableInfo", () => {
];
const encounterUnavailableData = [
{
title: "Encounter type",
title: "Encounter Date/Time",
value: "",
},
{
title: "Encounter Type",
value: "",
},
{
title: "Encounter ID",
value: "",
},
];
const facilityUnavailableData = [
{
title: "Facility Name",
value: "",
},
{
title: "Facility Address",
value: "",
},
{
title: "Facility Contact Address",
value: "",
},
{
title: "Facility Type",
value: "",
},
{
title: "Facility ID",
value: "",
},
];
const providerUnavailableData = [
{
title: "Provider Name",
title: "Provider Facility Name",
value: "",
},
{
title: "Provider Facility Address",
value: "",
},
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ exports[`Encounter should match snapshot 1`] = `
<div
class="data-title padding-right-1"
>
Facility ID
Facility Name
</div>
<div
class="grid-col maxw7 text-pre-line"
>
2.16.840.1.113883.4.6
PRM- Palmdale Regional Medical Center
</div>
</div>
<div
Expand All @@ -97,12 +97,33 @@ exports[`Encounter should match snapshot 1`] = `
<div
class="data-title padding-right-1"
>
Facility Name
Facility Address
</div>
<div
class="grid-col maxw7 text-pre-line"
>
PRM- Palmdale Regional Medical Center
5001 North Mount Washington Circle Drive
North Canton, MA 02740
</div>
</div>
<div
class="section__line_gray"
/>
</div>
<div>
<div
class="grid-row"
>
<div
class="data-title padding-right-1"
>
Facility Contact Address
</div>
<div
class="grid-col maxw7 text-pre-line"
>
5001 North Mount Washington Circle Drive
North Canton, MA 02740
</div>
</div>
<div
Expand All @@ -128,6 +149,25 @@ exports[`Encounter should match snapshot 1`] = `
class="section__line_gray"
/>
</div>
<div>
<div
class="grid-row"
>
<div
class="data-title padding-right-1"
>
Facility ID
</div>
<div
class="grid-col maxw7 text-pre-line"
>
2.16.840.1.113883.4.6
</div>
</div>
<div
class="section__line_gray"
/>
</div>
</div>
</div>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,45 @@ exports[`UnavailableInfo should match snapshot 1`] = `
<div
class="data-title padding-right-1"
>
Encounter type
Encounter Date/Time
</div>
<div
class="grid-col maxw7 text-pre-line text-italic text-base"
>
No data
</div>
</div>
<div
class="section__line_gray"
/>
</div>
<div>
<div
class="grid-row"
>
<div
class="data-title padding-right-1"
>
Encounter Type
</div>
<div
class="grid-col maxw7 text-pre-line text-italic text-base"
>
No data
</div>
</div>
<div
class="section__line_gray"
/>
</div>
<div>
<div
class="grid-row"
>
<div
class="data-title padding-right-1"
>
Encounter ID
</div>
<div
class="grid-col maxw7 text-pre-line text-italic text-base"
Expand All @@ -213,6 +251,25 @@ exports[`UnavailableInfo should match snapshot 1`] = `
<div
class="usa-summary-box__text"
>
<div>
<div
class="grid-row"
>
<div
class="data-title padding-right-1"
>
Facility Name
</div>
<div
class="grid-col maxw7 text-pre-line text-italic text-base"
>
No data
</div>
</div>
<div
class="section__line_gray"
/>
</div>
<div>
<div
class="grid-row"
Expand All @@ -232,6 +289,63 @@ exports[`UnavailableInfo should match snapshot 1`] = `
class="section__line_gray"
/>
</div>
<div>
<div
class="grid-row"
>
<div
class="data-title padding-right-1"
>
Facility Contact Address
</div>
<div
class="grid-col maxw7 text-pre-line text-italic text-base"
>
No data
</div>
</div>
<div
class="section__line_gray"
/>
</div>
<div>
<div
class="grid-row"
>
<div
class="data-title padding-right-1"
>
Facility Type
</div>
<div
class="grid-col maxw7 text-pre-line text-italic text-base"
>
No data
</div>
</div>
<div
class="section__line_gray"
/>
</div>
<div>
<div
class="grid-row"
>
<div
class="data-title padding-right-1"
>
Facility ID
</div>
<div
class="grid-col maxw7 text-pre-line text-italic text-base"
>
No data
</div>
</div>
<div
class="section__line_gray"
/>
</div>
</div>
</div>
<div
Expand Down Expand Up @@ -284,7 +398,26 @@ exports[`UnavailableInfo should match snapshot 1`] = `
<div
class="data-title padding-right-1"
>
Provider Name
Provider Facility Name
</div>
<div
class="grid-col maxw7 text-pre-line text-italic text-base"
>
No data
</div>
</div>
<div
class="section__line_gray"
/>
</div>
<div>
<div
class="grid-row"
>
<div
class="data-title padding-right-1"
>
Provider Facility Address
</div>
<div
class="grid-col maxw7 text-pre-line text-italic text-base"
Expand Down

0 comments on commit 8953e77

Please sign in to comment.