From a61cd465126543d0ac38d1e3940db233173da427 Mon Sep 17 00:00:00 2001 From: jgilber2 Date: Wed, 16 Jul 2025 12:50:15 -0700 Subject: [PATCH 01/10] Initial code for saving and loading template definitions --- DESCRIPTION | 2 +- R/Module-CohortGenerator.R | 12 +++ R/StrategusModule.R | 160 +++++++++++++++++++++++-------------- 3 files changed, 112 insertions(+), 62 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 365b112a..48ccbd2c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -52,7 +52,7 @@ Suggests: Remotes: ohdsi/Characterization, ohdsi/CohortDiagnostics, - ohdsi/CohortGenerator, + ohdsi/CohortGenerator@cohort_templates, ohdsi/CohortIncidence, ohdsi/CohortMethod, ohdsi/PatientLevelPrediction, diff --git a/R/Module-CohortGenerator.R b/R/Module-CohortGenerator.R index 7f69b9c7..f9a4975a 100644 --- a/R/Module-CohortGenerator.R +++ b/R/Module-CohortGenerator.R @@ -120,7 +120,15 @@ CohortGeneratorModule <- R6::R6Class( stop("cohortDefinitionSet is not properly defined") } + templateDefinitions <- CohortGenerator::getTemplateDefinitions(cohortDefinitionSet) + if (length(templateDefinitions) > 0) { + # Don't save templates as regular cohorts, this is handled entirely in the template definitions + cohortDefinitionSet <- cohortDefinitionSet |> + dplyr::filter(!.data$isTemplatedCohort) + } + subsetDefinitions <- CohortGenerator::getSubsetDefinitions(cohortDefinitionSet) + if (length(subsetDefinitions) > 0) { # Filter the cohort definition set to the "parent" cohorts. parentCohortDefinitionSet <- cohortDefinitionSet[!cohortDefinitionSet$isSubset, ] @@ -153,6 +161,10 @@ CohortGeneratorModule <- R6::R6Class( sharedResource["cohortSubsets"] <- list(subsetIdMapping) } + if (length(templateDefinitions)) { + sharedResource["templateDefs"] <- lapply(templateDefinitions, function(x) { x$toList() }) + } + sharedResource <- super$createSharedResourcesSpecifications( className = self$cohortDefinitionSharedResourcesClassName, sharedResourcesSpecifications = sharedResource diff --git a/R/StrategusModule.R b/R/StrategusModule.R index ce00cde5..e88d03b4 100644 --- a/R/StrategusModule.R +++ b/R/StrategusModule.R @@ -9,13 +9,13 @@ JobContext <- R6::R6Class( classname = "JobContext", public = list( - #' @field sharedResources Shared resources for execution - #' TODO: Revisit to break this into fields for cohorts, subsets, - #' negative controls, + #' @field sharedResources Shared resources for execution + #' TODO: Revisit to break this into fields for cohorts, subsets, + #' negative controls, sharedResources = list(), - #' @field settings Module settings + #' @field settings Module settings settings = list(), - #' @field moduleExecutionSettings Module execution settings + #' @field moduleExecutionSettings Module execution settings moduleExecutionSettings = list() ) ) @@ -31,30 +31,30 @@ JobContext <- R6::R6Class( StrategusModule <- R6::R6Class( classname = "StrategusModule", public = list( - #' @field moduleName The name of the module taken from the class name. - #' This is set in the constructor of the class. + #' @field moduleName The name of the module taken from the class name. + #' This is set in the constructor of the class. moduleName = "", - #' @field moduleClassName The class name that identifies - #' the module specifications in the overall analysis specification. - #' This is set in the constructor of the class. + #' @field moduleClassName The class name that identifies + #' the module specifications in the overall analysis specification. + #' This is set in the constructor of the class. moduleClassName = "", - #' @field internalModuleSpecificationClassName A constant value. - #' The base class name that identifies a module specification - #' in the analysis specification. + #' @field internalModuleSpecificationClassName A constant value. + #' The base class name that identifies a module specification + #' in the analysis specification. internalModuleSpecificationClassName = "ModuleSpecifications", - #' @field internalSharedResourcesClassName A constant value. The class name - #' that identifies the shared resources section in the overall analysis - #' specification. + #' @field internalSharedResourcesClassName A constant value. The class name + #' that identifies the shared resources section in the overall analysis + #' specification. internalSharedResourcesClassName = "SharedResources", - #' @description Initialize the module + #' @description Initialize the module initialize = function() { self$moduleName <- class(self)[[1]] self$moduleClassName <- paste0(self$moduleName, "Specifications") }, - #' @description Executes the module - #' @template connectionDetails - #' @template analysisSpecifications - #' @template executionSettings + #' @description Executes the module + #' @template connectionDetails + #' @template analysisSpecifications + #' @template executionSettings execute = function(connectionDetails, analysisSpecifications, executionSettings) { errorMessages <- checkmate::makeAssertCollection() checkmate::assertClass(connectionDetails, "ConnectionDetails", add = errorMessages) @@ -66,10 +66,10 @@ StrategusModule <- R6::R6Class( private$.createJobContext(analysisSpecifications, executionSettings) private$.message("EXECUTING: ", self$moduleName) }, - #' @description Create the results data model for the module - #' @template resultsConnectionDetails - #' @template resultsDatabaseSchema - #' @template tablePrefix + #' @description Create the results data model for the module + #' @template resultsConnectionDetails + #' @template resultsDatabaseSchema + #' @template tablePrefix createResultsDataModel = function(resultsConnectionDetails, resultsDatabaseSchema, tablePrefix = "") { errorMessages <- checkmate::makeAssertCollection() checkmate::assertClass(resultsConnectionDetails, "ConnectionDetails", add = errorMessages) @@ -77,14 +77,14 @@ StrategusModule <- R6::R6Class( checkmate::reportAssertions(collection = errorMessages) private$.message("CREATE RESULTS DATA MODEL: ", self$moduleName) }, - #' @description Get the results data model specification for the module - #' @template tablePrefix + #' @description Get the results data model specification for the module + #' @template tablePrefix getResultsDataModelSpecification = function(tablePrefix = "") { }, - #' @description Upload the results for the module - #' @template resultsConnectionDetails - #' @template analysisSpecifications - #' @template resultsDataModelSettings + #' @description Upload the results for the module + #' @template resultsConnectionDetails + #' @template analysisSpecifications + #' @template resultsDataModelSettings uploadResults = function(resultsConnectionDetails, analysisSpecifications, resultsDataModelSettings) { errorMessages <- checkmate::makeAssertCollection() checkmate::assertClass(resultsConnectionDetails, "ConnectionDetails", add = errorMessages) @@ -95,10 +95,10 @@ StrategusModule <- R6::R6Class( private$.createJobContext(analysisSpecifications, resultsDataModelSettings) private$.message("UPLOAD RESULTS: ", self$moduleName) }, - #' @description Base function for creating the module settings object. - #' Each module will have its own implementation and this base class method - #' will be used to ensure the class of the specifications is set properly. - #' @template moduleSpecifications + #' @description Base function for creating the module settings object. + #' Each module will have its own implementation and this base class method + #' will be used to ensure the class of the specifications is set properly. + #' @template moduleSpecifications createModuleSpecifications = function(moduleSpecifications) { moduleSpecifications <- list( module = self$moduleName, @@ -107,32 +107,32 @@ StrategusModule <- R6::R6Class( class(moduleSpecifications) <- c(self$internalModuleSpecificationClassName, self$moduleClassName) return(moduleSpecifications) }, - #' @description Base function for creating the shared resources settings object. - #' Each module will have its own implementation if it needs to create - #' a shared resource. - #' @param className The class name of the shared resources specifications - #' @param sharedResourcesSpecifications The shared resources specifications + #' @description Base function for creating the shared resources settings object. + #' Each module will have its own implementation if it needs to create + #' a shared resource. + #' @param className The class name of the shared resources specifications + #' @param sharedResourcesSpecifications The shared resources specifications createSharedResourcesSpecifications = function(className, sharedResourcesSpecifications) { class(sharedResourcesSpecifications) <- c(className, self$internalSharedResourcesClassName) return(sharedResourcesSpecifications) }, - #' @description Base function for validating the module settings object. - #' Each module will have its own implementation and this base class method - #' will be used to ensure the module specifications are valid ahead of - #' execution - #' @template moduleSpecifications + #' @description Base function for validating the module settings object. + #' Each module will have its own implementation and this base class method + #' will be used to ensure the module specifications are valid ahead of + #' execution + #' @template moduleSpecifications validateModuleSpecifications = function(moduleSpecifications) { errorMessages <- checkmate::makeAssertCollection() checkmate::assertClass(moduleSpecifications, self$internalModuleSpecificationClassName) checkmate::assertClass(moduleSpecifications, self$moduleClassName) checkmate::reportAssertions(collection = errorMessages) }, - #' @description Base function for validating the shared resources - #' specification settings object. Each module will have its own - #' implementation and this base class method will be used to ensure - #' the module specifications are valid ahead of execution - #' @param className The class name of the shared resources specifications - #' @param sharedResourcesSpecifications The shared resources specifications + #' @description Base function for validating the shared resources + #' specification settings object. Each module will have its own + #' implementation and this base class method will be used to ensure + #' the module specifications are valid ahead of execution + #' @param className The class name of the shared resources specifications + #' @param sharedResourcesSpecifications The shared resources specifications validateSharedResourcesSpecifications = function(className, sharedResourcesSpecifications) { errorMessages <- checkmate::makeAssertCollection() checkmate::assertClass(sharedResourcesSpecifications, self$internalSharedResourcesClassName) @@ -173,15 +173,39 @@ StrategusModule <- R6::R6Class( # for the given module. private$jobContext$sharedResources <- analysisSpecifications$sharedResources private$jobContext$moduleExecutionSettings <- executionSettings - private$jobContext$moduleExecutionSettings$resultsSubFolder <- file.path(private$jobContext$moduleExecutionSettings$resultsFolder, self$moduleName) - if (!dir.exists(private$jobContext$moduleExecutionSettings$resultsSubFolder)) { - dir.create(private$jobContext$moduleExecutionSettings$resultsSubFolder, showWarnings = F, recursive = T) + private$ + jobContext$ + moduleExecutionSettings$ + resultsSubFolder <- file.path(private$ + jobContext$ + moduleExecutionSettings$ + resultsFolder, self$moduleName) + if (!dir.exists(private$ + jobContext$ + moduleExecutionSettings$ + resultsSubFolder)) { + dir.create(private$ + jobContext$ + moduleExecutionSettings$ + resultsSubFolder, showWarnings = F, recursive = T) } if (is(private$jobContext$moduleExecutionSettings, "ExecutionSettings")) { - private$jobContext$moduleExecutionSettings$workSubFolder <- file.path(private$jobContext$moduleExecutionSettings$workFolder, self$moduleName) - if (!dir.exists(private$jobContext$moduleExecutionSettings$workSubFolder)) { - dir.create(private$jobContext$moduleExecutionSettings$workSubFolder, showWarnings = F, recursive = T) + private$ + jobContext$ + moduleExecutionSettings$ + workSubFolder <- file.path(private$ + jobContext$ + moduleExecutionSettings$ + workFolder, self$moduleName) + if (!dir.exists(private$ + jobContext$ + moduleExecutionSettings$ + workSubFolder)) { + dir.create(private$ + jobContext$ + moduleExecutionSettings$ + workSubFolder, showWarnings = F, recursive = T) } } }, @@ -257,6 +281,14 @@ StrategusModule <- R6::R6Class( )) } + if (length(cohortDefinitionSharedResource$templateDefs)) { + for (tplDef in cohortDefinitionSharedResource$templateDefs) { + template <- CohortGenerator::CohortTemplateDefinition$new(tplDef) + cohortDefinitionSet <- cohortDefinitionSet |> + CohortGenerator::addCohortTemplateDefintion(template) + } + } + if (length(cohortDefinitionSharedResource$subsetDefs)) { subsetDefinitions <- lapply(cohortDefinitionSharedResource$subsetDefs, CohortGenerator::CohortSubsetDefinition$new) for (subsetDef in subsetDefinitions) { @@ -269,7 +301,6 @@ StrategusModule <- R6::R6Class( ) } } - return(cohortDefinitionSet) }, .createNegativeControlOutcomeSettingsFromJobContext = function() { @@ -279,7 +310,9 @@ StrategusModule <- R6::R6Class( className = "NegativeControlOutcomeSharedResources" ) if (!is.null(negativeControlSharedResource)) { - negativeControlOutcomes <- negativeControlSharedResource$negativeControlOutcomes$negativeControlOutcomeCohortSet + negativeControlOutcomes <- negativeControlSharedResource$ + negativeControlOutcomes$ + negativeControlOutcomeCohortSet if (length(negativeControlOutcomes) <= 0) { stop("Negative control outcome shared resource found but no negative control outcomes were provided.") } @@ -297,8 +330,12 @@ StrategusModule <- R6::R6Class( } invisible(list( cohortSet = negativeControlOutcomeCohortSet, - occurrenceType = negativeControlSharedResource$negativeControlOutcomes$occurrenceType, - detectOnDescendants = negativeControlSharedResource$negativeControlOutcomes$detectOnDescendants + occurrenceType = negativeControlSharedResource$ + negativeControlOutcomes$ + occurrenceType, + detectOnDescendants = negativeControlSharedResource$ + negativeControlOutcomes$ + detectOnDescendants )) } else { invisible(list( @@ -363,6 +400,7 @@ StrategusModule <- R6::R6Class( } return(s) } + if (is.null(names(covariateSettings))) { # List of lists modifiedCovariateSettings <- lapply(covariateSettings, .replaceProperties) From 050e13fae10c7fb768eafcac0d7f496b5acf0d6c Mon Sep 17 00:00:00 2001 From: jgilber2 Date: Wed, 16 Jul 2025 13:52:37 -0700 Subject: [PATCH 02/10] testing changes for saving definitions --- R/Module-CohortGenerator.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/R/Module-CohortGenerator.R b/R/Module-CohortGenerator.R index f9a4975a..5ccb95aa 100644 --- a/R/Module-CohortGenerator.R +++ b/R/Module-CohortGenerator.R @@ -125,6 +125,10 @@ CohortGeneratorModule <- R6::R6Class( # Don't save templates as regular cohorts, this is handled entirely in the template definitions cohortDefinitionSet <- cohortDefinitionSet |> dplyr::filter(!.data$isTemplatedCohort) + + templateDefs <- lapply(templateDefinitions, function(x) { x$toList(forStrategus = TRUE) }) + sharedResource["templateDefs"] <- templateDefs + browser() } subsetDefinitions <- CohortGenerator::getSubsetDefinitions(cohortDefinitionSet) @@ -161,10 +165,6 @@ CohortGeneratorModule <- R6::R6Class( sharedResource["cohortSubsets"] <- list(subsetIdMapping) } - if (length(templateDefinitions)) { - sharedResource["templateDefs"] <- lapply(templateDefinitions, function(x) { x$toList() }) - } - sharedResource <- super$createSharedResourcesSpecifications( className = self$cohortDefinitionSharedResourcesClassName, sharedResourcesSpecifications = sharedResource From 553aec5f598d5ef6da488d3b6de71bbc988684f9 Mon Sep 17 00:00:00 2001 From: jgilber2 Date: Wed, 16 Jul 2025 14:02:06 -0700 Subject: [PATCH 03/10] debug removed --- R/Module-CohortGenerator.R | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/R/Module-CohortGenerator.R b/R/Module-CohortGenerator.R index 5ccb95aa..1fddb61d 100644 --- a/R/Module-CohortGenerator.R +++ b/R/Module-CohortGenerator.R @@ -119,7 +119,7 @@ CohortGeneratorModule <- R6::R6Class( if (!CohortGenerator::isCohortDefinitionSet(cohortDefinitionSet)) { stop("cohortDefinitionSet is not properly defined") } - + sharedResource <- list() templateDefinitions <- CohortGenerator::getTemplateDefinitions(cohortDefinitionSet) if (length(templateDefinitions) > 0) { # Don't save templates as regular cohorts, this is handled entirely in the template definitions @@ -128,7 +128,6 @@ CohortGeneratorModule <- R6::R6Class( templateDefs <- lapply(templateDefinitions, function(x) { x$toList(forStrategus = TRUE) }) sharedResource["templateDefs"] <- templateDefs - browser() } subsetDefinitions <- CohortGenerator::getSubsetDefinitions(cohortDefinitionSet) @@ -140,7 +139,7 @@ CohortGeneratorModule <- R6::R6Class( parentCohortDefinitionSet <- cohortDefinitionSet } - sharedResource <- list() + cohortDefinitionSetFiltered <- private$.listafy(parentCohortDefinitionSet) sharedResource["cohortDefinitions"] <- list(cohortDefinitionSetFiltered) From 75ed861bc2f903534349197e8ca8afb6a2747c98 Mon Sep 17 00:00:00 2001 From: jgilber2 Date: Wed, 16 Jul 2025 14:13:22 -0700 Subject: [PATCH 04/10] using lists correctly --- R/Module-CohortGenerator.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/R/Module-CohortGenerator.R b/R/Module-CohortGenerator.R index 1fddb61d..1a53d0ec 100644 --- a/R/Module-CohortGenerator.R +++ b/R/Module-CohortGenerator.R @@ -127,7 +127,7 @@ CohortGeneratorModule <- R6::R6Class( dplyr::filter(!.data$isTemplatedCohort) templateDefs <- lapply(templateDefinitions, function(x) { x$toList(forStrategus = TRUE) }) - sharedResource["templateDefs"] <- templateDefs + sharedResource$templateDefs <- templateDefs } subsetDefinitions <- CohortGenerator::getSubsetDefinitions(cohortDefinitionSet) @@ -141,14 +141,14 @@ CohortGeneratorModule <- R6::R6Class( cohortDefinitionSetFiltered <- private$.listafy(parentCohortDefinitionSet) - sharedResource["cohortDefinitions"] <- list(cohortDefinitionSetFiltered) + sharedResource$cohortDefinitions <- list(cohortDefinitionSetFiltered) if (length(subsetDefinitions)) { # Subset definitions subsetDefinitionsJson <- lapply(subsetDefinitions, function(x) { x$toJSON() }) - sharedResource["subsetDefs"] <- list(subsetDefinitionsJson) + sharedResource$subsetDefs <- list(subsetDefinitionsJson) # Filter to the subsets subsetCohortDefinitionSet <- cohortDefinitionSet[cohortDefinitionSet$isSubset, ] @@ -161,7 +161,7 @@ CohortGeneratorModule <- R6::R6Class( ) subsetIdMapping[[i]] <- idMapping } - sharedResource["cohortSubsets"] <- list(subsetIdMapping) + sharedResource$cohortSubsets <- list(subsetIdMapping) } sharedResource <- super$createSharedResourcesSpecifications( From c10f9dc8c77839142e20d747be5bd54c9dd57430 Mon Sep 17 00:00:00 2001 From: jgilber2 Date: Wed, 16 Jul 2025 14:48:20 -0700 Subject: [PATCH 05/10] Don't store hash names, seems to create an issue --- R/Module-CohortGenerator.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/Module-CohortGenerator.R b/R/Module-CohortGenerator.R index 1a53d0ec..1b4839f1 100644 --- a/R/Module-CohortGenerator.R +++ b/R/Module-CohortGenerator.R @@ -126,7 +126,8 @@ CohortGeneratorModule <- R6::R6Class( cohortDefinitionSet <- cohortDefinitionSet |> dplyr::filter(!.data$isTemplatedCohort) - templateDefs <- lapply(templateDefinitions, function(x) { x$toList(forStrategus = TRUE) }) + templateDefs <- lapply(templateDefinitions, function(x) { x$toList() }) + names(templateDefs) <- NULL sharedResource$templateDefs <- templateDefs } From 3a947968f340b09d1b72b0944d4ad7030ba8909a Mon Sep 17 00:00:00 2001 From: jgilber2 Date: Wed, 16 Jul 2025 17:13:43 -0700 Subject: [PATCH 06/10] Modified storage of values in list to test odd behaviour --- R/Module-CohortGenerator.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/R/Module-CohortGenerator.R b/R/Module-CohortGenerator.R index 1b4839f1..64fdb7bb 100644 --- a/R/Module-CohortGenerator.R +++ b/R/Module-CohortGenerator.R @@ -142,14 +142,14 @@ CohortGeneratorModule <- R6::R6Class( cohortDefinitionSetFiltered <- private$.listafy(parentCohortDefinitionSet) - sharedResource$cohortDefinitions <- list(cohortDefinitionSetFiltered) + sharedResource$cohortDefinitions <- cohortDefinitionSetFiltered if (length(subsetDefinitions)) { # Subset definitions subsetDefinitionsJson <- lapply(subsetDefinitions, function(x) { x$toJSON() }) - sharedResource$subsetDefs <- list(subsetDefinitionsJson) + sharedResource$subsetDefs <- subsetDefinitionsJson # Filter to the subsets subsetCohortDefinitionSet <- cohortDefinitionSet[cohortDefinitionSet$isSubset, ] @@ -162,7 +162,7 @@ CohortGeneratorModule <- R6::R6Class( ) subsetIdMapping[[i]] <- idMapping } - sharedResource$cohortSubsets <- list(subsetIdMapping) + sharedResource$cohortSubsets <- subsetIdMapping } sharedResource <- super$createSharedResourcesSpecifications( From de09e6e5c2272c7a783faf1096df07aee5b86eed Mon Sep 17 00:00:00 2001 From: jgilber2 Date: Wed, 16 Jul 2025 17:29:26 -0700 Subject: [PATCH 07/10] fixed whitespace changes --- R/StrategusModule.R | 152 ++++++++++++++++++-------------------------- 1 file changed, 61 insertions(+), 91 deletions(-) diff --git a/R/StrategusModule.R b/R/StrategusModule.R index e88d03b4..67f4713b 100644 --- a/R/StrategusModule.R +++ b/R/StrategusModule.R @@ -9,13 +9,13 @@ JobContext <- R6::R6Class( classname = "JobContext", public = list( - #' @field sharedResources Shared resources for execution - #' TODO: Revisit to break this into fields for cohorts, subsets, - #' negative controls, + #' @field sharedResources Shared resources for execution + #' TODO: Revisit to break this into fields for cohorts, subsets, + #' negative controls, sharedResources = list(), - #' @field settings Module settings + #' @field settings Module settings settings = list(), - #' @field moduleExecutionSettings Module execution settings + #' @field moduleExecutionSettings Module execution settings moduleExecutionSettings = list() ) ) @@ -31,30 +31,30 @@ JobContext <- R6::R6Class( StrategusModule <- R6::R6Class( classname = "StrategusModule", public = list( - #' @field moduleName The name of the module taken from the class name. - #' This is set in the constructor of the class. + #' @field moduleName The name of the module taken from the class name. + #' This is set in the constructor of the class. moduleName = "", - #' @field moduleClassName The class name that identifies - #' the module specifications in the overall analysis specification. - #' This is set in the constructor of the class. + #' @field moduleClassName The class name that identifies + #' the module specifications in the overall analysis specification. + #' This is set in the constructor of the class. moduleClassName = "", - #' @field internalModuleSpecificationClassName A constant value. - #' The base class name that identifies a module specification - #' in the analysis specification. + #' @field internalModuleSpecificationClassName A constant value. + #' The base class name that identifies a module specification + #' in the analysis specification. internalModuleSpecificationClassName = "ModuleSpecifications", - #' @field internalSharedResourcesClassName A constant value. The class name - #' that identifies the shared resources section in the overall analysis - #' specification. + #' @field internalSharedResourcesClassName A constant value. The class name + #' that identifies the shared resources section in the overall analysis + #' specification. internalSharedResourcesClassName = "SharedResources", - #' @description Initialize the module + #' @description Initialize the module initialize = function() { self$moduleName <- class(self)[[1]] self$moduleClassName <- paste0(self$moduleName, "Specifications") }, - #' @description Executes the module - #' @template connectionDetails - #' @template analysisSpecifications - #' @template executionSettings + #' @description Executes the module + #' @template connectionDetails + #' @template analysisSpecifications + #' @template executionSettings execute = function(connectionDetails, analysisSpecifications, executionSettings) { errorMessages <- checkmate::makeAssertCollection() checkmate::assertClass(connectionDetails, "ConnectionDetails", add = errorMessages) @@ -66,10 +66,10 @@ StrategusModule <- R6::R6Class( private$.createJobContext(analysisSpecifications, executionSettings) private$.message("EXECUTING: ", self$moduleName) }, - #' @description Create the results data model for the module - #' @template resultsConnectionDetails - #' @template resultsDatabaseSchema - #' @template tablePrefix + #' @description Create the results data model for the module + #' @template resultsConnectionDetails + #' @template resultsDatabaseSchema + #' @template tablePrefix createResultsDataModel = function(resultsConnectionDetails, resultsDatabaseSchema, tablePrefix = "") { errorMessages <- checkmate::makeAssertCollection() checkmate::assertClass(resultsConnectionDetails, "ConnectionDetails", add = errorMessages) @@ -77,14 +77,14 @@ StrategusModule <- R6::R6Class( checkmate::reportAssertions(collection = errorMessages) private$.message("CREATE RESULTS DATA MODEL: ", self$moduleName) }, - #' @description Get the results data model specification for the module - #' @template tablePrefix + #' @description Get the results data model specification for the module + #' @template tablePrefix getResultsDataModelSpecification = function(tablePrefix = "") { }, - #' @description Upload the results for the module - #' @template resultsConnectionDetails - #' @template analysisSpecifications - #' @template resultsDataModelSettings + #' @description Upload the results for the module + #' @template resultsConnectionDetails + #' @template analysisSpecifications + #' @template resultsDataModelSettings uploadResults = function(resultsConnectionDetails, analysisSpecifications, resultsDataModelSettings) { errorMessages <- checkmate::makeAssertCollection() checkmate::assertClass(resultsConnectionDetails, "ConnectionDetails", add = errorMessages) @@ -95,10 +95,10 @@ StrategusModule <- R6::R6Class( private$.createJobContext(analysisSpecifications, resultsDataModelSettings) private$.message("UPLOAD RESULTS: ", self$moduleName) }, - #' @description Base function for creating the module settings object. - #' Each module will have its own implementation and this base class method - #' will be used to ensure the class of the specifications is set properly. - #' @template moduleSpecifications + #' @description Base function for creating the module settings object. + #' Each module will have its own implementation and this base class method + #' will be used to ensure the class of the specifications is set properly. + #' @template moduleSpecifications createModuleSpecifications = function(moduleSpecifications) { moduleSpecifications <- list( module = self$moduleName, @@ -107,32 +107,32 @@ StrategusModule <- R6::R6Class( class(moduleSpecifications) <- c(self$internalModuleSpecificationClassName, self$moduleClassName) return(moduleSpecifications) }, - #' @description Base function for creating the shared resources settings object. - #' Each module will have its own implementation if it needs to create - #' a shared resource. - #' @param className The class name of the shared resources specifications - #' @param sharedResourcesSpecifications The shared resources specifications + #' @description Base function for creating the shared resources settings object. + #' Each module will have its own implementation if it needs to create + #' a shared resource. + #' @param className The class name of the shared resources specifications + #' @param sharedResourcesSpecifications The shared resources specifications createSharedResourcesSpecifications = function(className, sharedResourcesSpecifications) { class(sharedResourcesSpecifications) <- c(className, self$internalSharedResourcesClassName) return(sharedResourcesSpecifications) }, - #' @description Base function for validating the module settings object. - #' Each module will have its own implementation and this base class method - #' will be used to ensure the module specifications are valid ahead of - #' execution - #' @template moduleSpecifications + #' @description Base function for validating the module settings object. + #' Each module will have its own implementation and this base class method + #' will be used to ensure the module specifications are valid ahead of + #' execution + #' @template moduleSpecifications validateModuleSpecifications = function(moduleSpecifications) { errorMessages <- checkmate::makeAssertCollection() checkmate::assertClass(moduleSpecifications, self$internalModuleSpecificationClassName) checkmate::assertClass(moduleSpecifications, self$moduleClassName) checkmate::reportAssertions(collection = errorMessages) }, - #' @description Base function for validating the shared resources - #' specification settings object. Each module will have its own - #' implementation and this base class method will be used to ensure - #' the module specifications are valid ahead of execution - #' @param className The class name of the shared resources specifications - #' @param sharedResourcesSpecifications The shared resources specifications + #' @description Base function for validating the shared resources + #' specification settings object. Each module will have its own + #' implementation and this base class method will be used to ensure + #' the module specifications are valid ahead of execution + #' @param className The class name of the shared resources specifications + #' @param sharedResourcesSpecifications The shared resources specifications validateSharedResourcesSpecifications = function(className, sharedResourcesSpecifications) { errorMessages <- checkmate::makeAssertCollection() checkmate::assertClass(sharedResourcesSpecifications, self$internalSharedResourcesClassName) @@ -173,39 +173,15 @@ StrategusModule <- R6::R6Class( # for the given module. private$jobContext$sharedResources <- analysisSpecifications$sharedResources private$jobContext$moduleExecutionSettings <- executionSettings - private$ - jobContext$ - moduleExecutionSettings$ - resultsSubFolder <- file.path(private$ - jobContext$ - moduleExecutionSettings$ - resultsFolder, self$moduleName) - if (!dir.exists(private$ - jobContext$ - moduleExecutionSettings$ - resultsSubFolder)) { - dir.create(private$ - jobContext$ - moduleExecutionSettings$ - resultsSubFolder, showWarnings = F, recursive = T) + private$jobContext$moduleExecutionSettings$resultsSubFolder <- file.path(private$jobContext$moduleExecutionSettings$resultsFolder, self$moduleName) + if (!dir.exists(private$jobContext$moduleExecutionSettings$resultsSubFolder)) { + dir.create(private$jobContext$moduleExecutionSettings$resultsSubFolder, showWarnings = F, recursive = T) } if (is(private$jobContext$moduleExecutionSettings, "ExecutionSettings")) { - private$ - jobContext$ - moduleExecutionSettings$ - workSubFolder <- file.path(private$ - jobContext$ - moduleExecutionSettings$ - workFolder, self$moduleName) - if (!dir.exists(private$ - jobContext$ - moduleExecutionSettings$ - workSubFolder)) { - dir.create(private$ - jobContext$ - moduleExecutionSettings$ - workSubFolder, showWarnings = F, recursive = T) + private$jobContext$moduleExecutionSettings$workSubFolder <- file.path(private$jobContext$moduleExecutionSettings$workFolder, self$moduleName) + if (!dir.exists(private$jobContext$moduleExecutionSettings$workSubFolder)) { + dir.create(private$jobContext$moduleExecutionSettings$workSubFolder, showWarnings = F, recursive = T) } } }, @@ -301,6 +277,7 @@ StrategusModule <- R6::R6Class( ) } } + return(cohortDefinitionSet) }, .createNegativeControlOutcomeSettingsFromJobContext = function() { @@ -310,9 +287,7 @@ StrategusModule <- R6::R6Class( className = "NegativeControlOutcomeSharedResources" ) if (!is.null(negativeControlSharedResource)) { - negativeControlOutcomes <- negativeControlSharedResource$ - negativeControlOutcomes$ - negativeControlOutcomeCohortSet + negativeControlOutcomes <- negativeControlSharedResource$negativeControlOutcomes$negativeControlOutcomeCohortSet if (length(negativeControlOutcomes) <= 0) { stop("Negative control outcome shared resource found but no negative control outcomes were provided.") } @@ -330,12 +305,8 @@ StrategusModule <- R6::R6Class( } invisible(list( cohortSet = negativeControlOutcomeCohortSet, - occurrenceType = negativeControlSharedResource$ - negativeControlOutcomes$ - occurrenceType, - detectOnDescendants = negativeControlSharedResource$ - negativeControlOutcomes$ - detectOnDescendants + occurrenceType = negativeControlSharedResource$negativeControlOutcomes$occurrenceType, + detectOnDescendants = negativeControlSharedResource$negativeControlOutcomes$detectOnDescendants )) } else { invisible(list( @@ -400,7 +371,6 @@ StrategusModule <- R6::R6Class( } return(s) } - if (is.null(names(covariateSettings))) { # List of lists modifiedCovariateSettings <- lapply(covariateSettings, .replaceProperties) From c588cd9c24f319e4e3cc34e60b4ba8d3673d1d14 Mon Sep 17 00:00:00 2001 From: jgilber2 Date: Mon, 22 Sep 2025 08:24:53 -0700 Subject: [PATCH 08/10] CG branch updated to develop line --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 48ccbd2c..90575263 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -52,7 +52,7 @@ Suggests: Remotes: ohdsi/Characterization, ohdsi/CohortDiagnostics, - ohdsi/CohortGenerator@cohort_templates, + ohdsi/CohortGenerator@develop, ohdsi/CohortIncidence, ohdsi/CohortMethod, ohdsi/PatientLevelPrediction, From 895292db1283340b2af1ee36ec3ae0d961bebabd Mon Sep 17 00:00:00 2001 From: jgilber2 Date: Fri, 3 Oct 2025 11:17:16 -0700 Subject: [PATCH 09/10] Comparator selection explorer module added --- DESCRIPTION | 4 +- R/Module-ComparatorSelectionExplorer.R | 129 ++++++++++++++++++ .../test-ComparatorSelectionExplorer.R | 31 +++++ tests/testthat/test-ModulesRdms.R | 4 + 4 files changed, 167 insertions(+), 1 deletion(-) create mode 100644 R/Module-ComparatorSelectionExplorer.R create mode 100644 tests/testthat/test-ComparatorSelectionExplorer.R diff --git a/DESCRIPTION b/DESCRIPTION index f58eca28..7cc279ca 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -35,6 +35,7 @@ Suggests: CohortDiagnostics (>= 3.4.0), CohortIncidence, CohortMethod, + ComparatorSelectionExplorer, Cyclops (>= 3.6.0), Eunomia, EvidenceSynthesis (>= 1.0.0), @@ -53,7 +54,8 @@ Remotes: ohdsi/CohortDiagnostics, ohdsi/CohortGenerator@develop, ohdsi/CohortIncidence, - ohdsi/CohortMethod + ohdsi/CohortMethod, + ohdsi/ComparatorSelectionExplorer@develop License: Apache License 2.0 VignetteBuilder: knitr URL: https://ohdsi.github.io/Strategus, https://github.com/OHDSI/Strategus diff --git a/R/Module-ComparatorSelectionExplorer.R b/R/Module-ComparatorSelectionExplorer.R new file mode 100644 index 00000000..a06e1a92 --- /dev/null +++ b/R/Module-ComparatorSelectionExplorer.R @@ -0,0 +1,129 @@ +# ComparatorSelectionExplorerModule ------------- +#' @title Analyze comparator selection using the ComparatorSelectionExplorer package +#' @export +#' @description +#' Development and evaluation of comparator selection algorithms +#' against the OMOP Common Data Model. +ComparatorSelectionExplorerModule <- R6::R6Class( + classname = "ComparatorSelectionExplorerModule", + inherit = StrategusModule, + public = list( + #' @field tablePrefix The table prefix to append to results tables + tablePrefix = "cse_", + + #' @description Initialize the module + initialize = function() { + super$initialize() + }, + + #' @description Executes the ComparatorSelectionExplorer package + #' @template connectionDetails + #' @template analysisSpecifications + #' @template executionSettings + execute = function(connectionDetails, analysisSpecifications, executionSettings) { + super$.validateCdmExecutionSettings(executionSettings) + super$execute(connectionDetails, analysisSpecifications, executionSettings) + + jobContext <- private$jobContext + exportFolder <- jobContext$moduleExecutionSettings$resultsSubFolder + args <- jobContext$settings + args$connectionDetails <- connectionDetails + args$cdmDatabaseSchema <- jobContext$moduleExecutionSettings$cdmDatabaseSchema + args$vocabularyDatabaseSchema <- jobContext$moduleExecutionSettings$vocabularyDatabaseSchema + args$resultsDatabaseSchema <- jobContext$moduleExecutionSettings$resultsDatabaseSchema + args$cohortDatabaseSchema <- jobContext$moduleExecutionSettings$workDatabaseSchema + args$tempEmulationSchema <- jobContext$moduleExecutionSettings$tempEmulationSchema + args$cohortDefinitionSet <- super$.createCohortDefinitionSetFromJobContext() + args$exportZipFile <- file.path(exportFolder, "results.zip") + args$incrementalFolder <- jobContext$moduleExecutionSettings$workSubFolder + args$logFileLocation <- file.path(exportFolder, "execution-log.txt") + args$generateCohortDefinitionSet <- TRUE + + # Execute the ComparatorSelectionExplorer package + ComparatorSelectionExplorer::execute(executionSettings = do.call(ComparatorSelectionExplorer::createExecutionSettings, args)) + + private$.message(paste("Results available at:", exportFolder)) + }, + + #' @description Create the results data model for the module + #' @template resultsConnectionDetails + #' @template resultsDatabaseSchema + #' @template tablePrefix + createResultsDataModel = function(resultsConnectionDetails, resultsDatabaseSchema, tablePrefix = self$tablePrefix) { + super$createResultsDataModel(resultsConnectionDetails, resultsDatabaseSchema, tablePrefix) + # Custom results data model creation logic if needed + ComparatorSelectionExplorer::createResultsDataModel(connectionDetails = resultsConnectionDetails, + databaseSchema = resultsDatabaseSchema, + tablePrefix = tablePrefix) + }, + + #' @description Get the results data model specification for the module + #' @template tablePrefix + getResultsDataModelSpecification = function(tablePrefix = "") { + resultsDataModelSpecification <- private$.getResultsDataModelSpecification() + # Add the prefix to the tableName column + resultsDataModelSpecification$tableName <- paste0(tablePrefix, self$tablePrefix, resultsDataModelSpecification$tableName) + return(resultsDataModelSpecification) + }, + + #' @description Upload the results for the module + #' @template resultsConnectionDetails + #' @template analysisSpecifications + #' @template resultsDataModelSettings + uploadResults = function(resultsConnectionDetails, analysisSpecifications, resultsDataModelSettings) { + super$uploadResults(resultsConnectionDetails, analysisSpecifications, resultsDataModelSettings) + + resultsFolder <- private$jobContext$moduleExecutionSettings$resultsSubFolder + zipFiles <- list.files( + path = resultsFolder, + pattern = "\\.zip$", + full.names = TRUE + ) + + if (length(zipFiles) > 0) { + zipFileName <- zipFiles[1] + } else { + DatabaseConnector::createZipFile( + zipFile = "results.zip", + files = list.files(resultsFolder, pattern = ".*\\.csv$"), + rootFolder = resultsFolder + ) + zipFileName <- file.path(resultsFolder, "results.zip") + } + + # Upload results using ComparatorSelectionExplorer + ComparatorSelectionExplorer::uploadResults( + connectionDetails = resultsConnectionDetails, + schema = resultsDataModelSettings$resultsDatabaseSchema, + tablePrefix = self$tablePrefix, + zipFileName = zipFileName + ) + }, + + #' @description Creates the ComparatorSelectionExplorer Module Specifications + #' @param ... Additional arameters for ComparatorSelectionExplorer settings + #' @param minExposureSize minimum number of individuals exposed to be considered in this analysis + #' @param targetCohortIds (optional) subset of cohort definition set to compute all pairwise comparisons for. By the N x N matrix of all similarity scores will be computed. + createModuleSpecifications = function(minExposureSize = 1000, targetCohortIds = NULL, ...) { + checkmate::assertIntegerish(minExposureSize, len = 1, lower = 1) + checkmate::assertNumeric(targetCohortIds, min.len = 1, null.ok = TRUE) + if (!is.null(targetCohortIds)) + checkmate::assertTRUE(all(targetCohortIds %% 1 == 0)) + analysis <- list(minExposureSize = minExposureSize, targetCohortIds = targetCohortIds, ...) + specifications <- super$createModuleSpecifications(moduleSpecifications = analysis) + return(specifications) + }, + + #' @description Validate the module specifications + #' @param moduleSpecifications The ComparatorSelectionExplorer module specifications + validateModuleSpecifications = function(moduleSpecifications) { + super$validateModuleSpecifications(moduleSpecifications = moduleSpecifications) + } + ), + + private = list( + .getResultsDataModelSpecification = function() { + ComparatorSelectionExplorer::getResultsDataModelSpec() + } + ) +) diff --git a/tests/testthat/test-ComparatorSelectionExplorer.R b/tests/testthat/test-ComparatorSelectionExplorer.R new file mode 100644 index 00000000..3f2524ca --- /dev/null +++ b/tests/testthat/test-ComparatorSelectionExplorer.R @@ -0,0 +1,31 @@ + +test_that("Verify createModuleSpecification input validation works properly", { + cseModule <- ComparatorSelectionExplorerModule$new() + + # Ensure valid inputs do not raise errors + specs <- cseModule$createModuleSpecifications( + targetCohortIds = c(1, 2, 3), + minExposureSize = 1000 + ) + expect_true(is.list(specs)) + expect_equal(specs$settings$targetCohortIds, c(1, 2, 3)) + expect_equal(specs$settings$minExposureSize, 1000) +}) + +test_that("Verify createModuleSpecifications handles optional parameters correctly", { + cseModule <- ComparatorSelectionExplorerModule$new() + + # Verify that excluding optional parameters uses default values + specs <- cseModule$createModuleSpecifications( + targetCohortIds = c(1, 2, 3) + ) + expect_equal(specs$settings$minExposureSize, 1000) # Default value + + # Verify that providing specific optional parameters overrides defaults + specs <- cseModule$createModuleSpecifications( + targetCohortIds = c(1, 2, 3), + minExposureSize = 500, + generateCohortDefinitionSet = FALSE + ) + expect_equal(specs$settings$minExposureSize, 500) +}) diff --git a/tests/testthat/test-ModulesRdms.R b/tests/testthat/test-ModulesRdms.R index 937bf39b..8237aa93 100644 --- a/tests/testthat/test-ModulesRdms.R +++ b/tests/testthat/test-ModulesRdms.R @@ -39,3 +39,7 @@ test_that("PatientLevelPredictionModule results data model is in correct format" test_that("SelfControlledCaseSeriesModule results data model is in correct format", { testResultsDataModelFormat("SelfControlledCaseSeriesModule") }) + +test_that("SelfControlledCaseSeriesModule results data model is in correct format", { + testResultsDataModelFormat("ComparatorSelectionExplorerModule") +}) From e91f373577e8824f213934780d9c705e9b36b7c6 Mon Sep 17 00:00:00 2001 From: jgilber2 Date: Fri, 3 Oct 2025 11:19:31 -0700 Subject: [PATCH 10/10] doc strings --- NAMESPACE | 1 + man/ComparatorSelectionExplorerModule.Rd | 232 +++++++++++++++++++++++ 2 files changed, 233 insertions(+) create mode 100644 man/ComparatorSelectionExplorerModule.Rd diff --git a/NAMESPACE b/NAMESPACE index f546988b..52dfcd4b 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -5,6 +5,7 @@ export(CohortDiagnosticsModule) export(CohortGeneratorModule) export(CohortIncidenceModule) export(CohortMethodModule) +export(ComparatorSelectionExplorerModule) export(EvidenceSynthesisModule) export(PatientLevelPredictionModule) export(PatientLevelPredictionValidationModule) diff --git a/man/ComparatorSelectionExplorerModule.Rd b/man/ComparatorSelectionExplorerModule.Rd new file mode 100644 index 00000000..89ff5ea2 --- /dev/null +++ b/man/ComparatorSelectionExplorerModule.Rd @@ -0,0 +1,232 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/Module-ComparatorSelectionExplorer.R +\name{ComparatorSelectionExplorerModule} +\alias{ComparatorSelectionExplorerModule} +\title{Analyze comparator selection using the ComparatorSelectionExplorer package} +\description{ +Development and evaluation of comparator selection algorithms +against the OMOP Common Data Model. +} +\section{Super class}{ +\code{\link[Strategus:StrategusModule]{Strategus::StrategusModule}} -> \code{ComparatorSelectionExplorerModule} +} +\section{Public fields}{ +\if{html}{\out{
}} +\describe{ +\item{\code{tablePrefix}}{The table prefix to append to results tables} +} +\if{html}{\out{
}} +} +\section{Methods}{ +\subsection{Public methods}{ +\itemize{ +\item \href{#method-ComparatorSelectionExplorerModule-new}{\code{ComparatorSelectionExplorerModule$new()}} +\item \href{#method-ComparatorSelectionExplorerModule-execute}{\code{ComparatorSelectionExplorerModule$execute()}} +\item \href{#method-ComparatorSelectionExplorerModule-createResultsDataModel}{\code{ComparatorSelectionExplorerModule$createResultsDataModel()}} +\item \href{#method-ComparatorSelectionExplorerModule-getResultsDataModelSpecification}{\code{ComparatorSelectionExplorerModule$getResultsDataModelSpecification()}} +\item \href{#method-ComparatorSelectionExplorerModule-uploadResults}{\code{ComparatorSelectionExplorerModule$uploadResults()}} +\item \href{#method-ComparatorSelectionExplorerModule-createModuleSpecifications}{\code{ComparatorSelectionExplorerModule$createModuleSpecifications()}} +\item \href{#method-ComparatorSelectionExplorerModule-validateModuleSpecifications}{\code{ComparatorSelectionExplorerModule$validateModuleSpecifications()}} +\item \href{#method-ComparatorSelectionExplorerModule-clone}{\code{ComparatorSelectionExplorerModule$clone()}} +} +} +\if{html}{\out{ +
Inherited methods + +
+}} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-ComparatorSelectionExplorerModule-new}{}}} +\subsection{Method \code{new()}}{ +Initialize the module +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{ComparatorSelectionExplorerModule$new()}\if{html}{\out{
}} +} + +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-ComparatorSelectionExplorerModule-execute}{}}} +\subsection{Method \code{execute()}}{ +Executes the ComparatorSelectionExplorer package +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{ComparatorSelectionExplorerModule$execute( + connectionDetails, + analysisSpecifications, + executionSettings +)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{connectionDetails}}{An object of class \code{connectionDetails} as created by the +\code{\link[DatabaseConnector:createConnectionDetails]{DatabaseConnector::createConnectionDetails()}} function.} + +\item{\code{analysisSpecifications}}{An object of type \code{AnalysisSpecifications} as created +by \code{\link[=createEmptyAnalysisSpecificiations]{createEmptyAnalysisSpecificiations()}}.} + +\item{\code{analysisSpecifications}}{An object of type \code{AnalysisSpecifications} as created +by \code{\link[=createEmptyAnalysisSpecificiations]{createEmptyAnalysisSpecificiations()}}.} + +\item{\code{executionSettings}}{An object of type \code{ExecutionSettings} as created +by \code{\link[=createCdmExecutionSettings]{createCdmExecutionSettings()}} or \code{\link[=createResultsExecutionSettings]{createResultsExecutionSettings()}}.} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-ComparatorSelectionExplorerModule-createResultsDataModel}{}}} +\subsection{Method \code{createResultsDataModel()}}{ +Create the results data model for the module +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{ComparatorSelectionExplorerModule$createResultsDataModel( + resultsConnectionDetails, + resultsDatabaseSchema, + tablePrefix = self$tablePrefix +)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{resultsConnectionDetails}}{The connection details to the results database which +is an object of class \code{connectionDetails} as created by the +\code{\link[DatabaseConnector:createConnectionDetails]{DatabaseConnector::createConnectionDetails()}} function.} + +\item{\code{resultsConnectionDetails}}{The connection details to the results database which +is an object of class \code{connectionDetails} as created by the +\code{\link[DatabaseConnector:createConnectionDetails]{DatabaseConnector::createConnectionDetails()}} function.} + +\item{\code{resultsDatabaseSchema}}{The schema in the results database that holds the results data model.} + +\item{\code{tablePrefix}}{A prefix to apply to the database table names (optional).} + +\item{\code{tablePrefix}}{A prefix to apply to the database table names (optional).} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-ComparatorSelectionExplorerModule-getResultsDataModelSpecification}{}}} +\subsection{Method \code{getResultsDataModelSpecification()}}{ +Get the results data model specification for the module +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{ComparatorSelectionExplorerModule$getResultsDataModelSpecification( + tablePrefix = "" +)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{tablePrefix}}{A prefix to apply to the database table names (optional).} + +\item{\code{tablePrefix}}{A prefix to apply to the database table names (optional).} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-ComparatorSelectionExplorerModule-uploadResults}{}}} +\subsection{Method \code{uploadResults()}}{ +Upload the results for the module +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{ComparatorSelectionExplorerModule$uploadResults( + resultsConnectionDetails, + analysisSpecifications, + resultsDataModelSettings +)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{resultsConnectionDetails}}{The connection details to the results database which +is an object of class \code{connectionDetails} as created by the +\code{\link[DatabaseConnector:createConnectionDetails]{DatabaseConnector::createConnectionDetails()}} function.} + +\item{\code{resultsConnectionDetails}}{The connection details to the results database which +is an object of class \code{connectionDetails} as created by the +\code{\link[DatabaseConnector:createConnectionDetails]{DatabaseConnector::createConnectionDetails()}} function.} + +\item{\code{analysisSpecifications}}{An object of type \code{AnalysisSpecifications} as created +by \code{\link[=createEmptyAnalysisSpecificiations]{createEmptyAnalysisSpecificiations()}}.} + +\item{\code{analysisSpecifications}}{An object of type \code{AnalysisSpecifications} as created +by \code{\link[=createEmptyAnalysisSpecificiations]{createEmptyAnalysisSpecificiations()}}.} + +\item{\code{resultsDataModelSettings}}{The results data model settings as created using [@seealso \code{\link[=createResultsDataModelSettings]{createResultsDataModelSettings()}}]} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-ComparatorSelectionExplorerModule-createModuleSpecifications}{}}} +\subsection{Method \code{createModuleSpecifications()}}{ +Creates the ComparatorSelectionExplorer Module Specifications +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{ComparatorSelectionExplorerModule$createModuleSpecifications( + minExposureSize = 1000, + targetCohortIds = NULL, + ... +)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{minExposureSize}}{minimum number of individuals exposed to be considered in this analysis} + +\item{\code{targetCohortIds}}{(optional) subset of cohort definition set to compute all pairwise comparisons for. By the N x N matrix of all similarity scores will be computed.} + +\item{\code{...}}{Additional arameters for ComparatorSelectionExplorer settings} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-ComparatorSelectionExplorerModule-validateModuleSpecifications}{}}} +\subsection{Method \code{validateModuleSpecifications()}}{ +Validate the module specifications +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{ComparatorSelectionExplorerModule$validateModuleSpecifications( + moduleSpecifications +)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{moduleSpecifications}}{The ComparatorSelectionExplorer module specifications} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-ComparatorSelectionExplorerModule-clone}{}}} +\subsection{Method \code{clone()}}{ +The objects of this class are cloneable with this method. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{ComparatorSelectionExplorerModule$clone(deep = FALSE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{deep}}{Whether to make a deep clone.} +} +\if{html}{\out{
}} +} +} +}