Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RA-1604: Confirmation before deleting a condition #200

Merged
merged 1 commit into from Jul 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 20 additions & 6 deletions omod/src/main/webapp/pages/conditionlist/manageConditions.gsp
Expand Up @@ -77,19 +77,17 @@ ${ui.includeFragment("coreapps", "patientHeader", [patient: patient])}
</tr>
<tbody ng-repeat="conditionHistory in conditionHistoryList">
<tr class="clickable-tr" ng-init="condition = conditionHistory.conditions[0]"
ng-show="condition.status===tab">
<td ng-style="strikeThrough(condition.voided)">{{condition.concept.name}}</td>
<td ng-style="strikeThrough(condition.voided)">{{formatDate(condition.onSetDate)}}</td>
ng-show="condition.status===tab && condition.voided === false">
<td>{{condition.concept.name}}</td>
<td>{{formatDate(condition.onSetDate)}}</td>
<td ng-if="condition.status==='INACTIVE' && condition.voided===false" ng-style="strikeThrough(condition.voided)">{{formatDate(condition.endDate)}}</td>
<td ng-if="'${hasModifyConditionsPrivilege}'">
<i class="icon-plus-sign edit-action" title="${ui.message("coreapps.conditionui.active")}"
ng-click="activateCondition(condition)" ng-if="condition.status==='INACTIVE' && condition.voided===false"></i>
<i class="icon-minus-sign edit-action" title="${ui.message("coreapps.conditionui.inactive")}"
ng-click="deactivateCondition(condition)" ng-if="condition.status==='ACTIVE' && condition.voided===false"></i>
<i class="icon-remove delete-action" title="${ui.message("coreapps.coreapps.delete")}"
ng-click="removeCondition(condition)" ng-if="condition.voided===false"></i>
<i class="icon-undo delete-action" title="${ui.message("coreapps.conditionui.undo")}"
ng-click="undoCondition(condition)" ng-if="condition.voided===true"></i>
ng-click="conditionConfirmation(condition)" ng-if="condition.voided===false"></i>
</td>
</tr>
</tbody>
Expand All @@ -99,6 +97,22 @@ ${ui.includeFragment("coreapps", "patientHeader", [patient: patient])}
</span>
</div>


<div id="remove-condition-dialog" class="dialog" style="display: none; position: absolute; left: 35%; top:30%;">
<div class="dialog-header">
<h3>${ ui.message("coreapps.conditionui.removeCondition") }</h3>
</div>
<div class="dialog-content">
<ul>
<li class="info">
<span id="removeConditionMessage">${ ui.message("coreapps.conditionui.removeCondition.message","")}</span>
</li>
</ul>
<button class="confirm right" type="submit" ng-click="removeCondition()">${ ui.message("general.yes") }</button>
<button class="cancel" ng-click="cancelDeletion()">${ ui.message("general.no") }</button>
</div>
</div>

<div class="actions">
<button class="cancel"
onclick="location.href = '${ ui.encodeHtml(returnUrl) }'">${ui.message("coreapps.cancel")}</button>
Expand Down
Expand Up @@ -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
Expand Down Expand Up @@ -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: <b>"+$scope.conditionToBeRemoved.concept.name+"</b> 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
}