Skip to content

Commit

Permalink
Merge pull request #25 from eHealthAfrica/feat/nextAppointment
Browse files Browse the repository at this point in the history
Feat/next appointment
  • Loading branch information
adeolabadmus authored Mar 2, 2017
2 parents 3314ee2 + 9765327 commit 6ce8d23
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 14 deletions.
3 changes: 2 additions & 1 deletion app/locales/en/translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
15 changes: 10 additions & 5 deletions app/mixins/patient-visits.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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) {
Expand Down
6 changes: 4 additions & 2 deletions app/reports/edit/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 {
Expand Down
38 changes: 32 additions & 6 deletions app/reports/edit/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,38 @@
</div>
{{/if}}

{{#if nextAppointment}}
<div class="ps-info-group">
<label class="ps-info-label">{{t 'reports.form.nextAppointmentDate' }}:</label>
{{date-format nextAppointment format="DD/MM/YYYY hh:mm a"}}
</div>
{{/if}}
{{#if model.visit.outPatient}}
{{#if nextAppointments.length}}
<div class="ps-info-group">
<label class="ps-info-label">{{t 'reports.form.nextAppointments' }}</label>
<ul>
{{#each nextAppointments as |appointment|}}
<li>
{{date-format appointment.startDate format="DD/MM/YYYY hh:mm a"}}
{{#if appointment.appointmentType}}
(<b>{{appointment.appointmentType}}</b>)
{{/if}}
</li>
{{/each}}
</ul>
</div>
{{/if}}

{{else}}

{{#if nextAppointment}}
<div class="ps-info-group">
<label class="ps-info-label">{{t 'reports.form.nextAppointment' }}:</label>
{{date-format nextAppointment.startDate format="DD/MM/YYYY hh:mm a"}}
{{#if nextAppointment.location}}
({{nextAppointment.location}})
{{/if}}
</div>
{{/if}}

{{/if}}



{{#if model.visit.patient.operativePlans.length}}
<div class="ps-info-group">
Expand Down

0 comments on commit 6ce8d23

Please sign in to comment.