Skip to contents

Applies column filters for the duration of the supplied expression, then restores the previous state (even on error). This is useful when you need different filters for a group of calls without permanently changing session state. For a single call, prefer the col_filters argument on the query function itself (see CODES()) — it has the same semantics, scoped to that call.

Usage

with_col_filters(col_filters, code)

Arguments

col_filters

The filters to apply: a type-layered list or get_col_filters() object (each table entry replaces that table's pins/defaults wholesale), or NULL / NA for no filtering at all.

code

Code to execute with the temporary filters. The scope covers query construction: every codeminer read made while code evaluates resolves against the temporary filters.

Value

The result of evaluating code.

Details

Note the argument order (filters first, code last, as in withr::with_*()): wrap the expression rather than piping into this function.

Examples

if (FALSE) { # \dontrun{
# Temporarily include inactive SNOMED concepts
with_col_filters(
  list(lookup = list("SNOMED CT" = list(active_concept = c("0", "1")))),
  CODES("all", type = "SNOMED CT")
)

# Temporarily disable all filtering
with_col_filters(NA, CODES("all", type = "SNOMED CT"))
} # }