inferno_core 1.4.3 → 1.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/lib/inferno/apps/cli/main.rb +46 -5
  3. data/lib/inferno/apps/cli/templates/%library_name%.gemspec.tt +1 -1
  4. data/lib/inferno/apps/cli/templates/.gitignore +1 -1
  5. data/lib/inferno/apps/cli/templates/Rakefile.tt +0 -13
  6. data/lib/inferno/apps/cli/templates/config/nginx.background.conf.tt +0 -30
  7. data/lib/inferno/apps/cli/templates/config/nginx.conf.tt +0 -30
  8. data/lib/inferno/apps/cli/templates/docker-compose.background.yml.tt +1 -14
  9. data/lib/inferno/apps/cli/templates/docker-compose.yml.tt +1 -10
  10. data/lib/inferno/apps/cli/templates/execution_scripts/%library_name%_script_expected.json.tt +0 -8
  11. data/lib/inferno/apps/cli/templates/execution_scripts/{README.md.tt → README.md} +3 -3
  12. data/lib/inferno/apps/cli/templates/lib/%library_name%/requirements/%library_name%_requirements.csv +3 -0
  13. data/lib/inferno/apps/cli/templates/lib/%library_name%/requirements/Inferno Requirements Template.xlsx +0 -0
  14. data/lib/inferno/apps/cli/templates/lib/%library_name%/requirements/README.md +12 -0
  15. data/lib/inferno/apps/cli/templates/lib/%library_name%/requirements/generated/%test_suite_id%_requirements_coverage.csv.tt +1 -0
  16. data/lib/inferno/apps/cli/templates/spec/%library_name%/patient_group_spec.rb.tt +3 -3
  17. data/lib/inferno/config/boot/suites.rb +35 -0
  18. data/lib/inferno/dsl/fhir_resource_validation.rb +90 -4
  19. data/lib/inferno/dsl/input_output_handling.rb +101 -5
  20. data/lib/inferno/dsl/must_support_metadata_extractor.rb +19 -1
  21. data/lib/inferno/entities/input.rb +57 -0
  22. data/lib/inferno/public/bundle.js +13 -13
  23. data/lib/inferno/test_runner.rb +5 -1
  24. data/lib/inferno/utils/execution_script_runner.rb +56 -7
  25. data/lib/inferno/version.rb +1 -1
  26. data/spec/spec_helper.rb +18 -0
  27. metadata +6 -4
  28. data/lib/inferno/apps/cli/templates/lib/%library_name%/suite.rb.tt +0 -59
@@ -75,7 +75,20 @@ module Inferno
75
75
  end
76
76
 
77
77
  def all_must_support_elements
78
- profile_elements.select { |element| element.mustSupport || by_requirement_extension_only?(element) }
78
+ profile_elements.select do |element|
79
+ (element.mustSupport || by_requirement_extension_only?(element)) && !prohibited_by_cardinality?(element)
80
+ end
81
+ end
82
+
83
+ # A profile can inherit mustSupport flags from a base profile while constraining the element to a max
84
+ # cardinality of 0. Such an element, and its descendants, cannot appear in a conformant resource.
85
+ def prohibited_by_cardinality?(element)
86
+ profile_elements.any? do |profile_element|
87
+ profile_element.max == '0' &&
88
+ (element.id == profile_element.id ||
89
+ element.id.start_with?("#{profile_element.id}.") ||
90
+ element.id.start_with?("#{profile_element.id}:"))
91
+ end
79
92
  end
80
93
 
81
94
  def must_support_extension_elements
@@ -364,6 +377,11 @@ module Inferno
364
377
  path: navigation_compatible_discriminator_path(discriminator_path),
365
378
  value: pattern_element.fixed
366
379
  }
380
+ elsif pattern_element.patternString
381
+ fixed_values << {
382
+ path: navigation_compatible_discriminator_path(discriminator_path),
383
+ value: pattern_element.patternString
384
+ }
367
385
  elsif pattern_value.present?
368
386
  raise StandardError, "Found more than one pattern slices for the same element #{pattern_element}."
369
387
  else
@@ -1,3 +1,5 @@
1
+ require 'json'
2
+
1
3
  require_relative 'attributes'
2
4
  require_relative '../exceptions'
3
5
 
@@ -91,6 +93,30 @@ module Inferno
91
93
  type_is_hash && input_name_string_exists && value_string_exists
92
94
  end
93
95
 
96
+ # @private
97
+ # Whether this input is enabled for a map of submitted input values.
98
+ # An input without an enable_when condition is always enabled. An input
99
+ # whose controlling input is itself conditionally disabled (i.e. has its
100
+ # own enable_when condition that is not met) is never enabled, regardless
101
+ # of the controlling input's current value.
102
+ # @param visited [Array<Symbol>] names of inputs already visited in this
103
+ # evaluation chain, used to guard against circular enable_when references.
104
+ def enabled?(input_values, available_inputs, visited = [])
105
+ return true if enable_when.blank?
106
+ return false if visited.include?(name)
107
+ return false unless input_values.key?(enable_when[:input_name])
108
+
109
+ controlling_input = available_inputs[enable_when[:input_name].to_sym]
110
+ if controlling_input && !controlling_input.enabled?(input_values, available_inputs, visited + [name])
111
+ return false
112
+ end
113
+
114
+ return checkbox_group_enabled?(input_values[enable_when[:input_name]]) if checkbox_group?(controlling_input)
115
+
116
+ normalize_enable_when_value(input_values[enable_when[:input_name]]) ==
117
+ normalize_enable_when_value(enable_when[:value])
118
+ end
119
+
94
120
  # @private
95
121
  # Merge this input with an input belonging to a child. Fields defined on
96
122
  # this input take precedence over those defined on the child input.
@@ -211,6 +237,37 @@ module Inferno
211
237
 
212
238
  ATTRIBUTES.all? { |attribute| send(attribute) == other.send(attribute) }
213
239
  end
240
+
241
+ private
242
+
243
+ def checkbox_group?(input)
244
+ input&.type.to_s == 'checkbox' && input.options&.dig(:list_options)&.any?
245
+ end
246
+
247
+ def checkbox_group_enabled?(value)
248
+ actual_values = normalize_checkbox_values(value)
249
+ expected_values = normalize_checkbox_values(enable_when[:value])
250
+ !actual_values.nil? && actual_values == expected_values
251
+ end
252
+
253
+ def normalize_checkbox_values(value)
254
+ value = JSON.parse(value) if value.is_a?(String)
255
+ return unless value.is_a?(Array) && value.all? { |item| item.is_a?(String) }
256
+
257
+ value.sort
258
+ rescue JSON::ParserError
259
+ nil
260
+ end
261
+
262
+ # Normalize values using the same rules as the client-side enable_when
263
+ # comparison for non-checkbox-group inputs.
264
+ def normalize_enable_when_value(value)
265
+ return '' if value.nil?
266
+ return JSON.generate(value.sort_by(&:to_s)) if value.is_a?(Array)
267
+ return JSON.generate(value) if value.is_a?(Hash)
268
+
269
+ value.to_s
270
+ end
214
271
  end
215
272
  end
216
273
  end