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

Commit

Permalink
Deprecation fixes for medication
Browse files Browse the repository at this point in the history
  • Loading branch information
jkleinsc committed Oct 28, 2015
1 parent e837a3b commit 1ff3b5d
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 52 deletions.
2 changes: 0 additions & 2 deletions app/medication/delete/template.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{{#modal-dialog
hideCancelButton=hideCancelButton
hideUpdateButton=hideUpdateButton
isUpdateDisabled=isUpdateDisabled
title=title
updateButtonAction=updateButtonAction
Expand Down
52 changes: 26 additions & 26 deletions app/medication/edit/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,49 +8,50 @@ import PatientSubmodule from 'hospitalrun/mixins/patient-submodule';
import UserSession from 'hospitalrun/mixins/user-session';

export default AbstractEditController.extend(InventorySelection, FulfillRequest, InventoryLocations, PatientId, PatientSubmodule, UserSession, {
needs: ['medication'],
medicationController: Ember.inject.controller('medication'),
newPatientId: null,

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

canFulfill: function() {
return this.currentUserCan('fulfill_medication');
}.property(),

isFulfilled: function() {
var status = this.get('status');
var status = this.get('model.status');
return (status === 'Fulfilled');
}.property('status'),
}.property('model.status'),

isFulfilling: function() {
var canFulfill = this.get('canFulfill'),
isRequested = this.get('isRequested'),
fulfillRequest = this.get('shouldFulfillRequest'),
isRequested = this.get('model.isRequested'),
fulfillRequest = this.get('model.shouldFulfillRequest'),
isFulfilling = canFulfill && (isRequested || fulfillRequest);
this.get('model').set('isFulfilling', isFulfilling);
return isFulfilling;
}.property('canFulfill', 'isRequested', 'shouldFulfillRequest'),
}.property('canFulfill', 'model.isRequested', 'model.shouldFulfillRequest'),

isFulfilledOrRequested: function() {
return (this.get('isFulfilled') || this.get('isRequested'));
}.property('isFulfilled', 'isRequested'),
return (this.get('isFulfilled') || this.get('model.isRequested'));
}.property('isFulfilled', 'model.isRequested'),

prescriptionClass: function() {
var quantity = this.get('quantity');
var quantity = this.get('model.quantity');
this.get('model').validate().catch(Ember.K, 'Prescription validation');
if (Ember.isEmpty(quantity)) {
return 'required';
}
}.property('quantity'),
}.property('model.quantity'),

quantityClass: function() {
var prescription = this.get('prescription'),
var prescription = this.get('model.prescription'),
returnClass = 'col-xs-3',
isFulfilling = this.get('isFulfilling');
if (isFulfilling || Ember.isEmpty(prescription)) {
returnClass += ' required';
}
return returnClass;
}.property('isFulfilling', 'prescription'),
}.property('isFulfilling', 'model.prescription'),

