Class: Formulary::QuantityLimitDetailExtensionFactory
- Inherits:
-
Object
- Object
- Formulary::QuantityLimitDetailExtensionFactory
- Defined in:
- lib/formulary/quantity_limit_detail_extension_factory.rb
Overview
Class to build the FHIR extensions for the quantity limit detail field of the the formulary item profile (Basic Resource)
Constant Summary collapse
- PILL_ROLLING =
Selection for tablet, capsule, caplet, etc.
[ { url: QUANTITY_LIMIT_DETAIL_ROLLING_EXTENSION, valueTiming: { repeat: { count: 60, period: 30, periodUnit: "d", }, }, }, { url: QUANTITY_LIMIT_DETAIL_ROLLING_EXTENSION, valueTiming: { repeat: { count: 30, period: 30, periodUnit: "d", }, }, }, { url: QUANTITY_LIMIT_DETAIL_ROLLING_EXTENSION, valueTiming: { repeat: { count: 120, period: 30, periodUnit: "d", }, }, }, { url: QUANTITY_LIMIT_DETAIL_ROLLING_EXTENSION, valueTiming: { repeat: { count: 9, period: 30, periodUnit: "d", }, }, }, ].freeze
- LIQUID_ROLLING =
Selection for solution, suspension, etc.
[ { url: QUANTITY_LIMIT_DETAIL_ROLLING_EXTENSION, valueTiming: { repeat: { count: 60, period: 30, periodUnit: "d", }, }, }, { url: QUANTITY_LIMIT_DETAIL_ROLLING_EXTENSION, valueTiming: { repeat: { count: 300, period: 30, periodUnit: "d", }, }, }, { url: QUANTITY_LIMIT_DETAIL_ROLLING_EXTENSION, valueTiming: { repeat: { count: 15, period: 30, periodUnit: "d", }, }, }, ].freeze
- PASTE_ROLLING =
Selection for cream, ointment, gel, paste, etc.
[ { url: QUANTITY_LIMIT_DETAIL_ROLLING_EXTENSION, valueTiming: { repeat: { count: 60, period: 30, periodUnit: "d", }, }, }, { url: QUANTITY_LIMIT_DETAIL_ROLLING_EXTENSION, valueTiming: { repeat: { count: 15, period: 30, periodUnit: "d", }, }, }, { url: QUANTITY_LIMIT_DETAIL_ROLLING_EXTENSION, valueTiming: { repeat: { count: 100, period: 30, periodUnit: "d", }, }, }, ].freeze
- INJECTION_ROLLING =
Selection injections
[ { url: QUANTITY_LIMIT_DETAIL_ROLLING_EXTENSION, valueTiming: { repeat: { count: 12, period: 30, periodUnit: "d", }, }, }, { url: QUANTITY_LIMIT_DETAIL_ROLLING_EXTENSION, valueTiming: { repeat: { count: 1, period: 30, periodUnit: "d", }, }, }, { url: QUANTITY_LIMIT_DETAIL_ROLLING_EXTENSION, valueTiming: { repeat: { count: 15, period: 30, periodUnit: "d", }, }, }, ].freeze
- OPHTHALMIC_ROLLING =
Selection for ophthalmic
[ { url: QUANTITY_LIMIT_DETAIL_ROLLING_EXTENSION, valueTiming: { repeat: { count: 20, period: 30, periodUnit: "d", }, }, }, { url: QUANTITY_LIMIT_DETAIL_ROLLING_EXTENSION, valueTiming: { repeat: { count: 30, period: 30, periodUnit: "d", }, }, }, ].freeze
- DAYS_SUPPLY =
Sample days supply extension
[ { url: QUANTITY_LIMIT_DETAIL_DAYS_SUPPLY_EXTENSION, valueTiming: { repeat: { boundsDuration: { value: 365, system: UCUM_SYSTEM, code: "d", }, count: 1, period: 180, periodUnit: "d", }, }, }, nil, nil, nil, nil, { url: QUANTITY_LIMIT_DETAIL_DAYS_SUPPLY_EXTENSION, valueTiming: { repeat: { boundsDuration: { value: 365, system: UCUM_SYSTEM, code: "d", }, count: 2, period: 28, periodUnit: "d", }, }, }, ].freeze
Instance Attribute Summary collapse
-
#drug_name ⇒ Object
readonly
Returns the value of attribute drug_name.
-
#rolling_extension ⇒ Object
readonly
Returns the value of attribute rolling_extension.
Instance Method Summary collapse
-
#build ⇒ Object
Construct a quantityLimitDetail FHIR extension instance.
-
#days_supply_extension ⇒ Object
private
Selects a days supply extension from the sample list DAYS_SUPPLY.
-
#initialize(drug_name) ⇒ QuantityLimitDetailExtensionFactory
constructor
A new instance of QuantityLimitDetailExtensionFactory.
-
#maximum_daily_extension ⇒ Object
private
Structure the maximum daily extension based on the Rolling extension.
-
#set_rolling_extension ⇒ Object
private
Sets @rolling_extension based on the drug form.
Constructor Details
#initialize(drug_name) ⇒ QuantityLimitDetailExtensionFactory
Returns a new instance of QuantityLimitDetailExtensionFactory.
11 12 13 14 |
# File 'lib/formulary/quantity_limit_detail_extension_factory.rb', line 11 def initialize(drug_name) @drug_name = drug_name set_rolling_extension end |
Instance Attribute Details
#drug_name ⇒ Object (readonly)
Returns the value of attribute drug_name.
9 10 11 |
# File 'lib/formulary/quantity_limit_detail_extension_factory.rb', line 9 def drug_name @drug_name end |
#rolling_extension ⇒ Object (readonly)
Returns the value of attribute rolling_extension.
9 10 11 |
# File 'lib/formulary/quantity_limit_detail_extension_factory.rb', line 9 def rolling_extension @rolling_extension end |
Instance Method Details
#build ⇒ Object
Construct a quantityLimitDetail FHIR extension instance
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/formulary/quantity_limit_detail_extension_factory.rb', line 17 def build FHIR::Extension.new( url: QUANTITY_LIMIT_DETAIL_EXTENSION, extension: [ rolling_extension, maximum_daily_extension, days_supply_extension, ].compact, ) end |
#days_supply_extension ⇒ Object (private)
Selects a days supply extension from the sample list DAYS_SUPPLY
32 33 34 |
# File 'lib/formulary/quantity_limit_detail_extension_factory.rb', line 32 def days_supply_extension DAYS_SUPPLY.sample end |
#maximum_daily_extension ⇒ Object (private)
Structure the maximum daily extension based on the Rolling extension
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/formulary/quantity_limit_detail_extension_factory.rb', line 38 def maximum_daily_extension return if rolling_extension.nil? extension = nil count = rolling_extension[:valueTiming][:repeat][:count] period = rolling_extension[:valueTiming][:repeat][:period] if count % period == 0 extension = { url: QUANTITY_LIMIT_DETAIL_MAXIMUM_DAILY_EXTENSION, valueQuantity: { value: count / period, }, } end extension end |
#set_rolling_extension ⇒ Object (private)
Sets @rolling_extension based on the drug form
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/formulary/quantity_limit_detail_extension_factory.rb', line 56 def set_rolling_extension ext = nil pill_form = ["tablet", "capsule", "caplet"].any? { |s| drug_name.downcase.include?(s) } paste_form = ["paste", "cream", "ointment", "gel"].any? { |s| drug_name.downcase.include?(s) } liquid_form = ["ml", "solution", "suspension"].any? { |s| drug_name.downcase.include?(s) } injection_form = drug_name.downcase.include?("injection") ophthalmic = drug_name.downcase.include?("ophthalmic") if ophthalmic ext = OPHTHALMIC_ROLLING.sample elsif injection_form ext = INJECTION_ROLLING.sample elsif pill_form ext = PILL_ROLLING.sample elsif paste_form ext = PASTE_ROLLING.sample elsif liquid_form ext = LIQUID_ROLLING.sample end @rolling_extension = ext end |