Class: USCoreTestKit::Generator::IGResources

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

Instance Method Summary collapse

Instance Method Details

#add(resource) ⇒ Object



4
5
6
# File 'lib/us_core_test_kit/generator/ig_resources.rb', line 4

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

#capability_statement(mode = 'server') ⇒ Object



8
9
10
11
12
# File 'lib/us_core_test_kit/generator/ig_resources.rb', line 8

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



34
35
36
# File 'lib/us_core_test_kit/generator/ig_resources.rb', line 34

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

#igObject



14
15
16
# File 'lib/us_core_test_kit/generator/ig_resources.rb', line 14

def ig
  resources_by_type['ImplementationGuide'].first
end

#inspectObject



18
19
20
# File 'lib/us_core_test_kit/generator/ig_resources.rb', line 18

def inspect
  'IGResources'
end

#profile_by_url(url) ⇒ Object



22
23
24
# File 'lib/us_core_test_kit/generator/ig_resources.rb', line 22

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

#resource_for_profile(url) ⇒ Object



26
27
28
# File 'lib/us_core_test_kit/generator/ig_resources.rb', line 26

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



38
39
40
41
42
43
44
45
# File 'lib/us_core_test_kit/generator/ig_resources.rb', line 38

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

  resources_by_type['SearchParameter'].find do |param|
    param.id == "us-core-#{resource.downcase}-#{normalized_name}" || param.name == name
  end
end

#value_set_by_url(url) ⇒ Object



30
31
32
# File 'lib/us_core_test_kit/generator/ig_resources.rb', line 30

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