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

Adding 'missed appointments' tab #402

Merged
merged 1 commit into from
May 4, 2016
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
2 changes: 1 addition & 1 deletion app/appointments/item/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<td>{{appointment.appointmentType}}</td>
<td>{{appointment.location}}</td>
<td>{{appointment.provider}}</td>
<td>{{appointment.displayStatus}}</td>
<td class="appointment-status">{{appointment.displayStatus}}</td>
<td>
{{#if canAddVisit}}
<button class="btn btn-default" {{action 'createVisit' appointment bubbles=false }}>{{t 'buttons.add_visit'}}</button>
Expand Down
4 changes: 4 additions & 0 deletions app/appointments/missed/controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import AppointmentIndexController from 'hospitalrun/appointments/index/controller';
export default AppointmentIndexController.extend({
startKey: []
});
17 changes: 17 additions & 0 deletions app/appointments/missed/route.js
Original file line number Diff line number Diff line change
@@ -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;
}
});
1 change: 1 addition & 0 deletions app/appointments/missed/template.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{partial 'appointments/index'}}
1 change: 1 addition & 0 deletions app/locales/en/translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
3 changes: 2 additions & 1 deletion app/mixins/appointment-statuses.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),

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/models/appointment.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
1 change: 1 addition & 0 deletions app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' });
Expand Down
39 changes: 22 additions & 17 deletions tests/acceptance/appointments-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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');
Expand Down Expand Up @@ -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');
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);
});