Skip to contents

Introduction

In this vignette we introduce the use of addDrugUse() and summariseDrugUse() functions to get drug-related information of subjects in OMOP CDM tables and cohort tables.

Create a drug utilisation cohort

We will use Acetaminophen as our example drug to construct our drug utilisation cohort. To begin, we will employ the package CodelistGenerator to generate a concept list associated with Acetaminophen.

conceptList <- getDrugIngredientCodes(cdm, c("acetaminophen"))
conceptList
#> $acetaminophen
#> [1]  1125315  1125360  2905077 43135274

Next, we create a drug utilisation cohort by using the conceptList with the generateDrugUtilisationCohortSet() function. For a better understanding of the arguments and functionalities of generateDrugUtilisationCohortSet(), please refer to the Use DrugUtilisation to create a cohort vignette.

cdm <- generateDrugUtilisationCohortSet(
  cdm  = cdm,
  name = "acetaminophen_users",
  conceptSet = conceptList
)

addDrugUse

addDrugUse() function is used to add columns related to the drug use. You must provide a cohort and a reference ingredient. See an example below.

addDrugUse(
  cohort = cdm[["acetaminophen_users"]],
  cdm    = cdm,
  ingredientConceptId = 1125315
) %>%
  glimpse()
#> Rows: ??
#> Columns: 13
#> Database: DuckDB v0.9.2 [unknown@Linux 6.2.0-1019-azure:R 4.3.2/:memory:]
#> $ cohort_definition_id         <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,…
#> $ subject_id                   <int> 25, 12, 36, 146, 186, 22, 92, 97, 103, 12…
#> $ cohort_start_date            <date> 2013-04-08, 2003-06-26, 2018-05-24, 2008…
#> $ cohort_end_date              <date> 2016-08-10, 2004-10-19, 2019-10-31, 2008…
#> $ duration                     <dbl> 1221, 482, 526, 34, 1659, 138, 77, 638, 1…
#> $ number_exposures             <dbl> 1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 1, 3, 1, 1,…
#> $ cumulative_quantity          <dbl> 30, 15, 90, 40, 15, 50, 80, 60, 50, 130, …
#> $ initial_quantity             <dbl> 30, 15, 10, 40, 15, 50, 80, 60, 50, 30, 6…
#> $ impute_duration_percentage   <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
#> $ number_eras                  <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,…
#> $ impute_daily_dose_percentage <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
#> $ initial_daily_dose_milligram <dbl> 235.872236, 12.448133, 182.509506, 11294.…
#> $ cumulative_dose_milligram    <dbl> 288000, 6000, 128000, 384000, 6000, 48000…

As seen, the following columns have been added:

1. number_exposures: Number of exposures during the cohort observation.

2. cumulative_quantity: Cumulative sum of the column quantity of drug_exposure table during the drug exposure period.

3. initial_quantity: Quantity at drug_exposure_start_date.

4. impute_duration_percentage: If a drug exposure record does not have the duration of the exposure, or falls outside a specified range (see later), records will be imputed. This column shows the number of records that have been imputed or that would be imputed.

5. number_eras: Number of eras within each drug exposure period.

6. impute_daily_dose_percentage: If a drug exposure record does not have the daily dose of the exposure, or falls outside a specified range (see later), records will be imputed. This column shows the number of records that have been imputed or that would be imputed.

7. initial_daily_dose_milligram: dose at drug_exposure_start_date.

8. cumulative_dose_milligram: cumulative sum of the column dose of drug_exposure table during the drug exposure period,

You can choose which columns will be added by defining the duration, quantity, and dose inputs as either TRUE or FALSE.

addDrugUse(
  cohort = cdm[["acetaminophen_users"]],
  cdm    = cdm,
  ingredientConceptId = 1125315,
  duration = TRUE,
  quantity = FALSE,
  dose = FALSE
) %>%
  glimpse()
#> Rows: ??
#> Columns: 8
#> Database: DuckDB v0.9.2 [unknown@Linux 6.2.0-1019-azure:R 4.3.2/:memory:]
#> $ cohort_definition_id       <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
#> $ subject_id                 <int> 25, 12, 36, 146, 186, 22, 92, 97, 103, 129,…
#> $ cohort_start_date          <date> 2013-04-08, 2003-06-26, 2018-05-24, 2008-0…
#> $ cohort_end_date            <date> 2016-08-10, 2004-10-19, 2019-10-31, 2008-0…
#> $ duration                   <dbl> 1221, 482, 526, 34, 1659, 138, 77, 638, 124…
#> $ number_exposures           <dbl> 1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 1, 3, 1, 1, 1…
#> $ impute_duration_percentage <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0…
#> $ number_eras                <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…

