Skip to content

Commit

Permalink
Merge pull request #272 from OHDSI/develop
Browse files Browse the repository at this point in the history
Release v3.7.0
  • Loading branch information
ginberg authored Sep 3, 2024
2 parents a0bbc9b + 725aee8 commit eabfb42
Show file tree
Hide file tree
Showing 93 changed files with 335 additions and 313 deletions.
6 changes: 3 additions & 3 deletions CRAN-SUBMISSION
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Version: 3.5.2
Date: 2024-04-30 18:12:58 UTC
SHA: fe1f8048024d84e8079e872e60c4623c9d0c5c5f
Version: 3.7.0
Date: 2024-09-03 08:24:46 UTC
SHA: efa425b67203564c5a581de9180a87d14c28767e
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: FeatureExtraction
Type: Package
Title: Generating Features for a Cohort
Version: 3.6.0
Date: 2024-07-15
Version: 3.7.0
Date: 2024-09-02
Authors@R: c(
person("Martijn", "Schuemie", , "[email protected]", role = c("aut")),
person("Marc", "Suchard", role = c("aut")),
Expand Down Expand Up @@ -45,6 +45,6 @@ VignetteBuilder: knitr
URL: https://github.com/OHDSI/FeatureExtraction
BugReports: https://github.com/OHDSI/FeatureExtraction/issues
NeedsCompilation: no
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
Encoding: UTF-8
Language: en-US
7 changes: 7 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
FeatureExtraction 3.7.0
=======================

- Deprecate oracleTempSchema param, add tempEmulationSchema param (#126)
- Filter binary covariates server side (#255)
- Limit tests that are run on CRAN (#267)

FeatureExtraction 3.6.0
=======================

Expand Down
4 changes: 2 additions & 2 deletions R/DefaultCovariateSettings.R
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@
#' useMeasurementValueAsConceptAnyTimePrior = FALSE,
#' useMeasurementValueAsConceptLongTerm = TRUE,
#' useMeasurementValueAsConceptMediumTerm = FALSE,
#' useMeasurementValueAsConceptShortTerm = TRUE,
#' useMeasurementValueAsConceptShortTerm = TRUE,
#' useObservationAnyTimePrior = FALSE,
#' useObservationLongTerm = TRUE,
#' useObservationMediumTerm = FALSE,
Expand Down Expand Up @@ -617,7 +617,7 @@ createCovariateSettings <- function(useDemographicsGender = FALSE,
useObservationValueAsConceptAnyTimePrior = FALSE,
useObservationValueAsConceptLongTerm = FALSE,
useObservationValueAsConceptMediumTerm = FALSE,
useObservationValueAsConceptShortTerm = FALSE,
useObservationValueAsConceptShortTerm = FALSE,
useCharlsonIndex = FALSE,
useDcsi = FALSE,
useChads2 = FALSE,
Expand Down
21 changes: 16 additions & 5 deletions R/GetCovariates.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#' \code{connect} function in the \code{DatabaseConnector} package.
#' Either the \code{connection} or \code{connectionDetails} argument
#' should be specified.
#' @param oracleTempSchema A schema where temp tables can be created in Oracle.
#' @param oracleTempSchema DEPRECATED: use \code{tempEmulationSchema} instead.
#' @param cdmDatabaseSchema The name of the database schema that contains the OMOP CDM instance.
#' Requires read permissions to this database. On SQL Server, this should
#' specify both the database and the schema, so for example
Expand Down Expand Up @@ -66,6 +66,9 @@
#' @param minCharacterizationMean The minimum mean value for characterization output. Values below this will be cut off from output. This
#' will help reduce the file size of the characterization output, but will remove information
#' on covariates that have very low values. The default is 0.
#' @param 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.
#'
#' @return
#' Returns an object of type \code{covariateData}, containing information on the covariates.
Expand All @@ -82,7 +85,7 @@
#' )
#' covData <- getDbCovariateData(
#' connectionDetails = eunomiaConnectionDetails,
#' oracleTempSchema = NULL,
#' tempEmulationSchema = NULL,
#' cdmDatabaseSchema = "main",
#' cdmVersion = "5",
#' cohortTable = "cohort",
Expand All @@ -109,7 +112,8 @@ getDbCovariateData <- function(connectionDetails = NULL,
rowIdField = "subject_id",
covariateSettings,
aggregated = FALSE,
minCharacterizationMean = 0) {
minCharacterizationMean = 0,
tempEmulationSchema = NULL) {
if (is.null(connectionDetails) && is.null(connection)) {
stop("Need to provide either connectionDetails or connection")
}
Expand All @@ -123,6 +127,13 @@ getDbCovariateData <- function(connectionDetails = NULL,
warning("cohortId argument has been deprecated, please use cohortIds")
cohortIds <- cohortId
}
if (!is.null(oracleTempSchema) && oracleTempSchema != "") {
rlang::warn("The 'oracleTempSchema' argument is deprecated. Use 'tempEmulationSchema' instead.",
.frequency = "regularly",
.frequency_id = "oracleTempSchema"
)
tempEmulationSchema <- oracleTempSchema
}
errorMessages <- checkmate::makeAssertCollection()
minCharacterizationMean <- utils::type.convert(minCharacterizationMean, as.is = TRUE)
checkmate::assertNumeric(x = minCharacterizationMean, lower = 0, upper = 1, add = errorMessages)
Expand All @@ -149,7 +160,7 @@ getDbCovariateData <- function(connectionDetails = NULL,
sql <- SqlRender::translate(
sql = sql,
targetDialect = attr(connection, "dbms"),
oracleTempSchema = oracleTempSchema
tempEmulationSchema = tempEmulationSchema
)
temp <- DatabaseConnector::querySql(connection, sql, snakeCaseToCamelCase = TRUE)
if (aggregated) {
Expand All @@ -174,7 +185,7 @@ getDbCovariateData <- function(connectionDetails = NULL,
fun <- attr(covariateSettings[[i]], "fun")
args <- list(
connection = connection,
oracleTempSchema = oracleTempSchema,
tempEmulationSchema = tempEmulationSchema,
cdmDatabaseSchema = cdmDatabaseSchema,
cohortTable = cohortDatabaseSchemaTable,
cohortIds = cohortIds,
Expand Down
20 changes: 14 additions & 6 deletions R/GetCovariatesFromCohortAttributes.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#'
#' covData <- getDbCohortAttrCovariatesData(
#' connection = connection,
#' oracleTempSchema = NULL,
#' tempEmulationSchema = NULL,
#' cdmDatabaseSchema = "main",
#' cdmVersion = "5",
#' cohortTable = "cohort",
Expand All @@ -66,7 +66,8 @@ getDbCohortAttrCovariatesData <- function(connection,
cdmVersion = "5",
rowIdField = "subject_id",
covariateSettings,
aggregated = FALSE) {
aggregated = FALSE,
tempEmulationSchema = NULL) {
if (aggregated) {
stop("Aggregation not implemented for covariates from cohort attributes.")
}
Expand All @@ -77,6 +78,13 @@ getDbCohortAttrCovariatesData <- function(connection,
warning("cohortId argument has been deprecated, please use cohortIds")
cohortIds <- cohortId
}
if (!is.null(oracleTempSchema) && oracleTempSchema != "") {
rlang::warn("The 'oracleTempSchema' argument is deprecated. Use 'tempEmulationSchema' instead.",
.frequency = "regularly",
.frequency_id = "oracleTempSchema"
)
tempEmulationSchema <- oracleTempSchema
}
start <- Sys.time()
writeLines("Constructing covariates from cohort attributes table")

Expand All @@ -93,7 +101,7 @@ getDbCohortAttrCovariatesData <- function(connection,
dropTableIfExists = TRUE,
createTable = TRUE,
tempTable = TRUE,
oracleTempSchema = oracleTempSchema
tempEmulationSchema = tempEmulationSchema
)
}
sql <- SqlRender::readSql(system.file("sql/sql_server/GetAttrCovariates.sql", package = "FeatureExtraction"))
Expand All @@ -108,12 +116,12 @@ getDbCohortAttrCovariatesData <- function(connection,
renderedSql <- SqlRender::translate(
sql = renderedSql,
targetDialect = attr(connection, "dbms"),
oracleTempSchema = oracleTempSchema
tempEmulationSchema = tempEmulationSchema
)
# renderedSql <- SqlRender::loadRenderTranslateSql("GetAttrCovariates.sql",
# packageName = "FeatureExtraction",
# dbms = attr(connection, "dbms"),
# oracleTempSchema = oracleTempSchema,
# tempEmulationSchema = tempEmulationSchema,
# attr_database_schema = covariateSettings$attrDatabaseSchema,
# cohort_table = cohortTable,
# row_id_field = rowIdField,
Expand All @@ -129,7 +137,7 @@ getDbCohortAttrCovariatesData <- function(connection,
covariateRefSql <- SqlRender::translate(
sql = covariateRefSql,
targetDialect = attr(connection, "dbms"),
oracleTempSchema = oracleTempSchema
tempEmulationSchema = tempEmulationSchema
)
covariateRef <- DatabaseConnector::querySql(connection, covariateRefSql, snakeCaseToCamelCase = TRUE)
covariateRef$analysisId <- rep(as.numeric(covariateSettings$analysisId), length = nrow(covariateRef))
Expand Down
17 changes: 13 additions & 4 deletions R/GetCovariatesFromOtherCohorts.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ getDbCohortBasedCovariatesData <- function(connection,
rowIdField = "subject_id",
covariateSettings,
aggregated = FALSE,
minCharacterizationMean = 0) {
minCharacterizationMean = 0,
tempEmulationSchema = NULL) {
errorMessages <- checkmate::makeAssertCollection()
checkmate::assertClass(connection, "DatabaseConnectorConnection", add = errorMessages)
checkmate::assertCharacter(oracleTempSchema, len = 1, null.ok = TRUE, add = errorMessages)
checkmate::assertCharacter(tempEmulationSchema, len = 1, null.ok = TRUE, add = errorMessages)
checkmate::assertCharacter(cdmDatabaseSchema, len = 1, null.ok = TRUE, add = errorMessages)
checkmate::assertCharacter(cohortTable, len = 1, add = errorMessages)
checkmate::assertIntegerish(cohortId, add = errorMessages)
Expand All @@ -56,6 +58,13 @@ getDbCohortBasedCovariatesData <- function(connection,
warning("cohortId argument has been deprecated, please use cohortIds")
cohortIds <- cohortId
}
if (!is.null(oracleTempSchema) && oracleTempSchema != "") {
rlang::warn("The 'oracleTempSchema' argument is deprecated. Use 'tempEmulationSchema' instead.",
.frequency = "regularly",
.frequency_id = "oracleTempSchema"
)
tempEmulationSchema <- oracleTempSchema
}

start <- Sys.time()
message("Constructing covariates from other cohorts")
Expand All @@ -69,7 +78,7 @@ getDbCohortBasedCovariatesData <- function(connection,
dropTableIfExists = TRUE,
createTable = TRUE,
tempTable = TRUE,
oracleTempSchema = oracleTempSchema,
tempEmulationSchema = tempEmulationSchema,
camelCaseToSnakeCase = TRUE
)
if (is.null(covariateSettings$covariateCohortTable)) {
Expand Down Expand Up @@ -137,7 +146,7 @@ getDbCohortBasedCovariatesData <- function(connection,
}
result <- getDbDefaultCovariateData(
connection = connection,
oracleTempSchema = oracleTempSchema,
tempEmulationSchema = tempEmulationSchema,
cdmDatabaseSchema = cdmDatabaseSchema,
cohortTable = cohortTable,
cohortIds = cohortIds,
Expand All @@ -154,7 +163,7 @@ getDbCohortBasedCovariatesData <- function(connection,
sql = sql,
progressBar = FALSE,
reportOverallTime = FALSE,
oracleTempSchema = oracleTempSchema
tempEmulationSchema = tempEmulationSchema
)
return(result)
}
Expand Down
Loading

0 comments on commit eabfb42

Please sign in to comment.