Class: CarinForBlueButtonTestKit::Generator::ValueExactor
- Inherits:
-
Object
- Object
- CarinForBlueButtonTestKit::Generator::ValueExactor
- Defined in:
- lib/carin_for_blue_button_test_kit/generator/value_extractor.rb
Instance Attribute Summary collapse
-
#ig_resources ⇒ Object
Returns the value of attribute ig_resources.
-
#resource ⇒ Object
Returns the value of attribute resource.
Instance Method Summary collapse
- #bound_systems(the_element) ⇒ Object
- #fhir_metadata(current_path) ⇒ Object
-
#initialize(ig_resources, resource) ⇒ ValueExactor
constructor
A new instance of ValueExactor.
- #value_set(the_element) ⇒ Object
- #value_set_binding(the_element) ⇒ Object
- #values_from_resource_metadata(paths) ⇒ Object
- #values_from_value_set_binding(the_element) ⇒ Object
Constructor Details
#initialize(ig_resources, resource) ⇒ ValueExactor
Returns a new instance of ValueExactor.
6 7 8 9 |
# File 'lib/carin_for_blue_button_test_kit/generator/value_extractor.rb', line 6 def initialize(ig_resources, resource) self.ig_resources = ig_resources self.resource = resource end |
Instance Attribute Details
#ig_resources ⇒ Object
Returns the value of attribute ig_resources.
4 5 6 |
# File 'lib/carin_for_blue_button_test_kit/generator/value_extractor.rb', line 4 def ig_resources @ig_resources end |
#resource ⇒ Object
Returns the value of attribute resource.
4 5 6 |
# File 'lib/carin_for_blue_button_test_kit/generator/value_extractor.rb', line 4 def resource @resource end |
Instance Method Details
#bound_systems(the_element) ⇒ Object
19 20 21 |
# File 'lib/carin_for_blue_button_test_kit/generator/value_extractor.rb', line 19 def bound_systems(the_element) value_set(the_element)&.compose&.include&.reject { |code| code.concept.nil? } end |
#fhir_metadata(current_path) ⇒ Object
31 32 33 |
# File 'lib/carin_for_blue_button_test_kit/generator/value_extractor.rb', line 31 def (current_path) FHIR.const_get(resource)::METADATA[current_path] end |
#value_set(the_element) ⇒ Object
15 16 17 |
# File 'lib/carin_for_blue_button_test_kit/generator/value_extractor.rb', line 15 def value_set(the_element) ig_resources.value_set_by_url(value_set_binding(the_element)&.valueSet) end |
#value_set_binding(the_element) ⇒ Object
11 12 13 |
# File 'lib/carin_for_blue_button_test_kit/generator/value_extractor.rb', line 11 def value_set_binding(the_element) the_element&.binding end |
#values_from_resource_metadata(paths) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/carin_for_blue_button_test_kit/generator/value_extractor.rb', line 35 def (paths) values = [] paths.each do |current_path| = (current_path) if &.dig('valid_codes').present? values = values + ['valid_codes'].values.flatten end end values end |
#values_from_value_set_binding(the_element) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/carin_for_blue_button_test_kit/generator/value_extractor.rb', line 23 def values_from_value_set_binding(the_element) bound_systems = bound_systems(the_element) return [] if bound_systems.blank? bound_systems.flat_map { |system| system.concept.map { |code| code.code } }.uniq end |