### Example: Setting up CDM and running executeChecks Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/executeChecks.html Demonstrates how to connect to a database, create a CDMConnector object, and then use the executeChecks function with default parameters. This is a common starting point for data quality assessments. ```r if (FALSE) { # \dontrun{ db <- DBI::dbConnect(" Your database connection here ") cdm <- CDMConnector::cdmFromCon( con = db, cdmSchema = "cdm schema name" ) result <- executeChecks( cdm = cdm, ingredients = c(1125315) ) } # } ``` -------------------------------- ### Example of writeFile Usage Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/writeFile.html Demonstrates how to use the writeFile function with a list of data and specifies output parameters. This example is non-runnable and intended for illustration. ```r if (FALSE) { # \dontrun{ resultList <- list("mtcars" = mtcars) result <- writeZipToDisk( metadata = metadata, databaseId = "mtcars", outputFolder = here::here() ) } # } ``` -------------------------------- ### Example usage of runBenchmarkExecuteSingleIngredient Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/runBenchmarkExecuteSingleIngredient.html This example demonstrates how to use the `runBenchmarkExecuteSingleIngredient` function. It first creates a mock CDM object and then runs the benchmark, storing the results. ```r if (FALSE) { # \dontrun{ cdm <- mockDrugExposure() benchmarkResults <- runBenchmarkExecuteSingleIngredient(cdm) } # } ``` -------------------------------- ### Install DrugExposureDiagnostics Development Version Source: https://darwin-eu.github.io/DrugExposureDiagnostics/index.html Install the latest development version of the DrugExposureDiagnostics package from GitHub using the remotes package. ```r install.packages("remotes") remotes::install_github("darwin-eu/DrugExposureDiagnostics") ``` -------------------------------- ### Install DrugExposureDiagnostics from CRAN Source: https://darwin-eu.github.io/DrugExposureDiagnostics/index.html Use this command to install the stable version of the DrugExposureDiagnostics package from CRAN. ```r install.packages("DrugExposureDiagnostics") ``` -------------------------------- ### metaDataPanel$new() Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/metaDataPanel.html Initializes a new instance of the metaDataPanel class. This method handles the back-end setup for the metadata panel. ```APIDOC ## Method `new()` Method to handle the back-end. Initializer method ### Usage __``` metaDataPanel$new(data, id, title, description, downloadFilename) ``` ### Arguments `data` data from the `DrugExposureDiagnostics` package. `id` the unique reference id for the module `title` panel title `description` description of data table `downloadFilename` filename of the downloaded file `input` (`input`) Input from the server function. `output` (`output`) Output from the server function. `session` (`session`) Session from the server function. ### Returns (`NULL`) ``` -------------------------------- ### Initialize metaDataPanel Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/metaDataPanel.html Initializes a new instance of the metaDataPanel class. This method handles the back-end setup for the metadata panel, accepting data, module ID, title, description, and download filename as arguments. ```r metaDataPanel$new(data, id, title, description, downloadFilename) ``` -------------------------------- ### Connect to Database and Create CDM Object Source: https://darwin-eu.github.io/DrugExposureDiagnostics/index.html Demonstrates how to connect to a database using CDMConnector and create a CDM object. It highlights the importance of the 'bigint' parameter for preventing merge errors. An example using a mock database is also shown. ```r # conn <- DBI::dbConnect( # RPostgres::Postgres(), # dbname = dbname, # port = port, # host = host, # user = user, # password = password, # bigint = c("numeric") # ) # cdm <- CDMConnector::cdmFromCon( # con = conn, # cdmSchema = "cdm schema name" # ) cdm <- mockDrugExposure() ``` -------------------------------- ### Load DrugExposureDiagnostics Package Source: https://darwin-eu.github.io/DrugExposureDiagnostics/articles/IntroductionToDrugExposureDiagnostics.html Loads the DrugExposureDiagnostics R package. Ensure the package is installed before running. ```r library(DrugExposureDiagnostics) ``` -------------------------------- ### printDurationAndMessage() Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/index.html Prints the duration from start to now and displays it as a status message. ```APIDOC ## printDurationAndMessage() ### Description Print duration from start to now and print it as well as new status message ### Usage ```r printDurationAndMessage() ``` ``` -------------------------------- ### Initialize dataPlotPanel Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/dataPlotPanel.html Initializes a new instance of the dataPlotPanel class. This method handles the back-end setup for viewing and plotting diagnostic data. ```r dataPlotPanel$new( data, dataByConcept = NULL, id, title, description, plotPercentage, byConcept, downloadFilename, selectedColumns = colnames(data) ) ``` -------------------------------- ### printDurationAndMessage Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/printDurationAndMessage.html Prints the elapsed time since a start point and a given message. ```APIDOC ## printDurationAndMessage ### Description Prints the duration from a start time to the current time and displays a new status message. ### Usage ```R printDurationAndMessage(message, start) ``` ### Arguments * **message** (character) - The message to be printed. * **start** (POSIXct or similar) - The start time from which to calculate the duration. ``` -------------------------------- ### Execute Exposure Duration Check Source: https://darwin-eu.github.io/DrugExposureDiagnostics/articles/DrugDuration.html Loads the DrugExposureDiagnostics library and executes the 'exposureDuration' check using a mock CDM dataset. Ensure the DrugExposureDiagnostics library is installed and a CDM object is available. ```r library(DrugExposureDiagnostics) cdm <- mockDrugExposure() result <- executeChecks( cdm = cdm, checks = "exposureDuration" ) ``` -------------------------------- ### Get All Check Options Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/getAllCheckOptions.html Call this function to retrieve a list of all valid options for the 'checks' parameter. No arguments are required. ```r getAllCheckOptions() ``` -------------------------------- ### Get Drug Source Concepts Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/index.html Identifies and retrieves the source concepts for drug exposure records. ```r getDrugSourceConcepts() ``` -------------------------------- ### Print Duration and Message Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/printDurationAndMessage.html Calculates the time elapsed since a start time and prints it along with a provided message. This function is useful for tracking process durations and providing status updates. ```r printDurationAndMessage <- function(message, start) { # Calculate duration duration <- difftime(Sys.time(), start, units = "secs") # Print message and duration message(paste0(message, " (Duration: ", round(duration, 2), "s)")) # Return current time return(Sys.time()) } ``` -------------------------------- ### Get Drug Exposure Records Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/index.html Fetches drug exposure records for specified ingredients of interest. ```r getDrugRecords() ``` -------------------------------- ### Get Descendants for Ingredients Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/ingredientDescendantsInDb.html Retrieves descendant concepts for a given ingredient ID from a CDM database. Specify the drug exposure table and an optional prefix for permanent tables. Set verbose to TRUE for extra output. ```r ingredientDescendantsInDb( cdm, ingredient, drugRecordsTable = "drug_exposure", tablePrefix = NULL, verbose = FALSE ) ``` -------------------------------- ### Initialize ShinyModule Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/ShinyModule.html Use the initializer method to create a new instance of the ShinyModule class. ```r ShinyModule$new() ``` -------------------------------- ### Get Drug Types Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/index.html Retrieves the different types of drug exposure records. ```r getDrugTypes() ``` -------------------------------- ### writeFile Function Usage Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/writeFile.html Shows the basic usage of the writeFile function, including its arguments. ```r writeFile(result, resultName, databaseId, dbDir) ``` -------------------------------- ### Initialize ShinyApp Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/ShinyApp.html Initializes the ShinyApp with a list of check results and an optional database ID. ```R ShinyApp$new(resultList, database_id = NULL) ``` -------------------------------- ### Get Drug Routes Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/index.html Retrieves the different types of routes recorded for drug exposure. ```r getDrugRoutes() ``` -------------------------------- ### Launch Shiny App for Results Exploration Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/viewResults.html Launches a Shiny app to explore diagnostic results stored in zip files. Optional arguments control publishability and directory settings. ```r viewResults( dataFolder, makePublishable = FALSE, publishDir = file.path(getwd(), "ResultsExplorer"), overwritePublishDir = FALSE, launch.browser = FALSE ) ``` -------------------------------- ### Get Ingredient Descendants Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/index.html Retrieves descendant concepts for a given set of ingredients present in the database. ```r ingredientDescendantsInDb() ``` -------------------------------- ### Handle ShinyModule Server Logic Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/ShinyModule.html Implement the server method to manage the back-end logic of the Shiny module, including inputs, outputs, and session management. ```r ShinyModule$server(input, output, session) ``` -------------------------------- ### ShinyApp Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/index.html Launches the DrugExposureDiagnostics Shiny application. ```APIDOC ## ShinyApp ### Description DrugExposureDiagnostics ShinyApp ### Usage ```r ShinyApp() ``` ``` -------------------------------- ### runBenchmarkExecuteSingleIngredient() Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/index.html Runs a benchmark for the ExecuteSingleIngredient function. ```APIDOC ## runBenchmarkExecuteSingleIngredient() ### Description Run benchmark for ExecuteSingleIngredient ### Usage ```r runBenchmarkExecuteSingleIngredient() ``` ``` -------------------------------- ### Get Drug Missing Records Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/index.html Identifies and retrieves records with missing values in the drug exposure data. ```r getDrugMissings() ``` -------------------------------- ### dataPlotPanel$new() Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/dataPlotPanel.html Initializes a new instance of the dataPlotPanel class, handling the back-end logic for the module. ```APIDOC ## Method `new()` Method to handle the back-end. Initializer method ### Usage __``` dataPlotPanel$new( data, dataByConcept = NULL, id, title, description, plotPercentage, byConcept, downloadFilename, selectedColumns = colnames(data) ) ``` ### Arguments `data` data from the `DrugExposureDiagnostics` package. `dataByConcept` data by drug concept `id` the unique reference id for the module `title` panel title `description` description of data table `plotPercentage` if plot by percentage should be enabled `byConcept` add byConcept switch `downloadFilename` filename of the downloaded file `selectedColumns` default selected columns `input` (`input`) Input from the server function. `output` (`output`) Output from the server function. `session` (`session`) Session from the server function. ### Returns (`NULL`) ``` -------------------------------- ### Execute Quantity Check Source: https://darwin-eu.github.io/DrugExposureDiagnostics/articles/Quantity.html This snippet demonstrates how to execute the quantity check using the DrugExposureDiagnostics package. It requires a CDM object and specifies 'quantity' as the check to run. ```R library(DrugExposureDiagnostics) cdm <- mockDrugExposure() result <- executeChecks( cdm = cdm, checks = "quantity" ) ``` -------------------------------- ### Get Drug Records Function Signature Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/getDrugRecords.html This is the function signature for getDrugRecords. It outlines the parameters required to retrieve drug exposure data. ```R getDrugRecords( cdm, ingredient, includedConceptsTable, drugRecordsTable = "drug_exposure", exposureTypeId = NULL, tablePrefix = NULL, verbose = FALSE ) ``` -------------------------------- ### ShinyModule Class Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/ShinyModule.html Documentation for the ShinyModule class and its public methods. ```APIDOC ## Class ShinyModule Module Decorator Class ### Public methods * `ShinyModule$new()` * `ShinyModule$validate()` * `ShinyModule$UI()` * `ShinyModule$server()` * `ShinyModule$clone()` ### Method `new()` Initializer method #### Usage ``` ShinyModule$new() ``` #### Returns (`self`) ### Method `validate()` Validator method #### Usage ``` ShinyModule$validate() ``` #### Returns (`self`) ### Method `UI()` Method to include a tagList to include the body. #### Usage ``` ShinyModule$UI() ``` #### Returns (`tagList`) ### Method `server()` Method to handle the back-end. #### Usage ``` ShinyModule$server(input, output, session) ``` #### Arguments `input` (`input`) Input from the server function. `output` (`output`) Output from the server function. `session` (`session`) Session from the server function. #### Returns (`NULL`) ### Method `clone()` The objects of this class are cloneable with this method. #### Usage ``` ShinyModule$clone(deep = FALSE) ``` #### Arguments `deep` Whether to make a deep clone. ``` -------------------------------- ### Get UI Body for dataPlotPanel Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/dataPlotPanel.html Generates the UI component for the dataPlotPanel, typically used within a Shiny application's tab structure. ```r dataPlotPanel$uiBody() ``` -------------------------------- ### ShinyApp Function Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/index.html Launches the DrugExposureDiagnostics Shiny application. ```r ShinyApp() ``` -------------------------------- ### writeZipToDisk Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/writeZipToDisk.html Writes ingredient diagnostics results to disk in a given output folder. The results are compressed into a zip file. ```APIDOC ## Function: writeZipToDisk ### Description Writes ingredient diagnostics results to disk in a given output folder. The results are compressed into a zip file. ### Arguments * **metadata** (any) - Required - metadata results * **databaseId** (any) - Required - database identifier * **outputFolder** (any) - Required - folder to write to * **filename** (any) - Optional - output filename for the zip file ### Value No return value, called for side effects ### Examples ```R if (FALSE) { # \dontrun{ resultList <- list("mtcars" = mtcars) result <- writeZipToDisk( metadata = metadata, databaseId = "mtcars", outputFolder = here::here() ) } # } ``` ``` -------------------------------- ### Get Current R Memory Usage Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/mem_used.html This function wraps around `gc()` to return the total amount of memory (in megabytes) currently used by R. ```APIDOC ## mem_used() ### Description Returns the total amount of memory (in megabytes) currently used by R. ### Usage ``` mem_used() ``` ### Value Megabytes of ram used by R objects. ``` -------------------------------- ### checkDaysSupply Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/checkDaysSupply.html Checks if the 'days_supply' in drug records matches the difference between the start and end dates. It can perform this check by drug concept and allows for a specified sample size for the analysis. ```APIDOC ## Function: checkDaysSupply ### Description Checks if the `days_supply` in drug records matches the difference between the start and end dates. It can perform this check by drug concept and allows for a specified sample size for the analysis. ### Arguments * **cdm** (CDMConnector reference object) - Required - The CDMConnector reference object. * **drugRecordsTable** (string) - Optional - A modified version of the drug exposure table. Defaults to "ingredient_drug_records". * **byConcept** (boolean) - Optional - Whether to get the result by drug concept. Defaults to TRUE. * **sampleSize** (integer) - Optional - The sample size given in execute checks. Defaults to 10000. ### Value A table with the statistics of days supply compared to the start and end date. ``` -------------------------------- ### writeZipToDisk() Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/index.html Writes diagnostics results to a zip file on disk in the specified output folder. ```APIDOC ## writeZipToDisk() ### Description Write (ingredient) diagnostics results on disk in given output folder. ### Usage ```r writeZipToDisk() ``` ``` -------------------------------- ### Write Ingredient Results to Zip Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/index.html Saves diagnostic results for ingredients to a zip file in the specified output folder on disk. ```r writeZipToDisk() ``` -------------------------------- ### Get Drug Source Concepts Function Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/getDrugSourceConcepts.html This function retrieves drug source concepts from a CDMConnector object. Specify the drug exposure table and sample size as needed. ```r getDrugSourceConcepts( cdm, drugRecordsTable = "ingredient_drug_records", sampleSize = 10000 ) ``` -------------------------------- ### Execute All Drug Exposure Diagnostics Checks Source: https://darwin-eu.github.io/DrugExposureDiagnostics/articles/IntroductionToDrugExposureDiagnostics.html Runs all available diagnostic checks on drug exposures for specified ingredients. Results can be saved to disk by specifying 'outputFolder' and 'filename'. If 'outputFolder' is not provided, results are stored in memory. ```r all_checks <- executeChecks(cdm, ingredients = c(1125315), subsetToConceptId = NULL, checks = c( "missing", "exposureDuration", "type", "route", "sourceConcept", "daysSupply", "verbatimEndDate", "dose", "sig", "quantity", "daysBetween", "diagnosticsSummary" ), minCellCount = 5, sample = 10000, tablePrefix = NULL, earliestStartDate = "2010-01-01", verbose = FALSE, byConcept = TRUE, exposureTypeId = NULL, outputFolder = "output_folder", filename = "your_database" ) #> population after earliestStartDate smaller than sample, sampling ignored #> ℹ The following estimates will be calculated: #> • daily_dose: count_missing, percentage_missing, mean, sd, q05, q25, median, #> q75, q95, min, max #> ! Table is collected to memory as not all requested estimates are supported on #> the database side #> → Start summary of data, at 2026-06-19 10:01:44.160526 #> #> ✔ Summary finished, at 2026-06-19 10:01:44.583345 ``` -------------------------------- ### getAllCheckOptions() Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/index.html Retrieves all available options that can be passed to the 'checks' parameter. ```APIDOC ## getAllCheckOptions() ### Description Get all options that can be passed to the "checks" parameter ### Usage ```r getAllCheckOptions() ``` ``` -------------------------------- ### Summarize Daily Drug Dose Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/checkDrugDose.html Use this function to get a summary of the daily drug dose for a specific ingredient. You can control the maximum number of records to sample and the minimum cell count for reporting results. ```r checkDrugDose(cdm, ingredientConceptId, sampleSize = NULL, minCellCount = 5) ``` -------------------------------- ### Execute Diagnostic Checks Source: https://darwin-eu.github.io/DrugExposureDiagnostics/articles/DiagnosticsSummary.html This snippet demonstrates how to execute a series of diagnostic checks, including the diagnosticsSummary, using the executeChecks function. Ensure the cdm object is properly set up and the desired checks are specified. ```R library(DrugExposureDiagnostics) cdm <- mockDrugExposure() cetaminophen_checks <- executeChecks( cdm = cdm, checks = c("missing", "exposureDuration", "type", "route", "dose", "quantity", "diagnosticsSummary") ) ``` -------------------------------- ### Get Current R Memory Usage Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/mem_used.html This function wraps around gc() to return the total amount of memory (in megabytes) currently used by R. Use this to monitor R's memory consumption. ```R mem_used() ``` -------------------------------- ### Load Required R Libraries Source: https://darwin-eu.github.io/DrugExposureDiagnostics/index.html Loads the necessary libraries for using the DrugExposureDiagnostics package and its dependencies. ```r library(DrugExposureDiagnostics) library(CDMConnector) library(dplyr) ``` -------------------------------- ### Get Drug Exposure Record Types Function Signature Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/getDrugTypes.html This snippet shows the usage of the getDrugTypes function, including its parameters and their default values. It is used to query drug exposure record types from a CDM database. ```r getDrugTypes( cdm, drugRecordsTable = "ingredient_drug_records", byConcept = TRUE, sampleSize = 10000 ) ``` -------------------------------- ### writeFile() Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/index.html Writes a result to a file on disk. ```APIDOC ## writeFile() ### Description Write a result to a file on disk. ### Usage ```r writeFile() ``` ``` -------------------------------- ### Check Days Supply Function Signature Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/checkDaysSupply.html This function checks if the recorded days supply matches the calculated difference between drug exposure start and end dates. It can operate on a specified table and optionally group results by drug concept. ```r checkDaysSupply( cdm, drugRecordsTable = "ingredient_drug_records", byConcept = TRUE, sampleSize = 10000 ) ``` -------------------------------- ### writeIngredientResultToDisk() Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/index.html Writes ingredient diagnostics results to disk in the specified output folder. ```APIDOC ## writeIngredientResultToDisk() ### Description Write (ingredient) diagnostics results on disk in given output folder. ### Usage ```r writeIngredientResultToDisk() ``` ``` -------------------------------- ### runBenchmarkExecuteSingleIngredient Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/runBenchmarkExecuteSingleIngredient.html Runs a benchmark for the ExecuteSingleIngredient function, assessing time and memory usage for various analyses per ingredient. It accepts a CDMConnector object and configurable parameters for ingredients, checks, sampling, and data filtering. ```APIDOC ## Function: runBenchmarkExecuteSingleIngredient ### Description Runs a benchmark for the ExecuteSingleIngredient function, assessing time and memory usage for various analyses per ingredient. It accepts a CDMConnector object and configurable parameters for ingredients, checks, sampling, and data filtering. ### Arguments * **cdm** (CDMConnector reference object) - Required - The CDMConnector reference object. * **ingredients** (vector of integers, optional) - The concept IDs of the ingredients to benchmark. Defaults to `c(1125315)` (acetaminophen). * **subsetToConceptId** (vector of integers, optional) - A vector of concept IDs to filter the ingredients. Positive IDs are included, negative IDs are excluded. If NULL, all concept IDs for an ingredient are considered. * **checks** (vector of strings, optional) - The checks to be executed. Possible options include "missing", "exposureDuration", "type", "route", "sourceConcept", "daysSupply", "verbatimEndDate", "dose", "sig", "quantity", and "diagnosticsSummary". Defaults to `c("missing", "exposureDuration", "quantity")`. * **minCellCount** (integer, optional) - The minimum number of events required to report results. Results below this count will be obscured. If 0, all results are reported. Defaults to 5. * **sampleSize** (integer, optional) - The number of samples to use for the benchmark. Defaults to 10000. * **tablePrefix** (string, optional) - The stem for permanent tables created during diagnostics. If NULL, temporary tables are used. * **earliestStartDate** (string, optional) - The earliest date from which records can be included in the analysis (format: "YYYY-MM-DD"). Defaults to "2010-01-01". * **verbose** (boolean, optional) - If TRUE, provides verbose output during execution. Defaults to FALSE. * **byConcept** (boolean, optional) - If TRUE, returns results aggregated by concept ID. Defaults to FALSE. ### Value A tibble containing the time taken and memory usage for different analyses per ingredient. ### Examples ```R if (FALSE) { # \dontrun{ cdm <- mockDrugExposure() benchmarkResults <- runBenchmarkExecuteSingleIngredient(cdm) } } ``` ``` -------------------------------- ### Get Drug Exposure Route Types Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/getDrugRoutes.html Retrieves drug exposure route types from a CDMConnector reference object. Specify the drug records table and whether to group by concept. The sample size for executing checks can also be adjusted. ```r getDrugRoutes( cdm, drugRecordsTable = "ingredient_drug_records", byConcept = TRUE, sampleSize = 10000 ) ``` -------------------------------- ### Calculate Drug Exposure Duration Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/getDuration.html Computes the difference in days between two date columns in a database table and adds it as a new column. Specify the table name, start date column, end date column, and the name for the new duration column. ```r getDuration( cdm, tableName = "drug_exposure", startDateCol = "drug_exposure_start_date", endDateCol = "drug_exposure_end_date", colName = "duration" ) ``` -------------------------------- ### Generate ShinyModule UI Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/ShinyModule.html Use the UI method to generate the tagList for the module's user interface. ```r ShinyModule$UI() ``` -------------------------------- ### Run Drug Source Concept Check Source: https://darwin-eu.github.io/DrugExposureDiagnostics/articles/DrugSourceConcepts.html Execute the 'sourceConcept' check using the DrugExposureDiagnostics package. Requires a CDM object and specifies the checks to run. ```R library(DrugExposureDiagnostics) cdm <- mockDrugExposure() result <- executeChecks( cdm = cdm, checks = "sourceConcept" ) ``` -------------------------------- ### Get drug missings in drug exposure records Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/getDrugMissings.html Use this function to check for missing records in drug exposure data. It can summarize missingness by individual drug concept or across all records. Ensure you have a CDMConnector reference object and specify the drug records table if it differs from the default. ```r getDrugMissings( cdm, drugRecordsTable = "ingredient_drug_records", byConcept = TRUE, sampleSize = 10000 ) ``` -------------------------------- ### viewResults Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/viewResults.html Launches a Shiny app that allows the user to explore the diagnostics. The app can be used to interactively view results stored in a specified folder, with options to prepare the data for publishing. ```APIDOC ## viewResults ### Description Launches a Shiny app that allows the user to explore the diagnostics. The app can be used to interactively view results stored in a specified folder, with options to prepare the data for publishing. ### Usage ```R viewResults( dataFolder, makePublishable = FALSE, publishDir = file.path(getwd(), "ResultsExplorer"), overwritePublishDir = FALSE, launch.browser = FALSE ) ``` ### Arguments * **dataFolder** (string) - Required - A folder where the exported zip files with the results are stored. Zip files containing results from multiple databases can be placed in the same folder. * **makePublishable** (boolean) - Optional - Copy data files to make app publishable to posit connect/shinyapp.io. * **publishDir** (string) - Optional - If `makePublishable` is true, the directory that the Shiny app is copied to. * **overwritePublishDir** (boolean) - Optional - If `makePublishable` is true, overwrite the directory for publishing. * **launch.browser** (boolean) - Optional - Should the app be launched in your default browser, or in a Shiny window. Note: copying to clipboard will not work in a Shiny window. ``` -------------------------------- ### Run benchmark for ExecuteSingleIngredient Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/runBenchmarkExecuteSingleIngredient.html This function benchmarks the execution of single ingredient diagnostics. It takes a CDMConnector reference object and various parameters to control the benchmarking process, including which ingredients and checks to run, and data sampling options. ```r runBenchmarkExecuteSingleIngredient( cdm, ingredients = c(1125315), subsetToConceptId = NULL, checks = c("missing", "exposureDuration", "quantity"), minCellCount = 5, sampleSize = 10000, tablePrefix = NULL, earliestStartDate = "2010-01-01", verbose = FALSE, byConcept = FALSE ) ``` -------------------------------- ### writeIngredientResultToDisk Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/writeIngredientResultToDisk.html Writes ingredient diagnostics results to disk. ```APIDOC ## writeIngredientResultToDisk ### Description Write (ingredient) diagnostics results on disk in given output folder. ### Usage ```R writeIngredientResultToDisk( resultList, databaseId, outputFolder, clearDBDir = FALSE ) ``` ### Arguments * `resultList` (named list) - A named list containing the results. * `databaseId` (any) - The identifier for the database. * `outputFolder` (any) - The folder where the results should be written. * `clearDBDir` (logical) - If TRUE, the database directory will be cleared before writing. Defaults to FALSE. ### Value No return value, called for side effects. ### Examples ```R if (FALSE) { # \dontrun{ resultList <- list("mtcars" = mtcars) result <- writeIngredientResultToDisk( resultList = resultList, databaseId = "mtcars", outputFolder = here::here() ) } # } ``` ``` -------------------------------- ### ShinyModule Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/index.html Decorator class for Shiny modules. ```APIDOC ## ShinyModule ### Description Module Decorator Class ### Usage ```r ShinyModule ``` ``` -------------------------------- ### Benchmark Execute Single Ingredient Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/index.html Runs a performance benchmark for the 'ExecuteSingleIngredient' function. ```r runBenchmarkExecuteSingleIngredient() ``` -------------------------------- ### Apache License Boilerplate Source: https://darwin-eu.github.io/DrugExposureDiagnostics/LICENSE.html This is the standard boilerplate text to be included when applying the Apache License to your work. Replace bracketed information with your specific details. ```text Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ``` -------------------------------- ### Clone ShinyModule Instance Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/ShinyModule.html Utilize the clone method to create a copy of a ShinyModule object. Set `deep = TRUE` for a deep clone. ```r ShinyModule$clone(deep = FALSE) ``` -------------------------------- ### getAllCheckOptions Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/getAllCheckOptions.html This function retrieves all possible options that can be passed to the 'checks' parameter. It is a utility function to help users understand the available check types. ```APIDOC ## GET /getAllCheckOptions ### Description Retrieves all available options for the 'checks' parameter. ### Method GET ### Endpoint /getAllCheckOptions ### Parameters This endpoint does not accept any parameters. ### Response #### Success Response (200) - **options** (array) - A list of strings, where each string is a valid option for the 'checks' parameter. ### Response Example { "options": [ "check1", "check2", "check3" ] } ``` -------------------------------- ### metaDataPanel$clone() Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/metaDataPanel.html Creates a clone of the metaDataPanel object. This method allows for deep or shallow copying of the object. ```APIDOC ## Method `clone()` The objects of this class are cloneable with this method. ### Usage __``` metaDataPanel$clone(deep = FALSE) ``` ### Arguments `deep` Whether to make a deep clone. ``` -------------------------------- ### Mock Drug Exposure Data Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/index.html Generates mock drug exposure tables for specified ingredients. ```r mockDrugExposure() ``` -------------------------------- ### Run Drug Dose Check Source: https://darwin-eu.github.io/DrugExposureDiagnostics/articles/DrugDose.html Executes the 'dose' check using the DrugExposureDiagnostics package. Requires a CDM object and returns check results. ```r library(DrugExposureDiagnostics) cdm <- mockDrugExposure() acetaminophen_checks <- executeChecks( cdm = cdm, checks = "dose" ) ``` -------------------------------- ### ShinyModule Decorator Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/index.html A decorator class for creating Shiny modules within the package. ```r ShinyModule ``` -------------------------------- ### metaDataPanel$uiBody() Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/metaDataPanel.html Generates the UI body for the metadata panel, typically used within a tabPanel. ```APIDOC ## Method `uiBody()` Method to include a tabPanel to include the body. ### Usage __``` metaDataPanel$uiBody() ``` ### Returns (`tabItem`) ``` -------------------------------- ### Run Route Check Source: https://darwin-eu.github.io/DrugExposureDiagnostics/articles/Routes.html Executes the route check within the DrugExposureDiagnostics package. Ensure the CDM object is properly set up and the 'route' check is specified. ```R library(DrugExposureDiagnostics) cdm <- mockDrugExposure() result <- executeChecks( cdm = cdm, checks = "route" ) ``` -------------------------------- ### writeResultToDisk Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/writeResultToDisk.html Writes diagnostic results to a zip file on disk in the given output folder. ```APIDOC ## writeResultToDisk ### Description Writes diagnostic results to a zip file on disk in the given output folder. ### Usage ```R writeResultToDisk(resultList, databaseId, outputFolder, filename = NULL) ``` ### Arguments * `resultList` (named list) - A named list containing the results. * `databaseId` (character) - The identifier for the database. * `outputFolder` (character) - The folder where the zip file will be written. * `filename` (character, optional) - The desired output filename. If NULL, it defaults to the `databaseId`. ### Value No return value. The function is called for its side effects. ### Examples ```R if (FALSE) { # \dontrun{ resultList <- list("mtcars" = mtcars) result <- writeResultToDisk( resultList = resultList, databaseId = "mtcars", outputFolder = here::here() ) } # } ``` ``` -------------------------------- ### Check Days Supply Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/index.html Verifies if the 'Days_supply' column matches the difference between 'drug_exp_end_date' and 'drug_exp_start_date'. ```r checkDaysSupply() ``` -------------------------------- ### Check Database Type Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/index.html Determines the type of the connected database. ```r checkDbType() ``` -------------------------------- ### Display Quantity Results by Ingredient Source: https://darwin-eu.github.io/DrugExposureDiagnostics/articles/Quantity.html This snippet shows how to display the results of the quantity check, summarized at the ingredient level. The quantity field is crucial for understanding dispensed amounts, especially for non-quantified drugs. ```R DT::datatable(result$drugQuantity, rownames = FALSE ) ``` -------------------------------- ### Display Days Supply Summary by Ingredient Source: https://darwin-eu.github.io/DrugExposureDiagnostics/articles/DaysSupply.html Displays the days supply of drug records summarized at the ingredient level using an interactive data table. This table shows various quantiles and counts related to drug exposure duration. ```r DT::datatable(result$drugDaysSupply, rownames = FALSE ) ``` -------------------------------- ### Generate UI Body for metaDataPanel Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/metaDataPanel.html Generates the UI body for the metaDataPanel, which is typically included as a tabPanel. This method returns a tabItem object. ```r metaDataPanel$uiBody() ``` -------------------------------- ### dataPlotPanel$clone() Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/dataPlotPanel.html Creates a clone of the dataPlotPanel object. This method is inherited and allows for deep or shallow copying. ```APIDOC ## Method `clone()` The objects of this class are cloneable with this method. ### Usage __``` dataPlotPanel$clone(deep = FALSE) ``` ### Arguments `deep` Whether to make a deep clone. ``` -------------------------------- ### Compute Database Query Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/index.html Stores input data in a remote database table, either permanently or temporarily based on 'tablePrefix'. ```r computeDBQuery() ``` -------------------------------- ### Check Drug Dose Summary Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/index.html Provides a summary of the daily drug dosage. ```r checkDrugDose() ``` -------------------------------- ### checkDrugDose() Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/index.html Provides a summary of the daily drug dose. ```APIDOC ## checkDrugDose() ### Description Get a summary of the daily drug dose ### Usage ```r checkDrugDose() ``` ``` -------------------------------- ### Run Sig Checks Source: https://darwin-eu.github.io/DrugExposureDiagnostics/articles/DrugSig.html Execute the 'sig' check using the DrugExposureDiagnostics package. Requires a CDM object and specifies the checks to run. ```r library(DrugExposureDiagnostics) cdm <- mockDrugExposure() result <- executeChecks( cdm = cdm, checks = "sig" ) ``` -------------------------------- ### Run Missingness Check Source: https://darwin-eu.github.io/DrugExposureDiagnostics/articles/Missingness.html Executes a missingness check on the drug exposure data. Requires the DrugExposureDiagnostics library and a CDM object. ```R library(DrugExposureDiagnostics) cdm <- mockDrugExposure() result <- executeChecks( cdm = cdm, checks = "missing" ) ``` -------------------------------- ### Check Is Ingredient Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/index.html Determines if a given item is an ingredient. ```r checkIsIngredient() ``` -------------------------------- ### ingredientDescendantsInDb() Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/index.html Retrieves the descendants for the given ingredients from the database. ```APIDOC ## ingredientDescendantsInDb() ### Description Get the descendants for the given ingredients ### Usage ```r ingredientDescendantsInDb() ``` ``` -------------------------------- ### Write Ingredient Result to Disk Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/index.html Saves diagnostic results for a specific ingredient to disk within a designated output folder. ```r writeIngredientResultToDisk() ``` -------------------------------- ### summariseDrugExposureDuration() Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/index.html Summarizes the durations of drug exposure records. ```APIDOC ## summariseDrugExposureDuration() ### Description Summarise drug exposure record durations ### Usage ```r summariseDrugExposureDuration() ``` ``` -------------------------------- ### View Results in Shiny App and Prepare for Publishing Source: https://darwin-eu.github.io/DrugExposureDiagnostics/articles/IntroductionToDrugExposureDiagnostics.html This function displays diagnostic results in a Shiny application and can prepare them for publishing. Ensure the `dataFolder` points to the location where results were saved. ```r viewResults( dataFolder = file.path(getwd(), "output_folder"), makePublishable = TRUE, publishDir = file.path(getwd(), "MyStudyResultsExplorer"), overwritePublishDir = TRUE ) ``` -------------------------------- ### Execute Days Supply Check Source: https://darwin-eu.github.io/DrugExposureDiagnostics/articles/DaysSupply.html Runs the 'daysSupply' check using the DrugExposureDiagnostics package. Requires a CDM object and specifies the checks to execute. ```r library(DrugExposureDiagnostics) cdm <- mockDrugExposure() result <- executeChecks( cdm = cdm, checks = "daysSupply" ) ``` -------------------------------- ### metaDataPanel Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/index.html Panel for displaying metadata. ```APIDOC ## metaDataPanel ### Description metaDataPanel ### Usage ```r metaDataPanel ``` ``` -------------------------------- ### summariseQuantity() Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/index.html Summarizes the quantity column of the drug_exposure table. ```APIDOC ## summariseQuantity() ### Description Summarise the quantity column of the drug_exposure table ### Usage ```r summariseQuantity() ``` ``` -------------------------------- ### View Results in App Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/index.html Displays the diagnostic results within the Shiny application interface. ```r viewResults() ``` -------------------------------- ### checkDaysSupply() Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/index.html Checks if Days_supply is the same as datediff(drug_exp_start_date, drug_exp_end_date). ```APIDOC ## checkDaysSupply() ### Description Check if Days_supply is the same as datediff(drug_exp_start_date,drug_exp_end_date) ### Usage ```r checkDaysSupply() ``` ``` -------------------------------- ### Execute Diagnostic Checks Source: https://darwin-eu.github.io/DrugExposureDiagnostics/index.html Runs all available diagnostic checks in the DrugExposureDiagnostics package for a specified ingredient. The 'checks' argument allows for selecting specific diagnostics to run. ```r all_checks <- executeChecks( cdm = cdm, ingredients = 1125315, checks = c( "missing", "exposureDuration", "type", "route", "sourceConcept", "daysSupply", "verbatimEndDate", "dose", "sig", "quantity", "diagnosticsSummary" ) ) ``` -------------------------------- ### summariseChecks() Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/index.html Creates a summary of the diagnostics results. ```APIDOC ## summariseChecks() ### Description Create a summary about the diagnostics results ### Usage ```r summariseChecks() ``` ``` -------------------------------- ### Write Result to Zip File Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/index.html Saves diagnostic results to a zip file in the specified output folder on disk. ```r writeResultToDisk() ``` -------------------------------- ### mem_change() Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/index.html Determines the change in memory usage from running code. ```APIDOC ## mem_change() ### Description Determine change in memory from running code ### Usage ```r mem_change() ``` ``` -------------------------------- ### Inspect Output Structure Source: https://darwin-eu.github.io/DrugExposureDiagnostics/index.html Displays the names of all the tibbles contained within the output list generated by the executeChecks function. ```r names(all_checks) #> [1] "conceptSummary" "missingValuesOverall" #> [3] "missingValuesByConcept" "drugExposureDurationOverall" #> [5] "drugExposureDurationByConcept" "drugTypesOverall" #> [7] "drugTypesByConcept" "drugRoutesOverall" #> [9] "drugRoutesByConcept" "drugSourceConceptsOverall" #> [11] "drugDaysSupply" "drugDaysSupplyByConcept" #> [13] "drugVerbatimEndDate" "drugVerbatimEndDateByConcept" #> [15] "drugDose" "drugSig" #> [17] "drugSigByConcept" "drugQuantity" #> [19] "drugQuantityByConcept" "diagnosticsSummary" #> [21] "metadata" ``` -------------------------------- ### Display Drug Routes Overall Source: https://darwin-eu.github.io/DrugExposureDiagnostics/articles/Routes.html Visualizes the summarized routes of drug records at the ingredient level. This table helps understand the most common routes for each drug ingredient. ```R DT::datatable(result$drugRoutesOverall, rownames = FALSE ) ``` -------------------------------- ### mockDrugExposure() Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/index.html Mocks drug exposure tables for specified ingredients. ```APIDOC ## mockDrugExposure() ### Description Mock Drug exposure tables for ingredients of interest ### Usage ```r mockDrugExposure() ``` ``` -------------------------------- ### summariseTimeBetween() Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/index.html Checks the time between drug records per person and reports a summary. ```APIDOC ## summariseTimeBetween() ### Description Check time in between drug records per person and report the summary ### Usage ```r summariseTimeBetween() ``` ``` -------------------------------- ### Write Diagnostics Results to Zip File Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/writeZipToDisk.html Saves diagnostic results to a zip file in the specified output folder. Ensure the output folder exists before calling this function. The function does not return any value. ```R if (FALSE) { # \dontrun{ resultList <- list("mtcars" = mtcars) result <- writeZipToDisk( metadata = metadata, databaseId = "mtcars", outputFolder = here::here() ) } # } ``` -------------------------------- ### Pipe Operator Usage Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/pipe.html Demonstrates the basic syntax for using the pipe operator. It takes a value on the left-hand side (lhs) and passes it as an argument to a function call on the right-hand side (rhs). ```R lhs %>% rhs ``` -------------------------------- ### Execute Verbatim End Date Check Source: https://darwin-eu.github.io/DrugExposureDiagnostics/articles/VerbatimEndDate.html Run the verbatim end date check using the DrugExposureDiagnostics library. This check compares the verbatim end date from source data with the drug_exposure_end_date in the OMOP CDM. Ensure the CDM object is properly set up and the 'verbatimEndDate' check is specified. ```R library(DrugExposureDiagnostics) cdm <- mockDrugExposure() result <- executeChecks( cdm = cdm, checks = "verbatimEndDate" ) ``` -------------------------------- ### dataPlotPanel$uiBody() Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/dataPlotPanel.html Generates the UI body for the dataPlotPanel, typically included as a tabPanel. ```APIDOC ## Method `uiBody()` Method to include a tabPanel to include the body. ### Usage __``` dataPlotPanel$uiBody() ``` ### Returns (`tabItem`) ``` -------------------------------- ### Display Quantity Results by Concept Source: https://darwin-eu.github.io/DrugExposureDiagnostics/articles/Quantity.html This snippet displays the quantity check results summarized at the drug concept level. Similar to ingredient-level results, it aids in understanding dispensed quantities, with additional columns for drug concept ID and name. ```R DT::datatable(result$drugQuantityByConcept, rownames = FALSE) ``` -------------------------------- ### Save Diagnostic Results to Disk Source: https://darwin-eu.github.io/DrugExposureDiagnostics/articles/IntroductionToDrugExposureDiagnostics.html Use this function to write diagnostic outputs (CSV files) into a zip file. This is necessary when the `outputFolder` argument is not provided to `executeChecks`. The generated zip file is used as input for the Shiny Application. ```r writeResultToDisk( all_checks, databaseId = "your_database", outputFolder = "output_folder" ) ``` -------------------------------- ### Check Ingredient Presence Source: https://darwin-eu.github.io/DrugExposureDiagnostics/reference/index.html Verifies if a specified ingredient exists within a given table. ```r checkIngredientInTable() ``` -------------------------------- ### R Package Citation Source: https://darwin-eu.github.io/DrugExposureDiagnostics/authors.html This is the recommended citation format for the DrugExposureDiagnostics R package in R documentation. ```r @Manual{ title = {DrugExposureDiagnostics: Diagnostics for OMOP Common Data Model Drug Records}, author = {Ger Inberg and Edward Burn and Theresa Burkard}, year = {2026}, note = {R package version 1.1.8}, url = {https://darwin-eu.github.io/DrugExposureDiagnostics/}, } ```