From 6e86ee75a4fbb5c5a8e9aa783ea88dd20b3c5ee3 Mon Sep 17 00:00:00 2001 From: Mary McGrath Date: Fri, 15 Nov 2024 11:29:32 -0500 Subject: [PATCH] Fix ordering of notes/comments (#2900) * fix: move things to fhir converter, unify make and docker * ci: remove dotnet testing * fix: undo debugging docker changes * fix: more debugging clenaup * docs: update README with current dev guidance and pointing to the fork * feat: allow passing the converter tool path as an environment variable * fix: rename environment variable * fix: point to converter pr * fix: sanitize and map the incoming original inner tex * test: add unit tests * fix: use valueString when available * test: update snapshot * docs: add section header comment * test: update snapshot * test: more snapshot updating * fix: gender identity fhirpath, parsing lab notes * fix: point to corresponding FHIR-Converter branch * fix: update to v7.0-skylight-7 release * refactor: move selection logic into fhirpath * fix: escape div * test: make sure tests cover the changes * Update containers/fhir-converter/Dockerfile --- containers/ecr-viewer/src/app/api/fhirPath.yml | 7 +++---- containers/ecr-viewer/src/app/services/labsService.tsx | 4 ++-- containers/ecr-viewer/src/app/tests/assets/BundleLab.json | 2 +- .../tests/components/__snapshots__/LabInfo.test.tsx.snap | 4 +++- .../ecr-viewer/src/app/view-data/components/common.tsx | 7 ++++--- containers/fhir-converter/Dockerfile | 2 +- .../integration/__snapshots__/test_FHIR-Converter.ambr | 2 +- .../f3eae968-d262-40f1-b1cb-699dda5b395a/CDA_eICR.xml | 3 ++- 8 files changed, 17 insertions(+), 14 deletions(-) diff --git a/containers/ecr-viewer/src/app/api/fhirPath.yml b/containers/ecr-viewer/src/app/api/fhirPath.yml index d5d7ca462a..238326dc74 100644 --- a/containers/ecr-viewer/src/app/api/fhirPath.yml +++ b/containers/ecr-viewer/src/app/api/fhirPath.yml @@ -89,17 +89,16 @@ activeProblemsDisplay: "Condition.code.coding.display.first()" activeProblemsOnsetDate: "Condition.onsetDateTime" activeProblemsOnsetAge: "Condition.onsetAge.value" activeProblemsComments: "Condition.note[0].text" -historyOfPresentIllness: "Bundle.entry.resource.where(resourceType = 'Composition').section.where(code.coding.code = '10164-2').text" +historyOfPresentIllness: "Bundle.entry.resource.where(resourceType = 'Composition').section.where(code.coding.code = '10164-2').text.`div`.first()" # Treatment Details -planOfTreatment: "Bundle.entry.resource.section.where(title = 'Plan of Treatment').text" +planOfTreatment: "Bundle.entry.resource.section.where(title = 'Plan of Treatment').text.first().`div`" plannedProcedures: "Bundle.entry.resource.where(resourceType = 'CarePlan').activity" plannedProcedureName: "detail.code.coding[0].display" plannedProcedureOrderedDate: "extension.where(url = 'dibbs.orderedDate').valueString" plannedProcedureScheduledDate: "detail.scheduledString" # Administered Medications -administeredMedications: "Bundle.entry.resource.section.where(code.coding[0].code = '29549-3').text" adminMedicationsRefs: "Bundle.entry.resource.section.where(code.coding[0].code = '29549-3').entry.reference" ## Care Team @@ -126,7 +125,7 @@ procedureReason: "Procedure.reason.display" # Lab Info diagnosticReports: "Bundle.entry.resource.where(resourceType = 'DiagnosticReport')" observations: "Bundle.entry.resource.where(resourceType = 'Observation')" -labResultDiv: "Bundle.entry.resource.section.where(code.coding[0].code = '30954-2').text" +labResultDiv: "Bundle.entry.resource.section.where(code.coding[0].code = '30954-2').text.`div`.first()" specimenCollectionTime: "Observation.extension[0].extension.where(url = 'specimen collection time').valueDateTime" specimenReceivedTime: "Observation.extension[0].extension.where(url = 'specimen receive time').valueDateTime" specimenSource: "Observation.extension[0].extension.where(url = 'specimen source').valueString" diff --git a/containers/ecr-viewer/src/app/services/labsService.tsx b/containers/ecr-viewer/src/app/services/labsService.tsx index 9473065ff1..60c69a8851 100644 --- a/containers/ecr-viewer/src/app/services/labsService.tsx +++ b/containers/ecr-viewer/src/app/services/labsService.tsx @@ -88,7 +88,7 @@ export const getLabJsonObject = ( const observationRefVal = [...new Set(observationRefValsArray)].join(", "); // should only be 1 // Get lab reports HTML String (for all lab reports) & convert to JSON - const labsString = evaluate(fhirBundle, mappings["labResultDiv"])[0].div; + const labsString = evaluateValue(fhirBundle, mappings["labResultDiv"]); const labsJson = formatTablesToJSON(labsString); // Get specified lab report (by reference value) @@ -341,7 +341,7 @@ export const evaluateDiagnosticReportData = ( infoPath: "observationDeviceReference", applyToValue: (ref) => { const device = evaluateReference(fhirBundle, mappings, ref) as Device; - return device.deviceName?.[0]?.name; + return parse(sanitizeAndMap(device.deviceName?.[0]?.name ?? "")); }, className: "minw-10 width-20", }, diff --git a/containers/ecr-viewer/src/app/tests/assets/BundleLab.json b/containers/ecr-viewer/src/app/tests/assets/BundleLab.json index b18eb122c0..0c99342cda 100644 --- a/containers/ecr-viewer/src/app/tests/assets/BundleLab.json +++ b/containers/ecr-viewer/src/app/tests/assets/BundleLab.json @@ -792,7 +792,7 @@ "valueString": "Acinetobacter baumannii", "note": [ { - "text": "Lab comment" + "text": "Lab comment" } ], "effectiveDateTime": "2022-04-18T19:57:02Z", diff --git a/containers/ecr-viewer/src/app/tests/components/__snapshots__/LabInfo.test.tsx.snap b/containers/ecr-viewer/src/app/tests/components/__snapshots__/LabInfo.test.tsx.snap index 78b6fe171b..fa066d5aee 100644 --- a/containers/ecr-viewer/src/app/tests/components/__snapshots__/LabInfo.test.tsx.snap +++ b/containers/ecr-viewer/src/app/tests/components/__snapshots__/LabInfo.test.tsx.snap @@ -988,7 +988,9 @@ NASHVILLE, TN class="hideableData p-list" colspan="5" > - Lab comment +

+ Lab comment +

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 432d1face7..ccaf6dd1a1 100644 --- a/containers/ecr-viewer/src/app/view-data/components/common.tsx +++ b/containers/ecr-viewer/src/app/view-data/components/common.tsx @@ -1,6 +1,7 @@ import { calculatePatientAge, evaluateReference, + evaluateValue, } from "@/app/services/evaluateFhirDataService"; import EvaluateTable, { BuildHeaders, @@ -255,8 +256,8 @@ export const returnPlanOfTreatmentContent = ( fhirBundle: Bundle, mappings: PathMappings, ) => { - const bundle = evaluate(fhirBundle, mappings["planOfTreatment"]); - const rawTables = formatTablesToJSON(bundle[0]?.div); + const bundle = evaluateValue(fhirBundle, mappings["planOfTreatment"]); + const rawTables = formatTablesToJSON(bundle); const tables = rawTables .map((rawTable) => returnPlanOfTreatmentTable(rawTable)) .filter((t) => !!t); @@ -500,7 +501,7 @@ export const evaluateClinicalData = ( title: "Miscellaneous Notes", value: parse( sanitizeAndMap( - evaluate(fhirBundle, mappings["historyOfPresentIllness"])[0]?.div, + evaluateValue(fhirBundle, mappings["historyOfPresentIllness"]), ) || "", ), }, diff --git a/containers/fhir-converter/Dockerfile b/containers/fhir-converter/Dockerfile index 0f67120343..5ead6c7681 100644 --- a/containers/fhir-converter/Dockerfile +++ b/containers/fhir-converter/Dockerfile @@ -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-7 --single-branch /build/FHIR-Converter +RUN git clone https://github.com/skylight-hq/FHIR-Converter.git --branch v7.0-skylight-8 --single-branch /build/FHIR-Converter WORKDIR /build/FHIR-Converter diff --git a/containers/fhir-converter/tests/integration/__snapshots__/test_FHIR-Converter.ambr b/containers/fhir-converter/tests/integration/__snapshots__/test_FHIR-Converter.ambr index b76a893600..dd4fe97f90 100644 --- a/containers/fhir-converter/tests/integration/__snapshots__/test_FHIR-Converter.ambr +++ b/containers/fhir-converter/tests/integration/__snapshots__/test_FHIR-Converter.ambr @@ -7543,7 +7543,7 @@ }), 'note': list([ dict({ - 'text': 'Last Assessment & Plan: Formatting of this note might be different from the original.
This is my note about this problem.

', + 'text': 'A note:Last Assessment & Plan: Formatting of this note might be different from the original.
This is my note about this problem.

', }), ]), 'onsetDateTime': '2019-04-16', diff --git a/containers/fhir-converter/tests/test_files/snapshot/f3eae968-d262-40f1-b1cb-699dda5b395a/CDA_eICR.xml b/containers/fhir-converter/tests/test_files/snapshot/f3eae968-d262-40f1-b1cb-699dda5b395a/CDA_eICR.xml index 31171f6bef..8b1cf326da 100644 --- a/containers/fhir-converter/tests/test_files/snapshot/f3eae968-d262-40f1-b1cb-699dda5b395a/CDA_eICR.xml +++ b/containers/fhir-converter/tests/test_files/snapshot/f3eae968-d262-40f1-b1cb-699dda5b395a/CDA_eICR.xml @@ -769,6 +769,7 @@ + A note: Last Assessment & Plan: Formatting of this note @@ -5784,4 +5785,4 @@ - \ No newline at end of file +