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

First step at allergy work #786

Merged
merged 34 commits into from
Dec 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
e6a783a
added size for ES queries
donaldwasserman Oct 7, 2016
f86f7d7
undelete example config folder
donaldwasserman Oct 7, 2016
22335ef
oops
donaldwasserman Oct 7, 2016
9982bcb
update results to 25
donaldwasserman Oct 8, 2016
f7fa8dd
Merge branch 'master' of github.com:HospitalRun/hospitalrun-frontend …
donaldwasserman Oct 8, 2016
a7308a6
Merge branch 'master' of github.com:HospitalRun/hospitalrun-frontend
donaldwasserman Oct 10, 2016
fbd0986
actually make ajax request with correct data
donaldwasserman Oct 14, 2016
db3e24e
Merge branch 'master' of github.com:HospitalRun/hospitalrun-frontend
donaldwasserman Oct 14, 2016
266ff9f
Merge branch 'master' of github.com:HospitalRun/hospitalrun-frontend
donaldwasserman Oct 15, 2016
adad31d
learned that binding this works on promises too
donaldwasserman Oct 15, 2016
dd2ebda
added new line on config
donaldwasserman Oct 15, 2016
09a0eff
Merge branch 'master' of github.com:HospitalRun/hospitalrun-frontend …
donaldwasserman Oct 15, 2016
3bc01d3
Merge branch 'master' into feature/allergy_service
donaldwasserman Oct 15, 2016
ddcd3b7
merge add commits
donaldwasserman Nov 5, 2016
3ca5361
Merge branch 'master' of github.com:HospitalRun/hospitalrun-frontend …
donaldwasserman Nov 5, 2016
4bab7a7
added styling
donaldwasserman Nov 7, 2016
9bb784e
more updates to put some :meat_on_bone: for what I was thinking
donaldwasserman Nov 8, 2016
61b0e4f
refactoring allergy components
donaldwasserman Nov 23, 2016
a94042b
Merge branch 'master' of github.com:HospitalRun/hospitalrun-frontend …
donaldwasserman Nov 23, 2016
10ff6fa
Merge branch 'master' of github.com:HospitalRun/hospitalrun-frontend …
donaldwasserman Nov 29, 2016
aec2379
additional refactoring
donaldwasserman Nov 29, 2016
ed42be0
added translation strings, clean up various sloppiness
donaldwasserman Nov 30, 2016
e55d164
added tests, translations, misc cleanup
donaldwasserman Dec 1, 2016
be8f2ad
Merge branch 'master' of github.com:HospitalRun/hospitalrun-frontend …
donaldwasserman Dec 1, 2016
60860cc
fixed errors i thought didn't exist
donaldwasserman Dec 2, 2016
69fbb4b
uncommented out code
donaldwasserman Dec 2, 2016
95ceeaa
new layout changes
donaldwasserman Dec 9, 2016
e2766fe
Merge branch 'master' of github.com:HospitalRun/hospitalrun-frontend …
donaldwasserman Dec 9, 2016
930ac69
forgot to update html
donaldwasserman Dec 9, 2016
f5ffac3
Merge branch 'master' of github.com:HospitalRun/hospitalrun-frontend …
donaldwasserman Dec 9, 2016
19d0d3f
more changes
donaldwasserman Dec 9, 2016
38b1b48
fixed style issues
donaldwasserman Dec 9, 2016
c3a20b1
resolved conflicts
donaldwasserman Dec 16, 2016
86f02e5
one more update + updated tests
donaldwasserman Dec 16, 2016
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
85 changes: 85 additions & 0 deletions app/components/medication-allergy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import Ember from 'ember';
import { translationMacro as t } from 'ember-i18n';