If duration, quantity, and dose are FALSE, only number_exposures and number_eras will be added.

addDrugUse(
  cohort = cdm[["acetaminophen_users"]],
  cdm    = cdm,
  ingredientConceptId = 1125315,
  gapEra = 20,
  eraJoinMode = "zero",
  duration = FALSE,
  quantity = FALSE,
  dose = FALSE
) %>%
  glimpse()
#> Rows: ??
#> Columns: 6
#> Database: DuckDB v0.9.2 [unknown@Linux 6.2.0-1019-azure:R 4.3.2/:memory:]
#> $ cohort_definition_id <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
#> $ subject_id           <int> 25, 12, 36, 146, 186, 22, 92, 97, 103, 129, 7, 86…
#> $ cohort_start_date    <date> 2013-04-08, 2003-06-26, 2018-05-24, 2008-04-22, …
#> $ cohort_end_date      <date> 2016-08-10, 2004-10-19, 2019-10-31, 2008-05-25, …
#> $ number_exposures     <dbl> 1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 1, 3, 1, 1, 2, 1, 2…
#> $ number_eras          <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…

gapEra

gapEra parameter defines the number of days between two continuous drug exposures. Let’s see an example.

First, let’s create a cohort with gapEra = 0. For a better understanding, let’s observe only subject_id number 56.

cdm <- generateDrugUtilisationCohortSet(
  cdm = cdm,
  name = "acetaminophen_example1",
  conceptSet = conceptList,
  gapEra = 0
)
 
cdm$drug_exposure %>%
  filter(drug_concept_id %in% !!conceptList$acetaminophen) %>%
  filter(person_id == 56) %>%
  glimpse()
#> Rows: ??
#> Columns: 7
#> Database: DuckDB v0.9.2 [unknown@Linux 6.2.0-1019-azure:R 4.3.2/:memory:]
#> $ drug_exposure_id         <int> 166, 164
#> $ person_id                <int> 56, 56
#> $ drug_concept_id          <dbl> 1125360, 43135274
#> $ drug_exposure_start_date <date> 2022-01-27, 2021-08-08
#> $ drug_exposure_end_date   <date> 2022-03-04, 2021-09-17
#> $ drug_type_concept_id     <dbl> 38000177, 38000177
#> $ quantity                 <dbl> 100, 20

This subject has two different drug exposure periods separated by less than 6 months. Hence, it has two different cohort periods:

cdm$acetaminophen_example1 %>%
  addDrugUse(
    ingredientConceptId = 1125315,
    gapEra = 0
  ) %>%
  filter(subject_id == 56) %>%
  glimpse()
#> Rows: ??
#> Columns: 13
#> Database: DuckDB v0.9.2 [unknown@Linux 6.2.0-1019-azure:R 4.3.2/:memory:]
#> $ cohort_definition_id         <int> 1, 1
#> $ subject_id                   <int> 56, 56
#> $ cohort_start_date            <date> 2022-01-27, 2021-08-08
#> $ cohort_end_date              <date> 2022-03-04, 2021-09-17
#> $ duration                     <dbl> 37, 41
#> $ number_exposures             <dbl> 1, 1
#> $ cumulative_quantity          <dbl> 100, 20
#> $ initial_quantity             <dbl> 100, 20
#> $ impute_duration_percentage   <dbl> 0, 0
#> $ number_eras                  <dbl> 1, 1
#> $ impute_daily_dose_percentage <dbl> 0, 0
#> $ initial_daily_dose_milligram <dbl> 1351.351, 195.122
#> $ cumulative_dose_milligram    <dbl> 50000, 8000

Let’s merge this two periods by modifying the gapEra input when creating the cohort. For a better understanding of gapEra arguments and functionalities, please see Use DrugUtilisation to create a cohort vignette.

cdm <- generateDrugUtilisationCohortSet(
  cdm = cdm,
  name = "acetaminophen_example2",
  conceptSet = conceptList,
  gapEra = 180
)

cdm$acetaminophen_example2 %>%
  addDrugUse(
    ingredientConceptId = 1125315,
    gapEra = 180,
    duration = TRUE,
    quantity = FALSE,
    dose = FALSE
  ) %>%
  filter(subject_id == 56) %>%
  glimpse()
