|
1 | 1 | package org.bahmni.module.hip.web.model;
|
2 | 2 |
|
| 3 | +import org.bahmni.module.bahmnicore.service.OrderService; |
3 | 4 | import org.bahmni.module.hip.Config;
|
4 | 5 | import org.bahmni.module.hip.web.service.FHIRResourceMapper;
|
5 | 6 | import org.bahmni.module.hip.web.service.FHIRUtils;
|
@@ -88,16 +89,25 @@ public static FhirLabResult fromOpenMrsLabResults(OpenMrsLabResults labresult, F
|
88 | 89 | }
|
89 | 90 | }
|
90 | 91 | if(labresult.getLabResults() != null) {
|
91 |
| - for(Map.Entry<LabOrderResult, Obs> labOrderResultObsMap: labresult.getLabResults().entrySet()){ |
92 |
| - LabOrderResult labResult = labOrderResultObsMap.getKey(); |
93 |
| - DiagnosticReport reports = map(labResult.getOrderUuid(),labOrderResultObsMap.getValue(),labResult.getTestName(),patient,practitioners); |
94 |
| - FhirLabResult.mapToObsFromLabResult(labResult, patient, reports, results); |
| 92 | + Map<String, List<Map.Entry<LabOrderResult, Obs>>> labOrderResultObsOrdersMap = |
| 93 | + labresult.getLabResults().entrySet().stream() |
| 94 | + .collect(Collectors.groupingBy(entry -> entry.getKey().getOrderUuid())); |
| 95 | + |
| 96 | + for(Map.Entry<String, List<Map.Entry<LabOrderResult, Obs>>> labOrder: labOrderResultObsOrdersMap.entrySet()){ |
| 97 | + String testName = labOrder.getValue().get(0).getKey().getPanelName(); |
| 98 | + if (testName == null) { |
| 99 | + testName = labOrder.getValue().get(0).getKey().getTestName(); |
| 100 | + } |
| 101 | + DiagnosticReport reports = map(labOrder.getKey(),null,testName,patient,practitioners); |
| 102 | + labOrder.getValue().forEach(entry -> { |
| 103 | + FhirLabResult.mapToObsFromLabResult(entry.getKey(), patient, reports, results); |
| 104 | + }); |
95 | 105 | reportList.add(reports);
|
96 | 106 | }
|
97 | 107 |
|
98 | 108 | }
|
99 | 109 | Encounter encounter = fhirResourceMapper.mapToEncounter(labresult.getEncounter());
|
100 |
| - encounter.getClass_().setDisplay("Diagnostic Report"); |
| 110 | + encounter.getClass_().setDisplay("ambulatory"); |
101 | 111 |
|
102 | 112 | return new FhirLabResult(fhirResourceMapper.mapToPatient(labresult.getPatient()),
|
103 | 113 | encounter, labresult.getEncounter().getEncounterDatetime(), reportList, results, practitioners);
|
|
0 commit comments