Class: DaVinciPlanNetTestKit::Generator::IGResources

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

Instance Method Summary collapse

Instance Method Details

#add(resource) ⇒ Object



4
5
6
# File 'lib/davinci_plan_net_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/davinci_plan_net_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/davinci_plan_net_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/davinci_plan_net_test_kit/generator/ig_resources.rb', line 14

def ig
  resources_by_type['ImplementationGuide'].first
end

#inspectObject



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

def inspect
  'IGResources'
end

#profile_by_url(url) ⇒ Object



22
23
24
# File 'lib/davinci_plan_net_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/davinci_plan_net_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
46
47
48
49
50
51
52
53
54
55
# File 'lib/davinci_plan_net_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('_')

  if ['family', 'given'].include?(normalized_name) && resource == 'Practitioner'
    normalized_name += '-name'
  end

  param = resources_by_type['SearchParameter']
    .find { |param| param.id == "#{resource.downcase}-#{normalized_name}" }

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

  return param
end

#value_set_by_url(url) ⇒ Object



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

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