#> Rows: ??
#> Columns: 8
#> Database: DuckDB v0.9.2 [unknown@Linux 6.2.0-1019-azure:R 4.3.2/:memory:]
#> $ cohort_definition_id       <int> 1
#> $ subject_id                 <int> 56
#> $ cohort_start_date          <date> 2021-08-08
#> $ cohort_end_date            <date> 2022-03-04
#> $ duration                   <dbl> 209
#> $ number_exposures           <dbl> 2
#> $ impute_duration_percentage <dbl> 0
#> $ number_eras                <dbl> 1

Mow we have only one record with two exposures for subject number 56. Note that the number of eras is still 1, as we have defined the same gapEra as when the cohort was created. However, it is possible to specify a different gapEra than the one defined when the cohort was created.

cdm$acetaminophen_example2 %>%
  addDrugUse(
    ingredientConceptId = 1125315,
    gapEra = 0
  ) %>%
  filter(subject_id == 56) %>%
  glimpse()
#> Rows: ??
#> Columns: 13
#> Database: DuckDB v0.9.2 [unknown@Linux 6.2.0-1019-azure:R 4.3.2/:memory:]
#> $ cohort_definition_id         <int> 1
#> $ subject_id                   <int> 56
#> $ cohort_start_date            <date> 2021-08-08
#> $ cohort_end_date              <date> 2022-03-04
#> $ duration                     <dbl> 209
#> $ number_exposures             <dbl> 2
#> $ cumulative_quantity          <dbl> 120
#> $ initial_quantity             <dbl> 20
#> $ impute_duration_percentage   <dbl> 0
#> $ number_eras                  <dbl> 2
#> $ impute_daily_dose_percentage <dbl> 0
#> $ initial_daily_dose_milligram <dbl> 195.122
#> $ cumulative_dose_milligram    <dbl> 58000

Note that number_eras now indicates that we have two eras within the same record.

eraJoinMode

subject_id number 56 has two separate exposure periods. As observed, by defining the gapEra, we can merge these two periods into a single era. However, there are different ways to join these two continuous exposures, and this can be specified with eraJoinMode.

The are three different ways to join different continuous exposures:

  1. eraJoinMode = "zero" (default option): Subject’s daily dose during the period between both continuous exposures is zero. However, the time elapsed between these exposures contributes to the total exposed time.
cdm$acetaminophen_example2 %>%
  addDrugUse(
    ingredientConceptId = 1125315,
    gapEra = 180,
    duration = TRUE,
    quantity = TRUE,
    dose = TRUE,
    eraJoinMode = "zero"
  ) %>%
  dplyr::filter(subject_id == 56) %>%
  glimpse()
#> Rows: ??
#> Columns: 13
#> Database: DuckDB v0.9.2 [unknown@Linux 6.2.0-1019-azure:R 4.3.2/:memory:]
#> $ cohort_definition_id         <int> 1
#> $ subject_id                   <int> 56
#> $ cohort_start_date            <date> 2021-08-08
#> $ cohort_end_date              <date> 2022-03-04
#> $ duration                     <dbl> 209
#> $ number_exposures             <dbl> 2
#> $ cumulative_quantity          <dbl> 120
#> $ initial_quantity             <dbl> 20
#> $ impute_duration_percentage   <dbl> 0
#> $ number_eras                  <dbl> 1
#> $ impute_daily_dose_percentage <dbl> 0
#> $ initial_daily_dose_milligram <dbl> 195.122
#> $ cumulative_dose_milligram    <dbl> 58000
  1. eraJoinMode = "previous": The subject’s daily dose during the period between both continuous exposures is equal to the daily dose of the earliest subexposure. The time between both exposures contributes to the total exposed time.
cdm$acetaminophen_example2 %>%
  addDrugUse(
    ingredientConceptId = 1125315,
    gapEra = 180,
    duration = TRUE,
    quantity = TRUE,
    dose = TRUE,
    eraJoinMode = "previous"
  ) %>%
  dplyr::filter(subject_id == 56) %>%
  glimpse()
