pathling_filter: Filter a DataFrame using a FHIRPath or search expression

View source: R/context.R

pathling_filterR Documentation

Filter a DataFrame using a FHIRPath or search expression

Description

Filters a tbl_spark using either a FHIRPath boolean expression or a FHIR search query string, returning a tbl_spark containing only the matching rows. The DataFrame must be the first argument to enable piping with %>%.

Usage

pathling_filter(df, pc, resource_type, expression, type = "fhirpath")

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

The filter expression. For type = "fhirpath", a FHIRPath boolean expression (e.g., "gender = 'male'"). For type = "search", a FHIR search query string (e.g., "gender=male&birthdate=ge1990-01-01").

type

The type of expression: "fhirpath" (default) or "search".

Value

A tbl_spark containing only the rows matching the expression.

See Also

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

Examples

## Not run: 
pc <- pathling_connect()
data_source <- pc %>% pathling_read_ndjson(pathling_examples("ndjson"))
patients <- data_source %>% ds_read("Patient")

# Filter using a FHIRPath expression.
male_patients <- patients %>%
  pathling_filter(pc, "Patient", "gender = 'male'")

# Filter using a FHIR search expression.
male_patients <- patients %>%
  pathling_filter(pc, "Patient", "gender=male", type = "search")

pathling_disconnect(pc)

## End(Not run)

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