quantityLabel: function() {
var returnLabel = 'Quantity Requested',
Expand All @@ -74,7 +75,7 @@ export default AbstractEditController.extend(InventorySelection, FulfillRequest,
if (isFulfilled) {
alertTitle = 'Medication Request Fulfilled';
alertMessage = 'The medication request has been fulfilled.';
this.set('selectPatient', false);
this.set('model.selectPatient', false);
} else {
alertTitle = 'Medication Request Saved';
alertMessage = 'The medication record has been saved.';
Expand All @@ -85,7 +86,7 @@ export default AbstractEditController.extend(InventorySelection, FulfillRequest,
_addNewPatient: function() {
this.displayAlert('Please Wait', 'A new patient needs to be created...Please wait..');
this._getNewPatientId().then(function(friendlyId) {
var patientTypeAhead = this.get('patientTypeAhead'),
var patientTypeAhead = this.get('model.patientTypeAhead'),
nameParts = patientTypeAhead.split(' '),
patientDetails = {
friendlyId: friendlyId,
Expand Down Expand Up @@ -124,7 +125,7 @@ export default AbstractEditController.extend(InventorySelection, FulfillRequest,

beforeUpdate: function() {
var isFulfilling = this.get('isFulfilling'),
isNew = this.get('isNew');
isNew = this.get('model.isNew');
if (isNew || isFulfilling) {
return new Ember.RSVP.Promise(function(resolve, reject) {
var newMedication = this.get('model');
Expand All @@ -135,7 +136,6 @@ export default AbstractEditController.extend(InventorySelection, FulfillRequest,
this._addNewPatient();
reject('creating new patient first');
} else {
this.set('newMedication', true);
newMedication.set('status', 'Requested');
newMedication.set('requestedBy', newMedication.getUserName());
newMedication.set('requestedDate', new Date());
Expand All @@ -162,19 +162,19 @@ export default AbstractEditController.extend(InventorySelection, FulfillRequest,

finishBeforeUpdate: function(isFulfilling, resolve) {
if (isFulfilling) {
var inventoryLocations = this.get('inventoryLocations'),
var inventoryLocations = this.get('model.inventoryLocations'),
inventoryRequest = this.get('store').createRecord('inv-request', {
expenseAccount: this.get('expenseAccount'),
expenseAccount: this.get('model.expenseAccount'),
dateCompleted: new Date(),
inventoryItem: this.get('inventoryItem'),
inventoryItem: this.get('model.inventoryItem'),
inventoryLocations: inventoryLocations,
quantity: this.get('quantity'),
quantity: this.get('model.quantity'),
transactionType: 'Fulfillment',
patient: this.get('patient'),
patient: this.get('model.patient'),
markAsConsumed: true
});
this.performFulfillRequest(inventoryRequest, false, false, true).then(function() {
this.set('status', 'Fulfilled');
this.set('model.status', 'Fulfilled');
resolve();
}.bind(this));
} else {
Expand All @@ -192,16 +192,16 @@ export default AbstractEditController.extend(InventorySelection, FulfillRequest,
}.property('updateCapability', 'isFulfilled'),

updateButtonText: function() {
if (this.get('hideFulfillRequest')) {
if (this.get('model.hideFulfillRequest')) {
return 'Dispense';
} else if (this.get('isFulfilling')) {
return 'Fulfill';
} else if (this.get('isNew')) {
} else if (this.get('model.isNew')) {
return 'Add';
} else {
return 'Update';
}
}.property('isNew', 'isFulfilling'),
}.property('model.isNew', 'isFulfilling', 'model.hideFulfillRequest'),

actions: {
addedNewPatient: function(record) {
Expand Down
32 changes: 16 additions & 16 deletions app/medication/edit/template.hbs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{{#edit-panel editPanelProps=editPanelProps}}
{{#em-form model=this submitButton=false }}
{{#unless selectPatient}}
{{patient-summary patient=model.patient returnTo='medication.edit' returnToContext=id disablePatientLink=isNew }}
{{#em-form model=model submitButton=false }}
{{#unless model.selectPatient}}
{{patient-summary patient=model.patient returnTo='medication.edit' returnToContext=model.id disablePatientLink=model.isNew }}
{{/unless}}
<div class="row">
{{#if selectPatient}}
{{#if model.selectPatient}}
{{patient-typeahead property="patientTypeAhead" label="Patient" content=patientList selection=selectedPatient class="col-xs-6 required"}}
{{/if}}
{{#if isNew}}
{{#if model.isNew}}
{{em-select class="col-xs-4 required" label="Visit"
property="visit" content=patientVisitsForSelect
optionValuePath="selectObject" optionLabelPath="selectObject.visitDescription"
prompt="--Add New Outpatient Visit--"
selected=visit
selected=model.visit
}}
{{else}}
<div class="form-group col-xs-3">
Expand All @@ -24,19 +24,19 @@
{{#if isFulfilledOrRequested}}
<div class="form-group">
<label class="control-label">Medication</label>
<p class="form-control-static">{{inventoryItem.name}}</p>
<p class="form-control-static">{{model.inventoryItem.name}}</p>
</div>
{{else}}
{{inventory-typeahead property="inventoryItemTypeAhead" label="Medication" content=medicationList selection=selectedInventoryItem class="required"}}
{{/if}}
{{#if isFulfilled}}
{{static-text label="Prescription" value=prescription }}
{{static-text label="Prescription" value=model.prescription }}
<div class="row">
{{#static-text label="Prescription Date" class="col-xs-4"}}
{{date-format prescriptionDate}}
{{date-format model.prescriptionDate}}
{{/static-text}}
{{static-text label=quantityLabel class="col-xs-3" value=quantity }}
{{static-text label="Refills" class="col-xs-3" value=refills }}
{{static-text label=quantityLabel class="col-xs-3" value=model.quantity }}
{{static-text label="Refills" class="col-xs-3" value=model.refills }}
</div>
{{else}}
{{em-text property="prescription" label="Prescription" rows="3" class=prescriptionClass }}
Expand All @@ -47,8 +47,8 @@
{{em-input property="quantity" label=quantityLabel class=quantityClass }}
{{em-input property="refills" label="Refills" class="col-xs-3"}}
</div>
{{#unless hideFulfillRequest}}
{{#if isNew}}
{{#unless model.hideFulfillRequest}}
{{#if model.isNew}}
{{#if canFulfill}}
<div class="form-group">
<label class="control-label">Fulfill Request</label>
Expand All @@ -58,9 +58,9 @@
{{/if}}
{{/unless}}
{{#if isFulfilling}}
{{select-or-typeahead property="expenseAccount" label="Bill To" list=expenseAccountList selection=expenseAccount }}
{{inventory-location-picker label="Pull From" quantityRequested=quantity
locationList=inventoryItem.availableLocations
{{select-or-typeahead property="expenseAccount" label="Bill To" list=expenseAccountList selection=model.expenseAccount }}
{{inventory-location-picker label="Pull From" quantityRequested=model.quantity
locationList= model.inventoryItem.availableLocations
selectedLocations=model.inventoryLocations
}}
{{/if}}
Expand Down
14 changes: 7 additions & 7 deletions app/medication/return/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,28 @@ import PatientSubmodule from 'hospitalrun/mixins/patient-submodule';
import SelectValues from 'hospitalrun/utils/select-values';

export default AbstractEditController.extend(FulfillRequest, InventoryLocations, InventorySelection, PatientSubmodule, {
needs: ['medication'],
medicationController: Ember.inject.controller('medication'),

lookupListsToUpdate: [{
name: 'aisleLocationList', // Name of property containing lookup list
property: 'aisleLocation', // Corresponding property on model that potentially contains a new value to add to the list
property: 'model.aisleLocation', // Corresponding property on model that potentially contains a new value to add to the list
id: 'aisle_location_list' // Id of the lookup list to update
}, {
name: 'expenseAccountList', // Name of property containing lookup list
property: 'expenseAccount', // Corresponding property on model that potentially contains a new value to add to the list
property: 'model.expenseAccount', // Corresponding property on model that potentially contains a new value to add to the list
id: 'expense_account_list' // Id of the lookup list to update
}, {
name: 'warehouseList', // Name of property containing lookup list
property: 'location', // Corresponding property on model that potentially contains a new value to add to the list
property: 'model.location', // Corresponding property on model that potentially contains a new value to add to the list
id: 'warehouse_list' // Id of the lookup list to update
}],

patientMedicationList: [],
setNewMedicationList: false,

aisleLocationList: Ember.computed.alias('controllers.medication.aisleLocationList'),
expenseAccountList: Ember.computed.alias('controllers.medication.expenseAccountList'),
warehouseList: Ember.computed.alias('controllers.medication.warehouseList'),
aisleLocationList: Ember.computed.alias('medicationController.aisleLocationList'),
expenseAccountList: Ember.computed.alias('medicationController.expenseAccountList'),
warehouseList: Ember.computed.alias('medicationController.warehouseList'),
updateCapability: 'add_medication',

medicationChanged: function() {
Expand Down
2 changes: 1 addition & 1 deletion app/medication/return/template.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{#edit-panel editPanelProps=editPanelProps}}
{{#em-form model=this submitButton=false }}
{{#em-form model=model submitButton=false }}
{{#if showPatientMedicationList}}
{{em-select class="required" label="Medication"
property="medication" content=patientMedication
Expand Down

0 comments on commit 1ff3b5d

Please sign in to comment.