Class: Inferno::DSL::FHIRValidation::Validator
- Inherits:
-
Object
- Object
- Inferno::DSL::FHIRValidation::Validator
- Defined in:
- lib/inferno/dsl/fhir_validation.rb
Instance Attribute Summary collapse
-
#requirements ⇒ Object
readonly
Returns the value of attribute requirements.
Instance Method Summary collapse
-
#exclude_message {|message| ... } ⇒ Object
Filter out unwanted validation messages.
-
#perform_additional_validation {|resource, profile_url| ... } ⇒ Object
Perform validation steps in addition to FHIR validation.
-
#resource_is_valid?(resource, profile_url, runnable, add_messages_to_runnable: true, validator_response_details: nil) ⇒ Boolean
rubocop:disable Metrics/CyclomaticComplexity, Lint/UnusedMethodArgument.
-
#url(validator_url = nil) ⇒ Object
Set the url of the validator service.
-
#validate(resource, profile_url) ⇒ String
Post a resource to the validation service for validating.
Instance Attribute Details
#requirements ⇒ Object (readonly)
Returns the value of attribute requirements.
55 56 57 |
# File 'lib/inferno/dsl/fhir_validation.rb', line 55 def requirements @requirements end |
Instance Method Details
#exclude_message {|message| ... } ⇒ Object
Filter out unwanted validation messages. Any messages for which the block evalutates to a truthy value will be excluded.
120 121 122 123 |
# File 'lib/inferno/dsl/fhir_validation.rb', line 120 def (&block) @exclude_message = block if block_given? @exclude_message end |
#perform_additional_validation {|resource, profile_url| ... } ⇒ Object
Perform validation steps in addition to FHIR validation.
101 102 103 |
# File 'lib/inferno/dsl/fhir_validation.rb', line 101 def perform_additional_validation(&block) additional_validations << block end |
#resource_is_valid?(resource, profile_url, runnable, add_messages_to_runnable: true, validator_response_details: nil) ⇒ Boolean
rubocop:disable Metrics/CyclomaticComplexity, Lint/UnusedMethodArgument
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/inferno/dsl/fhir_validation.rb', line 127 def resource_is_valid?(resource, profile_url, runnable, add_messages_to_runnable: true, validator_response_details: nil) profile_url ||= FHIR::Definitions.resource_definition(resource.resourceType).url begin response = call_validator(resource, profile_url) rescue StandardError => e # This could be a complete failure to connect (validator isn't running) # or a timeout (validator took too long to respond). runnable.('error', e.) raise Inferno::Exceptions::ErrorInValidatorException, "Unable to connect to validator at #{url}." end outcome = operation_outcome_from_validator_response(response, runnable) = (outcome, resource, profile_url) if .each { || runnable.([:type], [:message]) } end unless response.status == 200 raise Inferno::Exceptions::ErrorInValidatorException, 'Error occurred in the validator. Review Messages tab or validator service logs for more information.' end .none? { || [:type] == 'error' } rescue Inferno::Exceptions::ErrorInValidatorException raise rescue StandardError => e runnable.('error', e.) raise Inferno::Exceptions::ErrorInValidatorException, 'Error occurred in the validator. Review Messages tab or validator service logs for more information.' end |
#url(validator_url = nil) ⇒ Object
Set the url of the validator service
71 72 73 74 75 |
# File 'lib/inferno/dsl/fhir_validation.rb', line 71 def url(validator_url = nil) @url = validator_url if validator_url @url ||= default_validator_url @url end |
#validate(resource, profile_url) ⇒ String
Post a resource to the validation service for validating.
224 225 226 |
# File 'lib/inferno/dsl/fhir_validation.rb', line 224 def validate(resource, profile_url) call_validator(resource, profile_url).body end |