diff --git a/containers/ecr-viewer/src/app/tests/assets/BundlePendingResultsOnly.json b/containers/ecr-viewer/src/app/tests/assets/BundlePendingResultsOnly.json new file mode 100644 index 0000000000..dcab8c8ea6 --- /dev/null +++ b/containers/ecr-viewer/src/app/tests/assets/BundlePendingResultsOnly.json @@ -0,0 +1,96 @@ +{ + "resourceType": "Bundle", + "type": "batch", + "entry": [ + { + "fullUrl": "urn:uuid:1.2.840.114350.1.13.202.3.7.8.688883.484", + "resource": { + "resourceType": "Composition", + "id": "1.2.840.114350.1.13.202.3.7.8.688883.484", + "meta": { + "profile": [ + "http://hl7.org/fhir/us/ecr/StructureDefinition/eicr-composition" + ], + "source": [ + "ecr" + ] + }, + "identifier": [ + { + "use": "official", + "type": { + "coding": [ + { + "code": "55751-2", + "display": "Initial Public Health Case Report", + "system": "http://loinc.org" + } + ] + }, + "value": "28beb5ae-3f68-11ed-8bdc-005056a7fb21", + "assigner": { + "display": "EPC" + } + } + ], + "extension": [ + { + "url": "http://hl7.org/fhir/StructureDefinition/composition-clinicaldocument-versionNumber", + "valueString": "28" + } + ], + "status": "final", + "type": { + "coding": [ + { + "code": "55751-2", + "display": "Initial Public Health Case Report", + "system": "http://loinc.org" + } + ] + }, + "date": "2022-10-04T17:01:48-07:00", + "title": "Initial Public Health Case Report", + "confidentiality": "N", + "section": [ + { + "id": "7dfb261e-4d95-b4c2-9906-efe4979bc1aa", + "title": "Miscellaneous Notes", + "text": { + "status": "generated", + "div": "
Active ProblemsNoted Date
Parkinson's syndrome7/25/22
Essential hypertension7/21/22
" + }, + "code": { + "coding": [ + { + "code": "10164-2", + "display": "HISTORY OF PRESENT ILLNESS", + "system": "http://loinc.org" + } + ] + }, + "mode": "snapshot" + }, + { + "id": "eb08daad-1e00-4280-4846-4276acb00888", + "title": "Plan of Treatment", + "text": { + "status": "generated", + "div": "
Pending Results
NameTypePriorityAssociated DiagnosesDate/Time
PCR SARS-CoV-2 and Influenza A/BLabRoutine12/07/2021 4:16 PM CST
PCR SARS-CoV-2 and Influenza A/BLabRoutine12/07/2021 4:16 PM CST
PCR SARS-CoV-2 and Influenza A/BLabRoutine12/07/2021 4:16 PM CST
PCR SARS-CoV-2 and Influenza A/BLabRoutine12/07/2021 4:16 PM CST
PCR SARS-CoV-2 and Influenza A/BLabRoutine12/07/2021 4:16 PM CST
PCR SARS-CoV-2 and Influenza A/BLabRoutine12/07/2021 4:16 PM CST
PCR SARS-CoV-2 and Influenza A/BLabRoutine12/07/2021 4:16 PM CST
PCR SARS-CoV-2 and Influenza A/BLabRoutine12/07/2021 4:16 PM CST
PCR SARS-CoV-2 and Influenza A/BLabRoutine12/07/2021 4:16 PM CST
PCR SARS-CoV-2 and Influenza A/BLabRoutine12/07/2021 4:16 PM CST
PCR SARS-CoV-2 and Influenza A/BLabRoutine12/07/2021 4:16 PM CST
PCR SARS-CoV-2 and Influenza A/BLabRoutine12/07/2021 4:16 PM CST
PCR SARS-CoV-2 and Influenza A/BLabRoutine12/07/2021 4:16 PM CST
documented as of this encounter" + }, + "code": { + "coding": [ + { + "code": "18776-5", + "display": "Plan of care note", + "system": "http://loinc.org" + } + ] + }, + "mode": "snapshot" + } + ] + } + } + ] +} diff --git a/containers/ecr-viewer/src/app/tests/assets/BundleScheduledOrdersOnly.json b/containers/ecr-viewer/src/app/tests/assets/BundleScheduledOrdersOnly.json new file mode 100644 index 0000000000..2fbe210dec --- /dev/null +++ b/containers/ecr-viewer/src/app/tests/assets/BundleScheduledOrdersOnly.json @@ -0,0 +1,96 @@ +{ + "resourceType": "Bundle", + "type": "batch", + "entry": [ + { + "fullUrl": "urn:uuid:1.2.840.114350.1.13.202.3.7.8.688883.484", + "resource": { + "resourceType": "Composition", + "id": "1.2.840.114350.1.13.202.3.7.8.688883.484", + "meta": { + "profile": [ + "http://hl7.org/fhir/us/ecr/StructureDefinition/eicr-composition" + ], + "source": [ + "ecr" + ] + }, + "identifier": [ + { + "use": "official", + "type": { + "coding": [ + { + "code": "55751-2", + "display": "Initial Public Health Case Report", + "system": "http://loinc.org" + } + ] + }, + "value": "28beb5ae-3f68-11ed-8bdc-005056a7fb21", + "assigner": { + "display": "EPC" + } + } + ], + "extension": [ + { + "url": "http://hl7.org/fhir/StructureDefinition/composition-clinicaldocument-versionNumber", + "valueString": "28" + } + ], + "status": "final", + "type": { + "coding": [ + { + "code": "55751-2", + "display": "Initial Public Health Case Report", + "system": "http://loinc.org" + } + ] + }, + "date": "2022-10-04T17:01:48-07:00", + "title": "Initial Public Health Case Report", + "confidentiality": "N", + "section": [ + { + "id": "7dfb261e-4d95-b4c2-9906-efe4979bc1aa", + "title": "Miscellaneous Notes", + "text": { + "status": "generated", + "div": "
Active ProblemsNoted Date
Parkinson's syndrome7/25/22
Essential hypertension7/21/22
" + }, + "code": { + "coding": [ + { + "code": "10164-2", + "display": "HISTORY OF PRESENT ILLNESS", + "system": "http://loinc.org" + } + ] + }, + "mode": "snapshot" + }, + { + "id": "eb08daad-1e00-4280-4846-4276acb00888", + "title": "Plan of Treatment", + "text": { + "status": "generated", + "div": "
Scheduled Orders
NameTypePriorityAssociated DiagnosesDate/Time
PCR SARS-CoV-2 and Influenza A/BLabRoutine12/07/2021 4:16 PM CST
PCR SARS-CoV-2 and Influenza A/BLabRoutine12/07/2021 4:16 PM CST
PCR SARS-CoV-2 and Influenza A/BLabRoutine12/07/2021 4:16 PM CST
PCR SARS-CoV-2 and Influenza A/BLabRoutine12/07/2021 4:16 PM CST
PCR SARS-CoV-2 and Influenza A/BLabRoutine12/07/2021 4:16 PM CST
PCR SARS-CoV-2 and Influenza A/BLabRoutine12/07/2021 4:16 PM CST
PCR SARS-CoV-2 and Influenza A/BLabRoutine12/07/2021 4:16 PM CST
PCR SARS-CoV-2 and Influenza A/BLabRoutine12/07/2021 4:16 PM CST
PCR SARS-CoV-2 and Influenza A/BLabRoutine12/07/2021 4:16 PM CST
PCR SARS-CoV-2 and Influenza A/BLabRoutine12/07/2021 4:16 PM CST
PCR SARS-CoV-2 and Influenza A/BLabRoutine12/07/2021 4:16 PM CST
PCR SARS-CoV-2 and Influenza A/BLabRoutine12/07/2021 4:16 PM CST
PCR SARS-CoV-2 and Influenza A/BLabRoutine12/07/2021 4:16 PM CST
documented as of this encounter" + }, + "code": { + "coding": [ + { + "code": "18776-5", + "display": "Plan of care note", + "system": "http://loinc.org" + } + ] + }, + "mode": "snapshot" + } + ] + } + } + ] +} diff --git a/containers/ecr-viewer/src/app/tests/utils.test.tsx b/containers/ecr-viewer/src/app/tests/utils.test.tsx index c13444e23f..298897c9ec 100644 --- a/containers/ecr-viewer/src/app/tests/utils.test.tsx +++ b/containers/ecr-viewer/src/app/tests/utils.test.tsx @@ -6,6 +6,8 @@ import BundleWithPatient from "./assets/BundlePatient.json"; import BundleWithDeceasedPatient from "./assets/BundlePatientDeceased.json"; import BundleWithSexualOrientation from "./assets/BundleSexualOrientation.json"; import BundleWithMiscNotes from "./assets/BundleMiscNotes.json"; +import BundleWithPendingResultsOnly from "./assets/BundlePendingResultsOnly.json"; +import BundleWithScheduledOrdersOnly from "./assets/BundleScheduledOrdersOnly.json"; import BundleNoActiveProblems from "./assets/BundleNoActiveProblems.json"; import BundleCareTeam from "./assets/BundleCareTeam.json"; import React from "react"; @@ -48,7 +50,7 @@ describe("Utils", () => { it("should have travel history when there is a travel history observation present", () => { const actual = evaluateSocialData( BundleWithTravelHistory as unknown as Bundle, - mappings, + mappings ); expect(actual.availableData[0].value) @@ -59,7 +61,7 @@ describe("Utils", () => { it("should have patient sexual orientation when available", () => { const actual = evaluateSocialData( BundleWithSexualOrientation as unknown as Bundle, - mappings, + mappings ); expect(actual.availableData[0].value).toEqual("Other"); @@ -70,11 +72,11 @@ describe("Utils", () => { it("Should return notes", () => { const actual = evaluateClinicalData( BundleWithMiscNotes as unknown as Bundle, - mappings, + mappings ); render(actual.clinicalNotes.availableData[0].value as React.JSX.Element); expect(actual.clinicalNotes.availableData[0].title).toEqual( - "Miscellaneous Notes", + "Miscellaneous Notes" ); expect(screen.getByText("Active Problems")).toBeInTheDocument(); expect(actual.clinicalNotes.unavailableData).toBeEmpty(); @@ -82,17 +84,33 @@ describe("Utils", () => { it("Should not include Treatment details if medications is not available", () => { const actual = evaluateClinicalData( BundleWithMiscNotes as unknown as Bundle, - mappings, + mappings ); expect(actual.treatmentData.availableData).toBeEmpty(); }); + it("Should return Plan of Treatment when only pending results", () => { + const actual = evaluateClinicalData( + BundleWithPendingResultsOnly as unknown as Bundle, + mappings + ); + console.log(actual.treatmentData); + expect(actual.treatmentData.availableData[0].title).toEqual("Plan of Treatment"); + }); + it("Should return Plan of Treatment when only scheduled orders", () => { + const actual = evaluateClinicalData( + BundleWithScheduledOrdersOnly as unknown as Bundle, + mappings + ); + console.log(actual.treatmentData); + expect(actual.treatmentData.availableData[0].title).toEqual("Plan of Treatment"); + }); }); describe("Evaluate Care Team Table", () => { it("should evaluate care team table results", () => { const actual: React.JSX.Element = returnCareTeamTable( BundleCareTeam as unknown as Bundle, - mappings, + mappings ) as React.JSX.Element; render(actual); @@ -100,14 +118,14 @@ describe("Utils", () => { expect(screen.getByText("Dr. Gregory House")).toBeInTheDocument(); expect(screen.getByText("family")).toBeInTheDocument(); expect( - screen.getByText("Start: 11/16/2004 End: 05/21/2012"), + screen.getByText("Start: 11/16/2004 End: 05/21/2012") ).toBeInTheDocument(); }); it("the table should not appear when there are no results", () => { const actual = returnCareTeamTable( BundleWithPatient as unknown as Bundle, - mappings, + mappings ); expect(actual).toBeUndefined(); }); @@ -117,7 +135,7 @@ describe("Utils", () => { it("should return name", () => { const actual = evaluatePatientName( BundleWithPatient as unknown as Bundle, - mappings, + mappings ); expect(actual).toEqual("ABEL CASTILLO"); }); @@ -131,7 +149,7 @@ describe("Utils", () => { it("should get patient address", () => { const actual = evaluatePatientAddress( BundleWithPatient as unknown as Bundle, - mappings, + mappings ); expect(actual).toEqual("1050 CARPENTER ST\nEDWARDS, CA\n93523-2800, US"); @@ -144,7 +162,7 @@ describe("Utils", () => { const patientAge = calculatePatientAge( BundleWithPatient as unknown as Bundle, - mappings, + mappings ); expect(patientAge).toEqual(8); @@ -164,7 +182,7 @@ describe("Utils", () => { const resultAge = calculatePatientAge( BundleWithPatient as unknown as Bundle, mappings, - givenDate, + givenDate ); expect(resultAge).toEqual(expectedAge); @@ -179,12 +197,12 @@ describe("Utils", () => { const patientAge = calculatePatientAge( BundleWithPatient as unknown as Bundle, - mappings, + mappings ); const patientAgeAtDeath = calculatePatientAgeAtDeath( BundleWithPatient as unknown as Bundle, - mappings, + mappings ); expect(patientAgeAtDeath).toEqual(expectedAgeAtDeath); @@ -197,7 +215,7 @@ describe("Utils", () => { it("should return age at death when DOD is given", () => { const patientAgeAtDeath = calculatePatientAgeAtDeath( BundleWithDeceasedPatient as unknown as Bundle, - mappings, + mappings ); const expectedAgeAtDeath = 4; @@ -212,12 +230,12 @@ describe("Utils", () => { const patientAge = calculatePatientAge( BundleWithDeceasedPatient as unknown as Bundle, - mappings, + mappings ); const patientAgeAtDeath = calculatePatientAgeAtDeath( BundleWithDeceasedPatient as unknown as Bundle, - mappings, + mappings ); expect(patientAgeAtDeath).toEqual(expectedAgeAtDeath); @@ -269,7 +287,7 @@ describe("Utils", () => { const actual = returnProblemsTable( BundleNoActiveProblems as unknown as Bundle, evaluate(BundleNoActiveProblems, mappings["activeProblems"]), - mappings, + mappings ); expect(actual).toBeUndefined(); @@ -313,7 +331,7 @@ describe("Utils", () => { expect(FiveHundredChars).toHaveLength(500); render( - , + ); expect(screen.getByText(FiveHundredChars)).toBeInTheDocument(); @@ -324,15 +342,15 @@ describe("Utils", () => { expect(FiveHundredOneChars).toHaveLength(501); render( - , + ); expect( - screen.getByText(FiveHundredOneChars.substring(0, 300) + "..."), + screen.getByText(FiveHundredOneChars.substring(0, 300) + "...") ).toBeInTheDocument(); expect(screen.getByText("View more")).toBeInTheDocument(); expect( - screen.queryByText(FiveHundredOneChars.substring(300)), + screen.queryByText(FiveHundredOneChars.substring(300)) ).not.toBeInTheDocument(); }); it("should show full text when view more is clicked", async () => { @@ -342,7 +360,7 @@ describe("Utils", () => { expect(FiveHundredOneChars).toHaveLength(501); render( - , + ); await user.click(screen.getByText("View more")); @@ -359,7 +377,7 @@ describe("Utils", () => { expect(FiveHundredOneChars).toHaveLength(501); render( - , + ); await user.click(screen.getByText("View more")); @@ -368,11 +386,11 @@ describe("Utils", () => { await user.click(screen.getByText("View less")); expect( - screen.getByText(FiveHundredOneChars.substring(0, 300) + "..."), + screen.getByText(FiveHundredOneChars.substring(0, 300) + "...") ).toBeInTheDocument(); expect(screen.getByText("View more")).toBeInTheDocument(); expect( - screen.queryByText(FiveHundredOneChars.substring(300)), + screen.queryByText(FiveHundredOneChars.substring(300)) ).not.toBeInTheDocument(); }); }); @@ -397,29 +415,29 @@ describe("Utils", () => { ]; render( - , + ); expect( - screen.getByText(OneHundredTwentyFiveCharStrings[0]), + screen.getByText(OneHundredTwentyFiveCharStrings[0]) ).toBeInTheDocument(); expect( - screen.getByText(OneHundredTwentyFiveCharStrings[1]), + screen.getByText(OneHundredTwentyFiveCharStrings[1]) ).toBeInTheDocument(); expect( screen.getByText( - OneHundredTwentyFiveCharStrings[2].substring(0, 50) + "...", - ), + OneHundredTwentyFiveCharStrings[2].substring(0, 50) + "..." + ) ).toBeInTheDocument(); expect(screen.getByText("View more")).toBeInTheDocument(); expect( - screen.queryByText(OneHundredTwentyFiveCharStrings[2].substring(50)), + screen.queryByText(OneHundredTwentyFiveCharStrings[2].substring(50)) ).not.toBeInTheDocument(); expect( - screen.queryByText(OneHundredTwentyFiveCharStrings[3]), + screen.queryByText(OneHundredTwentyFiveCharStrings[3]) ).not.toBeInTheDocument(); expect( - screen.queryByText(OneHundredTwentyFiveCharStrings[4]), + screen.queryByText(OneHundredTwentyFiveCharStrings[4]) ).not.toBeInTheDocument(); }); it("should show the whole ReactNode when view more is clicked", async () => { @@ -447,7 +465,7 @@ describe("Utils", () => { await user.click(screen.getByText("View more")); OneHundredTwentyFiveCharStrings.forEach((str) => - expect(screen.getByText(str)).toBeInTheDocument(), + expect(screen.getByText(str)).toBeInTheDocument() ); expect(screen.getByText("this is more text")).toBeInTheDocument(); expect(screen.getByText("View less")).toBeInTheDocument(); @@ -473,31 +491,31 @@ describe("Utils", () => { ]; render( - , + ); await user.click(screen.getByText("View more")); await user.click(screen.getByText("View less")); expect( - screen.getByText(OneHundredTwentyFiveCharStrings[0]), + screen.getByText(OneHundredTwentyFiveCharStrings[0]) ).toBeInTheDocument(); expect( - screen.getByText(OneHundredTwentyFiveCharStrings[1]), + screen.getByText(OneHundredTwentyFiveCharStrings[1]) ).toBeInTheDocument(); expect( screen.getByText( - OneHundredTwentyFiveCharStrings[2].substring(0, 50) + "...", - ), + OneHundredTwentyFiveCharStrings[2].substring(0, 50) + "..." + ) ).toBeInTheDocument(); expect(screen.getByText("View more")).toBeInTheDocument(); expect( - screen.queryByText(OneHundredTwentyFiveCharStrings[2].substring(50)), + screen.queryByText(OneHundredTwentyFiveCharStrings[2].substring(50)) ).not.toBeInTheDocument(); expect( - screen.queryByText(OneHundredTwentyFiveCharStrings[3]), + screen.queryByText(OneHundredTwentyFiveCharStrings[3]) ).not.toBeInTheDocument(); expect( - screen.queryByText(OneHundredTwentyFiveCharStrings[4]), + screen.queryByText(OneHundredTwentyFiveCharStrings[4]) ).not.toBeInTheDocument(); }); }); @@ -512,7 +530,7 @@ describe("Utils", () => { className="testClass" > Test child - , + ); const tip = screen.getByTestId("triggerElement"); expect(tip.className).toInclude("testClass"); diff --git a/containers/ecr-viewer/src/app/view-data/components/common.tsx b/containers/ecr-viewer/src/app/view-data/components/common.tsx index b714daf6c1..a82597452f 100644 --- a/containers/ecr-viewer/src/app/view-data/components/common.tsx +++ b/containers/ecr-viewer/src/app/view-data/components/common.tsx @@ -555,7 +555,7 @@ export const evaluateClinicalData = ( const pendingResults = returnPendingResultsTable(fhirBundle, mappings); const scheduledOrders = returnScheduledOrdersTable(fhirBundle, mappings); let planOfTreatmentElement: React.JSX.Element | undefined = undefined; - if (pendingResults) { + if (pendingResults || scheduledOrders) { planOfTreatmentElement = ( <>
Plan of Treatment