Let’s first create a cdm reference to the Eunomia synthetic data.
One base cohort we can create is based around patient demographics. Here for example we create a cohort where people enter on their 18th birthday and leave at age 65 or
cdm$working_age_cohort <- demographicsCohort(cdm = cdm,
ageRange = c(18, 65),
name = "working_age_cohort")
settings(cdm$working_age_cohort)
#> # A tibble: 1 × 3
#> cohort_definition_id cohort_name age_range
#> <dbl> <chr> <chr>
#> 1 1 demographics 18_65
cohortCount(cdm$working_age_cohort)
#> # A tibble: 1 × 3
#> cohort_definition_id number_records number_subjects
#> <int> <int> <int>
#> 1 1 2694 2694
attrition(cdm$working_age_cohort)
#> # A tibble: 2 × 7
#> cohort_definition_id number_records number_subjects reason_id reason
#> <int> <int> <int> <int> <chr>
#> 1 1 2694 2694 1 Initial qualify…
#> 2 1 2694 2694 2 Age requirement…
#> # ℹ 2 more variables: excluded_records <int>, excluded_subjects <int>
cdm$working_age_cohort |>
addAge(indexDate = "cohort_start_date") |>
summarise(min_start_age = min(age),
median_start_age = median(age),
max_start_age = max(age))
#> # Source: SQL [1 x 3]
#> # Database: DuckDB v0.10.3-dev775 [eburn@Windows 10 x64:R 4.4.0/C:\Users\eburn\AppData\Local\Temp\RtmpgHH2qN\file5b383dc01d2e.duckdb]
#> min_start_age median_start_age max_start_age
#> <int> <dbl> <int>
#> 1 17 18 18
cdm$working_age_cohort |>
addAge(indexDate = "cohort_end_date") |>
summarise(min_start_age = min(age),
median_start_age = median(age),
max_start_age = max(age))
#> # Source: SQL [1 x 3]
#> # Database: DuckDB v0.10.3-dev775 [eburn@Windows 10 x64:R 4.4.0/C:\Users\eburn\AppData\Local\Temp\RtmpgHH2qN\file5b383dc01d2e.duckdb]
#> min_start_age median_start_age max_start_age
#> <int> <dbl> <int>
#> 1 31 57 65
drug_codes <- getDrugIngredientCodes(cdm,
name = c("diclofenac",
"acetaminophen"))
drug_codes
#>
#> - diclofenac (1 codes)
#> - acetaminophen (7 codes)
cdm$medications <- conceptCohort(cdm = cdm,
conceptSet = drug_codes,
name = "medications")
settings(cdm$medications)
#> # A tibble: 2 × 2
#> cohort_definition_id cohort_name
#> <int> <chr>
#> 1 1 diclofenac
#> 2 2 acetaminophen
cohortCount(cdm$medications)
#> # A tibble: 2 × 3
#> cohort_definition_id number_records number_subjects
#> <int> <int> <int>
#> 1 1 830 830
#> 2 2 13908 2679
TO DO