inferno_core 0.6.13 → 0.6.15

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3b6ca0be7f115ec7578f07efdb81f51301ffc58011257839439325a0f232f3dd
4
- data.tar.gz: 79c99071c6d89aafea8234c9fea372efbbaf4835f39da46bad226a8b12a317b3
3
+ metadata.gz: be97c34b62bf28dc41266ecc22d01ccb2b8548a75150507ea72fff5aa76f6b17
4
+ data.tar.gz: 2f4121330b353d2f425e1be20f3895a1f256b8f20a825cc5c26adc9aa85f0898
5
5
  SHA512:
6
- metadata.gz: bb251b81e0232761cdddd83603a00d7d16844c61a8c80315b4a239a2f3ff1a6305700bd9c7f352d8c179773ecc45e5d5f824d08f3c00438f4cf460069cb0ae16
7
- data.tar.gz: f01952a5cd0cd31c5e6f35901409581cd047d7b6bd099865efa9bebfe40450d115c299266b1c700a7fd7cceb7b20b15a0e8635e6ff482e27193af81030d7b400
6
+ metadata.gz: eded37149214782930c42e8e672e768eaf0e07411fba2ad9e8f96fad282ff0ff31aee18cab668592ea355a6ddafdfd1c4128d1c04de639e24aa3968a79026ac7
7
+ data.tar.gz: 4322a86fc7f289cfc3cc92e70d0926c7dd79a3ce6941f8479c6096ffdcd3718a7f59e17479031d50e2a0a24cbc0e6bd632e8c31ec9cf00fdad317351176524f4
@@ -12,6 +12,11 @@ module Inferno
12
12
  LONGDESC
13
13
  def export_csv
14
14
  ENV['NO_DB'] = 'true'
15
+
16
+ require_relative '../../../inferno'
17
+
18
+ Inferno::Application.start(:requirements)
19
+
15
20
  RequirementsExporter.new.run
16
21
  end
17
22
 
@@ -22,6 +27,11 @@ module Inferno
22
27
  LONGDESC
23
28
  def check
24
29
  ENV['NO_DB'] = 'true'
30
+
31
+ require_relative '../../../inferno'
32
+
33
+ Inferno::Application.start(:requirements)
34
+
25
35
  RequirementsExporter.new.run_check
26
36
  end
27
37
 
@@ -66,7 +76,7 @@ module Inferno
66
76
  RequirementsCoverageChecker.new(test_suite_id).run_check
67
77
  else
68
78
  Inferno::Repositories::TestSuites.all.each do |test_suite|
69
- if Object.const_source_location(test_suite.to_s).first.start_with?(Dir.pwd, 'lib')
79
+ if Object.const_source_location(test_suite.to_s).first.start_with?(File.join(Dir.pwd, 'lib'))
70
80
  RequirementsCoverageChecker.new(test_suite.id).run_check
71
81
  end
72
82
  end
@@ -176,7 +176,7 @@ module Inferno
176
176
  if File.exist?(output_file_path)
177
177
  if old_csv == new_csv
178
178
  puts "'#{output_file_name}' file is up to date."
179
- return unless unmatched_requirement_ids.present?
179
+ return
180
180
  else
181
181
  puts <<~MESSAGE
182
182
  #{output_file_name} file is out of date.
@@ -70,21 +70,24 @@ module Inferno
70
70
  # requirement_set_id_2: [row1, row2, row 3, ...]
71
71
  # }
72
72
  def input_requirement_sets
73
- requirement_set_hash = Hash.new { |hash, key| hash[key] = [] }
74
- available_input_worksheets.each_with_object(requirement_set_hash) do |worksheet_file, requirement_sets|
75
- worksheet = Roo::Spreadsheet.open(worksheet_file)
76
- set_identifier = requirement_set_id(worksheet)
77
-
78
- CSV.parse(
79
- worksheet.sheet('Requirements').to_csv,
80
- headers: true
81
- ).each do |row|
82
- row_hash = row.to_h.slice(*INPUT_HEADERS)
83
- row_hash['Sub-Requirement(s)']&.delete_prefix!('mailto:')
84
-
85
- requirement_sets[set_identifier] << row_hash
73
+ @input_requirement_sets ||=
74
+ begin
75
+ requirement_set_hash = Hash.new { |hash, key| hash[key] = [] }
76
+ available_input_worksheets.each_with_object(requirement_set_hash) do |worksheet_file, requirement_sets|
77
+ worksheet = Roo::Spreadsheet.open(worksheet_file)
78
+ set_identifier = requirement_set_id(worksheet)
79
+
80
+ CSV.parse(
81
+ worksheet.sheet('Requirements').to_csv,
82
+ headers: true
83
+ ).each do |row|
84
+ row_hash = row.to_h.slice(*INPUT_HEADERS)
85
+ row_hash['Sub-Requirement(s)']&.delete_prefix!('mailto:')
86
+
87
+ requirement_sets[set_identifier] << row_hash
88
+ end
89
+ end
86
90
  end
