Assessing drug restart and switching after treatment

Introduction

Obtaining information on drug restart or switching to another drug after discontinuation of the original treatment is often of interest in drug utilisation studies. In this vignette, we show how to assess drug switching and restart with this package.

Data

Connect to mock data

For this vignette we will use mock data contained in the DrugUtilisation package.

library(DrugUtilisation)

cdm <- mockDrugUtilisation(numberIndividual = 200)

Generate study cohorts

We will examine the patterns of drug restart and switching among patients taking metformin as an example. Specifically, we will investigate whether patients restart metformin after discontinuation, switch to insulin, try both medications, or remain untreated.

For this we will need two cohorts: one of patients exposed to metformin and another of patients exposed to insulin.

# codelists
metformin <- CodelistGenerator::getDrugIngredientCodes(cdm = cdm, name = "metformin")
insulin <- CodelistGenerator::getDrugIngredientCodes(cdm = cdm, name = "insulin detemir")

cdm <- generateDrugUtilisationCohortSet(
  cdm = cdm, name = "metformin", conceptSet = metformin
)
cdm$metformin |>
  cohortCount()
#> # A tibble: 1 × 3
#>   cohort_definition_id number_records number_subjects
#>                  <int>          <int>           <int>
#> 1                    1            117             101

cdm <- generateDrugUtilisationCohortSet(
  cdm = cdm, name = "insulin", conceptSet = insulin
)
cdm$insulin |>
  cohortCount()
#> # A tibble: 1 × 3
#>   cohort_definition_id number_records number_subjects
#>                  <int>          <int>           <int>
#> 1                    1            101              88

Assess drug restart

The summariseDrugRestart() function analyses the outcomes within a treatment cohort following the first exposure to a specific drug. It categorises the events into four distinct groups:

The figure below illustrates the analysis, focusing on the outcomes after the initial exposure to a particular drug (in blue), with consideration of a specific switch drug (in orange). This study examines what occurs within 100, 180, and 365 days following first treatment discontinuation in the cohort.

Now, let’s use the function to assess metformin restart and switch to insulin after the first metformin treatment.

results <- cdm$metformin |>
  summariseDrugRestart(
    switchCohortTable = "insulin",
    switchCohortId = NULL,
    strata = list(),
    followUpDays = Inf,
    censorDate = NULL,
    restrictToFirstDiscontinuation = TRUE
  )

results |>
  dplyr::glimpse()
#> Rows: 8
#> Columns: 13
#> $ result_id        <int> 1, 1, 1, 1, 1, 1, 1, 1
#> $ cdm_name         <chr> "DUS MOCK", "DUS MOCK", "DUS MOCK", "DUS MOCK", "DUS …
#> $ group_name       <chr> "cohort_name", "cohort_name", "cohort_name", "cohort_…
#> $ group_level      <chr> "6809_metformin", "6809_metformin", "6809_metformin",…
#> $ strata_name      <chr> "overall", "overall", "overall", "overall", "overall"…
#> $ strata_level     <chr> "overall", "overall", "overall", "overall", "overall"…
#> $ variable_name    <chr> "Drug restart till end of observation", "Drug restart…
#> $ variable_level   <chr> "restart", "restart", "switch", "switch", "restart an…
#> $ estimate_name    <chr> "count", "percentage", "count", "percentage", "count"…
#> $ estimate_type    <chr> "integer", "percentage", "integer", "percentage", "in…
#> $ estimate_value   <chr> "11", "10.8910891089109", "10", "9.9009900990099", "4…
#> $ additional_name  <chr> "follow_up_days", "follow_up_days", "follow_up_days",…
#> $ additional_level <chr> "inf days", "inf days", "inf days", "inf days", "inf …

We could be interested in getting these results in different follow-up periods since the first metformin exposure ended. For instance, next we get the results in the first 180 days, the first year, and until the end of observation.

results <- cdm$metformin |>
  summariseDrugRestart(
    switchCohortTable = "insulin",
    switchCohortId = NULL,
    strata = list(),
    followUpDays = c(180, 365, Inf),
    censorDate = NULL,
    restrictToFirstDiscontinuation = TRUE
  )

Other options that this function allows are:

By default this argument is set to TRUE, which means that we only consider the firsts exposure of the subject. If FALSE, the analysis is conducted on a record level, considering all exposures in the cohort, as the following image illustrates:

This argument allows to stop considering restart and switch events after a certain date, which must specified as a column in the cohort.

This argument is by default TRUE, which means we will only consider switch treatments starting after discontinuation. If set to FALSE, we will allow switch treatments starting before the discontinuation of the treatment and ending afterwards.

