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 %>%.

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.

Examples

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