diff --git a/omod/src/main/webapp/pages/conditionlist/manageConditions.gsp b/omod/src/main/webapp/pages/conditionlist/manageConditions.gsp index 063890240..dedeb420d 100644 --- a/omod/src/main/webapp/pages/conditionlist/manageConditions.gsp +++ b/omod/src/main/webapp/pages/conditionlist/manageConditions.gsp @@ -77,9 +77,9 @@ ${ui.includeFragment("coreapps", "patientHeader", [patient: patient])} - {{condition.concept.name}} - {{formatDate(condition.onSetDate)}} + ng-show="condition.status===tab && condition.voided === false"> + {{condition.concept.name}} + {{formatDate(condition.onSetDate)}} {{formatDate(condition.endDate)}} - + ng-click="conditionConfirmation(condition)" ng-if="condition.voided===false"> @@ -99,6 +97,22 @@ ${ui.includeFragment("coreapps", "patientHeader", [patient: patient])} + + +
diff --git a/omod/src/main/webapp/resources/scripts/conditionlist/controllers/manageconditions.controller.js b/omod/src/main/webapp/resources/scripts/conditionlist/controllers/manageconditions.controller.js index 957a99a89..288bda8c7 100644 --- a/omod/src/main/webapp/resources/scripts/conditionlist/controllers/manageconditions.controller.js +++ b/omod/src/main/webapp/resources/scripts/conditionlist/controllers/manageconditions.controller.js @@ -7,6 +7,7 @@ ManageConditionsController.$inject = ['$scope', 'RestfulService', 'CommonFunctio function ManageConditionsController($scope, RestfulService, CommonFunctions) { var self = this; $scope.conditions = []; + $scope.conditionToBeRemoved =null; $scope.tabs = ["ACTIVE", "INACTIVE"]; // this is required inorder to initialize the Restangular service @@ -38,36 +39,50 @@ function ManageConditionsController($scope, RestfulService, CommonFunctions) { self.saveCondition(condition); } - self.removeCondition = self.removeCondition || function (condition) { - condition.voided = true; - condition.endDate = new Date(); - self.saveCondition(condition); - } - - self.undoCondition = self.undoCondition || function (condition) { - condition.voided = false; - condition.endDate = null; - self.saveCondition(condition); + self.removeCondition = self.removeCondition || function () { + $scope.conditionToBeRemoved.voided = true; + $scope.conditionToBeRemoved.endDate = new Date(); + self.saveCondition($scope.conditionToBeRemoved); + var dialog = document.getElementById("remove-condition-dialog"); + dialog.style.display = "none"; } + + self.conditionConfirmation = self.conditionConfirmation || function(condition) { + var dialog = document.getElementById("remove-condition-dialog"); + dialog.style.display = "block"; + $scope.conditionToBeRemoved = condition; + var setText = document.getElementById("removeConditionMessage"); + setText.innerHTML = "Are you sure you want to remove condition: "+$scope.conditionToBeRemoved.concept.name+" for this patient"; + } + + self.cancelDeletion = self.cancelDeletion || function(){ + var dialog = document.getElementById("remove-condition-dialog"); + dialog.style.display = "none"; + } self.saveCondition = self.saveCondition || function (condition) { var conditions = []; conditions.push(condition); RestfulService.post('condition', conditions, function (data) { + if(condition.voided == false){ //emr.successAlert("conditionlist.updateCondition.success"); - emr.successAlert("Condition Saved Successfully"); + emr.successAlert("Condition Saved Successfully"); + } + else{ + emr.successAlert("Condition Deleted Successfully"); + } }, function (error) { //emr.errorAlert("conditionlist.updateCondition.error"); emr.errorAlert("Error Saving condition"); }); - } + } // bind functions to scope $scope.removeCondition = self.removeCondition; + $scope.cancelDeletion = self.cancelDeletion; $scope.activateCondition = self.activateCondition; $scope.deactivateCondition = self.deactivateCondition; - $scope.undoCondition = self.undoCondition; $scope.formatDate = CommonFunctions.formatDate; - $scope.strikeThrough = CommonFunctions.strikeThrough; $scope.getConditions = self.getConditions; + $scope.conditionConfirmation = self.conditionConfirmation } \ No newline at end of file