From d5f8f16bd1fe3507db7801a8bb72a9f87033191d Mon Sep 17 00:00:00 2001 From: pete_the_pete Date: Sun, 3 Apr 2016 17:07:33 -0700 Subject: [PATCH] Adding 'missed appointments' tab --- app/appointments/item/template.hbs | 2 +- app/appointments/missed/controller.js | 4 ++ app/appointments/missed/route.js | 17 +++++++++ app/appointments/missed/template.hbs | 1 + app/locales/en/translations.js | 1 + app/mixins/appointment-statuses.js | 3 +- app/mixins/navigation.js | 6 +++ app/models/appointment.js | 1 + app/router.js | 1 + tests/acceptance/appointments-test.js | 39 +++++++++++--------- tests/unit/appointments/missed/route-test.js | 11 ++++++ 11 files changed, 67 insertions(+), 19 deletions(-) create mode 100644 app/appointments/missed/controller.js create mode 100644 app/appointments/missed/route.js create mode 100644 app/appointments/missed/template.hbs create mode 100644 tests/unit/appointments/missed/route-test.js diff --git a/app/appointments/item/template.hbs b/app/appointments/item/template.hbs index f8d4487102..dcc23237f6 100644 --- a/app/appointments/item/template.hbs +++ b/app/appointments/item/template.hbs @@ -6,7 +6,7 @@ {{appointment.appointmentType}} {{appointment.location}} {{appointment.provider}} - {{appointment.displayStatus}} + {{appointment.displayStatus}} {{#if canAddVisit}} diff --git a/app/appointments/missed/controller.js b/app/appointments/missed/controller.js new file mode 100644 index 0000000000..22d6d2128f --- /dev/null +++ b/app/appointments/missed/controller.js @@ -0,0 +1,4 @@ +import AppointmentIndexController from 'hospitalrun/appointments/index/controller'; +export default AppointmentIndexController.extend({ + startKey: [] +}); \ No newline at end of file diff --git a/app/appointments/missed/route.js b/app/appointments/missed/route.js new file mode 100644 index 0000000000..2c57ce8c4b --- /dev/null +++ b/app/appointments/missed/route.js @@ -0,0 +1,17 @@ +import AppointmentIndexRoute from 'hospitalrun/appointments/index/route'; +import { translationMacro as t } from 'ember-i18n'; + +export default AppointmentIndexRoute.extend({ + editReturn: 'appointments.missed', + modelName: 'appointment', + pageTitle: t('appointments.missed'), + + _modelQueryParams() { + let queryParams = this._super(...arguments); + queryParams.filterBy = [{ + name: 'status', + value: 'Missed' + }]; + return queryParams; + } +}); \ No newline at end of file diff --git a/app/appointments/missed/template.hbs b/app/appointments/missed/template.hbs new file mode 100644 index 0000000000..e8aa599df1 --- /dev/null +++ b/app/appointments/missed/template.hbs @@ -0,0 +1 @@ +{{partial 'appointments/index'}} diff --git a/app/locales/en/translations.js b/app/locales/en/translations.js index 1be4b84254..4b95f3a29d 100644 --- a/app/locales/en/translations.js +++ b/app/locales/en/translations.js @@ -580,6 +580,7 @@ export default { new_title: 'New Appointment', section_title: 'Appointments', this_week: 'Appointments This Week', + missed: 'Missed Appointments', search_title: 'Search Appointments', today_title: 'Today\'s Appointments', messages: { diff --git a/app/mixins/appointment-statuses.js b/app/mixins/appointment-statuses.js index 3f6461963e..6f3ae79161 100644 --- a/app/mixins/appointment-statuses.js +++ b/app/mixins/appointment-statuses.js @@ -3,7 +3,8 @@ import SelectValues from 'hospitalrun/utils/select-values'; export default Ember.Mixin.create({ appointmentStatusList: [ 'Scheduled', - 'Canceled' + 'Canceled', + 'Missed' ], appointmentStatuses: Ember.computed.map('appointmentStatusList', SelectValues.selectValuesMap), diff --git a/app/mixins/navigation.js b/app/mixins/navigation.js index 78942f43f2..34fd3fbe6d 100644 --- a/app/mixins/navigation.js +++ b/app/mixins/navigation.js @@ -88,6 +88,12 @@ export default Ember.Mixin.create({ route: 'appointments.today', capability: 'appointments' }, + { + title: 'Missed', + iconClass: 'octicon-chevron-right', + route: 'appointments.missed', + capability: 'appointments' + }, { title: 'Search', iconClass: 'octicon-search', diff --git a/app/models/appointment.js b/app/models/appointment.js index 300611c91c..2941863c96 100644 --- a/app/models/appointment.js +++ b/app/models/appointment.js @@ -8,6 +8,7 @@ export default AbstractModel.extend({ patient: DS.belongsTo('patient', { async: false }), + visits: DS.hasMany('visit'), provider: DS.attr('string'), location: DS.attr('string'), appointmentType: DS.attr('string'), diff --git a/app/router.js b/app/router.js index 60ea72d49b..824d8e0b3f 100755 --- a/app/router.js +++ b/app/router.js @@ -27,6 +27,7 @@ Router.map(function() { this.route('edit', { path: '/edit/:appointment_id' }); this.route('search'); this.route('today'); + this.route('missed'); }); this.route('finishgauth', { path: '/finishgauth/:s1/:s2/:k/:t/:i/:p' }); diff --git a/tests/acceptance/appointments-test.js b/tests/acceptance/appointments-test.js index 3b66d62975..4b9c258387 100644 --- a/tests/acceptance/appointments-test.js +++ b/tests/acceptance/appointments-test.js @@ -24,6 +24,23 @@ test('visiting /appointments', function(assert) { }); }); +test('visiting /appointments/missed', function(assert) { + runWithPouchDump('appointments', function() { + authenticateUser(); + let url = '/appointments'; + // create an apointmet scheduled in the past + let today = moment(); + let tomorrow = moment().add(1, 'days'); + let status = 'Missed'; + createAppointment(today, tomorrow, status); + visit(url); + andThen(function() { + assert.equal(currentURL(), url); + findWithAssert(`.appointment-status:contains(${status})`); + }); + }); +}); + test('Creating a new appointment', function(assert) { runWithPouchDump('appointments', function() { authenticateUser(); @@ -35,20 +52,7 @@ test('Creating a new appointment', function(assert) { findWithAssert('button:contains(Add)'); }); - fillIn('.test-patient-input .tt-input', 'Lennex Zinyando - P00017'); - triggerEvent('.test-patient-input .tt-input', 'input'); - triggerEvent('.test-patient-input .tt-input', 'blur'); - select('.test-appointment-type', 'Followup'); - waitToAppear('.test-appointment-date input'); - andThen(function() { - selectDate('.test-appointment-date input', new Date()); - }); - fillIn('.test-appointment-location .tt-input', 'Harare'); - triggerEvent('.test-appointment-location .tt-input', 'input'); - triggerEvent('.test-appointment-location .tt-input', 'blur'); - fillIn('.test-appointment-with', 'Dr Test'); - click('button:contains(Add)'); - waitToAppear('.table-header'); + createAppointment(); andThen(() => { assert.equal(currentURL(), '/appointments'); @@ -133,18 +137,19 @@ test('Delete an appointment', function(assert) { }); }); -function createAppointment() { +function createAppointment(startDate=(new Date()), endDate=(moment().add(1, 'day').toDate()), status='Scheduled') { visit('/appointments/edit/new'); fillIn('.test-patient-input .tt-input', 'Lennex Zinyando - P00017'); triggerEvent('.test-patient-input .tt-input', 'input'); triggerEvent('.test-patient-input .tt-input', 'blur'); select('.test-appointment-type', 'Admission'); + select('.test-appointment-status', status); waitToAppear('.test-appointment-start input'); andThen(function() { - selectDate('.test-appointment-start input', new Date()); + selectDate('.test-appointment-start input', startDate); }); andThen(function() { - selectDate('.test-appointment-end input', moment().add(1, 'day').toDate()); + selectDate('.test-appointment-end input', endDate); }); fillIn('.test-appointment-location .tt-input', 'Harare'); triggerEvent('.test-appointment-location .tt-input', 'input'); diff --git a/tests/unit/appointments/missed/route-test.js b/tests/unit/appointments/missed/route-test.js new file mode 100644 index 0000000000..c1f28bc024 --- /dev/null +++ b/tests/unit/appointments/missed/route-test.js @@ -0,0 +1,11 @@ +import { moduleFor, test } from 'ember-qunit'; + +moduleFor('route:appointments/missed', 'Unit | Route | appointments/missed', { + // Specify the other units that are required for this test. + // needs: ['controller:foo'] +}); + +test('it exists', function(assert) { + let route = this.subject(); + assert.ok(route); +});