For this vignette we are going to create codelists for identifying a acetaminophen, looking in the drug domain.
# postgres database connection details
<- Sys.getenv("server")
serverDbi <- Sys.getenv("user")
user <- Sys.getenv("password")
password <- Sys.getenv("port")
port <- Sys.getenv("host")
host
<- DBI::dbConnect(RPostgres::Postgres(),
db dbname = serverDbi,
port = port,
host = host,
user = user,
password = password
)
# name of vocabulary schema
<- "vocabulary" vocabularyDatabaseSchema
First we can follow the approach of identifying high-level codes and include all their descendants.
library(dplyr)
library(CodelistGenerator)
library(stringr)
library(DT)
library(kableExtra)
<- getCandidateCodes(
acetaminophen1 cdm = cdm,
keywords = "acetaminophen",
domains = "drug",
standardConcept = "standard",
includeDescendants = TRUE
)
%>% dplyr::glimpse()
acetaminophen1 #> Rows: 22,782
#> Columns: 15
#> $ concept_id <int> 587290, 587473, 587705, 587929, 588401, 58…
#> $ concept_name <chr> "Acetaminophen 0.0501 MG/MG / Antipyrine 0…
#> $ domain_id <chr> "drug", "drug", "drug", "drug", "drug", "d…
#> $ concept_class_id <chr> "clinical drug", "branded drug", "branded …
#> $ vocabulary_id <chr> "rxnorm extension", "rxnorm extension", "r…
#> $ found_from <chr> "From initial search", "From initial searc…
#> $ ingredient_concept_id <int> 1134439, 1134439, 1036059, 1135766, 113576…
#> $ amount_value <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
#> $ amount_unit_concept_id <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
#> $ numerator_value <dbl> 1.25e-02, 1.25e-02, 7.49e-02, 7.42e-03, 6.…
#> $ numerator_unit_concept_id <int> 8576, 8576, 8576, 8576, 8576, 8576, 8576, …
#> $ denominator_value <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
#> $ denominator_unit_concept_id <int> 8576, 8576, 8576, 8576, 8576, 8576, 8576, …
#> $ box_size <int> NA, NA, 100, 10, NA, 100, 5, NA, 5, 10, NA…
#> $ dose_form <chr> "Oral Solution", "Oral Solution", "Oral So…
We can also restrict on dose form, in this case requiring dose form to include either “injection” or “intravenous” in it’s name
<- getCandidateCodes(
acetaminophen2 cdm = cdm_arrow,
keywords = "acetaminophen",
domains = "drug",
doseForm = c("injection", "intravenous"),
standardConcept = "standard",
includeDescendants = TRUE,
verbose = TRUE
)
%>% dplyr::glimpse()
acetaminophen2 #> Rows: 127
#> Columns: 15
#> $ concept_id <int> 740261, 19112656, 21029938, 21049585, 2105…
#> $ concept_name <chr> "50 ML acetaminophen 10 MG/ML Injection", …
#> $ domain_id <chr> "drug", "drug", "drug", "drug", "drug", "d…
#> $ concept_class_id <chr> "quant clinical drug", "quant clinical dru…
#> $ vocabulary_id <chr> "rxnorm", "rxnorm", "rxnorm extension", "r…
#> $ found_from <chr> "From initial search", "From initial searc…
#> $ ingredient_concept_id <int> 1125315, 1125315, 1125315, 1125315, 112531…
#> $ amount_value <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
#> $ amount_unit_concept_id <int> NA, NA, NA, NA, NA, NA, NA, NA, 8576, NA, …
#> $ numerator_value <dbl> 500, 1000, 1000, 1000, 1000, 10, 1000, 100…
#> $ numerator_unit_concept_id <int> 8576, 8576, 8576, 8576, 8576, 8576, 8576, …
#> $ denominator_value <dbl> 50, 100, 100, 100, 100, NA, 100, 100, NA, …
#> $ denominator_unit_concept_id <int> 8587, 8587, 8587, 8587, 8587, 8587, 8587, …
#> $ box_size <int> NA, NA, 10, 12, 10, 12, NA, 12, NA, 10, 10…
#> $ dose_form <chr> "Injection", "Injection", "Injection", "In…
We can also restrict on concept class, in this case only identifying codes with a concept class of “Quant Clinical Drug”
<- getCandidateCodes(
acetaminophen3 cdm = cdm_arrow,
keywords = "acetaminophen",
domains = "drug",
conceptClassId = c("Quant Clinical Drug"),
doseForm = c("injection", "intravenous"),
standardConcept = "standard",
includeDescendants = TRUE,
verbose = TRUE
)
%>% dplyr::glimpse()
acetaminophen3 #> Rows: 5
#> Columns: 15
#> $ concept_id <int> 740261, 19112656, 36279869, 36778619, 3677…
#> $ concept_name <chr> "50 ML acetaminophen 10 MG/ML Injection", …
#> $ domain_id <chr> "drug", "drug", "drug", "drug", "drug"
#> $ concept_class_id <chr> "quant clinical drug", "quant clinical dru…
#> $ vocabulary_id <chr> "rxnorm", "rxnorm", "rxnorm extension", "r…
#> $ found_from <chr> "From initial search", "From initial searc…
#> $ ingredient_concept_id <int> 1125315, 1125315, 1125315, 1125315, 1125315
#> $ amount_value <dbl> NA, NA, NA, NA, NA
#> $ amount_unit_concept_id <int> NA, NA, NA, NA, NA
#> $ numerator_value <dbl> 500, 1000, 100, 1000, 500
#> $ numerator_unit_concept_id <int> 8576, 8576, 8576, 8576, 8576
#> $ denominator_value <dbl> 50, 100, 10, 100, 50
#> $ denominator_unit_concept_id <int> 8587, 8587, 8587, 8587, 8587
#> $ box_size <int> NA, NA, NA, NA, NA
#> $ dose_form <chr> "Injection", "Injection", "Intravenous Sol…