darwin-eu / CodelistGenerator

Identifying relevant concepts from the OMOP CDM vocabularies
https://darwin-eu.github.io/CodelistGenerator/
Other
12 stars 8 forks source link

get drug ingredient descendants without combination concepts ids #106

Closed tiozab closed 8 months ago

tiozab commented 12 months ago

Is your feature request related to a problem? Please describe. Often we want to have pure medication concepts, however, using the ingredient descendants, this is not possible because the descendants include all children (also those that have multiple parents)

Describe the solution you'd like (https://forums.ohdsi.org/t/drug-ingredient-descendants-without-combination-concepts/20475)

Describe alternatives you've considered I went manually through and excluded descendants from ingredients that had combinations with the drug of interest, however this is prone to errors and includes a lot of manual work.

edward-burn commented 11 months ago

@tiozab this should now be possible with https://github.com/darwin-eu/CodelistGenerator/commit/a3bc823a250b0153b6e275851b04d56b754141d5

library(CDMConnector)
#> Warning: package 'CDMConnector' was built under R version 4.2.3
library(CodelistGenerator)

con <- DBI::dbConnect(duckdb::duckdb(), dbdir = eunomia_dir())
cdm <- cdm_from_con(con, cdm_schema = "main", write_schema = "main")
cdm
#> # OMOP CDM reference (tbl_duckdb_connection)
#> 
#> Tables: person, observation_period, visit_occurrence, visit_detail, condition_occurrence, drug_exposure, procedure_occurrence, device_exposure, measurement, observation, death, note, note_nlp, specimen, fact_relationship, location, care_site, provider, payer_plan_period, cost, drug_era, dose_era, condition_era, metadata, cdm_source, concept, vocabulary, domain, concept_class, concept_relationship, relationship, concept_synonym, concept_ancestor, source_to_concept_map, drug_strength

getDrugIngredientCodes(cdm = cdm, name = "acetaminophen",
                       ingredientRange = c(1,Inf), # no restriction
                       withConceptDetails = TRUE)
#> $acetaminophen
#> # A tibble: 7 × 4
#>   concept_id concept_name                                domain_id vocabulary_id
#>        <dbl> <chr>                                       <chr>     <chr>        
#> 1   19133768 Acetaminophen 750 MG / Hydrocodone Bitartr… Drug      RxNorm       
#> 2   40231925 Acetaminophen 325 MG / Oxycodone Hydrochlo… Drug      RxNorm       
#> 3   40229134 Acetaminophen 21.7 MG/ML / Dextromethorpha… Drug      RxNorm       
#> 4   40162522 Acetaminophen 325 MG / Hydrocodone Bitartr… Drug      RxNorm       
#> 5    1127078 Acetaminophen 160 MG Oral Tablet            Drug      RxNorm       
#> 6    1125315 Acetaminophen                               Drug      RxNorm       
#> 7    1127433 Acetaminophen 325 MG Oral Tablet            Drug      RxNorm

getDrugIngredientCodes(cdm = cdm, name = "acetaminophen",
                       ingredientRange = c(1,1),  # must only have 1 ingredient
                       withConceptDetails = TRUE)
#> $acetaminophen
#> # A tibble: 3 × 4
#>   concept_id concept_name                     domain_id vocabulary_id
#>        <dbl> <chr>                            <chr>     <chr>        
#> 1    1127078 Acetaminophen 160 MG Oral Tablet Drug      RxNorm       
#> 2    1125315 Acetaminophen                    Drug      RxNorm       
#> 3    1127433 Acetaminophen 325 MG Oral Tablet Drug      RxNorm

getDrugIngredientCodes(cdm = cdm, name = "acetaminophen",
                       ingredientRange = c(2,2), # must have 2 ingredients
                       withConceptDetails = TRUE)
#> $acetaminophen
#> # A tibble: 3 × 4
#>   concept_id concept_name                                domain_id vocabulary_id
#>        <dbl> <chr>                                       <chr>     <chr>        
#> 1   19133768 Acetaminophen 750 MG / Hydrocodone Bitartr… Drug      RxNorm       
#> 2   40231925 Acetaminophen 325 MG / Oxycodone Hydrochlo… Drug      RxNorm       
#> 3   40162522 Acetaminophen 325 MG / Hydrocodone Bitartr… Drug      RxNorm

getDrugIngredientCodes(cdm = cdm, name = "acetaminophen",
                       ingredientRange = c(3,3), # must have 3 ingredients
                       withConceptDetails = TRUE)
#> $acetaminophen
#> # A tibble: 1 × 4
#>   concept_id concept_name                                domain_id vocabulary_id
#>        <dbl> <chr>                                       <chr>     <chr>        
#> 1   40229134 Acetaminophen 21.7 MG/ML / Dextromethorpha… Drug      RxNorm

getDrugIngredientCodes(cdm = cdm, name = "acetaminophen",
                       ingredientRange = c(2,3), # must have 2 or 3 ingredients
                       withConceptDetails = TRUE)
#> $acetaminophen
#> # A tibble: 4 × 4
#>   concept_id concept_name                                domain_id vocabulary_id
#>        <dbl> <chr>                                       <chr>     <chr>        
#> 1   19133768 Acetaminophen 750 MG / Hydrocodone Bitartr… Drug      RxNorm       
#> 2   40231925 Acetaminophen 325 MG / Oxycodone Hydrochlo… Drug      RxNorm       
#> 3   40229134 Acetaminophen 21.7 MG/ML / Dextromethorpha… Drug      RxNorm       
#> 4   40162522 Acetaminophen 325 MG / Hydrocodone Bitartr… Drug      RxNorm

Created on 2023-11-25 with reprex v2.0.2

tiozab commented 11 months ago

Thanks, @edward-burn, I just checked this for myself and it solves the issue to have pure codelists of 1 ingredient. That is great. I do not see the purpose of having more than one, because the ingredients can vary so much. This would require a functionality to exactly search for concepts ids that have exactly those two ingredient specified for example. This is possible in Athena by putting the search term in quotes, so I used this functionality and downloaded the results

edward-burn commented 8 months ago

Closed as this is now implemented