Converts a FHIRPath expression into a Spark Column that can be used in DataFrame operations such as filtering and selection. Boolean expressions can be used for filtering, while other expressions can be used for value extraction.
pc_fhirpath_to_column(pc, resource_type, fhirpath_expression)A Spark Column object (spark_jobj) representing the evaluated expression.
The expression should evaluate to a single value per resource row.
Other context functions:
pathling_filter(),
pathling_with_column(),
pc_search_to_column()
if (FALSE) { # \dontrun{
pc <- pathling_connect()
data_source <- pc %>% pathling_read_ndjson(pathling_examples("ndjson"))
patients <- data_source %>% ds_read("Patient")
# Boolean expression for filtering.
gender_filter <- pc_fhirpath_to_column(pc, "Patient", "gender = 'male'")
filtered <- sparklyr::spark_dataframe(patients) %>%
sparklyr::j_invoke("filter", gender_filter) %>%
sparklyr::sdf_register()
# Value expression for selection.
name_col <- pc_fhirpath_to_column(pc, "Patient", "name.given.first()")
pathling_disconnect(pc)
} # }