Class: DaVinciPlanNetTestKit::ProvenanceValidator
- Inherits:
-
Object
- Object
- DaVinciPlanNetTestKit::ProvenanceValidator
- Includes:
- FHIRResourceNavigation
- Defined in:
- lib/davinci_plan_net_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.
11 12 13 14 |
# File 'lib/davinci_plan_net_test_kit/provenance_validator.rb', line 11 def initialize(resource) @resource = resource @validation_messages = [] end |
Instance Attribute Details
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
9 10 11 |
# File 'lib/davinci_plan_net_test_kit/provenance_validator.rb', line 9 def resource @resource end |
#validation_messages ⇒ Object (readonly)
Returns the value of attribute validation_messages.
9 10 11 |
# File 'lib/davinci_plan_net_test_kit/provenance_validator.rb', line 9 def @validation_messages end |
Class Method Details
.validate ⇒ Object
5 6 7 |
# File 'lib/davinci_plan_net_test_kit/provenance_validator.rb', line 5 def self.validate(...) new(...).validate end |
Instance Method Details
#validate ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/davinci_plan_net_test_kit/provenance_validator.rb', line 16 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 |