inferno_core 0.4.24 → 0.4.25

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: ab9c01a985f9ceb43cc9ad79ddb604cc246b19dfa39f09b323c7677ed347aa88
4
- data.tar.gz: 05aa6e68ea46177b1fab155052e1c84fe7c09368eca5ada5f9a5d933ff270a07
3
+ metadata.gz: 53dd42c86435fdf6b5ad2c900d54473cadbb8bacba17e9bef9a50f8c79e44403
4
+ data.tar.gz: f3c272fb7883ea70be89968bc7df47d15dfe123545d8f5da4a049766de54d343
5
5
  SHA512:
6
- metadata.gz: f2879c429dea880db81928b84a0b17afbc06dab2dc2dae2bd088918ac0e25e594b13b12b1bd4f01943c698c382acd1f85ae07a2b14b0b8eea07484e23cc0eb8e
7
- data.tar.gz: 5bc9bcf0b1006acf2fd46962d0e69609f343b480c88b832f1465382001029dc5b97353fb80ae3dd22c9c32e375012a290b585f9064eabb2e22816855b9d51612
6
+ metadata.gz: f03a19d7206420a9a4fe709ce3e91bb0f07c61e6ec80628ae8ca4a481d652a8116b24e4f7b40435d55300442d41e83f5841a4450a96560101396a9805ac75626
7
+ data.tar.gz: 932878abdf1d03a5c9d55a5dc58973ba2b0228b9386d0be157cb0f4d0e8d5cba040998810be0aad6d6e58161e609278c0311b1e78e9af35ac8254ab5092d7414
@@ -50,12 +50,52 @@ module Inferno
50
50
  end
51
51
 
52
52
  # Set the IGs that the validator will need to load
53
- # Example: ["hl7.fhir.us.core#4.0.0"]
54
- # @param igs [Array<String>]
55
- def igs(validator_igs = nil)
56
- @igs = validator_igs if validator_igs
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
- @igs
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
- # TODO: these should be configurable as well
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.to_json,
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