Skip to contents

Compute 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),
  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.

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.

Value

table with added columns with intersect information.

Examples

# \donttest{
cdm <- mockPatientProfiles()

cdm$cohort1 |>
  addTableIntersectDays(tableName = "visit_occurrence")
#> # Source:   table<og_152_1734615545> [?? x 5]
#> # Database: DuckDB v1.1.3 [unknown@Linux 6.8.0-1017-azure:R 4.4.2/:memory:]
#>    cohort_definition_id subject_id cohort_start_date cohort_end_date
#>                   <int>      <int> <date>            <date>         
#>  1                    2          1 1925-07-01        1936-01-22     
#>  2                    1          5 1960-05-25        1982-02-15     
#>  3                    2          8 1955-06-07        1966-12-14     
#>  4                    1          7 1974-01-25        1986-01-19     
#>  5                    2          9 1978-03-26        1979-02-02     
#>  6                    1          4 1926-06-19        1936-09-06     
#>  7                    2          3 1962-07-19        1963-09-12     
#>  8                    1          2 1986-09-26        1988-08-08     
#>  9                    2         10 1985-01-30        1990-07-26     
#> 10                    2          6 1926-02-04        1932-08-08     
#> # ℹ 1 more variable: visit_occurrence_0_to_inf <dbl>

mockDisconnect(cdm = cdm)
# }