Class: Formulary::FormularyFactory
- Inherits:
- 
      Object
      
        - Object
- Formulary::FormularyFactory
 
- Defined in:
- lib/formulary/formulary_factory.rb
Overview
Class to build Formulary resources from a QHPPlan
Instance Attribute Summary collapse
- 
  
    
      #plan  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute plan. 
Instance Method Summary collapse
- #build ⇒ Object
- #identifier ⇒ Object private
- 
  
    
      #initialize(plan)  ⇒ FormularyFactory 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of FormularyFactory. 
- #meta ⇒ Object private
- 
  
    
      #name  ⇒ Object 
    
    
  
  
  
  
  private
  
  
  
  
    The plan marketing name [String]. 
- #period ⇒ Object private
- #text ⇒ Object private
- #type ⇒ Object private
Constructor Details
#initialize(plan) ⇒ FormularyFactory
Returns a new instance of FormularyFactory.
| 12 13 14 | # File 'lib/formulary/formulary_factory.rb', line 12 def initialize(plan) @plan = plan end | 
Instance Attribute Details
#plan ⇒ Object (readonly)
Returns the value of attribute plan.
| 10 11 12 | # File 'lib/formulary/formulary_factory.rb', line 10 def plan @plan end | 
Instance Method Details
#build ⇒ Object
| 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | # File 'lib/formulary/formulary_factory.rb', line 16 def build name.strip! FHIR::InsurancePlan.new( id: FORMULARY_ID_PREFIX + plan.id, meta: , text: text, identifier: identifier, status: "active", name: name, type: type, period: period, ) end | 
#identifier ⇒ Object (private)
| 47 48 49 | # File 'lib/formulary/formulary_factory.rb', line 47 def identifier [{ value: FORMULARY_ID_PREFIX + plan.id }] end | 
#meta ⇒ Object (private)
| 33 34 35 36 37 38 | # File 'lib/formulary/formulary_factory.rb', line 33 def { profile: [FORMULARY_PROFILE], lastUpdated: plan.last_updated + "T00:00:00Z", } end | 
#name ⇒ Object (private)
Returns the plan marketing name [String].
| 52 53 54 | # File 'lib/formulary/formulary_factory.rb', line 52 def name plan.marketing_name end | 
#period ⇒ Object (private)
| 68 69 70 71 72 73 74 | # File 'lib/formulary/formulary_factory.rb', line 68 def period current_year = Date.today.year { "start": "#{current_year}-01-01", "end": "#{current_year}-12-31", } end | 
#text ⇒ Object (private)
| 40 41 42 43 44 45 | # File 'lib/formulary/formulary_factory.rb', line 40 def text { status: "generated", div: %(<div xmlns="http://www.w3.org/1999/xhtml">#{name}</div>), } end | 
#type ⇒ Object (private)
| 56 57 58 59 60 61 62 63 64 65 66 | # File 'lib/formulary/formulary_factory.rb', line 56 def type { coding: [ { system: FORMULARY_TYPE_SYSTEM, code: FORMULARY_TYPE_CS_CODE, display: FORMULARY_TYPE_CS_DISPLAY, }, ], } end |