Skip to contents

Adds a new cohort table to the cdm reference with individuals who have drug exposure records with the specified concepts. Cohort start and end dates will be based on drug record start and end dates, respectively. Records that overlap or have fewer days between them than the specified gap era will be concatenated into a single cohort entry.

Usage

generateDrugUtilisationCohortSet(
  cdm,
  name,
  conceptSet,
  gapEra = 1,
  subsetCohort = NULL,
  subsetCohortId = NULL,
  numberExposures = FALSE,
  daysPrescribed = FALSE,
  durationRange = lifecycle::deprecated(),
  imputeDuration = lifecycle::deprecated(),
  priorUseWashout = lifecycle::deprecated(),
  priorObservation = lifecycle::deprecated(),
  cohortDateRange = lifecycle::deprecated(),
  limit = lifecycle::deprecated()
)

Arguments

cdm

A cdm_reference object.

name

Name of the new cohort table, it must be a length 1 character vector.

conceptSet

List of concepts to be included.

gapEra

Number of days between two continuous exposures to be considered in the same era.

subsetCohort

Cohort table to subset.

subsetCohortId

Cohort id to subset.

numberExposures

Whether to include 'number_exposures' (number of drug exposure records between indexDate and censorDate).

daysPrescribed

Whether to include 'days_prescribed' (number of days prescribed used to create each era).

durationRange

Deprecated.

imputeDuration

Deprecated.

priorUseWashout

Deprecated.

priorObservation

Deprecated.

cohortDateRange

Deprecated.

limit

Deprecated.

Value

The function returns the cdm reference provided with the addition of the new cohort table.

Examples

# \donttest{
library(CDMConnector)
library(DrugUtilisation)
library(dplyr)

cdm <- mockDrugUtilisation()

druglist <- CodelistGenerator::getDrugIngredientCodes(
  cdm, c("acetaminophen", "metformin"), nameStyle = "{concept_name}"
)

cdm <- generateDrugUtilisationCohortSet(
  cdm = cdm,
  name = "drug_cohorts",
  conceptSet = druglist,
  gapEra = 30,
  numberExposures = TRUE,
  daysPrescribed = TRUE
)
#>  Subsetting drug_exposure table
#>  Checking whether any record needs to be dropped.
#>  Collapsing overlaping records.
#>  Collapsing records with gapEra = 30 days.

cdm$drug_cohorts |>
  glimpse()
#> Rows: ??
#> Columns: 6
#> Database: DuckDB v1.1.3 [unknown@Linux 6.8.0-1017-azure:R 4.4.2/:memory:]
#> $ cohort_definition_id <int> 2, 1, 2, 1, 2, 1, 1
#> $ subject_id           <int> 1, 10, 1, 9, 10, 3, 6
#> $ cohort_start_date    <date> 2020-11-08, 2011-08-04, 2019-12-14, 2020-03-15, 2…
#> $ cohort_end_date      <date> 2020-12-19, 2012-02-02, 2019-12-31, 2020-10-01, 2…
#> $ number_exposures     <int> 1, 1, 1, 1, 1, 1, 1
#> $ days_prescribed      <int> 42, 183, 18, 201, 674, 367, 208
# }