diff --git a/omod/src/main/java/org/bahmni/module/hip/web/model/FhirDiagnosticReport.java b/omod/src/main/java/org/bahmni/module/hip/web/model/FhirDiagnosticReport.java index 124ef10a..b37907fe 100644 --- a/omod/src/main/java/org/bahmni/module/hip/web/model/FhirDiagnosticReport.java +++ b/omod/src/main/java/org/bahmni/module/hip/web/model/FhirDiagnosticReport.java @@ -72,7 +72,7 @@ public static FhirDiagnosticReport fromOpenMrsDiagnosticReport(OpenMrsDiagnostic Patient patient = fhirResourceMapper.mapToPatient(openMrsDiagnosticReport.getPatient()); Reference patientReference = FHIRUtils.getReferenceToResource(patient); Encounter encounter = fhirResourceMapper.mapToEncounter(openMrsDiagnosticReport.getEncounter()); - encounter.getClass_().setDisplay("Diagnostic Report"); + encounter.getClass_().setDisplay("ambulatory"); Date visitDateTime = openMrsDiagnosticReport.getEncounter().getVisit().getStartDatetime(); Integer encounterId = openMrsDiagnosticReport.getEncounter().getId(); List practitioners = getPractitionersFrom(fhirResourceMapper, openMrsDiagnosticReport.getEncounterProviders()); diff --git a/omod/src/main/java/org/bahmni/module/hip/web/model/FhirDischargeSummary.java b/omod/src/main/java/org/bahmni/module/hip/web/model/FhirDischargeSummary.java index 18773705..a973058b 100644 --- a/omod/src/main/java/org/bahmni/module/hip/web/model/FhirDischargeSummary.java +++ b/omod/src/main/java/org/bahmni/module/hip/web/model/FhirDischargeSummary.java @@ -86,7 +86,7 @@ public static FhirDischargeSummary fromOpenMrsDischargeSummary(OpenMrsDischargeS Patient patient = fhirResourceMapper.mapToPatient(openMrsDischargeSummary.getPatient()); Reference patientReference = FHIRUtils.getReferenceToResource(patient); Encounter encounter = fhirResourceMapper.mapToEncounter(openMrsDischargeSummary.getEncounter()); - encounter.getClass_().setDisplay("Discharge Summary"); + encounter.getClass_().setDisplay("ambulatory"); Date visitDatetime = openMrsDischargeSummary.getEncounter().getVisit().getStartDatetime(); Integer encounterId = openMrsDischargeSummary.getEncounter().getId(); List practitioners = getPractitionersFrom(fhirResourceMapper, openMrsDischargeSummary.getEncounter().getEncounterProviders()); diff --git a/omod/src/main/java/org/bahmni/module/hip/web/model/FhirLabResult.java b/omod/src/main/java/org/bahmni/module/hip/web/model/FhirLabResult.java index 70ec9fe1..bb3a84fa 100644 --- a/omod/src/main/java/org/bahmni/module/hip/web/model/FhirLabResult.java +++ b/omod/src/main/java/org/bahmni/module/hip/web/model/FhirLabResult.java @@ -1,5 +1,6 @@ package org.bahmni.module.hip.web.model; +import org.bahmni.module.bahmnicore.service.OrderService; import org.bahmni.module.hip.Config; import org.bahmni.module.hip.web.service.FHIRResourceMapper; import org.bahmni.module.hip.web.service.FHIRUtils; @@ -88,16 +89,25 @@ public static FhirLabResult fromOpenMrsLabResults(OpenMrsLabResults labresult, F } } if(labresult.getLabResults() != null) { - for(Map.Entry labOrderResultObsMap: labresult.getLabResults().entrySet()){ - LabOrderResult labResult = labOrderResultObsMap.getKey(); - DiagnosticReport reports = map(labResult.getOrderUuid(),labOrderResultObsMap.getValue(),labResult.getTestName(),patient,practitioners); - FhirLabResult.mapToObsFromLabResult(labResult, patient, reports, results); + Map>> labOrderResultObsOrdersMap = + labresult.getLabResults().entrySet().stream() + .collect(Collectors.groupingBy(entry -> entry.getKey().getOrderUuid())); + + for(Map.Entry>> labOrder: labOrderResultObsOrdersMap.entrySet()){ + String testName = labOrder.getValue().get(0).getKey().getPanelName(); + if (testName == null) { + testName = labOrder.getValue().get(0).getKey().getTestName(); + } + DiagnosticReport reports = map(labOrder.getKey(),null,testName,patient,practitioners); + labOrder.getValue().forEach(entry -> { + FhirLabResult.mapToObsFromLabResult(entry.getKey(), patient, reports, results); + }); reportList.add(reports); } } Encounter encounter = fhirResourceMapper.mapToEncounter(labresult.getEncounter()); - encounter.getClass_().setDisplay("Diagnostic Report"); + encounter.getClass_().setDisplay("ambulatory"); return new FhirLabResult(fhirResourceMapper.mapToPatient(labresult.getPatient()), encounter, labresult.getEncounter().getEncounterDatetime(), reportList, results, practitioners); diff --git a/omod/src/main/java/org/bahmni/module/hip/web/model/FhirOPConsult.java b/omod/src/main/java/org/bahmni/module/hip/web/model/FhirOPConsult.java index 7af10665..42adec88 100644 --- a/omod/src/main/java/org/bahmni/module/hip/web/model/FhirOPConsult.java +++ b/omod/src/main/java/org/bahmni/module/hip/web/model/FhirOPConsult.java @@ -95,7 +95,7 @@ public static FhirOPConsult fromOpenMrsOPConsult(OpenMrsOPConsult openMrsOPConsu Patient patient = fhirResourceMapper.mapToPatient(openMrsOPConsult.getPatient()); Reference patientReference = FHIRUtils.getReferenceToResource(patient); Encounter encounter = fhirResourceMapper.mapToEncounter(openMrsOPConsult.getEncounter()); - encounter.getClass_().setDisplay("OP Consultation"); + encounter.getClass_().setDisplay("ambulatory"); Date visitDatetime = openMrsOPConsult.getEncounter().getVisit().getStartDatetime(); Integer encounterId = openMrsOPConsult.getEncounter().getId(); List medicationRequestsList = openMrsOPConsult.getDrugOrders().stream(). diff --git a/omod/src/main/java/org/bahmni/module/hip/web/model/FhirPrescription.java b/omod/src/main/java/org/bahmni/module/hip/web/model/FhirPrescription.java index b1c3b30c..3518b634 100644 --- a/omod/src/main/java/org/bahmni/module/hip/web/model/FhirPrescription.java +++ b/omod/src/main/java/org/bahmni/module/hip/web/model/FhirPrescription.java @@ -51,7 +51,7 @@ public static FhirPrescription from(OpenMrsPrescription openMrsPrescription, FHI Patient patient = fhirResourceMapper.mapToPatient(openMrsPrescription.getPatient()); Reference patientReference = FHIRUtils.getReferenceToResource(patient); Encounter encounter = fhirResourceMapper.mapToEncounter(openMrsPrescription.getEncounter()); - encounter.getClass_().setDisplay("Prescription"); + encounter.getClass_().setDisplay("ambulatory"); List practitioners = getPractitionersFrom(fhirResourceMapper, openMrsPrescription.getEncounterProviders()); List medicationRequests = medicationRequestsFor(fhirResourceMapper, openMrsPrescription.getDrugOrders()); List medications = medicationsFor(fhirResourceMapper, openMrsPrescription.getDrugOrders()); diff --git a/omod/src/main/java/org/bahmni/module/hip/web/service/FhirHealthDocumentRecordBuilder.java b/omod/src/main/java/org/bahmni/module/hip/web/service/FhirHealthDocumentRecordBuilder.java index 6b6ba368..a6d7b4c8 100644 --- a/omod/src/main/java/org/bahmni/module/hip/web/service/FhirHealthDocumentRecordBuilder.java +++ b/omod/src/main/java/org/bahmni/module/hip/web/service/FhirHealthDocumentRecordBuilder.java @@ -35,7 +35,7 @@ public HealthDocumentRecordBundle build(Obs docObs, OrganizationContext organiza DocumentReference documentReference = documentTransformer.transForm(docObs, DocumentReference.class, AbdmConfig.HiTypeDocumentKind.HEALTH_DOCUMENT_RECORD); if (documentReference == null) return null; org.hl7.fhir.r4.model.Encounter docEncounter = fhirResourceMapper.mapToEncounter(docObs.getEncounter()); - docEncounter.getClass_().setDisplay("Health Document"); + docEncounter.getClass_().setDisplay("ambulatory"); Patient patient = fhirResourceMapper.mapToPatient(docObs.getEncounter().getPatient()); List practitioners = docObs.getEncounter().getEncounterProviders() .stream() @@ -87,7 +87,7 @@ public HealthDocumentRecordBundle build(Encounter encounter, List obsDocLis if (documentRefs.isEmpty()) return null; org.hl7.fhir.r4.model.Encounter docEncounter = fhirResourceMapper.mapToEncounter(encounter); - docEncounter.getClass_().setDisplay("Health Document"); + docEncounter.getClass_().setDisplay("ambulatory"); Patient patient = fhirResourceMapper.mapToPatient(encounter.getPatient()); List practitioners = encounter.getEncounterProviders() .stream() diff --git a/omod/src/main/java/org/bahmni/module/hip/web/service/FhirImmunizationRecordBundleBuilder.java b/omod/src/main/java/org/bahmni/module/hip/web/service/FhirImmunizationRecordBundleBuilder.java index ed1c325e..633b119f 100644 --- a/omod/src/main/java/org/bahmni/module/hip/web/service/FhirImmunizationRecordBundleBuilder.java +++ b/omod/src/main/java/org/bahmni/module/hip/web/service/FhirImmunizationRecordBundleBuilder.java @@ -100,7 +100,7 @@ private boolean isYesTerm(Concept obsValue) { private ImmunizationRecordBundle buildImmunizationBundle(Obs obs, Encounter encounter) { Patient patient = fhirResourceMapper.mapToPatient(encounter.getPatient()); org.hl7.fhir.r4.model.Encounter immunizationEncounter = encounterTranslator.toFhirResource(encounter); - immunizationEncounter.getClass_().setDisplay("Immunization Record"); + immunizationEncounter.getClass_().setDisplay("ambulatory"); List practitioners = practitionersFrom(encounter.getEncounterProviders()); Reference patientRef = FHIRUtils.getReferenceToResource(patient); diff --git a/omod/src/main/java/org/bahmni/module/hip/web/service/FhirWellnessRecordBundleBuilder.java b/omod/src/main/java/org/bahmni/module/hip/web/service/FhirWellnessRecordBundleBuilder.java index 024ffe84..de9f43ff 100644 --- a/omod/src/main/java/org/bahmni/module/hip/web/service/FhirWellnessRecordBundleBuilder.java +++ b/omod/src/main/java/org/bahmni/module/hip/web/service/FhirWellnessRecordBundleBuilder.java @@ -38,7 +38,7 @@ public WellnessRecordBundle build(Encounter encounter, Map> wellnessAttributeObsMap, OrganizationContext orgContext) { Patient patient = fhirResourceMapper.mapToPatient(encounter.getPatient()); org.hl7.fhir.r4.model.Encounter wellnessEncounter = encounterTranslator.toFhirResource(encounter); - wellnessEncounter.getClass_().setDisplay("Wellness Record"); + wellnessEncounter.getClass_().setDisplay("ambulatory"); List practitioners = practitionersFrom(encounter.getEncounterProviders()); Reference patientRef = FHIRUtils.getReferenceToResource(patient); List observations = new ArrayList<>();