Module: Inferno::DSL::FHIRValidation

Included in:
Entities::TestGroup, Entities::TestSuite
Defined in:
lib/inferno/dsl/fhir_validation.rb

Overview

This module contains the methods needed to configure a validator to perform validation of FHIR resources. The actual validation is performed by an external FHIR validation service. Tests will typically rely on assert_valid_resource for validation rather than directly calling methods on a validator.

Examples:


validator do
  url 'http://example.com/validator'
  exclude_message { |message| message.type == 'info' }
  perform_additional_validation do |resource, profile_url|
    if something_is_wrong
      { type: 'error', message: 'something is wrong' }
    else
      { type: 'info', message: 'everything is ok' }
    end
  end
end

Defined Under Namespace

Modules: ClassMethods Classes: Validator

Instance Method Summary collapse

Instance Method Details

#find_validator(validator_name) ⇒ Object

Find a particular validator. Looks through a runnable’s parents up to the suite to find a validator with a particular name



44
45
46
# File 'lib/inferno/dsl/fhir_validation.rb', line 44

def find_validator(validator_name)
  self.class.find_validator(validator_name, suite_options)
end

#resource_is_valid?(resource: self.resource, profile_url: nil, validator: :default, add_messages_to_runnable: true) ⇒ Boolean

Perform validation, and add validation messages to the runnable

Parameters:

  • resource (FHIR::Model) (defaults to: self.resource)
  • profile_url (String) (defaults to: nil)
  • validator (Symbol) (defaults to: :default)

    the name of the validator to use

  • add_messages_to_runnable (Boolean) (defaults to: true)

    whether to add validation messages to runnable or not

Returns:

  • (Boolean)

    whether the resource is valid



35
36
37
38
39
40
# File 'lib/inferno/dsl/fhir_validation.rb', line 35

def resource_is_valid?(
  resource: self.resource, profile_url: nil,
  validator: :default, add_messages_to_runnable: true
)
  find_validator(validator).resource_is_valid?(resource, profile_url, self, add_messages_to_runnable:)
end