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(dplyr)
library(PatientProfiles)
con <- DBI::dbConnect(duckdb::duckdb(), eunomia_dir())
cdm <- CDMConnector::cdm_from_con(
con = con,
cdm_schema = "main",
write_schema = "main"
)
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
#>
#> - 161_acetaminophen (7 codes)
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
)
Next we going to create our indications cohort to indicate patients
with sinusitis and bronchitis. This can be done by using
CDMConnector::generateConceptCohortSet()
.
indications <-
list(
sinusitis = c(257012, 4294548, 40481087),
bronchitis = c(260139, 258780)
)
cdm <-
CDMConnector::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
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(
indicationCohortName = "indications_cohort",
indicationWindow = list(c(0,0),c(-30,0),c(-365,0)),
unknownIndicationTable = c("condition_occurrence")
)
#> # Source: table<og_085_1721394717> [?? x 7]
#> # Database: DuckDB v1.0.0 [root@Darwin 23.4.0:R 4.4.1//private/var/folders/pl/k11lm9710hlgl02nvzx4z9wr0000gp/T/RtmpgwzDZu/file10f7b733c74b7.duckdb]
#> cohort_definition_id subject_id cohort_start_date cohort_end_date
#> <int> <int> <date> <date>
#> 1 1 488 1962-09-21 1962-09-28
#> 2 1 4602 1996-04-30 1996-05-07
#> 3 1 4562 1975-09-14 1975-09-21
#> 4 1 1425 1946-08-01 1946-08-15
#> 5 1 457 1954-04-01 1954-04-15
#> 6 1 1658 1928-07-31 1928-08-14
#> 7 1 4086 1979-02-28 1979-03-07
#> 8 1 4990 1971-03-09 1971-03-23
#> 9 1 4432 1966-01-11 1966-01-25
#> 10 1 388 1994-08-16 1994-08-30
#> # ℹ more rows
#> # ℹ 3 more variables: indication_0_to_0 <chr>, indication_m30_to_0 <chr>,
#> # indication_m365_to_0 <chr>
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.
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")
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")