
Compute time to intersect with an omop table.
Source:R/addTableIntersect.R
addTableIntersectDays.RdCompute time to intersect with an omop table.
Usage
addTableIntersectDays(
x,
tableName,
indexDate = "cohort_start_date",
censorDate = NULL,
window = list(c(0, Inf)),
targetDate = startDateColumn(tableName),
inObservation = TRUE,
order = "first",
nameStyle = "{table_name}_{window_name}",
name = NULL,
type = "numeric"
)Arguments
- x
A table containing individuals in a CDM reference.
- tableName
Names of one or more OMOP CDM tables to intersect with.
- indexDate
Name of a date column in
x, or a single date to use for all rows, used as the reference date.- censorDate
Date or name of a date column in
xon which to censor follow-up. IfNULL, no censoring is applied.- window
Window or windows of time relative to
indexDateto consider.- targetDate
Name or names of date columns in the target tables to use for the intersection.
- inObservation
If
TRUE, only records that occur during an observation period are considered.- order
Which record to use when multiple records occur in a window:
"first"or"last".- nameStyle
Naming pattern for the added column or columns. It should include the required formatting variables. If more than one
tableNameis provided, it must include{table_name}.- name
Name of the new table. If
NULL, a temporary table is returned.- type
Type of the created column(s). Counts, days, age, and observation durations can be
"numeric"or"integer". Flag columns can also be"logical". Field columns can use"auto"to preserve the source type, or can be converted to"numeric","integer","logical", or"character".
Examples
# \donttest{
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addTableIntersectDays(tableName = "visit_occurrence")
#> # A query: ?? x 5
#> # Database: DuckDB 1.5.4 [unknown@Linux 6.17.0-1020-azure:R 4.6.1/:memory:]
#> cohort_definition_id subject_id cohort_start_date cohort_end_date
#> <int> <int> <date> <date>
#> 1 2 8 1971-01-09 1983-11-20
#> 2 1 1 1936-01-06 1958-01-20
#> 3 1 10 1913-12-09 1914-02-09
#> 4 3 3 1940-12-25 1947-11-25
#> 5 1 2 1914-06-29 1917-10-23
#> 6 2 9 1968-01-12 1980-11-22
#> 7 2 5 1965-06-22 1974-08-07
#> 8 1 7 1979-10-26 1980-08-27
#> 9 2 4 1927-06-03 1930-09-18
#> 10 1 6 1909-08-09 1913-05-01
#> # ℹ 1 more variable: visit_occurrence_0_to_inf <dbl>
# }