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.

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.

Examples

if (FALSE) { # \dontrun{
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)
} # }