
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
)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, episode.
- 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.
- targetDate
Target date in tableName.
- inObservation
If TRUE only records inside an observation period will be considered.
- order
which record is considered in case of multiple records (only required for date and days options).
- nameStyle
naming of the added column or columns, should include required parameters.
- name
Name of the new table, if NULL a temporary table is returned.
Examples
# \donttest{
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
#> Warning: There are observation period end dates after the current date: 2026-04-06
#> ℹ The latest max observation period end date found is 2033-09-27
cdm$cohort1 |>
addTableIntersectDays(tableName = "visit_occurrence")
#> # Source: table<og_155_1775495343> [?? x 5]
#> # Database: DuckDB 1.5.1 [unknown@Linux 6.17.0-1008-azure:R 4.5.3/:memory:]
#> cohort_definition_id subject_id cohort_start_date cohort_end_date
#> <int> <int> <date> <date>
#> 1 3 10 1951-10-01 1998-09-29
#> 2 1 5 1956-08-15 1961-05-25
#> 3 3 2 2009-04-04 2018-07-18
#> 4 2 7 1972-10-06 1976-01-23
#> 5 2 8 1997-11-30 2000-02-09
#> 6 1 1 1941-03-14 1941-06-13
#> 7 2 6 1927-04-22 1963-05-28
#> 8 2 4 1946-02-10 1969-01-16
#> 9 1 3 1986-04-30 1987-08-20
#> 10 1 9 1951-10-21 1980-03-04
#> # ℹ 1 more variable: visit_occurrence_0_to_inf <dbl>
# }