Class: AUCoreTestKit::Generator::IGResources
- Inherits:
-
Object
- Object
- AUCoreTestKit::Generator::IGResources
- Defined in:
- lib/au_core_test_kit/generator/ig_resources.rb
Instance Method Summary collapse
- #add(resource) ⇒ Object
- #capability_statement(mode = 'server') ⇒ Object
- #code_system_by_url(url) ⇒ Object
- #ig ⇒ Object
- #inspect ⇒ Object
- #profile_by_url(url) ⇒ Object
- #resource_for_profile(url) ⇒ Object
- #search_param_by_exact_resource_and_code(resource, code) ⇒ Object
- #search_param_by_general_resource_and_code(resource, code) ⇒ Object
- #search_param_by_resource_and_code(resource, code) ⇒ Object
- #search_param_by_resource_and_name(resource, name) ⇒ Object
- #search_param_by_specific_cases(resource, code) ⇒ Object
- #value_set_by_url(url) ⇒ Object
Instance Method Details
#add(resource) ⇒ Object
6 7 8 |
# File 'lib/au_core_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/au_core_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/au_core_test_kit/generator/ig_resources.rb', line 36 def code_system_by_url(url) resources_by_type['CodeSystem'].find { |system| system.url == url } end |
#ig ⇒ Object
16 17 18 |
# File 'lib/au_core_test_kit/generator/ig_resources.rb', line 16 def ig resources_by_type['ImplementationGuide'].first end |
#inspect ⇒ Object
20 21 22 |
# File 'lib/au_core_test_kit/generator/ig_resources.rb', line 20 def inspect 'IGResources' end |
#profile_by_url(url) ⇒ Object
24 25 26 |
# File 'lib/au_core_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/au_core_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_exact_resource_and_code(resource, code) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/au_core_test_kit/generator/ig_resources.rb', line 40 def search_param_by_exact_resource_and_code(resource, code) search_params = resources_by_type['SearchParameter'] .select { |param| param.base.include?(resource) && param.code == code } if search_params.length > 1 search_params.find do |param| param.jurisdiction.any? do |codeable_concept| codeable_concept.coding.any? do |coding| coding.system == 'urn:iso:std:iso:3166' && coding.code == 'AU' end end end else search_params.first end end |
#search_param_by_general_resource_and_code(resource, code) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/au_core_test_kit/generator/ig_resources.rb', line 57 def search_param_by_general_resource_and_code(resource, code) # For all base search params (eg: _id) which not defined in separate files, we get details from the base Resource. search_param = resources_by_type['SearchParameter'] .find { |param| param.base.include?('Resource') && param.code == code } search_param_dup = search_param.dup if search_param_dup.present? search_param_dup.id = search_param_dup.id.gsub('Resource', resource) search_param_dup.base = resource search_param_dup.expression = search_param_dup.expression.gsub('Resource', resource) end search_param_dup end |
#search_param_by_resource_and_code(resource, code) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/au_core_test_kit/generator/ig_resources.rb', line 81 def search_param_by_resource_and_code(resource, code) exact_resource = search_param_by_exact_resource_and_code(resource, code) if exact_resource.present? exact_resource else general_resource = search_param_by_general_resource_and_code(resource, code) if general_resource.present? general_resource else search_param_by_specific_cases(resource, code) end end end |
#search_param_by_resource_and_name(resource, name) ⇒ Object
95 96 97 |
# File 'lib/au_core_test_kit/generator/ig_resources.rb', line 95 def search_param_by_resource_and_name(resource, name) search_param_by_resource_and_code(resource, name) end |
#search_param_by_specific_cases(resource, code) ⇒ Object
73 74 75 76 77 78 79 |
# File 'lib/au_core_test_kit/generator/ig_resources.rb', line 73 def search_param_by_specific_cases(resource, code) case "#{resource}-#{code}" when 'ServiceRequest-code' resources_by_type['SearchParameter'] .find { |param| param.id == 'ServiceRequest-code-concept' } end end |
#value_set_by_url(url) ⇒ Object
32 33 34 |
# File 'lib/au_core_test_kit/generator/ig_resources.rb', line 32 def value_set_by_url(url) resources_by_type['ValueSet'].find { |profile| profile.url == url } end |