Skip to contents

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)
#> Error in get(paste0(generic, ".", class), envir = get_method_env()) : 
#>   object 'type_sum.accel' not found

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            107              92

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             93              85

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:

  • Restarting the same treatment.

  • Switching to a different treatment.

  • Restarting the same treatment while also switching to another.

  • Discontinuing treatment altogether (neither the original treatment nor any potential switch).

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> "13", "14.1304347826087", "3", "3.26086956521739", "2…
#> $ 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:

  • restrictToFirstDiscontinuation

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:

  • censorEndDate

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

  • strata

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()
cdm_name
DUS MOCK
cohort_table_name incident switch_cohort_table sex Treatment estimate_name
cohort_name
cohort_1 cohort_2 cohort_3
Drug restart in 180 days
cohort1 TRUE insulin overall restart N (%) 0 (0.0 %) 0 (0.0 %) 0 (0.0 %)
cohort1 TRUE insulin overall switch N (%) 3 (4.5 %) 3 (5.9 %) 4 (4.8 %)
cohort1 TRUE insulin overall restart and switch N (%) 0 (0.0 %) 0 (0.0 %) 0 (0.0 %)
cohort1 TRUE insulin overall untreated N (%) 63 (95.5 %) 48 (94.1 %) 79 (95.2 %)
cohort1 TRUE insulin Female restart N (%) 0 (0.0 %) 0 (0.0 %) 0 (0.0 %)
cohort1 TRUE insulin Female switch N (%) 2 (6.9 %) 2 (7.4 %) 3 (7.7 %)
cohort1 TRUE insulin Female restart and switch N (%) 0 (0.0 %) 0 (0.0 %) 0 (0.0 %)
cohort1 TRUE insulin Female untreated N (%) 27 (93.1 %) 25 (92.6 %) 36 (92.3 %)
cohort1 TRUE insulin Male restart N (%) 0 (0.0 %) 0 (0.0 %) 0 (0.0 %)
cohort1 TRUE insulin Male switch N (%) 1 (2.7 %) 1 (4.2 %) 1 (2.3 %)
cohort1 TRUE insulin Male restart and switch N (%) 0 (0.0 %) 0 (0.0 %) 0 (0.0 %)
cohort1 TRUE insulin Male untreated N (%) 36 (97.3 %) 23 (95.8 %) 43 (97.7 %)
Drug restart in 365 days
cohort1 TRUE insulin overall restart N (%) 0 (0.0 %) 0 (0.0 %) 0 (0.0 %)
cohort1 TRUE insulin overall switch N (%) 3 (4.5 %) 5 (9.8 %) 5 (6.0 %)
cohort1 TRUE insulin overall restart and switch N (%) 0 (0.0 %) 0 (0.0 %) 0 (0.0 %)
cohort1 TRUE insulin overall untreated N (%) 63 (95.5 %) 46 (90.2 %) 78 (94.0 %)
cohort1 TRUE insulin Female restart N (%) 0 (0.0 %) 0 (0.0 %) 0 (0.0 %)
cohort1 TRUE insulin Female switch N (%) 2 (6.9 %) 3 (11.1 %) 4 (10.3 %)
cohort1 TRUE insulin Female restart and switch N (%) 0 (0.0 %) 0 (0.0 %) 0 (0.0 %)
cohort1 TRUE insulin Female untreated N (%) 27 (93.1 %) 24 (88.9 %) 35 (89.7 %)
cohort1 TRUE insulin Male restart N (%) 0 (0.0 %) 0 (0.0 %) 0 (0.0 %)
cohort1 TRUE insulin Male switch N (%) 1 (2.7 %) 2 (8.3 %) 1 (2.3 %)
cohort1 TRUE insulin Male restart and switch N (%) 0 (0.0 %) 0 (0.0 %) 0 (0.0 %)
cohort1 TRUE insulin Male untreated N (%) 36 (97.3 %) 22 (91.7 %) 43 (97.7 %)
Drug restart till end of observation
cohort1 TRUE insulin overall restart N (%) 0 (0.0 %) 0 (0.0 %) 0 (0.0 %)
cohort1 TRUE insulin overall switch N (%) 5 (7.6 %) 8 (15.7 %) 8 (9.6 %)
cohort1 TRUE insulin overall restart and switch N (%) 0 (0.0 %) 0 (0.0 %) 0 (0.0 %)
cohort1 TRUE insulin overall untreated N (%) 61 (92.4 %) 43 (84.3 %) 75 (90.4 %)
cohort1 TRUE insulin Female restart N (%) 0 (0.0 %) 0 (0.0 %) 0 (0.0 %)
cohort1 TRUE insulin Female switch N (%) 4 (13.8 %) 5 (18.5 %) 6 (15.4 %)
cohort1 TRUE insulin Female restart and switch N (%) 0 (0.0 %) 0 (0.0 %) 0 (0.0 %)
cohort1 TRUE insulin Female untreated N (%) 25 (86.2 %) 22 (81.5 %) 33 (84.6 %)
cohort1 TRUE insulin Male restart N (%) 0 (0.0 %) 0 (0.0 %) 0 (0.0 %)
cohort1 TRUE insulin Male switch N (%) 1 (2.7 %) 3 (12.5 %) 2 (4.5 %)
cohort1 TRUE insulin Male restart and switch N (%) 0 (0.0 %) 0 (0.0 %) 0 (0.0 %)
cohort1 TRUE insulin Male untreated N (%) 36 (97.3 %) 21 (87.5 %) 42 (95.5 %)

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)