Skip to content

Commit

Permalink
Add liver transplants form
Browse files Browse the repository at this point in the history
  • Loading branch information
Rupert Bedford committed May 31, 2016
1 parent ec3037d commit 01a27fc
Show file tree
Hide file tree
Showing 6 changed files with 273 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/app/patients/patients.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
INS_CLINICAL_PICTURES: patientPage('Clinical Pictures', 'patient.insClinicalPictures'),
INS_RELAPSES: patientPage('Relapses', 'patient.insRelapses'),
LIVER_IMAGING: patientPage('Liver Imaging', 'patient.liverImaging'),
LIVER_TRANSPLANTS: patientPage('Liver Transplants', 'patient.liverTransplants'),
MEDICATIONS: patientPage('Medications', 'patient.medications'),
META: patientPage('Metadata', 'patient.metadata'),
MPGN_CLINICAL_PICTURES: patientPage('Clinical Pictures', 'patient.mpgnClinicalPictures'),
Expand Down
9 changes: 9 additions & 0 deletions src/app/patients/pkd/liver-transplant-model.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(function() {
'use strict';

var app = angular.module('radar.patients.pkd');

app.config(['storeProvider', function(storeProvider) {
storeProvider.registerMixin('liver-transplants', 'SourceModelMixin');
}]);
})();
71 changes: 71 additions & 0 deletions src/app/patients/pkd/liver-transplants-component.directive.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
(function() {
'use strict';

var app = angular.module('radar.patients.pkd');

app.factory('LiverTransplantPermission', ['PatientSourceObjectPermission', function(PatientSourceObjectPermission) {
return PatientSourceObjectPermission;
}]);

function controllerFactory(
ModelListDetailController,
LiverTransplantPermission,
firstPromise,
$injector,
store
) {
function LiverTransplantsController($scope) {
var self = this;

$injector.invoke(ModelListDetailController, self, {
$scope: $scope,
params: {
permission: new LiverTransplantPermission($scope.patient)
}
});

self.load(firstPromise([
store.findMany('liver-transplants', {patient: $scope.patient.id}),
store.findMany('liver-transplant-indications').then(function(indications) {
$scope.indications = indications;
}),
store.findMany('liver-transplant-first-graft-sources').then(function(firstGraftSources) {
$scope.firstGraftSources = firstGraftSources;
}),
store.findMany('liver-transplant-loss-reasons').then(function(lossReasons) {
$scope.lossReasons = lossReasons;
})
]));

$scope.create = function() {
var item = store.create('liver-transplants', {patient: $scope.patient.id});
self.edit(item);
};
}

LiverTransplantsController.$inject = ['$scope'];
LiverTransplantsController.prototype = Object.create(ModelListDetailController.prototype);

return LiverTransplantsController;
}

controllerFactory.$inject = [
'ModelListDetailController',
'LiverTransplantPermission',
'firstPromise',
'$injector',
'store'
];

app.factory('LiverTransplantsController', controllerFactory);

app.directive('liverTransplantsComponent', ['LiverTransplantsController', function(LiverTransplantsController) {
return {
scope: {
patient: '='
},
controller: LiverTransplantsController,
templateUrl: 'app/patients/pkd/liver-transplants-component.html'
};
}]);
})();
184 changes: 184 additions & 0 deletions src/app/patients/pkd/liver-transplants-component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
<div loading="loading" crud>
<div ng-if="viewing">
<p>
<span crud-list-button></span>
<span crud-edit-button item="item"></span>
</p>

<table class="table properties">
<tr>
<th>Source</th>
<td>{{item.getSource()}}</td>
</tr>

<tr>
<th>Registration Date</th>
<td>{{item.registrationDate | dateFormat}}</td>
</tr>

<tr>
<th>Transplant Date</th>
<td>{{item.transplantDate | dateFormat}}</td>
</tr>

<tr>
<th>Indications</th>
<td>
<div ng-if="item.indications.length == 0">-</div>
<ul ng-if="item.indications.length > 0">
<li ng-repeat="indication in item.indications">{{indication.label}}</li>
</ul>
</td>
</tr>

<tr>
<th>Other Indications</th>
<td class="newlines">{{item.otherIndications | missing}}</td>
</tr>

<tr>
<th>First Graft Source</th>
<td>{{item.firstGraftSource.label | missing}}</td>
</tr>

