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

Commit

Permalink
Finished medication deprecations
Browse files Browse the repository at this point in the history
Resolves #187
  • Loading branch information
jkleinsc committed Oct 29, 2015
1 parent c421401 commit 2e0c1bf
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
33 changes: 17 additions & 16 deletions app/medication/return/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import SelectValues from 'hospitalrun/utils/select-values';

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

lookupListsToUpdate: [{
name: 'aisleLocationList', // Name of property containing lookup list
Expand All @@ -32,23 +33,23 @@ export default AbstractEditController.extend(FulfillRequest, InventoryLocations,
updateCapability: 'add_medication',

medicationChanged: function() {
var medication = this.get('medication');
var medication = this.get('model.medication');
if (!Ember.isEmpty(medication)) {
var inventoryItem = medication.get('inventoryItem');
this.set('inventoryItemTypeAhead', '%@ - %@'.fmt(inventoryItem.get('name'), inventoryItem.get('friendlyId')));
this.set('inventoryItem', inventoryItem);
this.set('model.inventoryItemTypeAhead', '%@ - %@'.fmt(inventoryItem.get('name'), inventoryItem.get('friendlyId')));
this.set('model.inventoryItem', inventoryItem);
} else {
this.set('inventoryItem');
this.set('model.inventoryItem');
}
Ember.run.later(function() {
this.get('model').validate().catch(Ember.K);
}.bind(this));
}.observes('medication'),
}.observes('model.medication'),

patientVisitsChanged: function() {
var patientVisits = this.get('patientVisits');
if (!Ember.isEmpty(patientVisits)) {
this.set('visit', patientVisits.get('firstObject'));
this.set('model.visit', patientVisits.get('firstObject'));
}
}.observes('patientVisits'),

Expand All @@ -66,7 +67,7 @@ export default AbstractEditController.extend(FulfillRequest, InventoryLocations,
} else if (!Ember.isEmpty(visit)) {
visit.get('medication').then(function(medication) {
medication = medication.filterBy('status', 'Fulfilled');
this.set('medication', medication.get('firstObject'));
this.set('model.medication', medication.get('firstObject'));
this.set('patientMedicationList', medication.map(SelectValues.selectObjectMap));
this.set('setNewMedicationList', true);
}.bind(this));
Expand All @@ -75,17 +76,17 @@ export default AbstractEditController.extend(FulfillRequest, InventoryLocations,
}.property('setNewMedicationList', 'model.patient', 'model.visit'),

_finishUpdate: function() {
var aisle = this.get('deliveryAisle'),
location = this.get('deliveryLocation'),
inventoryItem = this.get('inventoryItem');
var aisle = this.get('model.deliveryAisle'),
location = this.get('model.deliveryLocation'),
inventoryItem = this.get('model.inventoryItem');

// find location on inventoryItem
this._findOrCreateLocation(inventoryItem, location, aisle).then(function(inventoryLocation) {
this.set('adjustPurchases', true);
this.set('inventoryLocations', [inventoryLocation]);
this.set('markAsConsumed', true);
this.set('model.adjustPurchases', true);
this.set('model.inventoryLocations', [inventoryLocation]);
this.set('model.markAsConsumed', true);
// Make sure inventory item is resolved first.
this.get('inventoryItem').then(function() {
this.get('model.inventoryItem').then(function() {
this.send('fulfillRequest', this.get('model'), false, true, true);
}.bind(this));
}.bind(this));
Expand All @@ -97,8 +98,8 @@ export default AbstractEditController.extend(FulfillRequest, InventoryLocations,
this.displayAlert('Medication Returned', 'The medication has been marked as returned.', 'allItems');
},
update: function() {
var medication = this.get('medication'),
quantity = this.get('quantity');
var medication = this.get('model.medication'),
quantity = this.get('model.quantity');
if (!Ember.isEmpty(medication)) {
medication.reload().then(function() {
medication.decrementProperty('quantity', quantity);
Expand Down
8 changes: 4 additions & 4 deletions app/medication/return/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{{em-select class="required" label="Medication"
property="medication" content=patientMedication
optionValuePath="selectObject" optionLabelPath="selectObject.inventoryItem.name"
selected=medication
selected=model.medication
}}
{{else}}
{{inventory-typeahead property="inventoryItemTypeAhead" label="Medication" content=medicationList selection=selectedInventoryItem class="required" showQuantity=false }}
Expand All @@ -19,13 +19,13 @@
</div>
<div class="row">
{{em-input property="quantity" label="Quantity To Return" class="col-xs-3 required"}}
{{select-or-typeahead property="deliveryLocation" label="Return Location" list=warehouseList selection=location className="col-xs-4"}}
{{select-or-typeahead property="deliveryAisle" label="Return Aisle" list=aisleLocationList selection=aisleLocation className="col-xs-4"}}
{{select-or-typeahead property="deliveryLocation" label="Return Location" list=warehouseList selection=model.location className="col-xs-4"}}
{{select-or-typeahead property="deliveryAisle" label="Return Aisle" list=aisleLocationList selection=model.aisleLocation className="col-xs-4"}}
</div>
{{em-text property="reason" label="Return Reason/Notes" rows="3"}}
<div class="row">
{{date-picker property="dateCompleted" label="Adjustment Date" class="col-sm-4"}}
{{select-or-typeahead property="expenseAccount" label="Credit To Account" list=expenseAccountList selection=expenseAccount className="col-sm-8"}}
{{select-or-typeahead property="expenseAccount" label="Credit To Account" list=expenseAccountList selection=model.expenseAccount className="col-sm-8"}}
</div>
{{/em-form}}
{{/edit-panel}}

0 comments on commit 2e0c1bf

Please sign in to comment.