Skip to content

Instantly share code, notes, and snippets.

@porcelli
Created July 7, 2015 11:35
Show Gist options
  • Save porcelli/eaf85f823e7bbfa2177c to your computer and use it in GitHub Desktop.
Save porcelli/eaf85f823e7bbfa2177c to your computer and use it in GitHub Desktop.
function ListCases($scope, $http) {
$scope.field = '';
$scope.detail = '';
$scope.listCases = function () {
$http.get('http://localhost:8080/case/custom/cases').success(function (data) {
$scope.detail = "";
$scope.cases = data.cases;
});
};
$scope.goto = function () {
$goToPlace("Process Definitions");
};
$scope.view = function (a) {
$scope.detail = "";
$http.get('http://localhost:8080/case/custom/case/' + a).success(function (data) {
$scope.detail = "show";
$scope.active = data;
});
};
$scope.forward = function () {
$http.post('http://localhost:8080/case/custom/case/' + $scope.active.id).success(function () {
$scope.listCases();
});
}
$scope.createTask = function () {
$http.put('http://localhost:8080/case/custom/case/' + $scope.active.id + "?taskIds=" + $scope.selection.join(",")).success(function () {
$scope.view($scope.active.id);
});
};
// tasks
$scope.taskOptions = ['Glucose Test', 'Enzyme and Protein Test', 'White blood cell count'];
// selected fruits
$scope.selection = [];
// toggle selection for a given task by name
$scope.toggleSelection = function toggleSelection(taskName) {
var idx = $scope.selection.indexOf(taskName);
// is currently selected
if (idx > -1) {
$scope.selection.splice(idx, 1);
}
// is newly selected
else {
$scope.selection.push(taskName);
}
};
$scope.listCases();
}
<div ng-controller="ListCases">
<div ng-hide="detail">
<h2>Cases</h2>
<table class="table table-condensed table-striped table-hover">
<thead>
<tr>
<th>Case Id</th>
<th>Patient Name</th>
<th>Existing Tasks</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="case in cases">
<td>{{case.id}}</td>
<td>{{case.patient.name}}</td>
<td>
<ul ng-repeat="task in case.taskList">
<div ng-hide="task.value">
<li><strong><font color="red">{{task.status}}</font></strong> <em>{{task.name}}</em></li>
</div>
<div ng-hide="!task.value">
<li><strong>{{task.status}}</strong> <em>{{task.name}}</em></li>
</div>
</ul>
</td>
<td>
<form id="myForm" class="form-inline" ng-submit="view(field)">
<input type="hidden" ng-model="field" name="field" ng-init="field = case.id">
<input class="btn btn-primary" type="submit" value="View">
</form>
</td>
</tr>
</tbody>
</table>
<form class="form-inline" ng-submit="goto()">
<input class="btn btn-primary" type="submit" value="Create New Case">
</form>
</div>
<div ng-hide="!detail">
<div class="well">
<h2>Case <em>{{active.id}}</em> of Patient <em>{{active.patient.name}}</em></h2>
</div>
<form class="form-horizontal">
<div class="control-group">
<label class="control-label">Patient Name</label>
<div class="controls">
<input type="text" value="{{active.patient.name}}" readonly>
</div>
</div>
<div class="control-group">
<label class="control-label">Patient Age</label>
<div class="controls">
<input type="text" value="{{active.patient.age}}" readonly>
</div>
</div>
<div class="control-group">
<label class="control-label">Patient Address</label>
<div class="controls">
<input type="text" value="{{active.patient.address}}" readonly>
</div>
</div>
</form>
<table class="table table-condensed table-striped table-hover">
<thead>
<tr>
<th>Status</th>
<th>Task Name</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="task in active.taskList">
<td ng-hide="task.value"><strong><font color="red">{{task.status}}</font></strong></td>
<td ng-hide="!task.value"><strong>{{task.status}}</strong></td>
<td>{{task.name}}</td>
<td>{{task.value}}</td>
</tr>
</tbody>
</table>
<button class="btn" ng-click="listCases()">Back</button>
<a href="#myModal" role="button" class="btn btn-warning" data-toggle="modal">Recommend New Tests</a>
<button class="btn btn-success" ng-click="forward()">Submit for Doc Review</button>
</div>
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Modal header</h3>
</div>
<div class="modal-body">
<label ng-repeat="taskName in taskOptions">
<input
type="checkbox"
name="selectedFruits[]"
value="{{taskName}}"
ng-checked="selection.indexOf(taskName) > -1"
ng-click="toggleSelection(taskName)"
> {{taskName}}
</label>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
<button class="btn btn-primary" data-dismiss="modal" ng-click="createTask()">Save changes</button>
</div>
</div>
</div>
"Case Management"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment