Evaluates a FHIRPath expression and adds the result as a named column to a tbl_spark, returning the augmented tbl_spark. The DataFrame must be the first argument to enable piping with %>%. Multiple calls can be chained to add several columns.

pathling_with_column(df, pc, resource_type, expression, column)

Arguments

df

A tbl_spark containing FHIR resource data.

pc

The PathlingContext object.

resource_type

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

expression

A FHIRPath expression to evaluate (e.g., "name.given.first()").

column

The name of the new column to add.

Value

A tbl_spark with the new column added.

Examples

if (FALSE) { # \dontrun{
pc <- pathling_connect()
data_source <- pc %>% pathling_read_ndjson(pathling_examples("ndjson"))
patients <- data_source %>% ds_read("Patient")

# Add a single column.
result <- patients %>%
  pathling_with_column(pc, "Patient", "name.given.first()", column = "given_name")

# Chain multiple columns.
result <- patients %>%
  pathling_with_column(pc, "Patient", "name.given.first()", column = "given_name") %>%
  pathling_with_column(pc, "Patient", "gender", column = "gender_value") %>%
  dplyr::select(id, given_name, gender_value)

pathling_disconnect(pc)
} # }