From 4716eeeae5021b27a6804ee88873605cf4fb6e82 Mon Sep 17 00:00:00 2001 From: John Kleinschmidt Date: Wed, 6 May 2015 09:59:50 -0400 Subject: [PATCH] Added Admission visit type Admission type allows entry on admission and discharge dates and times. Resolves HospitalRun/frontend#38 --- app/models/visit.js | 23 +++++++++++++++++++++++ app/visits/edit/controller.js | 29 +++++++++++++++++++++++++++++ app/visits/edit/template.hbs | 4 ++-- 3 files changed, 54 insertions(+), 2 deletions(-) diff --git a/app/models/visit.js b/app/models/visit.js index f95014f7c6..21397e9200 100644 --- a/app/models/visit.js +++ b/app/models/visit.js @@ -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 }, diff --git a/app/visits/edit/controller.js b/app/visits/edit/controller.js index 3197a9f977..1bb87db358 100644 --- a/app/visits/edit/controller.js +++ b/app/visits/edit/controller.js @@ -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', @@ -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', diff --git a/app/visits/edit/template.hbs b/app/visits/edit/template.hbs index 9c8676d3f0..a33d828a82 100644 --- a/app/visits/edit/template.hbs +++ b/app/visits/edit/template.hbs @@ -17,8 +17,8 @@

{{patient.displayName}}

- {{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"}}
{{em-select class="col-sm-3 required" label="Visit Type"