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

Commit

Permalink
Added Admission visit type
Browse files Browse the repository at this point in the history
Admission type allows entry on admission and discharge dates and times.
Resolves #38
  • Loading branch information
jkleinsc committed May 6, 2015
1 parent 7fdc9d3 commit 4716eee
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
23 changes: 23 additions & 0 deletions app/models/visit.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,29 @@ export default AbstractModel.extend({
}.property('visitDate', 'visitType'),

validations: {
endDate: {
acceptance: {
accept: true,
if: function(object) {
if (!object.get('isDirty')) {
return false;
}
var startDate = object.get('startDate'),
endDate = object.get('endDate');
if (Ember.isEmpty(endDate) || Ember.isEmpty(startDate)) {
//Can't validate if empty
return false;
} else {
if (endDate.getTime() <= startDate.getTime()) {
return true;
}
}
return false;
},
message: 'Please select an end date later than the start date'
}
},

startDate: {
presence: true
},
Expand Down
29 changes: 29 additions & 0 deletions app/visits/edit/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,34 @@ export default AbstractEditController.extend(ChargeActions, PatientSubmodule, Us
return this.currentUserCan('delete_vitals');
}.property(),

dateFormat: function() {
if (this.get('isAdmissionVisit')) {
return 'l h:mm A';
} else {
return 'l';
}
}.property('isAdmissionVisit'),

endDateLabel: function() {
if (this.get('isAdmissionVisit')) {
return 'Discharge Date';
} else {
return 'End Date';
}
}.property('isAdmissionVisit'),

isAdmissionVisit: function() {
var visitType = this.get('visitType');
return (visitType === 'Admission');
}.property('visitType'),

startDateLabel: function() {
if (this.get('isAdmissionVisit')) {
return 'Admission Date';
} else {
return 'Start Date';
}
}.property('isAdmissionVisit'),

cancelAction: 'returnToPatient',
chargePricingCategory: 'Ward',
Expand All @@ -68,6 +96,7 @@ export default AbstractEditController.extend(ChargeActions, PatientSubmodule, Us
pricingTypes: Ember.computed.alias('controllers.visits.wardPricingTypes'),
physicianList: Ember.computed.alias('controllers.visits.physicianList'),
locationList: Ember.computed.alias('controllers.visits.locationList'),
visitTypesList: Ember.computed.alias('controllers.visits.visitTypeList'),
lookupListsToUpdate: [{
name: 'clinicList',
property: 'clinic',
Expand Down
4 changes: 2 additions & 2 deletions app/visits/edit/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
<label>Patient</label>
<p class="form-control-static">{{patient.displayName}}</p>
</div>
{{date-picker property="startDate" label="Start Date" class="col-sm-3 required"}}
{{date-picker property="endDate" label="End Date" class="col-sm-3"}}
{{date-picker property="startDate" label=startDateLabel format=dateFormat showTime=isAdmissionVisit class="col-sm-3 required"}}
{{date-picker property="endDate" label=endDateLabel format=dateFormat showTime=isAdmissionVisit class="col-sm-3"}}
</div>
<div class="row">
{{em-select class="col-sm-3 required" label="Visit Type"
Expand Down

0 comments on commit 4716eee

Please sign in to comment.