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

Commit

Permalink
Closes #518
Browse files Browse the repository at this point in the history
Added paymentState to visit — Fixes #464
Create an administrative screen where workflow rules can be toggled on/off Fixes #462
  • Loading branch information
soarez authored and jkleinsc committed Jul 7, 2016
1 parent b6f3402 commit 9831e20
Show file tree
Hide file tree
Showing 9 changed files with 175 additions and 2 deletions.
9 changes: 9 additions & 0 deletions app/admin/workflow/controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import AbstractEditController from 'hospitalrun/controllers/abstract-edit-controller';
export default AbstractEditController.extend({
hideCancelButton: true,
updateCapability: 'update_config',

afterUpdate: function() {
this.displayAlert(this.get('i18n').t('admin.workflow.titles.options_saved'), this.get('i18n').t('admin.workflow.messages.options_saved'));
}
});
24 changes: 24 additions & 0 deletions app/admin/workflow/route.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import AbstractEditRoute from 'hospitalrun/routes/abstract-edit-route';
import { translationMacro as t } from 'ember-i18n';
export default AbstractEditRoute.extend({
hideNewButton: true,
editTitle: t('admin.workflow.edit_title'),

model: function() {
var store = this.get('store');
return store.find('option', 'workflow_options').catch(function() {
// create a new workflow_option if none exists
return store.push(store.normalize('option', {
id: 'workflow_options',
value: {
admissionDeposit: false,
clinicPrepayment: false,
followupPrepayment: false,
outpatientLabPrepayment: false,
outpatientImagingPrepayment: false,
outpatientMedicationPrepayment: false
}
}));
});
}
});
14 changes: 14 additions & 0 deletions app/admin/workflow/template.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{#edit-panel editPanelProps=editPanelProps}}
<div class="panel panel-primary">
<div class="panel-body">
{{#em-form model=model submitButton=false }}
{{em-checkbox label=(t 'admin.workflow.admission_deposit_label') property="value.admissionDeposit"}}
{{em-checkbox label=(t 'admin.workflow.clinic_prepayment_label') property="value.clinicPrepayment"}}
{{em-checkbox label=(t 'admin.workflow.followup_prepayment_label') property="value.followupPrepayment"}}
{{em-checkbox label=(t 'admin.workflow.outpatient_lab_label') property="value.outpatientLabPrepayment"}}
{{em-checkbox label=(t 'admin.workflow.outpatient_imaging_label') property="value.outpatientImagingPrepayment"}}
{{em-checkbox label=(t 'admin.workflow.outpatient_medication_label') property="value.outpatientMedicationPrepayment"}}
{{/em-form}}
</div>
</div>
{{/edit-panel}}
23 changes: 22 additions & 1 deletion app/locales/en/translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ export default {
new_user: 'New User',
admitted_patients: 'Admitted Patients',
missed: 'Missed',
user_roles: 'User Roles'
user_roles: 'User Roles',
workflow: 'Workflow'
},
actions: {
logout: 'Logout',
Expand Down Expand Up @@ -230,6 +231,26 @@ export default {
titles: {
role_saved: 'Role Saved'
}
},
workflow: {
admission_deposit_label: 'Admission deposit required',
clinic_prepayment_label: 'Clinic prepayment required',
followup_prepayment_label: 'Followup prepayment required',
outpatient_lab_label: 'Outpatient Lab prepayment required',
outpatient_imaging_label: 'Outpatient Imaging prepayment required',
outpatient_medication_label: 'Outpatient Medication prepayment required',

titles: {
options_saved: 'Options Saved'
},
messages: {
options_saved: 'The workflow options have been saved'
},

new_title: 'Workflow Options',
edit_title: 'Workflow Options',
workflow_label: 'Workflow'

}
},
labels: {
Expand Down
6 changes: 6 additions & 0 deletions app/mixins/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,12 @@ export default Ember.Mixin.create({
iconClass: 'octicon-chevron-right',
route: 'admin.roles',
capability: 'user_roles'
},
{
title: 'Workflow',
iconClass: 'octicon-chevron-right',
route: 'admin.workflow',
capability: 'update_config'
}
]
}
Expand Down
19 changes: 18 additions & 1 deletion app/models/visit.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ function dateAcceptance(object) {
return false;
}

const PAYMENT_STATES = {
CLEAR: 'clear',
PENDING: 'pending'
};

function paymentStateAcceptance(object) {
return !Object.keys(PAYMENT_STATES)
.some((state) => PAYMENT_STATES[state] === object.get('paymentState'));
}

export default AbstractModel.extend({
additionalDiagnoses: DS.attr(), // Yes, the plural of diagnosis is diagnoses!
charges: DS.hasMany('proc-charge', {
Expand All @@ -40,6 +50,7 @@ export default AbstractModel.extend({
patient: DS.belongsTo('patient', {
async: false
}),
paymentState: DS.attr('string', { defaultValue: PAYMENT_STATES.PENDING }),
primaryDiagnosis: DS.attr('string'), // AKA admitting diagnosis
primaryBillingDiagnosis: DS.attr('string'), // AKA final diagnosis
primaryBillingDiagnosisId: DS.attr('string'),
Expand Down Expand Up @@ -88,7 +99,13 @@ export default AbstractModel.extend({
message: 'Please select an end date later than the start date'
}
},

paymentState: {
acceptance: {
accept: true,
if: paymentStateAcceptance
},
presence: true
},
startDate: {
acceptance: {
accept: true,
Expand Down
1 change: 1 addition & 0 deletions app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Router.map(function() {
});
this.route('roles');
this.route('query');
this.route('workflow');
});

this.route('appointments', {
Expand Down
41 changes: 41 additions & 0 deletions tests/acceptance/admin-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,44 @@ test('Update address options', function(assert) {
});
});

test('Update workflow options', function(assert) {
const selector = 'input[type=checkbox]';

runWithPouchDump('admin', function() {
authenticateUser();
visit('/admin/workflow');
andThen(() => {
assert.equal(currentURL(), '/admin/workflow', 'Correctly navigated to admin workflow');

setAllTo(false, () => {
visit('/admin/workflow');
andThen(() => {
setAllTo(true);
});
});
});
});

function setAllTo(checked, cb) {
Array.prototype.slice.call(document.querySelectorAll(selector)).forEach((node) => {
node.checked = checked;
});
click('button:contains(Update)');
andThen(() => {
waitToAppear('.modal-dialog');
andThen(() => {
assert.equal(find('.modal-title').text(), 'Options Saved', 'Workflow Options Saved');
verifyAll(checked);
if (cb) {
cb();
}
});
});
}

function verifyAll(checked) {
Array.prototype.slice.call(document.querySelectorAll(selector)).forEach((node) => {
assert.equal(node.checked, checked, 'Checkbox is ' + (checked ? 'checked' : 'unchecked'));
});
}
});
40 changes: 40 additions & 0 deletions tests/unit/models/visit-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import Ember from 'ember';
import { moduleForModel, test } from 'ember-qunit';

moduleForModel('visit', 'Unit | Model | visit', {
// Specify the other units that are required for this test.
needs: [
'ember-validations@validator:local/acceptance',
'ember-validations@validator:local/presence',
'model:procedure',
'model:imaging',
'model:lab',
'model:medication',
'model:patient',
'model:patient-note',
'model:proc-charge',
'model:vital',
'model:visit',
'service:validations'
]
});

test('paymentState', function(assert) {
let model = this.subject();

Ember.run(() => {
model.setProperties({
paymentState: 'bad value'
});
});
assert.equal(model.get('paymentState'), 'bad value');
assert.ok(model.errors.paymentState.length, 'there should errors');

Ember.run(() => {
model.setProperties({
paymentState: 'clear'
});
});
assert.equal(model.get('paymentState'), 'clear');
assert.ok(!model.errors.paymentState.length, 'there should be no error');
});

0 comments on commit 9831e20

Please sign in to comment.