From bf614b5f6a7558c35af3f26f13e5478d7ede1ec3 Mon Sep 17 00:00:00 2001 From: Chima Date: Mon, 6 Feb 2017 13:40:55 +0100 Subject: [PATCH] fix: added next appointment and operative plans to opd form --- app/helpers/date-format.js | 3 ++ app/reports/edit/controller.js | 41 ++++++++++++++- app/reports/edit/route.js | 3 +- app/reports/edit/template.hbs | 91 +++++++++++++++++++++++++++++++++- 4 files changed, 133 insertions(+), 5 deletions(-) diff --git a/app/helpers/date-format.js b/app/helpers/date-format.js index 0ea014d301..ff2594ae40 100644 --- a/app/helpers/date-format.js +++ b/app/helpers/date-format.js @@ -6,6 +6,9 @@ export default Ember.Helper.helper(function(params, hash) { if (hash && hash.format) { dateFormat = hash.format; } + if (date && typeof date.get == 'function') { + date = date.get('content'); + } return moment(date).format(dateFormat); } }); diff --git a/app/reports/edit/controller.js b/app/reports/edit/controller.js index 9a10ecdf87..7f63daa635 100644 --- a/app/reports/edit/controller.js +++ b/app/reports/edit/controller.js @@ -1,9 +1,11 @@ import AbstractEditController from 'hospitalrun/controllers/abstract-edit-controller'; -import ChargeActions from 'hospitalrun/mixins/charge-actions'; import Ember from 'ember'; import PatientSubmodule from 'hospitalrun/mixins/patient-submodule'; +import PatientDiagnosis from 'hospitalrun/mixins/patient-diagnosis'; +import PouchDbMixin from 'hospitalrun/mixins/pouchdb'; +import DS from 'ember-data'; -export default AbstractEditController.extend(PatientSubmodule, { +export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, PouchDbMixin, { visitsController: Ember.inject.controller('visits'), lookupListsToUpdate: [], @@ -19,6 +21,41 @@ export default AbstractEditController.extend(PatientSubmodule, { return this.get('i18n').t('reports.titles.edit'); }.property('model.isNew'), + diagnosis: Ember.computed ('model.patient',function() { + let container = this.get('model.patient'); + let result = { + primary: this.getDiagnoses(container, true, false), + secondary: this.getDiagnoses(container, true, true) + }; + return result; + }), + + nextAppointment: Ember.computed('model.patient.id', 'model.visit.startDate', function () { + let patientId = this.get('model.patient.id') + console.log('patientId', patientId) + let visitDate = this.get('model.visit.startDate') + let maxValue = this.get('maxValue'); + let promise = this.store.query('appointment', { + options: { + startkey: [patientId, null, null, 'appointment_'], + endkey: [patientId, maxValue, maxValue, maxValue] + }, + mapReduce: 'appointments_by_patient' + }).then(function(result) { + let futureAppointments = result.filter(function (data) { + let startDate = data.get('startDate') + return startDate && moment(startDate).isAfter(moment(visitDate), 'day') + }).sortBy('startDate') + if (!futureAppointments.length) { + return '' + } + let appointment = futureAppointments[0]; + let res = appointment.get('startDate'); + return res; + }); + return DS.PromiseObject.create({ promise: promise }); + }), + updateCapability: 'add_report', actions: { diff --git a/app/reports/edit/route.js b/app/reports/edit/route.js index 5b6686ae4c..c17fc3f86e 100644 --- a/app/reports/edit/route.js +++ b/app/reports/edit/route.js @@ -1,8 +1,7 @@ import AbstractEditRoute from 'hospitalrun/routes/abstract-edit-route'; -import ChargeRoute from 'hospitalrun/mixins/charge-route'; import Ember from 'ember'; -export default AbstractEditRoute.extend(ChargeRoute, { +export default AbstractEditRoute.extend({ modelName: 'report', database: Ember.inject.service(), getNewData() { diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index 09f95f40e0..f12b41ee93 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -8,5 +8,94 @@ disablePatientLink=model.isNew }} {{/if}} + {{#if model.visit.patient.displayPatientId}} +
+ + +
+ {{/if}} + {{#if model.visit.patient.dateOfBirth}} +
+ + +
+ {{/if}} + + {{#if diagnosis.primary.length}} +
+ + +
+ {{/if}} + + {{#if diagnosis.secondary.length}} +
+ + +
+ {{/if}} + + {{#if model.visit.procedures.length}} +
+ + +
+ {{/if}} + + {{#if model.visit.labs.length}} +
+ + +
+ {{/if}} + + {{#if model.visit.imaging.length}} +
+ + +
+ {{/if}} + + + {{#if nextAppointment}} +
+ + +
+ {{/if}} + + {{#if model.visit.patient.operativePlans.length}} +
+ + +
+ {{/if}} + {{/em-form}} -{{/edit-panel}} \ No newline at end of file +{{/edit-panel}}