The recipe is the central user-facing data structure for an OMOP data extraction. It holds every selection in one place: populations (who), variable blocks (what, grouped), individual variables, filters (constraints), outputs (how to shape the result), the base cohort, and plan-wide options.
Usage
omop_recipe(
variables = NULL,
filters = NULL,
outputs = NULL,
populations = NULL,
blocks = NULL,
cohort = NULL,
tables = NULL,
combine = "union",
options = NULL,
output = NULL
)Arguments
- variables
A single
omop_variable(including the convenienceomop_variable_*derived constructors) or a list of them.- filters
A single
omop_filter/omop_filter_groupor a list of them. A named list uses each name as the filter ID.- outputs
A single
omop_outputor a list of them.- populations
A single
omop_populationor a list of them (the implicit"base"population always exists; parents must be declared before their children).- blocks
A single
omop_variable_blockor a list of them; each block is expanded into individual variables.- cohort
Recipe-level scope. Any form – a scalar OMOP
cohort_definition_id, a cohort handle (dsomop_cohort_handle), or a server-side cohort table name – resolves to a gated person set that is intersected into every population (alongsidetables). It does NOT re-root the base population; to build a base population from an existing cohort useomop_population(cohort_definition_id = ...).NULLsets no scope.- tables
Character vector of server-side
omop.tablesymbol names, orNULL. Their distinct persons form a recipe-level scope folded with anycohortscope bycombineand intersected into every population (the server resolves the symbol names to frames).- combine
Character; how to fold multiple scope sources together:
"union"(the default) or"intersect".- options
Named list of plan-wide options (
translate_concepts,block_sensitive,factor_concepts); only supplied keys override the defaults.- output
Convenience alias for a single
omop_output; use it instead ofoutputswhen the recipe has just one output.
Details
This is the single recipe-authoring entry point: pass the complete extraction
as one nested expression built from the leaf constructors
(omop_variable, omop_filter,
omop_output, omop_population,
omop_variable_block, and friends). Each argument accepts a
single object or a list of objects. The recipe is assembled in dependency
order (populations, then blocks, then variables, then filters, then outputs,
then the base cohort, then options) so later items can reference earlier ones.
Most users then work at the recipe level with recipe_preview,
recipe_execute, recipe_save, and
recipe_load; recipe_to_plan exposes the
lower-level execution contract sent to the server.
Examples
if (FALSE) { # \dontrun{
recipe <- omop_recipe(
blocks = omop_variable_block(
table = "condition_occurrence",
concept_ids = c(201820),
format = "binary"
),
variables = list(
omop_variable_age(),
omop_variable(table = "measurement", concept_id = 3004410,
format = "mean")
),
filters = omop_filter_sex("F"),
outputs = omop_output(name = "study", type = "wide")
)
recipe_execute(recipe)
# Multi-population: build two criteria subgroups, UNION them into one
# population, then run an output against that union while a recipe-level
# scope (a cohort handle INTERSECTED with a workspace omop.table's persons)
# narrows every population.
recipe2 <- omop_recipe(
populations = list(
omop_population("diabetic", "Diabetics",
filters = list(omop_filter_has_concept(
201820, "condition_occurrence"))),
omop_population("hypertensive", "Hypertensives",
filters = list(omop_filter_has_concept(
320128, "condition_occurrence"))),
omop_population("either", "Diabetic or hypertensive",
union = c("diabetic", "hypertensive"))
),
variables = omop_variable_age(),
outputs = omop_output(name = "study", type = "wide",
population_id = "either"),
cohort = my_cohort_handle, # cohort handle / table name as scope
tables = "my_inclusion_set", # workspace omop.table symbol name
combine = "intersect"
)
recipe_execute(recipe2)
# `cohort=` is ALWAYS scope, including a bare cohort_definition_id: it resolves
# to a gated person set that narrows every population. To instead BUILD the base
# population from an existing admin/ATLAS cohort, pass it through
# omop_population(cohort_definition_id = ...); `cohort=` then layers a scope on
# top.
recipe3 <- omop_recipe(
populations = omop_population(id = "base", label = "Registry cohort",
cohort_definition_id = 1001), # base population
variables = omop_variable_age(),
outputs = omop_output(name = "study", type = "wide"),
cohort = 2002 # scalar id = scope
)
recipe_execute(recipe3)
} # }