Skip to content

Commit

Permalink
BAH-3092 | refactor to display latest diagnoses and test fixes
Browse files Browse the repository at this point in the history
Co-authored-by: Ashish Kurian <[email protected]>
  • Loading branch information
kavitha-sundararajan and AshishkurianTw committed Jul 6, 2023
1 parent 30331d9 commit c9cc008
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
15 changes: 13 additions & 2 deletions ui/app/ot/mappers/SurgicalBlockMapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,20 @@ Bahmni.OT.SurgicalBlockMapper = function () {
};

var mapPrimaryDiagnoses = function (diagnosisObs) {
var primaryDiagnosesNames = _.filter(diagnosisObs, function (diagnosis) {
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");
return _.includes(obsGroupList, "Primary") && !(_.includes(obsGroupList, "Ruled Out Diagnosis"));
}).map(function (diagnosis) {
if (diagnosis.concept.display == "Non-coded Diagnosis") {
return diagnosis.value;
Expand Down
8 changes: 5 additions & 3 deletions ui/test/unit/ot/controller/listViewController.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand All @@ -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 () {
Expand All @@ -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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ describe('surgicalAppointmentService', function () {
expect(mockHttp.get.calls.mostRecent().args[1].params).toEqual({ startDatetime : '2039-08-26T12:00:00.000', endDatetime : '2039-08-26T15:00:00.000',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();
});

Expand Down

0 comments on commit c9cc008

Please sign in to comment.