Skip to contents

Add drug restart information as a column per follow-up period of interest.

Usage

addDrugRestart(
  cohort,
  switchCohortTable,
  switchCohortId = NULL,
  followUpDays = Inf,
  censorDate = NULL,
  incident = TRUE,
  nameStyle = "drug_restart_{follow_up_days}"
)

Arguments

cohort

A cohort_table object.

switchCohortTable

A cohort table in the cdm that contains possible alternative treatments.

switchCohortId

The cohort ids to be used from switchCohortTable. If NULL all cohort definition ids are used.

followUpDays

A vector of number of days to follow up. It can be multiple values.

censorDate

Name of a column that indicates the date to stop the analysis, if NULL end of individuals observation is used.

incident

Whether the switch treatment has to be incident (start after discontinuation) or not (it can start before the discontinuation and last till after).

nameStyle

Character string to specify the nameStyle of the new columns.

Value

The cohort table given with additional columns with information on the restart, switch and not exposed per follow-up period of interest.

Examples

# \donttest{
cdm <- mockDrugUtilisation()

conceptlist <- list("a" = 1125360, "b" = c(1503297, 1503327))
cdm <- generateDrugUtilisationCohortSet(
  cdm = cdm,
  name = "switch_cohort",
  conceptSet = conceptlist
)
#>  Subsetting drug_exposure table
#>  Checking whether any record needs to be dropped.
#>  Collapsing overlaping records.
#>  Collapsing records with gapEra = 1 days.

cdm$cohort1 |>
  addDrugRestart(switchCohortTable = "switch_cohort")
#> # Source:   table<og_042_1746625006> [?? x 5]
#> # Database: DuckDB v1.2.2 [unknown@Linux 6.11.0-1013-azure:R 4.5.0/:memory:]
#>    cohort_definition_id subject_id cohort_start_date cohort_end_date
#>                   <int>      <int> <date>            <date>         
#>  1                    2          2 2021-09-29        2021-10-13     
#>  2                    1          3 2021-12-19        2022-01-01     
#>  3                    2          8 2000-07-07        2003-10-07     
#>  4                    1          9 2014-01-17        2014-04-24     
#>  5                    1          4 2005-09-23        2005-12-27     
#>  6                    2          7 2020-05-11        2020-08-02     
#>  7                    1          1 1993-04-03        2012-05-08     
#>  8                    3          5 2021-11-21        2021-11-21     
#>  9                    2          6 2018-06-22        2018-08-09     
#> 10                    1         10 2020-06-08        2020-06-20     
#> # ℹ 1 more variable: drug_restart_inf <chr>
# }