Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
Adding 'missed appointments' tab
Browse files Browse the repository at this point in the history
  • Loading branch information
pete-the-pete committed Apr 4, 2016
1 parent 5f4505d commit 133abd0
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 17 deletions.
20 changes: 20 additions & 0 deletions app/appointments/missed/controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import AbstractPagedController from 'hospitalrun/controllers/abstract-paged-controller';
import UserSession from 'hospitalrun/mixins/user-session';
export default AbstractPagedController.extend(UserSession, {
startKey: [],
canAddVisit: function() {
return this.currentUserCan('add_visit');
}.property(),

canEdit: function() {
// Add and edit are the same capability
return this.currentUserCan('add_appointment');
}.property(),

canDelete: function() {
return this.currentUserCan('delete_appointment');
}.property(),

sortProperties: ['startDate', 'endDate'],
sortAscending: true
});
8 changes: 8 additions & 0 deletions app/appointments/missed/route.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import AbstractIndexRoute from 'hospitalrun/routes/abstract-index-route';
import { translationMacro as t } from 'ember-i18n';

export default AbstractIndexRoute.extend({
editReturn: 'appointments.missed',
modelName: 'appointment',
pageTitle: t('appointments.missed')
});
16 changes: 16 additions & 0 deletions app/appointments/missed/template.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{#item-listing paginationProps=paginationProps }}
<table class="table">
<tr class="table-header">
<th>{{t 'labels.date'}}</th>
<th>{{t 'labels.name'}}</th>
<th>{{t 'labels.type'}}</th>
<th>{{t 'labels.location'}}</th>
<th>{{t 'labels.provider'}}</th>
<th>{{t 'labels.status'}}</th>
<th>{{t 'labels.actions'}}</th>
</tr>
{{#each model as |appointment|}}
{{partial 'appointments/item'}}
{{/each}}
</table>
{{/item-listing}}
1 change: 1 addition & 0 deletions app/locales/en/translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,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: {
Expand Down
6 changes: 6 additions & 0 deletions app/mixins/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,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' });
Expand Down
37 changes: 20 additions & 17 deletions tests/acceptance/appointments-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,22 @@ test('visiting /appointments', function(assert) {
});
});

test('visiting /appointments/missed', function(assert) {
runWithPouchDump('appointments', function() {
authenticateUser();
let shortFormat = 'l';
// create an apointmet scheduled in the past
let lastWeek = moment().subtract(7, 'days');
let sixDaysAgo = moment().subtract(6, 'days');
createAppointment(lastWeek.toDate(), sixDaysAgo.toDate());
visit('/appointments/missed');
andThen(function() {
assert.equal(currentURL(), '/appointments/missed');
findWithAssert(`.appointment-date:contains(${moment(lastWeek).format(shortFormat)} - ${moment(sixDaysAgo).format(shortFormat)})`);
});
});
});

test('Creating a new appointment', function(assert) {
runWithPouchDump('appointments', function() {
authenticateUser();
Expand All @@ -35,20 +51,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');
Expand Down Expand Up @@ -133,18 +136,18 @@ test('Delete an appointment', function(assert) {
});
});

function createAppointment() {
function createAppointment(startDate=(new Date()), endDate=(moment().add(1, 'day').toDate())) {
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');
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');
Expand Down
11 changes: 11 additions & 0 deletions tests/unit/appointments/missed/route-test.js
Original file line number Diff line number Diff line change
@@ -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);
});

0 comments on commit 133abd0

Please sign in to comment.