
Compute date of intersect with an omop table.
Source:R/addTableIntersect.R
addTableIntersectDate.RdCompute date of intersect with an omop table.
Usage
addTableIntersectDate(
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
)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.
Examples
# \donttest{
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addTableIntersectDate(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 4 1967-06-09 1978-12-26
#> 2 1 9 1963-02-01 1992-11-03
#> 3 3 6 1936-08-30 1954-12-31
#> 4 1 1 1966-04-07 1967-10-06
#> 5 2 2 1999-05-23 2000-06-15
#> 6 2 7 1959-08-15 1961-10-02
#> 7 3 5 1941-06-22 1941-11-09
#> 8 1 8 1956-09-02 1960-02-03
#> 9 1 10 1984-02-13 1994-06-17
#> 10 2 3 1951-11-10 1952-03-10
#> # ℹ 1 more variable: visit_occurrence_0_to_inf <date>
# }