export default Ember.Component.extend({
store: Ember.inject.service(),
i18n: Ember.inject.service(),
patient: null,
displayModal: false,
currentAllergy: false,
buttonConfirmText: t('buttons.add'),
additionalButtons: Ember.computed('currentAllergy', function() {
let currentAllergy = this.get('currentAllergy');
let btn = this.get('i18n').t('buttons.delete');
if (currentAllergy) {
return [{
class: 'btn btn-default warning',
buttonAction: 'deleteAllergy',
buttonIcon: 'octicon octicon-x',
buttonText: btn
}];
}
}),

modalTitle: Ember.computed('currentAllergy', function() {
let currentAllergy = this.get('currentAllergy');
let i18n = this.get('i18n');
if (currentAllergy) {
return i18n.t('allergies.editAllergy', { allergy: currentAllergy.get('name') });
} else {
return i18n.t('allergies.newAllergy');
}
}),

closeAllergyModal() {
this.set('currentAllergy', false);
this.set('displayModal', false);
},

actions: {

cancel() {
this.closeAllergyModal();
},

closeModal() {
this.closeAllergyModal();
},

editAllergy(allergy) {
this.set('currentAllergy', allergy);
this.set('displayModal', true);
},

createNewAllergy() {
this.set('displayModal', true);
},

updateAllergy() {
let model = this.get('patient');
let allergyModel = this.get('currentAllergy');
if (!allergyModel) {
allergyModel = this.get('store').createRecord('allergy', {
name: this.get('name')
});
allergyModel.save().then(() => {
model.get('allergies').pushObject(allergyModel);
model.save().then(() => {
this.set('name', '');
this.closeAllergyModal();
});
});
} else {
allergyModel.save().then(() => {
this.closeAllergyModal();
});
}
},
deleteAllergy() {
let allergy = this.get('currentAllergy');
allergy.destroyRecord().then(() => {
this.closeAllergyModal();
});
}
}
});
28 changes: 16 additions & 12 deletions app/components/patient-summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,39 @@ export default Ember.Component.extend(PatientDiagnosis, {
showPatientAction: 'showPatient',
visits: null,

havePrimaryDiagnoses: function() {
havePrimaryDiagnoses: Ember.computed('primaryDiagnosis.length', function() {
let primaryDiagnosesLength = this.get('primaryDiagnoses.length');
return (primaryDiagnosesLength > 0);
}.property('primaryDiagnoses.length'),
}),

haveProcedures: function() {
haveProcedures: Ember.computed('patientProcedures.length', function() {
let proceduresLength = this.get('patientProcedures.length');
return (proceduresLength > 0);
}.property('patientProcedures.length'),
}),

haveSecondaryDiagnoses: function() {
haveSecondaryDiagnoses: Ember.computed('secondaryDiagnoses.length', function() {
let secondaryDiagnosesLength = this.get('secondaryDiagnoses.length');
return (secondaryDiagnosesLength > 0);
}.property('secondaryDiagnoses.length'),
}),

primaryDiagnoses: function() {
primaryDiagnoses: Ember.computed('visits.[]', function() {
let visits = this.get('visits');
return this.getPrimaryDiagnoses(visits);
}.property('visits.[]'),
}),

secondaryDiagnoses: function() {
secondaryDiagnoses: Ember.computed('visits.[]', function() {
let visits = this.get('visits');
return this.getSecondaryDiagnoses(visits);
}.property('visits.[]'),
}),

shouldLinkToPatient: function() {
shouldLinkToPatient: Ember.computed('disablePatientLink', function() {
let disablePatientLink = this.get('disablePatientLink');
return !disablePatientLink;
}.property('disablePatientLink'),
}),

hasAllergies: Ember.computed('patient.allergies.[]', function() {
return Ember.computed.notEmpty('patient.allergies');
}),

actions: {
linkToPatient() {
Expand Down
12 changes: 11 additions & 1 deletion app/locales/en/translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,10 @@ export default {
addVisit: 'Add Visit',
search: 'Search',
edit: 'Edit',
addLineItem: 'Add Line Item'
addLineItem: 'Add Line Item',
addNewAllergy: 'Add New Allergy',
showFewer: 'Show Fewer',
showAll: 'Show All'
},
login: {
messages: {
Expand Down Expand Up @@ -1007,5 +1010,12 @@ export default {
priceList: {
charges: '{{pricingType}} charges'
}
},
allergies: {
addAllergy: 'Add Allergy',
allergyName: 'Name',
editAllergy: 'Edit {{allergy}}',
newAllergy: 'Add New Allergy',
patientAllergy: 'Patient Allergies'
}
};
1 change: 0 additions & 1 deletion app/medication/edit/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import UserSession from 'hospitalrun/mixins/user-session';
export default AbstractEditController.extend(InventorySelection, FulfillRequest, InventoryLocations, PatientId, PatientSubmodule, UserSession, {
medicationController: Ember.inject.controller('medication'),
newPatientId: null,

expenseAccountList: Ember.computed.alias('medicationController.expenseAccountList'),

canFulfill: function() {
Expand Down
7 changes: 7 additions & 0 deletions app/medication/edit/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@
</div>
{{/if}}
</div>
{{#if model.patient.allergies}}
<div class="row">
<div class="col-xs-12">
{{medication-allergy patient=model.patient}}
</div>
</div>
{{/if}}
{{#if isFulfilledOrRequested}}
<div class="form-group">
<label class="control-label">{{t 'labels.medication'}}</label>
Expand Down
3 changes: 2 additions & 1 deletion app/mixins/medication-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,6 @@ export default Ember.Mixin.create({
},

medicationTitle: DS.attr('string'),
priceOfMedication: DS.attr('number')
priceOfMedication: DS.attr('number'),
rxNormIdentifier: DS.attr('string')
});
3 changes: 2 additions & 1 deletion app/models/allergy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import AbstractModel from 'hospitalrun/models/abstract';
import DS from 'ember-data';

export default AbstractModel.extend({
description: DS.attr('string'),
patient: DS.belongsTo('patient'),
name: DS.attr('string'),
icd9CMCode: DS.attr('string'),
icd10Code: DS.attr('string')
});
39 changes: 39 additions & 0 deletions app/templates/components/medication-allergy.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<label class="ps-info-label wide">{{t 'allergies.patientAllergy'}}</label>

<a class="clickable" {{action "createNewAllergy"}}><span class="octicon octicon-plus"></span> {{t 'buttons.addNewAllergy'}}</a>

<div class="ps-info-data-block">
<ul class="list-inline allergy-list">
{{#each patient.allergies as |allergy index|}}
<li>
<button class="btn-link allergy-button" {{action "editAllergy" allergy}}>{{allergy.name}}</button>
</li>
{{/each}}
</ul>
</div>



{{#if displayModal}}
{{#modal-dialog
title=modalTitle
updateButtonText=buttonConfirmText
hideCancelButton=true
updateButtonAction='updateAllergy'
additionalButtons=additionalButtons
}}

<div class="row">
<div class="col-xs-12 form-group">
<label>{{t "allergies.allergyName"}}</label>
{{#if currentAllergy}}
{{input class="form-control" value=currentAllergy.name}}
{{else}}
{{input class="form-control" value=name}}
{{/if}}
</div>

</div>

{{/modal-dialog}}
{{/if}}
8 changes: 7 additions & 1 deletion app/templates/components/patient-summary.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<span class="ps-info-data">{{patient.age}} (<strong>{{date-format patient.dateOfBirth}}</strong>)</span>
</div>


{{#if havePrimaryDiagnoses}}
<div class="ps-info-group long-form">
<label class="ps-info-label wide">{{t 'patients.labels.primaryDiagnosis'}}</label>
Expand Down Expand Up @@ -59,4 +58,11 @@
</div>
{{/if}}

{{#if hasAllergies}}
<div class="ps-info-group long-form">
{{medication-allergy patient=patient}}
</div>
{{/if}}


</div>
2 changes: 2 additions & 0 deletions app/visits/edit/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,14 @@
{{/each}}
</table>
{{/if}}
{{medication-allergy patient=model.patient showOperations=true}}
{{em-text label="Patient History" property="history" rows=3 }}
{{em-text label="History since last seen" property="historySince" rows=3 }}
{{/em-form}}
</div>
</div>
</div>

{{#unless model.isNew}}
<div class="panel">
<div class="panel-heading">
Expand Down
27 changes: 27 additions & 0 deletions tests/integration/components/medication-allergy-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
import Ember from 'ember';

const Patient = Ember.Object.extend({ allergies: [] });
let patient = Patient.create();
const Allergy = Ember.Object.extend();
let allergy = Allergy.create({ name: 'test allergy' });

moduleForComponent('medication-allergy', 'Integration | Component | medication allergy', {
integration: true,
beforeEach() {
this.inject.service('i18n');
}
});

test('allergy component renders with appropriate data', function(assert) {
patient.get('allergies').pushObject(allergy);
// Set any properties with this.set('myProperty', 'value');
// Handle any actions with this.on('myAction', function(val) { ... });
this.set('patient', patient);
this.render(hbs`{{medication-allergy patient=patient}}`);
let allergyName = allergy.get('name');
let allergies = patient.get('allergies');
assert.equal(this.$('.allergy-list li').length, allergies.length, 'renders allergy list with correct list of elements');
assert.equal(this.$('.allergy-list li').first().text().trim(), allergyName, 'renders allergy names on buttons');
});