This repository has been archived by the owner on Jan 9, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid inventory lookups when possible
This commit denormalizes medication information on medication and proc-charge records by making the relationship to inventory async and adding two additional properties to the medication and proc-charge models: medicationTitle (denormalized inventory name) and priceOfMedication(denormalized inventory price). Resolves #261
- Loading branch information
Showing
11 changed files
with
142 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import Ember from 'ember'; | ||
import DS from 'ember-data'; | ||
export default Ember.Mixin.create({ | ||
// Denormalized medication details so that inventory records do not need to be retrieved | ||
getMedicationName: function(inventoryAttribute) { | ||
let medicationTitle = this.get('medicationTitle'); | ||
if (!Ember.isEmpty(medicationTitle)) { | ||
return medicationTitle; | ||
} else { | ||
this.get(inventoryAttribute).then((inventoryItem) => { | ||
this.set('medicationTitle', inventoryItem.get('name')); | ||
}); | ||
} | ||
}, | ||
|
||
getMedicationPrice: function(inventoryAttribute) { | ||
let priceOfMedication = this.get('priceOfMedication'); | ||
if (!Ember.isEmpty(priceOfMedication)) { | ||
return priceOfMedication; | ||
} else { | ||
this.get(inventoryAttribute).then((inventoryItem) => { | ||
this.set('priceOfMedication', inventoryItem.get('price')); | ||
}); | ||
} | ||
}, | ||
|
||
getMedicationDetails: function(inventoryAttribute) { | ||
return new Ember.RSVP.Promise((resolve) => { | ||
let medicationTitle = this.get('medicationTitle'); | ||
let priceOfMedication = this.get('priceOfMedication'); | ||
if (!Ember.isEmpty(medicationTitle) && !Ember.isEmpty(priceOfMedication)) { | ||
resolve({ | ||
name: medicationTitle, | ||
price: priceOfMedication | ||
}); | ||
} else { | ||
this.get(inventoryAttribute).then((inventoryItem) => { | ||
resolve({ | ||
name: inventoryItem.get('name'), | ||
price: inventoryItem.get('price') | ||
}); | ||
}); | ||
} | ||
}); | ||
}, | ||
|
||
medicationTitle: DS.attr('string'), | ||
priceOfMedication: DS.attr('number') | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.