pathling_with_column: Add a FHIRPath-derived column to a DataFrame

View source: R/context.R

pathling_with_columnR Documentation

Add a FHIRPath-derived column to a DataFrame

Description

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.

Usage

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.

See Also

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

Examples

## Not run: 
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)

## End(Not run)

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