From 693c8cac3983f18aa7a22b1b476572b4cc9a723a Mon Sep 17 00:00:00 2001 From: Kavitha S Date: Thu, 4 Apr 2024 21:39:31 +0530 Subject: [PATCH] Kavitha | refactor to accept grouped configs --- ui/app/common/patient/services/patientService.js | 10 +++++----- .../controllers/createPatientController.js | 4 +++- .../registration/controllers/editPatientController.js | 11 +++++++---- ui/app/registration/views/editpatient.html | 6 +++--- ui/app/registration/views/newpatient.html | 6 +++--- 5 files changed, 21 insertions(+), 16 deletions(-) diff --git a/ui/app/common/patient/services/patientService.js b/ui/app/common/patient/services/patientService.js index 7bda323bfd..1b373570b6 100644 --- a/ui/app/common/patient/services/patientService.js +++ b/ui/app/common/patient/services/patientService.js @@ -38,12 +38,12 @@ angular.module('bahmni.common.patient') q: query, startIndex: offset, identifier: identifier, - loginLocationUuid: sessionService.getLoginLocationUuid(), - patientSearchResultsConfig: customAttribute + loginLocationUuid: sessionService.getLoginLocationUuid() }; - if (appService.getAppDescriptor().getConfigValue("filterAttributeForAllSearch")) { - searchParams.attributeToFilterOut = appService.getAppDescriptor().getConfigValue("filterAttributeForAllSearch"); - searchParams.attributeValueToFilterOut = appService.getAppDescriptor().getConfigValue("filterAttrValueForAllSearch"); + var filterAttributeForAllSearch = appService.getAppDescriptor().getConfigValue("filterAttributeForAllSearch"); + if (filterAttributeForAllSearch && filterAttributeForAllSearch != undefined) { + searchParams.attributeToFilterOut = filterAttributeForAllSearch.attrName; + searchParams.attributeValueToFilterOut = filterAttributeForAllSearch.attrValue; } return $http.get(Bahmni.Common.Constants.bahmniCommonsSearchUrl + "/patient/lucene", { method: "GET", diff --git a/ui/app/registration/controllers/createPatientController.js b/ui/app/registration/controllers/createPatientController.js index 17481b094a..24283369cc 100644 --- a/ui/app/registration/controllers/createPatientController.js +++ b/ui/app/registration/controllers/createPatientController.js @@ -82,7 +82,9 @@ angular.module('bahmni.registration') _.chain(defaultsWithAnswers).filter(isConcept).each(setDefaultConcept).value(); _.chain(defaultsWithAnswers).filter(isDateType).each(setDefaultValue).value(); - $scope.patient[$scope.prePatientAttribute] = false; + if ($scope.prePatientAttribute && $scope.prePatientAttribute.name) { + $scope.patient[$scope.prePatientAttribute.name] = false; + } }; var expandSectionsWithDefaultValue = function () { diff --git a/ui/app/registration/controllers/editPatientController.js b/ui/app/registration/controllers/editPatientController.js index c3e66cfcd3..4e20731e4e 100644 --- a/ui/app/registration/controllers/editPatientController.js +++ b/ui/app/registration/controllers/editPatientController.js @@ -31,10 +31,13 @@ angular.module('bahmni.registration') $scope.patientLoaded = true; $scope.enableWhatsAppButton = (appService.getAppDescriptor().getConfigValue("enableWhatsAppButton") || Bahmni.Registration.Constants.enableWhatsAppButton) && ($scope.patient.phoneNumber != undefined); $scope.prePatientAttribute = appService.getAppDescriptor().getConfigValue('prePatientAttribute'); - const hideOrDisablePrePatientAttr = appService.getAppDescriptor().getConfigValue('hideOrDisablePrePatientAttr'); - const hidePrePatientAttrOnValue = appService.getAppDescriptor().getConfigValue('hidePrePatientAttrOnValue'); - $scope.hidePrePatientOption = (hideOrDisablePrePatientAttr === "hide" && $scope.patient[$scope.prePatientAttribute].toString() === hidePrePatientAttrOnValue) ? true : false; - $scope.showDisabledPrePatientOption = hideOrDisablePrePatientAttr === "disable" ? true : false; + if ($scope.prePatientAttribute && $scope.prePatientAttribute.name) { + const hideOrDisablePrePatientAttr = $scope.prePatientAttribute.hideOrDisable; + const hidePrePatientAttrOnValue = $scope.prePatientAttribute.hideOnValue; + $scope.showPrePatientOption = !(hideOrDisablePrePatientAttr === "hide" && $scope.patient[$scope.prePatientAttribute.name] && + $scope.patient[$scope.prePatientAttribute.name].toString() === hidePrePatientAttrOnValue); + $scope.showDisabledPrePatientOption = hideOrDisablePrePatientAttr === "disable" ? true : false; + } }; var expandDataFilledSections = function () { diff --git a/ui/app/registration/views/editpatient.html b/ui/app/registration/views/editpatient.html index e5dada95c1..64af34dd9a 100644 --- a/ui/app/registration/views/editpatient.html +++ b/ui/app/registration/views/editpatient.html @@ -20,14 +20,14 @@
{{patient.registrationDate | bahmniDate}}
-
+
- +
diff --git a/ui/app/registration/views/newpatient.html b/ui/app/registration/views/newpatient.html index 4ba08b498c..cb872e665b 100644 --- a/ui/app/registration/views/newpatient.html +++ b/ui/app/registration/views/newpatient.html @@ -42,14 +42,14 @@
-
+
- +