#> Rows: ??
#> Columns: 13
#> Database: DuckDB v0.9.2 [unknown@Linux 6.2.0-1019-azure:R 4.3.2/:memory:]
#> $ cohort_definition_id         <int> 1
#> $ subject_id                   <int> 56
#> $ cohort_start_date            <date> 2021-08-08
#> $ cohort_end_date              <date> 2022-03-04
#> $ duration                     <dbl> 209
#> $ number_exposures             <dbl> 2
#> $ cumulative_quantity          <dbl> 120
#> $ initial_quantity             <dbl> 20
#> $ impute_duration_percentage   <dbl> 0
#> $ number_eras                  <dbl> 1
#> $ impute_daily_dose_percentage <dbl> 0
#> $ initial_daily_dose_milligram <dbl> 195.122
#> $ cumulative_dose_milligram    <dbl> 83560.98
  1. eraJoinMode = "subsequent": The subject’s daily dose during the period between both continuous exposures is the daily dose of the latest subexposure. The time between both exposures contributes to the total exposed time.
cdm$acetaminophen_example2 %>%
  addDrugUse(
    ingredientConceptId = 1125315,
    gapEra = 180,
    duration = TRUE,
    quantity = TRUE,
    dose = TRUE,
    eraJoinMode = "subsequent"
  ) %>%
  dplyr::filter(subject_id == 56) %>%
  glimpse()
#> Rows: ??
#> Columns: 13
#> Database: DuckDB v0.9.2 [unknown@Linux 6.2.0-1019-azure:R 4.3.2/:memory:]
#> $ cohort_definition_id         <int> 1
#> $ subject_id                   <int> 56
#> $ cohort_start_date            <date> 2021-08-08
#> $ cohort_end_date              <date> 2022-03-04
#> $ duration                     <dbl> 209
#> $ number_exposures             <dbl> 2
#> $ cumulative_quantity          <dbl> 120
#> $ initial_quantity             <dbl> 20
#> $ impute_duration_percentage   <dbl> 0
#> $ number_eras                  <dbl> 1
#> $ impute_daily_dose_percentage <dbl> 0
#> $ initial_daily_dose_milligram <dbl> 195.122
#> $ cumulative_dose_milligram    <dbl> 235027

overlapMode

In the previous example, we observed the merging of two separated drug exposure periods into one era. Now, let’s explore how two overlapping drug exposure periods can be merged. It’s important to note that this input only impacts overlapping periods that do not share the same start date. Refer to the input sameIndexMode for details on managing overlapping periods with the same start date.

Let’s observe subject number 8.

cdm$drug_exposure %>%
  filter(drug_concept_id %in% !!conceptList$acetaminophen) %>%
  filter(person_id == 8)  %>%
  glimpse()
#> Rows: ??
#> Columns: 7
#> Database: DuckDB v0.9.2 [unknown@Linux 6.2.0-1019-azure:R 4.3.2/:memory:]
#> $ drug_exposure_id         <int> 27, 28
#> $ person_id                <int> 8, 8
#> $ drug_concept_id          <dbl> 1125360, 1125360
#> $ drug_exposure_start_date <date> 1984-12-28, 1982-11-07
#> $ drug_exposure_end_date   <date> 1985-10-29, 1986-11-11
#> $ drug_type_concept_id     <dbl> 38000177, 38000177
#> $ quantity                 <dbl> 35, 1

We can customize how the overlapping is handled using the overlapMode input. In this case, there are five options:

  1. overlapMode* = "sum" (default): The daily dose considered is the sum of all exposures.
cdm$acetaminophen_example2 %>%
  addDrugUse(
    ingredientConceptId = 1125315,
    duration = FALSE,
    quantity = FALSE,
    dose     = TRUE,
    overlapMode = "sum"
  ) %>% 
  dplyr::filter(subject_id == 8) %>%
  glimpse()
#> Rows: ??
#> Columns: 9
#> Database: DuckDB v0.9.2 [unknown@Linux 6.2.0-1019-azure:R 4.3.2/:memory:]
#> $ cohort_definition_id         <int> 1
#> $ subject_id                   <int> 8
#> $ cohort_start_date            <date> 1982-11-07
#> $ cohort_end_date              <date> 1986-11-11
#> $ number_exposures             <dbl> 2
#> $ number_eras                  <dbl> 1
#> $ impute_daily_dose_percentage <dbl> 0
#> $ initial_daily_dose_milligram <dbl> 0.3410641
#> $ cumulative_dose_milligram    <dbl> 18000
  1. overlapMode* = "previous": The daily dose considered is that of the earliest exposure.
cdm$acetaminophen_example2 %>%
  addDrugUse(
    ingredientConceptId = 1125315,
    duration = FALSE,
    quantity = FALSE,
    dose     = TRUE,
    overlapMode = "previous"
  ) %>%
  dplyr::filter(subject_id == 8) %>%
  glimpse()
