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: ab9c01a985f9ceb43cc9ad79ddb604cc246b19dfa39f09b323c7677ed347aa88
4
- data.tar.gz: 05aa6e68ea46177b1fab155052e1c84fe7c09368eca5ada5f9a5d933ff270a07
3
+ metadata.gz: 57454d0d82af134cbd8442876476ccb93ae8dd381a5a57e306b6a6f633a58b63
4
+ data.tar.gz: 3af45799f0be1f94f8f10242bfdb88e93cd87889fbaae7e3f2f212410d7d6b8c
5
5
  SHA512:
6
- metadata.gz: f2879c429dea880db81928b84a0b17afbc06dab2dc2dae2bd088918ac0e25e594b13b12b1bd4f01943c698c382acd1f85ae07a2b14b0b8eea07484e23cc0eb8e
7
- data.tar.gz: 5bc9bcf0b1006acf2fd46962d0e69609f343b480c88b832f1465382001029dc5b97353fb80ae3dd22c9c32e375012a290b585f9064eabb2e22816855b9d51612
6
+ metadata.gz: 185562b9ff9f39805ac4a6eb5a4215a583ea997cff81421d9f6445b2011a5244d8702128b60bd2a4b79dd1af4eff3df71ddae87145fd03b121b96f9c3d7fca50
7
+ data.tar.gz: a5024572e4f88e0a68df5e328dfc8d63e48ad4062c8aa38af62ab562ae21e9f853f380721596a5443148ca921ed33387dbf306fd9ef22eabb6ae36132bfb34e1
@@ -34,6 +34,9 @@
34
34
  display: none;
35
35
  }
36
36
  }
37
+ body {
38
+ margin: 0;
39
+ }
37
40
  .wrapper {
38
41
  height: 100%;
39
42
  display: flex;
@@ -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
@@ -80,7 +80,7 @@ module Inferno
80
80
 
81
81
  return true if expires_in.blank?
82
82
 
83
- token_retrieval_time.to_i + expires_in - DateTime.now.to_i < 60
83
+ token_retrieval_time.to_i + expires_in.to_i - DateTime.now.to_i < 60
84
84
  end
85
85
 
86
86
  # @private