The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

DrugExposureDiagnostics

CRAN status R-CMD-check

The goal of DrugExposureDiagnostics is to summarise ingredient specific drug exposure data in the OMOP CDM.

Installation

You can install the DrugExposureDiagnostics from CRAN like this:

install.packages("DrugExposureDiagnostics")

or install the development version:

install.packages("remotes")
remotes::install_github("darwin-eu/DrugExposureDiagnostics")

Setup

In order to use the example data from the eunomia dataset, you need to set an environment variable. You can do it like this:

Example use

library(DrugExposureDiagnostics)
library(CDMConnector)
library(dplyr)
cdm <- getEunomiaCdm()

Let´s look at the ingredient acetaminophen (https://athena.ohdsi.org/search-terms/terms/1125315).

We can run all the checks available in ´DrugExposureDiagnostics´ using the ´executeChecks´ function.

all_checks <- executeChecks(cdm = cdm, 
                            ingredients = 1125315, 
                            checks = c("missing", "exposureDuration", "type", "route", "sourceConcept", "daysSupply", "verbatimEndDate", 
                                       "dose", "sig", "quantity", "histogram", "diagnosticsSummary"))
#> population after earliestStartDate smaller than sample
#> Joining with `by = join_by(ingredient_concept_id)`
#> Joining with `by = join_by(ingredient_concept_id)`

The output is a list which contains the following set of tibbles:

names(all_checks)
#>  [1] "conceptSummary"                "missingValuesOverall"         
#>  [3] "missingValuesByConcept"        "drugExposureDurationOverall"  
#>  [5] "drugExposureDurationByConcept" "drugTypesOverall"             
#>  [7] "drugTypesByConcept"            "drugRoutesOverall"            
#>  [9] "drugRoutesByConcept"           "drugSourceConceptsOverall"    
#> [11] "drugSourceConceptsByConcept"   "drugDaysSupply"               
#> [13] "drugDaysSupplyByConcept"       "drugVerbatimEndDate"          
#> [15] "drugVerbatimEndDateByConcept"  "drugDose"                     
#> [17] "drugDoseByConcept"             "drugSig"                      
#> [19] "drugSigByConcept"              "drugQuantity"                 
#> [21] "drugQuantityByConcept"         "drugDaysSupplyHistogram"      
#> [23] "drugQuantityHistogram"         "drugDurationHistogram"        
#> [25] "diagnosticsSummary"

The first item contains information on the concept ids that are used in the database for a given ingredient.

glimpse(all_checks$conceptSummary)
#> Rows: 2
#> Columns: 26
#> Rowwise: 
#> $ drug_concept_id             <int> 40162522, 1127078
#> $ drug                        <chr> "Acetaminophen 325 MG / Hydrocodone Bitart…
#> $ ingredient_concept_id       <dbl> 1125315, 1125315
#> $ ingredient                  <chr> "Acetaminophen", "Acetaminophen"
#> $ n_records                   <int> 312, 2158
#> $ n_patients                  <int> 312, 1428
#> $ domain_id                   <chr> "Drug", "Drug"
#> $ vocabulary_id               <chr> "RxNorm", "RxNorm"
#> $ concept_class_id            <chr> "Clinical Drug", "Clinical Drug"
#> $ standard_concept            <chr> "S", "S"
#> $ concept_code                <chr> "857005", "282464"
#> $ valid_start_date            <date> 2009-08-02, 1970-01-01
#> $ valid_end_date              <date> 2099-12-31, 2099-12-31
#> $ invalid_reason              <chr> NA, NA
#> $ amount_value                <dbl> 1, 1
#> $ amount_unit_concept_id      <dbl> 1, 1
#> $ numerator_value             <dbl> 1, 1
#> $ numerator_unit_concept_id   <dbl> 1, 1
#> $ numerator_unit              <chr> NA, NA
#> $ denominator_value           <dbl> 1, 1
#> $ denominator_unit_concept_id <dbl> 1, 1
#> $ denominator_unit            <chr> NA, NA
#> $ box_size                    <int> NA, NA
#> $ amount_unit                 <chr> NA, NA
#> $ dose_form                   <chr> NA, NA
#> $ result_obscured             <lgl> FALSE, FALSE
all_checks$conceptSummary %>% 
  select("drug_concept_id", "drug")
#> # A tibble: 2 × 2
#> # Rowwise: 
#>   drug_concept_id drug                                                          
#>             <int> <chr>                                                         
#> 1        40162522 Acetaminophen 325 MG / Hydrocodone Bitartrate 7.5 MG Oral Tab…
#> 2         1127078 Acetaminophen 160 MG Oral Tablet

Other tibbles then contain information from the various checks performed.

For example, we can see a summary of missingness for the ingredient-related records in the drug exposure table, both overall and by concept.

all_checks$missingValuesOverall
#> # A tibble: 18 × 9
#> # Rowwise:  ingredient_concept_id, ingredient
#>    ingredient_concept_id ingredient    variable               n_records n_sample
#>                    <dbl> <chr>         <chr>                      <int>    <dbl>
#>  1               1125315 Acetaminophen n_missing_drug_exposu…        59    10000
#>  2               1125315 Acetaminophen n_missing_drug_exposu…        59    10000
#>  3               1125315 Acetaminophen n_missing_verbatim_en…        59    10000
#>  4               1125315 Acetaminophen n_missing_drug_type_c…        59    10000
#>  5               1125315 Acetaminophen n_missing_stop_reason         59    10000
#>  6               1125315 Acetaminophen n_missing_refills             59    10000
#>  7               1125315 Acetaminophen n_missing_quantity            59    10000
#>  8               1125315 Acetaminophen n_missing_days_supply         59    10000
#>  9               1125315 Acetaminophen n_missing_sig                 59    10000
#> 10               1125315 Acetaminophen n_missing_route_conce…        59    10000
#> 11               1125315 Acetaminophen n_missing_lot_number          59    10000
#> 12               1125315 Acetaminophen n_missing_provider_id         59    10000
#> 13               1125315 Acetaminophen n_missing_visit_occur…        59    10000
#> 14               1125315 Acetaminophen n_missing_visit_detai…        59    10000
#> 15               1125315 Acetaminophen n_missing_drug_source…        59    10000
#> 16               1125315 Acetaminophen n_missing_drug_source…        59    10000
#> 17               1125315 Acetaminophen n_missing_route_sourc…        59    10000
#> 18               1125315 Acetaminophen n_missing_dose_unit_s…        59    10000
#> # ℹ 4 more variables: n_records_not_missing_value <dbl>,
#> #   n_records_missing_value <dbl>, proportion_records_missing_value <dbl>,
#> #   result_obscured <lgl>
all_checks$missingValuesByConcept
#> # A tibble: 18 × 11
#> # Rowwise:  drug_concept_id, drug, ingredient_concept_id, ingredient
#>    drug_concept_id drug      ingredient_concept_id ingredient variable n_records
#>              <int> <chr>                     <dbl> <chr>      <chr>        <int>
#>  1        40162522 Acetamin…               1125315 Acetamino… n_missi…        59
#>  2        40162522 Acetamin…               1125315 Acetamino… n_missi…        59
#>  3        40162522 Acetamin…               1125315 Acetamino… n_missi…        59
#>  4        40162522 Acetamin…               1125315 Acetamino… n_missi…        59
#>  5        40162522 Acetamin…               1125315 Acetamino… n_missi…        59
#>  6        40162522 Acetamin…               1125315 Acetamino… n_missi…        59
#>  7        40162522 Acetamin…               1125315 Acetamino… n_missi…        59
#>  8        40162522 Acetamin…               1125315 Acetamino… n_missi…        59
#>  9        40162522 Acetamin…               1125315 Acetamino… n_missi…        59
#> 10        40162522 Acetamin…               1125315 Acetamino… n_missi…        59
#> 11        40162522 Acetamin…               1125315 Acetamino… n_missi…        59
#> 12        40162522 Acetamin…               1125315 Acetamino… n_missi…        59
#> 13        40162522 Acetamin…               1125315 Acetamino… n_missi…        59
#> 14        40162522 Acetamin…               1125315 Acetamino… n_missi…        59
#> 15        40162522 Acetamin…               1125315 Acetamino… n_missi…        59
#> 16        40162522 Acetamin…               1125315 Acetamino… n_missi…        59
#> 17        40162522 Acetamin…               1125315 Acetamino… n_missi…        59
#> 18        40162522 Acetamin…               1125315 Acetamino… n_missi…        59
#> # ℹ 5 more variables: n_sample <dbl>, n_records_not_missing_value <dbl>,
#> #   n_records_missing_value <dbl>, proportion_records_missing_value <dbl>,
#> #   result_obscured <lgl>

Or we can also see a summary of drug exposure duration (drug_exposure_end_date - drug_exposure_end_date + 1), again overall or by concept.

all_checks$drugExposureDurationOverall
#> # A tibble: 1 × 17
#> # Rowwise:  ingredient_concept_id
#>   ingredient_concept_id ingredient    n_records n_sample n_non_negative_days
#>                   <dbl> <chr>             <int>    <dbl>               <int>
#> 1               1125315 Acetaminophen        59    10000                  59
#> # ℹ 12 more variables: n_negative_days <int>, proportion_negative_days <dbl>,
#> #   minimum_drug_exposure_days <dbl>, q05_drug_exposure_days <dbl>,
#> #   q10_drug_exposure_days <dbl>, q25_drug_exposure_days <dbl>,
#> #   median_drug_exposure_days <dbl>, q75_drug_exposure_days <dbl>,
#> #   q90_drug_exposure_days <dbl>, q95_drug_exposure_days <dbl>,
#> #   maximum_drug_exposure_days <dbl>, result_obscured <lgl>
all_checks$drugExposureDurationByConcept
#> # A tibble: 1 × 19
#> # Rowwise:  drug_concept_id, drug, ingredient_concept_id
#>   drug_concept_id drug       ingredient_concept_id ingredient n_records n_sample
#>             <int> <chr>                      <dbl> <chr>          <int>    <dbl>
#> 1        40162522 Acetamino…               1125315 Acetamino…        59    10000
#> # ℹ 13 more variables: n_non_negative_days <int>, n_negative_days <int>,
#> #   proportion_negative_days <dbl>, minimum_drug_exposure_days <dbl>,
#> #   q05_drug_exposure_days <dbl>, q10_drug_exposure_days <dbl>,
#> #   q25_drug_exposure_days <dbl>, median_drug_exposure_days <dbl>,
#> #   q75_drug_exposure_days <dbl>, q90_drug_exposure_days <dbl>,
#> #   q95_drug_exposure_days <dbl>, maximum_drug_exposure_days <dbl>,
#> #   result_obscured <lgl>

For further information on the checks performed please see the package vignettes.

After running the checks we can write the CSVs to disk using the writeResultToDisk function.

writeResultToDisk(all_checks,
                  databaseId = "Synthea", 
                  outputFolder =tempdir())

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.