Class: DaVinciPlanNetTestKit::Generator::SearchMetadataExtractor
- Inherits:
-
Object
- Object
- DaVinciPlanNetTestKit::Generator::SearchMetadataExtractor
- Defined in:
- lib/davinci_plan_net_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
-
#ig_resources ⇒ Object
Returns the value of attribute ig_resources.
-
#profile_elements ⇒ Object
Returns the value of attribute profile_elements.
-
#resource ⇒ Object
Returns the value of attribute resource.
-
#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, resource, profile_elements) ⇒ 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, resource, profile_elements) ⇒ SearchMetadataExtractor
Returns a new instance of SearchMetadataExtractor.
11 12 13 14 15 16 |
# File 'lib/davinci_plan_net_test_kit/generator/search_metadata_extractor.rb', line 11 def initialize(resource_capabilities, ig_resources, resource, profile_elements) self.resource_capabilities = resource_capabilities self.ig_resources = ig_resources self.resource = resource self.profile_elements = profile_elements end |
Instance Attribute Details
#ig_resources ⇒ Object
Returns the value of attribute ig_resources.
9 10 11 |
# File 'lib/davinci_plan_net_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/davinci_plan_net_test_kit/generator/search_metadata_extractor.rb', line 9 def profile_elements @profile_elements end |
#resource ⇒ Object
Returns the value of attribute resource.
9 10 11 |
# File 'lib/davinci_plan_net_test_kit/generator/search_metadata_extractor.rb', line 9 def resource @resource end |
#resource_capabilities ⇒ Object
Returns the value of attribute resource_capabilities.
9 10 11 |
# File 'lib/davinci_plan_net_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/davinci_plan_net_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/davinci_plan_net_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/davinci_plan_net_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/davinci_plan_net_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/davinci_plan_net_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, resource, profile_elements).search_definition end end |
#search_extensions ⇒ Object
43 44 45 |
# File 'lib/davinci_plan_net_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/davinci_plan_net_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/davinci_plan_net_test_kit/generator/search_metadata_extractor.rb', line 18 def searches @searches ||= basic_searches + combo_searches end |