87
- end
88
91
  end
89
92
 
90
93
  def new_requirements_csv # rubocop:disable Metrics/CyclomaticComplexity
@@ -125,6 +128,52 @@ module Inferno
125
128
  @old_requirements_csv ||= File.read(requirements_output_file_path)
126
129
  end
127
130
 
131
+ def missing_sub_requirements
132
+ @missing_sub_requirements =
133
+ {}.tap do |missing_requirements|
134
+ repo = Inferno::Repositories::Requirements.new
135
+
136
+ input_requirement_sets
137
+ .each do |requirement_set, requirements|
138
+ requirements.each do |requirement_hash|
139
+ missing_sub_requirements =
140
+ Inferno::Entities::Requirement.expand_requirement_ids(requirement_hash['Sub-Requirement(s)'])
141
+ .reject { |requirement_id| repo.exists? requirement_id }
142
+
143
+ missing_sub_requirements += missing_actor_sub_requirements(requirement_hash['Sub-Requirement(s)'])
144
+
145
+ next if missing_sub_requirements.blank?
146
+
147
+ id = "#{requirement_set}@#{requirement_hash['ID*']}"
148
+
149
+ missing_requirements[id] = missing_sub_requirements
150
+ end
151
+ end
152
+ end
153
+ end
154
+
155
+ def missing_actor_sub_requirements(sub_requirement_string)
156
+ return [] if sub_requirement_string.blank?
157
+
158
+ return [] unless sub_requirement_string.include? '#'
159
+
160
+ sub_requirement_string
161
+ .split(',')
162
+ .map(&:strip)
163
+ .select { |requirement_string| requirement_string.include? '#' }
164
+ .select do |requirement_string|
165
+ Inferno::Entities::Requirement.expand_requirement_ids(requirement_string).blank?
166
+ end
167
+ end
168
+
169
+ def check_sub_requirements
170
+ return if missing_sub_requirements.blank?
171
+
172
+ missing_sub_requirements.each do |id, sub_requirement_ids|
173
+ puts "#{id} is missing the following sub-requirements:\n #{sub_requirement_ids.join(', ')}"
174
+ end
175
+ end
176
+
128
177
  def run
129
178
  check_presence_of_input_files
130
179
 
@@ -147,6 +196,8 @@ module Inferno
147
196
  File.write(requirements_output_file_path, new_requirements_csv, encoding: Encoding::UTF_8)
148
197
  end
149
198
 
199
+ check_sub_requirements
200
+
150
201
  puts 'Done.'
151
202
  end
152
203
 
@@ -167,14 +218,20 @@ module Inferno
167
218
  false
168
219
  end
169
220
 
170
- return if requirements_ok
221
+ unless requirements_ok
222
+ puts <<~MESSAGE
223
+ Check Failed. To resolve, run:
224
+
225
+ bundle exec inferno requirements export_csv
226
+
227
+ MESSAGE
228
+ exit(1)
229
+ end
171
230
 
172
- puts <<~MESSAGE
173
- Check Failed. To resolve, run:
231
+ check_sub_requirements
174
232
 
175
- bundle exec inferno requirements export_csv
233
+ return if missing_sub_requirements.blank?
176
234
 
177
- MESSAGE
178
235
  exit(1)
179
236
  end
180
237
 
@@ -66,8 +66,9 @@ module Inferno
66
66
  # Validate a FHIR resource
67
67
  #
68
68
  # @param resource [FHIR::Model]
69
- # @param profile_url [String] url of the profile to validate against,
70
- # defaults to validating against the base FHIR resource
69
+ # @param profile_url [String] canonical url of the profile to validate against,
70
+ # may include a version separated by a vertical bar (|),
71
+ # and defaults to validating against the base FHIR resource type
71
72
  # @param validator [Symbol] the name of the validator to use
72
73
  # @return [void]
73
74
  def assert_valid_resource(resource: self.resource, profile_url: nil, validator: :default)