From 3aa7497194d3be9e61d8a864303d12b6edc042f3 Mon Sep 17 00:00:00 2001 From: Hugo Soto Date: Tue, 10 Jan 2017 16:47:47 -0300 Subject: [PATCH] Lab model modification (#916) * Modified invoice model * Modified lab model --- app/models/lab.js | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/app/models/lab.js b/app/models/lab.js index 41567f12e9..cfaae72498 100644 --- a/app/models/lab.js +++ b/app/models/lab.js @@ -2,36 +2,34 @@ import AbstractModel from 'hospitalrun/models/abstract'; import CanEditRequested from 'hospitalrun/mixins/can-edit-requested'; import DateFormat from 'hospitalrun/mixins/date-format'; import DS from 'ember-data'; +import Ember from 'ember'; import PatientValidation from 'hospitalrun/utils/patient-validation'; import ResultValidation from 'hospitalrun/mixins/result-validation'; +const { computed, get } = Ember; + export default AbstractModel.extend(CanEditRequested, DateFormat, ResultValidation, { - charges: DS.hasMany('proc-charge', { - async: false - }), + // Attributes labDate: DS.attr('date'), - labType: DS.belongsTo('pricing', { - async: false - }), notes: DS.attr('string'), - patient: DS.belongsTo('patient', { - async: false - }), requestedBy: DS.attr('string'), requestedDate: DS.attr('date'), result: DS.attr('string'), status: DS.attr('string'), - visit: DS.belongsTo('visit', { - async: false - }), - labDateAsTime: function() { - return this.dateToTime(this.get('labDate')); - }.property('labDate'), + // Associations + charges: DS.hasMany('proc-charge', { async: false }), + labType: DS.belongsTo('pricing', { async: false }), + patient: DS.belongsTo('patient', { async: false }), + visit: DS.belongsTo('visit', { async: false }), + + labDateAsTime: computed('labDate', function() { + return this.dateToTime(get(this, 'labDate')); + }), - requestedDateAsTime: function() { - return this.dateToTime(this.get('requestedDate')); - }.property('requestedDate'), + requestedDateAsTime: computed('requestedDate', function() { + return this.dateToTime(get(this, 'requestedDate')); + }), validations: { labTypeName: {