inferno_core 1.0.5 → 1.0.6
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 +4 -4
- data/lib/inferno/apps/cli/templates/lib/%library_name%/.DS_Store +0 -0
- data/lib/inferno/apps/cli/templates/lib/.DS_Store +0 -0
- data/lib/inferno/dsl/fhir_resource_navigation.rb +30 -8
- data/lib/inferno/dsl/result_collection.rb +88 -0
- data/lib/inferno/dsl.rb +2 -0
- data/lib/inferno/entities/test_group.rb +2 -2
- data/lib/inferno/entities/test_suite.rb +2 -2
- data/lib/inferno/public/bundle.js +8 -8
- data/lib/inferno/result_summarizer.rb +2 -1
- data/lib/inferno/version.rb +1 -1
- metadata +5 -3
- data/lib/inferno/result_collection.rb +0 -72
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4cee81fb82d77d10a15e555d118fb4dcb7c38bda12176ac5d4f6e835487ea7a
|
4
|
+
data.tar.gz: 3f6144ea9c28c260b6701a7c849cb4b10d530657ba8e72f3e9fbe80a40858b80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9a5ec40918160f8dcc099f69c2970cfd90857ed4f74ddda4df1f3f399f44a8a2d83bc33ce31bf69f149371b68405751a1b8d4d12376f58f97b27a3620b13e10
|
7
|
+
data.tar.gz: f9d7425ac56f6589406af7125acc8bcba9fde8db134a40fb74ec7c5908619e22ce48506d6cce8e27b2d83b575c0015b059370c248d81be9ebe718a0632578248
|
Binary file
|
Binary file
|
@@ -2,16 +2,21 @@ require_relative 'primitive_type'
|
|
2
2
|
|
3
3
|
module Inferno
|
4
4
|
module DSL
|
5
|
-
# The FHIRResourceNavigation module is used to pick values from a FHIR
|
6
|
-
# Originally intended for use for verifying
|
7
|
-
#
|
8
|
-
#
|
5
|
+
# The FHIRResourceNavigation module is used to pick values from a FHIR
|
6
|
+
# resource, based on a profile. Originally intended for use for verifying
|
7
|
+
# the presence of Must Support elements on a resource and finding values to
|
8
|
+
# use for search parameters. The methods in this module related to slices
|
9
|
+
# expects pre-processed metadata defining the elements of the profile to be
|
10
|
+
# present in the attribute `metadata` in the including class.
|
11
|
+
#
|
9
12
|
# @see Inferno::DSL::MustSupportMetadataExtractor
|
10
13
|
module FHIRResourceNavigation
|
11
14
|
DAR_EXTENSION_URL = 'http://hl7.org/fhir/StructureDefinition/data-absent-reason'.freeze
|
12
15
|
PRIMITIVE_DATA_TYPES = FHIR::PRIMITIVES.keys
|
13
16
|
|
14
|
-
# Get a value from the given FHIR element(s) by walking the given path
|
17
|
+
# Get a value from the given FHIR element(s) by walking the given path
|
18
|
+
# through the element.
|
19
|
+
#
|
15
20
|
# @param elements [FHIR::Model, Array<FHIR::Model>]
|
16
21
|
# @param path [String]
|
17
22
|
# @return [Array<FHIR::Model>]
|
@@ -29,9 +34,11 @@ module Inferno
|
|
29
34
|
end.compact
|
30
35
|
end
|
31
36
|
|
32
|
-
# Get a value from the given FHIR element(s), by navigating through the
|
33
|
-
# Fields with a DataAbsentReason extension
|
34
|
-
#
|
37
|
+
# Get a value from the given FHIR element(s), by navigating through the
|
38
|
+
# resource to the given path. Fields with a DataAbsentReason extension
|
39
|
+
# present will be excluded unless include_dar is true. To filter the
|
40
|
+
# resulting elements, a block may be passed in.
|
41
|
+
#
|
35
42
|
# @param given_element [FHIR::Model, Array<FHIR::Model>]
|
36
43
|
# @param path [String]
|
37
44
|
# @param include_dar [Boolean]
|
@@ -56,6 +63,7 @@ module Inferno
|
|
56
63
|
nil
|
57
64
|
end
|
58
65
|
|
66
|
+
# @private
|
59
67
|
def find_in_elements(elements, include_dar: false, &)
|
60
68
|
unless include_dar
|
61
69
|
elements = elements.reject do |el|
|
@@ -68,6 +76,7 @@ module Inferno
|
|
68
76
|
elements.first
|
69
77
|
end
|
70
78
|
|
79
|
+
# @private
|
71
80
|
def get_next_value(element, property)
|
72
81
|
extension_url = property[/(?<=where\(url=').*(?='\))/]
|
73
82
|
if extension_url.present?
|
@@ -85,6 +94,7 @@ module Inferno
|
|
85
94
|
nil
|
86
95
|
end
|
87
96
|
|
97
|
+
# @private
|
88
98
|
def get_primitive_type_value(element, property, value)
|
89
99
|
source_value = element.source_hash["_#{property}"]
|
90
100
|
|
@@ -95,6 +105,7 @@ module Inferno
|
|
95
105
|
primitive_value
|
96
106
|
end
|
97
107
|
|
108
|
+
# @private
|
98
109
|
def local_field_name(field_name)
|
99
110
|
# fhir_models prepends fields whose names are reserved in ruby with "local_"
|
100
111
|
# This should be used before `x.send(field_name)`
|
@@ -105,6 +116,7 @@ module Inferno
|
|
105
116
|
end
|
106
117
|
end
|
107
118
|
|
119
|
+
# @private
|
108
120
|
def find_slice_via_discriminator(element, property)
|
109
121
|
return unless metadata.present?
|
110
122
|
|
@@ -117,6 +129,7 @@ module Inferno
|
|
117
129
|
slices.find { |slice| matching_slice?(slice, discriminator) }
|
118
130
|
end
|
119
131
|
|
132
|
+
# @private
|
120
133
|
def matching_slice?(slice, discriminator)
|
121
134
|
case discriminator[:type]
|
122
135
|
when 'patternCodeableConcept'
|
@@ -134,6 +147,7 @@ module Inferno
|
|
134
147
|
end
|
135
148
|
end
|
136
149
|
|
150
|
+
# @private
|
137
151
|
def matching_pattern_codeable_concept_slice?(slice, discriminator)
|
138
152
|
slice_value = discriminator[:path].present? ? slice.send((discriminator[:path]).to_s)&.coding : slice.coding
|
139
153
|
slice_value&.any? do |coding|
|
@@ -141,20 +155,24 @@ module Inferno
|
|
141
155
|
end
|
142
156
|
end
|
143
157
|
|
158
|
+
# @private
|
144
159
|
def matching_pattern_coding_slice?(slice, discriminator)
|
145
160
|
slice_value = discriminator[:path].present? ? slice.send(discriminator[:path]) : slice
|
146
161
|
slice_value&.code == discriminator[:code] && slice_value&.system == discriminator[:system]
|
147
162
|
end
|
148
163
|
|
164
|
+
# @private
|
149
165
|
def matching_pattern_identifier_slice?(slice, discriminator)
|
150
166
|
slice.system == discriminator[:system]
|
151
167
|
end
|
152
168
|
|
169
|
+
# @private
|
153
170
|
def matching_value_slice?(slice, discriminator)
|
154
171
|
values = discriminator[:values].map { |value| value.merge(path: value[:path].split('.')) }
|
155
172
|
verify_slice_by_values(slice, values)
|
156
173
|
end
|
157
174
|
|
175
|
+
# @private
|
158
176
|
def matching_type_slice?(slice, discriminator)
|
159
177
|
case discriminator[:code]
|
160
178
|
when 'Date'
|
@@ -176,6 +194,7 @@ module Inferno
|
|
176
194
|
end
|
177
195
|
end
|
178
196
|
|
197
|
+
# @private
|
179
198
|
def matching_required_binding_slice?(slice, discriminator)
|
180
199
|
slice_coding = discriminator[:path].present? ? slice.send((discriminator[:path]).to_s).coding : slice.coding
|
181
200
|
slice_coding.any? do |coding|
|
@@ -190,6 +209,7 @@ module Inferno
|
|
190
209
|
end
|
191
210
|
end
|
192
211
|
|
212
|
+
# @private
|
193
213
|
def verify_slice_by_values(element, value_definitions)
|
194
214
|
path_prefixes = value_definitions.map { |value_definition| value_definition[:path].first }.uniq
|
195
215
|
path_prefixes.all? do |path_prefix|
|
@@ -203,6 +223,7 @@ module Inferno
|
|
203
223
|
end
|
204
224
|
end
|
205
225
|
|
226
|
+
# @private
|
206
227
|
def current_and_child_values_match?(el_found, value_definitions_for_path)
|
207
228
|
child_element_value_definitions, current_element_value_definitions =
|
208
229
|
value_definitions_for_path.partition { |value_definition| value_definition[:path].present? }
|
@@ -220,6 +241,7 @@ module Inferno
|
|
220
241
|
current_element_values_match && child_element_values_match
|
221
242
|
end
|
222
243
|
|
244
|
+
# @private
|
223
245
|
def flatten_bundles(resources)
|
224
246
|
resources.flat_map do |resource|
|
225
247
|
if resource&.resourceType == 'Bundle'
|
@@ -0,0 +1,88 @@
|
|
1
|
+
module Inferno
|
2
|
+
module DSL
|
3
|
+
# The ResultCollection class is used to manage a collection of Inferno::Entities::Result objects.
|
4
|
+
# It provides methods to filter required and optional results, access results
|
5
|
+
# by index or by their runnable IDs, and iterate over the collection.
|
6
|
+
#
|
7
|
+
# @example
|
8
|
+
#
|
9
|
+
# results = [
|
10
|
+
# Result.new(test_group_id: 'group_id1', result: 'pass'),
|
11
|
+
# Result.new(test_group_id: 'group_id2', result: 'fail'),
|
12
|
+
# Result.new(test_group_id: 'group_id3', result: 'pass')
|
13
|
+
# ]
|
14
|
+
#
|
15
|
+
# result_collection = Inferno::DSL::ResultCollection.new(results)
|
16
|
+
#
|
17
|
+
# # Access by index
|
18
|
+
# result = result_collection[0]
|
19
|
+
#
|
20
|
+
# # Access by runnable ID (partial)
|
21
|
+
# result = result_collection['group_id2']
|
22
|
+
#
|
23
|
+
# # Iterate over results
|
24
|
+
# result_collection.each do |result|
|
25
|
+
# puts result.result
|
26
|
+
# end
|
27
|
+
#
|
28
|
+
# # Get required results
|
29
|
+
# required_results = result_collection.required_results
|
30
|
+
#
|
31
|
+
# # Get optional results
|
32
|
+
# optional_results = result_collection.optional_results
|
33
|
+
class ResultCollection
|
34
|
+
include Enumerable
|
35
|
+
|
36
|
+
attr_reader :results
|
37
|
+
|
38
|
+
def initialize(results = [])
|
39
|
+
@results = results
|
40
|
+
end
|
41
|
+
|
42
|
+
# If given an integer, returns the result at that index. If given a string
|
43
|
+
# or symbol, it will return the result for the runnable whose id matches
|
44
|
+
# the provided string/symbol.
|
45
|
+
#
|
46
|
+
# @param key [Integer, String, Symbol]
|
47
|
+
# @return [Inferno::DSL::Result]
|
48
|
+
def [](key)
|
49
|
+
key.is_a?(Integer) ? results[key] : lookup_by_runnable_id(key)
|
50
|
+
end
|
51
|
+
|
52
|
+
def <<(result)
|
53
|
+
(results << result).flatten!
|
54
|
+
self
|
55
|
+
end
|
56
|
+
|
57
|
+
def each(&)
|
58
|
+
return to_enum(:each) unless block_given?
|
59
|
+
|
60
|
+
results.each(&)
|
61
|
+
self
|
62
|
+
end
|
63
|
+
|
64
|
+
# Returns the results for required runnables
|
65
|
+
#
|
66
|
+
# @return Array<Inferno::Entities::Result>
|
67
|
+
def required_results
|
68
|
+
results.select(&:required?)
|
69
|
+
end
|
70
|
+
|
71
|
+
# Returns the results for optional runnables
|
72
|
+
#
|
73
|
+
# @return Array<Inferno::Entities::Result>
|
74
|
+
def optional_results
|
75
|
+
results.select(&:optional?)
|
76
|
+
end
|
77
|
+
|
78
|
+
private
|
79
|
+
|
80
|
+
def lookup_by_runnable_id(key)
|
81
|
+
results.find { |result| result.runnable&.id == key.to_s || result.runnable&.id&.end_with?("-#{key}") }
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
# For backwards compatibility
|
87
|
+
ResultCollection = DSL::ResultCollection
|
88
|
+
end
|
data/lib/inferno/dsl.rb
CHANGED
@@ -3,6 +3,7 @@ require_relative 'dsl/auth_info'
|
|
3
3
|
require_relative 'dsl/fhir_client'
|
4
4
|
require_relative 'dsl/fhir_validation'
|
5
5
|
require_relative 'dsl/fhir_evaluation/evaluator'
|
6
|
+
require_relative 'dsl/fhir_resource_navigation'
|
6
7
|
require_relative 'dsl/fhir_resource_validation'
|
7
8
|
require_relative 'dsl/fhirpath_evaluation'
|
8
9
|
require_relative 'dsl/http_client'
|
@@ -22,6 +23,7 @@ module Inferno
|
|
22
23
|
Results,
|
23
24
|
FHIRValidation,
|
24
25
|
FHIREvaluation,
|
26
|
+
FHIRResourceNavigation,
|
25
27
|
FHIRResourceValidation,
|
26
28
|
FhirpathEvaluation,
|
27
29
|
Messages,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require_relative '../dsl'
|
2
2
|
require_relative '../repositories/test_groups'
|
3
|
-
require_relative '../result_collection'
|
3
|
+
require_relative '../dsl/result_collection'
|
4
4
|
|
5
5
|
module Inferno
|
6
6
|
module Entities
|
@@ -21,7 +21,7 @@ module Inferno
|
|
21
21
|
|
22
22
|
# @private
|
23
23
|
def initialize
|
24
|
-
@results = Inferno::ResultCollection.new
|
24
|
+
@results = Inferno::DSL::ResultCollection.new
|
25
25
|
end
|
26
26
|
|
27
27
|
# @private
|
@@ -6,7 +6,7 @@ require_relative '../dsl/messages'
|
|
6
6
|
require_relative '../dsl/links'
|
7
7
|
require_relative '../repositories/test_groups'
|
8
8
|
require_relative '../repositories/test_suites'
|
9
|
-
require_relative '../result_collection'
|
9
|
+
require_relative '../dsl/result_collection'
|
10
10
|
require_relative '../dsl/short_id_manager'
|
11
11
|
|
12
12
|
module Inferno
|
@@ -33,7 +33,7 @@ module Inferno
|
|
33
33
|
|
34
34
|
# @private
|
35
35
|
def initialize
|
36
|
-
@results = Inferno::ResultCollection.new
|
36
|
+
@results = Inferno::DSL::ResultCollection.new
|
37
37
|
end
|
38
38
|
|
39
39
|
class << self
|