Title: | Diagnostics for OMOP Common Data Model Drug Records |
---|---|
Description: | Ingredient specific diagnostics for drug exposure records in the Observational Medical Outcomes Partnership (OMOP) common data model. |
Authors: | Ger Inberg [aut, cre] , Edward Burn [aut] , Theresa Burkard [aut] , Yuchen Guo [ctb] , Marti Catala [ctb] , Mike Du [ctb] , Xintong Li [ctb] , Ross Williams [ctb] , Erasmus MC [cph] |
Maintainer: | Ger Inberg <[email protected]> |
License: | Apache License (>= 2) |
Version: | 1.0.9 |
Built: | 2024-11-19 06:28:27 UTC |
Source: | https://github.com/darwin-eu/drugexposurediagnostics |
Check if Days_supply is the same as datediff(drug_exp_start_date,drug_exp_end_date)
checkDaysSupply( cdm, drugRecordsTable = "ingredient_drug_records", byConcept = TRUE, sampleSize = 10000 )
checkDaysSupply( cdm, drugRecordsTable = "ingredient_drug_records", byConcept = TRUE, sampleSize = 10000 )
cdm |
CDMConnector reference object |
drugRecordsTable |
a modified version of the drug exposure table, default "ingredient_drug_records" |
byConcept |
whether to get result by drug concept |
sampleSize |
the sample size given in execute checks |
a table with the stats of days supply compared to start and end date
Check the database type.
checkDbType(cdm, type = "cdm_reference", messageStore)
checkDbType(cdm, type = "cdm_reference", messageStore)
cdm |
CDMConnector reference object |
type |
type of the database, default cdm_reference |
messageStore |
checkmate collection |
Get a summary of the daily drug dose
checkDrugDose(cdm, ingredientConceptId, sampleSize = NULL, minCellCount = 5)
checkDrugDose(cdm, ingredientConceptId, sampleSize = NULL, minCellCount = 5)
cdm |
CDMConnector reference object |
ingredientConceptId |
ingredient |
sampleSize |
Maximum number of records of an ingredient to estimate dose
coverage. If an ingredient has more, a random sample equal to |
minCellCount |
minimum number of events to report- results lower than this will be obscured. If NULL all results will be reported. |
a table with the stats about the daily dose
Check the drug sig field; this is the verbatim instruction for the drug as written by the provider.
checkDrugSig( cdm, drugRecordsTable = "ingredient_drug_records", byConcept = TRUE, sampleSize = 10000 )
checkDrugSig( cdm, drugRecordsTable = "ingredient_drug_records", byConcept = TRUE, sampleSize = 10000 )
cdm |
CDMConnector reference object |
drugRecordsTable |
a modified version of the drug exposure table, default "ingredient_drug_records" |
byConcept |
whether to get result by drug concept |
sampleSize |
the sample size given in execute checks |
a table with a summary of the sig values
Check ingredient is present in given table
checkIngredientInTable(cdm, conceptId, tableName, messageStore)
checkIngredientInTable(cdm, conceptId, tableName, messageStore)
cdm |
CDMConnector reference object |
conceptId |
ingredient concept id to check |
tableName |
name of the table to check |
messageStore |
checkmate collection |
Check is an ingredient
checkIsIngredient(cdm, conceptId, messageStore)
checkIsIngredient(cdm, conceptId, messageStore)
cdm |
CDMConnector reference object |
conceptId |
ingredient concept id to check |
messageStore |
checkmate collection |
Check if given object is a boolean.
checkLogical(input, messageStore, null.ok = TRUE)
checkLogical(input, messageStore, null.ok = TRUE)
input |
the input |
messageStore |
checkmate collection |
null.ok |
if value null is allowed |
Check that the sample is bigger than the mincellcount
checkSampleMinCellCount(sampleSize, minCellCount, messageStore)
checkSampleMinCellCount(sampleSize, minCellCount, messageStore)
sampleSize |
sample size for sampling |
minCellCount |
minimum cell count below which to obsure results |
messageStore |
checkmate collection |
Check if given table exists in cdm.
checkTableExists(cdm, tableName, messageStore)
checkTableExists(cdm, tableName, messageStore)
cdm |
CDMConnector reference object |
tableName |
checkmate collection |
messageStore |
the message store |
Check the verbatim_end_date field
checkVerbatimEndDate( cdm, drugRecordsTable = "ingredient_drug_records", byConcept = TRUE, sampleSize = 10000 )
checkVerbatimEndDate( cdm, drugRecordsTable = "ingredient_drug_records", byConcept = TRUE, sampleSize = 10000 )
cdm |
CDMConnector reference object |
drugRecordsTable |
a modified version of the drug exposure table, default "ingredient_drug_records" |
byConcept |
whether to get result by drug concept |
sampleSize |
the sample size given in execute checks |
a table with the stats about the verbatim_end_date
Store the given input in a remote database table. It will be stored either in a permanent table or a temporary table depending on tablePrefix.
computeDBQuery(table, tablePrefix, tableName, cdm, overwrite = TRUE)
computeDBQuery(table, tablePrefix, tableName, cdm, overwrite = TRUE)
table |
the input table |
tablePrefix |
The stem for the permanent tables that will be created when running the diagnostics. Permanent tables will be created using this prefix, and any existing tables that start with this will be at risk of being dropped or overwritten. If NULL, temporary tables will be used throughout. |
tableName |
the input table |
cdm |
cdm reference object |
overwrite |
if the table should be overwritten (default TRUE). |
reference to the table
Execute given checks on Drug Exposure.
executeChecks( cdm, ingredients = c(1125315), subsetToConceptId = NULL, checks = c("missing", "exposureDuration", "quantity"), minCellCount = 5, sample = 10000, tablePrefix = NULL, earliestStartDate = "2010-01-01", verbose = FALSE, byConcept = TRUE )
executeChecks( cdm, ingredients = c(1125315), subsetToConceptId = NULL, checks = c("missing", "exposureDuration", "quantity"), minCellCount = 5, sample = 10000, tablePrefix = NULL, earliestStartDate = "2010-01-01", verbose = FALSE, byConcept = TRUE )
cdm |
CDMConnector reference object |
ingredients |
vector of ingredients, by default: acetaminophen |
subsetToConceptId |
vector of concept IDs of the ingredients to filter. If a concept ID is positive it will be included, a negative one will be excluded. If NULL, all concept IDs for an ingredient will be considered. |
checks |
the checks to be executed, by default the missing values, the exposure duration and the quantity. Possible options are "missing", "exposureDuration", "type", "route", "sourceConcept", "daysSupply", "verbatimEndDate", "dose", "sig", "quantity" and "diagnosticsSummary" |
minCellCount |
minimum number of events to report- results lower than this will be obscured. If 0 all results will be reported. |
sample |
the number of samples, default 10.000 |
tablePrefix |
The stem for the permanent tables that will be created when running the diagnostics. Permanent tables will be created using this prefix, and any existing tables that start with this will be at risk of being dropped or overwritten. If NULL, temporary tables will be used throughout. |
earliestStartDate |
the earliest date from which a record can be included |
verbose |
verbose, default FALSE |
byConcept |
boolean argument whether to return results by Concept or overall only |
named list with results
## Not run: db <- DBI::dbConnect(" Your database connection here ") cdm <- CDMConnector::cdm_from_con( con = db, cdm_schema = "cdm schema name" ) result <- executeChecks( cdm = cdm, ingredients = c(1125315)) ## End(Not run)
## Not run: db <- DBI::dbConnect(" Your database connection here ") cdm <- CDMConnector::cdm_from_con( con = db, cdm_schema = "cdm schema name" ) result <- executeChecks( cdm = cdm, ingredients = c(1125315)) ## End(Not run)
Execute given checks on Drug Exposure for a single ingredient.
executeChecksSingleIngredient( cdm, ingredient = 1125315, subsetToConceptId = NULL, checks = c("missing", "exposureDuration", "quantity"), minCellCount = 5, sampleSize = 10000, tablePrefix = NULL, earliestStartDate = "2010-01-01", verbose = FALSE, byConcept = FALSE )
executeChecksSingleIngredient( cdm, ingredient = 1125315, subsetToConceptId = NULL, checks = c("missing", "exposureDuration", "quantity"), minCellCount = 5, sampleSize = 10000, tablePrefix = NULL, earliestStartDate = "2010-01-01", verbose = FALSE, byConcept = FALSE )
cdm |
CDMConnector reference object |
ingredient |
ingredient, by default: acetaminophen |
subsetToConceptId |
vector of concept IDs of the ingredients to filter. If a concept ID is positive it will be included, a negative one will be excluded. If NULL, all concept IDs for an ingredient will be considered. |
checks |
the checks to be executed, by default the missing values, the exposure duration and the quantity. |
minCellCount |
minimum number of events to report- results lower than this will be obscured. If 0 all results will be reported. |
sampleSize |
the number of samples, default 10.000 |
tablePrefix |
The stem for the permanent tables that will be created when running the diagnostics. Permanent tables will be created using this prefix, and any existing tables that start with this will be at risk of being dropped or overwritten. If NULL, temporary tables will be used throughout. |
earliestStartDate |
the earliest date from which a record can be included |
verbose |
verbose, default FALSE |
byConcept |
boolean argument whether to return restults by Concept or overall only |
named list with results
Check missings in drug exposure records
getDrugMissings( cdm, drugRecordsTable = "ingredient_drug_records", byConcept = TRUE, sampleSize = 10000 )
getDrugMissings( cdm, drugRecordsTable = "ingredient_drug_records", byConcept = TRUE, sampleSize = 10000 )
cdm |
CDMConnector reference object |
drugRecordsTable |
a modified version of the drug exposure table, default "ingredient_drug_records" |
byConcept |
by individual drug Concept |
sampleSize |
the sample size given in execute checks |
a table with a summary of missing records
Drug exposure records for ingredients of interest
getDrugRecords( cdm, ingredient, includedConceptsTable, drugRecordsTable = "drug_exposure", tablePrefix = NULL, verbose = FALSE )
getDrugRecords( cdm, ingredient, includedConceptsTable, drugRecordsTable = "drug_exposure", tablePrefix = NULL, verbose = FALSE )
cdm |
CDMConnector reference object |
ingredient |
Concept ID for ingredient of interest |
includedConceptsTable |
includedConceptsTable |
drugRecordsTable |
drugRecordsTable, default "drug_exposure" |
tablePrefix |
The stem for the permanent tables that will be created when running the diagnostics. Permanent tables will be created using this prefix, and any existing tables that start with this will be at risk of being dropped or overwritten. If NULL, temporary tables will be used throughout. |
verbose |
verbose |
a table containing drug exposure records
Get drug exposure route types
getDrugRoutes( cdm, drugRecordsTable = "ingredient_drug_records", byConcept = TRUE, sampleSize = 10000 )
getDrugRoutes( cdm, drugRecordsTable = "ingredient_drug_records", byConcept = TRUE, sampleSize = 10000 )
cdm |
CDMConnector reference object |
drugRecordsTable |
a modified version of the drug exposure table, default "ingredient_drug_records" |
byConcept |
by individual drug Concept |
sampleSize |
the sample size given in execute checks |
a table with the drug exposure route types
Check drug exposure source types
getDrugSourceConcepts( cdm, drugRecordsTable = "ingredient_drug_records", sampleSize = 10000 )
getDrugSourceConcepts( cdm, drugRecordsTable = "ingredient_drug_records", sampleSize = 10000 )
cdm |
CDMConnector reference object |
drugRecordsTable |
modified drug exposure table |
sampleSize |
the sample size given in execute checks |
a table with the drug source concepts
Drug strength records for ingredients of interest
getDrugStrength( cdm, ingredient, includedConceptsTable = "ingredient_concepts", drugStrengthTable = "drug_strength", tablePrefix = NULL, verbose = FALSE )
getDrugStrength( cdm, ingredient, includedConceptsTable = "ingredient_concepts", drugStrengthTable = "drug_strength", tablePrefix = NULL, verbose = FALSE )
cdm |
CDMConnector reference object |
ingredient |
ingredient concept ID for ingredient of interest |
includedConceptsTable |
table name for the concept ids, names and units |
drugStrengthTable |
table name for drug strength, default "drug_strength" |
tablePrefix |
The stem for the permanent tables that will be created when running the diagnostics. Permanent tables will be created using this prefix, and any existing tables that start with this will be at risk of being dropped or overwritten. If NULL, temporary tables will be used throughout. |
verbose |
verbose |
a table containing drug strength records
Get drug exposure record types
getDrugTypes( cdm, drugRecordsTable = "ingredient_drug_records", byConcept = TRUE, sampleSize = 10000 )
getDrugTypes( cdm, drugRecordsTable = "ingredient_drug_records", byConcept = TRUE, sampleSize = 10000 )
cdm |
CDMConnector reference object |
drugRecordsTable |
a modified version of the drug exposure table, default "ingredient_drug_records" |
byConcept |
by individual drug Concept |
sampleSize |
the sample size given in execute checks |
a table with the drug exposure record types
Compute the difference in days between 2 variables in a database table.
getDuration( cdm, tableName = "drug_exposure", startDateCol = "drug_exposure_start_date", endDateCol = "drug_exposure_end_date", colName = "duration" )
getDuration( cdm, tableName = "drug_exposure", startDateCol = "drug_exposure_start_date", endDateCol = "drug_exposure_end_date", colName = "duration" )
cdm |
CDMConnector reference object |
tableName |
the table name |
startDateCol |
the start date column name |
endDateCol |
the end date column name |
colName |
the result column name |
the table with as new column the duration
Get the descendants for the given ingredients
ingredientDescendantsInDb( cdm, ingredient, drugRecordsTable = "drug_exposure", tablePrefix = NULL, verbose = FALSE )
ingredientDescendantsInDb( cdm, ingredient, drugRecordsTable = "drug_exposure", tablePrefix = NULL, verbose = FALSE )
cdm |
CDMConnector reference object |
ingredient |
ingredient concept id for ingredient of interest |
drugRecordsTable |
table name of the drug exposure records, default "drug_exposure" |
tablePrefix |
The stem for the permanent tables that will be created when running the diagnostics. Permanent tables will be created using this prefix, and any existing tables that start with this will be at risk of being dropped or overwritten. If NULL, temporary tables will be used throughout. |
verbose |
if verbose set to TRUE, the function will output extra messages |
temp table with concepts used
Mock Drug exposure tables for ingredients of interest
mockDrugExposure( drug_exposure = NULL, concept_ancestor = NULL, concept_relationship = NULL, concept = NULL, drug_strength = NULL, ingredient_drug_records = NULL, drug_exposure_size = 100, patient_size = 50, person = NULL, observation_period = NULL, amount_val = c(NA, 100, 200, 300), den_val = c(1, 10, 100), amount_unit = c(8587, 8576, 9655), num_unit = c(8587, 8576, 9655), denom_unit = c(8587, 8576, 8505), num_val = c(1, 2, 3), seed = 1 )
mockDrugExposure( drug_exposure = NULL, concept_ancestor = NULL, concept_relationship = NULL, concept = NULL, drug_strength = NULL, ingredient_drug_records = NULL, drug_exposure_size = 100, patient_size = 50, person = NULL, observation_period = NULL, amount_val = c(NA, 100, 200, 300), den_val = c(1, 10, 100), amount_unit = c(8587, 8576, 9655), num_unit = c(8587, 8576, 9655), denom_unit = c(8587, 8576, 8505), num_val = c(1, 2, 3), seed = 1 )
drug_exposure |
drug exposure table |
concept_ancestor |
concept_ancestor table |
concept_relationship |
concept_relationship table |
concept |
concept table |
drug_strength |
drug strength table |
ingredient_drug_records |
modified drug exposure table having drug name |
drug_exposure_size |
the sample size of the drug exposure table |
patient_size |
the number of unique patients in the drug exposure table |
person |
person table |
observation_period |
observation_period table |
amount_val |
vector of possible numeric amount value for the drug in the drug strength table |
den_val |
vector of possible numeric denominator value for the drug in drug strength table |
amount_unit |
vector of possible amount unit type drug strength table representing milligram, milliliter and microgram |
num_unit |
vector of possible numerator unit type drug strength table representing milligram, milliliter and microgram |
denom_unit |
vector of possible numerator unit type drug strength table representing milligram, milliliter and hour |
num_val |
vector of possible numeric numerator denominator value drug strength table |
seed |
seed to make results reproducible |
CDMConnector CDM reference object to duckdb database with mock data include concept_ancestor, concept, drug_strength, drug_exposure tables
Obscure the small number of counts
obscureCounts(table, tableName, minCellCount = 5, substitute = NA)
obscureCounts(table, tableName, minCellCount = 5, substitute = NA)
table |
the table as a tibble |
tableName |
the table name |
minCellCount |
the minimum number of counts that will be displayed. If 0 all results will be reported. |
substitute |
the substitute value if values will be obscured |
the input table with results obscured if minCellCount applies
Print duration from start to now and print it as well as new status message
printDurationAndMessage(message, start)
printDurationAndMessage(message, start)
message |
the message |
start |
the start time |
the current time
Create a summary about the diagnostics results
summariseChecks(resultList)
summariseChecks(resultList)
resultList |
a list with the diagnostics results |
a table containing the diagnostics summary
Summarise drug exposure record durations
summariseDrugExposureDuration( cdm, drugRecordsTable = "ingredient_drug_records", byConcept = TRUE, sampleSize = 10000 )
summariseDrugExposureDuration( cdm, drugRecordsTable = "ingredient_drug_records", byConcept = TRUE, sampleSize = 10000 )
cdm |
CDMConnector reference object |
drugRecordsTable |
a modified version of the drug exposure table, default "ingredient_drug_records" |
byConcept |
by individual drug Concept |
sampleSize |
the sample size given in execute checks |
a table with the drug exposure record durations
Summarise the quantity column of the drug_exposure table
summariseQuantity( cdm, drugRecordsTable = "ingredient_drug_records", byConcept = TRUE, sampleSize = sampleSize )
summariseQuantity( cdm, drugRecordsTable = "ingredient_drug_records", byConcept = TRUE, sampleSize = sampleSize )
cdm |
CDMConnector reference object |
drugRecordsTable |
a modified version of the drug exposure table, default "ingredient_drug_records" |
byConcept |
whether to get result by drug concept |
sampleSize |
the sample size given in execute checks |
a table with the summarized quantity result
View the results in the Shiny app
viewResults( dataFolder, makePublishable = FALSE, publishDir = file.path(getwd(), "ResultsExplorer"), overwritePublishDir = FALSE, launch.browser = FALSE )
viewResults( dataFolder, makePublishable = FALSE, publishDir = file.path(getwd(), "ResultsExplorer"), overwritePublishDir = FALSE, launch.browser = FALSE )
dataFolder |
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 |
(Optional) copy data files to make app publishable to posit connect/shinyapp.io |
publishDir |
If make publishable is true - the directory that the shiny app is copied to |
overwritePublishDir |
(Optional) If make publishable is true - overwrite the directory for publishing |
launch.browser |
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. |
Launches a Shiny app that allows the user to explore the diagnostics
Write diagnostics results to a zip file on disk in given output folder.
writeResultToDisk(resultList, databaseId, outputFolder, filename = NULL)
writeResultToDisk(resultList, databaseId, outputFolder, filename = NULL)
resultList |
named list with results |
databaseId |
database identifier |
outputFolder |
folder to write to |
filename |
output filename, if NULL it will be equal to databaseId |
No return value, called for side effects
## Not run: resultList <- list("mtcars" = mtcars) result <- writeResultToDisk( resultList = resultList, databaseId = "mtcars", outputFolder = here::here()) ## End(Not run)
## Not run: resultList <- list("mtcars" = mtcars) result <- writeResultToDisk( resultList = resultList, databaseId = "mtcars", outputFolder = here::here()) ## End(Not run)