
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
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")
cdm$cohort1 |>
addTableIntersectDate(tableName = "visit_occurrence")
#> # Source: table<og_150_1775495339> [?? 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 1 10 1933-03-24 1945-09-19
#> 2 1 5 1916-10-29 1920-06-19
#> 3 3 2 1963-04-21 1971-06-22
#> 4 2 3 1979-04-29 2000-01-21
#> 5 1 8 1950-10-26 1952-12-17
#> 6 2 6 1912-06-26 1920-09-30
#> 7 2 7 1939-02-02 1939-12-23
#> 8 2 1 1925-06-28 1926-06-19
#> 9 1 4 1996-01-31 1999-06-13
#> 10 2 9 1930-12-19 1936-04-01
#> # ℹ 1 more variable: visit_occurrence_0_to_inf <date>
# }