From bf79a5c24b0a96adda29db3c6926f21df236e575 Mon Sep 17 00:00:00 2001 From: Chima Date: Tue, 21 Feb 2017 14:48:20 +0100 Subject: [PATCH 01/11] fix: fixed bug that has to do with page header title --- app/reports/edit/route.js | 18 ++++++++++++++++++ app/visits/edit/controller.js | 18 ++---------------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/app/reports/edit/route.js b/app/reports/edit/route.js index 68a441e248..54749b2ece 100644 --- a/app/reports/edit/route.js +++ b/app/reports/edit/route.js @@ -1,5 +1,6 @@ import AbstractEditRoute from 'hospitalrun/routes/abstract-edit-route'; import Ember from 'ember'; +import { translationMacro as t } from 'ember-i18n'; export default AbstractEditRoute.extend({ modelName: 'report', @@ -14,6 +15,23 @@ export default AbstractEditRoute.extend({ return customForms.setDefaultCustomForms(['opdReport'], newReportData); }, + afterModel(model) { + if (model.get('isNew')) { + let visit = this.modelFor('visits.edit'); + if (!visit) { + return this.transitionTo('patients'); + } + model.set('visit', visit); + } + model.setProperties({ returnToVisit: model.get('visit.id') }); + }, + + getScreenTitle(model) { + let state = model.get('isNew') ? 'new' : 'edit'; + let type = model.get('visit.outPatient') ? 'opd' : 'discharge'; + return t(`reports.${type}.titles.${state}`); + }, + setupController(controller, model) { this._super(controller, model); } diff --git a/app/visits/edit/controller.js b/app/visits/edit/controller.js index 979631d3b4..dc7ecab838 100644 --- a/app/visits/edit/controller.js +++ b/app/visits/edit/controller.js @@ -9,7 +9,6 @@ import PatientSubmodule from 'hospitalrun/mixins/patient-submodule'; import UserSession from 'hospitalrun/mixins/user-session'; import VisitStatus from 'hospitalrun/utils/visit-statuses'; import VisitTypes from 'hospitalrun/mixins/visit-types'; -import { translationMacro as t } from 'ember-i18n'; const { computed, @@ -437,24 +436,11 @@ export default AbstractEditController.extend(AddNewPatient, ChargeActions, Diagn }, newReport() { - let that = this; - this._addChildObject('reports.edit', (newRoute) => { - let controller = newRoute.controllerFor('visits'); - let isOutPatient = that.get('model').get('outPatient'); - controller.set('currentScreenTitle', isOutPatient ? t('reports.opd.titles.new') : t('reports.discharge.titles.new')); - }); + this._addChildObject('reports.edit'); }, editReport() { - let that = this; - this.transitionToRoute('reports.edit', this.get('report.id')) - .then(function(newRoute) { - let controller = newRoute.controllerFor('visits'); - newRoute.currentModel.setProperties({ returnToVisit: that.get('model.id') - }); - let isOutPatient = that.get('model').get('outPatient'); - controller.set('currentScreenTitle', isOutPatient ? t('reports.opd.titles.edit') : t('reports.discharge.titles.edit')); - }); + this.transitionToRoute('reports.edit', this.get('report.id')); }, newAppointment() { From 0b0b7614d8b19b7a3bd7ee2850ba0d4258cd654d Mon Sep 17 00:00:00 2001 From: Chima Date: Wed, 22 Feb 2017 10:31:00 +0100 Subject: [PATCH 02/11] fix: added translations for discharge report --- app/locales/en/translations.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/locales/en/translations.js b/app/locales/en/translations.js index feab068832..a2c267763e 100644 --- a/app/locales/en/translations.js +++ b/app/locales/en/translations.js @@ -1109,6 +1109,8 @@ export default { }, form: { visitDate: 'Date of Visit', + dischargeDate: 'Date of Discharge', + notes: 'Notes', primaryDiagnosis: 'Primary Diagnosis', secondaryDiagnosis: 'Secondary Diagnosis', procedures: 'Procedures', From 6a2e48015175508f177015c09250a18ace9fe507 Mon Sep 17 00:00:00 2001 From: Chima Date: Wed, 22 Feb 2017 10:31:54 +0100 Subject: [PATCH 03/11] fix: modified report model to accommodate discharge report --- app/models/report.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/models/report.js b/app/models/report.js index f6516dd802..ac12420641 100644 --- a/app/models/report.js +++ b/app/models/report.js @@ -7,7 +7,7 @@ export default AbstractModel.extend({ customForms: DS.attr('custom-forms'), reportType: DS.attr('string'), nextAppointment: DS.attr('date'), - diagnosis: DS.attr(), + surgeon: DS.attr('string'), // Associations visit: DS.belongsTo('visit', { async: false }), @@ -19,6 +19,15 @@ export default AbstractModel.extend({ reportDate: { presence: true + }, + + surgeon: { + presence: { + 'if'(object) { + return !object.get('visit.outPatient'); + }, + message: 'Please select a surgeon' + } } } }); From 3c6cb9e9b74160d26b2efb7fd68003e50bb74efe Mon Sep 17 00:00:00 2001 From: Chima Date: Wed, 22 Feb 2017 10:32:24 +0100 Subject: [PATCH 04/11] fix: added discharge report --- app/reports/edit/controller.js | 11 +++++++- app/reports/edit/template.hbs | 48 ++++++++++++++++++++++++++++------ 2 files changed, 50 insertions(+), 9 deletions(-) diff --git a/app/reports/edit/controller.js b/app/reports/edit/controller.js index 0f300dee03..3fe00c4b36 100644 --- a/app/reports/edit/controller.js +++ b/app/reports/edit/controller.js @@ -7,9 +7,15 @@ import DS from 'ember-data'; import moment from 'moment'; export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, PouchDbMixin, { - lookupListsToUpdate: [], + lookupListsToUpdate: [{ + name: 'physicianList', + property: 'model.surgeon', + id: 'physician_list' + }], + visitsController: Ember.inject.controller('visits'), newReport: false, + physicianList: Ember.computed.alias('visitsController.physicianList'), diagnosis: Ember.computed('model.patient', function() { let container = this.get('model.patient'); @@ -72,6 +78,9 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, } else { // update discharge report properties this.get('model').set('reportType', 'Discharge Report'); + // check that doctor exists + // check that next appointment exist + // } } resolve(); diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index 20a3761064..0f00d54aa0 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -1,6 +1,5 @@ -{{#if model.visit.outPatient}} +{{partial "report-header"}}
- {{partial "report-header"}} {{#edit-panel editPanelProps=editPanelProps}} {{#em-form model=model submitButton=false }} {{#if model.visit}} @@ -19,6 +18,37 @@
{{/if}} + {{#if model.visit.outPatient}} + {{else}} +
+

{{t 'reports.form.dischargeDate' }}

+ {{date-format model.reportDate format="DD/MM/YYYY hh:mm a"}} +
+ {{/if}} + + {{#if model.visit.outPatient}} + {{else}} +
+ {{select-or-typeahead className="col-sm-4" property="surgeon" + label=(t "operativePlan.labels.surgeon") list=physicianList + selection=model.surgeon + class="plan-surgeon" + }} +
+ {{/if}} + + {{#if model.visit.outPatient}} + {{else}} + {{#if model.visit.notes}} +
+ +
    +
  • {{model.visit.notes}}
  • +
+
+ {{/if}} + {{/if}} + {{#if diagnosis.primary.length}}
@@ -46,7 +76,7 @@
    {{#each model.visit.procedures as |item|}} -
  • {{item.description}}
  • +
  • {{item.description}} {{#if item.procedureDate }} - {{date-format item.procedureDate format="DD/MM/YYYY"}} {{/if}}
  • {{/each}}
@@ -95,12 +125,14 @@ {{/if}} - {{custom-form-manager model=model formType="opdReport"}} + {{#if model.visit.outPatient}} + {{custom-form-manager model=model formType="opdReport"}} + {{else}} + + {{/if}} + + {{/em-form}} {{/edit-panel}} - -{{else}} - -{{/if}} \ No newline at end of file From a0c3ddf5d4030a3ed4f9d1490b694cd85eaf2e87 Mon Sep 17 00:00:00 2001 From: Chima Date: Wed, 22 Feb 2017 10:35:12 +0100 Subject: [PATCH 05/11] fix: added next appointment date to discharge report on save --- app/reports/edit/controller.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/app/reports/edit/controller.js b/app/reports/edit/controller.js index 3fe00c4b36..b3d1dae79e 100644 --- a/app/reports/edit/controller.js +++ b/app/reports/edit/controller.js @@ -69,18 +69,12 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, beforeUpdate() { return new Ember.RSVP.Promise(function(resolve) { if (this.get('model.isNew')) { - + let appointmentDate = this.get('nextAppointment').get('content'); + this.get('model').set('nextAppointment', appointmentDate); if (this.get('model.visit.outPatient')) { this.get('model').set('reportType', 'OPD Report'); - let appointmentDate = this.get('nextAppointment').get('content'); - this.get('model').set('nextAppointment', appointmentDate); - this.get('model').set('diagnosis', this.get('diagnosis')); } else { - // update discharge report properties this.get('model').set('reportType', 'Discharge Report'); - // check that doctor exists - // check that next appointment exist - // } } resolve(); From bd2b0d431a4cbd4f491f2988f54ee47c860704d2 Mon Sep 17 00:00:00 2001 From: Chima Date: Wed, 22 Feb 2017 11:24:07 +0100 Subject: [PATCH 06/11] fix: implemented next appointment as a mixin --- app/mixins/patient-visits.js | 28 +++++++++++++++++++++++++++- app/reports/edit/controller.js | 29 +++-------------------------- 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/app/mixins/patient-visits.js b/app/mixins/patient-visits.js index aee87fa98b..a32a880bc3 100644 --- a/app/mixins/patient-visits.js +++ b/app/mixins/patient-visits.js @@ -1,7 +1,8 @@ import Ember from 'ember'; import PouchDbMixin from 'hospitalrun/mixins/pouchdb'; import VisitStatus from 'hospitalrun/utils/visit-statuses'; - +import DS from 'ember-data'; +import moment from 'moment'; const { isEmpty } = Ember; @@ -20,6 +21,31 @@ export default Ember.Mixin.create(PouchDbMixin, { }); }, + getPatientFutureAppointment (visit) { + let patientId = visit.get('patient.id'); + let visitDate = visit.get('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; + let res = appointment.get('startDate'); + return res; + }); + return DS.PromiseObject.create({ promise }); + }, + checkoutVisit(visit, status) { visit.set('status', status); visit.set('endDate', new Date()); diff --git a/app/reports/edit/controller.js b/app/reports/edit/controller.js index b3d1dae79e..16c2e24b6a 100644 --- a/app/reports/edit/controller.js +++ b/app/reports/edit/controller.js @@ -3,10 +3,9 @@ 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'; -import moment from 'moment'; +import PatientVisit from 'hospitalrun/mixins/patient-visits' -export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, PouchDbMixin, { +export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, PouchDbMixin, PatientVisit, { lookupListsToUpdate: [{ name: 'physicianList', property: 'model.surgeon', @@ -27,32 +26,10 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, }), nextAppointment: Ember.computed('model', function() { - let patientId = this.get('model.visit.patient.id'); - 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; - let res = appointment.get('startDate'); - return res; - }); - return DS.PromiseObject.create({ promise }); + return this.getPatientFutureAppointment(this.get('model.visit')) }), additionalButtons: Ember.computed('model.{isNew}', function() { - // let i18n = get(this, 'i18n'); let isNew = this.get('model.isNew'); if (!isNew) { return [{ From 1cf8534a32310e25b5be4ddd6ce0e1c87f76d2bd Mon Sep 17 00:00:00 2001 From: Chima Date: Wed, 22 Feb 2017 17:17:33 +0100 Subject: [PATCH 07/11] fix: added translations for followup appointment message --- app/locales/en/translations.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/locales/en/translations.js b/app/locales/en/translations.js index a2c267763e..25033aa2ef 100644 --- a/app/locales/en/translations.js +++ b/app/locales/en/translations.js @@ -1104,7 +1104,7 @@ export default { }, reports: { titles: { - preview: 'Preview Report', + followup: 'Create Followup appointment', saved: 'The report has been saved' }, form: { @@ -1132,7 +1132,7 @@ export default { } }, messages: { - deleteMedication: 'Are you sure you want to delete this medication?', + followup: 'Create new followup appointment for the discharge report', delete: 'Are you sure you wish to delete this report?', saved: 'The report has been saved.' } From d0140b30cf85b122912a98ff5a607da04a048f6a Mon Sep 17 00:00:00 2001 From: Chima Date: Wed, 22 Feb 2017 17:18:30 +0100 Subject: [PATCH 08/11] fix: made sure a followup appointment exists before you generate discharge report --- app/mixins/patient-visits.js | 2 +- app/reports/edit/controller.js | 4 ++-- app/visits/edit/controller.js | 9 +++++++++ app/visits/edit/route.js | 4 +++- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/app/mixins/patient-visits.js b/app/mixins/patient-visits.js index a32a880bc3..bf1dc2bc06 100644 --- a/app/mixins/patient-visits.js +++ b/app/mixins/patient-visits.js @@ -21,7 +21,7 @@ export default Ember.Mixin.create(PouchDbMixin, { }); }, - getPatientFutureAppointment (visit) { + getPatientFutureAppointment(visit) { let patientId = visit.get('patient.id'); let visitDate = visit.get('startDate'); let maxValue = this.get('maxValue'); diff --git a/app/reports/edit/controller.js b/app/reports/edit/controller.js index 16c2e24b6a..9cf5d41f37 100644 --- a/app/reports/edit/controller.js +++ b/app/reports/edit/controller.js @@ -3,7 +3,7 @@ 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 PatientVisit from 'hospitalrun/mixins/patient-visits' +import PatientVisit from 'hospitalrun/mixins/patient-visits'; export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, PouchDbMixin, PatientVisit, { lookupListsToUpdate: [{ @@ -26,7 +26,7 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, }), nextAppointment: Ember.computed('model', function() { - return this.getPatientFutureAppointment(this.get('model.visit')) + return this.getPatientFutureAppointment(this.get('model.visit')); }), additionalButtons: Ember.computed('model.{isNew}', function() { diff --git a/app/visits/edit/controller.js b/app/visits/edit/controller.js index dc7ecab838..cc31422291 100644 --- a/app/visits/edit/controller.js +++ b/app/visits/edit/controller.js @@ -37,6 +37,7 @@ export default AbstractEditController.extend(AddNewPatient, ChargeActions, Diagn } }), noReport: false, + nextAppointment: null, canAddAppointment: computed('model.isNew', function() { return (!this.get('model.isNew') && this.currentUserCan('add_appointment')); }), @@ -436,6 +437,14 @@ export default AbstractEditController.extend(AddNewPatient, ChargeActions, Diagn }, newReport() { + let next = this.get('nextAppointment.content'); + if (!this.get('model.outPatient') && !next) { + let i18n = this.get('i18n'); + let updateMesage = i18n.t('reports.messages.followup'); + let updateTitle = i18n.t('reports.titles.followup'); + this.displayAlert(updateTitle, updateMesage); + return false; + } this._addChildObject('reports.edit'); }, diff --git a/app/visits/edit/route.js b/app/visits/edit/route.js index b1f2e4cf38..da57946c31 100644 --- a/app/visits/edit/route.js +++ b/app/visits/edit/route.js @@ -3,9 +3,10 @@ import AbstractEditRoute from 'hospitalrun/routes/abstract-edit-route'; import ChargeRoute from 'hospitalrun/mixins/charge-route'; import Ember from 'ember'; import PatientListRoute from 'hospitalrun/mixins/patient-list-route'; +import PatientVisit from 'hospitalrun/mixins/patient-visits'; import DS from 'ember-data'; -export default AbstractEditRoute.extend(ChargeRoute, PatientListRoute, { +export default AbstractEditRoute.extend(ChargeRoute, PatientListRoute, PatientVisit, { customForms: Ember.inject.service(), editTitle: t('visits.titles.editVisit'), modelName: 'visit', @@ -58,6 +59,7 @@ export default AbstractEditRoute.extend(ChargeRoute, PatientListRoute, { return Ember.isEmpty(reports) ? '' : reports.get('firstObject'); }); controller.set('report', DS.PromiseObject.create({ promise })); + controller.set('nextAppointment', this.getPatientFutureAppointment(model)); this._super(controller, model); }, From d35a8a9b312c848acf8757c337d23bb6ee55e72e Mon Sep 17 00:00:00 2001 From: Chima Date: Thu, 23 Feb 2017 10:32:49 +0100 Subject: [PATCH 09/11] fix: fixed report header conflict --- app/reports/edit/template.hbs | 1 - 1 file changed, 1 deletion(-) diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index 21d473ed55..ca0c31a372 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -15,7 +15,6 @@ {{headerLine3}}
{{/if}} -{{#if model.visit.outPatient}}
{{#edit-panel editPanelProps=editPanelProps}} {{#em-form model=model submitButton=false }} From edb0ef3037b468285bfb0409970321b194bab2f4 Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Thu, 23 Feb 2017 12:03:05 +0100 Subject: [PATCH 10/11] Refactor report template --- app/reports/edit/template.hbs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index ca0c31a372..2b14d1b779 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -34,16 +34,14 @@
{{/if}} - {{#if model.visit.outPatient}} - {{else}} + {{#unless model.visit.outPatient}}

{{t 'reports.form.dischargeDate' }}

{{date-format model.reportDate format="DD/MM/YYYY hh:mm a"}}
- {{/if}} + {{/unless}} - {{#if model.visit.outPatient}} - {{else}} + {{#unless model.visit.outPatient}}
{{select-or-typeahead className="col-sm-4" property="surgeon" label=(t "operativePlan.labels.surgeon") list=physicianList @@ -51,10 +49,9 @@ class="plan-surgeon" }}
- {{/if}} + {{/unless}} - {{#if model.visit.outPatient}} - {{else}} + {{#unless model.visit.outPatient}} {{#if model.visit.notes}}
@@ -63,7 +60,7 @@
{{/if}} - {{/if}} + {{/unless}} {{#if diagnosis.primary.length}}
From 2db7c323a419a964b7fb94114814767373d99846 Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Thu, 23 Feb 2017 12:05:46 +0100 Subject: [PATCH 11/11] Add custom forms to discharge report --- app/admin/custom-forms/edit/controller.js | 3 ++- app/locales/en/translations.js | 3 ++- app/reports/edit/route.js | 2 +- app/reports/edit/template.hbs | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/admin/custom-forms/edit/controller.js b/app/admin/custom-forms/edit/controller.js index 295418802d..63b0607044 100644 --- a/app/admin/custom-forms/edit/controller.js +++ b/app/admin/custom-forms/edit/controller.js @@ -79,7 +79,8 @@ export default AbstractEditController.extend({ 'patient', 'socialwork', 'visit', - 'opdReport' + 'opdReport', + 'dischargeReport' ], formTypes: computed(function() { diff --git a/app/locales/en/translations.js b/app/locales/en/translations.js index 25033aa2ef..b0dbdf3875 100644 --- a/app/locales/en/translations.js +++ b/app/locales/en/translations.js @@ -147,7 +147,8 @@ export default { text: 'Text', textarea: 'Large Text', visitFormType: 'Visit', - opdReportFormType: 'Outpatient Report' + opdReportFormType: 'Outpatient Report', + dischargeReportFormType: 'Discharge Report' }, messages: { deleteForm: 'Are you sure you want to delete this custom form?', diff --git a/app/reports/edit/route.js b/app/reports/edit/route.js index 54749b2ece..1aa5943735 100644 --- a/app/reports/edit/route.js +++ b/app/reports/edit/route.js @@ -12,7 +12,7 @@ export default AbstractEditRoute.extend({ customForms: Ember.Object.create() }; let customForms = this.get('customForms'); - return customForms.setDefaultCustomForms(['opdReport'], newReportData); + return customForms.setDefaultCustomForms(['opdReport', 'dischargeReport'], newReportData); }, afterModel(model) { diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index 2b14d1b779..7bdf08c846 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -141,7 +141,7 @@ {{#if model.visit.outPatient}} {{custom-form-manager model=model formType="opdReport"}} {{else}} - + {{custom-form-manager model=model formType="dischargeReport"}} {{/if}}