diff --git a/NAMESPACE b/NAMESPACE index b10a82b..a7bd27e 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,5 +1,6 @@ # Generated by roxygen2: do not edit by hand +S3method(rbind,cohortDefinitionSet) export(CohortSubsetDefinition) export(CohortSubsetOperator) export(DemographicSubsetOperator) diff --git a/R/CohortConstruction.R b/R/CohortConstruction.R index 2c39889..e04648e 100644 --- a/R/CohortConstruction.R +++ b/R/CohortConstruction.R @@ -58,16 +58,17 @@ #' } #' #' @export -generateCohortSet <- function(connectionDetails = NULL, +generateCohortSet <- function(cohortDefinitionSet, + connectionDetails = NULL, connection = NULL, cdmDatabaseSchema, tempEmulationSchema = getOption("sqlRenderTempEmulationSchema"), cohortDatabaseSchema = cdmDatabaseSchema, cohortTableNames = getCohortTableNames(), - cohortDefinitionSet = NULL, stopOnError = TRUE, incremental = FALSE, incrementalFolder = NULL) { + cohortDefinitionSet <- as.cohortDefinitionSet(cohortDefinitionSet) checkmate::assertDataFrame(cohortDefinitionSet, min.rows = 1, col.names = "named") checkmate::assertNames(colnames(cohortDefinitionSet), must.include = c( diff --git a/R/CohortDefinitionSet.R b/R/CohortDefinitionSet.R index 29ad78b..278c98a 100644 --- a/R/CohortDefinitionSet.R +++ b/R/CohortDefinitionSet.R @@ -21,22 +21,14 @@ as.cohortDefinitionSet <- function(df) { invisible(df) } -# Define the cohortDefinitionSet class -setClass("cohortDefinitionSet", contains = "data.frame") +#' @export +rbind.cohortDefinitionSet <- function(...) { + print('foo') + base::rbind.default(...) -# Create a constructor for cohortDefinitionSet -cohortDefinitionSet <- function(...) { - obj <- new("cohortDefinitionSet", ...) - obj + return(NULL) } -# Override the rbind method for cohortDefinitionSet -setMethod("rbind", signature(x = "cohortDefinitionSet", y = "cohortDefinitionSet"), function(x, y, ...) { - # Custom logic to combine two cohortDefinitionSet objects - combined_set <- data.frame(rbind(as.data.frame(x), as.data.frame(y))) - return(combined_set) -}) - #' Create an empty cohort definition set #' #' @description diff --git a/man/createCohortSubsetDefinition.Rd b/man/createCohortSubsetDefinition.Rd index 6046b77..4076174 100644 --- a/man/createCohortSubsetDefinition.Rd +++ b/man/createCohortSubsetDefinition.Rd @@ -23,12 +23,12 @@ createCohortSubsetDefinition( \item{identifierExpression}{Expression (or string that converts to expression) that returns an id for an output cohort the default is dplyr::expr(targetId * 1000 + definitionId)} -\item{operatorNameConcatString}{(optional) SqlRender string template for formatting names of resulting subset cohorts +\item{operatorNameConcatString}{(optional) String to concatenate operator names together when outputting resulting cohort +name} + +\item{subsetCohortNameTemplate}{(optional) SqlRender string template for formatting names of resulting subset cohorts Can use the variables @baseCohortName, @subsetDefinitionName and @operatorNames. This is applied when adding the subset definition to a cohort definition set.} - -\item{subsetCohortNameTemplate}{(optional) String to concatenate operator names together when outputting resulting cohort -name} } \description{ Create subset definition from subset objects diff --git a/man/generateCohortSet.Rd b/man/generateCohortSet.Rd index ba4609e..632edcb 100644 --- a/man/generateCohortSet.Rd +++ b/man/generateCohortSet.Rd @@ -5,19 +5,27 @@ \title{Generate a set of cohorts} \usage{ generateCohortSet( + cohortDefinitionSet, connectionDetails = NULL, connection = NULL, cdmDatabaseSchema, tempEmulationSchema = getOption("sqlRenderTempEmulationSchema"), cohortDatabaseSchema = cdmDatabaseSchema, cohortTableNames = getCohortTableNames(), - cohortDefinitionSet = NULL, stopOnError = TRUE, incremental = FALSE, incrementalFolder = NULL ) } \arguments{ +\item{cohortDefinitionSet}{The \code{cohortDefinitionSet} argument must be a data frame with +the following columns: \describe{ +\item{cohortId}{The unique integer identifier of the cohort} +\item{cohortName}{The cohort's name} +\item{sql}{The OHDSI-SQL used to generate the cohort}} +Optionally, this data frame may contain: \describe{ +\item{json}{The Circe JSON representation of the cohort}}} + \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 @@ -44,14 +52,6 @@ this should include both the database and schema name, for example \item{cohortTableNames}{The names of the cohort tables. See \code{\link{getCohortTableNames}} for more details.} -\item{cohortDefinitionSet}{The \code{cohortDefinitionSet} argument must be a data frame with -the following columns: \describe{ -\item{cohortId}{The unique integer identifier of the cohort} -\item{cohortName}{The cohort's name} -\item{sql}{The OHDSI-SQL used to generate the cohort}} -Optionally, this data frame may contain: \describe{ -\item{json}{The Circe JSON representation of the cohort}}} - \item{stopOnError}{If an error happens while generating one of the cohorts in the cohortDefinitionSet, should we stop processing the other cohorts? The default is TRUE; when set to FALSE, failures will