From 298c781d9eb1e6fd25ff3b0dfaafb11644699831 Mon Sep 17 00:00:00 2001 From: SanoferSameera Date: Mon, 29 Jul 2024 09:46:24 +0530 Subject: [PATCH 1/2] BAH-3952 | Refactor. use location uuid instead of parentLocation uuid --- .../bedmanagement/controllers/bedManagementController.js | 8 +++++++- ui/app/common/domain/services/bedService.js | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ui/app/bedmanagement/controllers/bedManagementController.js b/ui/app/bedmanagement/controllers/bedManagementController.js index 1a1287772e..9d0b84cf71 100644 --- a/ui/app/bedmanagement/controllers/bedManagementController.js +++ b/ui/app/bedmanagement/controllers/bedManagementController.js @@ -73,7 +73,13 @@ angular.module('bahmni.ipd') var getWardDetails = function (department) { return _.filter($scope.wards, function (entry) { - return entry.ward.uuid === department.uuid; + if (entry.ward.uuid === department.uuid) { + return true; + } + + return entry.ward.childLocations.some(function (child) { + return child.uuid === department.uuid; + }); }); }; diff --git a/ui/app/common/domain/services/bedService.js b/ui/app/common/domain/services/bedService.js index 3445d0b1db..b36f0fb73b 100644 --- a/ui/app/common/domain/services/bedService.js +++ b/ui/app/common/domain/services/bedService.js @@ -7,8 +7,8 @@ angular.module('bahmni.common.domain') if (!_.isEmpty(results)) { var bed = _.first(results); return { - 'wardName': bed.physicalLocation.parentLocation.display, - 'wardUuid': bed.physicalLocation.parentLocation.uuid, + 'wardName': bed.physicalLocation.display, + 'wardUuid': bed.physicalLocation.uuid, 'physicalLocationName': bed.physicalLocation.name, 'bedNumber': bed.bedNumber, 'bedId': bed.bedId From 35e7a82eb99c5429161ac9d75ee157bd6eaa15ec Mon Sep 17 00:00:00 2001 From: SanoferSameera Date: Mon, 29 Jul 2024 10:34:08 +0530 Subject: [PATCH 2/2] BAH-3952 | Fixed. test failures --- .../controllers/bedManagementController.spec.js | 7 +++++-- ui/test/unit/common/domain/services/bedService.spec.js | 10 ++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/ui/test/unit/bedmanagement/controllers/bedManagementController.spec.js b/ui/test/unit/bedmanagement/controllers/bedManagementController.spec.js index 57a67ebe7a..ad28a42cab 100644 --- a/ui/test/unit/bedmanagement/controllers/bedManagementController.spec.js +++ b/ui/test/unit/bedmanagement/controllers/bedManagementController.spec.js @@ -34,13 +34,16 @@ describe('BedManagementController', function () { uuid: "some uuid", rooms: [ {beds: [], name: "ROOM1", totalBeds: 2, availableBeds: 1} - ] + ], + childLocations: [] } }, { occupiedBeds: 0, totalBeds: 10, - ward: {} + ward: { + childLocations: [] + } } ] }; diff --git a/ui/test/unit/common/domain/services/bedService.spec.js b/ui/test/unit/common/domain/services/bedService.spec.js index cc6c277d75..60d86a1cc5 100644 --- a/ui/test/unit/common/domain/services/bedService.spec.js +++ b/ui/test/unit/common/domain/services/bedService.spec.js @@ -29,9 +29,10 @@ describe("bedService",function () { results:[{ physicalLocation:{ name:'Physical Location Name', + uuid: 'Labour Ward uuid', + display:'Labour Ward', parentLocation:{ - display:'Labour Ward', - uuid:'Labour Ward uuid' + uuid:'Parent Location Uuid' } }, bedNumber:'314-a', @@ -63,9 +64,10 @@ describe("bedService",function () { results:[{ physicalLocation:{ name:'Physical Location Name', + uuid: 'Labour Ward uuid', + display:'Labour Ward', parentLocation:{ - display:'Labour Ward', - uuid:'Labour Ward uuid' + uuid:'Parent Location Uuid' } }, bedNumber:'314-a',