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

Fix/add allergy bug #1038

Closed
11 changes: 11 additions & 0 deletions app/components/medication-allergy.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default Ember.Component.extend({
patient: null,
displayModal: false,
currentAllergy: false,
parentProps: null,

buttonConfirmText: computed('currentAllergy', function() {
let i18n = this.get('i18n');
Expand Down Expand Up @@ -55,9 +56,17 @@ export default Ember.Component.extend({
}
}),

setStayOnPage(val) {
let props = this.get('parentProps');
if (props) {
props.stayOnPage = val;
}
},

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

actions: {
Expand All @@ -73,10 +82,12 @@ export default Ember.Component.extend({
editAllergy(allergy) {
this.set('currentAllergy', allergy);
this.set('displayModal', true);
this.setStayOnPage(true);
},

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

updateAllergy() {
Expand Down
4 changes: 3 additions & 1 deletion app/components/patient-summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default Ember.Component.extend(UserSession, {
hideInActiveDiagnoses: true,
patient: null,
patientProcedures: null,
props: {},
showAddDiagnosisAction: 'showAddDiagnosis',
showPatientAction: 'showPatient',

Expand Down Expand Up @@ -76,7 +77,8 @@ export default Ember.Component.extend(UserSession, {

linkToPatient() {
let shouldLink = this.get('shouldLinkToPatient');
if (shouldLink) {
let stayOnPage = this.get('props.stayOnPage');
if (shouldLink && !stayOnPage) {
let patient = this.get('patient');
let returnTo = this.get('returnTo');
let returnToContext = this.get('returnToContext');
Expand Down
4 changes: 2 additions & 2 deletions app/templates/components/medication-allergy.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
<div class="col-xs-12 form-group">
<label>{{t "allergies.labels.allergyName"}}</label>
{{#if currentAllergy}}
{{input class="form-control" value=currentAllergy.name}}
{{input class="form-control allergy-text" value=currentAllergy.name}}
{{else}}
{{input class="form-control" value=name}}
{{input class="form-control allergy-text" value=name}}
{{/if}}
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/templates/components/patient-summary.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
</div>
{{/if}}

{{medication-allergy patient=patient canAddAllergy=canAddAllergy}}
{{medication-allergy patient=patient canAddAllergy=canAddAllergy parentProps=props}}

{{#if canAddOperativePlan}}
<div class="ps-info-group long-form">
Expand Down
11 changes: 11 additions & 0 deletions tests/acceptance/visit-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,17 @@ test('Edit visit', function(assert) {
});
andThen(function() {
assert.equal(find('a.primary-diagnosis:contains(Broken Arm)').length, 1, 'New primary diagnosis appears');
click('a:contains(Add Allergy)');
waitToAppear('.modal-dialog');
});
andThen(function() {
assert.equal(find('.modal-title').text(), 'Add Allergy', 'Add Allergy dialog displays');
fillIn('input.allergy-text', 'Quinine');
click('.modal-footer button:contains(Add)');
waitToAppear('a.primary-diagnosis');
});
andThen(function() {
assert.equal(find('a.allergy-button:contains(Quinine)').length, 1, 'New allergy appears');
click('button:contains(New Medication)');
});
andThen(function() {
Expand Down