From abae4f11b4cda7b78e21841e944937e1b6e4ddc9 Mon Sep 17 00:00:00 2001 From: Adam Black Date: Thu, 19 Sep 2024 13:47:36 +0200 Subject: [PATCH] update documentation. Only download gibleed eunomia dataset if it does not already exist. Skip results datamode test if SKIP_DB_TESTS is TRUE. --- man/createConceptCountsTable.Rd | 30 +++++++++++++++++------- man/executeDiagnostics.Rd | 13 +++++----- tests/testthat/setup.R | 5 ++-- tests/testthat/test-1-ResultsDataModel.R | 3 ++- 4 files changed, 33 insertions(+), 18 deletions(-) diff --git a/man/createConceptCountsTable.Rd b/man/createConceptCountsTable.Rd index b5f59a084..bc0bbec9c 100644 --- a/man/createConceptCountsTable.Rd +++ b/man/createConceptCountsTable.Rd @@ -9,29 +9,43 @@ createConceptCountsTable( connection = NULL, cdmDatabaseSchema, tempEmulationSchema = NULL, - conceptCountsDatabaseSchema = cdmDatabaseSchema, conceptCountsTable = "concept_counts", + conceptCountsDatabaseSchema = cdmDatabaseSchema, conceptCountsTableIsTemp = FALSE, removeCurrentTable = TRUE ) } \arguments{ -\item{connectionDetails}{database connection details} +\item{connectionDetails}{An object of type \code{connectionDetails} as created using the +\code{\link[DatabaseConnector]{createConnectionDetails}} function in the +DatabaseConnector package. Can be left NULL if \code{connection} is +provided.} -\item{connection}{database connection} +\item{connection}{An object of type \code{connection} as created using the +\code{\link[DatabaseConnector]{connect}} function in the +DatabaseConnector package. Can be left NULL if \code{connectionDetails} +is provided, in which case a new connection will be opened at the start +of the function, and closed when the function finishes.} -\item{cdmDatabaseSchema}{CDM schema} +\item{cdmDatabaseSchema}{Schema name where your patient-level data in OMOP CDM format resides. +Note that for SQL Server, this should include both the database and +schema name, for example 'cdm_data.dbo'.} -\item{tempEmulationSchema}{schema to emulate temp table} +\item{tempEmulationSchema}{Some database platforms like Oracle and Impala do not truly support temp tables. To emulate temp +tables, provide a schema with write privileges where temp tables can be created.} -\item{conceptCountsDatabaseSchema}{schema name for the concept counts table} +\item{conceptCountsTable}{Concepts count table name. The default is "#concept_counts" to create a temporal concept counts table. +If an external concept counts table is used, provide the name in character, e.g. "concept_counts" without a hash} -\item{conceptCountsTable}{table name} +\item{conceptCountsDatabaseSchema}{schema name for the concept counts table} \item{conceptCountsTableIsTemp}{boolean to indicate if it should be a temporary table} \item{removeCurrentTable}{if the current table should be removed} } \description{ -Create a table containing the concept counts. +Create a table containing concept counts. +CohortDiagnostics performs this task in every run and takes a significant amount of time. +However, with this function, the user can create this table beforehand and +save it in the writing schema for further use. } diff --git a/man/executeDiagnostics.Rd b/man/executeDiagnostics.Rd index 5fab54f06..d14373a91 100644 --- a/man/executeDiagnostics.Rd +++ b/man/executeDiagnostics.Rd @@ -17,6 +17,7 @@ executeDiagnostics( tempEmulationSchema = getOption("sqlRenderTempEmulationSchema"), cohortTable = "cohort", cohortTableNames = CohortGenerator::getCohortTableNames(cohortTable = cohortTable), + conceptCountsTable = "#concept_counts", vocabularyDatabaseSchema = cdmDatabaseSchema, cohortIds = NULL, cdmVersion = 5, @@ -35,6 +36,7 @@ executeDiagnostics( irWashoutPeriod = 0, incremental = FALSE, incrementalFolder = file.path(exportFolder, "incremental"), + useExternalConceptCountsTable = FALSE, runFeatureExtractionOnSample = FALSE, sampleN = 1000, seed = 64374, @@ -79,6 +81,9 @@ tables, provide a schema with write privileges where temp tables can be created. \item{cohortTableNames}{Cohort Table names used by CohortGenerator package} +\item{conceptCountsTable}{Concepts count table name. The default is "#concept_counts" to create a temporal concept counts table. +If an external concept counts table is used, provide the name in character, e.g. "concept_counts" without a hash} + \item{vocabularyDatabaseSchema}{Schema name where your OMOP vocabulary data resides. This is commonly the same as cdmDatabaseSchema. Note that for SQL Server, this should include both the database and @@ -126,6 +131,8 @@ on covariates that have very low values. The default is 0.001 (i.e. 0.1 percent) \item{incrementalFolder}{If \code{incremental = TRUE}, specify a folder where records are kept of which cohort diagnostics has been executed.} +\item{useExternalConceptCountsTable}{If TRUE an external table for the cohort concept counts will be used.} + \item{runFeatureExtractionOnSample}{Logical. If TRUE, the function will operate on a sample of the data. Default is FALSE, meaning the function will operate on the full data set.} @@ -137,12 +144,6 @@ This ensures that the same sample can be drawn again in future runs. Default is \item{seedArgs}{List. Additional arguments to pass to the sampling function. This can be used to control aspects of the sampling process beyond the seed and sample size.} -\item{sampleIdentifierExpression}{Character. An expression that generates unique identifiers for each sample. -This expression can use the variables 'cohortId' and 'seed'. -Default is "cohortId * 1000 + seed", which ensures unique identifiers -as long as there are fewer than 1000 cohorts.} - -\item{useExternalConceptCountsTable}{If TRUE an external table for the cohort concept counts will be used.} } \description{ Runs the cohort diagnostics on all (or a subset of) the cohorts instantiated using the diff --git a/tests/testthat/setup.R b/tests/testthat/setup.R index 6597fe5e0..8dede91ed 100644 --- a/tests/testthat/setup.R +++ b/tests/testthat/setup.R @@ -31,9 +31,8 @@ minCellCountValue <- 5 skipCdmTests <- FALSE if (dbms == "sqlite") { - databaseFile <- paste0(Sys.getpid(), "testEunomia.sqlite") - - connectionDetails <- Eunomia::getEunomiaConnectionDetails(databaseFile = databaseFile) + databaseFile <- Eunomia::getDatabaseFile("GiBleed", overwrite = FALSE) + connectionDetails <- DatabaseConnector::createConnectionDetails(dbms = "sqlite", server = databaseFile) withr::defer( { unlink(databaseFile, recursive = TRUE, force = TRUE) diff --git a/tests/testthat/test-1-ResultsDataModel.R b/tests/testthat/test-1-ResultsDataModel.R index 1f2dd2182..fcae6b0d3 100644 --- a/tests/testthat/test-1-ResultsDataModel.R +++ b/tests/testthat/test-1-ResultsDataModel.R @@ -1,5 +1,5 @@ skipResultsDm <- FALSE -if (Sys.getenv("CDM5_POSTGRESQL_SERVER") == "") { +if (Sys.getenv("CDM5_POSTGRESQL_SERVER") == "" || Sys.getenv("SKIP_DB_TESTS") == "TRUE") { skipResultsDm <- TRUE } else { postgresConnectionDetails <- DatabaseConnector::createConnectionDetails( @@ -179,6 +179,7 @@ VALUES ('Synthea','Synthea','OHDSI Community','SyntheaTM is a Synthetic Patient }) test_that("Sqlite results data model", { + skip_if(skipResultsDm) dbFile <- tempfile(fileext = ".sqlite") createMergedResultsFile(dataFolder = file.path(folder, "export"), sqliteDbPath = dbFile, overwrite = TRUE, tablePrefix = "cd_") connectionDetailsSqlite <- DatabaseConnector::createConnectionDetails(dbms = "sqlite", server = dbFile)