#> Rows: ??
#> Columns: 9
#> Database: DuckDB v0.9.2 [unknown@Linux 6.2.0-1019-azure:R 4.3.2/:memory:]
#> $ cohort_definition_id         <int> 1
#> $ subject_id                   <int> 8
#> $ cohort_start_date            <date> 1982-11-07
#> $ cohort_end_date              <date> 1986-11-11
#> $ number_exposures             <dbl> 2
#> $ number_eras                  <dbl> 1
#> $ impute_daily_dose_percentage <dbl> 0
#> $ initial_daily_dose_milligram <dbl> 0.3410641
#> $ cumulative_dose_milligram    <dbl> 500
  1. overlapMode = "subsequent": The daily dose considered is that of the latest exposure.
cdm$acetaminophen_example2 %>%
  addDrugUse(
    ingredientConceptId = 1125315,
    duration = FALSE,
    quantity = FALSE,
    dose     = TRUE,
    overlapMode = "subsequent"
  ) %>%
  dplyr::filter(subject_id == 8) %>%
  select(contains("dose")) %>%
  glimpse()
#> Rows: ??
#> Columns: 3
#> Database: DuckDB v0.9.2 [unknown@Linux 6.2.0-1019-azure:R 4.3.2/:memory:]
#> $ impute_daily_dose_percentage <dbl> 0
#> $ initial_daily_dose_milligram <dbl> 0.3410641
#> $ cumulative_dose_milligram    <dbl> 17895.63
  1. overlapMode = "minimum": The daily dose considered is the minimum value among all exposures.
cdm$acetaminophen_example2 %>%
  addDrugUse(
    ingredientConceptId = 1125315,
    duration = FALSE,
    quantity = FALSE,
    dose     = TRUE,
    overlapMode = "minimum"
  ) %>%
  dplyr::filter(subject_id == 8) %>%
  glimpse()
#> Rows: ??
#> Columns: 9
#> Database: DuckDB v0.9.2 [unknown@Linux 6.2.0-1019-azure:R 4.3.2/:memory:]
#> $ cohort_definition_id         <int> 1
#> $ subject_id                   <int> 8
#> $ cohort_start_date            <date> 1982-11-07
#> $ cohort_end_date              <date> 1986-11-11
#> $ number_exposures             <dbl> 2
#> $ number_eras                  <dbl> 1
#> $ impute_daily_dose_percentage <dbl> 0
#> $ initial_daily_dose_milligram <dbl> 0.3410641
#> $ cumulative_dose_milligram    <dbl> 500
  1. overlapMode = "maximum": The daily dose considered is the maximum value among all exposures
cdm$acetaminophen_example2 %>%
  addDrugUse(
    ingredientConceptId = 1125315,
    duration = FALSE,
    quantity = FALSE,
    dose     = TRUE,
    overlapMode = "maximum"
  ) %>%
  dplyr::filter(subject_id == 8) %>%
  glimpse()
#> Rows: ??
#> Columns: 9
#> Database: DuckDB v0.9.2 [unknown@Linux 6.2.0-1019-azure:R 4.3.2/:memory:]
#> $ cohort_definition_id         <int> 1
#> $ subject_id                   <int> 8
#> $ cohort_start_date            <date> 1982-11-07
#> $ cohort_end_date              <date> 1986-11-11
#> $ number_exposures             <dbl> 2
#> $ number_eras                  <dbl> 1
#> $ impute_daily_dose_percentage <dbl> 0
#> $ initial_daily_dose_milligram <dbl> 0.3410641
#> $ cumulative_dose_milligram    <dbl> 17895.63

sameIndexMode

This input works similarly to overlapMode, but specifically impacts overlapping drug exposure periods with the same start date. It has the options “minimum”, “maximum”, and “sum” (default one), described in overlapMode.

imputeDuration and imputeDailyDose

These inputs determine the way the duration or the daily dose will be imputed if their value is NA or fall outside the specified range (defined in the durationRange and dailyDoseRange inputs). There are five possible values for these two inputs:

  1. imputeDuration/imputeDailyDose* = "none" (default): imputation is not applied.
  2. imputeDuration*/*imputeDailyDose = "median", "mean", "mode": imputation method that will be used.
  3. imputeDuration*/*imputeDailyDose can also be a numerical value that will replace the previous one.

durationRange and dailyDoseRange

These inputs are used to define the range within which the duration/daily dose must be comprised. It should be a numeric vector of length two, and the second value must be greater than or equal to the first one. If set to NULL, no restrictions are applied.

