Author: Marti Catala, Mike Du, Yuchen Guo, Kim Lopez-Guell, Edward Burn, Xintong Li
Date: 2024-05-14

# Add indications to Drug Utilisation Cohort

#### Marti Catala, Mike Du, Yuchen Guo, Kim Lopez-Guell, Edward Burn, Xintong Li

#### 2024-05-14

# 2 Introduction

In this vignette, we demonstrate how to use the `addIndications()` function to establish a binary indicator between the drug utilisation cohort and another concept-based cohort.

The DrugUtilisation package is designed to work with data in the OMOP CDM format, so our first step is to create a reference to the data using the DBI and CDMConnector packages. The connection to a Postgres database would look like:

    library(DrugUtilisation)
    library(DBI)
    library(duckdb)
    library(CDMConnector)
    library(CodelistGenerator)
    library(dplyr)
    library(PatientProfiles)

    con <- DBI::dbConnect(duckdb::duckdb(), eunomia_dir())

    cdm <- CDMConnector::cdm_from_con(
      con = con,
      cdm_schema = "main",
      write_schema = "main"
    )

## 2.1 Create a drug utilisation cohort

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

    conceptList <- CodelistGenerator::getDrugIngredientCodes(cdm, "acetaminophen")
    conceptList
    #> $acetaminophen
    #> [1]  1125315  1127078  1127433 40229134 40231925 40162522 19133768

Next, we can 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,
      limit = "All",
      gapEra = 30,
      priorUseWashout = 0
    )

## 2.2 Create a indication cohort

Next we going to create our indications cohort to indicate patients with sinusitis and bronchitis. This can be done by using `generateConceptCohortSet()`.

    indications <-
      list(
        sinusitis = c(257012, 4294548, 40481087),
        bronchitis = c(260139, 258780)
      )

    cdm <-
      generateConceptCohortSet(cdm, name = "indications_cohort", indications)

    cohortCount(cdm[["indications_cohort"]]) %>%
      left_join(
        settings(cdm[["indications_cohort"]]) %>%
          select(cohort_definition_id, cohort_name),
        by = "cohort_definition_id"
      )
    #> # A tibble: 2 × 4
    #>   cohort_definition_id number_records number_subjects cohort_name
    #>                  <int>          <int>           <int> <chr>
    #> 1                    1           2688            2688 sinusitis
    #> 2                    2           2546            2546 bronchitis

# 3 Add indications with addIndication() function

Then to add indication to the drug utilisation cohort we can simple use the `addIndication()` function. To do that, we only need the drug utilisation cohort and the `indicationCohortName`. However, other arguments can be specified using the additional parameters. An example is provided below.

    cdm[["acetaminophen_users"]] %>%
      addIndication(
        cdm = cdm,
        indicationCohortName = "indications_cohort",
        indicationGap =  c(0, 30, 365),
        unknownIndicationTable =  c("condition_occurrence")
      )
    #> # Source:   table<og_044_1715646254> [?? x 16]
    #> # Database: DuckDB v0.10.0 [martics@Windows 10 x64:R 4.2.3/C:\Users\martics\AppData\Local\Temp\RtmpoTdumo\file70e037153989.duckdb]
    #>    cohort_definition_id subject_id cohort_start_date cohort_end_date
    #>                   <int>      <int> <date>            <date>
    #>  1                    1         97 1999-07-06        1999-07-20
    #>  2                    1        180 1981-11-09        1981-11-23
    #>  3                    1        249 2011-01-19        2011-01-26
    #>  4                    1        358 1957-03-27        1957-04-03
    #>  5                    1        364 2016-09-10        2016-09-24
    #>  6                    1        387 1974-08-26        1974-10-25
    #>  7                    1        403 1926-02-07        1926-02-21
    #>  8                    1        479 1949-02-17        1949-03-03
    #>  9                    1        480 1954-02-10        1954-03-12
    #> 10                    1        480 1994-11-07        1994-11-14
    #> # ℹ more rows
    #> # ℹ 12 more variables: indication_gap_0_bronchitis <dbl>,
    #> #   indication_gap_0_sinusitis <dbl>, indication_gap_0_none <dbl>,
    #> #   indication_gap_0_unknown <dbl>, indication_gap_30_sinusitis <dbl>,
    #> #   indication_gap_30_bronchitis <dbl>, indication_gap_30_none <dbl>,
    #> #   indication_gap_30_unknown <dbl>, indication_gap_365_bronchitis <dbl>,
    #> #   indication_gap_365_sinusitis <dbl>, indication_gap_365_none <dbl>, …

Use `indicationGap` to specify the indication gaps, which are defined as the gap between the event and the indication. Additionally, you can use `unknownIndicationTable` to specify the tables to look for unknown indication.

## 3.1 Summarise indications with summariseIndication()

To create a summary table of the indications cohort, you can use the `summariseIndication()` function.

    cdm[["acetaminophen_users"]] %>%
      addIndication(
        cdm = cdm,
        indicationCohortName = "indications_cohort",
        indicationGap =  c(0, 30, 365),
        unknownIndicationTable =  c("condition_occurrence")
      ) %>%
      summariseIndication(cdm) %>%
      select("variable_name", "estimate_name", "estimate_value")
    #> # A tibble: 26 × 3
    #>    variable_name            estimate_name estimate_value
    #>    <chr>                    <chr>         <chr>
    #>  1 number records           count         13860
    #>  2 number subjects          count         2679
    #>  3 Indication on index date count         <NA>
    #>  4 Indication on index date percentage    <NA>
    #>  5 Indication on index date count         2518
    #>  6 Indication on index date percentage    18.1673881673882
    #>  7 Indication on index date count         163
    #>  8 Indication on index date percentage    1.17604617604618
    #>  9 Indication on index date count         11178
    #> 10 Indication on index date percentage    80.6493506493507
    #> # ℹ 16 more rows

You can also summarise the indications by using the `strata` argument in the `summariseIndication()` function. In the example below, it is summarized by `ageGroup` and `sex`.

    cdm[["acetaminophen_users"]] %>%
      addDemographics(ageGroup = list(c(0, 19), c(20, 150))) %>%
      addIndication(
        cdm = cdm,
        indicationCohortName = "indications_cohort",
        indicationGap =  c(0),
        unknownIndicationTable =  c("condition_occurrence")
      ) %>%
      summariseIndication(
        cdm,
        strata = list("age" = "age_group", "sex" = "sex")) %>%
          select("variable_name", "estimate_name", "estimate_value","strata_name")
    #> # A tibble: 50 × 4
    #>    variable_name            estimate_name estimate_value   strata_name
    #>    <chr>                    <chr>         <chr>            <chr>
    #>  1 number records           count         13860            overall
    #>  2 number subjects          count         2679             overall
    #>  3 Indication on index date count         <NA>             overall
    #>  4 Indication on index date percentage    <NA>             overall
    #>  5 Indication on index date count         2518             overall
    #>  6 Indication on index date percentage    18.1673881673882 overall
    #>  7 Indication on index date count         163              overall
    #>  8 Indication on index date percentage    1.17604617604618 overall
    #>  9 Indication on index date count         11178            overall
    #> 10 Indication on index date percentage    80.6493506493507 overall
    #> # ℹ 40 more rows