c(...) (`actual`) not equal to names(result[["metadata"]]) (`expected`).

actual[11:14] vs expected[11:15]
  "earliest_observation_period_start_date"
  "latest_observation_period_end_date"
  "snapshot_date"
- "package_version"
+ "cdm_data_hash"
+ "package_version"

# execute checks function with some defaults
checks = c("missing", "exposureDuration", "quantity"),
test_that("execute default checks, default ingredient, verbose", {
result <- executeChecksMock(cdm, verbose = TRUE)
"ingredient", "n_records", "n_patients", "domain_id", "vocabulary_id", "concept_class_id",
"standard_concept", "concept_code", "valid_start_date", "valid_end_date", "invalid_reason", "amount_value",
"amount_unit_concept_id", "numerator_value", "numerator_unit_concept_id", "numerator_unit", "denominator_value",
"denominator_unit_concept_id", "denominator_unit", "box_size", "amount_unit", "dose_form",
# check that all colnames don't have any uppercase characters (this might not be supported on some databases)
allColnames <- unlist(lapply(names(result), FUN = function(name) {
lapply(colnames(result[[name]]), FUN = function(colname) {
expect_true(all(unlist(lapply(allColnames, FUN = function(colName) {
DBI::dbDisconnect(attr(cdm, "dbcon"), shutdown = TRUE)
test_that("execute all checks, given ingredient", {
test_that("execute some checks, given ingredient", {
result <- executeChecksMock(cdm = cdm, ingredients = 1125315, checks = c("missing", "verbatimEndDate")) # acetaminophen
test_that("execute checks for given exposureTypeId", {
cdm <- mockDrugExposure(drug_exposure_size = 100)
expect_true(sum(allConcepts$n_records) > sum(prescriptionConcepts$n_records, na.rm = T))
expect_true(sum(allConcepts$n_patients) > sum(prescriptionConcepts$n_patients, na.rm = T))
test_that("execute checks: expected errors", {
expect_error(executeChecksMock(cdm = "a", ingredients = 1125315))
expect_error(executeChecksMock(cdm = cdm, ingredients = "a"))
expect_error(executeChecksMock(cdm, ingredients = 33)) # not an ingredient
expect_error(executeChecksMock(cdm = cdm, checks = "not valid"))
expect_error(executeChecksMock(cdm = cdm, checks = NA))
expect_error(executeChecksMock(cdm = cdm, checks = -1))
expect_error(executeChecksMock(cdm = cdm, checks = c("missing", "exposureDuration", "quantity", "not valid")))
concepts_db <- ingredientDescendantsInDb(cdm, 1125315) # acetaminophen
cdm[["ingredient_drug_records"]] <- getDrugRecords(cdm, 1125315, "ingredient_concepts")
getDrugMissings(cdm, "ingredient_drug_records", byConcept = TRUE)
getDrugMissings(cdm, "ingredient_drug_records", byConcept = FALSE)
getDrugTypes(cdm, "ingredient_drug_records", byConcept = TRUE)
getDrugTypes(cdm, "ingredient_drug_records", byConcept = FALSE)
getDrugRoutes(cdm, "ingredient_drug_records", byConcept = TRUE)
getDrugRoutes(cdm, "ingredient_drug_records", byConcept = FALSE)
summariseDrugExposureDuration(cdm, "ingredient_drug_records", byConcept = TRUE)
summariseDrugExposureDuration(cdm, "ingredient_drug_records", byConcept = FALSE)
# need to add checks for the above summaries .....
test_that("each check: expected errors", {
test_that("get number of Days_supply that are incorrect", {
cdm[["ingredient_concepts"]] <- ingredientDescendantsInDb(cdm, 1125315) # acetaminophen
result <- checkDaysSupply(cdm, drugRecordsTable = "ingredient_drug_records")
data <- cdm[["ingredient_drug_records"]] %>% dplyr::pull("drug_concept_id")
cdm = cdm, ingredients = 1125315, # acetaminophen
# sampling shouldn't affect ingredient concepts
# checks where sampling should have been implemented
expect_true(max(result$missingValuesOverall$n_records_missing_value, na.rm = TRUE) <= 50)
sample = 50, earliestStartDate = Sys.Date()
result <- executeChecksMock(cdm = cdm, ingredients = 1125315, checks = c(
"exposureDuration", "dose", "route", "quantity", "diagnosticsSummary"
test_that("subset on specific concepts", {
test_that("obscuring results by minCellCount", {
summary <- result_all$conceptSummary %>% dplyr::arrange(ingredient_concept_id, drug_concept_id)
expect_equal(summary$n_records, c(19, NA, 14, 18, NA, NA))
expect_equal(summary$n_patients, c(13, NA, 13, 15, NA, NA))
test_that("empty drug_strength table gives an error", {
test_that("results from multiple ingredients should be joined also if there is one in between that doesn't exist", {
# should have 2 times result for 1125315
test_that("sampleSize is null, no sampling must take place, all data from ingredient_drug_records must be used", {
checks = c("missing", "exposureDuration", "type", "route", "dose", "quantity", "diagnosticsSummary"),
if ("n_sample" %in% names(result[[colName]])) {
expect_equal(nSampleValues[i], expectedLength, info = paste("Issue in ", colName))
test_that("package version and name are included in the results", {