Skip to contents

Adds a new cohort table to the cdm reference with individuals who have drug exposure records with the specified drug ingredient. 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

generateIngredientCohortSet(
  cdm,
  name,
  ingredient = NULL,
  gapEra = 1,
  ...,
  durationRange = lifecycle::deprecated(),
  imputeDuration = lifecycle::deprecated(),
  priorUseWashout = lifecycle::deprecated(),
  priorObservation = lifecycle::deprecated(),
  cohortDateRange = lifecycle::deprecated(),
  limit = lifecycle::deprecated()
)

Arguments

cdm

A cdm reference.

name

The name of the new cohort table to add to the cdm reference.

ingredient

Accepts both vectors and named lists of ingredient names. For a vector input, e.g., c("acetaminophen", "codeine"), it generates a cohort table with descendant concept codes for each ingredient, assigning unique cohort_definition_id. For a named list input, e.g., list( "test_1" = c("simvastatin", "acetaminophen"), "test_2" = "metformin"), it produces a cohort table based on the structure of the input, where each name leads to a combined set of descendant concept codes for the specified ingredients, creating distinct cohort_definition_id for each named group.

gapEra

Number of days between two continuous exposures to be considered in the same era. Records that have fewer days between them than this gap will be concatenated into the same cohort record.

...

Arguments to be passed to CodelistGenerator::getDrugIngredientCodes().

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(DrugUtilisation)
library(dplyr)

cdm <- mockDrugUtilisation()
#> Warning: ! 7 column in condition_occurrence do not match expected column type:
#>  `stop_reason` is logical but expected character
#>  `provider_id` is logical but expected integer
#>  `visit_occurrence_id` is logical but expected integer
#>  `visit_detail_id` is logical but expected integer
#>  `condition_source_value` is logical but expected character
#>  `condition_source_concept_id` is logical but expected integer
#>  `condition_status_source_value` is logical but expected character
#> Warning: ! 3 column in concept do not match expected column type:
#>  `valid_start_date` is character but expected date
#>  `valid_end_date` is character but expected date
#>  `invalid_reason` is logical but expected character
#> Warning: ! 4 column in drug_strength do not match expected column type:
#>  `box_size` is logical but expected integer
#>  `valid_start_date` is character but expected date
#>  `valid_end_date` is character but expected date
#>  `invalid_reason` is logical but expected character

cdm <- generateIngredientCohortSet(
  cdm = cdm,
  ingredient = "acetaminophen",
  name = "acetaminophen"
)
#> Warning: ! `codelist` contains numeric values, they are casted to integers.

cdm$acetaminophen |>
  glimpse()
#> Rows: ??
#> Columns: 4
#> Database: DuckDB v1.1.3-dev165 [unknown@Linux 6.5.0-1025-azure:R 4.4.2/:memory:]
#> $ cohort_definition_id <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
#> $ subject_id           <int> 7, 2, 3, 6, 8, 10, 2, 6, 6, 8, 1
#> $ cohort_start_date    <date> 2016-10-14, 2020-05-10, 2000-05-16, 2020-06-13, 2…
#> $ cohort_end_date      <date> 2019-09-05, 2020-05-21, 2005-12-15, 2020-06-30, 2…
# }