1.1 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 drug Utilisation 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"
)

1.2 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” to generate a concept list associated with Acetaminophen.

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

Next, we can create a drug utilization cohort by using the conceptList with the “generateDrugUtilisationCohortSet” function. For a better understanding of the arguments and functionaities of “generateDrugUtilisationCohortSet”, please refer to the “How to Create a Cohort” vignette.

cdm <- generateDrugUtilisationCohortSet(
  cdm = cdm,
  name = "acetaminophen_users",
  conceptSet = conceptList,
  limit = "All",
  gapEra = 30,
  priorUseWashout = 0
)

1.3 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(
    cohortSet(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>          <dbl>           <dbl> <chr>      
#> 1                    1           2688            2688 sinusitis  
#> 2                    2           2546            2546 bronchitis

1.4 Add indications

Then to add indication to the drug Utilisation cohort we can simple use the addIndication function. An example is provided below. The function have argument to specify the indication gaps. The indication gaps is defined as the gap between the event and the indication. It also allow user to specify the tables to look for unknown indication.


cdm[["acetaminophen_users"]] %>%
  addIndication(
    cdm = cdm, 
    indicationCohortName = "indications_cohort",
    indicationGap =  c(0, 30, 365),
    unknownIndicationTable =  c("condition_occurrence")
  )
#> # Source:   table<dbplyr_195> [?? x 16]
#> # Database: DuckDB v0.9.1 [martics@Windows 10 x64:R 4.2.3/C:\Users\martics\AppData\Local\Temp\RtmpyU5BPt\file7238721a2d2b.duckdb]
#>    cohort_definition_id subject_id cohort_start_date cohort_end_date
#>                   <int>      <dbl> <date>            <date>         
#>  1                    1          7 2001-07-18        2001-08-01     
#>  2                    1         57 1986-07-31        1986-08-14     
#>  3                    1         80 1953-02-24        1953-03-10     
#>  4                    1         80 2008-06-03        2008-06-17     
#>  5                    1         84 1979-09-25        1979-10-09     
#>  6                    1         84 1996-11-08        1996-11-22     
#>  7                    1         86 1952-07-05        1952-07-19     
#>  8                    1         86 1965-11-10        1965-11-24     
#>  9                    1         86 1977-12-14        1977-12-28     
#> 10                    1        144 1980-10-21        1980-11-04     
#> # ℹ more rows
#> # ℹ 12 more variables: indication_gap_0_bronchitis <dbl>,
#> #   indication_gap_0_sinusitis <dbl>, indication_gap_0_none <dbl>,
#> #   indication_gap_30_sinusitis <dbl>, indication_gap_30_bronchitis <dbl>,
#> #   indication_gap_30_none <dbl>, indication_gap_365_bronchitis <dbl>,
#> #   indication_gap_365_sinusitis <dbl>, indication_gap_365_none <dbl>,
#> #   indication_gap_0_unknown <dbl>, indication_gap_30_unknown <dbl>, …

1.5 Summarise Indications

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", "estimate_type", "estimate")
#> # A tibble: 26 × 3
#>    variable                        estimate_type estimate         
#>    <chr>                           <chr>         <chr>            
#>  1 number subjects                 count         2679             
#>  2 number records                  count         13860            
#>  3 Indication on index date        count         2518             
#>  4 Indication on index date        percentage    18.1673881673882 
#>  5 Indication on index date        count         <5               
#>  6 Indication on index date        percentage    <NA>             
#>  7 Indication on index date        count         163              
#>  8 Indication on index date        percentage    1.17604617604618 
#>  9 Indication during prior 30 days count         21               
#> 10 Indication during prior 30 days percentage    0.151515151515152
#> # ℹ 16 more rows

You can also summarize 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", "estimate_type", "estimate","strata_name")
#> # A tibble: 50 × 4
#>    variable                 estimate_type estimate         strata_name
#>    <chr>                    <chr>         <chr>            <chr>      
#>  1 number subjects          count         2679             Overall    
#>  2 number records           count         13860            Overall    
#>  3 Indication on index date count         2518             Overall    
#>  4 Indication on index date percentage    18.1673881673882 Overall    
#>  5 Indication on index date count         <5               Overall    
#>  6 Indication on index date percentage    <NA>             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