Skip to contents

It creates columns to indicate the presence of cohorts

Usage

addCohortIntersectFlag(
  x,
  targetCohortTable,
  targetCohortId = NULL,
  indexDate = "cohort_start_date",
  censorDate = NULL,
  targetStartDate = "cohort_start_date",
  targetEndDate = "cohort_end_date",
  window = list(c(0, Inf)),
  nameStyle = "{cohort_name}_{window_name}",
  name = NULL
)

Arguments

x

Table with individuals in the cdm.

targetCohortTable

name of the cohort that we want to check for overlap.

targetCohortId

vector of cohort definition ids to include.

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.

targetStartDate

date of reference in cohort table, either for start (in overlap) or on its own (for incidence).

targetEndDate

date of reference in cohort table, either for end (overlap) or NULL (if incidence).

window

window to consider events of.

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 overlap information.

Examples

# \donttest{
cdm <- mockPatientProfiles()

cdm$cohort1 |>
  addCohortIntersectFlag(
    targetCohortTable = "cohort2"
  )
#> # Source:   table<og_032_1734613791> [?? x 7]
#> # 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                    1          2 1953-03-04        1971-05-28     
#>  2                    1          4 1966-01-22        1973-07-21     
#>  3                    3          7 2007-11-16        2019-11-21     
#>  4                    3          8 1981-07-21        1995-12-18     
#>  5                    3          6 1911-03-15        1919-03-19     
#>  6                    2          9 1923-07-13        1925-03-30     
#>  7                    1         10 1941-06-06        1976-12-23     
#>  8                    2          5 1987-11-20        1992-07-24     
#>  9                    2          1 1988-07-10        2006-02-20     
#> 10                    2          3 1959-03-16        1959-11-30     
#> # ℹ 3 more variables: cohort_1_0_to_inf <dbl>, cohort_3_0_to_inf <dbl>,
#> #   cohort_2_0_to_inf <dbl>
mockDisconnect(cdm = cdm)
# }