<tr>
<th>Reason For Loss</th>
<td>{{item.lossReason.label | missing}}</td>
</tr>

<tr>
<th>Other Reason For Loss</th>
<td class="newlines">{{item.otherLossReason | missing}}</td>
</tr>
</table>

<div metadata item="item"></div>
</div>

<div ng-if="editing">
<p>
<span crud-list-button></span>
<span crud-view-button item="originalItem"></span>
</p>

<form class="form-horizontal form-container" crud-submit="saveAndView()" novalidate>
<div frm-field frm-group>
<div frm-label>Source</div>

<div frm-control>
<div frm-source-group-field patient="patient" model="item.sourceGroup" required="true"></div>
<div frm-errors errors="item.errors.sourceGroup"></div>
</div>
</div>

<div frm-field frm-group>
<div frm-label>Registration Date</div>

<div frm-control>
<div frm-date-field model="item.registrationDate"></div>
<div frm-errors errors="item.errors.registrationDate"></div>
</div>
</div>

<div frm-field frm-group>
<div frm-label>Transplant Date</div>

<div frm-control>
<div frm-date-field model="item.transplantDate" required="true"></div>
<div frm-errors errors="item.errors.transplantDate"></div>
</div>
</div>

<div frm-field frm-group>
<div frm-label>Indications</div>

<div frm-control>
<div frm-multiple-checkbox-field model="item.indications" options="indications"></div>
<div frm-errors errors="item.errors.indications"></div>
</div>
</div>

<div frm-field frm-group>
<div frm-label>Other Indications</div>

<div frm-control>
<div frm-textarea-field model="item.otherIndications"></div>
<div frm-errors errors="item.errors.otherIndications"></div>
</div>
</div>

<div frm-field frm-group>
<div frm-label>First Graft Source</div>

<div frm-control>
<div frm-select-field model="item.firstGraftSource" options="firstGraftSources"></div>
<div frm-errors errors="item.errors.firstGraftSource"></div>
</div>
</div>

<div frm-field frm-group>
<div frm-label>Reason For Loss</div>

<div frm-control>
<div frm-select-field model="item.lossReason" options="lossReasons"></div>
<div frm-errors errors="item.errors.lossReason"></div>
</div>
</div>

<div frm-field frm-group>
<div frm-label>Other Reason For Loss</div>

<div frm-control>
<div frm-textarea-field model="item.otherLossReason"></div>
<div frm-errors errors="item.errors.otherLossReason"></div>
</div>
</div>

<div frm-buttons>
<span crud-save-button></span>
<span crud-cancel-list-button></span>
</div>
</form>
</div>

<div ng-if="!viewing && !editing" list-helper="items as page" list-helper-options="{sortBy: 'transplantDate', reverse: true}">
<p>
<span crud-create-button action="create()"></span>
</p>

<div filter-helper></div>

<div ng-show="!page.getCount()">
<p>No results.</p>
</div>

<table class="table table-condensed table-striped" ng-if="page.getCount()">
<thead>
<tr>
<th></th>
<th sort-helper="transplantDate">Date</th>
<th sort-helper="getSource()">Source</th>
<th></th>
</tr>
</thead>

<tbody>
<tr ng-repeat="item in page.getItems()">
<td>
<span crud-list-view-button item="item"></span>
<span crud-list-edit-button item="item"></span>
</td>

<td>{{item.transplantDate | dateFormat}}</td>
<td class="source">{{item.getSource()}}</td>

<td>
<span crud-list-remove-button item="item"></span>
</td>
</tr>
</tbody>
</table>

<div pagination-helper></div>
</div>
</div>
3 changes: 3 additions & 0 deletions src/app/patients/pkd/liver-transplants.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<h1 class="page-header">Liver Transplants</h1>

<div liver-transplants-component patient="patient"></div>
5 changes: 5 additions & 0 deletions src/app/patients/pkd/pkd.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,10 @@
url: '/liver-imaging',
templateUrl: 'app/patients/pkd/liver-imaging.html'
});

$stateProvider.state('patient.liverTransplants', {
url: '/liver-transplants',
templateUrl: 'app/patients/pkd/liver-transplants.html'
});
}]);
})();

0 comments on commit 01a27fc

Please sign in to comment.