Class: Formulary::FormularyDrugFactory
- Inherits:
-
Object
- Object
- Formulary::FormularyDrugFactory
- Defined in:
- lib/formulary/formulary_drug_factory.rb
Overview
Class to build FormularyDrug resources from a QHPPlanDrug
Instance Attribute Summary collapse
-
#plan_drug ⇒ Object
readonly
Returns the value of attribute plan_drug.
Instance Method Summary collapse
- #build(id = nil) ⇒ Object
- #code ⇒ Object private
- #dose_form ⇒ Object private
-
#initialize(plan_drug) ⇒ FormularyDrugFactory
constructor
A new instance of FormularyDrugFactory.
- #meta ⇒ Object private
- #text ⇒ Object private
Constructor Details
#initialize(plan_drug) ⇒ FormularyDrugFactory
Returns a new instance of FormularyDrugFactory.
12 13 14 |
# File 'lib/formulary/formulary_drug_factory.rb', line 12 def initialize(plan_drug) @plan_drug = plan_drug end |
Instance Attribute Details
#plan_drug ⇒ Object (readonly)
Returns the value of attribute plan_drug.
10 11 12 |
# File 'lib/formulary/formulary_drug_factory.rb', line 10 def plan_drug @plan_drug end |
Instance Method Details
#build(id = nil) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/formulary/formulary_drug_factory.rb', line 16 def build(id = nil) FHIR::MedicationKnowledge.new( id: "#{DRUG_ID_PREFIX}#{id}", code: code, status: "active", doseForm: dose_form, # TODO Need to do related Medication Knowledge (possibly optional based on testing outcomes) # Can we add classigfication for testing? Will need to build out source data more. meta: , ) end |
#code ⇒ Object (private)
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/formulary/formulary_drug_factory.rb', line 30 def code { coding: [ { system: RXNORM_SYSTEM, code: plan_drug.rxnorm_code, display: plan_drug.name, }, ], } end |
#dose_form ⇒ Object (private)
42 43 44 45 46 47 48 49 50 |
# File 'lib/formulary/formulary_drug_factory.rb', line 42 def dose_form json_data = File.read("doseform.json") dose_forms = JSON.parse(json_data, :symbolize_names => true) coding = dose_forms.find { |coding| plan_drug.name.downcase.include?(coding[:display].downcase) } return if coding.nil? { coding: [coding], } end |
#meta ⇒ Object (private)
59 60 61 62 63 64 65 |
# File 'lib/formulary/formulary_drug_factory.rb', line 59 def current_date = Date.today.to_s { profile: [FORMULARY_DRUG_PROFILE], lastUpdated: "#{current_date}T10:03:10Z", } end |
#text ⇒ Object (private)
52 53 54 55 56 57 |
# File 'lib/formulary/formulary_drug_factory.rb', line 52 def text { status: "generated", div: %(<div xmlns="http://www.w3.org/1999/xhtml">#{plan_drug.name}</div>), } end |