Class: DaVinciPASTestKit::Generator::ValueExactor

Inherits:
Object
  • Object
show all
Defined in:
lib/davinci_pas_test_kit/generator/value_extractor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ig_resources, resource) ⇒ ValueExactor

Returns a new instance of ValueExactor.



6
7
8
9
# File 'lib/davinci_pas_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_resourcesObject

Returns the value of attribute ig_resources.



4
5
6
# File 'lib/davinci_pas_test_kit/generator/value_extractor.rb', line 4

def ig_resources
  @ig_resources
end

#resourceObject

Returns the value of attribute resource.



4
5
6
# File 'lib/davinci_pas_test_kit/generator/value_extractor.rb', line 4

def resource
  @resource
end

Instance Method Details

#bound_systems(the_element) ⇒ Object



19
20
21
22
23
24
# File 'lib/davinci_pas_test_kit/generator/value_extractor.rb', line 19

def bound_systems(the_element)
  vs = value_set(the_element)
  return unless vs.present?

  vs.compose&.include&.reject { |code| code.concept.nil? }
end

#fhir_metadata(current_path) ⇒ Object



34
35
36
# File 'lib/davinci_pas_test_kit/generator/value_extractor.rb', line 34

def (current_path)
  FHIR.const_get(resource)::METADATA[current_path]
end

#value_set(the_element) ⇒ Object



15
16
17
# File 'lib/davinci_pas_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/davinci_pas_test_kit/generator/value_extractor.rb', line 11

def value_set_binding(the_element)
  the_element&.binding
end

#values_from_resource_metadata(paths) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/davinci_pas_test_kit/generator/value_extractor.rb', line 38

def (paths)
  values = []

  paths.each do |current_path|
     = (current_path)

    values += ['valid_codes'].values.flatten if &.dig('valid_codes').present?
  end

  values
end

#values_from_value_set_binding(the_element) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/davinci_pas_test_kit/generator/value_extractor.rb', line 26

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) }.uniq
end