Class: AUCoreTestKit::Generator::SearchMetadataExtractor
- Inherits:
-
Object
- Object
- AUCoreTestKit::Generator::SearchMetadataExtractor
- Defined in:
- lib/au_core_test_kit/generator/search_metadata_extractor.rb
Constant Summary collapse
- COMBO_EXTENSION_URL =
'http://hl7.org/fhir/StructureDefinition/capabilitystatement-search-parameter-combination'
Instance Attribute Summary collapse
-
#group_metadata ⇒ Object
Returns the value of attribute group_metadata.
-
#ig_resources ⇒ Object
Returns the value of attribute ig_resources.
-
#profile_elements ⇒ Object
Returns the value of attribute profile_elements.
-
#resource_capabilities ⇒ Object
Returns the value of attribute resource_capabilities.
Instance Method Summary collapse
- #basic_searches ⇒ Object
- #combo_searches ⇒ Object
- #conformance_expectation(search_param) ⇒ Object
- #handle_special_cases ⇒ Object
-
#initialize(resource_capabilities, ig_resources, profile_elements, group_metadata) ⇒ SearchMetadataExtractor
constructor
A new instance of SearchMetadataExtractor.
- #no_search_params? ⇒ Boolean
- #search_definitions ⇒ Object
- #search_extensions ⇒ Object
- #search_param_names ⇒ Object
- #searches ⇒ Object
Constructor Details
#initialize(resource_capabilities, ig_resources, profile_elements, group_metadata) ⇒ SearchMetadataExtractor
Returns a new instance of SearchMetadataExtractor.
13 14 15 16 17 18 |
# File 'lib/au_core_test_kit/generator/search_metadata_extractor.rb', line 13 def initialize(resource_capabilities, ig_resources, profile_elements, ) self.resource_capabilities = resource_capabilities self.ig_resources = ig_resources self.profile_elements = profile_elements self. = end |
Instance Attribute Details
#group_metadata ⇒ Object
Returns the value of attribute group_metadata.
11 12 13 |
# File 'lib/au_core_test_kit/generator/search_metadata_extractor.rb', line 11 def @group_metadata end |
#ig_resources ⇒ Object
Returns the value of attribute ig_resources.
11 12 13 |
# File 'lib/au_core_test_kit/generator/search_metadata_extractor.rb', line 11 def ig_resources @ig_resources end |
#profile_elements ⇒ Object
Returns the value of attribute profile_elements.
11 12 13 |
# File 'lib/au_core_test_kit/generator/search_metadata_extractor.rb', line 11 def profile_elements @profile_elements end |
#resource_capabilities ⇒ Object
Returns the value of attribute resource_capabilities.
11 12 13 |
# File 'lib/au_core_test_kit/generator/search_metadata_extractor.rb', line 11 def resource_capabilities @resource_capabilities end |
Instance Method Details
#basic_searches ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/au_core_test_kit/generator/search_metadata_extractor.rb', line 36 def basic_searches return [] if no_search_params? resource_capabilities.searchParam .select do |search_param| %w[SHALL SHOULD MAY].include? conformance_expectation(search_param) end .map do |search_param| { names: [search_param.name], expectation: conformance_expectation(search_param) } end end |
#combo_searches ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/au_core_test_kit/generator/search_metadata_extractor.rb', line 55 def combo_searches return [] if search_extensions.blank? search_extensions .select { |extension| extension.url == COMBO_EXTENSION_URL } .select { |extension| %w[SHALL SHOULD MAY].include? conformance_expectation(extension) } .map do |extension| names = extension.extension.select { |param| param.valueString.present? }.map(&:valueString) { expectation: conformance_expectation(extension), names: } end end |
#conformance_expectation(search_param) ⇒ Object
28 29 30 |
# File 'lib/au_core_test_kit/generator/search_metadata_extractor.rb', line 28 def conformance_expectation(search_param) search_param.extension.first.valueCode # TODO: fix expectation extension finding end |
#handle_special_cases ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/au_core_test_kit/generator/search_metadata_extractor.rb', line 82 def handle_special_cases # NOTE: https://github.com/hl7au/au-fhir-core-inferno/issues/57 profile_url = [:profile_url] if profile_url == 'http://hl7.org.au/fhir/core/StructureDefinition/au-core-medicationrequest' @searches.map do |search| if search[:names] == ["patient", "intent", "authoredon"] && search[:expectation] == "SHALL" search[:expectation] = "SHOULD" end end end end |
#no_search_params? ⇒ Boolean
32 33 34 |
# File 'lib/au_core_test_kit/generator/search_metadata_extractor.rb', line 32 def no_search_params? resource_capabilities.searchParam.blank? end |
#search_definitions ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/au_core_test_kit/generator/search_metadata_extractor.rb', line 74 def search_definitions search_param_names.each_with_object({}) do |name, definitions| definitions[name.to_sym] = SearchDefinitionMetadataExtractor.new(name, ig_resources, profile_elements, ).search_definition end end |
#search_extensions ⇒ Object
51 52 53 |
# File 'lib/au_core_test_kit/generator/search_metadata_extractor.rb', line 51 def search_extensions resource_capabilities.extension end |
#search_param_names ⇒ Object
70 71 72 |
# File 'lib/au_core_test_kit/generator/search_metadata_extractor.rb', line 70 def search_param_names searches.flat_map { |search| search[:names] }.uniq end |
#searches ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/au_core_test_kit/generator/search_metadata_extractor.rb', line 20 def searches @searches ||= basic_searches + combo_searches handle_special_cases @searches end |