This repository has been archived by the owner on Jan 9, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
addresses #349
- Loading branch information
Darin Swanson
committed
Mar 15, 2016
1 parent
f5fb033
commit 868d5b0
Showing
6 changed files
with
118 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import AbstractPagedController from 'hospitalrun/controllers/abstract-paged-controller'; | ||
import PatientVisits from 'hospitalrun/mixins/patient-visits'; | ||
export default AbstractPagedController.extend(PatientVisits, { | ||
addPermission: 'add_patient', | ||
deletePermission: 'delete_patient', | ||
canAdmitPatient: function() { | ||
return this.currentUserCan('admit_patient'); | ||
}.property(), | ||
|
||
canDischargePatient: function() { | ||
return this.currentUserCan('discharge_patient'); | ||
}.property(), | ||
|
||
startKey: [], | ||
actions: { | ||
admitPatient: function(patient) { | ||
this.getPatientVisits(patient).then(function(visits) { | ||
this.send('createNewVisit', patient, visits); | ||
}.bind(this)); | ||
|
||
}, | ||
|
||
dischargePatient: function(patient) { | ||
this.getPatientVisits(patient).then(function(visits) { | ||
var visitToDischarge = visits.findBy('status', 'Admitted'); | ||
if (visitToDischarge) { | ||
visitToDischarge.set('status', 'Discharged'); | ||
visitToDischarge.set('endDate', new Date()); | ||
this.transitionToRoute('visits.edit', visitToDischarge); | ||
} | ||
}.bind(this)); | ||
} | ||
} | ||
}); |
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,19 @@ | ||
import AbstractIndexRoute from 'hospitalrun/routes/abstract-index-route'; | ||
export default AbstractIndexRoute.extend({ | ||
modelName: 'patient', | ||
pageTitle: 'Admitted patients', | ||
|
||
_getStartKeyFromItem: function(item) { | ||
var displayPatientId = item.get('displayPatientId'); | ||
return [displayPatientId, 'patient_' + item.get('id')]; | ||
}, | ||
|
||
_modelQueryParams: function() { | ||
return { | ||
options: { | ||
key: true | ||
}, | ||
mapReduce: 'patient_by_admission' | ||
}; | ||
} | ||
}); |
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,55 @@ | ||
{{#item-listing paginationProps=paginationProps }} | ||
{{#if hasRecords}} | ||
<table class="table"> | ||
<thead> | ||
<tr class="table-header"> | ||
{{#sortable-column sortBy='id' sortDesc=sortDesc sortKey=sortKey }}ID{{/sortable-column}} | ||
{{#sortable-column sortBy='firstName' sortDesc=sortDesc sortKey=sortKey }}First Name{{/sortable-column}} | ||
{{#sortable-column sortBy='lastName' sortDesc=sortDesc sortKey=sortKey }}Last Name{{/sortable-column}} | ||
{{#sortable-column sortBy='sex' sortDesc=sortDesc sortKey=sortKey }}Sex{{/sortable-column}} | ||
{{#sortable-column sortBy='dateOfBirth' sortDesc=sortDesc sortKey=sortKey }}DOB{{/sortable-column}} | ||
{{#sortable-column sortBy='status' sortDesc=sortDesc sortKey=sortKey }}Status{{/sortable-column}} | ||
{{#if showActions}} | ||
<th>{{t 'labels.actions'}}</th> | ||
{{/if}} | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{{#each model as |patient|}} | ||
<tr {{action 'editItem' patient}}> | ||
<td>{{patient.displayPatientId}}</td> | ||
<td>{{patient.firstName}}</td> | ||
<td>{{patient.lastName}}</td> | ||
<td>{{patient.sex}}</td> | ||
<td>{{date-format patient.dateOfBirth}}</td> | ||
<td>{{patient.status}}</td> | ||
{{#if showActions}} | ||
<td> | ||
{{#if canAdd}} | ||
<button class="btn btn-default neutral" {{action 'editItem' patient bubbles=false }}>{{t 'labels.edit'}}</button> | ||
{{/if}} | ||
{{#unless patient.admitted}} | ||
{{#if canAdmitPatient}} | ||
<button class="btn btn-default success" {{action 'admitPatient' patient bubbles=false }}><span class="glyphicon glyphicon-log-in"></span> Admit</button> | ||
{{/if}} | ||
{{/unless}} | ||
{{#if patient.admitted}} | ||
{{#if canDischargePatient}} | ||
<button class="btn btn-default info" {{action 'dischargePatient' patient bubbles=false }}><span class="glyphicon glyphicon-log-out"></span> Discharge</button> | ||
{{/if}} | ||
{{/if}} | ||
{{#if canDelete}} | ||
<button class="btn btn-default warning" {{action 'deleteItem' patient bubbles=false }}><span class="octicon octicon-x"></span> Delete</button> | ||
{{/if}} | ||
</td> | ||
{{/if}} | ||
</tr> | ||
{{/each}} | ||
</tbody> | ||
</table> | ||
{{else}} | ||
<div class="alert alert-info" data-test-selector="no-patients-found"> | ||
<p>No patients found. {{#if canAdd}}<a href="#" {{action 'newItem'}}>Create a new patient record?</a>{{/if}}</p> | ||
</div> | ||
{{/if}} | ||
{{/item-listing}} |
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
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
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