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 @@ {{appointment.bedNumber}} + + {{appointment.primaryDiagnosis}} + diff --git a/ui/app/styles/ot/_ot.scss b/ui/app/styles/ot/_ot.scss index ef97eed751..a22d26c4e1 100644 --- a/ui/app/styles/ot/_ot.scss +++ b/ui/app/styles/ot/_ot.scss @@ -442,6 +442,10 @@ div[ng-app="ot"] { .status-cancelled { background: #fcb6b6; } + .list-view-primary-diagnosis { + min-width: 300px; + white-space: normal; + } } } diff --git a/ui/test/unit/ot/controller/listViewController.spec.js b/ui/test/unit/ot/controller/listViewController.spec.js index f904a8edd4..17abf3fd1e 100644 --- a/ui/test/unit/ot/controller/listViewController.spec.js +++ b/ui/test/unit/ot/controller/listViewController.spec.js @@ -647,7 +647,7 @@ describe('listViewController', function () { expect(isCancelled).toBeFalsy(); }); - it("should have bed location and bed id in table info", function () { + it("should have bed location, bed id and primary diagnoses in table info", function () { scope.filterParams = { providers: [], locations: {"OT 1": true, "OT 2": true, "OT 3": true}, @@ -659,11 +659,13 @@ describe('listViewController', function () { }; rootScope.attributeTypes = defaultAttributeTypes; createController(); - expect(scope.tableInfo.length).toBe(21); + expect(scope.tableInfo.length).toBe(22); expect(scope.tableInfo[19].heading).toBe("Bed Location"); expect(scope.tableInfo[19].sortInfo).toBe("bedLocation"); expect(scope.tableInfo[20].heading).toBe("Bed ID"); expect(scope.tableInfo[20].sortInfo).toBe("bedNumber"); + expect(scope.tableInfo[21].heading).toBe("Primary Diagnoses"); + expect(scope.tableInfo[21].sortInfo).toBe("patientObservations"); }); it('should have all the surgical attributes in table info', function () { @@ -674,7 +676,7 @@ describe('listViewController', function () { }; rootScope.attributeTypes = defaultAttributeTypes; createController(); - expect(scope.tableInfo.length).toBe(21); + expect(scope.tableInfo.length).toBe(22); expect(scope.tableInfo[11].heading).toBe('procedure'); expect(scope.tableInfo[11].sortInfo).toBe('surgicalAppointmentAttributes.procedure.value'); expect(scope.tableInfo[12].heading).toBe('otherSurgeon'); diff --git a/ui/test/unit/ot/services/surgicalAppointmentService.spec.js b/ui/test/unit/ot/services/surgicalAppointmentService.spec.js index 9bb511ae17..c7905545da 100644 --- a/ui/test/unit/ot/services/surgicalAppointmentService.spec.js +++ b/ui/test/unit/ot/services/surgicalAppointmentService.spec.js @@ -100,7 +100,7 @@ describe('surgicalAppointmentService', function () { expect(mockHttp.get.calls.mostRecent().args[1].params).toEqual({ startDatetime : '2039-08-26T12:00:00.000+0000', endDatetime : '2039-08-26T15:00:00.000+0000',includeVoided: false, activeBlocks: true, 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))"}); expect(mockHttp.get.calls.mostRecent().args[1].withCredentials).toBeTruthy(); });