From 6162cd904daf5a853ff6ef4248204de3674b1052 Mon Sep 17 00:00:00 2001 From: Kavitha S Date: Wed, 25 Jan 2023 16:40:08 +0530 Subject: [PATCH 1/8] BAH-2763 | added sending prescription in sms feature from dashboard --- .../common/services/treatmentService.js | 25 +++++++++++++++++-- .../patientDashboardTreatmentController.js | 12 ++++++--- .../directives/treatmentTable.js | 6 +++++ .../treatmentData/views/treatmentTable.html | 3 ++- ui/app/clinical/index.html | 2 ++ ui/app/clinical/initialization.js | 17 ++++++++++--- .../common/config/services/configurations.js | 8 ++++++ .../domain/services/configurationService.js | 24 ++++++++++++++++++ ...atientDashboardTreatmentController.spec.js | 12 ++++++--- 9 files changed, 96 insertions(+), 13 deletions(-) diff --git a/ui/app/clinical/common/services/treatmentService.js b/ui/app/clinical/common/services/treatmentService.js index c98d39be4c..c109471781 100644 --- a/ui/app/clinical/common/services/treatmentService.js +++ b/ui/app/clinical/common/services/treatmentService.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('bahmni.clinical') - .factory('treatmentService', ['$http', '$q', 'appService', '$rootScope', function ($http, $q, appService, $rootScope) { + .factory('treatmentService', ['$http', '$q', 'appService', '$rootScope', '$filter', function ($http, $q, appService, $rootScope, $filter) { var createDrugOrder = function (drugOrder) { return Bahmni.Clinical.DrugOrder.create(drugOrder); }; @@ -135,6 +135,26 @@ angular.module('bahmni.clinical') return deferred.promise; }; + var getMessageForPrescription = function (patientData, drugOrderSection) { + var message = "Date: " + $filter("bahmniDate")(drugOrderSection.visitDate); + message += "\nPrescription For Patient: " + patientData.name + ", " + patientData.gender + ", " + patientData.age + "years."; + var doctorArray = []; + var prescriptionDetails = ""; + for (var counter = 0; counter < drugOrderSection.drugOrders.length; counter++) { + var drugOrder = drugOrderSection.drugOrders[counter]; + prescriptionDetails += "\n" + (counter + 1) + ". " + drugOrder.getDisplayName() + ", " + drugOrder.getDescriptionWithoutRouteAndDuration() + drugOrder.getSpanDetails() + ", start from " + $filter("bahmniDate")(drugOrder.effectiveStartDate); + if (drugOrder.isDiscontinuedOrStopped()) { + prescriptionDetails += ", stopped on " + $filter("bahmniDate")(drugOrder.effectiveStopDate); + } + if (!doctorArray.includes("Dr. " + drugOrder.provider.name)) { + doctorArray.push("Dr. " + drugOrder.provider.name); + } + } + var doctorDetails = "Doctor: " + doctorArray.join(", ") + " (" + $rootScope.loggedInLocation.name + ")"; + message += "\n" + doctorDetails + prescriptionDetails; + return message; + }; + return { getActiveDrugOrders: getActiveDrugOrders, getConfig: getConfig, @@ -142,6 +162,7 @@ angular.module('bahmni.clinical') getPrescribedAndActiveDrugOrders: getPrescribedAndActiveDrugOrders, getNonCodedDrugConcept: getNonCodedDrugConcept, getAllDrugOrdersFor: getAllDrugOrdersFor, - voidDrugOrder: voidDrugOrder + voidDrugOrder: voidDrugOrder, + getMessageForPrescription: getMessageForPrescription }; }]); diff --git a/ui/app/clinical/dashboard/controllers/patientDashboardTreatmentController.js b/ui/app/clinical/dashboard/controllers/patientDashboardTreatmentController.js index b75ae055cb..8d4c9d8389 100644 --- a/ui/app/clinical/dashboard/controllers/patientDashboardTreatmentController.js +++ b/ui/app/clinical/dashboard/controllers/patientDashboardTreatmentController.js @@ -1,11 +1,12 @@ 'use strict'; angular.module('bahmni.clinical') - .controller('PatientDashboardTreatmentController', ['$scope', 'ngDialog', 'visitActionsService', - function ($scope, ngDialog, visitActionsService) { + .controller('PatientDashboardTreatmentController', ['$scope', 'ngDialog', 'visitActionsService', 'smsService', 'treatmentService', + function ($scope, ngDialog, visitActionsService, smsService, treatmentService) { var treatmentConfigParams = $scope.dashboard.getSectionByType("treatment") || {}; $scope.isEmailPresent = $scope.patient.email ? true : false; - var patientParams = {"patientUuid": $scope.patient.uuid, "isEmailPresent": $scope.isEmailPresent}; + $scope.isPhoneNumberPresent = $scope.patient.phoneNumber ? true : false; + var patientParams = {"patientUuid": $scope.patient.uuid, "isEmailPresent": $scope.isEmailPresent, "isPhoneNumberPresent": $scope.isPhoneNumberPresent}; $scope.dashboardConfig = {}; $scope.expandedViewConfig = {}; @@ -26,6 +27,11 @@ angular.module('bahmni.clinical') visitActionsService.printPrescription($scope.patient, visitStartDate, visitUuid); }); + $scope.$on("event:sendSMSForPrescription", function (event, drugOrderSection) { + var patientData = {"name": $scope.patient.name, "gender": $scope.patient.gender, "age": $scope.patient.age}; + smsService.sendSMS($scope.patient.phoneNumber.value, treatmentService.getMessageForPrescription(patientData, drugOrderSection)); + }); + var cleanUpListener = $scope.$on('ngDialog.closing', function () { $("body").removeClass('ngdialog-open'); }); diff --git a/ui/app/clinical/displaycontrols/treatmentData/directives/treatmentTable.js b/ui/app/clinical/displaycontrols/treatmentData/directives/treatmentTable.js index 15f3ecc7c3..f27cb000ea 100644 --- a/ui/app/clinical/displaycontrols/treatmentData/directives/treatmentTable.js +++ b/ui/app/clinical/displaycontrols/treatmentData/directives/treatmentTable.js @@ -3,6 +3,8 @@ angular.module('bahmni.clinical') .directive('treatmentTable', function () { var controller = function ($scope, $rootScope) { + $scope.prescriptionEmailToggle = $rootScope.prescriptionEmailToggle; + $scope.prescriptionSMSToggle = $rootScope.prescriptionSMSToggle; $scope.isOtherActiveSection = function (dateString) { return dateString === Bahmni.Clinical.Constants.otherActiveDrugOrders; }; @@ -17,6 +19,10 @@ angular.module('bahmni.clinical') $scope.downloadPrescription = function (visitStartDate, visitUuid) { $rootScope.$broadcast("event:downloadPrescriptionFromDashboard", visitStartDate, visitUuid); }; + + $scope.sendSMSForPrescription = function (drugOrderSection) { + $rootScope.$broadcast("event:sendSMSForPrescription", drugOrderSection); + }; }; return { diff --git a/ui/app/clinical/displaycontrols/treatmentData/views/treatmentTable.html b/ui/app/clinical/displaycontrols/treatmentData/views/treatmentTable.html index 71bf634bd9..d2070ce75c 100644 --- a/ui/app/clinical/displaycontrols/treatmentData/views/treatmentTable.html +++ b/ui/app/clinical/displaycontrols/treatmentData/views/treatmentTable.html @@ -11,7 +11,8 @@

{{::params | titleTran diff --git a/ui/app/clinical/index.html b/ui/app/clinical/index.html index 05f2b28130..c2b72f135b 100644 --- a/ui/app/clinical/index.html +++ b/ui/app/clinical/index.html @@ -344,6 +344,8 @@

+ + diff --git a/ui/app/clinical/initialization.js b/ui/app/clinical/initialization.js index d311beb96e..278ec7a59b 100644 --- a/ui/app/clinical/initialization.js +++ b/ui/app/clinical/initialization.js @@ -1,8 +1,8 @@ 'use strict'; angular.module('bahmni.clinical').factory('initialization', - ['$rootScope', 'authenticator', 'appService', 'spinner', 'configurations', 'orderTypeService', 'mergeService', '$q', 'messagingService', - function ($rootScope, authenticator, appService, spinner, configurations, orderTypeService, mergeService, $q, messagingService) { + ['$rootScope', 'authenticator', 'appService', 'spinner', 'configurations', 'orderTypeService', 'mergeService', '$q', 'messagingService', 'locationService', + function ($rootScope, authenticator, appService, spinner, configurations, orderTypeService, mergeService, $q, messagingService, locationService) { return function (config) { var loadConfigPromise = function () { return configurations.load([ @@ -17,11 +17,15 @@ angular.module('bahmni.clinical').factory('initialization', 'stoppedOrderReasonConfig', 'genderMap', 'relationshipTypeMap', - 'defaultEncounterType' + 'defaultEncounterType', + 'prescriptionSMSToggle', + 'prescriptionEmailToggle' ]).then(function () { $rootScope.genderMap = configurations.genderMap(); $rootScope.relationshipTypeMap = configurations.relationshipTypeMap(); $rootScope.diagnosisStatus = (appService.getAppDescriptor().getConfig("diagnosisStatus") && appService.getAppDescriptor().getConfig("diagnosisStatus").value || "RULED OUT"); + $rootScope.prescriptionSMSToggle = configurations.prescriptionSMSToggle(); + $rootScope.prescriptionEmailToggle = configurations.prescriptionEmailToggle(); }); }; @@ -43,11 +47,18 @@ angular.module('bahmni.clinical').factory('initialization', } }; + var loggedInLocation = function () { + return locationService.getLoggedInLocation().then(function (location) { + $rootScope.loggedInLocation = location; + }); + }; + return spinner.forPromise(authenticator.authenticateUser() .then(initApp) .then(checkPrivilege) .then(loadConfigPromise) .then(mergeFormConditions) + .then(loggedInLocation) .then(orderTypeService.loadAll)); }; } diff --git a/ui/app/common/config/services/configurations.js b/ui/app/common/config/services/configurations.js index f51e358bad..1e52026af3 100644 --- a/ui/app/common/config/services/configurations.js +++ b/ui/app/common/config/services/configurations.js @@ -86,4 +86,12 @@ angular.module('bahmni.common.config') this.helpDeskNumber = function () { return this.configs.helpDeskNumber; }; + + this.prescriptionSMSToggle = function () { + return this.configs.prescriptionSMSToggle; + }; + + this.prescriptionEmailToggle = function () { + return this.configs.prescriptionEmailToggle; + }; }]); diff --git a/ui/app/common/domain/services/configurationService.js b/ui/app/common/domain/services/configurationService.js index 242f16812f..f34a6f2c86 100644 --- a/ui/app/common/domain/services/configurationService.js +++ b/ui/app/common/domain/services/configurationService.js @@ -183,6 +183,30 @@ angular.module('bahmni.common.domain') }); }; + configurationFunctions.prescriptionSMSToggle = function () { + return $http.get(Bahmni.Common.Constants.globalPropertyUrl, { + params: { + property: 'sms.enablePrescriptionSMSAlert' + }, + withCredentials: true, + transformResponse: [function (data) { + return data; + }] + }); + }; + + configurationFunctions.prescriptionEmailToggle = function () { + return $http.get(Bahmni.Common.Constants.globalPropertyUrl, { + params: { + property: 'sms.enablePrescriptionEmailAlert' + }, + withCredentials: true, + transformResponse: [function (data) { + return data; + }] + }); + }; + configurationFunctions.helpDeskNumber = function () { return $http.get(Bahmni.Common.Constants.globalPropertyUrl, { params: { diff --git a/ui/test/unit/clinical/controllers/patientDashboardTreatmentController.spec.js b/ui/test/unit/clinical/controllers/patientDashboardTreatmentController.spec.js index 9c70c6193b..90a55bae08 100644 --- a/ui/test/unit/clinical/controllers/patientDashboardTreatmentController.spec.js +++ b/ui/test/unit/clinical/controllers/patientDashboardTreatmentController.spec.js @@ -4,7 +4,7 @@ describe("PatientDashboardTreatmentController", function () { beforeEach(module('bahmni.clinical')); - var scope, ngDialog; + var scope, ngDialog, treatmentService, smsService; var treatmentConfigParams = { title: "Treatments", @@ -34,6 +34,8 @@ describe("PatientDashboardTreatmentController", function () { }; ngDialog = jasmine.createSpyObj('ngDialog', ['open']); + treatmentService = jasmine.createSpyObj('treatmentService', ['getMessageForPrescription']); + smsService = jasmine.createSpyObj('smsService', ['sendSMS']); var config = { "dashboardName": "General", @@ -44,7 +46,9 @@ describe("PatientDashboardTreatmentController", function () { $controller('PatientDashboardTreatmentController', { $scope: scope, - ngDialog: ngDialog + ngDialog: ngDialog, + treatmentService: treatmentService, + smsService: smsService }); }) ) @@ -59,13 +63,13 @@ describe("PatientDashboardTreatmentController", function () { describe("Should fetch configuration", function () { it("should fetch dashboard params", function () { var expected = {}; - _.extend(expected, treatmentConfigParams.dashboardConfig || {}, {patientUuid: "patient uuid", isEmailPresent: false}); + _.extend(expected, treatmentConfigParams.dashboardConfig || {}, {patientUuid: "patient uuid", isEmailPresent: false, isPhoneNumberPresent: false}); expect(expected).toEqual(scope.dashboardConfig); }); it("should fetch summary page params", function () { var expected = {}; - _.extend(expected, treatmentConfigParams.expandedViewConfig || {}, {patientUuid: "patient uuid", isEmailPresent: false}); + _.extend(expected, treatmentConfigParams.expandedViewConfig || {}, {patientUuid: "patient uuid", isEmailPresent: false, isPhoneNumberPresent: false}); expect(expected).toEqual(scope.expandedViewConfig); }); }); From 825452c1e64e636f3d3b1695871151c1cacaba84 Mon Sep 17 00:00:00 2001 From: Kavitha S Date: Fri, 27 Jan 2023 13:26:07 +0530 Subject: [PATCH 2/8] BAH-2763 | updated the property name for email alert --- ui/app/common/domain/services/configurationService.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/app/common/domain/services/configurationService.js b/ui/app/common/domain/services/configurationService.js index f34a6f2c86..5acc78dc5a 100644 --- a/ui/app/common/domain/services/configurationService.js +++ b/ui/app/common/domain/services/configurationService.js @@ -198,7 +198,7 @@ angular.module('bahmni.common.domain') configurationFunctions.prescriptionEmailToggle = function () { return $http.get(Bahmni.Common.Constants.globalPropertyUrl, { params: { - property: 'sms.enablePrescriptionEmailAlert' + property: 'email.enablePrescriptionEmailAlert' }, withCredentials: true, transformResponse: [function (data) { From ad65e88a253656975f12b977e4e11b40ad10941a Mon Sep 17 00:00:00 2001 From: Kavitha S Date: Fri, 27 Jan 2023 13:56:08 +0530 Subject: [PATCH 3/8] BAH-2763 | refactored prescription message to be read from translation template --- .../common/services/treatmentService.js | 18 ++++++++++++------ ui/app/clinical/constants.js | 3 ++- ui/app/i18n/clinical/locale_en.json | 3 ++- .../common/services/treatmentService.spec.js | 4 +++- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/ui/app/clinical/common/services/treatmentService.js b/ui/app/clinical/common/services/treatmentService.js index c109471781..fccf72f53d 100644 --- a/ui/app/clinical/common/services/treatmentService.js +++ b/ui/app/clinical/common/services/treatmentService.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('bahmni.clinical') - .factory('treatmentService', ['$http', '$q', 'appService', '$rootScope', '$filter', function ($http, $q, appService, $rootScope, $filter) { + .factory('treatmentService', ['$http', '$q', 'appService', '$rootScope', '$filter', '$translate', function ($http, $q, appService, $rootScope, $filter, $translate) { var createDrugOrder = function (drugOrder) { return Bahmni.Clinical.DrugOrder.create(drugOrder); }; @@ -136,13 +136,17 @@ angular.module('bahmni.clinical') }; var getMessageForPrescription = function (patientData, drugOrderSection) { - var message = "Date: " + $filter("bahmniDate")(drugOrderSection.visitDate); - message += "\nPrescription For Patient: " + patientData.name + ", " + patientData.gender + ", " + patientData.age + "years."; + var message = $translate.instant(appService.getAppDescriptor().getConfigValue("prescriptionMessage") || Bahmni.Clinical.Constants.prescriptionMessage); + message = message.replace("#visitDate", $filter("bahmniDate")(drugOrderSection.visitDate)); + message = message.replace("#patientName", patientData.name); + message = message.replace("#gender", patientData.gender); + message = message.replace("#age", patientData.age); + var doctorArray = []; var prescriptionDetails = ""; for (var counter = 0; counter < drugOrderSection.drugOrders.length; counter++) { var drugOrder = drugOrderSection.drugOrders[counter]; - prescriptionDetails += "\n" + (counter + 1) + ". " + drugOrder.getDisplayName() + ", " + drugOrder.getDescriptionWithoutRouteAndDuration() + drugOrder.getSpanDetails() + ", start from " + $filter("bahmniDate")(drugOrder.effectiveStartDate); + prescriptionDetails += (counter + 1) + ". " + drugOrder.getDisplayName() + ", " + drugOrder.getDescriptionWithoutRouteAndDuration() + drugOrder.getSpanDetails() + ", start from " + $filter("bahmniDate")(drugOrder.effectiveStartDate) + "\n"; if (drugOrder.isDiscontinuedOrStopped()) { prescriptionDetails += ", stopped on " + $filter("bahmniDate")(drugOrder.effectiveStopDate); } @@ -150,8 +154,10 @@ angular.module('bahmni.clinical') doctorArray.push("Dr. " + drugOrder.provider.name); } } - var doctorDetails = "Doctor: " + doctorArray.join(", ") + " (" + $rootScope.loggedInLocation.name + ")"; - message += "\n" + doctorDetails + prescriptionDetails; + + message = message.replace("#doctorDetail", doctorArray.join(", ")); + message = message.replace("#clinicName", $rootScope.loggedInLocation.name); + message = message.replace("#prescriptionDetails", prescriptionDetails); return message; }; diff --git a/ui/app/clinical/constants.js b/ui/app/clinical/constants.js index df02b76d72..278aefecd8 100644 --- a/ui/app/clinical/constants.js +++ b/ui/app/clinical/constants.js @@ -70,7 +70,8 @@ Bahmni.Clinical.Constants = (function () { globalPropertyToFetchActivePatients: 'emrapi.sqlSearch.activePatients', adtPrivilege: "app:adt", adtForwardUrl: "../adt/#/patient/{{patientUuid}}/visit/{{visitUuid}}/", - certificateHeader: "Certificate Header" + certificateHeader: "Certificate Header", + prescriptionMessage: "PRESCRIPTION_MESSAGE" }; })(); diff --git a/ui/app/i18n/clinical/locale_en.json b/ui/app/i18n/clinical/locale_en.json index 965fbe0166..7db7041191 100644 --- a/ui/app/i18n/clinical/locale_en.json +++ b/ui/app/i18n/clinical/locale_en.json @@ -369,5 +369,6 @@ "CHIEF_COMPLAINT_DATA_CONCEPT_NAME_KEY": "Chief Complaint Data", "CHIEF_COMPLAINT_DATA_OTHER_CONCEPT_KEY": "Other generic", "CHIEF_COMPLAINT_DATA_OTHER_CONCEPT_TEMPLATE_KEY": "{{chiefComplaint}} ({{chiefComplaintText}}) since {{duration}} {{unit}}", - "CHIEF_COMPLAINT_DATA_WITHOUT_OTHER_CONCEPT_TEMPLATE_KEY": "{{chiefComplaint}} since {{duration}} {{unit}}" + "CHIEF_COMPLAINT_DATA_WITHOUT_OTHER_CONCEPT_TEMPLATE_KEY": "{{chiefComplaint}} since {{duration}} {{unit}}", + "PRESCRIPTION_MESSAGE": "Date: #visitDate\nPrescription For Patient: #patientName, #gender, #age years. \nDoctor: #doctorDetail\n#prescriptionDetails" } diff --git a/ui/test/unit/clinical/common/services/treatmentService.spec.js b/ui/test/unit/clinical/common/services/treatmentService.spec.js index 70674c4c61..b8303996fe 100644 --- a/ui/test/unit/clinical/common/services/treatmentService.spec.js +++ b/ui/test/unit/clinical/common/services/treatmentService.spec.js @@ -15,9 +15,11 @@ describe("TreamentService", function () { var appDescriptor = jasmine.createSpyObj('appDescriptor', ['getConfigValue']); appDescriptor.getConfigValue.and.returnValue({showDetailsWithinDateRange: false}); appService.getAppDescriptor.and.returnValue(appDescriptor); + var $translate = jasmine.createSpyObj('$translate', ['instant']); $provide.value('$http', _$http); $provide.value('$q', Q); - $provide.value('appService',appService); + $provide.value('appService', appService); + $provide.value('$translate', $translate); })); From 58c423f4d0a168172e6bbf5c27edcb94ac611f6d Mon Sep 17 00:00:00 2001 From: Kavitha S Date: Thu, 2 Feb 2023 23:19:14 +0530 Subject: [PATCH 4/8] BAH-2763 | refactor to move sms related functionality to backend --- .../common/services/treatmentService.js | 45 +++++++------------ ui/app/clinical/constants.js | 2 +- .../patientDashboardTreatmentController.js | 9 +--- .../directives/treatmentTable.js | 12 +++-- .../treatmentData/views/treatmentTable.html | 2 +- ui/app/clinical/index.html | 1 - ui/app/clinical/initialization.js | 11 +---- ui/app/common/constants.js | 3 +- .../domain/services/configurationService.js | 4 +- ui/app/i18n/clinical/locale_en.json | 4 +- .../registration/services/patientService.js | 2 +- ...atientDashboardTreatmentController.spec.js | 10 ++--- .../displaycontrols/treatmentTable.spec.js | 16 +++++++ 13 files changed, 59 insertions(+), 62 deletions(-) diff --git a/ui/app/clinical/common/services/treatmentService.js b/ui/app/clinical/common/services/treatmentService.js index fccf72f53d..d6215791e5 100644 --- a/ui/app/clinical/common/services/treatmentService.js +++ b/ui/app/clinical/common/services/treatmentService.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('bahmni.clinical') - .factory('treatmentService', ['$http', '$q', 'appService', '$rootScope', '$filter', '$translate', function ($http, $q, appService, $rootScope, $filter, $translate) { + .factory('treatmentService', ['$http', '$q', 'appService', '$rootScope', '$translate', function ($http, $q, appService, $rootScope, $translate) { var createDrugOrder = function (drugOrder) { return Bahmni.Clinical.DrugOrder.create(drugOrder); }; @@ -125,6 +125,21 @@ angular.module('bahmni.clinical') return deferred.promise; }; + var sendPrescriptionSMS = function (visitUuid) { + var deferred = $q.defer(); + var locale = $translate.instant(appService.getAppDescriptor().getConfigValue("smsLanguage") || Bahmni.Clinical.Constants.smsLanguage); + $http.post(Bahmni.Common.Constants.bahmniDrugOrderUrl + "/sendPrescriptionSMS", {"visitUuid": visitUuid, "locale": locale}, { + withCredentials: true, + headers: {"Content-Type": "application/json"} + }).success(function (response) { + if (response.status != 200) { + response.error = true; + } + deferred.resolve(response); + }); + return deferred.promise; + }; + var voidDrugOrder = function (drugOrder) { var deferred = $q.defer(); @@ -135,32 +150,6 @@ angular.module('bahmni.clinical') return deferred.promise; }; - var getMessageForPrescription = function (patientData, drugOrderSection) { - var message = $translate.instant(appService.getAppDescriptor().getConfigValue("prescriptionMessage") || Bahmni.Clinical.Constants.prescriptionMessage); - message = message.replace("#visitDate", $filter("bahmniDate")(drugOrderSection.visitDate)); - message = message.replace("#patientName", patientData.name); - message = message.replace("#gender", patientData.gender); - message = message.replace("#age", patientData.age); - - var doctorArray = []; - var prescriptionDetails = ""; - for (var counter = 0; counter < drugOrderSection.drugOrders.length; counter++) { - var drugOrder = drugOrderSection.drugOrders[counter]; - prescriptionDetails += (counter + 1) + ". " + drugOrder.getDisplayName() + ", " + drugOrder.getDescriptionWithoutRouteAndDuration() + drugOrder.getSpanDetails() + ", start from " + $filter("bahmniDate")(drugOrder.effectiveStartDate) + "\n"; - if (drugOrder.isDiscontinuedOrStopped()) { - prescriptionDetails += ", stopped on " + $filter("bahmniDate")(drugOrder.effectiveStopDate); - } - if (!doctorArray.includes("Dr. " + drugOrder.provider.name)) { - doctorArray.push("Dr. " + drugOrder.provider.name); - } - } - - message = message.replace("#doctorDetail", doctorArray.join(", ")); - message = message.replace("#clinicName", $rootScope.loggedInLocation.name); - message = message.replace("#prescriptionDetails", prescriptionDetails); - return message; - }; - return { getActiveDrugOrders: getActiveDrugOrders, getConfig: getConfig, @@ -169,6 +158,6 @@ angular.module('bahmni.clinical') getNonCodedDrugConcept: getNonCodedDrugConcept, getAllDrugOrdersFor: getAllDrugOrdersFor, voidDrugOrder: voidDrugOrder, - getMessageForPrescription: getMessageForPrescription + sendPrescriptionSMS: sendPrescriptionSMS }; }]); diff --git a/ui/app/clinical/constants.js b/ui/app/clinical/constants.js index 278aefecd8..be54c367c9 100644 --- a/ui/app/clinical/constants.js +++ b/ui/app/clinical/constants.js @@ -71,7 +71,7 @@ Bahmni.Clinical.Constants = (function () { adtPrivilege: "app:adt", adtForwardUrl: "../adt/#/patient/{{patientUuid}}/visit/{{visitUuid}}/", certificateHeader: "Certificate Header", - prescriptionMessage: "PRESCRIPTION_MESSAGE" + smsLanguage: "SMS_LANGUAGE" }; })(); diff --git a/ui/app/clinical/dashboard/controllers/patientDashboardTreatmentController.js b/ui/app/clinical/dashboard/controllers/patientDashboardTreatmentController.js index 8d4c9d8389..fd36e40d9d 100644 --- a/ui/app/clinical/dashboard/controllers/patientDashboardTreatmentController.js +++ b/ui/app/clinical/dashboard/controllers/patientDashboardTreatmentController.js @@ -1,8 +1,8 @@ 'use strict'; angular.module('bahmni.clinical') - .controller('PatientDashboardTreatmentController', ['$scope', 'ngDialog', 'visitActionsService', 'smsService', 'treatmentService', - function ($scope, ngDialog, visitActionsService, smsService, treatmentService) { + .controller('PatientDashboardTreatmentController', ['$scope', 'ngDialog', 'visitActionsService', + function ($scope, ngDialog, visitActionsService) { var treatmentConfigParams = $scope.dashboard.getSectionByType("treatment") || {}; $scope.isEmailPresent = $scope.patient.email ? true : false; $scope.isPhoneNumberPresent = $scope.patient.phoneNumber ? true : false; @@ -27,11 +27,6 @@ angular.module('bahmni.clinical') visitActionsService.printPrescription($scope.patient, visitStartDate, visitUuid); }); - $scope.$on("event:sendSMSForPrescription", function (event, drugOrderSection) { - var patientData = {"name": $scope.patient.name, "gender": $scope.patient.gender, "age": $scope.patient.age}; - smsService.sendSMS($scope.patient.phoneNumber.value, treatmentService.getMessageForPrescription(patientData, drugOrderSection)); - }); - var cleanUpListener = $scope.$on('ngDialog.closing', function () { $("body").removeClass('ngdialog-open'); }); diff --git a/ui/app/clinical/displaycontrols/treatmentData/directives/treatmentTable.js b/ui/app/clinical/displaycontrols/treatmentData/directives/treatmentTable.js index f27cb000ea..6e30dc2d3f 100644 --- a/ui/app/clinical/displaycontrols/treatmentData/directives/treatmentTable.js +++ b/ui/app/clinical/displaycontrols/treatmentData/directives/treatmentTable.js @@ -2,7 +2,7 @@ angular.module('bahmni.clinical') .directive('treatmentTable', function () { - var controller = function ($scope, $rootScope) { + var controller = function ($scope, $rootScope, treatmentService, messagingService) { $scope.prescriptionEmailToggle = $rootScope.prescriptionEmailToggle; $scope.prescriptionSMSToggle = $rootScope.prescriptionSMSToggle; $scope.isOtherActiveSection = function (dateString) { @@ -20,8 +20,14 @@ angular.module('bahmni.clinical') $rootScope.$broadcast("event:downloadPrescriptionFromDashboard", visitStartDate, visitUuid); }; - $scope.sendSMSForPrescription = function (drugOrderSection) { - $rootScope.$broadcast("event:sendSMSForPrescription", drugOrderSection); + $scope.sendSMSForPrescription = function (visitUuid) { + treatmentService.sendPrescriptionSMS(visitUuid).then(function (data) { + if (data.error) { + messagingService.showMessage("error", "MESSAGE_SENDING_SMS_FAILURE"); + } else { + messagingService.showMessage("info", "MESSAGE_SENDING_SMS_SUCCESS"); + } + }); }; }; diff --git a/ui/app/clinical/displaycontrols/treatmentData/views/treatmentTable.html b/ui/app/clinical/displaycontrols/treatmentData/views/treatmentTable.html index d2070ce75c..8549db9ec3 100644 --- a/ui/app/clinical/displaycontrols/treatmentData/views/treatmentTable.html +++ b/ui/app/clinical/displaycontrols/treatmentData/views/treatmentTable.html @@ -12,7 +12,7 @@

{{::params | titleTran diff --git a/ui/app/clinical/index.html b/ui/app/clinical/index.html index c2b72f135b..bb91a511f6 100644 --- a/ui/app/clinical/index.html +++ b/ui/app/clinical/index.html @@ -345,7 +345,6 @@

- diff --git a/ui/app/clinical/initialization.js b/ui/app/clinical/initialization.js index 278ec7a59b..f636cde5b1 100644 --- a/ui/app/clinical/initialization.js +++ b/ui/app/clinical/initialization.js @@ -1,8 +1,8 @@ 'use strict'; angular.module('bahmni.clinical').factory('initialization', - ['$rootScope', 'authenticator', 'appService', 'spinner', 'configurations', 'orderTypeService', 'mergeService', '$q', 'messagingService', 'locationService', - function ($rootScope, authenticator, appService, spinner, configurations, orderTypeService, mergeService, $q, messagingService, locationService) { + ['$rootScope', 'authenticator', 'appService', 'spinner', 'configurations', 'orderTypeService', 'mergeService', '$q', 'messagingService', + function ($rootScope, authenticator, appService, spinner, configurations, orderTypeService, mergeService, $q, messagingService) { return function (config) { var loadConfigPromise = function () { return configurations.load([ @@ -47,18 +47,11 @@ angular.module('bahmni.clinical').factory('initialization', } }; - var loggedInLocation = function () { - return locationService.getLoggedInLocation().then(function (location) { - $rootScope.loggedInLocation = location; - }); - }; - return spinner.forPromise(authenticator.authenticateUser() .then(initApp) .then(checkPrivilege) .then(loadConfigPromise) .then(mergeFormConditions) - .then(loggedInLocation) .then(orderTypeService.loadAll)); }; } diff --git a/ui/app/common/constants.js b/ui/app/common/constants.js index b66a81354c..b3f2b2564c 100644 --- a/ui/app/common/constants.js +++ b/ui/app/common/constants.js @@ -278,7 +278,8 @@ Bahmni.Common = Bahmni.Common || {}; defaultImageUploadSize: 500000, // Default patient profile photo size maxImageUploadSize: 9000000, // to ensure, extreme max size and prevent choking up server capacity (max size is 9MB) adhocTeleconsultationLinkServiceUrl: RESTWS_V1 + "/adhocTeleconsultation/generateAdhocTeleconsultationLink", - otpServiceUrl: "/otp-service" + otpServiceUrl: "/otp-service", + sendSMSForPrescription: RESTWS_V1 + "/send/prescriptionSMS" }; })(); diff --git a/ui/app/common/domain/services/configurationService.js b/ui/app/common/domain/services/configurationService.js index 5acc78dc5a..d20a955b99 100644 --- a/ui/app/common/domain/services/configurationService.js +++ b/ui/app/common/domain/services/configurationService.js @@ -186,7 +186,7 @@ angular.module('bahmni.common.domain') configurationFunctions.prescriptionSMSToggle = function () { return $http.get(Bahmni.Common.Constants.globalPropertyUrl, { params: { - property: 'sms.enablePrescriptionSMSAlert' + property: 'bahmni.enableSMSPrescriptionOption' }, withCredentials: true, transformResponse: [function (data) { @@ -198,7 +198,7 @@ angular.module('bahmni.common.domain') configurationFunctions.prescriptionEmailToggle = function () { return $http.get(Bahmni.Common.Constants.globalPropertyUrl, { params: { - property: 'email.enablePrescriptionEmailAlert' + property: 'bahmni.enableEmailPrescriptionOption' }, withCredentials: true, transformResponse: [function (data) { diff --git a/ui/app/i18n/clinical/locale_en.json b/ui/app/i18n/clinical/locale_en.json index 7db7041191..6c07c29ace 100644 --- a/ui/app/i18n/clinical/locale_en.json +++ b/ui/app/i18n/clinical/locale_en.json @@ -370,5 +370,7 @@ "CHIEF_COMPLAINT_DATA_OTHER_CONCEPT_KEY": "Other generic", "CHIEF_COMPLAINT_DATA_OTHER_CONCEPT_TEMPLATE_KEY": "{{chiefComplaint}} ({{chiefComplaintText}}) since {{duration}} {{unit}}", "CHIEF_COMPLAINT_DATA_WITHOUT_OTHER_CONCEPT_TEMPLATE_KEY": "{{chiefComplaint}} since {{duration}} {{unit}}", - "PRESCRIPTION_MESSAGE": "Date: #visitDate\nPrescription For Patient: #patientName, #gender, #age years. \nDoctor: #doctorDetail\n#prescriptionDetails" + "SMS_LANGUAGE": "en", + "MESSAGE_SENDING_SMS_SUCCESS" : "SMS sent successfully", + "MESSAGE_SENDING_SMS_FAILURE" : "Failed to send SMS . Please check SMS configuration settings" } diff --git a/ui/app/registration/services/patientService.js b/ui/app/registration/services/patientService.js index e642432f20..5ab8082b85 100644 --- a/ui/app/registration/services/patientService.js +++ b/ui/app/registration/services/patientService.js @@ -93,7 +93,7 @@ angular.module('bahmni.registration') var getRegistrationMessage = function (patientId, name, age, gender) { var clinicName = $rootScope.loggedInLocation.name; var message = $translate.instant(appService.getAppDescriptor().getConfigValue("registrationMessage") || Bahmni.Registration.Constants.registrationMessage); - message = message.replace("#clinicName", clinicName); + message = message.replace("#locationName", clinicName); message = message.replace("#patientId", patientId); message = message.replace("#name", name); message = message.replace("#age", age); diff --git a/ui/test/unit/clinical/controllers/patientDashboardTreatmentController.spec.js b/ui/test/unit/clinical/controllers/patientDashboardTreatmentController.spec.js index 90a55bae08..a9d2487637 100644 --- a/ui/test/unit/clinical/controllers/patientDashboardTreatmentController.spec.js +++ b/ui/test/unit/clinical/controllers/patientDashboardTreatmentController.spec.js @@ -4,7 +4,7 @@ describe("PatientDashboardTreatmentController", function () { beforeEach(module('bahmni.clinical')); - var scope, ngDialog, treatmentService, smsService; + var scope, ngDialog; var treatmentConfigParams = { title: "Treatments", @@ -34,9 +34,7 @@ describe("PatientDashboardTreatmentController", function () { }; ngDialog = jasmine.createSpyObj('ngDialog', ['open']); - treatmentService = jasmine.createSpyObj('treatmentService', ['getMessageForPrescription']); - smsService = jasmine.createSpyObj('smsService', ['sendSMS']); - + var config = { "dashboardName": "General", "sections": [treatmentConfigParams] @@ -46,9 +44,7 @@ describe("PatientDashboardTreatmentController", function () { $controller('PatientDashboardTreatmentController', { $scope: scope, - ngDialog: ngDialog, - treatmentService: treatmentService, - smsService: smsService + ngDialog: ngDialog }); }) ) diff --git a/ui/test/unit/clinical/displaycontrols/treatmentTable.spec.js b/ui/test/unit/clinical/displaycontrols/treatmentTable.spec.js index ecfaeb5c1c..c1ab724c75 100644 --- a/ui/test/unit/clinical/displaycontrols/treatmentTable.spec.js +++ b/ui/test/unit/clinical/displaycontrols/treatmentTable.spec.js @@ -5,6 +5,7 @@ describe('Treatment Table DisplayControl', function () { compile, mockBackend, rootScope, + treatmentService, params, simpleHtml = ''; @@ -23,12 +24,27 @@ describe('Treatment Table DisplayControl', function () { beforeEach(module('bahmni.clinical')); + beforeEach(module(function ($provide) { + treatmentService = jasmine.createSpyObj('treatmentService', ['sendPrescriptionSMS']); + $provide.value('treatmentService', treatmentService); + })); + beforeEach(inject(['$compile', '$httpBackend', '$rootScope', function ($compile, $httpBackend, $rootScope) { compile = $compile; mockBackend = $httpBackend; rootScope = $rootScope; }])); + var mockTreatmentService = function (data) { + treatmentService.sendPrescriptionSMS.and.callFake(function () { + return { + then: function (callback) { + return callback(data) + } + } + }); + }; + it("should return true if the section is other active drug orders", function () { var scope = rootScope.$new(); From 6f3619042c71b086f40f654a62828089efb62747 Mon Sep 17 00:00:00 2001 From: Kavitha S Date: Fri, 3 Feb 2023 20:38:19 +0530 Subject: [PATCH 5/8] BAH-2763 | refactor to read location with tag visit location for reg message --- ui/app/common/constants.js | 3 +-- ui/app/registration/initialization.js | 7 +++++++ ui/app/registration/services/patientService.js | 4 ++-- .../patientDashboardTreatmentController.spec.js | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/ui/app/common/constants.js b/ui/app/common/constants.js index b3f2b2564c..b66a81354c 100644 --- a/ui/app/common/constants.js +++ b/ui/app/common/constants.js @@ -278,8 +278,7 @@ Bahmni.Common = Bahmni.Common || {}; defaultImageUploadSize: 500000, // Default patient profile photo size maxImageUploadSize: 9000000, // to ensure, extreme max size and prevent choking up server capacity (max size is 9MB) adhocTeleconsultationLinkServiceUrl: RESTWS_V1 + "/adhocTeleconsultation/generateAdhocTeleconsultationLink", - otpServiceUrl: "/otp-service", - sendSMSForPrescription: RESTWS_V1 + "/send/prescriptionSMS" + otpServiceUrl: "/otp-service" }; })(); diff --git a/ui/app/registration/initialization.js b/ui/app/registration/initialization.js index 4dde951279..8c1e5a37c8 100644 --- a/ui/app/registration/initialization.js +++ b/ui/app/registration/initialization.js @@ -61,6 +61,12 @@ angular.module('bahmni.registration').factory('initialization', }); }; + var visitLocation = function () { + return locationService.getAllByTag("Visit Location").then(function (response) { + $rootScope.visitLocation = response.data.results[0]; + }); + }; + var mergeFormConditions = function () { var formConditions = Bahmni.ConceptSet.FormConditions; if (formConditions) { @@ -80,6 +86,7 @@ angular.module('bahmni.registration').factory('initialization', .then(initAppConfigs) .then(mapRelationsTypeWithSearch) .then(loggedInLocation) + .then(visitLocation) .then(loadValidators(appService.configBaseUrl(), "registration")) .then(mergeFormConditions) ); diff --git a/ui/app/registration/services/patientService.js b/ui/app/registration/services/patientService.js index 5ab8082b85..8714994784 100644 --- a/ui/app/registration/services/patientService.js +++ b/ui/app/registration/services/patientService.js @@ -91,9 +91,9 @@ angular.module('bahmni.registration') }; var getRegistrationMessage = function (patientId, name, age, gender) { - var clinicName = $rootScope.loggedInLocation.name; + var locationName = $rootScope.visitLocation.name; var message = $translate.instant(appService.getAppDescriptor().getConfigValue("registrationMessage") || Bahmni.Registration.Constants.registrationMessage); - message = message.replace("#locationName", clinicName); + message = message.replace("#locationName", locationName); message = message.replace("#patientId", patientId); message = message.replace("#name", name); message = message.replace("#age", age); diff --git a/ui/test/unit/clinical/controllers/patientDashboardTreatmentController.spec.js b/ui/test/unit/clinical/controllers/patientDashboardTreatmentController.spec.js index a9d2487637..62afe977c1 100644 --- a/ui/test/unit/clinical/controllers/patientDashboardTreatmentController.spec.js +++ b/ui/test/unit/clinical/controllers/patientDashboardTreatmentController.spec.js @@ -34,7 +34,7 @@ describe("PatientDashboardTreatmentController", function () { }; ngDialog = jasmine.createSpyObj('ngDialog', ['open']); - + var config = { "dashboardName": "General", "sections": [treatmentConfigParams] From 0930d0ab7e38d907d22541864d84059b0e9f22b0 Mon Sep 17 00:00:00 2001 From: Kavitha S Date: Wed, 8 Feb 2023 13:19:24 +0530 Subject: [PATCH 6/8] BAH-2763 | refactor for sms language translation key --- ui/app/clinical/common/services/treatmentService.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/app/clinical/common/services/treatmentService.js b/ui/app/clinical/common/services/treatmentService.js index d6215791e5..53de128bc5 100644 --- a/ui/app/clinical/common/services/treatmentService.js +++ b/ui/app/clinical/common/services/treatmentService.js @@ -127,7 +127,7 @@ angular.module('bahmni.clinical') var sendPrescriptionSMS = function (visitUuid) { var deferred = $q.defer(); - var locale = $translate.instant(appService.getAppDescriptor().getConfigValue("smsLanguage") || Bahmni.Clinical.Constants.smsLanguage); + var locale = $translate.instant("SMS_LANGUAGE"); $http.post(Bahmni.Common.Constants.bahmniDrugOrderUrl + "/sendPrescriptionSMS", {"visitUuid": visitUuid, "locale": locale}, { withCredentials: true, headers: {"Content-Type": "application/json"} From 0413676c9fddfb4138830cae158a912461c8ed27 Mon Sep 17 00:00:00 2001 From: Kavitha S Date: Sat, 11 Feb 2023 22:02:07 +0530 Subject: [PATCH 7/8] BAH-2763 | refactor to pass attibutes to directive --- .../controllers/patientDashboardTreatmentController.js | 9 +++++---- .../treatmentData/directives/treatmentTable.js | 2 -- .../treatmentData/views/treatmentTable.html | 4 ++-- .../patientDashboardTreatmentController.spec.js | 4 ++-- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/ui/app/clinical/dashboard/controllers/patientDashboardTreatmentController.js b/ui/app/clinical/dashboard/controllers/patientDashboardTreatmentController.js index fd36e40d9d..5ff4842b55 100644 --- a/ui/app/clinical/dashboard/controllers/patientDashboardTreatmentController.js +++ b/ui/app/clinical/dashboard/controllers/patientDashboardTreatmentController.js @@ -1,18 +1,19 @@ 'use strict'; angular.module('bahmni.clinical') - .controller('PatientDashboardTreatmentController', ['$scope', 'ngDialog', 'visitActionsService', - function ($scope, ngDialog, visitActionsService) { + .controller('PatientDashboardTreatmentController', ['$scope', '$rootScope', 'ngDialog', 'visitActionsService', + function ($scope, $rootScope, ngDialog, visitActionsService) { var treatmentConfigParams = $scope.dashboard.getSectionByType("treatment") || {}; $scope.isEmailPresent = $scope.patient.email ? true : false; $scope.isPhoneNumberPresent = $scope.patient.phoneNumber ? true : false; var patientParams = {"patientUuid": $scope.patient.uuid, "isEmailPresent": $scope.isEmailPresent, "isPhoneNumberPresent": $scope.isPhoneNumberPresent}; + var sharePrescriptionToggles = {"prescriptionEmailToggle": $rootScope.prescriptionEmailToggle, "prescriptionSMSToggle": $rootScope.prescriptionSMSToggle}; $scope.dashboardConfig = {}; $scope.expandedViewConfig = {}; - _.extend($scope.dashboardConfig, treatmentConfigParams.dashboardConfig || {}, patientParams); - _.extend($scope.expandedViewConfig, treatmentConfigParams.expandedViewConfig || {}, patientParams); + _.extend($scope.dashboardConfig, treatmentConfigParams.dashboardConfig || {}, patientParams, sharePrescriptionToggles); + _.extend($scope.expandedViewConfig, treatmentConfigParams.expandedViewConfig || {}, patientParams, sharePrescriptionToggles); $scope.openSummaryDialog = function () { ngDialog.open({ diff --git a/ui/app/clinical/displaycontrols/treatmentData/directives/treatmentTable.js b/ui/app/clinical/displaycontrols/treatmentData/directives/treatmentTable.js index 6e30dc2d3f..ed47ff3041 100644 --- a/ui/app/clinical/displaycontrols/treatmentData/directives/treatmentTable.js +++ b/ui/app/clinical/displaycontrols/treatmentData/directives/treatmentTable.js @@ -3,8 +3,6 @@ angular.module('bahmni.clinical') .directive('treatmentTable', function () { var controller = function ($scope, $rootScope, treatmentService, messagingService) { - $scope.prescriptionEmailToggle = $rootScope.prescriptionEmailToggle; - $scope.prescriptionSMSToggle = $rootScope.prescriptionSMSToggle; $scope.isOtherActiveSection = function (dateString) { return dateString === Bahmni.Clinical.Constants.otherActiveDrugOrders; }; diff --git a/ui/app/clinical/displaycontrols/treatmentData/views/treatmentTable.html b/ui/app/clinical/displaycontrols/treatmentData/views/treatmentTable.html index 8549db9ec3..dae5e876b8 100644 --- a/ui/app/clinical/displaycontrols/treatmentData/views/treatmentTable.html +++ b/ui/app/clinical/displaycontrols/treatmentData/views/treatmentTable.html @@ -11,8 +11,8 @@

{{::params | titleTran diff --git a/ui/test/unit/clinical/controllers/patientDashboardTreatmentController.spec.js b/ui/test/unit/clinical/controllers/patientDashboardTreatmentController.spec.js index 62afe977c1..19f23521e2 100644 --- a/ui/test/unit/clinical/controllers/patientDashboardTreatmentController.spec.js +++ b/ui/test/unit/clinical/controllers/patientDashboardTreatmentController.spec.js @@ -59,13 +59,13 @@ describe("PatientDashboardTreatmentController", function () { describe("Should fetch configuration", function () { it("should fetch dashboard params", function () { var expected = {}; - _.extend(expected, treatmentConfigParams.dashboardConfig || {}, {patientUuid: "patient uuid", isEmailPresent: false, isPhoneNumberPresent: false}); + _.extend(expected, treatmentConfigParams.dashboardConfig || {}, {patientUuid: "patient uuid", isEmailPresent: false, isPhoneNumberPresent: false}, {prescriptionEmailToggle: undefined, prescriptionSMSToggle: undefined}); expect(expected).toEqual(scope.dashboardConfig); }); it("should fetch summary page params", function () { var expected = {}; - _.extend(expected, treatmentConfigParams.expandedViewConfig || {}, {patientUuid: "patient uuid", isEmailPresent: false, isPhoneNumberPresent: false}); + _.extend(expected, treatmentConfigParams.expandedViewConfig || {}, {patientUuid: "patient uuid", isEmailPresent: false, isPhoneNumberPresent: false}, {prescriptionEmailToggle: undefined, prescriptionSMSToggle: undefined}); expect(expected).toEqual(scope.expandedViewConfig); }); }); From c58182ae6df685ac9644804c2ad40691577a7733 Mon Sep 17 00:00:00 2001 From: Kavitha S Date: Mon, 13 Feb 2023 15:47:00 +0530 Subject: [PATCH 8/8] removed registration sms related changes --- ui/app/clinical/constants.js | 3 +-- ui/app/registration/initialization.js | 7 ------- ui/app/registration/services/patientService.js | 4 ++-- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/ui/app/clinical/constants.js b/ui/app/clinical/constants.js index be54c367c9..df02b76d72 100644 --- a/ui/app/clinical/constants.js +++ b/ui/app/clinical/constants.js @@ -70,8 +70,7 @@ Bahmni.Clinical.Constants = (function () { globalPropertyToFetchActivePatients: 'emrapi.sqlSearch.activePatients', adtPrivilege: "app:adt", adtForwardUrl: "../adt/#/patient/{{patientUuid}}/visit/{{visitUuid}}/", - certificateHeader: "Certificate Header", - smsLanguage: "SMS_LANGUAGE" + certificateHeader: "Certificate Header" }; })(); diff --git a/ui/app/registration/initialization.js b/ui/app/registration/initialization.js index 8c1e5a37c8..4dde951279 100644 --- a/ui/app/registration/initialization.js +++ b/ui/app/registration/initialization.js @@ -61,12 +61,6 @@ angular.module('bahmni.registration').factory('initialization', }); }; - var visitLocation = function () { - return locationService.getAllByTag("Visit Location").then(function (response) { - $rootScope.visitLocation = response.data.results[0]; - }); - }; - var mergeFormConditions = function () { var formConditions = Bahmni.ConceptSet.FormConditions; if (formConditions) { @@ -86,7 +80,6 @@ angular.module('bahmni.registration').factory('initialization', .then(initAppConfigs) .then(mapRelationsTypeWithSearch) .then(loggedInLocation) - .then(visitLocation) .then(loadValidators(appService.configBaseUrl(), "registration")) .then(mergeFormConditions) ); diff --git a/ui/app/registration/services/patientService.js b/ui/app/registration/services/patientService.js index 8714994784..e642432f20 100644 --- a/ui/app/registration/services/patientService.js +++ b/ui/app/registration/services/patientService.js @@ -91,9 +91,9 @@ angular.module('bahmni.registration') }; var getRegistrationMessage = function (patientId, name, age, gender) { - var locationName = $rootScope.visitLocation.name; + var clinicName = $rootScope.loggedInLocation.name; var message = $translate.instant(appService.getAppDescriptor().getConfigValue("registrationMessage") || Bahmni.Registration.Constants.registrationMessage); - message = message.replace("#locationName", locationName); + message = message.replace("#clinicName", clinicName); message = message.replace("#patientId", patientId); message = message.replace("#name", name); message = message.replace("#age", age);