Skip to contents

[Deprecated]

Usage

summariseDrugUse(
  cohort,
  cdm = lifecycle::deprecated(),
  strata = list(),
  estimates = c("min", "q05", "q25", "median", "q75", "q95", "max", "mean", "sd",
    "count_missing", "percentage_missing"),
  minCellCount = lifecycle::deprecated()
)

Arguments

cohort

Cohort with drug use variables and strata.

cdm

Deprecated.

strata

Stratification list.

estimates

Estimates that we want for the columns.

minCellCount

Deprecated.

Value

A summary of the drug use stratified by cohort_name and strata_name

Examples

# \donttest{
library(DrugUtilisation)
library(PatientProfiles)

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, "acetaminophen")
#> Warning: ! `codelist` contains numeric values, they are casted to integers.
cdm <- generateDrugUtilisationCohortSet(
  cdm, "dus_cohort", codelist
)
cdm[["dus_cohort"]] <- cdm[["dus_cohort"]] |>
  addDrugUse(ingredientConceptId = 1125315)
result <- summariseDrugUse(cdm[["dus_cohort"]])
#> ! names of group will be ignored
#>  The following estimates will be computed:
#>  number_exposures: min, q05, q25, median, q75, q95, max, mean, sd,
#>   count_missing, percentage_missing
#>  duration: min, q05, q25, median, q75, q95, max, mean, sd, count_missing,
#>   percentage_missing
#>  cumulative_quantity: min, q05, q25, median, q75, q95, max, mean, sd,
#>   count_missing, percentage_missing
#>  number_eras: min, q05, q25, median, q75, q95, max, mean, sd, count_missing,
#>   percentage_missing
#>  initial_quantity: min, q05, q25, median, q75, q95, max, mean, sd,
#>   count_missing, percentage_missing
#>  impute_daily_dose_percentage: min, q05, q25, median, q75, q95, max, mean, sd,
#>   count_missing, percentage_missing
#>  impute_duration_percentage: min, q05, q25, median, q75, q95, max, mean, sd,
#>   count_missing, percentage_missing
#>  initial_daily_dose_milligram: min, q05, q25, median, q75, q95, max, mean, sd,
#>   count_missing, percentage_missing
#>  cumulative_dose_milligram: min, q05, q25, median, q75, q95, max, mean, sd,
#>   count_missing, percentage_missing
#> ! Table is collected to memory as not all requested estimates are supported on
#>   the database side
#> → Start summary of data, at 2024-11-04 09:25:22.051303
#>  Summary finished, at 2024-11-04 09:25:22.218362
print(result)
#> # A tibble: 101 × 13
#>    result_id cdm_name group_name  group_level       strata_name strata_level
#>        <int> <chr>    <chr>       <chr>             <chr>       <chr>       
#>  1         1 DUS MOCK cohort_name 161_acetaminophen overall     overall     
#>  2         1 DUS MOCK cohort_name 161_acetaminophen overall     overall     
#>  3         1 DUS MOCK cohort_name 161_acetaminophen overall     overall     
#>  4         1 DUS MOCK cohort_name 161_acetaminophen overall     overall     
#>  5         1 DUS MOCK cohort_name 161_acetaminophen overall     overall     
#>  6         1 DUS MOCK cohort_name 161_acetaminophen overall     overall     
#>  7         1 DUS MOCK cohort_name 161_acetaminophen overall     overall     
#>  8         1 DUS MOCK cohort_name 161_acetaminophen overall     overall     
#>  9         1 DUS MOCK cohort_name 161_acetaminophen overall     overall     
#> 10         1 DUS MOCK cohort_name 161_acetaminophen overall     overall     
#> # ℹ 91 more rows
#> # ℹ 7 more variables: variable_name <chr>, variable_level <chr>,
#> #   estimate_name <chr>, estimate_type <chr>, estimate_value <chr>,
#> #   additional_name <chr>, additional_level <chr>

cdm[["dus_cohort"]] <- cdm[["dus_cohort"]] |>
  addSex() |>
  addAge(ageGroup = list("<40" = c(0, 39), ">=40" = c(40, 150)))

cdm[["dus_cohort"]] |>
  summariseDrugUse(strata = list("age_group", "sex", c("age_group", "sex")))
#> ! names of group will be ignored
#>  The following estimates will be computed:
#>  number_exposures: min, q05, q25, median, q75, q95, max, mean, sd,
#>   count_missing, percentage_missing
#>  duration: min, q05, q25, median, q75, q95, max, mean, sd, count_missing,
#>   percentage_missing
#>  cumulative_quantity: min, q05, q25, median, q75, q95, max, mean, sd,
#>   count_missing, percentage_missing
#>  number_eras: min, q05, q25, median, q75, q95, max, mean, sd, count_missing,
#>   percentage_missing
#>  initial_quantity: min, q05, q25, median, q75, q95, max, mean, sd,
#>   count_missing, percentage_missing
#>  impute_daily_dose_percentage: min, q05, q25, median, q75, q95, max, mean, sd,
#>   count_missing, percentage_missing
#>  impute_duration_percentage: min, q05, q25, median, q75, q95, max, mean, sd,
#>   count_missing, percentage_missing
#>  initial_daily_dose_milligram: min, q05, q25, median, q75, q95, max, mean, sd,
#>   count_missing, percentage_missing
#>  cumulative_dose_milligram: min, q05, q25, median, q75, q95, max, mean, sd,
#>   count_missing, percentage_missing
#> ! Table is collected to memory as not all requested estimates are supported on
#>   the database side
#> → Start summary of data, at 2024-11-04 09:25:23.193551
#>  Summary finished, at 2024-11-04 09:25:23.901625
#> # A tibble: 606 × 13
#>    result_id cdm_name group_name  group_level       strata_name strata_level
#>        <int> <chr>    <chr>       <chr>             <chr>       <chr>       
#>  1         1 DUS MOCK cohort_name 161_acetaminophen overall     overall     
#>  2         1 DUS MOCK cohort_name 161_acetaminophen overall     overall     
#>  3         1 DUS MOCK cohort_name 161_acetaminophen overall     overall     
#>  4         1 DUS MOCK cohort_name 161_acetaminophen overall     overall     
#>  5         1 DUS MOCK cohort_name 161_acetaminophen overall     overall     
#>  6         1 DUS MOCK cohort_name 161_acetaminophen overall     overall     
#>  7         1 DUS MOCK cohort_name 161_acetaminophen overall     overall     
#>  8         1 DUS MOCK cohort_name 161_acetaminophen overall     overall     
#>  9         1 DUS MOCK cohort_name 161_acetaminophen overall     overall     
#> 10         1 DUS MOCK cohort_name 161_acetaminophen overall     overall     
#> # ℹ 596 more rows
#> # ℹ 7 more variables: variable_name <chr>, variable_level <chr>,
#> #   estimate_name <chr>, estimate_type <chr>, estimate_value <chr>,
#> #   additional_name <chr>, additional_level <chr>
# }