Class: USCoreTestKit::Generator::SearchMetadataExtractor
- Inherits:
-
Object
- Object
- USCoreTestKit::Generator::SearchMetadataExtractor
- Defined in:
- lib/us_core_test_kit/generator/search_metadata_extractor.rb
Constant Summary collapse
- COMBO_EXTENSION_URL =
'http://hl7.org/fhir/StructureDefinition/capabilitystatement-search-parameter-combination'.freeze
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
-
#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.
11 12 13 14 15 16 |
# File 'lib/us_core_test_kit/generator/search_metadata_extractor.rb', line 11 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.
9 10 11 |
# File 'lib/us_core_test_kit/generator/search_metadata_extractor.rb', line 9 def @group_metadata end |
#ig_resources ⇒ Object
Returns the value of attribute ig_resources.
9 10 11 |
# File 'lib/us_core_test_kit/generator/search_metadata_extractor.rb', line 9 def ig_resources @ig_resources end |
#profile_elements ⇒ Object
Returns the value of attribute profile_elements.
9 10 11 |
# File 'lib/us_core_test_kit/generator/search_metadata_extractor.rb', line 9 def profile_elements @profile_elements end |
#resource_capabilities ⇒ Object
Returns the value of attribute resource_capabilities.
9 10 11 |
# File 'lib/us_core_test_kit/generator/search_metadata_extractor.rb', line 9 def resource_capabilities @resource_capabilities end |
Instance Method Details
#basic_searches ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/us_core_test_kit/generator/search_metadata_extractor.rb', line 30 def basic_searches return [] if no_search_params? resource_capabilities.searchParam .select { |search_param| ['SHALL', 'SHOULD'].include? conformance_expectation(search_param) } .map do |search_param| { names: [search_param.name], expectation: conformance_expectation(search_param) } end end |
#combo_searches ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/us_core_test_kit/generator/search_metadata_extractor.rb', line 47 def combo_searches return [] if search_extensions.blank? search_extensions .select { |extension| extension.url == COMBO_EXTENSION_URL } .select { |extension| ['SHALL', 'SHOULD'].include? conformance_expectation(extension) } .map do |extension| names = extension.extension.select { |param| param.valueString.present? }.map(&:valueString) { expectation: conformance_expectation(extension), names: names } end end |
#conformance_expectation(search_param) ⇒ Object
22 23 24 |
# File 'lib/us_core_test_kit/generator/search_metadata_extractor.rb', line 22 def conformance_expectation(search_param) search_param.extension.first.valueCode # TODO: fix expectation extension finding end |
#no_search_params? ⇒ Boolean
26 27 28 |
# File 'lib/us_core_test_kit/generator/search_metadata_extractor.rb', line 26 def no_search_params? resource_capabilities.searchParam.blank? end |
#search_definitions ⇒ Object
66 67 68 69 70 71 |
# File 'lib/us_core_test_kit/generator/search_metadata_extractor.rb', line 66 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
43 44 45 |
# File 'lib/us_core_test_kit/generator/search_metadata_extractor.rb', line 43 def search_extensions resource_capabilities.extension end |
#search_param_names ⇒ Object
62 63 64 |
# File 'lib/us_core_test_kit/generator/search_metadata_extractor.rb', line 62 def search_param_names searches.flat_map { |search| search[:names] }.uniq end |
#searches ⇒ Object
18 19 20 |
# File 'lib/us_core_test_kit/generator/search_metadata_extractor.rb', line 18 def searches @searches ||= basic_searches + combo_searches end |