Class: DaVinciUSDrugFormularyTestKit::Generator::IGResources

Inherits:
Object
  • Object
show all
Defined in:
lib/davinci_us_drug_formulary_test_kit/generator/ig_resources.rb

Instance Method Summary collapse

Instance Method Details

#add(resource) ⇒ Object



6
7
8
# File 'lib/davinci_us_drug_formulary_test_kit/generator/ig_resources.rb', line 6

def add(resource)
  resources_by_type[resource.resourceType] << resource
end

#capability_statement(mode = 'server') ⇒ Object



10
11
12
13
14
# File 'lib/davinci_us_drug_formulary_test_kit/generator/ig_resources.rb', line 10

def capability_statement(mode = 'server')
  resources_by_type['CapabilityStatement'].find do |capability_statement_resource|
    capability_statement_resource.rest.any? { |r| r.mode == mode }
  end
end

#code_system_by_url(url) ⇒ Object



36
37
38
# File 'lib/davinci_us_drug_formulary_test_kit/generator/ig_resources.rb', line 36

def code_system_by_url(url)
  resources_by_type['CodeSystem'].find { |system| system.url == url }
end

#igObject



16
17
18
# File 'lib/davinci_us_drug_formulary_test_kit/generator/ig_resources.rb', line 16

def ig
  resources_by_type['ImplementationGuide'].first
end

#inspectObject



20
21
22
# File 'lib/davinci_us_drug_formulary_test_kit/generator/ig_resources.rb', line 20

def inspect
  'IGResources'
end

#profile_by_url(url) ⇒ Object



24
25
26
# File 'lib/davinci_us_drug_formulary_test_kit/generator/ig_resources.rb', line 24

def profile_by_url(url)
  resources_by_type['StructureDefinition'].find { |profile| profile.url == url }
end

#resource_for_profile(url) ⇒ Object



28
29
30
# File 'lib/davinci_us_drug_formulary_test_kit/generator/ig_resources.rb', line 28

def resource_for_profile(url)
  resources_by_type['StructureDefinition'].find { |profile| profile.url == url }.type
end

#search_param_by_resource_and_name(resource, name) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/davinci_us_drug_formulary_test_kit/generator/ig_resources.rb', line 40

def search_param_by_resource_and_name(resource, name)
  # remove '_' from search parameter name, such as _id or _tag
  normalized_name = name.to_s.delete_prefix('_')

  res = resources_by_type['SearchParameter']
    .find { |param| param.id == "#{resource}-#{normalized_name}" }
  if res.nil?
    res = resources_by_type['SearchParameter']
      .find { |param| param.id == "Resource-#{normalized_name}" }
  end
  res
end

#value_set_by_url(url) ⇒ Object



32
33
34
# File 'lib/davinci_us_drug_formulary_test_kit/generator/ig_resources.rb', line 32

def value_set_by_url(url)
  resources_by_type['ValueSet'].find { |profile| profile.url == url }
end