Class: IpaTestKit::ProvenanceValidator
- Inherits:
-
Object
- Object
- IpaTestKit::ProvenanceValidator
- Includes:
- FHIRResourceNavigation
- Defined in:
- lib/ipa_test_kit/provenance_validator.rb
Constant Summary
Constants included from FHIRResourceNavigation
FHIRResourceNavigation::DAR_EXTENSION_URL
Instance Attribute Summary collapse
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
-
#validation_messages ⇒ Object
readonly
Returns the value of attribute validation_messages.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(resource) ⇒ ProvenanceValidator
constructor
A new instance of ProvenanceValidator.
- #validate ⇒ Object
Methods included from FHIRResourceNavigation
#find_a_value_at, #get_next_value, #resolve_path
Constructor Details
#initialize(resource) ⇒ ProvenanceValidator
Returns a new instance of ProvenanceValidator.
13 14 15 16 |
# File 'lib/ipa_test_kit/provenance_validator.rb', line 13 def initialize(resource) @resource = resource @validation_messages = [] end |
Instance Attribute Details
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
11 12 13 |
# File 'lib/ipa_test_kit/provenance_validator.rb', line 11 def resource @resource end |
#validation_messages ⇒ Object (readonly)
Returns the value of attribute validation_messages.
11 12 13 |
# File 'lib/ipa_test_kit/provenance_validator.rb', line 11 def @validation_messages end |
Class Method Details
.validate ⇒ Object
7 8 9 |
# File 'lib/ipa_test_kit/provenance_validator.rb', line 7 def self.validate(...) new(...).validate end |
Instance Method Details
#validate ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ipa_test_kit/provenance_validator.rb', line 18 def validate # Invariant provenance-1 in US Core 5 causes validation error. See FHIR-39518 return unless resource.instance_of?(FHIR::Provenance) failed_provenance = find_a_value_at(resource, 'agent') do |agent| ['Practitioner', 'Device'].any? { |resource_type| agent.who.reference&.include?(resource_type) } && agent.onBehalfOf.nil? end if failed_provenance.present? << { type: 'error', message: "#{resource.resourceType}/#{resource.id}: Rule provenance-1: 'onBehalfOf SHALL be present when Provenance.agent.who is a Practitioner or Device' Failed" } end end |