The follow-up of the individuals will be set to Inf by default, i.e. we will follow them up for as long as possible. However, we can restrict the follow-up period to any other time interval as seen in the previous example.

This argument must be a list pointing to columns or combinations of columns in the cohort to use as strata. It will produce stratified estimates as well as for the overall cohort.

For instance, we reproduce the last calculation but this time straifying by sex. We first use PatientProfiles to add a column indicating the sex, which later we use in strata.

results <- cdm$cohort1 |>
  PatientProfiles::addSex(name = "cohort1") |>
  summariseDrugRestart(
    switchCohortTable = "insulin",
    switchCohortId = NULL,
    strata = list("sex"),
    followUpDays = c(180, 365, Inf),
    censorDate = NULL,
    restrictToFirstDiscontinuation = TRUE
  )

Visualise drug restart

The package has table and plot functions to help visualising the results from summariseDrugRestart().

Table

The function tableDrugRestart() will create a gt, flextable or tibble table from the summarised_result object created with summariseDrugRestart(). This function offers multiple customisation options to format the resulting table according to the user preferences.

results |>
  tableDrugRestart()
#> Warning: cdm_name, cohort_name, variable_name, follow_up_days, censor_date,
#> cohort_table_name, incident, restrict_to_first_discontinuation, and
#> switch_cohort_table are missing in `columnOrder`, will be added last.
CDM name
DUS MOCK
Sex Treatment Estimate name
Cohort name
cohort_1 cohort_2 cohort_3
Drug restart in 180 days
overall restart N (%) 0 (0.00 %) 0 (0.00 %) 0 (0.00 %)
switch N (%) 4 (6.15 %) 2 (3.17 %) 4 (5.56 %)
restart and switch N (%) 0 (0.00 %) 0 (0.00 %) 0 (0.00 %)
untreated N (%) 61 (93.85 %) 61 (96.83 %) 68 (94.44 %)
Female restart N (%) 0 (0.00 %) 0 (0.00 %) 0 (0.00 %)
switch N (%) 1 (2.94 %) 2 (6.45 %) 1 (3.03 %)
restart and switch N (%) 0 (0.00 %) 0 (0.00 %) 0 (0.00 %)
untreated N (%) 33 (97.06 %) 29 (93.55 %) 32 (96.97 %)
Male restart N (%) 0 (0.00 %) 0 (0.00 %) 0 (0.00 %)
switch N (%) 3 (9.68 %) 0 (0.00 %) 3 (7.69 %)
restart and switch N (%) 0 (0.00 %) 0 (0.00 %) 0 (0.00 %)
untreated N (%) 28 (90.32 %) 32 (100.00 %) 36 (92.31 %)
Drug restart in 365 days
overall restart N (%) 0 (0.00 %) 0 (0.00 %) 0 (0.00 %)
switch N (%) 6 (9.23 %) 5 (7.94 %) 7 (9.72 %)
restart and switch N (%) 0 (0.00 %) 0 (0.00 %) 0 (0.00 %)
untreated N (%) 59 (90.77 %) 58 (92.06 %) 65 (90.28 %)
Female restart N (%) 0 (0.00 %) 0 (0.00 %) 0 (0.00 %)
switch N (%) 2 (5.88 %) 4 (12.90 %) 3 (9.09 %)
restart and switch N (%) 0 (0.00 %) 0 (0.00 %) 0 (0.00 %)
untreated N (%) 32 (94.12 %) 27 (87.10 %) 30 (90.91 %)
Male restart N (%) 0 (0.00 %) 0 (0.00 %) 0 (0.00 %)
switch N (%) 4 (12.90 %) 1 (3.12 %) 4 (10.26 %)
restart and switch N (%) 0 (0.00 %) 0 (0.00 %) 0 (0.00 %)
untreated N (%) 27 (87.10 %) 31 (96.88 %) 35 (89.74 %)
Drug restart till end of observation
overall restart N (%) 0 (0.00 %) 0 (0.00 %) 0 (0.00 %)
switch N (%) 11 (16.92 %) 7 (11.11 %) 11 (15.28 %)
restart and switch N (%) 0 (0.00 %) 0 (0.00 %) 0 (0.00 %)
untreated N (%) 54 (83.08 %) 56 (88.89 %) 61 (84.72 %)
Female restart N (%) 0 (0.00 %) 0 (0.00 %) 0 (0.00 %)
switch N (%) 4 (11.76 %) 4 (12.90 %) 4 (12.12 %)
restart and switch N (%) 0 (0.00 %) 0 (0.00 %) 0 (0.00 %)
untreated N (%) 30 (88.24 %) 27 (87.10 %) 29 (87.88 %)
Male restart N (%) 0 (0.00 %) 0 (0.00 %) 0 (0.00 %)
switch N (%) 7 (22.58 %) 3 (9.38 %) 7 (17.95 %)
restart and switch N (%) 0 (0.00 %) 0 (0.00 %) 0 (0.00 %)
untreated N (%) 24 (77.42 %) 29 (90.62 %) 32 (82.05 %)

