Skip to content

Commit

Permalink
v1.0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
ginberg committed Sep 10, 2024
1 parent 3b3334e commit 8f7f3aa
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 24 deletions.
6 changes: 3 additions & 3 deletions CRAN-SUBMISSION
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Version: 1.0.4
Date: 2024-03-18 09:13:46 UTC
SHA: 5d055fdc24e44e04a2c42497b092dbff1cb9ade0
Version: 1.0.8
Date: 2024-09-10 07:20:12 UTC
SHA: 57b01591dca6ce7ff32929d541d6895f74e99688
5 changes: 2 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: DrugExposureDiagnostics
Title: Diagnostics for OMOP Common Data Model Drug Records
Version: 1.0.7
Version: 1.0.8
Authors@R: c(
person("Ger", "Inberg", email = "g.inberg@erasmusmc.nl", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-8993-8748")),
Expand All @@ -24,7 +24,7 @@ Description: Ingredient specific diagnostics for drug exposure records in the Ob
License: Apache License (>= 2)
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
Depends:
R (>= 4.0)
Imports:
Expand All @@ -51,7 +51,6 @@ Suggests:
DT,
graphics,
SqlRender,
PaRe,
magick,
DiagrammeRsvg,
ggplot2,
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# DrugExposureDiagnostics (development version)

# DrugExposureDiagnostics 1.0.8
* Skip unavailable concepts (#253 and #254)

# DrugExposureDiagnostics 1.0.7
* Updates related to newest release of DrugUtilisation

Expand Down
28 changes: 17 additions & 11 deletions R/executeChecks.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,24 @@ executeChecks <- function(cdm,
resultList <- vector(mode = "list", length = length(ingredients))
for (i in seq_along(ingredients)) {
ingredient <- ingredients[i]
resultList[[i]] <- executeChecksSingleIngredient(cdm = cdm,
ingredient = ingredient,
subsetToConceptId = subsetToConceptId,
checks = checks,
minCellCount = minCellCount,
sampleSize = sample,
tablePrefix = tablePrefix,
earliestStartDate = earliestStartDate,
verbose = verbose,
byConcept = byConcept)
ingredientResult <- NULL
tryCatch({
ingredientResult <- executeChecksSingleIngredient(cdm = cdm,
ingredient = ingredient,
subsetToConceptId = subsetToConceptId,
checks = checks,
minCellCount = minCellCount,
sampleSize = sample,
tablePrefix = tablePrefix,
earliestStartDate = earliestStartDate,
verbose = verbose,
byConcept = byConcept)
}, error = function(e) {
warning(e)
})
resultList[[i]] <- ingredientResult
}
resultList <- do.call(Map, c(f = rbind, resultList))
resultList <- do.call(Map, c(f = rbind, Filter(Negate(is.null), resultList)))
return(resultList)
}

Expand Down
1 change: 0 additions & 1 deletion R/ingredientDescendantsInDb.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ ingredientDescendantsInDb <- function(cdm,
messageStore = errorMessage
)
checkLogical(verbose, messageStore = errorMessage)
checkIsIngredient(cdm = cdm, conceptId = ingredient, messageStore = errorMessage)
checkIngredientInTable(cdm = cdm, conceptId = ingredient, tableName = "drug_strength", messageStore = errorMessage)
checkmate::reportAssertions(collection = errorMessage)

Expand Down
11 changes: 5 additions & 6 deletions R/mockDrugExposure.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ mockDrugExposure <- function(drug_exposure = NULL,
min_levels_of_separation <- as.integer(rep(0, each = 6))
max_levels_of_separation <- as.integer(rep(1, each = 6))


concept_ancestor <-
data.frame(
ancestor_concept_id = ancestor_concept_id ,
Expand Down Expand Up @@ -114,11 +113,11 @@ mockDrugExposure <- function(drug_exposure = NULL,
"Oral Tablet",
"METAMIZOLE"
) ,
domain_id = c(rep("Drug", 7),"Route","Type Concept",rep("Drug",2)),
vocabulary_id = c(rep("RxNorm", 7), "SNOMED","Drug Type","RxNorm","RxNormExtension"),
concept_class_id = c("Ingredient", rep("Clinical Drug", 6),"Qualifier Value","Drug Type","Dose Form","Ingredient"),
domain_id = c(rep("Drug", 7), "Route", "Type Concept", rep("Drug",2)),
vocabulary_id = c(rep("RxNorm", 7), "SNOMED", "Drug Type", "RxNorm", "RxNormExtension"),
concept_class_id = c("Ingredient", rep("Clinical Drug", 6), "Qualifier Value", "Drug Type", "Dose Form", "Ingredient"),
standard_concept = c(rep("S", 8), rep("Non-standard",2), "S"),
concept_code = c("161", "313782", "833036", "1049221", "1043400", "857005", "282464","26643006","OMOP4822241","421026006","OMOP5172468"),
concept_code = c("161", "313782", "833036", "1049221", "1043400", "857005", "282464", "26643006", "OMOP4822241", "421026006", "OMOP5172468"),
valid_start_date = c(rep(as.Date("1970-01-01"), 11)),
valid_end_date = c(rep(as.Date("2099-12-31"), 11)),
invalid_reason = as.character(c(rep(NA, 11)))
Expand All @@ -136,7 +135,7 @@ mockDrugExposure <- function(drug_exposure = NULL,
}

if (is.null(drug_strength)) {
ancestor_concept_id <- c(rep(1125315, 6),36854851)
ancestor_concept_id <- c(rep(1125315, 6), 36854851)
descendant_concept_id <-
c(40162522, 1127078, 1127433, 40229134, 40231925, 19133768,NA)

Expand Down
11 changes: 11 additions & 0 deletions tests/testthat/test-executeChecks.R
Original file line number Diff line number Diff line change
Expand Up @@ -259,3 +259,14 @@ test_that("empty drug_strength table gives an error", {
DBI::dbDisconnect(attr(cdm, "dbcon"), shutdown = TRUE)
})

test_that("results from multiple ingredients should be joined also if there is one in between that doesn't exist", {
cdm <- mockDrugExposure()

result <- executeChecks(cdm = cdm,
ingredients = c(1125315, 36854851, 1125315))
# should have 2 times result for 1125315
summary <- result$conceptSummary
expect_equal(nrow(summary), 12)

DBI::dbDisconnect(attr(cdm, "dbcon"), shutdown = TRUE)
})

0 comments on commit 8f7f3aa

Please sign in to comment.