Class: DaVinciPlanNetTestKit::Generator::ValueExactor
- Inherits:
-
Object
- Object
- DaVinciPlanNetTestKit::Generator::ValueExactor
- Defined in:
- lib/davinci_plan_net_test_kit/generator/value_extractor.rb
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.
Instance Method Summary collapse
- #bound_systems(the_element) ⇒ Object
- #bound_systems_from_valueset(value_set) ⇒ Object
- #fhir_metadata(current_path) ⇒ Object
-
#initialize(ig_resources, resource, profile_elements) ⇒ ValueExactor
constructor
A new instance of ValueExactor.
- #value_set(the_element) ⇒ Object
- #value_set_binding(the_element) ⇒ Object
- #values_from_fixed_codes(profile_element, type) ⇒ Object
- #values_from_pattern_codeable_concept(profile_element, type) ⇒ Object
- #values_from_pattern_coding(profile_element, type) ⇒ Object
- #values_from_required_binding(profile_element) ⇒ Object
- #values_from_resource_metadata(paths) ⇒ Object
- #values_from_slicing(profile_element, type) ⇒ Object
- #values_from_value_set_binding(the_element) ⇒ Object
Constructor Details
#initialize(ig_resources, resource, profile_elements) ⇒ ValueExactor
Returns a new instance of ValueExactor.
6 7 8 9 10 |
# File 'lib/davinci_plan_net_test_kit/generator/value_extractor.rb', line 6 def initialize(ig_resources, resource, profile_elements) 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.
4 5 6 |
# File 'lib/davinci_plan_net_test_kit/generator/value_extractor.rb', line 4 def ig_resources @ig_resources end |
#profile_elements ⇒ Object
Returns the value of attribute profile_elements.
4 5 6 |
# File 'lib/davinci_plan_net_test_kit/generator/value_extractor.rb', line 4 def profile_elements @profile_elements end |
#resource ⇒ Object
Returns the value of attribute resource.
4 5 6 |
# File 'lib/davinci_plan_net_test_kit/generator/value_extractor.rb', line 4 def resource @resource end |
Instance Method Details
#bound_systems(the_element) ⇒ Object
69 70 71 |
# File 'lib/davinci_plan_net_test_kit/generator/value_extractor.rb', line 69 def bound_systems(the_element) bound_systems_from_valueset(value_set(the_element)) end |
#bound_systems_from_valueset(value_set) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/davinci_plan_net_test_kit/generator/value_extractor.rb', line 73 def bound_systems_from_valueset(value_set) systems = value_set&.compose&.include&.map do |include| if include.concept.present? include elsif include.system.present? && include.filter&.empty? # Cannot process intensional value set with filters ig_resources.code_system_by_url(include.system) elsif include.valueSet.present? include.valueSet.map do |vs| a_value_set = ig_resources.value_set_by_url(vs) bound_systems_from_valueset(a_value_set) end end end&.flatten&.compact systems end |
#fhir_metadata(current_path) ⇒ Object
98 99 100 |
# File 'lib/davinci_plan_net_test_kit/generator/value_extractor.rb', line 98 def (current_path) FHIR.const_get(resource)::METADATA[current_path] end |
#value_set(the_element) ⇒ Object
65 66 67 |
# File 'lib/davinci_plan_net_test_kit/generator/value_extractor.rb', line 65 def value_set(the_element) ig_resources.value_set_by_url(value_set_binding(the_element)&.valueSet) end |
#value_set_binding(the_element) ⇒ Object
61 62 63 |
# File 'lib/davinci_plan_net_test_kit/generator/value_extractor.rb', line 61 def value_set_binding(the_element) the_element&.binding end |
#values_from_fixed_codes(profile_element, type) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/davinci_plan_net_test_kit/generator/value_extractor.rb', line 31 def values_from_fixed_codes(profile_element, type) return [] unless type == 'CodeableConcept' profile_elements .select do |element| element.path == "#{profile_element.path}.coding.code" && element.fixedCode.present? end .map { |element| element.fixedCode } end |
#values_from_pattern_codeable_concept(profile_element, type) ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/davinci_plan_net_test_kit/generator/value_extractor.rb', line 51 def values_from_pattern_codeable_concept(profile_element, type) return [] unless type == 'CodeableConcept' profile_elements .select do |element| element.path == profile_element.path && element.patternCodeableConcept.present? && element.min > 0 end .map { |element| element.patternCodeableConcept.coding.first.code } end |
#values_from_pattern_coding(profile_element, type) ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/davinci_plan_net_test_kit/generator/value_extractor.rb', line 41 def values_from_pattern_coding(profile_element, type) return [] unless type == 'CodeableConcept' profile_elements .select do |element| element.path == "#{profile_element.path}.coding" && element.patternCoding.present? end .map { |element| element.patternCoding.code } end |
#values_from_required_binding(profile_element) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/davinci_plan_net_test_kit/generator/value_extractor.rb', line 20 def values_from_required_binding(profile_element) return [] unless profile_element&.max == '*' profile_elements .select do |element| element.path == profile_element.path && element.binding&.strength == 'required' end .map { |element| values_from_value_set_binding(element) } .flatten.compact end |
#values_from_resource_metadata(paths) ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/davinci_plan_net_test_kit/generator/value_extractor.rb', line 102 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_slicing(profile_element, type) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/davinci_plan_net_test_kit/generator/value_extractor.rb', line 12 def values_from_slicing(profile_element, type) ( values_from_fixed_codes(profile_element, type) + values_from_pattern_coding(profile_element, type) + values_from_pattern_codeable_concept(profile_element, type) ).uniq end |
#values_from_value_set_binding(the_element) ⇒ Object
90 91 92 93 94 95 96 |
# File 'lib/davinci_plan_net_test_kit/generator/value_extractor.rb', line 90 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 |