diff --git a/micro-frontends/src/ipd/index.js b/micro-frontends/src/ipd/index.js
index 1df81f880a..963c1e8501 100644
--- a/micro-frontends/src/ipd/index.js
+++ b/micro-frontends/src/ipd/index.js
@@ -14,131 +14,32 @@ angular.module("bahmni.mfe.ipd", [
"bahmni.common.domain",
]);
-
/** MFE component 1: IpdDashboard
*================================================= */
-/** Step 1: create a react2angular wrapper for the component */
angular
.module("bahmni.mfe.ipd")
- .component("mfeIpdDashboardRemote", react2angular(IpdDashboard));
-
-/** Step 2: create a controller to pass hostData and hostApi */
-function ipdDashboardController($rootScope, $scope, confirmBox) {
-
- // Use hostData to pass data from bahmni to the micro-frontend component
- $scope.hostData = {
- patient: {
- uuid: "--- DUMMY UUID FOR TESTING FROM HOST ---",
- },
- };
-
- // Use hostApi to provide callbacks to the micro-frontend component
- $scope.hostApi = {
- onConfirm() {
- const dialogScope = {
- message:
- "This is a dialog triggered on the host in response to an event from IPD ",
- okay(close) {
- close();
- },
- };
-
- confirmBox({
- scope: dialogScope,
- actions: [{ name: "okay", display: "Okay" }],
- className: "ngdialog-theme-default",
- });
- },
- };
-}
-ipdDashboardController.$inject = ["$rootScope", "$scope", "confirmBox"];
-
-/** Step 3: bind the controller to the component by creating a new wrapper component */
-angular.module("bahmni.mfe.ipd").component("mfeIpdDashboard", {
- controller: ipdDashboardController,
- template:
- '',
-});
-/** ================= End of component 1 ========================== */
+ .component("mfeIpdDashboard", react2angular(IpdDashboard), {
+ template:
+ ''
+ });
/** MFE component 2: DrugChartModal
*================================================= */
angular
.module("bahmni.mfe.ipd")
- .component("mfeIpdDrugChartModalRemote", react2angular(DrugChartModal));
-
-function ipdDrugChartModalController($rootScope, $scope) {
- var vm = this;
- $scope.hostData = {
- drugOrder: vm.drugOrder,
- patientId: vm.patientId,
- scheduleFrequencies: vm.scheduleFrequencies,
- startTimeFrequencies: vm.startTimeFrequencies,
- enable24HourTimers: vm.enable24HourTimers,
- };
- $scope.hostApi = {
- onModalClose: function () {
- vm.closeDrugChart();
- },
- onModalSave: function () {
- vm.showSuccessNotification();
- },
- onModalCancel: function () {
- vm.showWarningNotification();
- },
- };
-}
+ .component("mfeIpdDrugChartModal", react2angular(DrugChartModal), {
+ template:
+ '',
+ });
-ipdDrugChartModalController.$inject = ["$rootScope", "$scope"];
-
-angular.module("bahmni.mfe.ipd").component("mfeIpdDrugChartModal", {
- controller: ipdDrugChartModalController,
- bindings: {
- drugOrder: "=",
- patientId: "=",
- scheduleFrequencies: "=",
- startTimeFrequencies: "=",
- enable24HourTimers: "=",
- closeDrugChart: "&",
- showWarningNotification: "&",
- showSuccessNotification: "&",
- },
- template:
- '',
-});
-/** ================= End of component 2 ========================== */
-
-/** MFE component 3: DrugChartModalWarnings
+/** MFE component 3: DrugChartModalNotification
* ================================================= */
angular
.module("bahmni.mfe.ipd")
- .component("mfeIpdDrugChartModalNotificationRemote", react2angular(DrugChartModalNotification));
-
-function ipdDrugChartModalNotificationController($rootScope, $scope) {
- var vm = this;
- $scope.hostData = {
- notificationKind: vm.notificationKind,
- };
- $scope.hostApi = {
- onClose() {
- vm.closeWarnings();
- }
- }
-}
-
-ipdDrugChartModalNotificationController.$inject = ["$rootScope", "$scope"];
-
-angular.module("bahmni.mfe.ipd").component("mfeIpdDrugChartModalNotification", {
- controller: ipdDrugChartModalNotificationController,
- bindings: {
- notificationKind: "=",
- closeWarnings: "&",
- },
- template:
- '',
-});
-
-/** ================= End of component 3 ========================== */
+ .component("mfeIpdDrugChartModalNotification", react2angular(DrugChartModalNotification), {
+ template:
+ '',
+ });
diff --git a/ui/app/clinical/dashboard/controllers/patientDashboardController.js b/ui/app/clinical/dashboard/controllers/patientDashboardController.js
index 69465cb835..3971e6b712 100644
--- a/ui/app/clinical/dashboard/controllers/patientDashboardController.js
+++ b/ui/app/clinical/dashboard/controllers/patientDashboardController.js
@@ -2,9 +2,9 @@
angular.module('bahmni.clinical')
.controller('PatientDashboardController', ['$scope', 'clinicalAppConfigService', 'clinicalDashboardConfig', 'printer',
- '$state', 'spinner', 'visitSummary', 'appService', '$stateParams', 'diseaseTemplateService', 'patientContext', '$location', '$filter',
+ '$state', 'spinner', 'visitSummary', 'appService', '$stateParams', 'diseaseTemplateService', 'patientContext', '$location', '$filter', 'confirmBox',
function ($scope, clinicalAppConfigService, clinicalDashboardConfig, printer,
- $state, spinner, visitSummary, appService, $stateParams, diseaseTemplateService, patientContext, $location, $filter) {
+ $state, spinner, visitSummary, appService, $stateParams, diseaseTemplateService, patientContext, $location, $filter, confirmBox) {
$scope.patient = patientContext.patient;
$scope.activeVisit = $scope.visitHistory.activeVisit;
$scope.activeVisitData = {};
@@ -26,6 +26,31 @@ angular.module('bahmni.clinical')
}
};
+ $scope.ipdDashboard = {
+ hostData: {
+ patient: {
+ uuid: "--- DUMMY UUID FOR TESTING FROM HOST ---"
+ }
+ },
+ hostApi: {
+ onConfirm: function () {
+ const dialogScope = {
+ message:
+ "This is a dialog triggered on the host in response to an event from IPD ",
+ okay: function (close) {
+ close();
+ }
+ };
+
+ confirmBox({
+ scope: dialogScope,
+ actions: [{ name: "okay", display: "Okay" }],
+ className: "ngdialog-theme-default"
+ });
+ }
+ }
+ };
+
$scope.stateChange = function () {
return $state.current.name === 'patient.dashboard.show';
};
diff --git a/ui/app/clinical/dashboard/views/dashboard.html b/ui/app/clinical/dashboard/views/dashboard.html
index 929c0fbb72..8afcbb75a7 100644
--- a/ui/app/clinical/dashboard/views/dashboard.html
+++ b/ui/app/clinical/dashboard/views/dashboard.html
@@ -3,6 +3,6 @@
disease-templates="diseaseTemplates" section-groups="sectionGroups" visit-history="visitHistory"
active-visit-uuid="visitHistory.activeVisit.uuid" visit-summary="visitSummary" enrollment="enrollment">
-
+
\ No newline at end of file
diff --git a/ui/app/clinical/displaycontrols/treatmentData/directives/treatmentTableRow.js b/ui/app/clinical/displaycontrols/treatmentData/directives/treatmentTableRow.js
index 68dc5dec53..18a4aa10aa 100644
--- a/ui/app/clinical/displaycontrols/treatmentData/directives/treatmentTableRow.js
+++ b/ui/app/clinical/displaycontrols/treatmentData/directives/treatmentTableRow.js
@@ -6,10 +6,12 @@ angular.module('bahmni.clinical')
$scope.selectedDrugOrder = {};
$scope.openModal = false;
$scope.enableIPDFeature = appService.getAppDescriptor().getConfigValue("enableIPDFeature");
- $scope.enable24HourTimers = appService.getAppDescriptor().getConfigValue("enable24HourTimers");
+ const enable24HourTimers = appService.getAppDescriptor().getConfigValue("enable24HourTimers");
+ var drugChartModalScheduleFrequencies = [];
+ var drugChartModalStartTimeFrequencies = [];
if ($scope.enableIPDFeature === true) {
- $scope.drugChartModalScheduleFrequencies = appService.getAppDescriptor().getConfigValue("drugChartScheduleFrequencies");
- $scope.drugChartModalStartTimeFrequencies = appService.getAppDescriptor().getConfigValue("drugChartStartTimeFrequencies");
+ drugChartModalScheduleFrequencies = appService.getAppDescriptor().getConfigValue("drugChartScheduleFrequencies");
+ drugChartModalStartTimeFrequencies = appService.getAppDescriptor().getConfigValue("drugChartStartTimeFrequencies");
}
$scope.showDetails = false;
if ($scope.params.showProvider === undefined) {
@@ -18,29 +20,50 @@ angular.module('bahmni.clinical')
$scope.toggle = function () {
$scope.showDetails = !$scope.showDetails;
};
- $scope.openDrugChartModal = function (drugOrder) {
- $scope.selectedDrugOrder = drugOrder;
- $scope.openModal = true;
- };
- $scope.closeDrugChartModal = function () {
- $scope.openModal = false;
- $scope.$apply();
- };
- $scope.showWarningNotification = function () {
- $scope.showModalWarningMessage = true;
- $scope.openModal = false;
- $scope.kind = "warning";
- $scope.$apply();
+
+ $scope.drugChartModal = {
+ hostData: {
+ drugOrder: {},
+ patientId: $scope.params.patientUuid,
+ scheduleFrequencies: drugChartModalScheduleFrequencies,
+ startTimeFrequencies: drugChartModalStartTimeFrequencies,
+ enable24HourTimers: enable24HourTimers
+ },
+ hostApi: {
+ onModalClose: function () {
+ $scope.openModal = false;
+ $scope.$apply();
+ },
+ onModalSave: function () {
+ $scope.openModal = false;
+ $scope.drugChartModalNotification.hostData.notificationKind = "success";
+ $scope.showModalWarningMessage = true;
+ $scope.$apply();
+ },
+ onModalCancel: function () {
+ $scope.openModal = false;
+ $scope.drugChartModalNotification.hostData.notificationKind = "warning";
+ $scope.showModalWarningMessage = true;
+ $scope.$apply();
+ }
+ }
};
- $scope.showSuccessNotification = function () {
- $scope.showModalWarningMessage = true;
- $scope.openModal = false;
- $scope.kind = "success";
- $scope.$apply();
+
+ $scope.drugChartModalNotification = {
+ hostData: {
+ notificationKind: ""
+ },
+ hostApi: {
+ onClose: function () {
+ $scope.showModalWarningMessage = false;
+ $scope.$apply();
+ }
+ }
};
- $scope.closeWarnings = function () {
- $scope.showModalWarningMessage = false;
- $scope.$apply();
+
+ $scope.openDrugChartModal = function (drugOrder) {
+ $scope.drugChartModal.hostData.drugOrder = drugOrder;
+ $scope.openModal = true;
};
};
diff --git a/ui/app/clinical/displaycontrols/treatmentData/views/treatmentTableRow.html b/ui/app/clinical/displaycontrols/treatmentData/views/treatmentTableRow.html
index 32b4e511e8..20841ba6d8 100644
--- a/ui/app/clinical/displaycontrols/treatmentData/views/treatmentTableRow.html
+++ b/ui/app/clinical/displaycontrols/treatmentData/views/treatmentTableRow.html
@@ -22,20 +22,17 @@
-
+
+
-
+
diff --git a/ui/test/unit/clinical/controllers/patientDashboardController.spec.js b/ui/test/unit/clinical/controllers/patientDashboardController.spec.js
index 9975a3dc94..70d85dbe3f 100644
--- a/ui/test/unit/clinical/controllers/patientDashboardController.spec.js
+++ b/ui/test/unit/clinical/controllers/patientDashboardController.spec.js
@@ -4,7 +4,7 @@ describe("patient dashboard controller", function () {
beforeEach(module('bahmni.clinical'));
var scope, spinner, _clinicalDashboardConfig, _clinicalAppConfigService, _state, _appService, _diseaseTemplateService,
- _stateParams, _controller, _appConfig, location, filter;
+ _stateParams, _controller, _appConfig, location, filter, confirmBox;
var diseaseTemplates;
location = {
path: function () {
@@ -13,7 +13,7 @@ describe("patient dashboard controller", function () {
return url;
},
search: function () {
- return {currentTab: "DASHBOARD_TAB_PATIENT_SUMMARY_KEY", replace: function () {}};
+ return { currentTab: "DASHBOARD_TAB_PATIENT_SUMMARY_KEY", replace: function () {} };
}
};
@@ -43,6 +43,7 @@ describe("patient dashboard controller", function () {
_appService = jasmine.createSpyObj('appService', ['getAppDescriptor']);
_appConfig = jasmine.createSpyObj('appConfig', ['getConfigValue']);
+ confirmBox = jasmine.createSpyObj('confirmBox', ['show']);
_appService.getAppDescriptor.and.returnValue(_appConfig);
_diseaseTemplateService = jasmine.createSpyObj('diseaseTemplateService', ['getLatestDiseaseTemplates']);
@@ -116,7 +117,8 @@ describe("patient dashboard controller", function () {
$stateParams: _stateParams,
diseaseTemplateService: _diseaseTemplateService,
patientContext: {patient: {}},
- $filter: filter
+ $filter: filter,
+ confirmBox: confirmBox
});
});
@@ -153,7 +155,8 @@ describe("patient dashboard controller", function () {
appService: _appService,
$stateParams: _stateParams,
diseaseTemplateService: _diseaseTemplateService,
- patientContext: {patient: {}}
+ patientContext: {patient: {}},
+ confirmBox: confirmBox
});
});
@@ -197,7 +200,8 @@ describe("patient dashboard controller", function () {
$stateParams: _stateParams,
diseaseTemplateService: _diseaseTemplateService,
patientContext: {patient: {}},
- $location: location
+ $location: location,
+ confirmBox: confirmBox
});
expect(_clinicalDashboardConfig.currentTab.translationKey).toBe("DASHBOARD_TAB_PATIENT_SUMMARY_KEY");