
Compute number of intersect with an omop table.
Source:R/addTableIntersect.R
addTableIntersectCount.RdCompute number of intersect with an omop table.
Usage
addTableIntersectCount(
x,
tableName,
indexDate = "cohort_start_date",
censorDate = NULL,
window = list(c(0, Inf)),
targetStartDate = startDateColumn(tableName),
targetEndDate = endDateColumn(tableName),
inObservation = TRUE,
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.
- targetStartDate
Column name with start date for comparison.
- targetEndDate
Column name with end date for comparison.
- inObservation
If TRUE only records inside an observation period will be considered.
- 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.
Value
The original table (x) with one added column per intersection with the desired table in a specific window. One column will be created for each combination of window and table. The value of the column will be the number of intersections in the desired window, or NA if the individual is not in observation at any time in the window.
Examples
# \donttest{
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addTableIntersectCount(tableName = "visit_occurrence")
#> # Source: table<og_141_1775495336> [?? 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 3 1902-11-21 1913-04-09
#> 2 2 5 1956-04-20 1960-11-24
#> 3 3 9 1961-07-25 1984-04-18
#> 4 1 1 1936-01-16 1938-03-24
#> 5 3 6 1950-01-01 1964-02-01
#> 6 1 7 1975-11-02 1986-08-01
#> 7 1 4 1971-12-14 1978-11-09
#> 8 1 10 1921-09-07 1937-08-22
#> 9 3 2 1930-12-06 1950-04-12
#> 10 2 8 1999-02-14 2002-12-06
#> # ℹ 1 more variable: visit_occurrence_0_to_inf <dbl>
# }