Skip to content

Commit

Permalink
comment out unnecessary tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mdlavallee92 committed May 16, 2024
1 parent df02197 commit bbbe860
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 76 deletions.
9 changes: 4 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ BugReports: https://github.com/OHDSI/Capr/issues/
Encoding: UTF-8
RoxygenNote: 7.3.1
Depends:
R (>= 3.5.0),
CirceR (>= 1.3.1)
R (>= 3.5.0)
Imports:
magrittr (>= 1.5.0),
jsonlite,
Expand All @@ -40,12 +39,12 @@ Imports:
DBI,
DatabaseConnector,
SqlRender,
generics
generics,
CirceR
Suggests:
testthat (>= 3.0.0),
knitr,
rmarkdown,
Eunomia
rmarkdown
VignetteBuilder: knitr
Config/testthat/edition: 3
Collate:
Expand Down
142 changes: 71 additions & 71 deletions tests/testthat/test-cohort.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ test_that("cohort entry works", {

})

test_that("getConceptSetDetails works on Eunomia", {
skip_if_not_installed("Eunomia")
gibleed <- cs(descendants(192671), name = "test")
connectionDetails <- Eunomia::getEunomiaConnectionDetails()
suppressMessages({
con <- DatabaseConnector::connect(connectionDetails)
})
suppressWarnings({ # DatabaseConnector will throw a warning when passing already translated SQL code to dbGetQuery
gibleed <- getConceptSetDetails(gibleed, con, vocabularyDatabaseSchema = "main")
})
expect_equal(gibleed@Expression[[1]]@Concept@concept_name, "Gastrointestinal hemorrhage")
DatabaseConnector::disconnect(con)
})
# test_that("getConceptSetDetails works on Eunomia", {
# skip_if_not_installed("Eunomia")
# gibleed <- cs(descendants(192671), name = "test")
# connectionDetails <- Eunomia::getEunomiaConnectionDetails()
# suppressMessages({
# con <- DatabaseConnector::connect(connectionDetails)
# })
# suppressWarnings({ # DatabaseConnector will throw a warning when passing already translated SQL code to dbGetQuery
# gibleed <- getConceptSetDetails(gibleed, con, vocabularyDatabaseSchema = "main")
# })
# expect_equal(gibleed@Expression[[1]]@Concept@concept_name, "Gastrointestinal hemorrhage")
# DatabaseConnector::disconnect(con)
# })


test_that("full cohort works", {
Expand Down Expand Up @@ -138,64 +138,64 @@ test_that("full cohort works without group", {
})


test_that("Capr cohort generates on synpuf", {
skip_if_not_installed("CirceR")
skip_if_not_installed("Eunomia")
# need simple cohort for synpuf
cd <- cohort(
entry = entry(
# observationWindow = continuousObservation(1, 0) # TODO this line causes an error.
drugExposure(cs(descendants(1118084), name = "celecoxib"), male()),
observationWindow = continuousObservation(365, 0)
)
)

cohortList <- toCirce(cd)
expect_type(cohortList, "list")

cohortJson <- jsonlite::toJSON(cohortList, pretty = T, auto_unbox = TRUE) %>%
as.character()

expect_type(cohortJson, "character")
expect_true(nchar(cohortJson) > 1)

sql <- CirceR::cohortExpressionFromJson(cohortJson) %>%
CirceR::buildCohortQuery(options = CirceR::createGenerateOptions(generateStats = TRUE))

expect_type(sql, "character")
expect_true(nchar(sql) > 1)

cohortsToCreate <- tibble::tibble(
cohortId = 999,
cohortName = "CaprTest",
sql = sql
)

connectionDetails <- Eunomia::getEunomiaConnectionDetails()
cohortTableNames <- CohortGenerator::getCohortTableNames("cohort")

invisible(capture_output(suppressMessages({
CohortGenerator::createCohortTables(connectionDetails,
cohortDatabaseSchema = "main",
cohortTableNames = cohortTableNames)


CohortGenerator::generateCohortSet(connectionDetails = connectionDetails,
cdmDatabaseSchema = "main" ,
cohortTableNames = cohortTableNames,
cohortDefinitionSet = cohortsToCreate,
incremental = FALSE)

df <- CohortGenerator::getCohortCounts(connectionDetails = connectionDetails,
cohortDatabaseSchema = "main",
cohortTable = "cohort",
cohortIds = c(999),
cohortDefinitionSet = cohortsToCreate)
})))

expect_true(df$cohortEntries > 1)

})
# test_that("Capr cohort generates on synpuf", {
# skip_if_not_installed("CirceR")
# skip_if_not_installed("Eunomia")
# # need simple cohort for synpuf
# cd <- cohort(
# entry = entry(
# # observationWindow = continuousObservation(1, 0) # TODO this line causes an error.
# drugExposure(cs(descendants(1118084), name = "celecoxib"), male()),
# observationWindow = continuousObservation(365, 0)
# )
# )
#
# cohortList <- toCirce(cd)
# expect_type(cohortList, "list")
#
# cohortJson <- jsonlite::toJSON(cohortList, pretty = T, auto_unbox = TRUE) %>%
# as.character()
#
# expect_type(cohortJson, "character")
# expect_true(nchar(cohortJson) > 1)
#
# sql <- CirceR::cohortExpressionFromJson(cohortJson) %>%
# CirceR::buildCohortQuery(options = CirceR::createGenerateOptions(generateStats = TRUE))
#
# expect_type(sql, "character")
# expect_true(nchar(sql) > 1)
#
# cohortsToCreate <- tibble::tibble(
# cohortId = 999,
# cohortName = "CaprTest",
# sql = sql
# )
#
# connectionDetails <- Eunomia::getEunomiaConnectionDetails()
# cohortTableNames <- CohortGenerator::getCohortTableNames("cohort")
#
# invisible(capture_output(suppressMessages({
# CohortGenerator::createCohortTables(connectionDetails,
# cohortDatabaseSchema = "main",
# cohortTableNames = cohortTableNames)
#
#
# CohortGenerator::generateCohortSet(connectionDetails = connectionDetails,
# cdmDatabaseSchema = "main" ,
# cohortTableNames = cohortTableNames,
# cohortDefinitionSet = cohortsToCreate,
# incremental = FALSE)
#
# df <- CohortGenerator::getCohortCounts(connectionDetails = connectionDetails,
# cohortDatabaseSchema = "main",
# cohortTable = "cohort",
# cohortIds = c(999),
# cohortDefinitionSet = cohortsToCreate)
# })))
#
# expect_true(df$cohortEntries > 1)
#
# })

test_that("compile generic works", {
ch <- cohort(conditionOccurrence(cs(1,2, name = "test")))
Expand Down

0 comments on commit bbbe860

Please sign in to comment.