inferno_core 1.0.8 → 1.1.1
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/web/serializers/test.rb +1 -0
- data/lib/inferno/dsl/assertions.rb +55 -6
- data/lib/inferno/dsl/fhir_client.rb +3 -0
- data/lib/inferno/dsl/fhir_resource_validation.rb +481 -149
- data/lib/inferno/dsl/fhir_validation.rb +46 -3
- data/lib/inferno/dsl/http_client.rb +28 -0
- data/lib/inferno/dsl/messages.rb +10 -0
- data/lib/inferno/dsl/runnable.rb +15 -0
- data/lib/inferno/exceptions.rb +7 -0
- data/lib/inferno/jobs/invoke_validator_session.rb +1 -10
- data/lib/inferno/public/bundle.js +11 -11
- data/lib/inferno/version.rb +1 -1
- data/spec/spec_helper.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cc9addf71b6ea91eb5aa426eabe24df9a2cbdb3199271e3f60d8e66f1cacd8cc
|
|
4
|
+
data.tar.gz: 16fd0eaf84e1c2a391ba90efcedbeae1a24f82ad45dcc9b7a8b5e2365ed3d53d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0eed6f34c2f0cfd4a78f12d7dc4ce853480520d740e4af6da052ec4b4eb2d3551ff4208e99516990438a957dcccf8a0ad38f01aaae34224b5286086fb88d4095
|
|
7
|
+
data.tar.gz: 0fc841b4d2ad71f098061277d9041caa6633e36679276ca6db2db8553c22a383d63c950196aacb661b9175b398aa8e80da5f5e8cd9b90d377019afb8b14d04b9
|
|
@@ -21,6 +21,7 @@ module Inferno
|
|
|
21
21
|
field :input_instructions
|
|
22
22
|
field :user_runnable?, name: :user_runnable
|
|
23
23
|
field :optional?, name: :optional
|
|
24
|
+
field :simulation_verification?, name: :is_simulation_verification
|
|
24
25
|
field :verifies_requirements, if: :field_present?, extractor: RequirementsFilteringExtractor
|
|
25
26
|
end
|
|
26
27
|
end
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require_relative '../exceptions'
|
|
2
|
+
require_relative 'messages'
|
|
2
3
|
|
|
3
4
|
module Inferno
|
|
4
5
|
module DSL
|
|
@@ -7,6 +8,7 @@ module Inferno
|
|
|
7
8
|
# immediately stop execution and receive a `fail` result. Additional
|
|
8
9
|
# assertions added to this module will be available in all tests.
|
|
9
10
|
module Assertions
|
|
11
|
+
include Messages
|
|
10
12
|
# Make an assertion
|
|
11
13
|
#
|
|
12
14
|
# @param test a value whose truthiness will determine whether the
|
|
@@ -59,6 +61,7 @@ module Inferno
|
|
|
59
61
|
# @private
|
|
60
62
|
def invalid_resource_message(resource, profile_url)
|
|
61
63
|
return "Resource does not conform to the profile: #{profile_url}" if profile_url.present?
|
|
64
|
+
return 'No resource to validate.' unless resource.present?
|
|
62
65
|
|
|
63
66
|
"Resource does not conform to the base #{resource&.resourceType} profile."
|
|
64
67
|
end
|
|
@@ -70,12 +73,31 @@ module Inferno
|
|
|
70
73
|
# may include a version separated by a vertical bar (|),
|
|
71
74
|
# and defaults to validating against the base FHIR resource type
|
|
72
75
|
# @param validator [Symbol] the name of the validator to use
|
|
76
|
+
# @param message_prefix [String] Prefix to add to the start of logged messages
|
|
73
77
|
# @return [void]
|
|
74
|
-
def assert_valid_resource(resource: self.resource, profile_url: nil, validator: :default)
|
|
75
|
-
assert resource_is_valid?(resource:, profile_url:, validator:),
|
|
78
|
+
def assert_valid_resource(resource: self.resource, profile_url: nil, validator: :default, message_prefix: '')
|
|
79
|
+
assert resource_is_valid?(resource:, profile_url:, validator:, message_prefix:),
|
|
76
80
|
invalid_resource_message(resource, profile_url)
|
|
77
81
|
end
|
|
78
82
|
|
|
83
|
+
# @private
|
|
84
|
+
def invalid_object_message(model_url)
|
|
85
|
+
"Object does not conform to the logical model: #{model_url}"
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# Validate an object against a logical model
|
|
89
|
+
#
|
|
90
|
+
# @param object [Hash]
|
|
91
|
+
# @param model_url [String] canonical url of the model to validate against,
|
|
92
|
+
# may include a version separated by a vertical bar (|),
|
|
93
|
+
# @param validator [Symbol] the name of the validator to use
|
|
94
|
+
# @param message_prefix [String] Prefix to add to the start of logged messages
|
|
95
|
+
# @return [void]
|
|
96
|
+
def assert_conformance_to_logical_model(object, model_url, validator: :default, message_prefix: '')
|
|
97
|
+
assert conforms_to_logical_model?(object, model_url, validator:, message_prefix:),
|
|
98
|
+
invalid_object_message(model_url)
|
|
99
|
+
end
|
|
100
|
+
|
|
79
101
|
# Validate each entry of a Bundle
|
|
80
102
|
#
|
|
81
103
|
# @param bundle [FHIR::Bundle]
|
|
@@ -87,6 +109,7 @@ module Inferno
|
|
|
87
109
|
# types as keys and profile urls (or nil) as values, only those resource
|
|
88
110
|
# types will be validated against the provided profile url or the base
|
|
89
111
|
# resource if nil.
|
|
112
|
+
# @param message_prefix [String] Prefix to add to the start of logged messages
|
|
90
113
|
# @example
|
|
91
114
|
# # Only validate Patient bundle entries
|
|
92
115
|
# assert_valid_bundle_entries(resource_types: 'Patient')
|
|
@@ -104,7 +127,7 @@ module Inferno
|
|
|
104
127
|
# }
|
|
105
128
|
# )
|
|
106
129
|
# @return [void]
|
|
107
|
-
def assert_valid_bundle_entries(bundle: resource, resource_types: {})
|
|
130
|
+
def assert_valid_bundle_entries(bundle: resource, resource_types: {}, message_prefix: '')
|
|
108
131
|
assert_resource_type('Bundle', resource: bundle)
|
|
109
132
|
|
|
110
133
|
types_to_check = normalize_types_to_check(resource_types)
|
|
@@ -115,7 +138,7 @@ module Inferno
|
|
|
115
138
|
.map(&:resource)
|
|
116
139
|
.select { |resource| types_to_check.empty? || types_to_check.include?(resource.resourceType) }
|
|
117
140
|
.reject do |resource|
|
|
118
|
-
validation_params = { resource: }
|
|
141
|
+
validation_params = { resource:, message_prefix: }
|
|
119
142
|
profile = types_to_check[resource.resourceType]
|
|
120
143
|
validation_params[:profile_url] = profile if profile
|
|
121
144
|
|
|
@@ -161,9 +184,25 @@ module Inferno
|
|
|
161
184
|
# @param message [String] extra failure message
|
|
162
185
|
# @return [void]
|
|
163
186
|
def assert_valid_json(maybe_json_string, message = '')
|
|
164
|
-
|
|
187
|
+
parsed_json_if_valid(maybe_json_string, message, continue: false)
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
# Return parsed json Hash if valid, or indicate an error with an error message or a failed assert
|
|
191
|
+
#
|
|
192
|
+
# @param maybe_json_string [String]
|
|
193
|
+
# @param message [String] extra failure message
|
|
194
|
+
# @param continue [Boolean] if true will log an error message and continue,
|
|
195
|
+
# otherwise will raise an assert exception
|
|
196
|
+
# @return [void]
|
|
197
|
+
def parsed_json_if_valid(maybe_json_string, message = '', continue: true)
|
|
198
|
+
JSON.parse(maybe_json_string)
|
|
165
199
|
rescue JSON::ParserError
|
|
166
|
-
|
|
200
|
+
if continue
|
|
201
|
+
add_message(:error, "Invalid JSON. #{message}")
|
|
202
|
+
nil
|
|
203
|
+
else
|
|
204
|
+
assert false, "Invalid JSON. #{message}"
|
|
205
|
+
end
|
|
167
206
|
end
|
|
168
207
|
|
|
169
208
|
# Check for a valid http/https uri
|
|
@@ -224,6 +263,16 @@ module Inferno
|
|
|
224
263
|
"Could not find #{missing_elements.join(', ')} in the #{resources.length} " \
|
|
225
264
|
'provided resource(s)'
|
|
226
265
|
end
|
|
266
|
+
|
|
267
|
+
# Check that there are no messages associated with the current runnable with a type of 'error'
|
|
268
|
+
#
|
|
269
|
+
# @param message [String] failure message
|
|
270
|
+
# @param message_list [Array] (optional) list of messages to check for errors,
|
|
271
|
+
# if different from the runnable's messages
|
|
272
|
+
# @return [void]
|
|
273
|
+
def assert_no_error_messages(message = '', message_list: messages)
|
|
274
|
+
assert !error_messages?(message_list:), message.present? ? message : 'Errors found - see Messages for details.'
|
|
275
|
+
end
|
|
227
276
|
end
|
|
228
277
|
end
|
|
229
278
|
end
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
require_relative 'fhir_client_builder'
|
|
2
2
|
require_relative 'request_storage'
|
|
3
3
|
require_relative 'tcp_exception_handler'
|
|
4
|
+
require_relative 'messages'
|
|
4
5
|
|
|
5
6
|
module Inferno
|
|
6
7
|
module DSL
|
|
@@ -37,6 +38,8 @@ module Inferno
|
|
|
37
38
|
# @see Inferno::DSL::FHIRClientBuilder Documentation for the client
|
|
38
39
|
# configuration DSL
|
|
39
40
|
module FHIRClient
|
|
41
|
+
include Messages
|
|
42
|
+
|
|
40
43
|
# @private
|
|
41
44
|
def self.included(klass)
|
|
42
45
|
klass.extend ClassMethods
|