Plot

The plotDrugRestart() function creates a bar plot depicting the percentage of drug restart events for each cohort, stratum, and follow-up time (specified in the variable_name column of the summarised result). This function offers customisation options for colours, facetting, and handling of strata.

results |>
  plotDrugRestart(facet = cohort_name + sex ~ follow_up_days)

Adding the information to an existing cohort

We can directly add the drug restart information to an existing cohort as a column instead of asking for a summarising object. In this case we will use the function addDrugRestart(), which will add one column per follow-up window we ask for:

cdm$metformin |>
  addDrugRestart(
    switchCohortTable = "insulin",
    switchCohortId = NULL,
    followUpDays = c(180, 365, Inf),
    censorDate = NULL
  ) |>
  gt::gt()
cohort_definition_id subject_id cohort_start_date cohort_end_date drug_restart_180 drug_restart_365 drug_restart_inf
1 194 2021-03-20 2021-06-21 untreated untreated untreated
1 73 1980-06-28 1983-03-17 untreated untreated untreated
1 132 1998-12-04 2004-12-15 untreated untreated untreated
1 176 1988-12-25 1989-01-02 untreated untreated untreated
1 186 2019-11-16 2019-11-27 untreated untreated untreated
1 120 2010-03-28 2010-06-05 untreated untreated untreated
1 131 2006-11-12 2010-10-23 untreated untreated untreated
1 83 2018-10-27 2020-02-08 untreated untreated untreated
1 147 2007-12-10 2011-08-24 untreated untreated untreated
1 9 2013-03-08 2013-08-13 untreated untreated untreated
1 94 2014-01-20 2015-01-16 untreated untreated untreated
1 116 2008-02-12 2008-11-29 untreated untreated untreated
1 99 1984-01-09 1986-06-12 untreated untreated untreated
1 161 2007-10-16 2008-02-09 untreated untreated untreated
1 200 2013-01-08 2018-07-15 untreated untreated untreated
1 128 2010-06-09 2012-03-17 untreated untreated untreated
1 156 1992-01-17 2015-09-27 untreated untreated untreated
1 91 2022-05-16 2022-06-04 untreated untreated untreated
1 108 2002-02-09 2012-05-17 untreated untreated untreated
1 38 2020-01-12 2020-02-20 untreated untreated untreated
1 97 2019-04-23 2020-06-10 untreated untreated untreated
1 15 2015-12-08 2016-10-07 untreated untreated untreated
1 178 2021-12-02 2022-05-12 untreated untreated untreated
1 81 2022-04-26 2022-04-30 untreated untreated untreated
1 173 2021-12-23 2022-01-04 untreated untreated untreated
1 28 2019-11-09 2019-12-25 untreated untreated untreated
1 140 1991-04-24 1995-04-17 untreated untreated untreated
1 30 2002-07-21 2002-08-17 untreated untreated untreated
1 113 2020-06-26 2020-08-03 untreated untreated untreated
1 29 1982-09-19 2009-12-05 untreated untreated untreated
1 110 2015-01-20 2016-05-28 untreated untreated untreated
1 121 2016-09-21 2018-02-16 untreated untreated untreated
1 192 2022-08-24 2022-09-04 untreated untreated untreated
1 183 2017-09-22 2017-11-18 untreated untreated untreated
1 119 2020-12-18 2020-12-20 untreated untreated untreated
1 74 2022-11-04 2022-11-06 untreated untreated untreated
1 8 2007-12-03 2009-06-16 untreated untreated untreated
1 182 2010-07-31 2011-03-31 untreated untreated untreated
1 103 2014-09-25 2014-10-01 untreated untreated untreated
1 64 2013-08-03 2015-08-12 untreated untreated untreated
1 98 2020-09-26 2020-12-12 untreated untreated untreated
1 59 2013-11-29 2014-10-25 untreated untreated untreated
1 17 2014-07-08 2016-11-29 untreated untreated untreated
1 3 2017-08-26 2019-01-02 untreated untreated untreated
1 160 1989-09-16 1989-10-04 untreated untreated untreated
1 25 2020-01-05 2020-03-23 untreated untreated untreated
1 40 2018-01-10 2021-01-26 untreated untreated untreated
1 124 1991-03-06 1991-06-27 untreated untreated untreated
1 107 1998-03-07 2006-03-01 untreated untreated untreated
1 92 2003-10-19 2010-12-31 untreated untreated untreated
1 45 2022-11-30 2022-12-01 untreated untreated untreated
1 19 1986-08-18 1995-04-01 untreated untreated untreated
1 32 2021-07-14 2021-08-18 untreated untreated untreated
1 89 2017-12-20 2018-02-06 untreated untreated untreated
1 172 2018-03-08 2018-03-09 untreated untreated untreated
1 18 2020-09-21 2021-09-14 untreated untreated untreated
1 37 2004-10-03 2006-08-23 untreated untreated untreated
1 174 2019-07-22 2019-07-25 untreated untreated untreated
1 123 2017-02-20 2018-06-13 untreated untreated untreated
1 134 2018-05-24 2020-01-10 untreated untreated untreated
1 61 1991-02-02 2007-01-25 untreated untreated untreated
1 114 2019-03-24 2021-07-31 untreated untreated untreated
1 138 2013-07-08 2014-06-12 untreated untreated untreated
1 126 2018-03-21 2018-08-24 untreated untreated untreated
1 50 2012-01-10 2012-05-17 untreated untreated untreated
1 80 2018-12-18 2020-10-05 untreated untreated untreated
1 1 2013-01-04 2013-02-03 untreated untreated untreated
1 26 1998-01-20 2012-11-25 untreated untreated untreated
1 191 2013-09-02 2014-05-07 untreated untreated untreated
1 158 2022-12-13 2022-12-15 untreated untreated untreated
1 146 2016-05-06 2016-05-19 untreated untreated untreated
1 72 2003-04-22 2003-04-27 untreated untreated untreated
1 70 2012-11-12 2016-10-17 untreated untreated untreated
1 41 2010-06-26 2011-08-15 untreated untreated untreated
1 195 2022-07-20 2022-07-22 untreated untreated untreated
1 115 2019-08-01 2019-10-24 untreated untreated untreated
1 2 2020-12-21 2020-12-21 untreated untreated untreated
1 87 2021-10-16 2022-01-01 untreated untreated untreated
1 122 1994-10-22 2009-04-03 untreated untreated untreated
1 118 1999-07-02 1999-07-07 untreated untreated untreated
1 193 2011-05-13 2011-11-26 untreated untreated untreated
1 79 2003-07-26 2004-07-23 untreated untreated untreated
1 55 2006-05-10 2006-08-30 untreated untreated untreated
1 169 2020-01-13 2020-02-14 untreated untreated untreated
1 170 2015-05-25 2015-06-20 untreated untreated untreated
1 190 1994-07-14 1997-08-12 untreated untreated untreated
1 84 2015-07-02 2019-02-27 untreated untreated untreated
1 109 2006-11-06 2015-06-21 untreated untreated untreated
1 130 2011-03-17 2011-03-22 untreated untreated untreated
1 68 2022-02-09 2022-03-18 untreated untreated untreated
1 141 1991-03-10 1998-05-14 untreated untreated untreated
1 91 2019-09-27 2020-02-25 untreated untreated restart
1 186 2019-03-03 2019-05-19 restart restart restart
1 186 2019-06-25 2019-10-20 restart restart restart
1 72 2003-02-21 2003-04-07 restart restart restart
1 160 1989-09-03 1989-09-14 restart restart restart
1 94 2006-11-16 2009-05-28 untreated untreated restart
1 74 2022-10-28 2022-11-02 restart restart restart
1 174 2018-12-12 2019-04-03 restart restart restart
1 134 2014-08-16 2016-09-22 untreated untreated restart
1 79 1986-05-09 1994-04-15 untreated untreated restart
1 15 2011-01-24 2015-07-19 restart restart restart
1 126 2012-07-27 2016-10-16 untreated untreated restart
1 11 2018-12-02 2020-06-15 switch switch switch
1 43 1974-06-23 1978-07-30 untreated untreated switch
1 162 1972-02-15 1973-10-24 untreated untreated switch
1 78 1969-03-27 1988-09-04 untreated untreated switch
1 112 2016-02-29 2016-07-14 untreated untreated switch
1 57 1971-01-08 1975-05-18 untreated untreated switch
1 90 1998-10-13 1999-09-09 untreated switch switch
1 36 2011-11-08 2012-07-31 untreated untreated switch
1 188 2007-01-19 2008-04-27 switch switch switch
1 144 2014-05-19 2016-11-05 untreated untreated switch
1 70 2004-10-25 2005-02-02 untreated untreated restart and switch
1 120 2006-05-12 2008-01-20 untreated untreated restart and switch
1 124 1989-10-30 1990-05-13 switch restart and switch restart and switch
1 9 2009-04-14 2010-01-04 untreated untreated restart and switch