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 we can specify “injection” or “intravenous” either in the keywords or by using the dose form option.
<- getCandidateCodes(
acetaminophen2a cdm = cdm,
keywords = c(
"acetaminophen injection",
"acetaminophen intravenous"
),domains = "drug",
standardConcept = "standard",
includeDescendants = TRUE,
verbose = TRUE
)
<- getCandidateCodes(
acetaminophen2b cdm = cdm,
keywords = "acetaminophen",
domains = "drug",
doseForm = c("injection", "intravenous"),
standardConcept = "standard",
includeDescendants = TRUE,
verbose = TRUE
)
%>% dplyr::glimpse()
acetaminophen2a #> 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…
%>% dplyr::glimpse()
acetaminophen2b #> 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…
In this case the two searches return the same result.
compareCodelists(acetaminophen2a, acetaminophen2b) %>%
group_by(codelist) %>%
tally()
#> # A tibble: 1 × 2
#> codelist n
#> <chr> <int>
#> 1 Both 127
We can see all the dose forms that could be specified like so
getDoseForm(cdm = cdm)
#> [1] "Prefilled Syringe"
#> [2] "Injectable Solution"
#> [3] "Oral Tablet"
#> [4] "Oral Solution"
#> [5] "Oral Capsule"
#> [6] "Injection"
#> [7] "Powder Spray"
#> [8] "Inhalation Solution"
#> [9] "Oral Powder"
#> [10] "Topical Ointment"
#> [11] "Oral Granules"
#> [12] "Transdermal System"
#> [13] "Topical Gel"
#> [14] "Topical Cream"
#> [15] "Extended Release Oral Tablet"
#> [16] "Topical Solution"
#> [17] "Extended Release Oral Capsule"
#> [18] "Ophthalmic Solution"
#> [19] "Topical Lotion"
#> [20] "Oral Suspension"
#> [21] "Inhalation Powder"
#> [22] "Nasal Solution"
#> [23] "Delayed Release Oral Tablet"
#> [24] "Oral Ointment"
#> [25] "Wound Cones"
#> [26] "Injectable Suspension"
#> [27] "Granules for Oral Suspension"
#> [28] "Toothpaste"
#> [29] "Pack"
#> [30] "Rectal Gel"
#> [31] "Chewing Gum"
#> [32] "Rectal Ointment"
#> [33] "Rectal Powder"
#> [34] "Inhalation Spray"
#> [35] "Tablet for Oral Suspension"
#> [36] "Vaginal Film"
#> [37] "Mucosal Spray"
#> [38] "Nasal Powder"
#> [39] "Otic Suspension"
#> [40] "Intratracheal Suspension"
#> [41] "Delayed Release Oral Capsule"
#> [42] "Paste"
#> [43] "Sublingual Film"
#> [44] "Intravenous Solution"
#> [45] "Intrathecal Suspension"
#> [46] "Intramuscular Prolonged Release Suspension"
#> [47] "Intravenous Suspension"
#> [48] "Vaginal Spray"
#> [49] "Prefilled Applicator"
#> [50] "Inhalant"
#> [51] "Intrauterine Drug Delivery System"
#> [52] "Sustained Release Buccal Tablet"
#> [53] "Otic Ointment"
#> [54] "Vaginal Ointment"
#> [55] "Augmented Topical Gel"
#> [56] "Augmented Topical Lotion"
#> [57] "Augmented Topical Ointment"
#> [58] "Intraperitoneal Solution"
#> [59] "Impregnated cigarette"
#> [60] "Nasal Metered-Dose Aerosol"
#> [61] "Powder for Nasal Solution"
#> [62] "Collodion"
#> [63] "Dental Pin"
#> [64] "Chewable Bar"
#> [65] "Medicated Gauzeball"
#> [66] "Dressing Gauze"
#> [67] "Topical Cake"
#> [68] "Oral Tablet with Sensor"
#> [69] "Powder for Pyelocalyceal Solution"
#> [70] "Vaginal Sponge"
#> [71] "Enema"
#> [72] "Disintegrating Oral Tablet"
#> [73] "Topical Spray"
#> [74] "Ophthalmic Ointment"
#> [75] "Buccal Film"
#> [76] "Powder for Oral Solution"
#> [77] "Sublingual Tablet"
#> [78] "Oral Spray"
#> [79] "Mouthwash"
#> [80] "Oral Strip"
#> [81] "Oral Film"
#> [82] "Auto-Injector"
#> [83] "Vaginal Cream"
#> [84] "Granules for Oral Solution"
#> [85] "Vaginal Gel"
#> [86] "Topical Suspension"
#> [87] "Effervescent Oral Tablet"
#> [88] "Oral Cream"
#> [89] "Topical Foam"
#> [90] "Rectal Solution"
#> [91] "Nasal Ointment"
#> [92] "Rectal Cream"
#> [93] "Nasal Inhaler"
#> [94] "Vaginal Insert"
#> [95] "Kit for radiopharmaceutical preparation"
#> [96] "Metered Dose Nasal Spray"
#> [97] "Delayed Release Oral Granules"
#> [98] "Oral Flakes"
#> [99] "Powder"
#> [100] "Unknown Combination Pack Medical Aids"
#> [101] "Medicated nail lacquer"
#> [102] "Shower Powder"
#> [103] "Intravitreal Applicator"
#> [104] "Nasal Pin"
#> [105] "Nasal Metered-Dose Pump"
#> [106] "Tablet for Opthalmic Solution"
#> [107] "Vaginal Powder"
#> [108] "Nasal Aerosol, Metered Dose"
#> [109] "Nasal Spray"
#> [110] "Oral Gel"
#> [111] "Vaginal Ring"
#> [112] "Oral Paste"
#> [113] "Medicated Patch"
#> [114] "Oral Lozenge"
#> [115] "Chewable Tablet"
#> [116] "Metered Dose Inhaler"
#> [117] "Mucous Membrane Topical Solution"
#> [118] "Vaginal System"
#> [119] "Urethral Gel"
#> [120] "Dry Powder Inhaler"
#> [121] "Ophthalmic Gel"
#> [122] "Rectal Foam"
#> [123] "Cartridge"
#> [124] "Medicated Shampoo"
#> [125] "Medicated Liquid Soap"
#> [126] "Stick"
#> [127] "Irrigation Solution"
#> [128] "Oral Granules (Effervescents)"
#> [129] "Oral Pellet"
#> [130] "Nasal Suspension"
#> [131] "Intrauterine System"
#> [132] "Vaginal Foam"
#> [133] "Nasal Gel"
#> [134] "Douche"
#> [135] "Jet Injector"
#> [136] "Rectal Spray"
#> [137] "Oil"
#> [138] "Bar Soap"
#> [139] "Bath Salts"
#> [140] "Variable Drug Form"
#> [141] "Oral Gas"
#> [142] "Medicated Tape"
#> [143] "Inhalation Suspension"
#> [144] "Powder for Oral Suspension"
#> [145] "Rectal Suppository"
#> [146] "Topical Powder"
#> [147] "Otic Solution"
#> [148] "Gas for Inhalation"
#> [149] "Ophthalmic Irrigation Solution"
#> [150] "Buccal Tablet"
#> [151] "Topical Oil"
#> [152] "Ophthalmic Suspension"
#> [153] "Medicated Bar Soap"
#> [154] "Drug Implant"
#> [155] "Medicated Pad"
#> [156] "Extended Release Suspension"
#> [157] "Medicated Nail Polish"
#> [158] "Vaginal Suppository"
#> [159] "Pen Injector"
#> [160] "Chewable Extended Release Oral Tablet"
#> [161] "Ophthalmic Cream"
#> [162] "Paint"
#> [163] "Vaginal Tablet"
#> [164] "Vaginal delivery system"
#> [165] "Intramuscular Solution"
#> [166] "Rectal Suspension"
#> [167] "Suspension"
#> [168] "Nasal Inhalant"
#> [169] "Urethral Suppository"
#> [170] "Oral Wafer"
#> [171] "Oral Foam"
#> [172] "Augmented Topical Cream"
#> [173] "Sublingual Powder"
#> [174] "Cement"
#> [175] "Nasal Cream"
#> [176] "Injectable Foam"
#> [177] "Subcutaneous Gel"
#> [178] "Vaginal Mechanical Pessaries with Substance"
#> [179] "Medicated Swab"
#> [180] "Medicated Cottonball"
#> [181] "Medicated Guaze"
#> [182] "Soft Tissue Injection Suspension"
#> [183] "Poultice"
#> [184] "Topical Liquefied Gas"
#> [185] "Subcutaneous Powder"
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,
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…
We can see all the concept classes for drugs like so
getConceptClassId(cdm = cdm, domain = "drug")
#> [1] "Ingredient" "Clinical Drug Comp" "Clinical Drug"
#> [4] "Quant Branded Drug" "Quant Clinical Drug" "Branded Drug"
#> [7] "Marketed Product" "Branded Drug Box" "Branded Drug Comp"
#> [10] "Quant Clinical Box" "Clinical Drug Box" "Clinical Drug Form"
#> [13] "Quant Branded Box" "Branded Drug Form" "Branded Pack"
#> [16] "Clinical Pack" "Branded Pack Box" "Clinical Pack Box"
#> [19] "HCPCS"