Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
Fixed patient discharge
Browse files Browse the repository at this point in the history
Fixes #356
  • Loading branch information
jkleinsc committed Mar 15, 2016
1 parent b64a373 commit 1aa358e
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions app/visits/edit/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,23 +149,21 @@ export default AbstractEditController.extend(ChargeActions, PatientSubmodule, Us
afterUpdate: function() {
var patient = this.get('model.patient'),
patientAdmitted = patient.get('admitted'),
patientUpdated = false,
status = this.get('model.status');
if (status === 'Admitted' && !patientAdmitted) {
patient.set('admitted', true);
patientUpdated = true;
patient.save().then(this._finishAfterUpdate.bind(this));
} else if (status === 'Discharged' && patientAdmitted) {
this.getPatientVisits(patient).then(function(visits) {
if (Ember.isEmpty(visits.findBy('status', 'Admitted'))) {
patient.set('admitted', false);
patientUpdated = true;
patient.save().then(this._finishAfterUpdate.bind(this));
} else {
this._finishAfterUpdate();
}
}.bind(this));
}
if (patientUpdated) {
patient.save().then(this._finishAfterUpdate.bind(this));
} else {
this.displayAlert('Visit Saved', 'The visit record has been saved.');
this._finishAfterUpdate();
}
},

Expand Down

0 comments on commit 1aa358e

Please sign in to comment.