Module: DaVinciCRDTestKit::FhirpathOnCDSRequest

Included in:
CustomServiceResponse, PrefetchCompletenessChecker, PrefetchContentsValidation
Defined in:
lib/davinci_crd_test_kit/cross_suite/fhirpath_on_cds_request.rb

Overview

Methods for executing simple fhirpath queries on cds request objects, e.g., to resolve prefetch tokens.

If resolve() calls are in scope (CRD 2.2.1 and beyond), then an implementation of the ‘resolve(target)` method must be provided, where `target` is

Constant Summary collapse

SUPPORTED_POST_RESOLVE_FUNCTIONS =
%w[ofType today resolve].freeze
TODAY_EXPRESSION_PATTERN =
/\Atoday\(\)\s*(?:([+-])\s*(\d+)\s+days)?\z/

Instance Method Summary collapse

Instance Method Details

#execute_fhirpath_on_cds_request(hook_request, fhirpath_query) ⇒ Object

fhirpath services doesn’t handle the following, which are handled manually

  • non-fhir objects

  • resolve()

  • Bundle.entry.resource when resolve() appears in the remaining query (to track entry.fullUrl per entry)

  • standalone today() expressions (today(), today()-N, today()+N)



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/davinci_crd_test_kit/cross_suite/fhirpath_on_cds_request.rb', line 21

def execute_fhirpath_on_cds_request(hook_request, fhirpath_query)
  today_result = execute_today_expression(fhirpath_query)
  return today_result if today_result

  cds_component, remaining_query = identify_cds_component(fhirpath_query)
  execution_targets = cds_component.present? ? get_cds_field(hook_request, cds_component) : hook_request

  execution_targets.map do |execution_target|
    @current_base_fhir_server = hook_request['fhirServer']
    execute(execution_target, remaining_query)
  end.flatten.compact
ensure
  # clean-up identity
  @current_base_fhir_server = nil
end