Codelist diagnostics
a02_CodelistDiagnostics.Rmd
Introduction
In this example we’re going to summarise the characteristics of individuals with an ankle sprain, ankle fracture, forearm fracture, or a hip fracture using the Eunomia synthetic data.
We’ll begin by creating our study cohorts.
library(CDMConnector)
library(CohortConstructor)
library(CodelistGenerator)
library(PhenotypeR)
library(dplyr)
library(ggplot2)
con <- DBI::dbConnect(duckdb::duckdb(),
dbdir = CDMConnector::eunomiaDir()
)
cdm <- CDMConnector::cdmFromCon(con,
cdmSchema = "main",
writeSchema = "main",
cdmName = "Eunomia"
)
cdm$injuries <- conceptCohort(cdm = cdm,
conceptSet = list(
"ankle_sprain" = 81151,
"ankle_fracture" = 4059173,
"forearm_fracture" = 4278672,
"hip_fracture" = 4230399
),
name = "injuries")
cdm$injuries |>
glimpse()
#> Rows: ??
#> Columns: 4
#> Database: DuckDB v1.1.3 [unknown@Linux 6.8.0-1020-azure:R 4.4.2//tmp/Rtmphddhan/file2b1e43943760.duckdb]
#> $ cohort_definition_id <int> 1, 2, 2, 2, 2, 2, 2, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2…
#> $ subject_id <int> 191, 321, 1025, 1779, 1791, 2980, 4279, 4274, 516…
#> $ cohort_start_date <date> 1994-05-07, 1996-06-30, 1941-04-18, 1955-03-23, …
#> $ cohort_end_date <date> 1994-08-05, 1996-07-21, 1941-05-16, 1955-04-06, …
Summarising code use
code_diag <- codelistDiagnostics(cdm$injuries)
#tableCohortCodeUse(code_diag)