Skip to content

Commit

Permalink
Fix. diagnosis unique id
Browse files Browse the repository at this point in the history
  • Loading branch information
SanoferSameera committed Feb 28, 2024
1 parent 57df5e1 commit c7bef05
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Practitioner> practitioners = getPractitionersFrom(fhirResourceMapper, openMrsDiagnosticReport.getEncounterProviders());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Practitioner> practitioners = getPractitionersFrom(fhirResourceMapper, openMrsDischargeSummary.getEncounter().getEncounterProviders());
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -88,16 +89,25 @@ public static FhirLabResult fromOpenMrsLabResults(OpenMrsLabResults labresult, F
}
}
if(labresult.getLabResults() != null) {
for(Map.Entry<LabOrderResult, Obs> 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<String, List<Map.Entry<LabOrderResult, Obs>>> labOrderResultObsOrdersMap =
labresult.getLabResults().entrySet().stream()
.collect(Collectors.groupingBy(entry -> entry.getKey().getOrderUuid()));

for(Map.Entry<String, List<Map.Entry<LabOrderResult, Obs>>> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<MedicationRequest> medicationRequestsList = openMrsOPConsult.getDrugOrders().stream().
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Practitioner> practitioners = getPractitionersFrom(fhirResourceMapper, openMrsPrescription.getEncounterProviders());
List<MedicationRequest> medicationRequests = medicationRequestsFor(fhirResourceMapper, openMrsPrescription.getDrugOrders());
List<Medication> medications = medicationsFor(fhirResourceMapper, openMrsPrescription.getDrugOrders());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Practitioner> practitioners = docObs.getEncounter().getEncounterProviders()
.stream()
Expand Down Expand Up @@ -87,7 +87,7 @@ public HealthDocumentRecordBundle build(Encounter encounter, List<Obs> 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<Practitioner> practitioners = encounter.getEncounterProviders()
.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Practitioner> practitioners = practitionersFrom(encounter.getEncounterProviders());
Reference patientRef = FHIRUtils.getReferenceToResource(patient);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public WellnessRecordBundle build(Encounter encounter, Map<AbdmConfig.WellnessAt
private WellnessRecordBundle buildWellnessBundle(Encounter encounter, Map<AbdmConfig.WellnessAttribute, List<Obs>> 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<Practitioner> practitioners = practitionersFrom(encounter.getEncounterProviders());
Reference patientRef = FHIRUtils.getReferenceToResource(patient);
List<Observation> observations = new ArrayList<>();
Expand Down

0 comments on commit c7bef05

Please sign in to comment.