From ce9b90d8c10e8eddebe821af8b0884e6e81aa78e Mon Sep 17 00:00:00 2001 From: Chima Date: Thu, 26 Jan 2017 16:23:42 +0100 Subject: [PATCH 01/99] added basic translations for report --- app/locales/en/translations.js | 18 ++++++++++++-- app/reports/edit/controller.js | 44 ++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 app/reports/edit/controller.js diff --git a/app/locales/en/translations.js b/app/locales/en/translations.js index 1e8750266f..5ffd0f8b52 100644 --- a/app/locales/en/translations.js +++ b/app/locales/en/translations.js @@ -853,7 +853,8 @@ export default { notes: 'Notes', orders: 'Orders', procedures: 'Procedures', - vitals: 'Vitals' + vitals: 'Vitals', + reports: 'Reports' } }, labs: { @@ -954,7 +955,8 @@ export default { newAppointment: 'New Appointment', backToPatients: 'Back to Patient List', newPatient: '+ new patient', - patientCheckIn: 'Patient Check In' + patientCheckIn: 'Patient Check In', + newOPDReport: 'New OPD Report' }, labels: { primaryDiagnosis: 'Primary Diagnoses', @@ -1080,6 +1082,18 @@ export default { addMedication: 'Add Medication' } }, + reports: { + titles: { + edit: 'Edit Report', + saved: 'Report Saved', + new: 'New Report' + }, + messages: { + deleteMedication: 'Are you sure you want to delete this medication?', + delete: 'Are you sure you wish to delete this report?', + saved: 'The report has been saved.' + } + }, components: { chargesByTypeTab: { charges: 'charges' diff --git a/app/reports/edit/controller.js b/app/reports/edit/controller.js new file mode 100644 index 0000000000..9a10ecdf87 --- /dev/null +++ b/app/reports/edit/controller.js @@ -0,0 +1,44 @@ +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'; + +export default AbstractEditController.extend(PatientSubmodule, { + visitsController: Ember.inject.controller('visits'), + + lookupListsToUpdate: [], + + editController: Ember.inject.controller('visits/edit'), + newReport: false, + + title: function() { + let isNew = this.get('model.isNew'); + if (isNew) { + return this.get('i18n').t('reports.titles.add'); + } + return this.get('i18n').t('reports.titles.edit'); + }.property('model.isNew'), + + updateCapability: 'add_report', + + actions: { + + }, + + beforeUpdate() { + return new Ember.RSVP.Promise(function(resolve, reject) { + if (this.get('model.isNew')) { + this.addChildToVisit(this.get('model'), 'reports').then(resolve, reject); + } else { + resolve(); + } + + }.bind(this)); + }, + + afterUpdate() { + let alertTitle = this.get('i18n').t('reports.titles.saved'); + let alertMessage = this.get('i18n').t('reports.messages.saved'); + this.saveVisitIfNeeded(alertTitle, alertMessage); + } +}); From 3dd403259591464d30ca1764e4b55ae6d745515d Mon Sep 17 00:00:00 2001 From: Chima Date: Thu, 26 Jan 2017 16:25:20 +0100 Subject: [PATCH 02/99] feat: added report model --- app/models/report.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 app/models/report.js diff --git a/app/models/report.js b/app/models/report.js new file mode 100644 index 0000000000..0762dce9d5 --- /dev/null +++ b/app/models/report.js @@ -0,0 +1,26 @@ +import AbstractModel from 'hospitalrun/models/abstract'; +import DS from 'ember-data'; + +export default AbstractModel.extend({ + // Attributes + description: DS.attr('string'), + reportDate: DS.attr('date'), + + // Associations + visit: DS.belongsTo('visit', { async: false }), + + validations: { + description: { + presence: true + }, + + reportDate: { + presence: true + }, + display_reportDate: { + presence: { + message: 'Please select a valid date' + } + } + } +}); From e883089b5596493a7862bcc7c9a1199645721b7e Mon Sep 17 00:00:00 2001 From: Chima Date: Thu, 26 Jan 2017 16:27:06 +0100 Subject: [PATCH 03/99] feat: added report tabs to visit page --- app/visits/edit/controller.js | 12 ++++++++++++ app/visits/edit/template.hbs | 17 +++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/app/visits/edit/controller.js b/app/visits/edit/controller.js index 434f217a2f..744e9427a8 100644 --- a/app/visits/edit/controller.js +++ b/app/visits/edit/controller.js @@ -64,6 +64,10 @@ export default AbstractEditController.extend(AddNewPatient, ChargeActions, Diagn return this.currentUserCan('add_vitals'); }.property(), + canAddReport: function() { + return this.currentUserCan('add_report'); + }.property(), + canDeleteImaging: function() { return this.currentUserCan('delete_imaging'); }.property(), @@ -84,6 +88,10 @@ export default AbstractEditController.extend(AddNewPatient, ChargeActions, Diagn return this.currentUserCan('delete_vitals'); }.property(), + canDeleteReport: function() { + return this.currentUserCan('delete_report'); + }.property(), + isAdmissionVisit: function() { let visitType = this.get('model.visitType'); let isAdmission = (visitType === 'Admission'); @@ -421,6 +429,10 @@ export default AbstractEditController.extend(AddNewPatient, ChargeActions, Diagn this.send('openModal', 'patients.notes', model); }, + newReport() { + this._addChildObject('reports.edit'); + }, + newAppointment() { this._addChildObject('appointments.edit'); }, diff --git a/app/visits/edit/template.hbs b/app/visits/edit/template.hbs index 49d6331c14..f56cfa5d87 100644 --- a/app/visits/edit/template.hbs +++ b/app/visits/edit/template.hbs @@ -129,6 +129,11 @@ {{t 'visits.navigation.charges'}} +
  • + + {{t 'visits.navigation.reports'}} + +
  • @@ -257,6 +262,18 @@ {{partial 'item-charges'}} {{/em-form}}
    +
    +
    +
    + {{#if canAddReport}} + + {{/if}} +
    +
    + Listing of reports +
    +
    +
    {{/unless}} From 0774d1cce0b8c0acf148aa15508329bb41cd20eb Mon Sep 17 00:00:00 2001 From: Chima Date: Thu, 26 Jan 2017 16:28:07 +0100 Subject: [PATCH 04/99] feat: added report route to router --- app/router.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/router.js b/app/router.js index b61d95cc36..5f161daf32 100755 --- a/app/router.js +++ b/app/router.js @@ -101,6 +101,13 @@ Router.map(function() { }, function() { this.route('edit', { path: '/edit/:procedure_id' }); }); + + this.route('reports', { + resetNamespace: true + }, function() { + this.route('edit', { path: '/edit/:report_id' }); + }); + }); }); From 7d4d07a60368c79ef0b9ea840a6e3d6da57f8e4e Mon Sep 17 00:00:00 2001 From: Chima Date: Thu, 26 Jan 2017 16:29:20 +0100 Subject: [PATCH 05/99] feat: added report page --- app/reports/edit/route.js | 21 +++++++++++++++++++++ app/reports/edit/template.hbs | 5 +++++ 2 files changed, 26 insertions(+) create mode 100644 app/reports/edit/route.js create mode 100644 app/reports/edit/template.hbs diff --git a/app/reports/edit/route.js b/app/reports/edit/route.js new file mode 100644 index 0000000000..d84c9a3d7e --- /dev/null +++ b/app/reports/edit/route.js @@ -0,0 +1,21 @@ +import AbstractEditRoute from 'hospitalrun/routes/abstract-edit-route'; +import ChargeRoute from 'hospitalrun/mixins/charge-route'; +import Ember from 'ember'; +import { translationMacro as t } from 'ember-i18n'; + +export default AbstractEditRoute.extend(ChargeRoute, { + editTitle: t('reports.titles.edit'), + modelName: 'report', + newTitle: t('reports.titles.new'), + database: Ember.inject.service(), + + getNewData() { + return Ember.RSVP.resolve({ + reportDate: new Date() + }); + }, + + setupController(controller, model) { + this._super(controller, model); + } +}); diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs new file mode 100644 index 0000000000..5f9836f3ec --- /dev/null +++ b/app/reports/edit/template.hbs @@ -0,0 +1,5 @@ +{{#edit-panel editPanelProps=editPanelProps}} + {{#em-form model=model submitButton=false }} + + {{/em-form}} +{{/edit-panel}} \ No newline at end of file From 80de01fa88da85fb37a7a3b1bdf045f6c3b9eb9a Mon Sep 17 00:00:00 2001 From: Chima Date: Thu, 26 Jan 2017 16:30:36 +0100 Subject: [PATCH 06/99] feat: reports to visits children --- app/mixins/patient-submodule.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app/mixins/patient-submodule.js b/app/mixins/patient-submodule.js index 85e91d01a4..28aaf94db4 100644 --- a/app/mixins/patient-submodule.js +++ b/app/mixins/patient-submodule.js @@ -229,6 +229,7 @@ export default Ember.Mixin.create(PatientVisits, { promises.push(visit.get('medication')); promises.push(visit.get('procedures')); promises.push(visit.get('vitals')); + promises.push(visit.get('reports')); } return promises; }, From 1495e89092359832f467744c6b3f5a5b47e53ccf Mon Sep 17 00:00:00 2001 From: Chima Date: Thu, 26 Jan 2017 16:31:37 +0100 Subject: [PATCH 07/99] feat: added add/delete report capabilities --- app/mixins/user-session.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/app/mixins/user-session.js b/app/mixins/user-session.js index fc9162a307..bac68cfed1 100644 --- a/app/mixins/user-session.js +++ b/app/mixins/user-session.js @@ -197,6 +197,15 @@ export default Ember.Mixin.create({ 'Nurse Manager', 'System Administrator' ], + add_report: [ + 'Data Entry', + 'Doctor', + 'Hospital Administrator', + 'Medical Records Officer', + 'Nurse', + 'Nurse Manager', + 'System Administrator' + ], admit_patient: [ 'Data Entry', 'Doctor', @@ -323,6 +332,14 @@ export default Ember.Mixin.create({ 'Nurse Manager', 'System Administrator' ], + delete_report: [ + 'Doctor', + 'Hospital Administrator', + 'Medical Records Officer', + 'Nurse', + 'Nurse Manager', + 'System Administrator' + ], delete_visit: [ 'Doctor', 'Hospital Administrator', From 7c466229fc75cba1c8e51dc9b698897366c3ab5c Mon Sep 17 00:00:00 2001 From: Chima Date: Thu, 26 Jan 2017 19:41:09 +0100 Subject: [PATCH 08/99] fix: fixed diagnosisContainer issue on browser back history button --- app/reports/edit/template.hbs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index 5f9836f3ec..5c63bd18c6 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -1,5 +1,17 @@ {{#edit-panel editPanelProps=editPanelProps}} {{#em-form model=model submitButton=false }} - + {{#if model.patient}} + {{patient-summary + patient=model.patient + diagnosisContainer=model.visit + returnTo='visits.edit' + returnToContext=model.id + disablePatientLink=model.isNew + allowAddAllergy=true + allowAddDiagnosis=true + allowAddOperativePlan=true + diagnosisList=diagnosisList + }} + {{/if}} {{/em-form}} {{/edit-panel}} \ No newline at end of file From f24c59ef3294e2cbfa2d38efcfc6e1c2c4709b03 Mon Sep 17 00:00:00 2001 From: Chima Date: Mon, 30 Jan 2017 14:04:59 +0100 Subject: [PATCH 09/99] fix: display different report title based on type of visit --- app/locales/en/translations.js | 13 ++++++++++++- app/reports/edit/route.js | 4 ---- app/reports/edit/template.hbs | 11 +++-------- app/visits/edit/controller.js | 8 +++++++- app/visits/edit/template.hbs | 10 ++++++++-- 5 files changed, 30 insertions(+), 16 deletions(-) diff --git a/app/locales/en/translations.js b/app/locales/en/translations.js index 5ffd0f8b52..241537a899 100644 --- a/app/locales/en/translations.js +++ b/app/locales/en/translations.js @@ -956,7 +956,8 @@ export default { backToPatients: 'Back to Patient List', newPatient: '+ new patient', patientCheckIn: 'Patient Check In', - newOPDReport: 'New OPD Report' + newOPDReport: 'New OPD Report', + newDischargeReport: 'New Discharge Report' }, labels: { primaryDiagnosis: 'Primary Diagnoses', @@ -1088,6 +1089,16 @@ export default { saved: 'Report Saved', new: 'New Report' }, + opd: { + titles: { + new: 'New OPD Report' + } + }, + discharge: { + titles: { + new: 'New Discharge Report' + } + }, messages: { deleteMedication: 'Are you sure you want to delete this medication?', delete: 'Are you sure you wish to delete this report?', diff --git a/app/reports/edit/route.js b/app/reports/edit/route.js index d84c9a3d7e..5b6686ae4c 100644 --- a/app/reports/edit/route.js +++ b/app/reports/edit/route.js @@ -1,14 +1,10 @@ import AbstractEditRoute from 'hospitalrun/routes/abstract-edit-route'; import ChargeRoute from 'hospitalrun/mixins/charge-route'; import Ember from 'ember'; -import { translationMacro as t } from 'ember-i18n'; export default AbstractEditRoute.extend(ChargeRoute, { - editTitle: t('reports.titles.edit'), modelName: 'report', - newTitle: t('reports.titles.new'), database: Ember.inject.service(), - getNewData() { return Ember.RSVP.resolve({ reportDate: new Date() diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index 5c63bd18c6..09f95f40e0 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -1,16 +1,11 @@ {{#edit-panel editPanelProps=editPanelProps}} {{#em-form model=model submitButton=false }} - {{#if model.patient}} + {{#if model.visit}} {{patient-summary - patient=model.patient - diagnosisContainer=model.visit - returnTo='visits.edit' + patient=model.visit.patient + returnTo='visit.edit' returnToContext=model.id disablePatientLink=model.isNew - allowAddAllergy=true - allowAddDiagnosis=true - allowAddOperativePlan=true - diagnosisList=diagnosisList }} {{/if}} {{/em-form}} diff --git a/app/visits/edit/controller.js b/app/visits/edit/controller.js index 744e9427a8..ec28e3a254 100644 --- a/app/visits/edit/controller.js +++ b/app/visits/edit/controller.js @@ -8,6 +8,7 @@ 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, @@ -430,7 +431,12 @@ export default AbstractEditController.extend(AddNewPatient, ChargeActions, Diagn }, newReport() { - this._addChildObject('reports.edit'); + 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')); + }); }, newAppointment() { diff --git a/app/visits/edit/template.hbs b/app/visits/edit/template.hbs index f56cfa5d87..502c928195 100644 --- a/app/visits/edit/template.hbs +++ b/app/visits/edit/template.hbs @@ -266,11 +266,17 @@
    {{#if canAddReport}} - + {{/if}}
    - Listing of reports +
    From 1107c539d25d259b260afbdfb742613475930d7d Mon Sep 17 00:00:00 2001 From: Mofesola Babalola Date: Fri, 3 Feb 2017 09:52:52 +0100 Subject: [PATCH 10/99] Modified Package.json for new NPM Deployment --- package.json | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index b7bb5b753e..b08c5d8d27 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,9 @@ { - "name": "hospitalrun", + "name": "hospitalruncli", "version": "0.9.17", "description": "Ember front end for HospitalRun", "homepage": "http://hospitalrun.io", "directories": { - "doc": "doc", "test": "tests" }, "files": [ @@ -18,7 +17,7 @@ }, "repository": { "type": "git", - "url": "git@github.com:HospitalRun/hospitalrun-frontend" + "url": "git+ssh://git@github.com:eHealthAfrica/hospitalrun-frontend.git" }, "engines": { "node": ">= 4" @@ -26,7 +25,8 @@ "author": "John Kleinschmidt", "contributors": [ "Joel Worrall", - "Joel Glovier" + "Joel Glovier", + "eHealth Africa" ], "license": "GPL-3.0", "devDependencies": { @@ -37,7 +37,7 @@ "broccoli-manifest": "0.0.7", "broccoli-merge-trees": "^1.1.1", "broccoli-serviceworker": "0.1.4", - "broccoli-stylelint": "billybonks/broccoli-stylelint", + "broccoli-stylelint": "github:billybonks/broccoli-stylelint", "ember-ajax": "2.5.2", "ember-browserify": "^1.1.12", "ember-cli": "2.10.0", @@ -69,7 +69,7 @@ "ember-load-initializers": "^0.6.0", "ember-pouch": "4.2.1", "ember-radio-buttons": "^4.0.1", - "ember-rapid-forms": "GCorbel/ember-rapid-forms#26229804a2c430bbdf1ffb6bab8fb53af17bb3a4", + "ember-rapid-forms": "github:gcorbel/ember-rapid-forms#26229804a2c430bbdf1ffb6bab8fb53af17bb3a4", "ember-resolver": "^2.0.3", "ember-select-list": "0.9.5", "ember-simple-auth": "^1.1.0", @@ -98,5 +98,22 @@ "paths": [ "lib/pouch-fixtures" ] - } + }, + "bugs": { + "url": "https://github.com/HospitalRun/hospitalrun-frontend/issues" + }, + "main": "index.js", + "dependencies": { + "ember": "^1.0.0-pre.2" + }, + "keywords": [ + "eHealth", + "Systems", + "Africa", + "HealthCare", + "Health", + "Hospital", + "Run", + "Hospital Run" + ] } From bf614b5f6a7558c35af3f26f13e5478d7ede1ec3 Mon Sep 17 00:00:00 2001 From: Chima Date: Mon, 6 Feb 2017 13:40:55 +0100 Subject: [PATCH 11/99] 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}} +
    + +
      + {{#each diagnosis.primary as |item|}} +
    • {{item.diagnosis}}
    • + {{/each}} +
    +
    + {{/if}} + + {{#if diagnosis.secondary.length}} +
    + +
      + {{#each diagnosis.secondary as |item|}} +
    • {{item.diagnosis}}
    • + {{/each}} +
    +
    + {{/if}} + + {{#if model.visit.procedures.length}} +
    + +
      + {{#each model.visit.procedures as |item|}} +
    • {{item.description}}
    • + {{/each}} +
    +
    + {{/if}} + + {{#if model.visit.labs.length}} +
    + +
      + {{#each model.visit.labs as |item|}} +
    • {{item.labType.name}}-{{item.result}} ({{item.status}})
    • + {{/each}} +
    +
    + {{/if}} + + {{#if model.visit.imaging.length}} +
    + +
      + {{#each model.visit.imaging as |item|}} +
    • {{item.imagingType.name}}-{{item.result}} ({{item.status}})
    • + {{/each}} +
    +
    + {{/if}} + + + {{#if nextAppointment}} +
    + + +
    + {{/if}} + + {{#if model.visit.patient.operativePlans.length}} +
    + +
      + {{#each model.visit.patient.operativePlans as |item|}} + {{#each item.procedures as |p|}} +
    • {{p.description}} ({{item.status}})
    • + {{/each}} + {{/each}} +
    +
    + {{/if}} + {{/em-form}} -{{/edit-panel}} \ No newline at end of file +{{/edit-panel}} From d9268c2fc85b36a4cbd4f8aab26b0119836f4c91 Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Thu, 9 Feb 2017 00:53:04 +0100 Subject: [PATCH 12/99] Restore package.json to working state --- package.json | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/package.json b/package.json index b08c5d8d27..b7bb5b753e 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,10 @@ { - "name": "hospitalruncli", + "name": "hospitalrun", "version": "0.9.17", "description": "Ember front end for HospitalRun", "homepage": "http://hospitalrun.io", "directories": { + "doc": "doc", "test": "tests" }, "files": [ @@ -17,7 +18,7 @@ }, "repository": { "type": "git", - "url": "git+ssh://git@github.com:eHealthAfrica/hospitalrun-frontend.git" + "url": "git@github.com:HospitalRun/hospitalrun-frontend" }, "engines": { "node": ">= 4" @@ -25,8 +26,7 @@ "author": "John Kleinschmidt", "contributors": [ "Joel Worrall", - "Joel Glovier", - "eHealth Africa" + "Joel Glovier" ], "license": "GPL-3.0", "devDependencies": { @@ -37,7 +37,7 @@ "broccoli-manifest": "0.0.7", "broccoli-merge-trees": "^1.1.1", "broccoli-serviceworker": "0.1.4", - "broccoli-stylelint": "github:billybonks/broccoli-stylelint", + "broccoli-stylelint": "billybonks/broccoli-stylelint", "ember-ajax": "2.5.2", "ember-browserify": "^1.1.12", "ember-cli": "2.10.0", @@ -69,7 +69,7 @@ "ember-load-initializers": "^0.6.0", "ember-pouch": "4.2.1", "ember-radio-buttons": "^4.0.1", - "ember-rapid-forms": "github:gcorbel/ember-rapid-forms#26229804a2c430bbdf1ffb6bab8fb53af17bb3a4", + "ember-rapid-forms": "GCorbel/ember-rapid-forms#26229804a2c430bbdf1ffb6bab8fb53af17bb3a4", "ember-resolver": "^2.0.3", "ember-select-list": "0.9.5", "ember-simple-auth": "^1.1.0", @@ -98,22 +98,5 @@ "paths": [ "lib/pouch-fixtures" ] - }, - "bugs": { - "url": "https://github.com/HospitalRun/hospitalrun-frontend/issues" - }, - "main": "index.js", - "dependencies": { - "ember": "^1.0.0-pre.2" - }, - "keywords": [ - "eHealth", - "Systems", - "Africa", - "HealthCare", - "Health", - "Hospital", - "Run", - "Hospital Run" - ] + } } From 4ab6026968396601cc4c9bee446068f66a2dbbec Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Thu, 9 Feb 2017 00:56:15 +0100 Subject: [PATCH 13/99] Implement custom forms for OPD Report --- app/admin/custom-forms/edit/controller.js | 3 ++- app/locales/en/translations.js | 3 ++- app/reports/edit/route.js | 11 ++++++++--- app/reports/edit/template.hbs | 2 ++ 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/app/admin/custom-forms/edit/controller.js b/app/admin/custom-forms/edit/controller.js index 3e1c525e1e..295418802d 100644 --- a/app/admin/custom-forms/edit/controller.js +++ b/app/admin/custom-forms/edit/controller.js @@ -78,7 +78,8 @@ export default AbstractEditController.extend({ 'operativePlan', 'patient', 'socialwork', - 'visit' + 'visit', + 'opdReport' ], formTypes: computed(function() { diff --git a/app/locales/en/translations.js b/app/locales/en/translations.js index 477f3dd8bd..3652a6b486 100644 --- a/app/locales/en/translations.js +++ b/app/locales/en/translations.js @@ -144,7 +144,8 @@ export default { socialworkFormType: 'Social Work', text: 'Text', textarea: 'Large Text', - visitFormType: 'Visit' + visitFormType: 'Visit', + opdReportFormType: 'Outpatient 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 c17fc3f86e..785179485c 100644 --- a/app/reports/edit/route.js +++ b/app/reports/edit/route.js @@ -4,10 +4,15 @@ import Ember from 'ember'; export default AbstractEditRoute.extend({ modelName: 'report', database: Ember.inject.service(), + customForms: Ember.inject.service(), + getNewData() { - return Ember.RSVP.resolve({ - reportDate: new Date() - }); + let newReportData = { + reportDate: new Date(), + customForms: Ember.Object.create() + }; + let customForms = this.get('customForms'); + return customForms.setDefaultCustomForms(['opdReport'], newReportData); }, setupController(controller, model) { diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index f12b41ee93..d7577366d5 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -97,5 +97,7 @@ {{/if}} + {{custom-form-manager model=model formType="opdReport"}} + {{/em-form}} {{/edit-panel}} From 32bf618ef9ffd3a2ff31fd1a9187f56256b6d2c2 Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Thu, 9 Feb 2017 01:18:54 +0100 Subject: [PATCH 14/99] Add custom forms attribute to report model --- app/models/report.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/report.js b/app/models/report.js index 0762dce9d5..0b7196efb6 100644 --- a/app/models/report.js +++ b/app/models/report.js @@ -5,6 +5,7 @@ export default AbstractModel.extend({ // Attributes description: DS.attr('string'), reportDate: DS.attr('date'), + customForms: DS.attr('custom-forms'), // Associations visit: DS.belongsTo('visit', { async: false }), From 4e94eaedf0e10a662831a6b6582a6bdb363ef6c3 Mon Sep 17 00:00:00 2001 From: Chima Date: Mon, 13 Feb 2017 17:22:45 +0100 Subject: [PATCH 15/99] fix: saved report object --- app/models/report.js | 10 +++------- app/models/visit.js | 1 + app/reports/edit/controller.js | 21 ++++++++++----------- app/reports/edit/route.js | 1 - 4 files changed, 14 insertions(+), 19 deletions(-) diff --git a/app/models/report.js b/app/models/report.js index 0b7196efb6..76a314aeb9 100644 --- a/app/models/report.js +++ b/app/models/report.js @@ -3,25 +3,21 @@ import DS from 'ember-data'; export default AbstractModel.extend({ // Attributes - description: DS.attr('string'), reportDate: DS.attr('date'), customForms: DS.attr('custom-forms'), + reportType : DS.attr('string'), + nextAppointment: DS.attr('date'), // Associations visit: DS.belongsTo('visit', { async: false }), validations: { - description: { + visit: { presence: true }, reportDate: { presence: true - }, - display_reportDate: { - presence: { - message: 'Please select a valid date' - } } } }); diff --git a/app/models/visit.js b/app/models/visit.js index e400cb4136..317d5ae968 100644 --- a/app/models/visit.js +++ b/app/models/visit.js @@ -70,6 +70,7 @@ export default AbstractModel.extend({ status: DS.attr('string'), visitType: DS.attr(), vitals: DS.hasMany('vital', { async: true }), + reports: DS.hasMany('report', { async: true }), diagnosisList: computed('diagnoses.[]', function() { let diagnoses = this.get('diagnoses'); diff --git a/app/reports/edit/controller.js b/app/reports/edit/controller.js index 7f63daa635..350be0db96 100644 --- a/app/reports/edit/controller.js +++ b/app/reports/edit/controller.js @@ -10,7 +10,6 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, lookupListsToUpdate: [], - editController: Ember.inject.controller('visits/edit'), newReport: false, title: function() { @@ -32,7 +31,6 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, 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', { @@ -58,18 +56,19 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, updateCapability: 'add_report', - actions: { - - }, - beforeUpdate() { - return new Ember.RSVP.Promise(function(resolve, reject) { + debugger + return new Ember.RSVP.Promise(function(resolve) { if (this.get('model.isNew')) { - this.addChildToVisit(this.get('model'), 'reports').then(resolve, reject); - } else { - resolve(); + var appointmentDate = this.get('nextAppointment').get('content') + this.get('model').set('nextAppointment', appointmentDate) + if (this.get('model.visit.outPatient')) { + this.get('model').set('reportType', 'OutPatient') + } else { + this.get('model').set('reportType', 'Discharge') + } } - + resolve(); }.bind(this)); }, diff --git a/app/reports/edit/route.js b/app/reports/edit/route.js index 785179485c..68a441e248 100644 --- a/app/reports/edit/route.js +++ b/app/reports/edit/route.js @@ -3,7 +3,6 @@ import Ember from 'ember'; export default AbstractEditRoute.extend({ modelName: 'report', - database: Ember.inject.service(), customForms: Ember.inject.service(), getNewData() { From 6da7b884010b23017546237dbbdfa28a3fe1c40e Mon Sep 17 00:00:00 2001 From: Chima Date: Mon, 13 Feb 2017 21:53:05 +0100 Subject: [PATCH 16/99] fix: added preview report feat --- app/reports/edit/controller.js | 35 ++++-- app/reports/edit/template.hbs | 193 +++++++++++++++++---------------- 2 files changed, 126 insertions(+), 102 deletions(-) diff --git a/app/reports/edit/controller.js b/app/reports/edit/controller.js index 350be0db96..7aeca369bd 100644 --- a/app/reports/edit/controller.js +++ b/app/reports/edit/controller.js @@ -6,20 +6,17 @@ import PouchDbMixin from 'hospitalrun/mixins/pouchdb'; import DS from 'ember-data'; export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, PouchDbMixin, { - visitsController: Ember.inject.controller('visits'), + queryParams: ['preview'], + preview: null, + + showPreview: Ember.computed('preview', function() { + return this.get('preview') + }), lookupListsToUpdate: [], newReport: false, - title: function() { - let isNew = this.get('model.isNew'); - if (isNew) { - return this.get('i18n').t('reports.titles.add'); - } - 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 = { @@ -54,10 +51,22 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, return DS.PromiseObject.create({ promise: promise }); }), + additionalButtons: Ember.computed('model.{isNew}', function() { + //let i18n = get(this, 'i18n'); + let isNew = this.get('model.isNew'); + if (!isNew) { + return [{ + class: 'btn btn-primary on-white', + buttonAction: 'previewReport', + buttonIcon: 'octicon octicon-check', + buttonText: 'Preview and Print' + }]; + } + }), + updateCapability: 'add_report', beforeUpdate() { - debugger return new Ember.RSVP.Promise(function(resolve) { if (this.get('model.isNew')) { var appointmentDate = this.get('nextAppointment').get('content') @@ -76,5 +85,11 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, let alertTitle = this.get('i18n').t('reports.titles.saved'); let alertMessage = this.get('i18n').t('reports.messages.saved'); this.saveVisitIfNeeded(alertTitle, alertMessage); + }, + + actions: { + previewReport() { + this.transitionToRoute('reports.edit', this.get('model.id'), {queryParams: {preview: true}}) + } } }); diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index d7577366d5..1575331971 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -1,103 +1,112 @@ -{{#edit-panel editPanelProps=editPanelProps}} - {{#em-form model=model submitButton=false }} - {{#if model.visit}} - {{patient-summary - patient=model.visit.patient - returnTo='visit.edit' - returnToContext=model.id - disablePatientLink=model.isNew - }} - {{/if}} - {{#if model.visit.patient.displayPatientId}} -
    - - -
    - {{/if}} - {{#if model.visit.patient.dateOfBirth}} -
    - - -
    - {{/if}} +{{#if showPreview}} +
    + Show Preview page here +
    +{{else}} + {{#edit-panel editPanelProps=editPanelProps}} + {{#em-form model=model submitButton=false }} + {{#if model.visit}} + {{patient-summary + patient=model.visit.patient + returnTo='visit.edit' + returnToContext=model.id + disablePatientLink=model.isNew + }} + {{/if}} + {{#if model.visit.patient.displayPatientId}} +
    + + +
    + {{/if}} + {{#if model.visit.patient.dateOfBirth}} +
    + + +
    + {{/if}} - {{#if diagnosis.primary.length}} -
    - -
      - {{#each diagnosis.primary as |item|}} -
    • {{item.diagnosis}}
    • - {{/each}} -
    -
    - {{/if}} + {{#if diagnosis.primary.length}} +
    + +
      + {{#each diagnosis.primary as |item|}} +
    • {{item.diagnosis}}
    • + {{/each}} +
    +
    + {{/if}} - {{#if diagnosis.secondary.length}} -
    - -
      - {{#each diagnosis.secondary as |item|}} -
    • {{item.diagnosis}}
    • - {{/each}} -
    -
    - {{/if}} + {{#if diagnosis.secondary.length}} +
    + +
      + {{#each diagnosis.secondary as |item|}} +
    • {{item.diagnosis}}
    • + {{/each}} +
    +
    + {{/if}} - {{#if model.visit.procedures.length}} -
    - -
      - {{#each model.visit.procedures as |item|}} -
    • {{item.description}}
    • - {{/each}} -
    -
    - {{/if}} + {{#if model.visit.procedures.length}} +
    + +
      + {{#each model.visit.procedures as |item|}} +
    • {{item.description}}
    • + {{/each}} +
    +
    + {{/if}} - {{#if model.visit.labs.length}} -
    - -
      - {{#each model.visit.labs as |item|}} -
    • {{item.labType.name}}-{{item.result}} ({{item.status}})
    • - {{/each}} -
    -
    - {{/if}} + {{#if model.visit.labs.length}} +
    + +
      + {{#each model.visit.labs as |item|}} +
    • {{item.labType.name}}-{{item.result}} ({{item.status}})
    • + {{/each}} +
    +
    + {{/if}} - {{#if model.visit.imaging.length}} -
    - -
      - {{#each model.visit.imaging as |item|}} -
    • {{item.imagingType.name}}-{{item.result}} ({{item.status}})
    • - {{/each}} -
    -
    - {{/if}} + {{#if model.visit.imaging.length}} +
    + +
      + {{#each model.visit.imaging as |item|}} +
    • {{item.imagingType.name}}-{{item.result}} ({{item.status}})
    • + {{/each}} +
    +
    + {{/if}} - {{#if nextAppointment}} -
    - - -
    - {{/if}} + {{#if nextAppointment}} +
    + + +
    + {{/if}} - {{#if model.visit.patient.operativePlans.length}} -
    - -
      - {{#each model.visit.patient.operativePlans as |item|}} - {{#each item.procedures as |p|}} -
    • {{p.description}} ({{item.status}})
    • + {{#if model.visit.patient.operativePlans.length}} +
      + +
        + {{#each model.visit.patient.operativePlans as |item|}} + {{#each item.procedures as |p|}} +
      • {{p.description}} ({{item.status}})
      • + {{/each}} {{/each}} - {{/each}} -
      -
      - {{/if}} +
    +
    + {{/if}} + + {{custom-form-manager model=model formType="opdReport"}} + + {{/em-form}} + {{/edit-panel}} +{{/if}} + - {{custom-form-manager model=model formType="opdReport"}} - {{/em-form}} -{{/edit-panel}} From 32f96a28ac85499df4504588491103f92cf4f113 Mon Sep 17 00:00:00 2001 From: Chima Date: Wed, 15 Feb 2017 16:04:00 +0100 Subject: [PATCH 17/99] fix: added report by visit view --- app/utils/pouch-views.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/utils/pouch-views.js b/app/utils/pouch-views.js index ece9e40bbd..a421b86456 100644 --- a/app/utils/pouch-views.js +++ b/app/utils/pouch-views.js @@ -419,6 +419,12 @@ let designDocs = [{ emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);` ), version: 4 +}, { + name: 'report_by_visit', + function: generateView('report', + 'emit(doc.data.visit);' + ), + version: 1 }]; export default function(db, runningTest, testDumpFile) { From dd2547544ab903d0a97847ce0180ca4f650a0e79 Mon Sep 17 00:00:00 2001 From: Chima Date: Wed, 15 Feb 2017 16:05:00 +0100 Subject: [PATCH 18/99] fix: added logic to show different report sections --- app/reports/edit/controller.js | 63 +++++---- app/reports/edit/route.js | 6 + app/reports/edit/template.hbs | 227 ++++++++++++++++++--------------- 3 files changed, 164 insertions(+), 132 deletions(-) diff --git a/app/reports/edit/controller.js b/app/reports/edit/controller.js index 7aeca369bd..6b5859668d 100644 --- a/app/reports/edit/controller.js +++ b/app/reports/edit/controller.js @@ -4,31 +4,33 @@ 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'; export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, PouchDbMixin, { queryParams: ['preview'], preview: null, showPreview: Ember.computed('preview', function() { - return this.get('preview') + let preview = this.get('preview'); + return preview; }), lookupListsToUpdate: [], newReport: false, - diagnosis: Ember.computed ('model.patient',function() { + 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) - }; + 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') - let visitDate = this.get('model.visit.startDate') + nextAppointment: Ember.computed('model.patient.id', 'model.visit.startDate', function() { + let patientId = this.get('model.patient.id'); + let visitDate = this.get('model.visit.startDate'); let maxValue = this.get('maxValue'); let promise = this.store.query('appointment', { options: { @@ -37,22 +39,22 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, }, 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') + 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 '' + return ''; } - let appointment = futureAppointments[0]; + let [appointment] = [futureAppointments]; let res = appointment.get('startDate'); return res; }); - return DS.PromiseObject.create({ promise: promise }); + return DS.PromiseObject.create({ promise }); }), additionalButtons: Ember.computed('model.{isNew}', function() { - //let i18n = get(this, 'i18n'); + // let i18n = get(this, 'i18n'); let isNew = this.get('model.isNew'); if (!isNew) { return [{ @@ -68,16 +70,19 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, beforeUpdate() { return new Ember.RSVP.Promise(function(resolve) { - if (this.get('model.isNew')) { - var appointmentDate = this.get('nextAppointment').get('content') - this.get('model').set('nextAppointment', appointmentDate) - if (this.get('model.visit.outPatient')) { - this.get('model').set('reportType', 'OutPatient') - } else { - this.get('model').set('reportType', 'Discharge') - } + if (this.get('model.isNew')) { + + if (this.get('model.visit.outPatient')) { + this.get('model').set('reportType', 'OutPatient'); + 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'); } - resolve(); + } + resolve(); }.bind(this)); }, @@ -85,11 +90,15 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, let alertTitle = this.get('i18n').t('reports.titles.saved'); let alertMessage = this.get('i18n').t('reports.messages.saved'); this.saveVisitIfNeeded(alertTitle, alertMessage); + let editTitle = this.get('model.visit.outPatient') ? this.get('i18n').t('reports.opd.titles.edit') : this.get('i18n').t('reports.discharge.titles.edit'); + let sectionDetails = {}; + sectionDetails.currentScreenTitle = editTitle; + this.send('setSectionHeader', sectionDetails); }, actions: { previewReport() { - this.transitionToRoute('reports.edit', this.get('model.id'), {queryParams: {preview: true}}) + this.transitionToRoute('reports.edit', this.get('model.id'), { queryParams: { preview: true } }); } } }); diff --git a/app/reports/edit/route.js b/app/reports/edit/route.js index 68a441e248..38ebf49047 100644 --- a/app/reports/edit/route.js +++ b/app/reports/edit/route.js @@ -5,6 +5,12 @@ export default AbstractEditRoute.extend({ modelName: 'report', customForms: Ember.inject.service(), + queryParams: { + preview: { + refreshModel: true + } + }, + getNewData() { let newReportData = { reportDate: new Date(), diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index 1575331971..68daab70ae 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -1,112 +1,129 @@ -{{#if showPreview}} -
    - Show Preview page here -
    -{{else}} - {{#edit-panel editPanelProps=editPanelProps}} - {{#em-form model=model submitButton=false }} - {{#if model.visit}} - {{patient-summary - patient=model.visit.patient - returnTo='visit.edit' - returnToContext=model.id - disablePatientLink=model.isNew - }} - {{/if}} - {{#if model.visit.patient.displayPatientId}} -
    - - -
    - {{/if}} - {{#if model.visit.patient.dateOfBirth}} -
    - - -
    - {{/if}} - - {{#if diagnosis.primary.length}} -
    - -
      - {{#each diagnosis.primary as |item|}} -
    • {{item.diagnosis}}
    • - {{/each}} -
    -
    - {{/if}} - - {{#if diagnosis.secondary.length}} -
    - -
      - {{#each diagnosis.secondary as |item|}} -
    • {{item.diagnosis}}
    • - {{/each}} -
    -
    - {{/if}} - - {{#if model.visit.procedures.length}} -
    - -
      - {{#each model.visit.procedures as |item|}} -
    • {{item.description}}
    • - {{/each}} -
    -
    - {{/if}} - - {{#if model.visit.labs.length}} -
    - -
      - {{#each model.visit.labs as |item|}} -
    • {{item.labType.name}}-{{item.result}} ({{item.status}})
    • - {{/each}} -
    -
    - {{/if}} - - {{#if model.visit.imaging.length}} -
    - -
      - {{#each model.visit.imaging as |item|}} -
    • {{item.imagingType.name}}-{{item.result}} ({{item.status}})
    • - {{/each}} -
    -
    - {{/if}} - - - {{#if nextAppointment}} -
    - - -
    - {{/if}} - - {{#if model.visit.patient.operativePlans.length}} -
    - -
      - {{#each model.visit.patient.operativePlans as |item|}} - {{#each item.procedures as |p|}} -
    • {{p.description}} ({{item.status}})
    • + +{{#if model.visit.outPatient}} + {{#if showPreview}} +
      + Show Preview for Out Patients Report +
      + {{else}} + {{#edit-panel editPanelProps=editPanelProps}} + {{#em-form model=model submitButton=false }} + {{#if model.visit}} + {{patient-summary + patient=model.visit.patient + returnTo='visit.edit' + returnToContext=model.id + disablePatientLink=model.isNew + }} + {{/if}} + {{#if model.visit.patient.displayPatientId}} +
      + + +
      + {{/if}} + {{#if model.visit.patient.dateOfBirth}} +
      + + +
      + {{/if}} + + {{#if diagnosis.primary.length}} +
      + +
        + {{#each diagnosis.primary as |item|}} +
      • {{item.diagnosis}}
      • + {{/each}} +
      +
      + {{/if}} + + {{#if diagnosis.secondary.length}} +
      + +
        + {{#each diagnosis.secondary as |item|}} +
      • {{item.diagnosis}}
      • + {{/each}} +
      +
      + {{/if}} + + {{#if model.visit.procedures.length}} +
      + +
        + {{#each model.visit.procedures as |item|}} +
      • {{item.description}}
      • + {{/each}} +
      +
      + {{/if}} + + {{#if model.visit.labs.length}} +
      + +
        + {{#each model.visit.labs as |item|}} +
      • {{item.labType.name}}-{{item.result}} ({{item.status}})
      • + {{/each}} +
      +
      + {{/if}} + + {{#if model.visit.imaging.length}} +
      + +
        + {{#each model.visit.imaging as |item|}} +
      • {{item.imagingType.name}}-{{item.result}} ({{item.status}})
      • + {{/each}} +
      +
      + {{/if}} + + + {{#if nextAppointment}} +
      + + +
      + {{/if}} + + {{#if model.visit.patient.operativePlans.length}} +
      + +
        + {{#each model.visit.patient.operativePlans as |item|}} + {{#each item.procedures as |p|}} +
      • {{p.description}} ({{item.status}})
      • + {{/each}} {{/each}} - {{/each}} -
      -
      - {{/if}} +
    +
    + {{/if}} - {{custom-form-manager model=model formType="opdReport"}} + {{custom-form-manager model=model formType="opdReport"}} + + {{/em-form}} + {{/edit-panel}} + {{/if}} + + {{else}} + + {{#if showPreview}} +
    + Show Preview for Discharge report +
    + {{else}} +
    + Show Discharge Report Form +
    + {{/if}} - {{/em-form}} - {{/edit-panel}} {{/if}} + From 07b23c90c8f6b9c9317cbf03e639b9f835dfa9f3 Mon Sep 17 00:00:00 2001 From: Chima Date: Wed, 15 Feb 2017 16:05:31 +0100 Subject: [PATCH 19/99] fix: added some report translations --- app/locales/en/translations.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/locales/en/translations.js b/app/locales/en/translations.js index 3652a6b486..bf080a2988 100644 --- a/app/locales/en/translations.js +++ b/app/locales/en/translations.js @@ -1089,18 +1089,19 @@ export default { }, reports: { titles: { - edit: 'Edit Report', - saved: 'Report Saved', - new: 'New Report' + preview: 'Preview Report', + saved: 'The report has been saved' }, opd: { titles: { - new: 'New OPD Report' + new: 'New OPD Report', + edit: 'Edit OPD Report' } }, discharge: { titles: { - new: 'New Discharge Report' + new: 'New Discharge Report', + edit: 'Edit Discharge Report' } }, messages: { From 8ac82d84850ab013c9d72702c45f212467a0d598 Mon Sep 17 00:00:00 2001 From: Chima Date: Wed, 15 Feb 2017 16:06:05 +0100 Subject: [PATCH 20/99] fix: edited report model --- app/models/report.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/report.js b/app/models/report.js index 76a314aeb9..f6516dd802 100644 --- a/app/models/report.js +++ b/app/models/report.js @@ -5,8 +5,9 @@ export default AbstractModel.extend({ // Attributes reportDate: DS.attr('date'), customForms: DS.attr('custom-forms'), - reportType : DS.attr('string'), + reportType: DS.attr('string'), nextAppointment: DS.attr('date'), + diagnosis: DS.attr(), // Associations visit: DS.belongsTo('visit', { async: false }), From f6f2dac58393aa2d18e1319bd287b46b6a280b84 Mon Sep 17 00:00:00 2001 From: Chima Date: Wed, 15 Feb 2017 16:07:14 +0100 Subject: [PATCH 21/99] fix: implemented logic to toggle between show report and new report --- app/visits/edit/controller.js | 18 +++++++++++++--- app/visits/edit/route.js | 19 +++++++++++++++++ app/visits/edit/template.hbs | 40 ++++++++++++++++++++++++++++------- 3 files changed, 66 insertions(+), 11 deletions(-) diff --git a/app/visits/edit/controller.js b/app/visits/edit/controller.js index 57b917482f..159121e011 100644 --- a/app/visits/edit/controller.js +++ b/app/visits/edit/controller.js @@ -37,7 +37,7 @@ export default AbstractEditController.extend(AddNewPatient, ChargeActions, Diagn return [buttonProps]; } }), - + noReport: false, canAddAppointment: computed('model.isNew', function() { return (!this.get('model.isNew') && this.currentUserCan('add_appointment')); }), @@ -67,8 +67,8 @@ export default AbstractEditController.extend(AddNewPatient, ChargeActions, Diagn }.property(), canAddReport: function() { - return this.currentUserCan('add_report'); - }.property(), + return this.currentUserCan('add_report') && !this.get('hasReport'); + }.property('hasReport'), canDeleteImaging: function() { return this.currentUserCan('delete_imaging'); @@ -440,6 +440,18 @@ export default AbstractEditController.extend(AddNewPatient, ChargeActions, Diagn }); }, + 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')); + }); + }, + newAppointment() { this._addChildObject('appointments.edit'); }, diff --git a/app/visits/edit/route.js b/app/visits/edit/route.js index d49288ce9b..b1f2e4cf38 100644 --- a/app/visits/edit/route.js +++ b/app/visits/edit/route.js @@ -3,6 +3,7 @@ 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 DS from 'ember-data'; export default AbstractEditRoute.extend(ChargeRoute, PatientListRoute, { customForms: Ember.inject.service(), @@ -42,6 +43,24 @@ export default AbstractEditRoute.extend(ChargeRoute, PatientListRoute, { } }, + report: function() { + + }.property('model'), + + setupController(controller, model) { + let promise = this.store.query('report', { + options: { + key: model.get('id') + }, + mapReduce: 'report_by_visit' + }).then((reports) => { + controller.set('noReport', Ember.isEmpty(reports)); + return Ember.isEmpty(reports) ? '' : reports.get('firstObject'); + }); + controller.set('report', DS.PromiseObject.create({ promise })); + this._super(controller, model); + }, + actions: { updateNote() { this.controller.send('update', true); diff --git a/app/visits/edit/template.hbs b/app/visits/edit/template.hbs index 502c928195..072a75e088 100644 --- a/app/visits/edit/template.hbs +++ b/app/visits/edit/template.hbs @@ -264,20 +264,44 @@
    -
    - {{#if canAddReport}} + {{#if noReport}} + +
    + {{#if canAddReport}} - {{/if}} -
    -
    + {{/if}} +
    + + {{else}} + +
    + + + + + + + + + + + + + + +
    {{t 'labels.date'}}Created ByReport type{{t 'labels.actions'}}
    {{date-format report.reportDate}}{{report.modifiedBy}}{{report.reportType}} + +
    +
    + + {{/if}} -
    From ccb0b059fec884f19bb000ad35343eec91dbf310 Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Thu, 16 Feb 2017 12:31:21 +0100 Subject: [PATCH 22/99] Remove preview functionality from OPD Reports --- app/reports/edit/controller.js | 36 +++--- app/reports/edit/route.js | 6 - app/reports/edit/template.hbs | 229 +++++++++++++++------------------ 3 files changed, 120 insertions(+), 151 deletions(-) diff --git a/app/reports/edit/controller.js b/app/reports/edit/controller.js index 6b5859668d..965cf613f2 100644 --- a/app/reports/edit/controller.js +++ b/app/reports/edit/controller.js @@ -7,19 +7,11 @@ import DS from 'ember-data'; import moment from 'moment'; export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, PouchDbMixin, { - queryParams: ['preview'], - preview: null, - - showPreview: Ember.computed('preview', function() { - let preview = this.get('preview'); - return preview; - }), - lookupListsToUpdate: [], newReport: false, - diagnosis: Ember.computed('model.patient', function() { + diagnosis: Ember.computed('model.patient', function () { let container = this.get('model.patient'); let result = { primary: this.getDiagnoses(container, true, false), @@ -28,19 +20,19 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, return result; }), - nextAppointment: Ember.computed('model.patient.id', 'model.visit.startDate', function() { + nextAppointment: Ember.computed('model.patient.id', 'model.visit.startDate', function () { let patientId = this.get('model.patient.id'); let visitDate = this.get('model.visit.startDate'); let maxValue = this.get('maxValue'); - let promise = this.store.query('appointment', { + 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'); + }).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) { @@ -50,18 +42,18 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, let res = appointment.get('startDate'); return res; }); - return DS.PromiseObject.create({ promise }); + return DS.PromiseObject.create({promise}); }), - additionalButtons: Ember.computed('model.{isNew}', function() { + additionalButtons: Ember.computed('model.{isNew}', function () { // let i18n = get(this, 'i18n'); let isNew = this.get('model.isNew'); if (!isNew) { return [{ class: 'btn btn-primary on-white', - buttonAction: 'previewReport', + buttonAction: 'printReport', buttonIcon: 'octicon octicon-check', - buttonText: 'Preview and Print' + buttonText: 'Print' }]; } }), @@ -69,7 +61,7 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, updateCapability: 'add_report', beforeUpdate() { - return new Ember.RSVP.Promise(function(resolve) { + return new Ember.RSVP.Promise(function (resolve) { if (this.get('model.isNew')) { if (this.get('model.visit.outPatient')) { @@ -97,8 +89,10 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, }, actions: { - previewReport() { - this.transitionToRoute('reports.edit', this.get('model.id'), { queryParams: { preview: true } }); + printReport() { + } } + + }); diff --git a/app/reports/edit/route.js b/app/reports/edit/route.js index 38ebf49047..68a441e248 100644 --- a/app/reports/edit/route.js +++ b/app/reports/edit/route.js @@ -5,12 +5,6 @@ export default AbstractEditRoute.extend({ modelName: 'report', customForms: Ember.inject.service(), - queryParams: { - preview: { - refreshModel: true - } - }, - getNewData() { let newReportData = { reportDate: new Date(), diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index 68daab70ae..4b92531197 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -1,129 +1,110 @@ - {{#if model.visit.outPatient}} - {{#if showPreview}} -
    - Show Preview for Out Patients Report -
    - {{else}} - {{#edit-panel editPanelProps=editPanelProps}} - {{#em-form model=model submitButton=false }} - {{#if model.visit}} - {{patient-summary - patient=model.visit.patient - returnTo='visit.edit' - returnToContext=model.id - disablePatientLink=model.isNew - }} - {{/if}} - {{#if model.visit.patient.displayPatientId}} -
    - - -
    - {{/if}} - {{#if model.visit.patient.dateOfBirth}} -
    - - -
    - {{/if}} - - {{#if diagnosis.primary.length}} -
    - -
      - {{#each diagnosis.primary as |item|}} -
    • {{item.diagnosis}}
    • - {{/each}} -
    -
    - {{/if}} - - {{#if diagnosis.secondary.length}} -
    - -
      - {{#each diagnosis.secondary as |item|}} -
    • {{item.diagnosis}}
    • - {{/each}} -
    -
    - {{/if}} - - {{#if model.visit.procedures.length}} -
    - -
      - {{#each model.visit.procedures as |item|}} -
    • {{item.description}}
    • - {{/each}} -
    -
    - {{/if}} - - {{#if model.visit.labs.length}} -
    - -
      - {{#each model.visit.labs as |item|}} -
    • {{item.labType.name}}-{{item.result}} ({{item.status}})
    • - {{/each}} -
    -
    - {{/if}} - - {{#if model.visit.imaging.length}} -
    - -
      - {{#each model.visit.imaging as |item|}} -
    • {{item.imagingType.name}}-{{item.result}} ({{item.status}})
    • + {{#edit-panel editPanelProps=editPanelProps}} + {{#em-form model=model submitButton=false }} + {{#if model.visit}} + {{patient-summary + patient=model.visit.patient + returnTo='visit.edit' + returnToContext=model.id + disablePatientLink=model.isNew + }} + {{/if}} + {{#if model.visit.patient.displayPatientId}} +
      + + +
      + {{/if}} + {{#if model.visit.patient.dateOfBirth}} +
      + + +
      + {{/if}} + + {{#if diagnosis.primary.length}} +
      + +
        + {{#each diagnosis.primary as |item|}} +
      • {{item.diagnosis}}
      • + {{/each}} +
      +
      + {{/if}} + + {{#if diagnosis.secondary.length}} +
      + +
        + {{#each diagnosis.secondary as |item|}} +
      • {{item.diagnosis}}
      • + {{/each}} +
      +
      + {{/if}} + + {{#if model.visit.procedures.length}} +
      + +
        + {{#each model.visit.procedures as |item|}} +
      • {{item.description}}
      • + {{/each}} +
      +
      + {{/if}} + + {{#if model.visit.labs.length}} +
      + +
        + {{#each model.visit.labs as |item|}} +
      • {{item.labType.name}}-{{item.result}} ({{item.status}})
      • + {{/each}} +
      +
      + {{/if}} + + {{#if model.visit.imaging.length}} +
      + +
        + {{#each model.visit.imaging as |item|}} +
      • {{item.imagingType.name}}-{{item.result}} ({{item.status}})
      • + {{/each}} +
      +
      + {{/if}} + + + {{#if nextAppointment}} +
      + + +
      + {{/if}} + + {{#if model.visit.patient.operativePlans.length}} +
      + +
        + {{#each model.visit.patient.operativePlans as |item|}} + {{#each item.procedures as |p|}} +
      • {{p.description}} ({{item.status}})
      • {{/each}} -
      -
      - {{/if}} - - - {{#if nextAppointment}} -
      - - -
      - {{/if}} - - {{#if model.visit.patient.operativePlans.length}} -
      - -
        - {{#each model.visit.patient.operativePlans as |item|}} - {{#each item.procedures as |p|}} -
      • {{p.description}} ({{item.status}})
      • - {{/each}} - {{/each}} -
      -
      - {{/if}} - - {{custom-form-manager model=model formType="opdReport"}} - - {{/em-form}} - {{/edit-panel}} - {{/if}} - - {{else}} - - {{#if showPreview}} -
      - Show Preview for Discharge report -
      - {{else}} -
      - Show Discharge Report Form -
      - {{/if}} - -{{/if}} - + {{/each}} +
    +
    + {{/if}} + {{custom-form-manager model=model formType="opdReport"}} + {{/em-form}} + {{/edit-panel}} +{{else}} +
    + Show Discharge Report Form +
    +{{/if}} \ No newline at end of file From 0e497681af30feafe1533df913fdb4668b8082ec Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Thu, 16 Feb 2017 16:36:45 +0100 Subject: [PATCH 23/99] Implement print button --- app/reports/edit/controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/reports/edit/controller.js b/app/reports/edit/controller.js index 965cf613f2..88dab4de60 100644 --- a/app/reports/edit/controller.js +++ b/app/reports/edit/controller.js @@ -90,7 +90,7 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, actions: { printReport() { - + window.print(); } } From bac66a6cbe09c54ba0360b6cb9aa19563d91881f Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Thu, 16 Feb 2017 21:43:25 +0100 Subject: [PATCH 24/99] Remove print section header --- app/templates/section.hbs | 1 - 1 file changed, 1 deletion(-) diff --git a/app/templates/section.hbs b/app/templates/section.hbs index 7deaed121b..7c89d7f305 100644 --- a/app/templates/section.hbs +++ b/app/templates/section.hbs @@ -2,7 +2,6 @@

    {{currentScreenTitle}}

    -
    {{#if newButtonAction}} From 5b2efbb349f741c445ed6cdffa67e8b61e966553 Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Fri, 17 Feb 2017 00:18:03 +0100 Subject: [PATCH 25/99] Write styles and markup for print page --- app/reports/edit/template.hbs | 7 ++++-- app/styles/_print.scss | 45 +++++++++++++++++++++++++++++++++-- 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index 4b92531197..7d20230766 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -1,5 +1,7 @@ {{#if model.visit.outPatient}} - {{#edit-panel editPanelProps=editPanelProps}} +
    + {{partial "report-header"}} + {{#edit-panel editPanelProps=editPanelProps}} {{#em-form model=model submitButton=false }} {{#if model.visit}} {{patient-summary @@ -10,7 +12,7 @@ }} {{/if}} {{#if model.visit.patient.displayPatientId}} -
    + @@ -102,6 +104,7 @@ {{/em-form}} {{/edit-panel}} +
    {{else}}
    diff --git a/app/styles/_print.scss b/app/styles/_print.scss index 2816743972..22db9a3b0e 100644 --- a/app/styles/_print.scss +++ b/app/styles/_print.scss @@ -1,4 +1,4 @@ -.print-section { +.report-header { display: none; } @@ -17,9 +17,11 @@ width: 90%; } - .print-section { + .report-header { display: block; text-align: center; + padding: 10px 0; + border-bottom: 1px solid #d2dae3; } .panel-footer, @@ -32,4 +34,43 @@ .patient-history-heading { border-bottom: 1px solid $black; } + + .report-logo { + height: 80px; + } + + .opd-report { + font-size: 0.8em; + } + + .opd-report .patient-summary { + margin-bottom: 20px; + border-bottom: 1px solid #d2dae3; + } + + .opd-report input { + padding: 5px; + font-size: 0.8em; + border: none; + } + + .opd-report .panel-primary { + position: absolute; + left: 0; + margin: 0; + width: 100%; + } + + .print-hide { + display: none; + } + + .view-top-bar { + display: none; + } + + .view-sub-bar { + display: none; + } + } From 6d6e851bbcb642dcc60dbee6150238372a91d864 Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Fri, 17 Feb 2017 00:18:49 +0100 Subject: [PATCH 26/99] Refactor report header into partial --- app/templates/report-header.hbs | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 app/templates/report-header.hbs diff --git a/app/templates/report-header.hbs b/app/templates/report-header.hbs new file mode 100644 index 0000000000..36b184ffea --- /dev/null +++ b/app/templates/report-header.hbs @@ -0,0 +1,5 @@ +
    + +

    Hospital Name

    + Hospital Address, No 23, 4th Avenue, Gwarimpa Abuja. +
    \ No newline at end of file From 1f85452012b33ddd94ace2f39fc8279699eef5ee Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Fri, 17 Feb 2017 00:52:44 +0100 Subject: [PATCH 27/99] Rename report types --- app/reports/edit/controller.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/reports/edit/controller.js b/app/reports/edit/controller.js index 965cf613f2..9a5cd3ed7f 100644 --- a/app/reports/edit/controller.js +++ b/app/reports/edit/controller.js @@ -65,13 +65,13 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, if (this.get('model.isNew')) { if (this.get('model.visit.outPatient')) { - this.get('model').set('reportType', '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'); + this.get('model').set('reportType', 'Discharge Report'); } } resolve(); From a9a3159cdf55202ce2bbf9c2ebab72fdc6596284 Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Fri, 17 Feb 2017 01:17:45 +0100 Subject: [PATCH 28/99] fix style lint errors --- app/styles/_print.scss | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/styles/_print.scss b/app/styles/_print.scss index 22db9a3b0e..b287f87dde 100644 --- a/app/styles/_print.scss +++ b/app/styles/_print.scss @@ -19,9 +19,9 @@ .report-header { display: block; - text-align: center; - padding: 10px 0; border-bottom: 1px solid #d2dae3; + padding: 10px 0; + text-align: center; } .panel-footer, @@ -40,7 +40,7 @@ } .opd-report { - font-size: 0.8em; + font-size: .8em; } .opd-report .patient-summary { @@ -49,9 +49,9 @@ } .opd-report input { + border: 0; padding: 5px; - font-size: 0.8em; - border: none; + font-size: .8em; } .opd-report .panel-primary { @@ -72,5 +72,4 @@ .view-sub-bar { display: none; } - } From 64583f201c035f775f558ab0cb3f257a468fc40d Mon Sep 17 00:00:00 2001 From: Chima Date: Fri, 17 Feb 2017 13:09:09 +0100 Subject: [PATCH 29/99] fix: completed internationalization and lint fix --- app/locales/en/translations.js | 14 +++++++++++++- app/reports/edit/controller.js | 15 +++++++-------- app/reports/edit/template.hbs | 24 +++++++++++------------- app/visits/edit/template.hbs | 4 ++-- 4 files changed, 33 insertions(+), 24 deletions(-) diff --git a/app/locales/en/translations.js b/app/locales/en/translations.js index dceb09a0a8..48459fd5c3 100644 --- a/app/locales/en/translations.js +++ b/app/locales/en/translations.js @@ -861,7 +861,8 @@ export default { statusDischarged: 'Discharged', statusCheckedIn: 'Checked In', statusCheckedOut: 'Checked Out', - createNewPatient: 'Create New Patient' + createNewPatient: 'Create New Patient', + reportType: 'Report type' }, navigation: { charges: 'Charges', @@ -1106,6 +1107,17 @@ export default { preview: 'Preview Report', saved: 'The report has been saved' }, + form: { + patientId: 'Patient Id', + visitDate: 'Date of Visit', + primaryDiagnosis: 'Primary Diagnosis', + secondaryDiagnosis: 'Secondary Diagnosis', + procedures: 'Procedures', + labs: 'Labs', + images: 'Images', + nextAppointmentDate: 'Date Of Next Appointment', + operativePlan: 'Operative Plans' + }, opd: { titles: { new: 'New OPD Report', diff --git a/app/reports/edit/controller.js b/app/reports/edit/controller.js index 9a0fa4ec62..f58adb726e 100644 --- a/app/reports/edit/controller.js +++ b/app/reports/edit/controller.js @@ -11,7 +11,7 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, newReport: false, - diagnosis: Ember.computed('model.patient', function () { + diagnosis: Ember.computed('model.patient', function() { let container = this.get('model.patient'); let result = { primary: this.getDiagnoses(container, true, false), @@ -20,7 +20,7 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, return result; }), - nextAppointment: Ember.computed('model.patient.id', 'model.visit.startDate', function () { + nextAppointment: Ember.computed('model.patient.id', 'model.visit.startDate', function() { let patientId = this.get('model.patient.id'); let visitDate = this.get('model.visit.startDate'); let maxValue = this.get('maxValue'); @@ -30,8 +30,8 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, endkey: [patientId, maxValue, maxValue, maxValue] }, mapReduce: 'appointments_by_patient' - }).then(function (result) { - let futureAppointments = result.filter(function (data) { + }).then(function(result) { + let futureAppointments = result.filter(function(data) { let startDate = data.get('startDate'); return startDate && moment(startDate).isAfter(moment(visitDate), 'day'); }).sortBy('startDate'); @@ -42,10 +42,10 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, let res = appointment.get('startDate'); return res; }); - return DS.PromiseObject.create({promise}); + return DS.PromiseObject.create({ promise }); }), - additionalButtons: Ember.computed('model.{isNew}', function () { + additionalButtons: Ember.computed('model.{isNew}', function() { // let i18n = get(this, 'i18n'); let isNew = this.get('model.isNew'); if (!isNew) { @@ -61,7 +61,7 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, updateCapability: 'add_report', beforeUpdate() { - return new Ember.RSVP.Promise(function (resolve) { + return new Ember.RSVP.Promise(function(resolve) { if (this.get('model.isNew')) { if (this.get('model.visit.outPatient')) { @@ -94,5 +94,4 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, } } - }); diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index 7d20230766..eed9faf8f1 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -13,20 +13,20 @@ {{/if}} {{#if model.visit.patient.displayPatientId}} {{/if}} - {{#if model.visit.patient.dateOfBirth}} + {{#if model.visit.startDate}}
    - +
    {{/if}} {{#if diagnosis.primary.length}}
    - +
      {{#each diagnosis.primary as |item|}}
    • {{item.diagnosis}}
    • @@ -37,7 +37,7 @@ {{#if diagnosis.secondary.length}}
      - +
        {{#each diagnosis.secondary as |item|}}
      • {{item.diagnosis}}
      • @@ -48,7 +48,7 @@ {{#if model.visit.procedures.length}}
        - +
          {{#each model.visit.procedures as |item|}}
        • {{item.description}}
        • @@ -59,7 +59,7 @@ {{#if model.visit.labs.length}}
          - +
            {{#each model.visit.labs as |item|}}
          • {{item.labType.name}}-{{item.result}} ({{item.status}})
          • @@ -70,7 +70,7 @@ {{#if model.visit.imaging.length}}
            - +
              {{#each model.visit.imaging as |item|}}
            • {{item.imagingType.name}}-{{item.result}} ({{item.status}})
            • @@ -82,14 +82,14 @@ {{#if nextAppointment}}
              - +
              {{/if}} {{#if model.visit.patient.operativePlans.length}}
              - +
                {{#each model.visit.patient.operativePlans as |item|}} {{#each item.procedures as |p|}} @@ -107,7 +107,5 @@
              {{else}} -
              - Show Discharge Report Form -
              + {{/if}} \ No newline at end of file diff --git a/app/visits/edit/template.hbs b/app/visits/edit/template.hbs index 072a75e088..3d4a7b25af 100644 --- a/app/visits/edit/template.hbs +++ b/app/visits/edit/template.hbs @@ -284,8 +284,8 @@ - - + + From a7ad7f4e4632741bd2a0e5a32192e54f2f6d5243 Mon Sep 17 00:00:00 2001 From: Mofesola Babalola Date: Fri, 17 Feb 2017 14:11:43 +0100 Subject: [PATCH 30/99] 0.9.18 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5264ab99bd..00c1d117e3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hospitalrun", - "version": "0.9.17", + "version": "0.9.18", "description": "Ember front end for HospitalRun", "homepage": "http://hospitalrun.io", "directories": { From 177f5b4f7e1ba9ce7f7f46ba7c6020f1e956e508 Mon Sep 17 00:00:00 2001 From: Mofesola Babalola Date: Fri, 17 Feb 2017 14:13:18 +0100 Subject: [PATCH 31/99] Incremented version number, added scope --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 00c1d117e3..5fab3b7f51 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "hospitalrun", - "version": "0.9.18", + "name": "@ehealth-ci/hospitalrun", + "version": "0.9.19", "description": "Ember front end for HospitalRun", "homepage": "http://hospitalrun.io", "directories": { From b6b70f1e3f6737b39932b2bbf98228157fef7a97 Mon Sep 17 00:00:00 2001 From: Chima Date: Fri, 17 Feb 2017 16:54:13 +0100 Subject: [PATCH 32/99] fix: remove patientId field, fixed next appointment bug, removed unused translation --- app/locales/en/translations.js | 3 +-- app/reports/edit/controller.js | 6 +++--- app/reports/edit/template.hbs | 11 +++-------- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/app/locales/en/translations.js b/app/locales/en/translations.js index 48459fd5c3..feab068832 100644 --- a/app/locales/en/translations.js +++ b/app/locales/en/translations.js @@ -1108,7 +1108,6 @@ export default { saved: 'The report has been saved' }, form: { - patientId: 'Patient Id', visitDate: 'Date of Visit', primaryDiagnosis: 'Primary Diagnosis', secondaryDiagnosis: 'Secondary Diagnosis', @@ -1116,7 +1115,7 @@ export default { labs: 'Labs', images: 'Images', nextAppointmentDate: 'Date Of Next Appointment', - operativePlan: 'Operative Plans' + operativePlan: 'Planned Procedures' }, opd: { titles: { diff --git a/app/reports/edit/controller.js b/app/reports/edit/controller.js index f58adb726e..0f300dee03 100644 --- a/app/reports/edit/controller.js +++ b/app/reports/edit/controller.js @@ -20,8 +20,8 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, return result; }), - nextAppointment: Ember.computed('model.patient.id', 'model.visit.startDate', function() { - let patientId = this.get('model.patient.id'); + 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', { @@ -38,7 +38,7 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, if (!futureAppointments.length) { return ''; } - let [appointment] = [futureAppointments]; + let [appointment] = futureAppointments; let res = appointment.get('startDate'); return res; }); diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index eed9faf8f1..336d0fa89f 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -11,16 +11,11 @@ disablePatientLink=model.isNew }} {{/if}} - {{#if model.visit.patient.displayPatientId}} - - {{/if}} + {{#if model.visit.startDate}}
              - +
              {{/if}} @@ -83,7 +78,7 @@ {{#if nextAppointment}}
              - +
              {{/if}} From 2d8c5c930a7864c538602954b65110eca3d96de0 Mon Sep 17 00:00:00 2001 From: Chima Date: Tue, 21 Feb 2017 10:24:11 +0100 Subject: [PATCH 33/99] fix: change date fields to simple text --- app/reports/edit/template.hbs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index 336d0fa89f..20a3761064 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -14,8 +14,8 @@ {{#if model.visit.startDate}}
              - - +

              {{t 'reports.form.visitDate' }}

              + {{date-format model.visit.startDate format="DD/MM/YYYY hh:mm a"}}
              {{/if}} @@ -77,8 +77,8 @@ {{#if nextAppointment}}
              - - +

              {{t 'reports.form.nextAppointmentDate' }}

              + {{date-format nextAppointment format="DD/MM/YYYY hh:mm a"}}
              {{/if}} From bf79a5c24b0a96adda29db3c6926f21df236e575 Mon Sep 17 00:00:00 2001 From: Chima Date: Tue, 21 Feb 2017 14:48:20 +0100 Subject: [PATCH 34/99] 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 9334afb3cd2cd7e53b813dfce1ba1e14359627af Mon Sep 17 00:00:00 2001 From: Mofesola Babalola Date: Tue, 21 Feb 2017 20:05:08 +0100 Subject: [PATCH 35/99] Added .travis.yml file for building and deploying to npm --- .travis.yml | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0c2e18bea3..ff2d5a030e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,29 +1,31 @@ ---- language: node_js node_js: - - "4" - +- '4' branches: only: - - "master" - + - master sudo: false - -cache: - directories - - $HOME/.npm - - $HOME/.cache # includes bowers cache - +cache: directories - $HOME/.npm - $HOME/.cache before_install: - - npm config set spin false - - npm install -g bower - - bower --version - - npm install phantomjs-prebuilt - - node_modules/phantomjs-prebuilt/bin/phantomjs --version - +- npm config set spin false +- npm install -g bower +- npm install -g ember +- npm install -g npm-cli-login +- bower --version +- npm install phantomjs-prebuilt +- node_modules/phantomjs-prebuilt/bin/phantomjs --version install: - - npm install - - bower install - +- npm install +- bower install script: - - npm test +- npm test +- ember test +deploy: + provider: npm + email: mofesola.babalola@ehealthafrica.org + api_key: + secure: G13Wfjt+5lzPmc/4M4669Q+htK389oglI/JDTYDDH1v0ZaWOtvAc2Zvu2BvMGy9IMJ5f66ICJLxcWIg0gP2SMxvkQgUYaGFkVCRbaAwxfhcbSLJ2H/AGaanV1qRFeLQQRmNXg/yK0tW+biOsLXKvDXqazaueh/hP64uJmzAr3L1Y26q6QjL2iMEczEUi9Z02Gl5u5rCWsdM8c0oZ872FR8QWkSR4fb6vaKIyItfcUCN0nbJ4RhIncCCJLja7NHbeaxGh9rXVaO6F6oTiuuuJj863ATSBO670dmWGbscZQWxIRJPko3IAn6dQD4Q9FaJZR1pyS2+pkGSuGbjdYjMfj0vh73Hf6wmCwve/i9cA8du0qDEKqMetdsMIAS4XKoR2jQyWCivGOhOHizjoH7xezyj9K469IEugTFoyENoASW3ADYL3YGFpKn0Xs2i0MuSS8MGmSLw6QfEDzLvmxJeGnNQFXKtXyOOJlmyoTcIcviMr26jOmWINBWzNFp6B1wqcWpPy2TJyoQFL8Fnd4uadc5i4mxv9hPKLbbpV72+EuWiPqNX+rvgMxuFfMogIVB6R7GIMrk+MVmLlr9O4jYcsNcEW5Pw5rcxw/OCSw/mReMNFyRWhscpgpWcYwOzQHXMFKusSzITJLNjtwL40JH4i90U2jDwEZTUXT8E/IJVuYmY= + on: + tags: true + repo: eHealthAfrica/hospitalrun-frontend + branch: master From da5668f91eeabdf6002fc2eb8b2686077bc65d61 Mon Sep 17 00:00:00 2001 From: Mofesola Babalola Date: Tue, 21 Feb 2017 20:23:32 +0100 Subject: [PATCH 36/99] Removed ember test. Pretty much does the same as npm test --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index ff2d5a030e..af345a0980 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,6 @@ before_install: - npm config set spin false - npm install -g bower - npm install -g ember -- npm install -g npm-cli-login - bower --version - npm install phantomjs-prebuilt - node_modules/phantomjs-prebuilt/bin/phantomjs --version @@ -19,7 +18,6 @@ install: - bower install script: - npm test -- ember test deploy: provider: npm email: mofesola.babalola@ehealthafrica.org From fdfa21e677951a3561737a317487e4b6e4216884 Mon Sep 17 00:00:00 2001 From: Mofesola Babalola Date: Tue, 21 Feb 2017 20:35:50 +0100 Subject: [PATCH 37/99] Allowing all branches to be tested and built --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index af345a0980..c1ae4b11d5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,6 @@ language: node_js node_js: - '4' -branches: - only: - - master sudo: false cache: directories - $HOME/.npm - $HOME/.cache before_install: From 0b0b7614d8b19b7a3bd7ee2850ba0d4258cd654d Mon Sep 17 00:00:00 2001 From: Chima Date: Wed, 22 Feb 2017 10:31:00 +0100 Subject: [PATCH 38/99] 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 39/99] 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 40/99] 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 41/99] 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 42/99] 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 43/99] 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 44/99] 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 29795ace8b801c09268bb8823af3a6810ce95fb3 Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Wed, 22 Feb 2017 23:22:04 +0100 Subject: [PATCH 45/99] Add Hospital Info report header as option config --- app/reports/edit/controller.js | 8 ++++++++ app/reports/edit/template.hbs | 18 +++++++++++++++++- app/styles/_print.scss | 2 +- app/templates/report-header.hbs | 5 ----- app/visits/route.js | 3 +++ 5 files changed, 29 insertions(+), 7 deletions(-) delete mode 100644 app/templates/report-header.hbs diff --git a/app/reports/edit/controller.js b/app/reports/edit/controller.js index 0f300dee03..fa20effc92 100644 --- a/app/reports/edit/controller.js +++ b/app/reports/edit/controller.js @@ -11,6 +11,14 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, newReport: false, + visitController: Ember.inject.controller('visits'), + + logoURL: Ember.computed.alias('visitController.printHeader.value.logoURL'), + facilityName: Ember.computed.alias('visitController.printHeader.value.facilityName'), + headerLine1: Ember.computed.alias('visitController.printHeader.value.headerLine1'), + headerLine2: Ember.computed.alias('visitController.printHeader.value.headerLine2'), + headerLine3: Ember.computed.alias('visitController.printHeader.value.headerLine3'), + diagnosis: Ember.computed('model.patient', function() { let container = this.get('model.patient'); let result = { diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index 20a3761064..c876383eac 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -1,6 +1,22 @@ +
              + {{#if logoURL}} + + {{/if}} + {{#if facilityName }} +

              {{facilityName}}

              + {{/if}} + {{#if headerLine1}} + {{headerLine1}}
              + {{/if}} + {{#if headerLine2}} + {{headerLine2}}
              + {{/if}} + {{#if headerLine3}} + {{headerLine3}}
              + {{/if}} +
              {{#if model.visit.outPatient}}
              - {{partial "report-header"}} {{#edit-panel editPanelProps=editPanelProps}} {{#em-form model=model submitButton=false }} {{#if model.visit}} diff --git a/app/styles/_print.scss b/app/styles/_print.scss index b287f87dde..79591157fc 100644 --- a/app/styles/_print.scss +++ b/app/styles/_print.scss @@ -36,7 +36,7 @@ } .report-logo { - height: 80px; + height: 60px; } .opd-report { diff --git a/app/templates/report-header.hbs b/app/templates/report-header.hbs deleted file mode 100644 index 36b184ffea..0000000000 --- a/app/templates/report-header.hbs +++ /dev/null @@ -1,5 +0,0 @@ -
              - -

              Hospital Name

              - Hospital Address, No 23, 4th Avenue, Gwarimpa Abuja. -
              \ No newline at end of file diff --git a/app/visits/route.js b/app/visits/route.js index d397fb2d74..3c66313539 100644 --- a/app/visits/route.js +++ b/app/visits/route.js @@ -37,6 +37,9 @@ export default AbstractModuleRoute.extend({ }, { name: 'wardPricingTypes', findArgs: ['lookup', 'ward_pricing_types'] + }, { + name: 'printHeader', + findArgs: ['option', 'print_header'] }], moduleName: 'visits', newButtonAction: null, // No new button From 20775326c554bad30845a0c9a77b66a9ed2ff17d Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Thu, 23 Feb 2017 01:58:35 +0100 Subject: [PATCH 46/99] Add report model to patient-diagnosis and visit unit tests --- tests/unit/mixins/patient-diagnosis-test.js | 1 + tests/unit/models/visit-test.js | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/unit/mixins/patient-diagnosis-test.js b/tests/unit/mixins/patient-diagnosis-test.js index 8001771292..11fdf1714e 100644 --- a/tests/unit/mixins/patient-diagnosis-test.js +++ b/tests/unit/mixins/patient-diagnosis-test.js @@ -22,6 +22,7 @@ moduleFor('mixin:patient-diagnosis', 'Unit | Mixin | patient-diagnosis', { 'model:patient-note', 'model:procedure', 'model:diagnosis', + 'model:report', 'ember-validations@validator:local/acceptance', 'ember-validations@validator:local/presence' ], diff --git a/tests/unit/models/visit-test.js b/tests/unit/models/visit-test.js index 601379d135..50db6d0be0 100644 --- a/tests/unit/models/visit-test.js +++ b/tests/unit/models/visit-test.js @@ -16,6 +16,7 @@ moduleForModel('visit', 'Unit | Model | visit', { 'model:proc-charge', 'model:vital', 'model:visit', + 'model:report', 'service:validations' ] }); From d35a8a9b312c848acf8757c337d23bb6ee55e72e Mon Sep 17 00:00:00 2001 From: Chima Date: Thu, 23 Feb 2017 10:32:49 +0100 Subject: [PATCH 47/99] 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 48/99] 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 49/99] 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}} From 4662424f6fe7bade2932ef6769dc694e523e07de Mon Sep 17 00:00:00 2001 From: Chima Date: Thu, 23 Feb 2017 13:19:13 +0100 Subject: [PATCH 50/99] fix: added hospital info doc to environment --- config/environment.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/config/environment.js b/config/environment.js index ae20b6bbcc..ede0572321 100644 --- a/config/environment.js +++ b/config/environment.js @@ -70,5 +70,18 @@ module.exports = function(environment) { schedulerLicenseKey: 'GPL-My-Project-Is-Open-Source' }; + ENV.hospitalInfoDoc = { + "_id": "option_2_print_header", + "_rev": "1-4457555eacb405267c6d3b7a53d8521d", + "data": { + "value": { + "facilityName": "Beit CURE International Hospital", + "headerLine1": "PO Box 31236", + "headerLine2": "Blantyre 3", + "headerLine3": "+265 (0) 1 871 900 / +265 (0) 1 875 015 /+265 (0) 1 873 694 / +265 (0) 999 505 212", + "logoURL": "https://curehospital.mw/wp-content/uploads/4/2012/11/CURE-Malawi-Logo_rgb_280_89.jpg" + } + } + } return ENV; }; From d98df0d0599aa9d0d8ce289090818810abe4c516 Mon Sep 17 00:00:00 2001 From: Chima Date: Thu, 23 Feb 2017 13:20:07 +0100 Subject: [PATCH 51/99] fix: create sample docs on couchdb --- app/services/database.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/app/services/database.js b/app/services/database.js index e04e25c424..71b0f22ff7 100644 --- a/app/services/database.js +++ b/app/services/database.js @@ -3,6 +3,7 @@ import createPouchViews from 'hospitalrun/utils/pouch-views'; import List from 'npm:pouchdb-list'; import PouchAdapterMemory from 'npm:pouchdb-adapter-memory'; import UnauthorizedError from 'hospitalrun/utils/unauthorized-error'; +import enviroment from './../config/environment'; const { isEmpty @@ -20,9 +21,42 @@ export default Ember.Service.extend({ .then((db) => { this.set('mainDB', db); this.set('setMainDB', true); + }) + .then(() => { + this.createSampleDocs([enviroment.hospitalInfoDoc]); }); }, + createSampleDocs(docs) { + return new Ember.RSVP.Promise((resolve, reject) => { + let mainDB = this.get('mainDB'); + let ids = docs.map((doc) => { + return doc._id; + }); + return mainDB.allDocs({ keys: ids }) + .then((res) => { + if (res.rows) { + let docsToCreate = res.rows.filter((row) => { + return row.error && row.error === 'not_found'; + }).map((row) => { + return docs.find((doc) => { + return doc._id === row.key; + }); + }); + if (docsToCreate.length) { + return mainDB.bulkDocs(docsToCreate); + } + } + }) + .then((res) => { + resolve(res); + }) + .catch((err) => { + reject(err); + }); + }); + }, + createDB(configs) { return new Ember.RSVP.Promise((resolve, reject) => { let pouchOptions = {}; From ed34c53507fbf4dc8deb1f21d9299841dfe5cc31 Mon Sep 17 00:00:00 2001 From: John Kleinschmidt Date: Wed, 22 Feb 2017 12:05:53 -0500 Subject: [PATCH 52/99] Change how "new" routes work Makes sure that if user redirects to url the patient is properly selected. --- app/appointments/edit/route.js | 16 +++++++++---- app/imaging/edit/route.js | 3 ++- app/labs/edit/route.js | 5 ++-- app/medication/edit/route.js | 13 ++++++++-- app/mixins/add-to-patient-route.js | 36 ++++++++++++++++++++++++++++ app/patients/edit/controller.js | 14 +++++------ app/patients/operative-plan/route.js | 3 ++- tests/acceptance/operative-test.js | 2 +- 8 files changed, 74 insertions(+), 18 deletions(-) create mode 100644 app/mixins/add-to-patient-route.js diff --git a/app/appointments/edit/route.js b/app/appointments/edit/route.js index d9f6433b6c..bd5c5c7055 100644 --- a/app/appointments/edit/route.js +++ b/app/appointments/edit/route.js @@ -1,4 +1,5 @@ import AbstractEditRoute from 'hospitalrun/routes/abstract-edit-route'; +import AddToPatientRoute from 'hospitalrun/mixins/add-to-patient-route'; import Ember from 'ember'; import moment from 'moment'; import PatientListRoute from 'hospitalrun/mixins/patient-list-route'; @@ -6,12 +7,13 @@ import { translationMacro as t } from 'ember-i18n'; const { get, + isEmpty, RSVP: { resolve } } = Ember; -export default AbstractEditRoute.extend(PatientListRoute, { +export default AbstractEditRoute.extend(AddToPatientRoute, PatientListRoute, { editTitle: t('appointments.editTitle'), modelName: 'appointment', newButtonText: t('appointments.buttons.newButton'), @@ -26,7 +28,7 @@ export default AbstractEditRoute.extend(PatientListRoute, { selectPatient: true, startDate: new Date() }; - if (!Ember.isEmpty(idParam) && params[idParam] === 'newsurgery') { + if (!isEmpty(idParam) && params[idParam] === 'newsurgery') { newData.appointmentType = 'Surgery'; newData.allDay = false; newData.endDate = moment().add('1', 'hours').toDate(); @@ -53,10 +55,16 @@ export default AbstractEditRoute.extend(PatientListRoute, { model(params) { let idParam = this.get('idParam'); let modelId = params[idParam]; - if (!Ember.isEmpty(idParam) && (modelId.indexOf('new') === 0)) { - return this._createNewRecord(params); + if (!isEmpty(idParam) && (modelId.indexOf('new') === 0)) { + if (!isEmpty(params.forPatientId)) { + let modelPromise = this._super(params); + return this._setPatientOnModel(modelPromise, params.forPatientId); + } else { + return this._createNewRecord(params); + } } else { return this._super(params); } } + }); diff --git a/app/imaging/edit/route.js b/app/imaging/edit/route.js index e84f3a243b..4d5bab420d 100644 --- a/app/imaging/edit/route.js +++ b/app/imaging/edit/route.js @@ -1,10 +1,11 @@ import { translationMacro as t } from 'ember-i18n'; import AbstractEditRoute from 'hospitalrun/routes/abstract-edit-route'; +import AddToPatientRoute from 'hospitalrun/mixins/add-to-patient-route'; import ChargeRoute from 'hospitalrun/mixins/charge-route'; import Ember from 'ember'; import moment from 'moment'; import PatientListRoute from 'hospitalrun/mixins/patient-list-route'; -export default AbstractEditRoute.extend(ChargeRoute, PatientListRoute, { +export default AbstractEditRoute.extend(AddToPatientRoute, ChargeRoute, PatientListRoute, { editTitle: t('imaging.titles.editTitle'), modelName: 'imaging', newTitle: t('imaging.titles.editTitle'), diff --git a/app/labs/edit/route.js b/app/labs/edit/route.js index 9b654c7e37..0338bbc9ab 100644 --- a/app/labs/edit/route.js +++ b/app/labs/edit/route.js @@ -1,11 +1,12 @@ -import Ember from 'ember'; import AbstractEditRoute from 'hospitalrun/routes/abstract-edit-route'; +import AddToPatientRoute from 'hospitalrun/mixins/add-to-patient-route'; import ChargeRoute from 'hospitalrun/mixins/charge-route'; +import Ember from 'ember'; import moment from 'moment'; import PatientListRoute from 'hospitalrun/mixins/patient-list-route'; import { translationMacro as t } from 'ember-i18n'; -export default AbstractEditRoute.extend(ChargeRoute, PatientListRoute, { +export default AbstractEditRoute.extend(AddToPatientRoute, ChargeRoute, PatientListRoute, { editTitle: t('labs.editTitle'), modelName: 'lab', newTitle: t('labs.newTitle'), diff --git a/app/medication/edit/route.js b/app/medication/edit/route.js index 2f8c7f131a..7cdbed5d87 100644 --- a/app/medication/edit/route.js +++ b/app/medication/edit/route.js @@ -1,12 +1,16 @@ import { translationMacro as t } from 'ember-i18n'; import AbstractEditRoute from 'hospitalrun/routes/abstract-edit-route'; +import AddToPatientRoute from 'hospitalrun/mixins/add-to-patient-route'; import Ember from 'ember'; import FulfillRequest from 'hospitalrun/mixins/fulfill-request'; import InventoryLocations from 'hospitalrun/mixins/inventory-locations'; // inventory-locations mixin is needed for fulfill-request mixin! import moment from 'moment'; import PatientListRoute from 'hospitalrun/mixins/patient-list-route'; import uuid from 'npm:uuid'; -export default AbstractEditRoute.extend(FulfillRequest, InventoryLocations, PatientListRoute, { + +const { isEmpty } = Ember; + +export default AbstractEditRoute.extend(AddToPatientRoute, FulfillRequest, InventoryLocations, PatientListRoute, { editTitle: t('medication.titles.editMedicationRequest'), modelName: 'medication', newTitle: t('medication.titles.newMedicationRequest'), @@ -27,8 +31,13 @@ export default AbstractEditRoute.extend(FulfillRequest, InventoryLocations, Pati model(params) { let idParam = this.get('idParam'); + let modelPromise = this._super(params); if (!Ember.isEmpty(idParam) && params[idParam] === 'new' || params[idParam] === 'dispense') { - return this._createNewRecord(params); + if (!isEmpty(params.forPatientId)) { + return this._setPatientOnModel(modelPromise, params.forPatientId); + } else { + return this._createNewRecord(params); + } } else { return this._super(params); } diff --git a/app/mixins/add-to-patient-route.js b/app/mixins/add-to-patient-route.js new file mode 100644 index 0000000000..c1f79dfe39 --- /dev/null +++ b/app/mixins/add-to-patient-route.js @@ -0,0 +1,36 @@ +import Ember from 'ember'; + +const { get, isEmpty, Mixin } = Ember; + +export default Mixin.create({ + queryParams: { + forPatientId: { + refreshModel: false + } + }, + + model(params) { + let idParam = get(this, 'idParam'); + let modelPromise = this._super(params); + if (!isEmpty(params.forPatientId) && params[idParam] === 'new') { + return this._setPatientOnModel(modelPromise, params.forPatientId); + } else { + return modelPromise; + } + }, + + /** + * Resolves the model promise and then sets the patient information on the model. + */ + _setPatientOnModel(modelPromise, patientId) { + let store = get(this, 'store'); + return modelPromise.then((model) => { + return store.find('patient', patientId).then((patient) => { + model.set('patient', patient); + model.set('returnToPatient', patientId); + model.set('selectPatient', false); + return model; + }); + }); + } +}); diff --git a/app/patients/edit/controller.js b/app/patients/edit/controller.js index 0e7eacddc9..45e854b78b 100644 --- a/app/patients/edit/controller.js +++ b/app/patients/edit/controller.js @@ -540,16 +540,16 @@ export default AbstractEditController.extend(BloodTypes, DiagnosisActions, Retur }, _addChildObject(route, afterTransition) { - this.transitionToRoute(route, 'new').then(function(newRoute) { - newRoute.currentModel.setProperties({ - patient: this.get('model'), - returnToPatient: this.get('model.id'), - selectPatient: false - }); + let options = { + queryParams: { + forPatientId: this.get('model.id') + } + }; + this.transitionToRoute(route, 'new', options).then((newRoute) => { if (afterTransition) { afterTransition(newRoute); } - }.bind(this)); + }); }, _showEditSocial(editAttributes, modelName, route) { diff --git a/app/patients/operative-plan/route.js b/app/patients/operative-plan/route.js index 96c292d465..f3f0fde73b 100644 --- a/app/patients/operative-plan/route.js +++ b/app/patients/operative-plan/route.js @@ -1,4 +1,5 @@ import AbstractEditRoute from 'hospitalrun/routes/abstract-edit-route'; +import AddToPatientRoute from 'hospitalrun/mixins/add-to-patient-route'; import Ember from 'ember'; import moment from 'moment'; import { translationMacro as t } from 'ember-i18n'; @@ -8,7 +9,7 @@ const { inject } = Ember; -export default AbstractEditRoute.extend({ +export default AbstractEditRoute.extend(AddToPatientRoute, { editTitle: t('operativePlan.titles.editTitle'), modelName: 'operative-plan', newTitle: t('operativePlan.titles.newTitle'), diff --git a/tests/acceptance/operative-test.js b/tests/acceptance/operative-test.js index 8c424bc39d..054665fd44 100644 --- a/tests/acceptance/operative-test.js +++ b/tests/acceptance/operative-test.js @@ -56,7 +56,7 @@ test('Plan and report creation', function(assert) { waitToAppear('span.secondary-diagnosis:contains(Tennis Elbow)'); }); andThen(() =>{ - assert.equal(currentURL(), '/patients/operative-plan/new', 'New operative plan URL is correct'); + assert.equal(currentURL(), '/patients/operative-plan/new?forPatientId=C87BFCB2-F772-7A7B-8FC7-AD00C018C32A', 'New operative plan URL is correct'); assert.equal(find('.patient-name .ps-info-data').text(), 'Joe Bagadonuts', 'Joe Bagadonuts patient header displays'); assert.equal(find('.view-current-title').text(), 'New Operative Plan', 'New operative plan title is correct'); assert.equal(find('span.primary-diagnosis:contains(Broken Arm)').length, 1, 'Primary diagnosis appears as read only'); From 4a2070948d77737a188ca0886ebf0e6c8c9b112f Mon Sep 17 00:00:00 2001 From: Chima Date: Thu, 23 Feb 2017 15:29:13 +0100 Subject: [PATCH 53/99] fix: made sure sample docs are created when deleted --- app/services/database.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/services/database.js b/app/services/database.js index 71b0f22ff7..7297713aea 100644 --- a/app/services/database.js +++ b/app/services/database.js @@ -37,10 +37,15 @@ export default Ember.Service.extend({ .then((res) => { if (res.rows) { let docsToCreate = res.rows.filter((row) => { - return row.error && row.error === 'not_found'; + return (row.error && row.error === 'not_found') || (row.value && row.value.deleted); }).map((row) => { return docs.find((doc) => { - return doc._id === row.key; + if (doc._id === row.key) { + if (row.value && row.value.deleted && row.value.rev !== doc._rev) { + doc._rev = row.value.rev; + } + return true; + } }); }); if (docsToCreate.length) { From 59b3b30273b37b7b76490f6c7761823a86f10f71 Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Fri, 24 Feb 2017 11:23:31 +0100 Subject: [PATCH 54/99] Add query parameters to improve app navigation experience --- app/mixins/add-to-patient-route.js | 26 ++++++++++++++++++++-- app/reports/edit/route.js | 14 ++---------- app/visits/edit/controller.js | 35 ++++++++++++++++-------------- 3 files changed, 45 insertions(+), 30 deletions(-) diff --git a/app/mixins/add-to-patient-route.js b/app/mixins/add-to-patient-route.js index c1f79dfe39..f3979f70f5 100644 --- a/app/mixins/add-to-patient-route.js +++ b/app/mixins/add-to-patient-route.js @@ -6,14 +6,21 @@ export default Mixin.create({ queryParams: { forPatientId: { refreshModel: false + }, + forVisitId: { + refreshModel: false } }, model(params) { let idParam = get(this, 'idParam'); let modelPromise = this._super(params); - if (!isEmpty(params.forPatientId) && params[idParam] === 'new') { - return this._setPatientOnModel(modelPromise, params.forPatientId); + if (params[idParam] === 'new') { + if (!isEmpty(params.forPatientId)) { + return this._setPatientOnModel(modelPromise, params.forPatientId); + } else if (!isEmpty(params.forVisitId)) { + return this._setVisitOnModel(modelPromise, params.forVisitId); + } } else { return modelPromise; } @@ -32,5 +39,20 @@ export default Mixin.create({ return model; }); }); + }, + + /** + * Resolves the model promise and then sets the visit information on the model. + */ + _setVisitOnModel(modelPromise, visitId) { + let store = get(this, 'store'); + return modelPromise.then((model) => { + return store.find('visit', visitId).then((visit) => { + model.set('visit', visit); + model.set('returnToVisit', visitId); + model.set('selectPatient', false); + return model; + }); + }); } }); diff --git a/app/reports/edit/route.js b/app/reports/edit/route.js index 1aa5943735..6dfa98e12a 100644 --- a/app/reports/edit/route.js +++ b/app/reports/edit/route.js @@ -1,8 +1,9 @@ import AbstractEditRoute from 'hospitalrun/routes/abstract-edit-route'; +import AddToPatientRoute from 'hospitalrun/mixins/add-to-patient-route'; import Ember from 'ember'; import { translationMacro as t } from 'ember-i18n'; -export default AbstractEditRoute.extend({ +export default AbstractEditRoute.extend(AddToPatientRoute, { modelName: 'report', customForms: Ember.inject.service(), @@ -15,17 +16,6 @@ export default AbstractEditRoute.extend({ return customForms.setDefaultCustomForms(['opdReport', 'dischargeReport'], 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'; diff --git a/app/visits/edit/controller.js b/app/visits/edit/controller.js index cc31422291..865ac74062 100644 --- a/app/visits/edit/controller.js +++ b/app/visits/edit/controller.js @@ -170,18 +170,21 @@ export default AbstractEditController.extend(AddNewPatient, ChargeActions, Diagn return visitTypes; }.property('visitTypes', 'model.outPatient'), - _addChildObject(route, afterTransition) { - this.transitionToRoute(route, 'new').then(function(newRoute) { - newRoute.currentModel.setProperties({ - patient: this.get('model.patient'), - visit: this.get('model'), - selectPatient: false, - returnToVisit: this.get('model.id') - }); + _addChildObject(route, queryParamType, afterTransition) { + let queryParams = {}; + if (queryParamType) { + if (queryParamType == 'patient') { + queryParams.forPatientId = this.get('model.patient.id'); + } else if (queryParamType == 'visit') { + queryParams.forVisitId = this.get('model.id'); + } + } + let options = { queryParams }; + this.transitionToRoute(route, 'new', options).then((newRoute) => { if (afterTransition) { afterTransition(newRoute); } - }.bind(this)); + }); }, _finishAfterUpdate() { @@ -398,7 +401,7 @@ export default AbstractEditController.extend(AddNewPatient, ChargeActions, Diagn editOperativePlan(operativePlan) { let model = operativePlan; if (isEmpty(model)) { - this._addChildObject('patients.operative-plan', (route) =>{ + this._addChildObject('patients.operative-plan', 'patient', (route) =>{ route.controller.getPatientDiagnoses(this.get('model.patient'), route.currentModel); }); } else { @@ -445,7 +448,7 @@ export default AbstractEditController.extend(AddNewPatient, ChargeActions, Diagn this.displayAlert(updateTitle, updateMesage); return false; } - this._addChildObject('reports.edit'); + this._addChildObject('reports.edit', 'visit'); }, editReport() { @@ -453,23 +456,23 @@ export default AbstractEditController.extend(AddNewPatient, ChargeActions, Diagn }, newAppointment() { - this._addChildObject('appointments.edit'); + this._addChildObject('appointments.edit', 'patient'); }, newImaging() { - this._addChildObject('imaging.edit'); + this._addChildObject('imaging.edit', 'patient'); }, newLab() { - this._addChildObject('labs.edit'); + this._addChildObject('labs.edit', 'patient'); }, newMedication() { - this._addChildObject('medication.edit'); + this._addChildObject('medication.edit', 'patient'); }, showAddProcedure() { - this._addChildObject('procedures.edit'); + this._addChildObject('procedures.edit', 'patient'); }, showDeleteImaging(imaging) { From dd9ce6b7785e8aa2d24bd5bb10f185fadd2a9b69 Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Fri, 24 Feb 2017 19:04:13 +0100 Subject: [PATCH 55/99] set patient on visit models --- app/mixins/add-to-patient-route.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/mixins/add-to-patient-route.js b/app/mixins/add-to-patient-route.js index f3979f70f5..865816d2c7 100644 --- a/app/mixins/add-to-patient-route.js +++ b/app/mixins/add-to-patient-route.js @@ -20,6 +20,8 @@ export default Mixin.create({ return this._setPatientOnModel(modelPromise, params.forPatientId); } else if (!isEmpty(params.forVisitId)) { return this._setVisitOnModel(modelPromise, params.forVisitId); + } else { + return this._createNewRecord(params); } } else { return modelPromise; @@ -51,6 +53,7 @@ export default Mixin.create({ model.set('visit', visit); model.set('returnToVisit', visitId); model.set('selectPatient', false); + model.set('patient', visit.get('patient')); return model; }); }); From 7d439f0be23c3c44195ca6bd89bd7041b9d7515b Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Fri, 24 Feb 2017 19:05:46 +0100 Subject: [PATCH 56/99] Redirect reports/new to patients when no visit model --- app/reports/edit/route.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/reports/edit/route.js b/app/reports/edit/route.js index 6dfa98e12a..19ac6dd505 100644 --- a/app/reports/edit/route.js +++ b/app/reports/edit/route.js @@ -22,6 +22,12 @@ export default AbstractEditRoute.extend(AddToPatientRoute, { return t(`reports.${type}.titles.${state}`); }, + afterModel(model) { + if (!model.get('visit')) { + return this.transitionTo('patients'); + } + }, + setupController(controller, model) { this._super(controller, model); } From dd895560d6b755045ca0a7b946281839e546305c Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Fri, 24 Feb 2017 19:08:40 +0100 Subject: [PATCH 57/99] Clean up visit controller --- app/visits/edit/controller.js | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/app/visits/edit/controller.js b/app/visits/edit/controller.js index 865ac74062..dabd6a47f7 100644 --- a/app/visits/edit/controller.js +++ b/app/visits/edit/controller.js @@ -170,16 +170,12 @@ export default AbstractEditController.extend(AddNewPatient, ChargeActions, Diagn return visitTypes; }.property('visitTypes', 'model.outPatient'), - _addChildObject(route, queryParamType, afterTransition) { - let queryParams = {}; - if (queryParamType) { - if (queryParamType == 'patient') { - queryParams.forPatientId = this.get('model.patient.id'); - } else if (queryParamType == 'visit') { - queryParams.forVisitId = this.get('model.id'); + _addChildObject(route, afterTransition) { + let options = { + queryParams: { + forVisitId: this.get('model.id') } - } - let options = { queryParams }; + }; this.transitionToRoute(route, 'new', options).then((newRoute) => { if (afterTransition) { afterTransition(newRoute); @@ -401,7 +397,7 @@ export default AbstractEditController.extend(AddNewPatient, ChargeActions, Diagn editOperativePlan(operativePlan) { let model = operativePlan; if (isEmpty(model)) { - this._addChildObject('patients.operative-plan', 'patient', (route) =>{ + this._addChildObject('patients.operative-plan', (route) =>{ route.controller.getPatientDiagnoses(this.get('model.patient'), route.currentModel); }); } else { @@ -448,7 +444,7 @@ export default AbstractEditController.extend(AddNewPatient, ChargeActions, Diagn this.displayAlert(updateTitle, updateMesage); return false; } - this._addChildObject('reports.edit', 'visit'); + this._addChildObject('reports.edit'); }, editReport() { @@ -456,23 +452,23 @@ export default AbstractEditController.extend(AddNewPatient, ChargeActions, Diagn }, newAppointment() { - this._addChildObject('appointments.edit', 'patient'); + this._addChildObject('appointments.edit'); }, newImaging() { - this._addChildObject('imaging.edit', 'patient'); + this._addChildObject('imaging.edit'); }, newLab() { - this._addChildObject('labs.edit', 'patient'); + this._addChildObject('labs.edit'); }, newMedication() { - this._addChildObject('medication.edit', 'patient'); + this._addChildObject('medication.edit'); }, showAddProcedure() { - this._addChildObject('procedures.edit', 'patient'); + this._addChildObject('procedures.edit'); }, showDeleteImaging(imaging) { From 012f7d51a160146707dc1cbd3eb8768913df9b43 Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Fri, 24 Feb 2017 19:10:02 +0100 Subject: [PATCH 58/99] Set visit on models --- app/appointments/edit/route.js | 3 +++ app/medication/edit/route.js | 2 ++ app/procedures/edit/route.js | 3 ++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/appointments/edit/route.js b/app/appointments/edit/route.js index bd5c5c7055..f1b47bc561 100644 --- a/app/appointments/edit/route.js +++ b/app/appointments/edit/route.js @@ -59,6 +59,9 @@ export default AbstractEditRoute.extend(AddToPatientRoute, PatientListRoute, { if (!isEmpty(params.forPatientId)) { let modelPromise = this._super(params); return this._setPatientOnModel(modelPromise, params.forPatientId); + } else if (!isEmpty(params.forVisitId)) { + let modelPromise = this._super(params); + return this._setVisitOnModel(modelPromise, params.forforVisitId); } else { return this._createNewRecord(params); } diff --git a/app/medication/edit/route.js b/app/medication/edit/route.js index 7cdbed5d87..e8ae0b4b0d 100644 --- a/app/medication/edit/route.js +++ b/app/medication/edit/route.js @@ -35,6 +35,8 @@ export default AbstractEditRoute.extend(AddToPatientRoute, FulfillRequest, Inven if (!Ember.isEmpty(idParam) && params[idParam] === 'new' || params[idParam] === 'dispense') { if (!isEmpty(params.forPatientId)) { return this._setPatientOnModel(modelPromise, params.forPatientId); + } else if (!isEmpty(params.forVisitId)) { + return this._setVisitOnModel(modelPromise, params.forVisitId); } else { return this._createNewRecord(params); } diff --git a/app/procedures/edit/route.js b/app/procedures/edit/route.js index cfac071baf..b2e54299ce 100644 --- a/app/procedures/edit/route.js +++ b/app/procedures/edit/route.js @@ -1,9 +1,10 @@ import AbstractEditRoute from 'hospitalrun/routes/abstract-edit-route'; +import AddToPatient from 'hospitalrun/mixins/add-to-patient-route'; import ChargeRoute from 'hospitalrun/mixins/charge-route'; import Ember from 'ember'; import { translationMacro as t } from 'ember-i18n'; -export default AbstractEditRoute.extend(ChargeRoute, { +export default AbstractEditRoute.extend(AddToPatient, ChargeRoute, { editTitle: t('procedures.titles.edit'), modelName: 'procedure', newTitle: t('procedures.titles.new'), From 4834a44eacaaddb714e968f748f03f75f7e4d679 Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Fri, 24 Feb 2017 19:11:17 +0100 Subject: [PATCH 59/99] Update visit acceptance tests --- tests/acceptance/visit-test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/acceptance/visit-test.js b/tests/acceptance/visit-test.js index b3fe28c347..97edebdb5b 100644 --- a/tests/acceptance/visit-test.js +++ b/tests/acceptance/visit-test.js @@ -68,7 +68,7 @@ test('Edit visit', function(assert) { click('button:contains(New Medication)'); }); andThen(function() { - assert.equal(currentURL(), '/medication/edit/new', 'New medication url is correct'); + assert.equal(currentURL(), '/medication/edit/new?forVisitId=03C7BF8B-04E0-DD9E-9469-96A5604F5340', 'New medication url is correct'); assert.equal(find('.patient-name .ps-info-data').text(), 'Joe Bagadonuts', 'New medication prepopulates with patient'); click('button:contains(Cancel)'); }); @@ -76,7 +76,7 @@ test('Edit visit', function(assert) { click('button:contains(New Lab)'); }); andThen(function() { - assert.equal(currentURL(), '/labs/edit/new', 'New lab url is correct'); + assert.equal(currentURL(), '/labs/edit/new?forVisitId=03C7BF8B-04E0-DD9E-9469-96A5604F5340', 'New lab url is correct'); assert.equal(find('.patient-name .ps-info-data').text(), 'Joe Bagadonuts', 'New lab prepopulates with patient'); click('button:contains(Cancel)'); }); @@ -84,7 +84,7 @@ test('Edit visit', function(assert) { click('button:contains(New Imaging)'); }); andThen(function() { - assert.equal(currentURL(), '/imaging/edit/new', 'New imaging url is correct'); + assert.equal(currentURL(), '/imaging/edit/new?forVisitId=03C7BF8B-04E0-DD9E-9469-96A5604F5340', 'New imaging url is correct'); assert.equal(find('.patient-name .ps-info-data').text(), 'Joe Bagadonuts', 'New imaging prepopulates with patient'); click('button:contains(Cancel)'); }); From 67670f64277b0f6185826a799c1508bfda4e304c Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Fri, 24 Feb 2017 21:02:44 +0100 Subject: [PATCH 60/99] Fix appointments new surgery test error --- app/appointments/edit/route.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/appointments/edit/route.js b/app/appointments/edit/route.js index f1b47bc561..aae30ff91d 100644 --- a/app/appointments/edit/route.js +++ b/app/appointments/edit/route.js @@ -1,5 +1,5 @@ import AbstractEditRoute from 'hospitalrun/routes/abstract-edit-route'; -import AddToPatientRoute from 'hospitalrun/mixins/add-to-patient-route'; +import AddToPatient from 'hospitalrun/mixins/add-to-patient-route'; import Ember from 'ember'; import moment from 'moment'; import PatientListRoute from 'hospitalrun/mixins/patient-list-route'; @@ -13,7 +13,7 @@ const { } } = Ember; -export default AbstractEditRoute.extend(AddToPatientRoute, PatientListRoute, { +export default AbstractEditRoute.extend(AddToPatient, PatientListRoute, { editTitle: t('appointments.editTitle'), modelName: 'appointment', newButtonText: t('appointments.buttons.newButton'), @@ -61,7 +61,7 @@ export default AbstractEditRoute.extend(AddToPatientRoute, PatientListRoute, { return this._setPatientOnModel(modelPromise, params.forPatientId); } else if (!isEmpty(params.forVisitId)) { let modelPromise = this._super(params); - return this._setVisitOnModel(modelPromise, params.forforVisitId); + return this._setVisitOnModel(modelPromise, params.forVisitId); } else { return this._createNewRecord(params); } From 8c0387a7b0e170fa1696a9a5f81c370c933bb6f1 Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Sun, 26 Feb 2017 15:02:00 +0100 Subject: [PATCH 61/99] Remove double reference to visits controller --- app/reports/edit/controller.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/app/reports/edit/controller.js b/app/reports/edit/controller.js index ff67d4e9da..f927d94db5 100644 --- a/app/reports/edit/controller.js +++ b/app/reports/edit/controller.js @@ -16,13 +16,11 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, newReport: false, physicianList: Ember.computed.alias('visitsController.physicianList'), - visitController: Ember.inject.controller('visits'), - - logoURL: Ember.computed.alias('visitController.printHeader.value.logoURL'), - facilityName: Ember.computed.alias('visitController.printHeader.value.facilityName'), - headerLine1: Ember.computed.alias('visitController.printHeader.value.headerLine1'), - headerLine2: Ember.computed.alias('visitController.printHeader.value.headerLine2'), - headerLine3: Ember.computed.alias('visitController.printHeader.value.headerLine3'), + logoURL: Ember.computed.alias('visitsController.printHeader.value.logoURL'), + facilityName: Ember.computed.alias('visitsController.printHeader.value.facilityName'), + headerLine1: Ember.computed.alias('visitsController.printHeader.value.headerLine1'), + headerLine2: Ember.computed.alias('visitsController.printHeader.value.headerLine2'), + headerLine3: Ember.computed.alias('visitsController.printHeader.value.headerLine3'), diagnosis: Ember.computed('model.patient', function() { let container = this.get('model.patient'); From a38f060ad0f428f4335bc4646b82af4f54f4a4f1 Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Sun, 26 Feb 2017 15:41:02 +0100 Subject: [PATCH 62/99] Display visit diagnosis appropriately --- app/reports/edit/controller.js | 13 ++++--------- app/reports/edit/template.hbs | 24 ++---------------------- 2 files changed, 6 insertions(+), 31 deletions(-) diff --git a/app/reports/edit/controller.js b/app/reports/edit/controller.js index f927d94db5..719b082992 100644 --- a/app/reports/edit/controller.js +++ b/app/reports/edit/controller.js @@ -12,8 +12,10 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, id: 'physician_list' }], - visitsController: Ember.inject.controller('visits'), newReport: false, + + visitsController: Ember.inject.controller('visits'), + physicianList: Ember.computed.alias('visitsController.physicianList'), logoURL: Ember.computed.alias('visitsController.printHeader.value.logoURL'), @@ -22,14 +24,7 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, headerLine2: Ember.computed.alias('visitsController.printHeader.value.headerLine2'), headerLine3: Ember.computed.alias('visitsController.printHeader.value.headerLine3'), - 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; - }), + diagnosisList: Ember.computed.alias('visitsController.diagnosisList'), nextAppointment: Ember.computed('model', function() { return this.getPatientFutureAppointment(this.get('model.visit')); diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index 7bdf08c846..6c50aeb9fe 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -24,6 +24,8 @@ returnTo='visit.edit' returnToContext=model.id disablePatientLink=model.isNew + diagnosisContainer=model.visit + diagnosisList=diagnosisList }} {{/if}} @@ -62,28 +64,6 @@ {{/if}} {{/unless}} - {{#if diagnosis.primary.length}} -
              - -
                - {{#each diagnosis.primary as |item|}} -
              • {{item.diagnosis}}
              • - {{/each}} -
              -
              - {{/if}} - - {{#if diagnosis.secondary.length}} -
              - -
                - {{#each diagnosis.secondary as |item|}} -
              • {{item.diagnosis}}
              • - {{/each}} -
              -
              - {{/if}} - {{#if model.visit.procedures.length}}
              From 62c4dcef1aa1c9f007754d983572721744bef6bd Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Sun, 26 Feb 2017 22:18:04 +0100 Subject: [PATCH 63/99] Fix Operative Plans display --- app/locales/en/translations.js | 8 ++++++- app/reports/edit/template.hbs | 42 +++++++++++++++++++++++++++------- 2 files changed, 41 insertions(+), 9 deletions(-) diff --git a/app/locales/en/translations.js b/app/locales/en/translations.js index b0dbdf3875..444619422d 100644 --- a/app/locales/en/translations.js +++ b/app/locales/en/translations.js @@ -1117,8 +1117,14 @@ export default { procedures: 'Procedures', labs: 'Labs', images: 'Images', + medications: 'Medications', nextAppointmentDate: 'Date Of Next Appointment', - operativePlan: 'Planned Procedures' + operativePlan: { + title: 'Operative Plans', + description: 'Operation Description', + procedures: 'Planned Procedures', + instructions: 'Instructions upon Admission' + } }, opd: { titles: { diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index 7bdf08c846..d74136452c 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -29,7 +29,7 @@ {{#if model.visit.startDate}}
              -

              {{t 'reports.form.visitDate' }}

              + {{date-format model.visit.startDate format="DD/MM/YYYY hh:mm a"}}
              {{/if}} @@ -89,7 +89,7 @@
                {{#each model.visit.procedures as |item|}} -
              • {{item.description}} {{#if item.procedureDate }} - {{date-format item.procedureDate format="DD/MM/YYYY"}} {{/if}}
              • +
              • {{item.description}}
              • {{/each}}
              @@ -117,23 +117,49 @@
              {{/if}} + {{#if model.visit.medication.length}} +
              + +
                + {{#each model.visit.medication as |medication|}} +
              • {{medication.medicationName}} - {{medication.prescription}} ({{medication.status}})
              • + {{/each}} +
              +
              + {{/if}} {{#if nextAppointment}}
              -

              {{t 'reports.form.nextAppointmentDate' }}

              + {{date-format nextAppointment format="DD/MM/YYYY hh:mm a"}}
              {{/if}} {{#if model.visit.patient.operativePlans.length}}
              - +
                - {{#each model.visit.patient.operativePlans as |item|}} - {{#each item.procedures as |p|}} -
              • {{p.description}} ({{item.status}})
              • + {{#each model.visit.patient.operativePlans as |operativePlan|}} +
              • +

                {{t 'reports.form.operativePlan.description' }}:
                + {{operativePlan.operationDescription}}

                +
              • + +
              • +

                {{t 'reports.form.operativePlan.procedures' }}:

                +
                  + {{#each operativePlan.procedures as |procedure|}} +
                • {{procedure.description}}
                • + {{/each}} +
                +
              • + +
              • +

                {{t 'reports.form.operativePlan.instructions' }}:
                + {{operativePlan.admissionInstructions}} +

                +
              • {{/each}} - {{/each}}
              {{/if}} From df81a13370cee25a406a89e18a760b812abde5c8 Mon Sep 17 00:00:00 2001 From: chima1707 Date: Thu, 2 Mar 2017 12:13:39 +0100 Subject: [PATCH 64/99] fix: fixed translation lables for next appointments --- app/locales/en/translations.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/locales/en/translations.js b/app/locales/en/translations.js index 444619422d..aa101a46fe 100644 --- a/app/locales/en/translations.js +++ b/app/locales/en/translations.js @@ -1118,7 +1118,8 @@ export default { labs: 'Labs', images: 'Images', medications: 'Medications', - nextAppointmentDate: 'Date Of Next Appointment', + nextAppointment: 'Next Appointment', + nextAppointments: 'Next Appointments', operativePlan: { title: 'Operative Plans', description: 'Operation Description', From de35e4432ab63c98731e3c416665680a28822364 Mon Sep 17 00:00:00 2001 From: chima1707 Date: Thu, 2 Mar 2017 12:14:59 +0100 Subject: [PATCH 65/99] fix: modified get futureAppointment to work for list of appointments --- app/mixins/patient-visits.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/mixins/patient-visits.js b/app/mixins/patient-visits.js index bf1dc2bc06..1f244935bd 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, outPatient) { let patientId = visit.get('patient.id'); let visitDate = visit.get('startDate'); let maxValue = this.get('maxValue'); @@ -39,11 +39,16 @@ export default Ember.Mixin.create(PouchDbMixin, { if (!futureAppointments.length) { return ''; } - let [appointment] = futureAppointments; - let res = appointment.get('startDate'); - return res; + if (!outPatient) { + let [appointment] = futureAppointments; + return appointment; + } else { + let res = futureAppointments.slice(0, 3); + return res; + } + }); - return DS.PromiseObject.create({ promise }); + return (outPatient) ? DS.PromiseArray.create({ promise}) : DS.PromiseObject.create({ promise }); }, checkoutVisit(visit, status) { From bbdbd654d2ff1e173f74d9aea273a73b92f8258d Mon Sep 17 00:00:00 2001 From: chima1707 Date: Thu, 2 Mar 2017 12:15:56 +0100 Subject: [PATCH 66/99] fix: implemented next appointments on both template and controller --- app/reports/edit/controller.js | 6 ++++-- app/reports/edit/template.hbs | 35 ++++++++++++++++++++++++++++------ 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/app/reports/edit/controller.js b/app/reports/edit/controller.js index 719b082992..00607cba5c 100644 --- a/app/reports/edit/controller.js +++ b/app/reports/edit/controller.js @@ -30,6 +30,10 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, return this.getPatientFutureAppointment(this.get('model.visit')); }), + nextAppointments: Ember.computed('model', function() { + return this.getPatientFutureAppointment(this.get('model.visit'), true); + }), + additionalButtons: Ember.computed('model.{isNew}', function() { let isNew = this.get('model.isNew'); if (!isNew) { @@ -47,8 +51,6 @@ 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'); } else { diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index cca704e8e3..b2f77d2378 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -108,12 +108,35 @@ {{/if}} - {{#if nextAppointment}} -
              - - {{date-format nextAppointment format="DD/MM/YYYY hh:mm a"}} -
              - {{/if}} + {{log nextAppointment}} + {{#if model.visit.outPatient}} + {{#if nextAppointments.length}} +
              + + {{#each nextAppointments as |appointment|}} + {{date-format appointment.startDate format="DD/MM/YYYY hh:mm a"}} + {{#if appointment.appointmentType}} + ({{appointment.appointmentType}}) + {{/if}}, + {{/each}} +
              + {{/if}} + + {{else}} + + {{#if nextAppointment}} +
              + + {{date-format nextAppointment.startDate format="DD/MM/YYYY hh:mm a"}} + {{#if nextAppointment.location}} + ({{nextAppointment.location}}) + {{/if}} +
              + {{/if}} + + {{/if}} + + {{#if model.visit.patient.operativePlans.length}}
              From f91deccd223e08f4ab5fc72a07bdd2ce57cdc4a9 Mon Sep 17 00:00:00 2001 From: chima1707 Date: Thu, 2 Mar 2017 12:18:44 +0100 Subject: [PATCH 67/99] fix: fix lint --- app/mixins/patient-visits.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/mixins/patient-visits.js b/app/mixins/patient-visits.js index 1f244935bd..4e93a6a12d 100644 --- a/app/mixins/patient-visits.js +++ b/app/mixins/patient-visits.js @@ -48,7 +48,7 @@ export default Ember.Mixin.create(PouchDbMixin, { } }); - return (outPatient) ? DS.PromiseArray.create({ promise}) : DS.PromiseObject.create({ promise }); + return (outPatient) ? DS.PromiseArray.create({ promise }) : DS.PromiseObject.create({ promise }); }, checkoutVisit(visit, status) { From 9765327483425e890ff80683d14b3b5fb901471c Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Thu, 2 Mar 2017 13:05:20 +0100 Subject: [PATCH 68/99] FIx next appointments display --- app/reports/edit/template.hbs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index b2f77d2378..01d1c37e8b 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -108,17 +108,20 @@
              {{/if}} - {{log nextAppointment}} {{#if model.visit.outPatient}} {{#if nextAppointments.length}}
              - - {{#each nextAppointments as |appointment|}} - {{date-format appointment.startDate format="DD/MM/YYYY hh:mm a"}} - {{#if appointment.appointmentType}} - ({{appointment.appointmentType}}) - {{/if}}, - {{/each}} + +
                + {{#each nextAppointments as |appointment|}} +
              • + {{date-format appointment.startDate format="DD/MM/YYYY hh:mm a"}} + {{#if appointment.appointmentType}} + ({{appointment.appointmentType}}) + {{/if}} +
              • + {{/each}} +
              {{/if}} From cc260dd19142f635e6e1836a5b1376428df781b7 Mon Sep 17 00:00:00 2001 From: Mofesola Babalola Date: Thu, 2 Mar 2017 17:14:44 +0100 Subject: [PATCH 69/99] Added auto trigger hospitalrun-server refresh script on successful build --- .travis.yml | 4 +++- script/server_build.sh | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100755 script/server_build.sh diff --git a/.travis.yml b/.travis.yml index c1ae4b11d5..e14b1b3076 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,10 +17,12 @@ script: - npm test deploy: provider: npm - email: mofesola.babalola@ehealthafrica.org + email: devops@ehealthafrica.org api_key: secure: G13Wfjt+5lzPmc/4M4669Q+htK389oglI/JDTYDDH1v0ZaWOtvAc2Zvu2BvMGy9IMJ5f66ICJLxcWIg0gP2SMxvkQgUYaGFkVCRbaAwxfhcbSLJ2H/AGaanV1qRFeLQQRmNXg/yK0tW+biOsLXKvDXqazaueh/hP64uJmzAr3L1Y26q6QjL2iMEczEUi9Z02Gl5u5rCWsdM8c0oZ872FR8QWkSR4fb6vaKIyItfcUCN0nbJ4RhIncCCJLja7NHbeaxGh9rXVaO6F6oTiuuuJj863ATSBO670dmWGbscZQWxIRJPko3IAn6dQD4Q9FaJZR1pyS2+pkGSuGbjdYjMfj0vh73Hf6wmCwve/i9cA8du0qDEKqMetdsMIAS4XKoR2jQyWCivGOhOHizjoH7xezyj9K469IEugTFoyENoASW3ADYL3YGFpKn0Xs2i0MuSS8MGmSLw6QfEDzLvmxJeGnNQFXKtXyOOJlmyoTcIcviMr26jOmWINBWzNFp6B1wqcWpPy2TJyoQFL8Fnd4uadc5i4mxv9hPKLbbpV72+EuWiPqNX+rvgMxuFfMogIVB6R7GIMrk+MVmLlr9O4jYcsNcEW5Pw5rcxw/OCSw/mReMNFyRWhscpgpWcYwOzQHXMFKusSzITJLNjtwL40JH4i90U2jDwEZTUXT8E/IJVuYmY= on: tags: true repo: eHealthAfrica/hospitalrun-frontend branch: master +after_deploy: + - script/server_build.sh diff --git a/script/server_build.sh b/script/server_build.sh new file mode 100755 index 0000000000..7cd6403366 --- /dev/null +++ b/script/server_build.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +BRANCH="${TRAVIS_BRANCH}" + +body='{ +"request": { + "branch":"${BRANCH}" +}}' + +curl -s -X POST \ + -H "Content-Type: application/json" \ + -H "Accept: application/json" \ + -H "Travis-API-Version: 3" \ + -H "Authorization: token ${BUILD_TRIGGER_TOKEN}" \ + -d "$body" \ + https://api.travis-ci.org/repo/eHealthAfrica%2Fhospitalrun-server/requests From cda47994c375eedfd67878af5770d12e9a85a601 Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Thu, 2 Mar 2017 21:39:44 +0100 Subject: [PATCH 70/99] Fix reports controller bug --- app/reports/edit/controller.js | 11 +-- app/reports/edit/route.js | 10 ++- app/reports/edit/template.hbs | 130 ++++++++++++++++----------------- 3 files changed, 73 insertions(+), 78 deletions(-) diff --git a/app/reports/edit/controller.js b/app/reports/edit/controller.js index 00607cba5c..fd7662ba1d 100644 --- a/app/reports/edit/controller.js +++ b/app/reports/edit/controller.js @@ -3,9 +3,8 @@ 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'; -export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, PouchDbMixin, PatientVisit, { +export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, PouchDbMixin, { lookupListsToUpdate: [{ name: 'physicianList', property: 'model.surgeon', @@ -26,14 +25,6 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, diagnosisList: Ember.computed.alias('visitsController.diagnosisList'), - nextAppointment: Ember.computed('model', function() { - return this.getPatientFutureAppointment(this.get('model.visit')); - }), - - nextAppointments: Ember.computed('model', function() { - return this.getPatientFutureAppointment(this.get('model.visit'), true); - }), - additionalButtons: Ember.computed('model.{isNew}', function() { let isNew = this.get('model.isNew'); if (!isNew) { diff --git a/app/reports/edit/route.js b/app/reports/edit/route.js index 19ac6dd505..8b122b36bc 100644 --- a/app/reports/edit/route.js +++ b/app/reports/edit/route.js @@ -2,8 +2,9 @@ import AbstractEditRoute from 'hospitalrun/routes/abstract-edit-route'; import AddToPatientRoute from 'hospitalrun/mixins/add-to-patient-route'; import Ember from 'ember'; import { translationMacro as t } from 'ember-i18n'; +import PatientVisits from 'hospitalrun/mixins/patient-visits'; -export default AbstractEditRoute.extend(AddToPatientRoute, { +export default AbstractEditRoute.extend(AddToPatientRoute, PatientVisits, { modelName: 'report', customForms: Ember.inject.service(), @@ -30,5 +31,12 @@ export default AbstractEditRoute.extend(AddToPatientRoute, { setupController(controller, model) { this._super(controller, model); + let isOutPatient = model.get('visit.outPatient'); + controller.set('isOutPatient', isOutPatient); + if (isOutPatient) { + controller.set('nextAppointments', this.getPatientFutureAppointment(model.get('visit'), true)); + } else { + controller.set('nextAppointment', this.getPatientFutureAppointment(model.get('visit'))); + } } }); diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index 01d1c37e8b..684514599b 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -15,8 +15,8 @@ {{headerLine3}}
              {{/if}} -
              - {{#edit-panel editPanelProps=editPanelProps}} +
              + {{#edit-panel editPanelProps=editPanelProps}} {{#em-form model=model submitButton=false }} {{#if model.visit}} {{patient-summary @@ -36,35 +36,35 @@
              {{/if}} - {{#unless model.visit.outPatient}} + {{#unless isOutPatient}}

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

              {{date-format model.reportDate format="DD/MM/YYYY hh:mm a"}}
              {{/unless}} - {{#unless model.visit.outPatient}} + {{#unless isOutPatient}}
              {{select-or-typeahead className="col-sm-4" property="surgeon" - label=(t "operativePlan.labels.surgeon") list=physicianList - selection=model.surgeon - class="plan-surgeon" + label=(t "operativePlan.labels.surgeon") list=physicianList + selection=model.surgeon + class="plan-surgeon" }}
              {{/unless}} - {{#unless model.visit.outPatient}} + {{#unless isOutPatient}} {{#if model.visit.notes}}
                -
              • {{model.visit.notes}}
              • +
              • {{model.visit.notes}}
              {{/if}} {{/unless}} - {{#if model.visit.procedures.length}} + {{#if model.visit.procedures}}
                @@ -75,7 +75,7 @@
              {{/if}} - {{#if model.visit.labs.length}} + {{#if model.visit.labs}}
                @@ -86,7 +86,7 @@
              {{/if}} - {{#if model.visit.imaging.length}} + {{#if model.visit.imaging}}
                @@ -97,7 +97,7 @@
              {{/if}} - {{#if model.visit.medication.length}} + {{#if model.visit.medication}}
                @@ -108,76 +108,72 @@
              {{/if}} - {{#if model.visit.outPatient}} - {{#if nextAppointments.length}} -
              - -
                - {{#each nextAppointments as |appointment|}} -
              • - {{date-format appointment.startDate format="DD/MM/YYYY hh:mm a"}} - {{#if appointment.appointmentType}} - ({{appointment.appointmentType}}) - {{/if}} -
              • - {{/each}} -
              -
              - {{/if}} - - {{else}} - - {{#if nextAppointment}} -
              - - {{date-format nextAppointment.startDate format="DD/MM/YYYY hh:mm a"}} - {{#if nextAppointment.location}} - ({{nextAppointment.location}}) - {{/if}} -
              - {{/if}} + {{#if isOutPatient}} + {{#if nextAppointments}} +
              + +
                + {{#each nextAppointments as |appointment|}} +
              • + {{date-format appointment.startDate format="DD/MM/YYYY hh:mm a"}} + {{#if appointment.appointmentType}} + ({{appointment.appointmentType}}) + {{/if}} +
              • + {{/each}} +
              +
              + {{/if}} - {{/if}} + {{else}} + {{#if nextAppointment}} +
              + + {{date-format nextAppointment.startDate format="DD/MM/YYYY hh:mm a"}} + {{#if nextAppointment.location}} + ({{nextAppointment.location}}) + {{/if}} +
              + {{/if}} + {{/if}} - {{#if model.visit.patient.operativePlans.length}} + {{#if model.visit.patient.operativePlans}}
                - {{#each model.visit.patient.operativePlans as |operativePlan|}} -
              • -

                {{t 'reports.form.operativePlan.description' }}:
                + {{#each model.visit.patient.operativePlans as |operativePlan|}} +

              • +

                {{t 'reports.form.operativePlan.description' }}:
                {{operativePlan.operationDescription}}

                -
              • - -
              • -

                {{t 'reports.form.operativePlan.procedures' }}:

                -
                  - {{#each operativePlan.procedures as |procedure|}} -
                • {{procedure.description}}
                • - {{/each}} -
                -
              • - -
              • -

                {{t 'reports.form.operativePlan.instructions' }}:
                - {{operativePlan.admissionInstructions}} -

                -
              • - {{/each}} + + +
              • +

                {{t 'reports.form.operativePlan.procedures' }}:

                +
                  + {{#each operativePlan.procedures as |procedure|}} +
                • {{procedure.description}}
                • + {{/each}} +
                +
              • + +
              • +

                {{t 'reports.form.operativePlan.instructions' }}:
                + {{operativePlan.admissionInstructions}} +

                +
              • + {{/each}}
              {{/if}} - {{#if model.visit.outPatient}} + {{#if isOutPatient}} {{custom-form-manager model=model formType="opdReport"}} {{else}} {{custom-form-manager model=model formType="dischargeReport"}} {{/if}} - - {{/em-form}} {{/edit-panel}} -
              + From 397fb9acf73ea2f244b4e2478a1efa9a5742e89b Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Thu, 2 Mar 2017 22:00:00 +0100 Subject: [PATCH 71/99] Add diagnosis container --- app/reports/edit/route.js | 13 +++++++++++-- app/reports/edit/template.hbs | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/reports/edit/route.js b/app/reports/edit/route.js index 8b122b36bc..3d85be619c 100644 --- a/app/reports/edit/route.js +++ b/app/reports/edit/route.js @@ -1,7 +1,7 @@ import AbstractEditRoute from 'hospitalrun/routes/abstract-edit-route'; import AddToPatientRoute from 'hospitalrun/mixins/add-to-patient-route'; import Ember from 'ember'; -import { translationMacro as t } from 'ember-i18n'; +import {translationMacro as t} from 'ember-i18n'; import PatientVisits from 'hospitalrun/mixins/patient-visits'; export default AbstractEditRoute.extend(AddToPatientRoute, PatientVisits, { @@ -23,6 +23,13 @@ export default AbstractEditRoute.extend(AddToPatientRoute, PatientVisits, { return t(`reports.${type}.titles.${state}`); }, + getDiagnosisContainer(visit) { + if (visit.get('outPatient')) { + return visit; + } + return null; + }, + afterModel(model) { if (!model.get('visit')) { return this.transitionTo('patients'); @@ -31,8 +38,10 @@ export default AbstractEditRoute.extend(AddToPatientRoute, PatientVisits, { setupController(controller, model) { this._super(controller, model); - let isOutPatient = model.get('visit.outPatient'); + let visit = model.get('visit'); + let isOutPatient = visit.get('outPatient'); controller.set('isOutPatient', isOutPatient); + controller.set('diagnosisContainer', this.getDiagnosisContainer(visit)); if (isOutPatient) { controller.set('nextAppointments', this.getPatientFutureAppointment(model.get('visit'), true)); } else { diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index 684514599b..19d3782763 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -24,7 +24,7 @@ returnTo='visit.edit' returnToContext=model.id disablePatientLink=model.isNew - diagnosisContainer=model.visit + diagnosisContainer=diagnosisContainer diagnosisList=diagnosisList }} {{/if}} From 897e380aa680b35ace7b4461b765667d2af33d2b Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Thu, 2 Mar 2017 22:07:12 +0100 Subject: [PATCH 72/99] Set patient on model if model is not new --- app/reports/edit/route.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/reports/edit/route.js b/app/reports/edit/route.js index 3d85be619c..437b7ad7bd 100644 --- a/app/reports/edit/route.js +++ b/app/reports/edit/route.js @@ -31,6 +31,10 @@ export default AbstractEditRoute.extend(AddToPatientRoute, PatientVisits, { }, afterModel(model) { + if (!model.get('isNew')) { + let patient = model.get('visit.patient'); + model.set('patient', patient); + } if (!model.get('visit')) { return this.transitionTo('patients'); } From 1d3302a6921a3f6390bcfe561f0105e68e063bf0 Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Thu, 2 Mar 2017 22:47:20 +0100 Subject: [PATCH 73/99] Set visit on controller and add display current operative plan --- app/locales/en/translations.js | 2 +- app/reports/edit/route.js | 8 ++++++ app/reports/edit/template.hbs | 50 +++++++++++++++++----------------- 3 files changed, 34 insertions(+), 26 deletions(-) diff --git a/app/locales/en/translations.js b/app/locales/en/translations.js index aa101a46fe..8bbda486cf 100644 --- a/app/locales/en/translations.js +++ b/app/locales/en/translations.js @@ -1121,7 +1121,7 @@ export default { nextAppointment: 'Next Appointment', nextAppointments: 'Next Appointments', operativePlan: { - title: 'Operative Plans', + title: 'Operative Plan', description: 'Operation Description', procedures: 'Planned Procedures', instructions: 'Instructions upon Admission' diff --git a/app/reports/edit/route.js b/app/reports/edit/route.js index 437b7ad7bd..636cd04cd1 100644 --- a/app/reports/edit/route.js +++ b/app/reports/edit/route.js @@ -30,6 +30,11 @@ export default AbstractEditRoute.extend(AddToPatientRoute, PatientVisits, { return null; }, + getCurrentOperativePlan(patient) { + let operativePlans = patient.get('operativePlans'); + return operativePlans.findBy('isPlanned', true); + }, + afterModel(model) { if (!model.get('isNew')) { let patient = model.get('visit.patient'); @@ -43,9 +48,12 @@ export default AbstractEditRoute.extend(AddToPatientRoute, PatientVisits, { setupController(controller, model) { this._super(controller, model); let visit = model.get('visit'); + let patient = model.get('patient'); let isOutPatient = visit.get('outPatient'); + controller.set('visit', visit); controller.set('isOutPatient', isOutPatient); controller.set('diagnosisContainer', this.getDiagnosisContainer(visit)); + controller.set('currentOperativePlan', this.getCurrentOperativePlan(patient)); if (isOutPatient) { controller.set('nextAppointments', this.getPatientFutureAppointment(model.get('visit'), true)); } else { diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index 19d3782763..7f457a3ceb 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -18,9 +18,9 @@
              {{#edit-panel editPanelProps=editPanelProps}} {{#em-form model=model submitButton=false }} - {{#if model.visit}} + {{#if visit}} {{patient-summary - patient=model.visit.patient + patient=visit.patient returnTo='visit.edit' returnToContext=model.id disablePatientLink=model.isNew @@ -29,10 +29,10 @@ }} {{/if}} - {{#if model.visit.startDate}} + {{#if visit.startDate}}
              - {{date-format model.visit.startDate format="DD/MM/YYYY hh:mm a"}} + {{date-format visit.startDate format="DD/MM/YYYY hh:mm a"}}
              {{/if}} @@ -54,54 +54,54 @@ {{/unless}} {{#unless isOutPatient}} - {{#if model.visit.notes}} + {{#if visit.notes}}
                -
              • {{model.visit.notes}}
              • +
              • {{visit.notes}}
              {{/if}} {{/unless}} - {{#if model.visit.procedures}} + {{#if visit.procedures}}
                - {{#each model.visit.procedures as |item|}} + {{#each visit.procedures as |item|}}
              • {{item.description}}
              • {{/each}}
              {{/if}} - {{#if model.visit.labs}} + {{#if visit.labs}}
                - {{#each model.visit.labs as |item|}} + {{#each visit.labs as |item|}}
              • {{item.labType.name}}-{{item.result}} ({{item.status}})
              • {{/each}}
              {{/if}} - {{#if model.visit.imaging}} + {{#if visit.imaging}}
                - {{#each model.visit.imaging as |item|}} + {{#each visit.imaging as |item|}}
              • {{item.imagingType.name}}-{{item.result}} ({{item.status}})
              • {{/each}}
              {{/if}} - {{#if model.visit.medication}} + {{#if visit.medication}}
                - {{#each model.visit.medication as |medication|}} + {{#each visit.medication as |medication|}}
              • {{medication.medicationName}} - {{medication.prescription}} ({{medication.status}})
              • {{/each}}
              @@ -139,20 +139,20 @@ {{/if}} - {{#if model.visit.patient.operativePlans}} -
              - -
                - {{#each model.visit.patient.operativePlans as |operativePlan|}} + {{#if isOutPatient}} + {{#if currentOperativePlan}} +
                + +
                • {{t 'reports.form.operativePlan.description' }}:
                  - {{operativePlan.operationDescription}}

                  + {{currentOperativePlan.operationDescription}}

                • {{t 'reports.form.operativePlan.procedures' }}:

                    - {{#each operativePlan.procedures as |procedure|}} + {{#each currentOperativePlan.procedures as |procedure|}}
                  • {{procedure.description}}
                  • {{/each}}
                  @@ -160,12 +160,12 @@
                • {{t 'reports.form.operativePlan.instructions' }}:
                  - {{operativePlan.admissionInstructions}} + {{currentOperativePlan.admissionInstructions}}

                • - {{/each}} -
                -
                +
              +
              + {{/if}} {{/if}} {{#if isOutPatient}} From fbfa8b78ad6b25690e543d8d3659de669a824685 Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Thu, 2 Mar 2017 22:54:00 +0100 Subject: [PATCH 74/99] Add `Completed By` field to report --- app/locales/en/translations.js | 3 ++- app/reports/edit/template.hbs | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/locales/en/translations.js b/app/locales/en/translations.js index 8bbda486cf..6a06fc68c1 100644 --- a/app/locales/en/translations.js +++ b/app/locales/en/translations.js @@ -1125,7 +1125,8 @@ export default { description: 'Operation Description', procedures: 'Planned Procedures', instructions: 'Instructions upon Admission' - } + }, + completedBy: 'Completed By' }, opd: { titles: { diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index 7f457a3ceb..01e7b6c2f6 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -174,6 +174,13 @@ {{custom-form-manager model=model formType="dischargeReport"}} {{/if}} + {{#unless isOutPatient}} +
              + + {{model.modifiedBy}} +
              + {{/unless}} + {{/em-form}} {{/edit-panel}}
              From c276e9ca23b2aa304ed209fde504976df834392c Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Thu, 2 Mar 2017 23:57:46 +0100 Subject: [PATCH 75/99] Refactor reports template --- app/locales/en/translations.js | 13 ++- app/reports/edit/template.hbs | 206 ++++++++++++++++----------------- app/styles/_print.scss | 10 +- 3 files changed, 114 insertions(+), 115 deletions(-) diff --git a/app/locales/en/translations.js b/app/locales/en/translations.js index 6a06fc68c1..85923be6af 100644 --- a/app/locales/en/translations.js +++ b/app/locales/en/translations.js @@ -1105,13 +1105,18 @@ export default { }, reports: { titles: { - followup: 'Create Followup appointment', + followup: 'Create Followup Appointment', saved: 'The report has been saved' }, form: { visitDate: 'Date of Visit', - dischargeDate: 'Date of Discharge', - notes: 'Notes', + admissionDate: 'Admission Date', + dischargeDate: 'Discharge Date', + notes: { + title: 'Notes', + date: 'Date', + author: 'Author' + }, primaryDiagnosis: 'Primary Diagnosis', secondaryDiagnosis: 'Secondary Diagnosis', procedures: 'Procedures', @@ -1141,7 +1146,7 @@ export default { } }, messages: { - followup: 'Create new followup appointment for the discharge report', + followup: 'There is no follow up appointment for this patient.', delete: 'Are you sure you wish to delete this report?', saved: 'The report has been saved.' } diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index 01e7b6c2f6..f13ef25927 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -15,100 +15,75 @@ {{headerLine3}}
              {{/if}}
              -
              +
              {{#edit-panel editPanelProps=editPanelProps}} {{#em-form model=model submitButton=false }} - {{#if visit}} + {{#if model.patient}} {{patient-summary - patient=visit.patient - returnTo='visit.edit' - returnToContext=model.id - disablePatientLink=model.isNew + patient=model.patient + disablePatientLink=true diagnosisContainer=diagnosisContainer diagnosisList=diagnosisList }} {{/if}} - {{#if visit.startDate}} -
              - - {{date-format visit.startDate format="DD/MM/YYYY hh:mm a"}} -
              - {{/if}} - - {{#unless isOutPatient}} -
              -

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

              - {{date-format model.reportDate format="DD/MM/YYYY hh:mm a"}} -
              - {{/unless}} +
              + + {{date-format visit.startDate format="DD/MM/YYYY"}} +
              - {{#unless isOutPatient}} -
              - {{select-or-typeahead className="col-sm-4" property="surgeon" - label=(t "operativePlan.labels.surgeon") list=physicianList - selection=model.surgeon - class="plan-surgeon" - }} -
              - {{/unless}} + {{#if isOutPatient}} - {{#unless isOutPatient}} - {{#if visit.notes}} + {{#if visit.procedures}}
              - +
                -
              • {{visit.notes}}
              • + {{#each visit.procedures as |item|}} +
              • {{item.description}}
              • + {{/each}}
              {{/if}} - {{/unless}} - {{#if visit.procedures}} -
              - -
                - {{#each visit.procedures as |item|}} -
              • {{item.description}}
              • - {{/each}} -
              -
              - {{/if}} - - {{#if visit.labs}} -
              - -
                - {{#each visit.labs as |item|}} -
              • {{item.labType.name}}-{{item.result}} ({{item.status}})
              • - {{/each}} -
              -
              - {{/if}} + {{#if visit.labs}} +
              + +
                + {{#each visit.labs as |item|}} +
              • {{item.labType.name}}-{{item.result}} ({{item.status}})
              • + {{/each}} +
              +
              + {{/if}} - {{#if visit.imaging}} -
              - -
                - {{#each visit.imaging as |item|}} -
              • {{item.imagingType.name}}-{{item.result}} ({{item.status}})
              • - {{/each}} -
              -
              - {{/if}} + {{#if visit.imaging}} +
              + +
                + {{#each visit.imaging as |item|}} +
              • {{item.imagingType.name}}-{{item.result}} ({{item.status}})
              • + {{/each}} +
              +
              + {{/if}} - {{#if visit.medication}} -
              - -
                - {{#each visit.medication as |medication|}} -
              • {{medication.medicationName}} - {{medication.prescription}} ({{medication.status}})
              • - {{/each}} -
              -
              - {{/if}} + {{#if visit.medication}} +
              + +
                + {{#each visit.medication as |medication|}} +
              • {{medication.medicationName}} - {{medication.prescription}} ({{medication.status}})
              • + {{/each}} +
              +
              + {{/if}} - {{#if isOutPatient}} {{#if nextAppointments}}
              @@ -125,29 +100,16 @@
              {{/if}} - {{else}} - - {{#if nextAppointment}} -
              - - {{date-format nextAppointment.startDate format="DD/MM/YYYY hh:mm a"}} - {{#if nextAppointment.location}} - ({{nextAppointment.location}}) - {{/if}} -
              - {{/if}} - - {{/if}} - - {{#if isOutPatient}} {{#if currentOperativePlan}}
                -
              • -

                {{t 'reports.form.operativePlan.description' }}:
                - {{currentOperativePlan.operationDescription}}

                -
              • + {{#if currentOperativePlan.operationDescription}} +
              • +

                {{t 'reports.form.operativePlan.description' }}:
                + {{currentOperativePlan.operationDescription}}

                +
              • + {{/if}}
              • {{t 'reports.form.operativePlan.procedures' }}:

                @@ -158,28 +120,64 @@
              -
            • -

              {{t 'reports.form.operativePlan.instructions' }}:
              - {{currentOperativePlan.admissionInstructions}} -

              -
            • + {{#if currentOperativePlan.admissionInstructions}} +
            • +

              {{t 'reports.form.operativePlan.instructions' }}:
              + {{currentOperativePlan.admissionInstructions}}

              +
            • + {{/if}}
              {{/if}} - {{/if}} - {{#if isOutPatient}} {{custom-form-manager model=model formType="opdReport"}} + {{else}} + +
              + + {{date-format model.reportDate format="DD/MM/YYYY"}} +
              + +
              + {{select-or-typeahead className="col-sm-4" property="surgeon" + label=(t "operativePlan.labels.surgeon") list=physicianList + selection=model.surgeon + class="plan-surgeon" + }} +
              + + {{#if visit.patientNotes}} + +
                + {{#each visit.patientNotes as |note|}} +
              • + {{t 'reports.form.notes.date' }}: {{date-format note.date}}
                + {{t 'reports.form.notes.author' }}: {{note.authoredBy}}
                + {{note.noteType}}: {{note.content}} +
              • + {{/each}} +
              + {{/if}} + + {{#if nextAppointment}} +
              + + {{date-format nextAppointment.startDate format="DD/MM/YYYY hh:mm a"}} + {{#if nextAppointment.location}} + ({{nextAppointment.location}}) + {{/if}} +
              + {{/if}} + {{custom-form-manager model=model formType="dischargeReport"}} - {{/if}} - {{#unless isOutPatient}}
              {{model.modifiedBy}}
              - {{/unless}} + + {{/if}} {{/em-form}} {{/edit-panel}} diff --git a/app/styles/_print.scss b/app/styles/_print.scss index 79591157fc..67337bde3e 100644 --- a/app/styles/_print.scss +++ b/app/styles/_print.scss @@ -39,22 +39,18 @@ height: 60px; } - .opd-report { - font-size: .8em; - } - - .opd-report .patient-summary { + .report .patient-summary { margin-bottom: 20px; border-bottom: 1px solid #d2dae3; } - .opd-report input { + .report input { border: 0; padding: 5px; font-size: .8em; } - .opd-report .panel-primary { + .report .panel-primary { position: absolute; left: 0; margin: 0; From 31d8c337012d948c6ab912f6a107ed39751970b3 Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Fri, 3 Mar 2017 00:04:38 +0100 Subject: [PATCH 76/99] Ensure reports.edit returns to visits.edit --- app/visits/edit/controller.js | 5 +++-- app/visits/edit/route.js | 4 ---- app/visits/edit/template.hbs | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/app/visits/edit/controller.js b/app/visits/edit/controller.js index dabd6a47f7..0c1f1485c0 100644 --- a/app/visits/edit/controller.js +++ b/app/visits/edit/controller.js @@ -447,8 +447,9 @@ export default AbstractEditController.extend(AddNewPatient, ChargeActions, Diagn this._addChildObject('reports.edit'); }, - editReport() { - this.transitionToRoute('reports.edit', this.get('report.id')); + editReport(report) { + report.set('returnToVisit', this.get('model.id')); + this.transitionToRoute('reports.edit', report); }, newAppointment() { diff --git a/app/visits/edit/route.js b/app/visits/edit/route.js index da57946c31..9b6932b5e0 100644 --- a/app/visits/edit/route.js +++ b/app/visits/edit/route.js @@ -44,10 +44,6 @@ export default AbstractEditRoute.extend(ChargeRoute, PatientListRoute, PatientVi } }, - report: function() { - - }.property('model'), - setupController(controller, model) { let promise = this.store.query('report', { options: { diff --git a/app/visits/edit/template.hbs b/app/visits/edit/template.hbs index 3d4a7b25af..714b9514f0 100644 --- a/app/visits/edit/template.hbs +++ b/app/visits/edit/template.hbs @@ -294,7 +294,7 @@
              {{t 'labels.date'}}Created ByReport type{{t 'visits.labels.authoredBy'}}{{t 'visits.labels.reportType'}} {{t 'labels.actions'}}
              {{report.modifiedBy}} {{report.reportType}} - +
              From ac20a24bc7c4c807c213dacf837c0e3f2b14688b Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Fri, 3 Mar 2017 01:34:53 +0100 Subject: [PATCH 77/99] Display patient procedures on report --- app/locales/en/translations.js | 1 + app/mixins/patient-submodule.js | 11 ++++++++++ app/mixins/patient-visits.js | 31 +++++++++++++++++++++++++++- app/patients/edit/controller.js | 36 +++++++++------------------------ app/reports/edit/route.js | 2 +- app/reports/edit/template.hbs | 12 +++++++++++ 6 files changed, 64 insertions(+), 29 deletions(-) diff --git a/app/locales/en/translations.js b/app/locales/en/translations.js index 85923be6af..74f9563b3d 100644 --- a/app/locales/en/translations.js +++ b/app/locales/en/translations.js @@ -1120,6 +1120,7 @@ export default { primaryDiagnosis: 'Primary Diagnosis', secondaryDiagnosis: 'Secondary Diagnosis', procedures: 'Procedures', + allProcedures: 'All Procedures Performed', labs: 'Labs', images: 'Images', medications: 'Medications', diff --git a/app/mixins/patient-submodule.js b/app/mixins/patient-submodule.js index 28aaf94db4..e85c6f0eb4 100644 --- a/app/mixins/patient-submodule.js +++ b/app/mixins/patient-submodule.js @@ -185,6 +185,17 @@ export default Ember.Mixin.create(PatientVisits, { }); }.property('model.patient.id', 'newVisitAdded'), + patientProcedures: Ember.computed('patientVisits.[]', function() { + let patient = this.get('model.patient'); + return DS.PromiseArray.create({ + promise: this.get('patientVisits').then((patientVisits) => { + return patient.get('operationReports').then((operationReports) => { + return this._getPatientProcedures(operationReports, patientVisits); + }); + }) + }); + }), + patientVisitsForSelect: function() { return DS.PromiseArray.create({ promise: this.get('patientVisits').then(function(patientVisits) { diff --git a/app/mixins/patient-visits.js b/app/mixins/patient-visits.js index 4e93a6a12d..d5197ed910 100644 --- a/app/mixins/patient-visits.js +++ b/app/mixins/patient-visits.js @@ -4,7 +4,8 @@ import VisitStatus from 'hospitalrun/utils/visit-statuses'; import DS from 'ember-data'; import moment from 'moment'; const { - isEmpty + isEmpty, + get } = Ember; export default Ember.Mixin.create(PouchDbMixin, { @@ -51,6 +52,34 @@ export default Ember.Mixin.create(PouchDbMixin, { return (outPatient) ? DS.PromiseArray.create({ promise }) : DS.PromiseObject.create({ promise }); }, + _getVisitCollection(visits, name) { + let returnList = []; + if (!Ember.isEmpty(visits)) { + visits.forEach(function(visit) { + visit.get(name).then(function(items) { + returnList.addObjects(items); + }); + }); + } + return returnList; + }, + + _getPatientProcedures(operationReports, visits) { + let patientProcedures = this._getVisitCollection(visits, 'procedures'); + operationReports.forEach((report) => { + let reportedProcedures = get(report, 'procedures'); + let surgeryDate = get(report, 'surgeryDate'); + reportedProcedures.forEach((procedure) => { + patientProcedures.addObject({ + description: get(procedure, 'description'), + procedureDate: surgeryDate, + report + }); + }); + }); + return patientProcedures; + }, + checkoutVisit(visit, status) { visit.set('status', status); visit.set('endDate', new Date()); diff --git a/app/patients/edit/controller.js b/app/patients/edit/controller.js index 45e854b78b..df32d32e9a 100644 --- a/app/patients/edit/controller.js +++ b/app/patients/edit/controller.js @@ -8,13 +8,14 @@ import ReturnTo from 'hospitalrun/mixins/return-to'; import SelectValues from 'hospitalrun/utils/select-values'; import UserSession from 'hospitalrun/mixins/user-session'; import VisitStatus from 'hospitalrun/utils/visit-statuses'; +import PatientVisits from 'hospitalrun/mixins/patient-visits'; const { get, isEmpty } = Ember; -export default AbstractEditController.extend(BloodTypes, DiagnosisActions, ReturnTo, UserSession, PatientId, PatientNotes, { +export default AbstractEditController.extend(BloodTypes, DiagnosisActions, ReturnTo, UserSession, PatientId, PatientNotes, PatientVisits, { canAddAppointment: function() { return this.currentUserCan('add_appointment'); @@ -144,32 +145,21 @@ export default AbstractEditController.extend(BloodTypes, DiagnosisActions, Retur }], patientImaging: function() { - return this._getVisitCollection('imaging'); + return this.getVisitCollection('imaging'); }.property('model.visits.[].imaging'), patientLabs: function() { - return this._getVisitCollection('labs'); + return this.getVisitCollection('labs'); }.property('model.visits.[].labs'), patientMedications: function() { - return this._getVisitCollection('medication'); + return this.getVisitCollection('medication'); }.property('model.visits.[].medication'), patientProcedures: function() { - let patientProcedures = this._getVisitCollection('procedures'); + let visits = this.get('model.visits'); let operationReports = get(this, 'model.operationReports'); - operationReports.forEach((report) => { - let reportedProcedures = get(report, 'procedures'); - let surgeryDate = get(report, 'surgeryDate'); - reportedProcedures.forEach((procedure) => { - patientProcedures.addObject({ - description: get(procedure, 'description'), - procedureDate: surgeryDate, - report - }); - }); - }); - return patientProcedures; + return this._getPatientProcedures(operationReports, visits); }.property('model.visits.[].procedures', 'model.operationReports.[].procedures'), showExpenseTotal: function() { @@ -570,17 +560,9 @@ export default AbstractEditController.extend(BloodTypes, DiagnosisActions, Retur this.send('openModal', `patients.socialwork.${route}`, model); }, - _getVisitCollection(name) { - let returnList = []; + getVisitCollection(name) { let visits = this.get('model.visits'); - if (!Ember.isEmpty(visits)) { - visits.forEach(function(visit) { - visit.get(name).then(function(items) { - returnList.addObjects(items); - }); - }); - } - return returnList; + return this._getVisitCollection(visits, name); }, _updateSocialRecord(recordToUpdate, name) { diff --git a/app/reports/edit/route.js b/app/reports/edit/route.js index 636cd04cd1..5b00ddafce 100644 --- a/app/reports/edit/route.js +++ b/app/reports/edit/route.js @@ -1,7 +1,7 @@ import AbstractEditRoute from 'hospitalrun/routes/abstract-edit-route'; import AddToPatientRoute from 'hospitalrun/mixins/add-to-patient-route'; import Ember from 'ember'; -import {translationMacro as t} from 'ember-i18n'; +import { translationMacro as t } from 'ember-i18n'; import PatientVisits from 'hospitalrun/mixins/patient-visits'; export default AbstractEditRoute.extend(AddToPatientRoute, PatientVisits, { diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index f13ef25927..c22284fef0 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -147,6 +147,18 @@ }}
            + {{#if patientProcedures}} + +
              + {{#each patientProcedures as |procedure|}} +
            • {{procedure.description}} - + {{#if procedure.procedureDate }} + {{date-format procedure.procedureDate format="DD/MM/YYYY"}} + {{/if}}
            • + {{/each}} +
            + {{/if}} + {{#if visit.patientNotes}}
              From d4bbd83af830706fed9e62ea5be9ed5e68403505 Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Tue, 7 Mar 2017 09:28:07 +0100 Subject: [PATCH 78/99] Remove discharge report compulsory next appointment modal --- app/locales/en/translations.js | 2 -- app/visits/edit/controller.js | 28 ++++++++++------------------ app/visits/edit/route.js | 1 - 3 files changed, 10 insertions(+), 21 deletions(-) diff --git a/app/locales/en/translations.js b/app/locales/en/translations.js index 74f9563b3d..87c8762fd8 100644 --- a/app/locales/en/translations.js +++ b/app/locales/en/translations.js @@ -1105,7 +1105,6 @@ export default { }, reports: { titles: { - followup: 'Create Followup Appointment', saved: 'The report has been saved' }, form: { @@ -1147,7 +1146,6 @@ export default { } }, messages: { - followup: 'There is no follow up appointment for this patient.', delete: 'Are you sure you wish to delete this report?', saved: 'The report has been saved.' } diff --git a/app/visits/edit/controller.js b/app/visits/edit/controller.js index 0c1f1485c0..58ed40ff3f 100644 --- a/app/visits/edit/controller.js +++ b/app/visits/edit/controller.js @@ -37,7 +37,6 @@ 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')); }), @@ -406,6 +405,11 @@ export default AbstractEditController.extend(AddNewPatient, ChargeActions, Diagn } }, + editReport(report) { + report.set('returnToVisit', this.get('model.id')); + this.transitionToRoute('reports.edit', report); + }, + newPatientChanged(createNewPatient) { set(this, 'model.createNewPatient', createNewPatient); let model = this.get('model'); @@ -435,23 +439,6 @@ export default AbstractEditController.extend(AddNewPatient, ChargeActions, Diagn this.send('openModal', 'patients.notes', model); }, - 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'); - }, - - editReport(report) { - report.set('returnToVisit', this.get('model.id')); - this.transitionToRoute('reports.edit', report); - }, - newAppointment() { this._addChildObject('appointments.edit'); }, @@ -468,6 +455,11 @@ export default AbstractEditController.extend(AddNewPatient, ChargeActions, Diagn this._addChildObject('medication.edit'); }, + newReport() { + this._addChildObject('reports.edit'); + }, + + showAddProcedure() { this._addChildObject('procedures.edit'); }, diff --git a/app/visits/edit/route.js b/app/visits/edit/route.js index 9b6932b5e0..27700d5901 100644 --- a/app/visits/edit/route.js +++ b/app/visits/edit/route.js @@ -55,7 +55,6 @@ export default AbstractEditRoute.extend(ChargeRoute, PatientListRoute, PatientVi 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 f0ee0b384537d3f3bf4baaacf35084beb85a9ac6 Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Tue, 7 Mar 2017 09:46:54 +0100 Subject: [PATCH 79/99] Fix `completed by` on report page --- app/reports/edit/template.hbs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index c22284fef0..a7ec5840fa 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -184,13 +184,14 @@ {{custom-form-manager model=model formType="dischargeReport"}} -
              - - {{model.modifiedBy}} -
              + {{#if model.modifiedBy}} +
              + + {{model.modifiedBy}} +
              + {{/if}} {{/if}} - {{/em-form}} {{/edit-panel}}
          From c1f82b016d4fc918cd963481a379debc6f8be593 Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Tue, 7 Mar 2017 10:52:05 +0100 Subject: [PATCH 80/99] Style select element properly; Add titles to report --- app/locales/en/translations.js | 4 +++- app/reports/edit/template.hbs | 5 +++++ app/styles/_print.scss | 8 ++++++++ app/visits/edit/controller.js | 1 - 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/locales/en/translations.js b/app/locales/en/translations.js index 87c8762fd8..290fd5d9d4 100644 --- a/app/locales/en/translations.js +++ b/app/locales/en/translations.js @@ -1105,7 +1105,9 @@ export default { }, reports: { titles: { - saved: 'The report has been saved' + saved: 'Report saved', + opdTitle: 'OPD Report', + dischargeReport: 'Discharge Report' }, form: { visitDate: 'Date of Visit', diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index a7ec5840fa..1789130db3 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -14,6 +14,11 @@ {{#if headerLine3}} {{headerLine3}}
          {{/if}} + {{#if isOutPatient}} +

          {{t 'reports.titles.opdTitle' }}

          + {{else}} +

          {{t 'reports.titles.dischargeReport' }}

          + {{/if}}
        {{#edit-panel editPanelProps=editPanelProps}} diff --git a/app/styles/_print.scss b/app/styles/_print.scss index 67337bde3e..750c1e367c 100644 --- a/app/styles/_print.scss +++ b/app/styles/_print.scss @@ -50,6 +50,14 @@ font-size: .8em; } + .report select { + outline: 0; + border: 0; + text-overflow: ''; + -moz-appearance: none; + -webkit-appearance: none; + } + .report .panel-primary { position: absolute; left: 0; diff --git a/app/visits/edit/controller.js b/app/visits/edit/controller.js index 58ed40ff3f..b05c6cf017 100644 --- a/app/visits/edit/controller.js +++ b/app/visits/edit/controller.js @@ -459,7 +459,6 @@ export default AbstractEditController.extend(AddNewPatient, ChargeActions, Diagn this._addChildObject('reports.edit'); }, - showAddProcedure() { this._addChildObject('procedures.edit'); }, From ac35a25f6450b9a5c4f981af786caa8fc51f0c54 Mon Sep 17 00:00:00 2001 From: chima1707 Date: Tue, 7 Mar 2017 12:47:55 +0100 Subject: [PATCH 81/99] fix: fix new user title bug after a new user has been added --- app/users/edit/controller.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/users/edit/controller.js b/app/users/edit/controller.js index b2d0733f2e..84e472f01b 100644 --- a/app/users/edit/controller.js +++ b/app/users/edit/controller.js @@ -40,6 +40,10 @@ export default AbstractEditController.extend(UserRoles, { } updateModel.save().then(() => { this.displayAlert(this.get('i18n').t('messages.userSaved'), this.get('i18n').t('messages.userHasBeenSaved')); + let editTitle = this.get('i18n').t('labels.editUser'); + let sectionDetails = {}; + sectionDetails.currentScreenTitle = editTitle; + this.send('setSectionHeader', sectionDetails); }).catch((error) => this.send('error', error)); } } From 3241938c70227771a3a5276cdf0444da21b5904d Mon Sep 17 00:00:00 2001 From: Mofesola Babalola Date: Wed, 8 Mar 2017 15:06:59 +0100 Subject: [PATCH 82/99] Added deploy branches to .travis.yml --- .travis.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.travis.yml b/.travis.yml index e14b1b3076..82dc8deaa4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,5 +24,18 @@ deploy: tags: true repo: eHealthAfrica/hospitalrun-frontend branch: master + on: + tags: true + repo: eHealthAfrica/hospitalrun-frontend + branch: develop + on: + tags: true + repo: eHealthAfrica/hospitalrun-frontend + branch: stage + on: + tags: true + repo: eHealthAfrica/hospitalrun-frontend + branch: eHA/Polyclinic + after_deploy: - script/server_build.sh From b7bbbc711161de2a9a06c9f9fd4473c5ef262629 Mon Sep 17 00:00:00 2001 From: chima1707 Date: Thu, 9 Mar 2017 12:02:49 +0100 Subject: [PATCH 83/99] fix: fix test for new user title bug --- tests/acceptance/users-test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/acceptance/users-test.js b/tests/acceptance/users-test.js index d1105e6db1..00993a5929 100644 --- a/tests/acceptance/users-test.js +++ b/tests/acceptance/users-test.js @@ -119,6 +119,7 @@ test('create new user', function(assert) { waitToAppear('.modal-dialog'); andThen(() => { assert.equal(find('.modal-title').text(), 'User Saved', 'User was saved successfully'); + assert.equal(find('.view-current-title').text(), 'Edit User', 'Page title changed to Edit User'); }); click('button:contains(Ok)'); }); From 3d127823080461487b3fc916430071f9bc410234 Mon Sep 17 00:00:00 2001 From: chima1707 Date: Fri, 10 Mar 2017 11:48:24 +0100 Subject: [PATCH 84/99] fix: updated report template with testing attributes on fields --- app/reports/edit/template.hbs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index 1789130db3..78da867d8a 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -33,7 +33,7 @@ {{/if}}
        -