Generates a cohort of the drug use of a certain list of concepts.
generateDrugUtilisationCohortSet.Rd
Generates a cohort of the drug use of a certain list of concepts.
Arguments
- cdm
A cdm_reference object.
- name
Name of the GeneratedCohortSet
- conceptSet
Named list of concept sets.
- durationRange
Range between the duration must be comprised. It should be a numeric vector of length two, with no NAs and the first value should be equal or smaller than the second one. It is only required if imputeDuration = TRUE. If NULL no restrictions are applied.
- imputeDuration
Whether/how the duration should be imputed "none", "median", "mean", "mode", or it can be a count
- gapEra
Number of days between two continuous exposures to be considered in the same era.
- priorUseWashout
Prior days without exposure.
- priorObservation
Minimum number of days of prior observation required for the incident eras to be considered.
- cohortDateRange
Range for cohort_start_date and cohort_end_date
- limit
Choice on how to summarise the exposures. There are two options: "all" we summarise the output will be a summary of the exposed eras of each individual. Each individual can contribute multiple times. "first" we only consider the first observable era of each individual that fulfills the criteria provided in previous parameters. In this case each individual can not contribute with multiple rows.
Examples
# \donttest{
library(CodelistGenerator)
library(CDMConnector)
library(DrugUtilisation)
cdm <- mockDrugUtilisation()
druglist <- getDrugIngredientCodes(cdm, c("acetaminophen", "metformin"))
cdm <- generateDrugUtilisationCohortSet(
cdm = cdm,
name = "drug_cohorts",
conceptSet = druglist,
priorObservation = 365
)
cdm[["drug_cohorts"]]
#> # Source: table<drug_cohorts> [7 x 4]
#> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1018-azure:R 4.4.0/:memory:]
#> cohort_definition_id subject_id cohort_start_date cohort_end_date
#> <int> <int> <date> <date>
#> 1 1 7 2018-05-21 2018-07-20
#> 2 2 3 2005-06-02 2008-05-08
#> 3 1 5 2014-07-28 2019-11-20
#> 4 2 10 1992-02-27 2004-03-07
#> 5 1 3 2009-04-18 2009-11-07
#> 6 1 6 1991-01-28 1991-09-17
#> 7 2 3 1994-02-27 1995-08-16
settings(cdm[["drug_cohorts"]])
#> # A tibble: 2 × 11
#> cohort_definition_id cohort_name duration_range_min duration_range_max
#> <int> <chr> <chr> <chr>
#> 1 1 acetaminophen 1 Inf
#> 2 2 metformin 1 Inf
#> # ℹ 7 more variables: impute_duration <chr>, gap_era <chr>,
#> # prior_use_washout <chr>, prior_observation <chr>,
#> # cohort_date_range_start <chr>, cohort_date_range_end <chr>, limit <chr>
cohortCount(cdm[["drug_cohorts"]])
#> # A tibble: 2 × 3
#> cohort_definition_id number_records number_subjects
#> <int> <int> <int>
#> 1 1 4 4
#> 2 2 3 2
attrition(cdm[["drug_cohorts"]])
#> # A tibble: 4 × 7
#> cohort_definition_id number_records number_subjects reason_id reason
#> <int> <int> <int> <int> <chr>
#> 1 1 11 9 1 Initial qualify…
#> 2 1 4 4 2 require at leas…
#> 3 2 7 5 1 Initial qualify…
#> 4 2 3 2 2 require at leas…
#> # ℹ 2 more variables: excluded_records <int>, excluded_subjects <int>
# }