If durationRange and dailyDoseRange are not set to “none”, imputeDuration and imputeDailyDose must be specified, respectively.

summariseDrugUse

This function is employed to sum up the dose table across multiple cohorts. Let’s see how it operates.

First, let’s use addDrugUse() to add drug details to our “acetaminophen_users” cohort. Then, we can apply summariseDrugUse() to explore the characteristics of the cohort.

cdm[["acetaminophen_users"]] <- cdm[["acetaminophen_users"]] %>% 
  addDrugUse(
    cdm    = cdm,
    ingredientConceptId = 1125315
  )

summariseDrugUse(cdm[["acetaminophen_users"]]) %>%
  glimpse()
#> Rows: 101
#> Columns: 15
#> $ cdm_name         <chr> "DUS MOCK", "DUS MOCK", "DUS MOCK", "DUS MOCK", "DUS …
#> $ result_type      <chr> "summarised_drug_use", "summarised_drug_use", "summar…
#> $ package_name     <chr> "DrugUtilisation", "DrugUtilisation", "DrugUtilisatio…
#> $ package_version  <chr> "0.5.0", "0.5.0", "0.5.0", "0.5.0", "0.5.0", "0.5.0",…
#> $ group_name       <chr> "cohort_name", "cohort_name", "cohort_name", "cohort_…
#> $ group_level      <chr> "acetaminophen", "acetaminophen", "acetaminophen", "a…
#> $ strata_name      <chr> "overall", "overall", "overall", "overall", "overall"…
#> $ strata_level     <chr> "overall", "overall", "overall", "overall", "overall"…
#> $ variable_name    <chr> "number subjects", "number records", "duration", "dur…
#> $ variable_level   <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…
#> $ estimate_name    <chr> "count", "count", "min", "q05", "q25", "median", "q75…
#> $ estimate_type    <chr> "numeric", "numeric", "numeric", "numeric", "numeric"…
#> $ estimate_value   <chr> "117", "141", "1", "6", "85", "386", "1242", "4037", …
#> $ additional_name  <chr> "overall", "overall", "overall", "overall", "overall"…
#> $ additional_level <chr> "overall", "overall", "overall", "overall", "overall"…

strata

We can employ this parameter to stratify our cohort and calculate the estimates within every strata group.

Let’s use addSex() function from PatientProfiles to include a sex column in our cohort. Subsequently, we can use it as a strata parameter.

cdm[["acetaminophen_users"]] <- cdm[["acetaminophen_users"]] %>%
  addSex(cdm)

summariseDrugUse(cdm[["acetaminophen_users"]],
                 strata = list("sex" = "sex")) %>%
  glimpse()
#> Rows: 303
#> Columns: 15
#> $ cdm_name         <chr> "DUS MOCK", "DUS MOCK", "DUS MOCK", "DUS MOCK", "DUS …
#> $ result_type      <chr> "summarised_drug_use", "summarised_drug_use", "summar…
#> $ package_name     <chr> "DrugUtilisation", "DrugUtilisation", "DrugUtilisatio…
#> $ package_version  <chr> "0.5.0", "0.5.0", "0.5.0", "0.5.0", "0.5.0", "0.5.0",…
#> $ group_name       <chr> "cohort_name", "cohort_name", "cohort_name", "cohort_…
#> $ group_level      <chr> "acetaminophen", "acetaminophen", "acetaminophen", "a…
#> $ strata_name      <chr> "overall", "overall", "overall", "overall", "overall"…
#> $ strata_level     <chr> "overall", "overall", "overall", "overall", "overall"…
#> $ variable_name    <chr> "number subjects", "number records", "duration", "dur…
#> $ variable_level   <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…
#> $ estimate_name    <chr> "count", "count", "min", "q05", "q25", "median", "q75…
#> $ estimate_type    <chr> "numeric", "numeric", "numeric", "numeric", "numeric"…
#> $ estimate_value   <chr> "117", "141", "1", "6", "85", "386", "1242", "4037", …
#> $ additional_name  <chr> "overall", "overall", "overall", "overall", "overall"…
#> $ additional_level <chr> "overall", "overall", "overall", "overall", "overall"…

drugUseEstimates

Use this input to specify the estimates to be calculated. By default, it will compute the minimum value, quartiles (5%, 25%, 50% - median, 75% and 95%), the maximum value, the mean, the standard deviation, and the number of missings values for each column added with addDrugUse().

minCellCount

Specify the minimum number of individuals that a strata group must appear in the table.