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 1526- Editing conditions #192
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...rg/openmrs/module/coreapps/page/controller/conditionlist/EditConditionPageController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.openmrs.module.coreapps.page.controller.conditionlist; | ||
|
||
/** | ||
* The contents of this file are subject to the OpenMRS Public License | ||
* Version 1.0 (the "License"); you may not use this file except in | ||
* compliance with the License. You may obtain a copy of the License at | ||
* http://license.openmrs.org | ||
* <p> | ||
* Software distributed under the License is distributed on an "AS IS" | ||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing rights and limitations | ||
* under the License. | ||
* <p> | ||
* Copyright (C) OpenMRS, LLC. All Rights Reserved. | ||
*/ | ||
|
||
import org.openmrs.ui.framework.page.PageModel; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
|
||
public class EditConditionPageController { | ||
|
||
public void controller(PageModel model, @RequestParam(value = "returnUrl", required = false) String returnUrl) { | ||
model.addAttribute("returnUrl", returnUrl); | ||
} | ||
} |
91 changes: 91 additions & 0 deletions
91
omod/src/main/webapp/pages/conditionlist/editCondition.gsp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<% | ||
ui.decorateWith("appui", "standardEmrPage") | ||
ui.includeJavascript("uicommons", "angular.min.js") | ||
ui.includeJavascript("uicommons", "angular-ui/ui-bootstrap-tpls-0.11.2.min.js") | ||
ui.includeJavascript("uicommons", "angular-resource.min.js") | ||
ui.includeJavascript("uicommons", "angular-common.js") | ||
ui.includeJavascript("uicommons", "ngDialog/ngDialog.js") | ||
ui.includeJavascript("uicommons", "ngDialog/ngDialog.js") | ||
ui.includeJavascript("uicommons", "services/conceptSearchService.js") | ||
ui.includeJavascript("uicommons", "directives/coded-or-free-text-answer.js") | ||
ui.includeFragment("coreapps", "patientHeader", [patient: patient]) | ||
ui.includeJavascript("coreapps", "conditionlist/lib/restangular.min.js") | ||
ui.includeJavascript("coreapps", "conditionlist/restful-services/restful-service.js"); | ||
ui.includeJavascript("coreapps", "conditionlist/models/model.module.js") | ||
ui.includeJavascript("coreapps", "conditionlist/models/concept.model.js") | ||
ui.includeJavascript("coreapps", "conditionlist/models/condition.model.js") | ||
ui.includeJavascript("coreapps", "conditionlist/emr.messages.js") | ||
ui.includeJavascript("coreapps", "conditionlist/common.functions.js") | ||
ui.includeJavascript("coreapps", "conditionlist/controllers/editcondition.controller.js") | ||
ui.includeCss("uicommons", "ngDialog/ngDialog.min.css") | ||
ui.includeCss("coreapps", "conditionlist/conditions.css") | ||
%> | ||
<script type="text/javascript"> | ||
var breadcrumbs = [ | ||
{icon: "icon-home", link: '/' + OPENMRS_CONTEXT_PATH + '/index.htm'}, | ||
{ | ||
label: "${ ui.escapeJs(ui.encodeHtmlContent(ui.format(patient.familyName))) }, ${ ui.escapeJs(ui.encodeHtmlContent(ui.format(patient.givenName))) }", | ||
link: '${ui.pageLink("coreapps", "clinicianfacing/patient", [patientId: patient.id])}' | ||
}, | ||
{ | ||
label: "${ ui.message("coreapps.conditionui.conditions") }", | ||
link: '${ui.pageLink("coreapps/conditionlist", "manageConditions", [patientId: patient.id, returnUrl: returnUrl])}' | ||
}, | ||
{label: "${ui.message('coreapps.conditionui.editCondition',"")}"} | ||
]; | ||
</script> | ||
|
||
<div id="condition" ng-app="conditionApp" ng-controller="ConditionController"> | ||
<h2 class="inline">${ui.message('coreapps.conditionui.editCondition',"")}</h2><br/> | ||
|
||
<div class="horizontal"> | ||
<ul id="concept-and-date"> | ||
<li class="group"> | ||
<label>${ui.message('coreapps.conditionui.condition')} </label> | ||
<coded-or-free-text-answer id="conceptId" class="concept" | ||
concept-classes="8d4918b0-c2cc-11de-8d13-0010c6dffd0f,8d492954-c2cc-11de-8d13-0010c6dffd0f,8d492b2a-c2cc-11de-8d13-0010c6dffd0f,8d491a9a-c2cc-11de-8d13-0010c6dffd0f" | ||
ng-model="concept"/> | ||
</li> | ||
<li class="group"> | ||
<br/> <br/> <label> ${ui.message('coreapps.conditionui.onsetdate')} </label> | ||
${ui.includeFragment("uicommons", "field/datetimepicker", [ | ||
formFieldName: "conditionStartDate", | ||
label : "", | ||
useTime : false, | ||
endDate : new Date(), | ||
])} | ||
</li> | ||
| ||
<li id="status" class="group"> | ||
<label>${ui.message('coreapps.stopDate.label')} </label> | ||
${ui.includeFragment("uicommons", "field/datetimepicker", [ | ||
formFieldName: "conditionEndDate", | ||
label : "", | ||
useTime : false, | ||
endDate : new Date(), | ||
])} | ||
</li> | ||
<br/> <br/> | ||
</ul> | ||
</div> | ||
|
||
<div id="status" class="horizontal"> | ||
<p> | ||
<input type="radio" id="status-1" class="condition-status" value="${ui.message('coreapps.conditionui.active.label')}" name="status" ng-model="condition.status" ng-change="showEndDate()"/> | ||
<label for="status-1">${ui.message('coreapps.conditionui.active.label')}</label> | ||
</p> | ||
<p> | ||
<input type="radio" id="status-2" class="condition-status" value="${ui.message('coreapps.conditionui.inactive.label')}" name="status" ng-model="condition.status" ng-change="showEndDate()"/> | ||
<label for="status-2">${ui.message('coreapps.conditionui.inactive.label')}</label> | ||
</p> | ||
</div> | ||
<br/> | ||
<div id="actions"> | ||
<input type="submit" id="addConditionBtn" class="confirm right" | ||
value="${ui.message("coreapps.save")}" ng-click="validateCondition()"/> | ||
<button class="cancel" | ||
onclick="location.href='${ui.pageLink("coreapps/conditionlist", "manageConditions", [patientId: patient.uuid, returnUrl: returnUrl])}'"> | ||
${ ui.message("coreapps.cancel") } | ||
</button> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
143 changes: 143 additions & 0 deletions
143
omod/src/main/webapp/resources/scripts/conditionlist/controllers/editcondition.controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
var app = angular.module("conditionApp", | ||
['uicommons.widget.coded-or-free-text-answer', 'app.restfulServices', 'app.models', 'app.commonFunctionsFactory']); | ||
|
||
app.controller("ConditionController", ConditionController); | ||
ConditionController.$inject = ['$scope', 'RestfulService', 'ConditionModel', 'ConceptModel', 'CommonFunctions']; | ||
|
||
function ConditionController($scope, RestfulService, ConditionModel, ConceptModel, CommonFunctions) { | ||
var self = this; | ||
|
||
$scope.patientUuid = null; | ||
$scope.condition = null; | ||
$scope.conditionUuid=null; | ||
const INACTIVE_STATUS = 'INACTIVE'; | ||
|
||
// this is required inorder to initialize the Restangular service | ||
RestfulService.setBaseUrl('/' + OPENMRS_CONTEXT_PATH + '/ws/rest/emrapi'); | ||
|
||
/** | ||
* Perform POST save | ||
* PS: Make sure the 'Non Coded Uuid' setting (under Settings->Condition List) is set inorder to work with noncoded concepts, | ||
* the LOCALE needs to be set (most concepts have 'en') | ||
* @type {Function} | ||
*/ | ||
self.saveCondition = self.saveCondition || function () { | ||
if($scope.condition.status == INACTIVE_STATUS && $scope.condition.onSetDate > $scope.condition.endDate){ | ||
emr.errorAlert("End Date can't be before Onset Date"); | ||
} | ||
else{ | ||
var conditions = []; | ||
conditions.push($scope.condition); | ||
RestfulService.post('condition', conditions, function (data) { | ||
emr.successAlert("Condition edited successfully") | ||
window.location = '/' + OPENMRS_CONTEXT_PATH + '/coreapps/conditionlist/manageConditions.page?patientId=' + $scope.patientUuid + '&'; | ||
}, function (error) { | ||
emr.errorAlert("Error Saving condition"); | ||
}); | ||
} | ||
} | ||
|
||
self.initCondition = self.initCondition || function () { | ||
$scope.patientUuid = CommonFunctions.extractUrlArgs(window.location.search)['patientId']; | ||
$scope.condition = new ConditionModel($scope.patientUuid) | ||
$scope.conditionUuid = CommonFunctions.extractUrlArgs(window.location.search)['conditionUuid']; | ||
self.getCondition($scope.conditionUuid); | ||
} | ||
|
||
self.getCondition = self.getCondition || function (conditionUuid) { | ||
if (conditionUuid == null || conditionUuid == undefined) { | ||
$scope.conditionUuid = CommonFunctions.extractUrlArgs(window.location.search)['conditionUUID']; | ||
} else { | ||
$scope.conditionUuid = conditionUuid; | ||
} | ||
$scope.conditionUuid = $scope.conditionUuid.substring(3,$scope.conditionUuid.length-3); | ||
if ($scope.conditionUuid !== null && $scope.conditionUuid !== undefined) { | ||
RestfulService.get('condition', {"conditionUuid": $scope.conditionUuid}, function (data) { | ||
$scope.condition = data[0]; | ||
self.displayCondition(); | ||
}, function (error) { | ||
}); | ||
} | ||
} | ||
|
||
self.displayCondition = self.displayCondition || function() | ||
{ | ||
$scope.concept = { | ||
display: $scope.condition.concept.name, | ||
concept: { | ||
display: $scope.condition.concept.name, | ||
}, | ||
conceptName: { | ||
display: $scope.condition.concept.name, | ||
} | ||
} | ||
|
||
var onsetDatePicker = angular.element(document.getElementsByName('conditionStartDate'))[0]; | ||
onsetDatePicker.value = CommonFunctions.formatDate($scope.condition.onSetDate); | ||
|
||
if($scope.condition.status == INACTIVE_STATUS){ | ||
var endDatePicker = angular.element(document.getElementsByName('conditionEndDate'))[0]; | ||
endDatePicker.value = CommonFunctions.formatDate($scope.condition.endDate); | ||
} | ||
|
||
var inputs = document.getElementsByTagName('input'); | ||
inputs[0].disabled = true; | ||
inputs[1].value = CommonFunctions.formatDate($scope.condition.onSetDate); | ||
self.showEndDate(); | ||
} | ||
|
||
|
||
self.showEndDate = self.showEndDate || function() { | ||
var inputs = document.getElementsByTagName('input'); | ||
var groups = document.getElementsByClassName("group"); | ||
if($scope.condition.status == INACTIVE_STATUS){ | ||
groups[2].style.visibility = "visible"; | ||
inputs[3].value = CommonFunctions.formatDate($scope.condition.endDate); | ||
} | ||
else{ | ||
groups[2].style.visibility = "hidden"; | ||
} | ||
} | ||
|
||
self.validateCondition = self.validateCondition || function () { | ||
var concept = null ; | ||
if($scope.concept.concept.uuid) | ||
{ | ||
concept = $scope.concept.concept; | ||
} | ||
else{ | ||
concept = $scope.condition.concept; | ||
} | ||
if (concept !== null) { | ||
$scope.condition.concept = new ConceptModel(concept.uuid, concept.display); | ||
} else { | ||
$scope.condition.conditionNonCoded = "NON_CODED:" + $scope.concept.word; | ||
} | ||
|
||
$scope.condition.onSetDate = self.getSelectedDate(); | ||
if($scope.condition.status == INACTIVE_STATUS) | ||
{ | ||
$scope.condition.endDate = self.getEndDate(); | ||
} | ||
self.saveCondition(); | ||
} | ||
|
||
self.getSelectedDate = self.getSelectedDate || function () { | ||
var datePicker = angular.element(document.getElementsByName('conditionStartDate'))[0]; | ||
return datePicker.value; | ||
} | ||
|
||
self.getEndDate = self.getEndDate || function() { | ||
var endDatePicker = angular.element(document.getElementsByName('conditionEndDate'))[0]; | ||
return endDatePicker.value; | ||
} | ||
|
||
self.initCondition(); | ||
|
||
$scope.validateCondition = self.validateCondition; | ||
$scope.showEndDate = self.showEndDate; | ||
$scope.getEndDate = self.getEndDate; | ||
$scope.formatDate = CommonFunctions.formatDate; | ||
$scope.getCondition = self.getCondition; | ||
$scope.displayCondition = self.displayCondition; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are we using the above line for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To redirect to edit conditions page when user clicks the pencil icon