Compute a flag intersect with an omop table.
Usage
addTableIntersectFlag(
x,
tableName,
indexDate = "cohort_start_date",
censorDate = NULL,
window = list(c(0, Inf)),
targetStartDate = startDateColumn(tableName),
targetEndDate = endDateColumn(tableName),
nameStyle = "{table_name}_{window_name}"
)
Arguments
- x
Table with individuals in the cdm.
- tableName
Name of the table to intersect with. Options: visit_occurrence, condition_occurrence, drug_exposure, procedure_occurrence, device_exposure, measurement, observation, drug_era, condition_era, specimen.
- indexDate
Variable in x that contains the date to compute the intersection.
- censorDate
whether to censor overlap events at a specific date or a column date of x.
- window
window to consider events in.
- targetStartDate
Column name with start date for comparison.
- targetEndDate
Column name with end date for comparison.
- nameStyle
naming of the added column or columns, should include required parameters.
Examples
# \donttest{
cdm <- mockPatientProfiles()
cdm$cohort1 %>%
addTableIntersectFlag(tableName = "visit_occurrence")
#> # Source: table<og_155_1715898480> [10 x 5]
#> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:]
#> cohort_definition_id subject_id cohort_start_date cohort_end_date
#> <int> <int> <date> <date>
#> 1 1 2 1983-01-21 2085-11-09
#> 2 1 5 2069-11-15 2085-05-08
#> 3 2 7 2029-02-11 2087-08-27
#> 4 2 6 2061-11-11 2086-02-13
#> 5 3 3 1942-01-04 1943-07-13
#> 6 2 8 1982-06-17 2031-12-19
#> 7 3 1 2052-08-25 2077-05-12
#> 8 3 9 1978-08-24 1997-04-03
#> 9 1 4 2023-09-04 2026-05-27
#> 10 2 10 2063-08-14 2070-08-02
#> # ℹ 1 more variable: visit_occurrence_0_to_inf <dbl>
mockDisconnect(cdm = cdm)
# }