Generate a set of drug cohorts based on given concepts
Source:R/generateDrugUtilisationCohortSet.R
generateDrugUtilisationCohortSet.Rd
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,
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.
- conceptSet
The concepts used to create the cohort, provide as a codelist or concept set expression.
- 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.
- durationRange
Deprecated.
- imputeDuration
Deprecated.
- priorUseWashout
Deprecated.
- priorObservation
Deprecated.
- cohortDateRange
Deprecated.
- limit
Deprecated.
Examples
# \donttest{
library(CDMConnector)
library(DrugUtilisation)
library(dplyr)
cdm <- mockDrugUtilisation()
#> Warning: ! 6 column in person do not match expected column type:
#> • `gender_concept_id` is numeric but expected integer
#> • `race_concept_id` is numeric but expected integer
#> • `ethnicity_concept_id` is numeric but expected integer
#> • `location_id` is numeric but expected integer
#> • `provider_id` is numeric but expected integer
#> • `care_site_id` is numeric but expected integer
#> Warning: ! 1 column in observation_period do not match expected column type:
#> • `period_type_concept_id` is numeric but expected integer
#> Warning: ! 2 column in visit_occurrence do not match expected column type:
#> • `visit_concept_id` is numeric but expected integer
#> • `visit_type_concept_id` is numeric but expected integer
#> Warning: ! 10 column in condition_occurrence do not match expected column type:
#> • `condition_concept_id` is numeric but expected integer
#> • `condition_type_concept_id` is numeric but expected integer
#> • `condition_status_concept_id` is numeric but expected integer
#> • `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: ! 2 column in drug_exposure do not match expected column type:
#> • `drug_concept_id` is numeric but expected integer
#> • `drug_type_concept_id` is numeric but expected integer
#> Warning: ! 2 column in observation do not match expected column type:
#> • `observation_concept_id` is numeric but expected integer
#> • `observation_type_concept_id` is numeric but expected integer
#> Warning: ! 4 column in concept do not match expected column type:
#> • `concept_id` is numeric 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
#> Warning: ! 2 column in concept_relationship do not match expected column type:
#> • `concept_id_1` is numeric but expected integer
#> • `concept_id_2` is numeric but expected integer
#> Warning: ! 4 column in concept_ancestor do not match expected column type:
#> • `ancestor_concept_id` is numeric but expected integer
#> • `descendant_concept_id` is numeric but expected integer
#> • `min_levels_of_separation` is numeric but expected integer
#> • `max_levels_of_separation` is numeric but expected integer
#> Warning: ! 9 column in drug_strength do not match expected column type:
#> • `drug_concept_id` is numeric but expected integer
#> • `ingredient_concept_id` is numeric but expected integer
#> • `amount_unit_concept_id` is numeric but expected integer
#> • `numerator_unit_concept_id` is numeric but expected integer
#> • `denominator_unit_concept_id` is numeric but expected integer
#> • `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
#> Warning: ! 6 column in person do not match expected column type:
#> • `gender_concept_id` is numeric but expected integer
#> • `race_concept_id` is numeric but expected integer
#> • `ethnicity_concept_id` is numeric but expected integer
#> • `location_id` is numeric but expected integer
#> • `provider_id` is numeric but expected integer
#> • `care_site_id` is numeric but expected integer
#> Warning: ! 1 column in observation_period do not match expected column type:
#> • `period_type_concept_id` is numeric but expected integer
druglist <- CodelistGenerator::getDrugIngredientCodes(
cdm, c("acetaminophen", "metformin")
)
#> Warning: ! `codelist` contains numeric values, they are casted to integers.
cdm <- generateDrugUtilisationCohortSet(
cdm = cdm,
name = "drug_cohorts",
conceptSet = druglist
)
cdm$drug_cohorts |>
glimpse()
#> Rows: ??
#> Columns: 4
#> Database: DuckDB v1.1.2 [unknown@Linux 6.5.0-1025-azure:R 4.4.2/:memory:]
#> $ cohort_definition_id <int> 2, 2, 1, 2, 1, 2, 1, 2, 1, 1
#> $ subject_id <int> 2, 9, 10, 3, 6, 5, 10, 7, 7, 4
#> $ cohort_start_date <date> 1971-04-17, 2007-03-16, 1985-05-02, 2005-10-02, 2…
#> $ cohort_end_date <date> 1975-06-05, 2011-10-24, 1992-08-14, 2009-11-12, 2…
# }