pathling_evaluate_fhirpath: Evaluate a FHIRPath expression against a single FHIR resource

View source: R/context.R

pathling_evaluate_fhirpathR Documentation

Evaluate a FHIRPath expression against a single FHIR resource

Description

Evaluates a FHIRPath expression against a single FHIR resource provided as a JSON string and returns materialised typed results. The resource is encoded into a one-row Spark Dataset internally, and the existing FHIRPath engine is used to evaluate the expression.

Usage

pathling_evaluate_fhirpath(
  pc,
  resource_type,
  resource_json,
  fhirpath_expression,
  context_expression = NULL,
  variables = NULL
)

Arguments

pc

The PathlingContext object.

resource_type

A string containing the FHIR resource type code (e.g., "Patient", "Observation").

resource_json

A string containing the FHIR resource as JSON.

fhirpath_expression

A FHIRPath expression to evaluate (e.g., "name.family", "gender = 'male'").

context_expression

An optional context expression string. If provided, the main expression is evaluated once for each result of the context expression. Defaults to NULL.

variables

An optional named list of variables available via %variable syntax. Defaults to NULL.

Value

A list with two elements:

results

A list of lists, each containing type (character) and value (the materialised R value or NULL).

expectedReturnType

A character string indicating the inferred return type.

See Also

Other context functions: pathling_fhirpath_to_column(), pathling_filter(), pathling_search_to_column(), pathling_with_column()

Examples

## Not run: 
pc <- pathling_connect()
patient_json <- '{"resourceType": "Patient", "id": "example", "gender": "male"}'
result <- pathling_evaluate_fhirpath(pc, "Patient", patient_json, "gender")
for (entry in result$results) {
  cat(entry$type, ": ", entry$value, "\n")
}
pathling_disconnect(pc)

## End(Not run)

pathling documentation built on June 3, 2026, 9:08 a.m.