Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/next appointment #25

Merged
merged 5 commits into from
Mar 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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