diff --git a/ui/app/ot/controller/listViewController.js b/ui/app/ot/controller/listViewController.js index b2b66e8581..649d20730d 100644 --- a/ui/app/ot/controller/listViewController.js +++ b/ui/app/ot/controller/listViewController.js @@ -27,8 +27,8 @@ angular.module('bahmni.ot') var attributesRelatedToBed = [{heading: 'Status Change Notes', sortInfo: 'notes'}, {heading: 'Bed Location', sortInfo: 'bedLocation'}, {heading: 'Bed ID', sortInfo: 'bedNumber'}]; - - return listViewAttributes.concat(getSurgicalAttributesTableInfo(), attributesRelatedToBed); + var primaryDiagnosisInfo = [{heading: 'Primary Diagnoses', sortInfo: 'patientObservations'}]; + return listViewAttributes.concat(getSurgicalAttributesTableInfo(), attributesRelatedToBed, primaryDiagnosisInfo); } function getFilteredSurgicalAttributeTypes () { diff --git a/ui/app/ot/mappers/SurgicalBlockMapper.js b/ui/app/ot/mappers/SurgicalBlockMapper.js index 95fa69d8e0..1a7f3e2c13 100644 --- a/ui/app/ot/mappers/SurgicalBlockMapper.js +++ b/ui/app/ot/mappers/SurgicalBlockMapper.js @@ -29,6 +29,30 @@ Bahmni.OT.SurgicalBlockMapper = function () { return mappedAttributes; }; + var mapPrimaryDiagnoses = function (diagnosisObs) { + var uniqueDiagnoses = new Map(); + _.each(diagnosisObs, function (diagnosis) { + var existingDiagnosis = uniqueDiagnoses.get(diagnosis.display); + if (existingDiagnosis) { + if (existingDiagnosis.obsDatetime < diagnosis.obsDatetime) { + uniqueDiagnoses.set(diagnosis.display, diagnosis); + } + } else { + uniqueDiagnoses.set(diagnosis.display, diagnosis); + } + }); + var primaryDiagnosesNames = _.filter(Array.from(uniqueDiagnoses.values()), function (diagnosis) { + var obsGroupList = diagnosis.obsGroup.display.split(": ")[1].split(", "); + return _.includes(obsGroupList, "Primary") && !(_.includes(obsGroupList, "Ruled Out Diagnosis")); + }).map(function (diagnosis) { + if (diagnosis.concept.display == "Non-coded Diagnosis") { + return diagnosis.value; + } + return diagnosis.value.display; + }).join(", "); + return primaryDiagnosesNames; + }; + var mapSurgicalAppointment = function (openMrsSurgicalAppointment, attributeTypes, surgeonsList) { var surgicalAppointmentAttributes = mapOpenMrsSurgicalAppointmentAttributes(openMrsSurgicalAppointment.surgicalAppointmentAttributes, surgeonsList); return { @@ -43,7 +67,8 @@ Bahmni.OT.SurgicalBlockMapper = function () { status: openMrsSurgicalAppointment.status, bedLocation: (openMrsSurgicalAppointment.bedLocation || ""), bedNumber: (openMrsSurgicalAppointment.bedNumber || ""), - surgicalAppointmentAttributes: new Bahmni.OT.SurgicalBlockMapper().mapAttributes(surgicalAppointmentAttributes, attributeTypes) + surgicalAppointmentAttributes: new Bahmni.OT.SurgicalBlockMapper().mapAttributes(surgicalAppointmentAttributes, attributeTypes), + primaryDiagnosis: mapPrimaryDiagnoses(openMrsSurgicalAppointment.patientObservations) || "" }; }; diff --git a/ui/app/ot/services/surgicalAppointmentService.js b/ui/app/ot/services/surgicalAppointmentService.js index fdd9e91918..947a1c055e 100644 --- a/ui/app/ot/services/surgicalAppointmentService.js +++ b/ui/app/ot/services/surgicalAppointmentService.js @@ -61,7 +61,7 @@ angular.module('bahmni.ot') v: "custom:(id,uuid," + "provider:(uuid,person:(uuid,display),attributes:(attributeType:(display),value,voided))," + "location:(uuid,name),startDatetime,endDatetime,surgicalAppointments:(id,uuid,patient:(uuid,display,person:(age))," + - "actualStartDatetime,actualEndDatetime,status,notes,sortWeight,bedNumber,bedLocation,surgicalAppointmentAttributes))" + "actualStartDatetime,actualEndDatetime,status,notes,sortWeight,bedNumber,bedLocation,surgicalAppointmentAttributes,patientObservations))" }, withCredentials: true }); diff --git a/ui/app/ot/views/listView.html b/ui/app/ot/views/listView.html index 024764b81d..f5c080b53d 100644 --- a/ui/app/ot/views/listView.html +++ b/ui/app/ot/views/listView.html @@ -67,6 +67,9 @@