Skip to content

Commit

Permalink
fix: added next appointment and operative plans to opd form
Browse files Browse the repository at this point in the history
  • Loading branch information
Chima1707 committed Feb 6, 2017
1 parent d16bc06 commit bf614b5
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 5 deletions.
3 changes: 3 additions & 0 deletions app/helpers/date-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
41 changes: 39 additions & 2 deletions app/reports/edit/controller.js
Original file line number Diff line number Diff line change
@@ -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: [],
Expand All @@ -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: {
Expand Down
3 changes: 1 addition & 2 deletions app/reports/edit/route.js
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
91 changes: 90 additions & 1 deletion app/reports/edit/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,94 @@
disablePatientLink=model.isNew
}}
{{/if}}
{{#if model.visit.patient.displayPatientId}}
<div class="ps-info-group patient-name">
<label class="ps-info-label">Patient Id</label>
<input class="form-control" value={{model.visit.patient.displayPatientId}}>
</div>
{{/if}}
{{#if model.visit.patient.dateOfBirth}}
<div class="ps-info-group">
<label class="ps-info-label">Date Of Visit</label>
<input class="form-control" value={{date-format model.visit.startDate format="DD/MM/YYYY hh:mm a"}}>
</div>
{{/if}}

{{#if diagnosis.primary.length}}
<div class="ps-info-group">
<label class="ps-info-label">Primary Diagnosis</label>
<ul>
{{#each diagnosis.primary as |item|}}
<li>{{item.diagnosis}}</li>
{{/each}}
</ul>
</div>
{{/if}}

{{#if diagnosis.secondary.length}}
<div class="ps-info-group">
<label class="ps-info-label">Secondary Diagnosis</label>
<ul>
{{#each diagnosis.secondary as |item|}}
<li>{{item.diagnosis}}</li>
{{/each}}
</ul>
</div>
{{/if}}

{{#if model.visit.procedures.length}}
<div class="ps-info-group">
<label class="ps-info-label">Procedures</label>
<ul>
{{#each model.visit.procedures as |item|}}
<li>{{item.description}}</li>
{{/each}}
</ul>
</div>
{{/if}}

{{#if model.visit.labs.length}}
<div class="ps-info-group">
<label class="ps-info-label">Labs</label>
<ul>
{{#each model.visit.labs as |item|}}
<li>{{item.labType.name}}-{{item.result}} ({{item.status}})</li>
{{/each}}
</ul>
</div>
{{/if}}

{{#if model.visit.imaging.length}}
<div class="ps-info-group">
<label class="ps-info-label">Images</label>
<ul>
{{#each model.visit.imaging as |item|}}
<li>{{item.imagingType.name}}-{{item.result}} ({{item.status}})</li>
{{/each}}
</ul>
</div>
{{/if}}


{{#if nextAppointment}}
<div class="ps-info-group">
<label class="ps-info-label">Date Of Next Appointment</label>
<input class="form-control" value={{date-format nextAppointment format="DD/MM/YYYY hh:mm a"}}>
</div>
{{/if}}

{{#if model.visit.patient.operativePlans.length}}
<div class="ps-info-group">
<label class="ps-info-label">Operative Plans</label>
<ul>
{{#each model.visit.patient.operativePlans as |item|}}
{{#each item.procedures as |p|}}
<li>{{p.description}} ({{item.status}})</li>
{{/each}}
{{/each}}
</ul>
</div>
{{/if}}

{{/em-form}}
{{/edit-panel}}
{{/edit-panel}}

0 comments on commit bf614b5

Please sign in to comment.