Generating vocabulary based codelists

For this vignette we are going to produce codelists based on the OMOP CDM vocabulary tables. First we will create medication codelists based on ATC classifications and drug ingredients. Second, we will create condition codes based on ICD10 chapters and subchapters.

Medication codelists based on drug ingredients

The function getDrugIngredientCodes() can be used to generate the medication codelists based around ingredient codes. Here, for example, we will create a codelist using ingredient codes only for acetaminophen. We´ll do this using the Eunomia example data.

By default the function will return a codelist. As Eunomia only contains a subset of the OMOP CDM vocabularies we see a few codes returned, but we would get many more if working with the full set of vocabularies.

acetaminophen_codes <- getDrugIngredientCodes(
  cdm = cdm,
  name = "acetaminophen"
)

acetaminophen_codes
#> 
#> ── 1 codelist ──────────────────────────────────────────────────────────────────
#> 
#> - 161_acetaminophen (7 codes)
acetaminophen_codes$acetaminophen
#> NULL

Alternatively, instead of returning a codelist with only the concept IDs we could get them with details such as their name and domain.

acetaminophen_codes_with_details <- getDrugIngredientCodes(
  cdm = cdm,
  name = "acetaminophen",
  type = "codelist_with_details"
)

acetaminophen_codes_with_details
#> 
#> ── 1 codelist with details ─────────────────────────────────────────────────────
#> 
#> - 161_acetaminophen (5 codes)

acetaminophen_codes_with_details[[1]] |> 
  glimpse()
#> Rows: 7
#> Columns: 5
#> $ concept_id       <int> 1125315, 1127078, 1127433, 40229134, 40231925, 401625…
#> $ concept_name     <chr> "Acetaminophen", "Acetaminophen 160 MG Oral Tablet", …
#> $ domain_id        <chr> "Drug", "Drug", "Drug", "Drug", "Drug", "Drug", "Drug"
#> $ vocabulary_id    <chr> "RxNorm", "RxNorm", "RxNorm", "RxNorm", "RxNorm", "Rx…
#> $ standard_concept <chr> "S", "S", "S", "S", "S", "S", "S"

Instead of getting back all concepts for acetaminophen, we could require that only concepts associated with acetaminophen and at least one more drug ingredient (i.e. combination therapies) are returned.

acetaminophen_two_or_more_ingredients <- getDrugIngredientCodes(
  cdm = cdm,
  name = "acetaminophen",
  ingredientRange = c(2,Inf),
  type = "codelist_with_details"
)

acetaminophen_two_or_more_ingredients
#> 
#> ── 1 codelist with details ─────────────────────────────────────────────────────
#> 
#> - 161_acetaminophen (5 codes)

acetaminophen_two_or_more_ingredients[[1]] |> 
  glimpse()
#> Rows: 4
#> Columns: 5
#> $ concept_id       <int> 40229134, 40231925, 40162522, 19133768
#> $ concept_name     <chr> "Acetaminophen 21.7 MG/ML / Dextromethorphan Hydrobro…
#> $ domain_id        <chr> "Drug", "Drug", "Drug", "Drug"
#> $ vocabulary_id    <chr> "RxNorm", "RxNorm", "RxNorm", "RxNorm"
#> $ standard_concept <chr> "S", "S", "S", "S"

Or we could instead only return concepts associated with acetaminophen and no other drug ingredient.

acetaminophen_one_ingredient <- getDrugIngredientCodes(
  cdm = cdm,
  name = "acetaminophen",
  ingredientRange = c(1,1),
  type = "codelist_with_details"
)

acetaminophen_one_ingredient
#> 
#> ── 1 codelist with details ─────────────────────────────────────────────────────
#> 
#> - 161_acetaminophen (5 codes)

acetaminophen_one_ingredient[[1]] |> 
  glimpse()
#> Rows: 3
#> Columns: 5
#> $ concept_id       <int> 1125315, 1127078, 1127433
#> $ concept_name     <chr> "Acetaminophen", "Acetaminophen 160 MG Oral Tablet", …
#> $ domain_id        <chr> "Drug", "Drug", "Drug"
#> $ vocabulary_id    <chr> "RxNorm", "RxNorm", "RxNorm"
#> $ standard_concept <chr> "S", "S", "S"

