Skip to content

Commit

Permalink
accessing sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
rpassas committed Jan 19, 2024
1 parent c8c1a01 commit b9da3e2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions lib/inferno/dsl/fhir_resource_validation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ def self.included(klass)

class Validator
attr_reader :requirements
attr_accessor :session_id
attr_accessor :session_id, :name, :test_suite_id

# @private
def initialize(requirements = nil, &)
def initialize(name, test_suite_id, requirements = nil, &)
@name = name
@test_suite_id = test_suite_id
instance_eval(&)
@requirements = requirements
end
Expand Down Expand Up @@ -231,6 +233,7 @@ def issue_message(issue, resource)

# @private
def wrap_resource_for_hl7_wrapper(resource, profile_url)
validator_session_id = Inferno::Repositories::ValidatorSessions.new.validator_session(test_suite_id, name.to_s) || @session_id
wrapped_resource = {
cliContext: {
**cli_context.definition,
Expand All @@ -243,7 +246,7 @@ def wrap_resource_for_hl7_wrapper(resource, profile_url)
fileType: 'json'
}
],
sessionId: @session_id
sessionId: validator_session_id
}
wrapped_resource.to_json
end
Expand Down Expand Up @@ -353,7 +356,7 @@ def fhir_validators
def fhir_resource_validator(name = :default, required_suite_options: nil, &block)
current_validators = fhir_validators[name] || []

new_validator = Inferno::DSL::FHIRResourceValidation::Validator.new(required_suite_options, &block)
new_validator = Inferno::DSL::FHIRResourceValidation::Validator.new(name, id, required_suite_options, &block)

current_validators.reject! { |validator| validator.requirements == required_suite_options }
current_validators << new_validator
Expand Down
2 changes: 1 addition & 1 deletion lib/inferno/jobs/invoke_validator_session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def perform(suite_id, validator_name, validator_index)
session_repo = Inferno::Repositories::ValidatorSessions.new
begin
result = session_repo.create(test_suite_id: suite_id, validator_session_id: session_id, \
validator_name:, validator_index:)
validator_name:)
rescue Sequel::ValidationFailed => e
puts e.message
end
Expand Down

0 comments on commit b9da3e2

Please sign in to comment.