Skip to contents

Add new columns with drug use related information

Usage

addDrugUtilisation(
  cohort,
  gapEra,
  conceptSet = NULL,
  ingredientConceptId = NULL,
  indexDate = "cohort_start_date",
  censorDate = "cohort_end_date",
  restrictIncident = TRUE,
  numberExposures = TRUE,
  numberEras = TRUE,
  exposedTime = TRUE,
  timeToExposure = TRUE,
  initialQuantity = TRUE,
  cumulativeQuantity = TRUE,
  initialDailyDose = TRUE,
  cumulativeDose = TRUE,
  nameStyle = "{value}_{concept_name}_{ingredient}",
  name = NULL
)

Arguments

cohort

Cohort in the cdm

gapEra

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

conceptSet

List of concepts to be included. If NULL all the descendants of ingredient concept id will be used.

ingredientConceptId

Ingredient OMOP concept that we are interested for the study. It is a compulsory input, no default value is provided.

indexDate

Name of a column that indicates the date to start the analysis.

censorDate

Name of a column that indicates the date to stop the analysis, if NULL end of individuals observation is used.

restrictIncident

Whether to include only incident prescriptions in the analysis. If FALSE all prescriptions that overlap with the study period will be included.

numberExposures

Whether to add a column with the number of exposures.

numberEras

Whether to add a column with the number of eras.

exposedTime

Whether to add a column with the number of exposed days.

timeToExposure

Whether to add a column with the number of days between indexDate and start of the first exposure.

initialQuantity

Whether to add a column with the initial quantity.

cumulativeQuantity

Whether to add a column with the cumulative quantity of the identified prescription.

initialDailyDose

Whether to add a column with the initial daily dose.

cumulativeDose

Whether to add a column with the cumulative dose.

nameStyle

Character string to specify the nameStyle of the new columns.

name

Name of the new computed cohort table, if NULL a temporary tables is created.

Value

The same cohort with the added columns.

Examples

# \donttest{
library(DrugUtilisation)

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
codelist <- CodelistGenerator::getDrugIngredientCodes(
  cdm,
  name = "acetaminophen"
)
#> Warning: ! `codelist` contains numeric values, they are casted to integers.

cdm <- generateDrugUtilisationCohortSet(cdm, "dus_cohort", codelist)
cdm[["dus_cohort"]] |>
  addDrugUtilisation(ingredientConceptId = 1125315, gapEra = 30)
#> Warning: ! `codelist` contains numeric values, they are casted to integers.
#> # Source:   table<og_041_1725980405> [7 x 12]
#> # Database: DuckDB v1.0.0 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:]
#>   cohort_definition_id subject_id cohort_start_date cohort_end_date
#>                  <int>      <int> <date>            <date>         
#> 1                    1         10 2012-03-26        2012-10-03     
#> 2                    1          1 1994-12-28        1998-01-18     
#> 3                    1          5 2019-12-27        2019-12-30     
#> 4                    1         10 2012-12-21        2013-10-18     
#> 5                    1          5 2020-01-03        2020-01-07     
#> 6                    1          3 2019-12-01        2020-01-15     
#> 7                    1          2 2015-10-12        2017-02-27     
#> # ℹ 8 more variables: number_exposures_ingredient_1125315_descendants <int>,
#> #   time_to_exposure_ingredient_1125315_descendants <int>,
#> #   cumulative_quantity_ingredient_1125315_descendants <dbl>,
#> #   initial_quantity_ingredient_1125315_descendants <dbl>,
#> #   number_eras_ingredient_1125315_descendants <int>,
#> #   exposed_time_ingredient_1125315_descendants <int>,
#> #   cumulative_dose_milligram_ingredient_1125315_descendants_1125315 <dbl>, …
# }