Skip to contents

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}",
  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.

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 %>%
  addTableIntersectFlag(tableName = "visit_occurrence")
#> # Source:   table<og_166_1731175204> [10 x 5]
#> # Database: DuckDB v1.1.2 [unknown@Linux 6.5.0-1025-azure:R 4.4.2/:memory:]
#>    cohort_definition_id subject_id cohort_start_date cohort_end_date
#>                   <int>      <int> <date>            <date>         
#>  1                    3          8 1937-07-11        1960-04-25     
#>  2                    1          6 1962-01-08        1988-05-30     
#>  3                    1         10 1949-07-02        1952-12-18     
#>  4                    2          2 1952-07-30        1974-07-14     
#>  5                    3          7 1997-08-08        2002-02-13     
#>  6                    1          3 1980-10-22        1993-07-03     
#>  7                    1          1 2002-04-17        2007-07-18     
#>  8                    3          4 1922-10-13        1923-10-25     
#>  9                    1          9 2004-11-02        2009-11-03     
#> 10                    2          5 1999-05-03        1999-06-05     
#> # ℹ 1 more variable: visit_occurrence_0_to_inf <dbl>
mockDisconnect(cdm = cdm)
# }