inferno_core 0.4.24 → 0.4.26
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57454d0d82af134cbd8442876476ccb93ae8dd381a5a57e306b6a6f633a58b63
|
4
|
+
data.tar.gz: 3af45799f0be1f94f8f10242bfdb88e93cd87889fbaae7e3f2f212410d7d6b8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 185562b9ff9f39805ac4a6eb5a4215a583ea997cff81421d9f6445b2011a5244d8702128b60bd2a4b79dd1af4eff3df71ddae87145fd03b121b96f9c3d7fca50
|
7
|
+
data.tar.gz: a5024572e4f88e0a68df5e328dfc8d63e48ad4062c8aa38af62ab562ae21e9f853f380721596a5443148ca921ed33387dbf306fd9ef22eabb6ae36132bfb34e1
|
@@ -50,12 +50,52 @@ module Inferno
|
|
50
50
|
end
|
51
51
|
|
52
52
|
# Set the IGs that the validator will need to load
|
53
|
-
#
|
54
|
-
#
|
55
|
-
|
56
|
-
|
53
|
+
# @example
|
54
|
+
# igs "hl7.fhir.us.core#4.0.0"
|
55
|
+
# @example
|
56
|
+
# igs("hl7.fhir.us.core#3.1.1", "hl7.fhir.us.core#6.0.0")
|
57
|
+
# @param validator_igs [Array<String>]
|
58
|
+
def igs(*validator_igs)
|
59
|
+
cli_context(igs: validator_igs) if validator_igs
|
57
60
|
|
58
|
-
|
61
|
+
cli_context.igs
|
62
|
+
end
|
63
|
+
|
64
|
+
# Set the cliContext used as part of each validation request.
|
65
|
+
# Fields may be passed as either a Hash or block.
|
66
|
+
# Note that all fields included here will be sent directly in requests,
|
67
|
+
# there is no check that the fields are correct.
|
68
|
+
#
|
69
|
+
# @example
|
70
|
+
# fhir_resource_validator do
|
71
|
+
# url 'http://example.com/validator'
|
72
|
+
# cli_context do
|
73
|
+
# noExtensibleBindingMessages true
|
74
|
+
# txServer nil
|
75
|
+
# end
|
76
|
+
# end
|
77
|
+
#
|
78
|
+
# @example
|
79
|
+
# fhir_resource_validator do
|
80
|
+
# url 'http://example.org/validator'
|
81
|
+
# cli_context({
|
82
|
+
# noExtensibleBindingMessages: true,
|
83
|
+
# txServer: nil
|
84
|
+
# })
|
85
|
+
# end
|
86
|
+
#
|
87
|
+
# @param definition [Hash] raw fields to set, optional
|
88
|
+
def cli_context(definition = nil, &)
|
89
|
+
if @cli_context
|
90
|
+
if definition
|
91
|
+
@cli_context.definition.merge!(definition.deep_symbolize_keys)
|
92
|
+
elsif block_given?
|
93
|
+
@cli_context.instance_eval(&)
|
94
|
+
end
|
95
|
+
else
|
96
|
+
@cli_context = CliContext.new(definition || {}, &)
|
97
|
+
end
|
98
|
+
@cli_context
|
59
99
|
end
|
60
100
|
|
61
101
|
# @private
|
@@ -193,19 +233,13 @@ module Inferno
|
|
193
233
|
def wrap_resource_for_hl7_wrapper(resource, profile_url)
|
194
234
|
wrapped_resource = {
|
195
235
|
cliContext: {
|
196
|
-
|
197
|
-
sv: '4.0.1',
|
198
|
-
# displayWarnings: true, # -display-issues-are-warnings
|
199
|
-
# txServer: nil, # -tx n/a
|
200
|
-
igs: @igs || [],
|
201
|
-
# NOTE: this profile must be part of a loaded IG,
|
202
|
-
# otherwise the response is an HTTP 500 with no content
|
236
|
+
**cli_context.definition,
|
203
237
|
profiles: [profile_url]
|
204
238
|
},
|
205
239
|
filesToValidate: [
|
206
240
|
{
|
207
241
|
fileName: "#{resource.resourceType}/#{resource.id}.json",
|
208
|
-
fileContent: resource.
|
242
|
+
fileContent: resource.source_contents,
|
209
243
|
fileType: 'json'
|
210
244
|
}
|
211
245
|
],
|
@@ -259,6 +293,39 @@ module Inferno
|
|
259
293
|
end
|
260
294
|
end
|
261
295
|
|
296
|
+
# @private
|
297
|
+
class CliContext
|
298
|
+
attr_reader :definition
|
299
|
+
|
300
|
+
CLICONTEXT_DEFAULTS = {
|
301
|
+
sv: '4.0.1',
|
302
|
+
doNative: false,
|
303
|
+
extensions: ['any']
|
304
|
+
}.freeze
|
305
|
+
|
306
|
+
# @private
|
307
|
+
def initialize(definition, &)
|
308
|
+
@definition = CLICONTEXT_DEFAULTS.merge(definition.deep_symbolize_keys)
|
309
|
+
instance_eval(&) if block_given?
|
310
|
+
end
|
311
|
+
|
312
|
+
# @private
|
313
|
+
def method_missing(method_name, *args)
|
314
|
+
# Interpret any other method as setting a field on cliContext.
|
315
|
+
# Follow the same format as `Validator.url` here:
|
316
|
+
# only set the value if one is provided.
|
317
|
+
# args will be an empty array if no value is provided.
|
318
|
+
definition[method_name] = args[0] unless args.empty?
|
319
|
+
|
320
|
+
definition[method_name]
|
321
|
+
end
|
322
|
+
|
323
|
+
# @private
|
324
|
+
def respond_to_missing?(_method_name, _include_private = false)
|
325
|
+
true
|
326
|
+
end
|
327
|
+
end
|
328
|
+
|
262
329
|
module ClassMethods
|
263
330
|
# @private
|
264
331
|
def fhir_validators
|