Lastly, we could also restrict to a particular dose form. Let’s try to see if there are any injection dose form of acetaminophen.

acetaminophen_injections <- getDrugIngredientCodes(
  cdm = cdm,
  name = "acetaminophen",
  doseForm = "injection",
  type = "codelist_with_details"
)
#> Warning: No descendant codes found

acetaminophen_injections
#> list()

In this case we see that in Eunomia there no concept for acetaminophen with an injection dose form.

The previous examples have focused on single drug ingredient. We can though specify multiple ingredients, in which case we will get a codelist back for each.

acetaminophen_heparin_codes <- getDrugIngredientCodes(
  cdm = cdm,
  name = c("acetaminophen", "heparin")
  )

acetaminophen_heparin_codes
#> 
#> ── 2 codelists ─────────────────────────────────────────────────────────────────
#> 
#> - 161_acetaminophen (7 codes)
#> - 5224_heparin (1 codes)

And if we don´t specify an ingredient, we´ll get a codelist for every drug ingredient in the vocabularies.

ingredient_codes <- getDrugIngredientCodes(cdm = cdm)
ingredient_codes
#> 
#> ── 91 codelists ────────────────────────────────────────────────────────────────
#> 
#> - 26225_ondansetron (2 codes)
#> - 6754_meperidine (2 codes)
#> - 28889_loratadine (3 codes)
#> - 7052_morphine (2 codes)
#> - 1191_aspirin (2 codes)
#> - 7258_naproxen (3 codes)
#> - 140587_celecoxib (1 codes)
#> - 3289_dextromethorphan (2 codes)
#> - 3355_diclofenac (1 codes)
#> - 7804_oxycodone (2 codes)
#> along with 81 more codelists

Medication codelists based on ATC classifications

Analogous to getDrugIngredientCodes(), getATCCodes() can be used to generate a codelist based on a particular ATC class. To show this, we´ll use a the mock vocabulary from CodelistGenerator.

cdm_mock <- mockVocabRef()

In this example, we will produce an ATC level 1 codelist based on Alimentary Tract and Metabolism Drugs.

atc_codelist <- getATCCodes(
  cdm = cdm_mock,
  level = "ATC 1st",
  name = "alimentary tract and metabolism"
)

atc_codelist
#> 
#> ── 1 codelist ──────────────────────────────────────────────────────────────────
#> 
#> - 1234_alimentary_tract_and_metabolism (2 codes)

Condition Codelists using ICD10 chapters and subchapters

We can use getICD10StandardCodes() to generate condition codes based on ICD10 chapters and subchapters. As ICD10 is a non-standard vocabulary in the OMOP CDM this function returns standard concepts associated with these ICD10 chapters and subchapters directly via a mapping from them or indirectly from being a descendant concept of a code that is mapped from them. It is important to note that getICD10StandardCodes() will only return results if the ICD codes are included in the vocabulary tables.

For this example, we will try to generate a codelist for arthropathies.

arthropathy_codes <- getICD10StandardCodes(
  cdm = cdm_mock,
  name = "arthropathies"
)
arthropathy_codes
#> 
#> ── 1 codelist ──────────────────────────────────────────────────────────────────
#> 
#> - 1234_arthropathies (3 codes)
arthropathy_codes$arthropathies
#> NULL

As with the above functions, we could return concepts with their details rather than as a codelist.

arthropathy_codes <- getICD10StandardCodes(
  cdm = cdm_mock,
  name = "arthropathies", 
  type = "codelist_with_details"
)
arthropathy_codes
#> 
#> ── 1 codelist with details ─────────────────────────────────────────────────────
#> 
#> - 1234_arthropathies (6 codes)

arthropathy_codes[[1]]
#> # A tibble: 3 × 6
#>   name              concept_id concept_name domain_id vocabulary_id concept_code
#>   <chr>                  <int> <chr>        <chr>     <chr>         <chr>       
#> 1 1234_arthropathi…          3 Arthritis    Condition SNOMED        1234        
#> 2 1234_arthropathi…          4 Osteoarthri… Condition SNOMED        1234        
#> 3 1234_arthropathi…          5 Osteoarthri… Condition SNOMED        1234