
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(),
CDMConnector::eunomiaDir("synpuf-1k", "5.3"))
cdm <- CDMConnector::cdmFromCon(con = con,
cdmName = "Eunomia Synpuf",
cdmSchema = "main",
writeSchema = "main",
achillesSchema = "main")
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-1021-azure:R 4.4.2//tmp/RtmpSNREcu/file21d77eb16cd.duckdb]
#> $ cohort_definition_id <int> 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2…
#> $ subject_id <int> 435, 743, 1212, 519, 347, 328, 466, 480, 429, 461…
#> $ cohort_start_date <date> 2008-12-19, 2010-04-02, 2010-04-17, 2008-03-21, …
#> $ cohort_end_date <date> 2008-12-19, 2010-04-02, 2010-04-17, 2008-03-21, …
Summarising code use
To get a good understanding of the codes we’ve used to define our
cohorts we can use the codelistDiagnostics()
function.
code_diag <- codelistDiagnostics(cdm$injuries)
From our results we can see a table of counts of our codes in our database based on the achilles results.
tableAchillesCodeUse(code_diag)
Database name
|
|||||||
---|---|---|---|---|---|---|---|
Eunomia Synpuf
|
|||||||
Codelist name | Domain ID | Standard concept name | Standard concept ID | Standard concept | Vocabulary ID |
Estimate name
|
|
Record count | Person count | ||||||
ankle_sprain | condition | Sprain of ankle | 81151 | standard | SNOMED | 31 | 27 |
And we can also see orphan codes, which are codes that we did not include in our cohort definition but maybe could have. These are codes being used in the database that are associated with codes we included in our definition. So although many can be false positives, we may identify some codes that we may want to our cohort definitions.
tableOrphanCodes(code_diag)
Database name
|
|||||||
---|---|---|---|---|---|---|---|
Eunomia Synpuf
|
|||||||
Codelist name | Domain ID | Standard concept name | Standard concept ID | Standard concept | Vocabulary ID |
Estimate name
|
|
Record count | Person count | ||||||
ankle_fracture | condition | Open fracture of medial malleolus | 432749 | standard | SNOMED | 3 | 3 |
Open fracture of lateral malleolus | 437998 | standard | SNOMED | 3 | 3 | ||
Closed bimalleolar fracture | 438879 | standard | SNOMED | 9 | 7 | ||
Closed fracture of medial malleolus | 439162 | standard | SNOMED | 4 | 3 | ||
Open bimalleolar fracture | 441154 | standard | SNOMED | 1 | 1 | ||
Closed trimalleolar fracture | 441155 | standard | SNOMED | 5 | 4 | ||
Closed fracture of lateral malleolus | 441428 | standard | SNOMED | 21 | 12 | ||
Closed fracture of talus | 74777 | standard | SNOMED | 2 | 2 | ||
Closed fracture of ankle | 75095 | standard | SNOMED | 19 | 16 | ||
Open fracture of talus | 77131 | standard | SNOMED | 2 | 2 | ||
Open fracture of ankle | 78888 | standard | SNOMED | 5 | 4 | ||
ankle_sprain | condition | Sprain of distal tibiofibular ligament | 73889 | standard | SNOMED | 4 | 4 |
Sprain of calcaneofibular ligament | 75667 | standard | SNOMED | 1 | 1 | ||
Sprain of deltoid ligament of ankle | 77707 | standard | SNOMED | 4 | 4 | ||
forearm_fracture | condition | Closed fracture of shaft of bone of forearm | 4101989 | standard | SNOMED | 1 | 1 |
Open fracture of shaft of bone of forearm | 4195752 | standard | SNOMED | 2 | 2 | ||
Open fracture of neck of radius | 432744 | standard | SNOMED | 1 | 1 | ||
Open fracture of lower end of radius AND ulna | 432747 | standard | SNOMED | 1 | 1 | ||
Open fracture of proximal end of ulna | 433047 | standard | SNOMED | 2 | 2 | ||
Open fracture of shaft of ulna | 433333 | standard | SNOMED | 1 | 1 | ||
Open Colles' fracture | 434767 | standard | SNOMED | 2 | 2 | ||
Open fracture of upper end of forearm | 434771 | standard | SNOMED | 1 | 1 | ||
Closed fracture of distal end of ulna | 435374 | standard | SNOMED | 4 | 3 | ||
Closed fracture of radius AND ulna | 435380 | standard | SNOMED | 6 | 6 | ||
Closed Colles' fracture | 435950 | standard | SNOMED | 20 | 13 | ||
Closed fracture of proximal end of ulna | 436251 | standard | SNOMED | 1 | 1 | ||
Closed fracture of ulna | 436541 | standard | SNOMED | 1 | 1 | ||
Closed fracture of shaft of radius | 436826 | standard | SNOMED | 2 | 2 | ||
Closed fracture of neck of radius | 436837 | standard | SNOMED | 3 | 2 | ||
Closed fracture of distal end of radius | 437116 | standard | SNOMED | 48 | 33 | ||
Open fracture of lower end of forearm | 437122 | standard | SNOMED | 1 | 1 | ||
Open fracture of upper end of radius AND ulna | 437393 | standard | SNOMED | 1 | 1 | ||
Closed fracture of lower end of forearm | 437394 | standard | SNOMED | 4 | 3 | ||
Closed fracture of shaft of ulna | 437400 | standard | SNOMED | 1 | 1 | ||
Open fracture of ulna | 438576 | standard | SNOMED | 1 | 1 | ||
Closed fracture of radius | 439166 | standard | SNOMED | 11 | 7 | ||
Closed fracture of upper end of forearm | 439940 | standard | SNOMED | 4 | 3 | ||
Pathological fracture - forearm | 440511 | standard | SNOMED | 1 | 1 | ||
Closed fracture of lower end of radius AND ulna | 440538 | standard | SNOMED | 6 | 5 | ||
Closed fracture of upper end of radius AND ulna | 440544 | standard | SNOMED | 6 | 2 | ||
Open fracture of distal end of radius | 440546 | standard | SNOMED | 3 | 3 | ||
Open fracture of forearm | 440851 | standard | SNOMED | 1 | 1 | ||
Closed fracture of proximal end of radius | 441973 | standard | SNOMED | 3 | 3 | ||
Closed fracture of forearm | 441974 | standard | SNOMED | 1 | 1 | ||
Fracture of radius AND ulna | 442598 | standard | SNOMED | 1 | 1 | ||
Torus fracture of radius | 443428 | standard | SNOMED | 1 | 1 | ||
Closed fracture of olecranon process of ulna | 73036 | standard | SNOMED | 7 | 5 | ||
Closed fracture of head of radius | 73341 | standard | SNOMED | 6 | 4 | ||
Open fracture of coronoid process of ulna | 74192 | standard | SNOMED | 1 | 1 | ||
Open fracture of olecranon process of ulna | 74763 | standard | SNOMED | 4 | 4 | ||
Closed Monteggia's fracture | 79165 | standard | SNOMED | 1 | 1 | ||
Closed fracture of coronoid process of ulna | 79172 | standard | SNOMED | 2 | 2 | ||
Open Monteggia's fracture | 81148 | standard | SNOMED | 1 | 1 | ||
hip_fracture | condition | Closed intertrochanteric fracture | 136834 | standard | SNOMED | 56 | 38 |
Closed fracture proximal femur, subtrochanteric | 4009610 | standard | SNOMED | 12 | 9 | ||
Closed fracture of neck of femur | 434500 | standard | SNOMED | 144 | 77 | ||
Closed fracture of base of neck of femur | 435956 | standard | SNOMED | 15 | 10 | ||
Closed fracture of midcervical section of femur | 436247 | standard | SNOMED | 16 | 14 | ||
Closed fracture of intracapsular section of femur | 437703 | standard | SNOMED | 8 | 7 | ||
Closed transcervical fracture of femur | 440556 | standard | SNOMED | 20 | 17 | ||
Closed fracture of acetabulum | 81696 | standard | SNOMED | 10 | 6 |
addCodelistAttribute
Some cohorts that may be created manually may not have the codelists
recorded in the cohort_codelist
attribute. The package has
a utility function to record a codelist in a cohort_table
object:
cohortCodelist(cdm$injuries, cohortId = 1)
#>
#> - ankle_fracture (1 codes)
cdm$injuries <- cdm$injuries |>
addCodelistAttribute(codelist = list(new_codelist = c(1L, 2L)), cohortName = "ankle_fracture")
cohortCodelist(cdm$injuries, cohortId = 1)
#>
#> - new_codelist (2 codes)