Module: Inferno::DSL::FhirpathEvaluation

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

Overview

Note:

the ‘element` field can either be a primitive value (string, boolean, etc.) or a FHIR::Model.

This module contains the methods needed to perform FHIRPath evaluations on FHIR resources/elements. The actual evaluation is typically performed by an external FHIRPath evaluation service.

Tests can leverage the evaluation functionality by calling ‘evaluate_fhirpath` to retrieve results of FHIRPath expressions.

results will be an array representing the result of evaluating the given expression against the given root element. Each “result” in the returned array will be in the form ‘{ “type”: “[FHIR datatype of the result]”, “element”: “[result value of the FHIRPath expression]” }`.

Examples:


results = evaluate_fhirpath(resource: patient_resource, path: 'Patient.name.given')

Defined Under Namespace

Modules: ClassMethods Classes: Evaluator

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



20
21
22
# File 'lib/inferno/dsl/fhirpath_evaluation.rb', line 20

def self.included(klass)
  klass.extend ClassMethods
end

Instance Method Details

#evaluate_fhirpath(resource:, path:, url: nil) ⇒ Array<Hash>

Evaluates a fhirpath expression for a given FHIR resource

Parameters:

  • resource (FHIR::Model)

    the root FHIR resource to use when evaluating the fhirpath expression.

  • path (String)

    The FHIRPath expression to evaluate.

  • url (String) (defaults to: nil)

    the url of the fhirpath service to use.

Returns:

  • (Array<Hash>)

    An array of hashes representing the result of evaluating the given expression against the given root resource.



31
32
33
# File 'lib/inferno/dsl/fhirpath_evaluation.rb', line 31

def evaluate_fhirpath(resource:, path:, url: nil)
  self.class.evaluator(url).evaluate_fhirpath(resource, path, self)
end