To add a new column with the time to exposure. To add multiple columns use addDrugUtilisation()
for efficiency.
Source: R/addDrugUtilisation.R
addTimeToExposure.Rd
To add a new column with the time to exposure. To add multiple columns use
addDrugUtilisation()
for efficiency.
Usage
addTimeToExposure(
cohort,
conceptSet,
indexDate = "cohort_start_date",
censorDate = "cohort_end_date",
restrictIncident = TRUE,
nameStyle = "time_to_exposure_{concept_name}",
name = NULL
)
Arguments
- cohort
Cohort in the cdm.
- conceptSet
List of concepts to be included.
- 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.
- 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.
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 = cdm, name = "dus_cohort", conceptSet = codelist
)
cdm$dus_cohort |>
addTimeToExposure(conceptSet = codelist)
#> # Source: table<og_102_1730712197> [8 x 5]
#> # Database: DuckDB v1.1.2 [unknown@Linux 6.5.0-1025-azure:R 4.4.2/:memory:]
#> cohort_definition_id subject_id cohort_start_date cohort_end_date
#> <int> <int> <date> <date>
#> 1 1 4 2014-05-11 2014-09-14
#> 2 1 8 2021-08-07 2021-08-16
#> 3 1 7 1964-05-25 1965-07-15
#> 4 1 7 1966-10-09 1983-05-24
#> 5 1 1 2022-11-30 2022-12-04
#> 6 1 4 2014-09-21 2014-10-03
#> 7 1 5 2021-03-24 2021-04-02
#> 8 1 9 2019-12-28 2020-02-02
#> # ℹ 1 more variable: time_to_exposure_161_acetaminophen <int>
# }