diff --git a/.Rbuildignore b/.Rbuildignore index 4da35e99..64d6f461 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -11,3 +11,7 @@ compare_versions .github docs .idea +^_pkgdown\.yml$ +^docs$ +^pkgdown$ +^\.github$ diff --git a/.github/.gitignore b/.github/.gitignore new file mode 100644 index 00000000..2d19fc76 --- /dev/null +++ b/.github/.gitignore @@ -0,0 +1 @@ +*.html diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml new file mode 100644 index 00000000..178b0de9 --- /dev/null +++ b/.github/workflows/pkgdown.yaml @@ -0,0 +1,104 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + branches: [main, master] + pull_request: + branches: [main, master] + release: + types: [published] + workflow_dispatch: + +name: pkgdown.yaml + +permissions: read-all + +jobs: + pkgdown: + runs-on: ubuntu-latest + # Only restrict concurrency for non-PR jobs + concurrency: + group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + permissions: + contents: write + services: + postgres: + image: postgres:latest + env: + POSTGRES_DB: strategus + POSTGRES_USER: user + POSTGRES_PASSWORD: password + POSTGRES_HOST: postgres + POSTGRES_PORT: 5432 + ports: + - 5432:5432 + options: --name postgres --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Pandoc + uses: r-lib/actions/setup-pandoc@v2 + + - name: Setup R + uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - name: Setup R Dependencies + uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::pkgdown, local::. + needs: website + + - name: Build site + run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) + shell: Rscript {0} + + - name: Wait for PostgreSQL to be ready + run: | + until pg_isready -h 127.0.0.1 -p 5432 -U myuser; do + echo "Waiting for postgres..."; + sleep 3; + done + + - name: Run SQL Script + run: | + PGPASSWORD=password psql -h 127.0.0.1 -U user -d strategus -f extras/rdms/full_data_model_pg.sql + + - name: Configure SchemaSpy environment + run: | + sudo apt-get update + sudo apt-get install default-jdk -y + sudo apt-get install postgresql-client -y + + - name: Download PostgreSQL JDBC Driver + run: | + wget https://jdbc.postgresql.org/download/postgresql-42.2.24.jar -O $HOME/postgresql-jdbc.jar + + - name: Execute SchemaSpy + run: | + java -jar extras/rdms/schemaspy-6.2.4.jar -vizjs -dp $HOME -configFile extras/rdms/schemaspy-config.properties -meta extras/rdms/schema_meta.xml -debug -desc "Results data model" -noTablePaging -noimplied + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: documentation-artifact + path: public + + - name: download documentation + uses: actions/download-artifact@v4 + with: + name: documentation-artifact + path: docs/results-schema + + - name: Deploy to GitHub pages 🚀 + if: github.event_name != 'pull_request' + uses: JamesIves/github-pages-deploy-action@v4.5.0 + with: + clean: false + branch: gh-pages + folder: docs diff --git a/.gitignore b/.gitignore index 6ed21cce..cd1b73a4 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,7 @@ src/*.dll /Debug standalone/build/* _targets +docs + +extras/rdms/public +extras/rdms/*.class \ No newline at end of file diff --git a/DESCRIPTION b/DESCRIPTION index 511c7d6d..680591fd 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -12,7 +12,7 @@ Authors@R: c( Maintainer: Anthony Sena Description: An R package for coordinating and executing analytics using HADES modules. License: Apache License 2.0 -URL: https://ohdsi.github.io/Strategus, https://github.com/OHDSI/Strategus +URL: https://ohdsi.github.io/Strategus, https://github.com/OHDSI/Strategus, https://ohdsi.github.io/Strategus/ BugReports: https://github.com/OHDSI/Strategus/issues Depends: R (>= 4.2.0), diff --git a/R/Module-Characterization.R b/R/Module-Characterization.R index 7bb102c1..2057faf2 100644 --- a/R/Module-Characterization.R +++ b/R/Module-Characterization.R @@ -45,19 +45,10 @@ CharacterizationModule <- R6::R6Class( ) # Export the resultsDataModelSpecification.csv - resultsDataModel <- CohortGenerator::readCsv( - file = system.file( - "settings/resultsDataModelSpecification.csv", - package = "Characterization" - ), - warnOnCaseMismatch = FALSE - ) - - # add the prefix to the tableName column - resultsDataModel$tableName <- paste0(self$tablePrefix, resultsDataModel$tableName) + resultsDataModelSpecification <- self$getResultsDataModelSpecification() CohortGenerator::writeCsv( - x = resultsDataModel, + x = resultsDataModelSpecification, file = file.path(resultsFolder, "resultsDataModelSpecification.csv"), warnOnCaseMismatch = FALSE, warnOnFileNameCaseMismatch = FALSE, @@ -81,6 +72,21 @@ CharacterizationModule <- R6::R6Class( tablePrefix = tablePrefix ) }, + #' @description Get the results data model specification for the module + #' @template tablePrefix + getResultsDataModelSpecification = function(tablePrefix = "") { + resultsDataModelSpecification <- CohortGenerator::readCsv( + file = system.file( + file.path("settings", "resultsDataModelSpecification.csv"), + package = "Characterization" + ), + warnOnCaseMismatch = FALSE + ) + + # 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 diff --git a/R/Module-CohortDiagnostics.R b/R/Module-CohortDiagnostics.R index 0f9acf06..e6331fc8 100644 --- a/R/Module-CohortDiagnostics.R +++ b/R/Module-CohortDiagnostics.R @@ -42,19 +42,18 @@ CohortDiagnosticsModule <- R6::R6Class( # TODO: Removing this to make the upload easier # unlink(file.path(exportFolder, sprintf("Results_%s.zip", jobContext$moduleExecutionSettings$cdmDatabaseMetaData$databaseId))) - resultsDataModel <- CohortGenerator::readCsv( - file = system.file("settings", "resultsDataModelSpecification.csv", package = "CohortDiagnostics"), - warnOnCaseMismatch = FALSE - ) - resultsDataModel <- resultsDataModel[file.exists(file.path(exportFolder, paste0(resultsDataModel$tableName, ".csv"))), ] - newTableNames <- paste0(self$tablePrefix, resultsDataModel$tableName) + # NOTE: CD exports data without the table prefix and this section + # will manipulate the files to include the table prefix + resultsDataModelSpecification <- private$.getResultsDataModelSpecification() + resultsDataModelSpecification <- resultsDataModelSpecification[file.exists(file.path(exportFolder, paste0(resultsDataModelSpecification$tableName, ".csv"))), ] + newTableNames <- paste0(self$tablePrefix, resultsDataModelSpecification$tableName) file.rename( - file.path(exportFolder, paste0(unique(resultsDataModel$tableName), ".csv")), + file.path(exportFolder, paste0(unique(resultsDataModelSpecification$tableName), ".csv")), file.path(exportFolder, paste0(unique(newTableNames), ".csv")) ) - resultsDataModel$tableName <- newTableNames + resultsDataModelSpecification$tableName <- newTableNames CohortGenerator::writeCsv( - x = resultsDataModel, + x = resultsDataModelSpecification, file.path(exportFolder, "resultsDataModelSpecification.csv"), warnOnFileNameCaseMismatch = FALSE ) @@ -73,6 +72,14 @@ CohortDiagnosticsModule <- R6::R6Class( 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 @@ -207,6 +214,16 @@ CohortDiagnosticsModule <- R6::R6Class( } ' ParallelLogger::convertJsonToSettings(covariateSettings) + }, + .getResultsDataModelSpecification = function() { + resultsDataModelSpecification <- CohortGenerator::readCsv( + file = system.file( + file.path("settings", "resultsDataModelSpecification.csv"), + package = "CohortDiagnostics" + ), + warnOnCaseMismatch = FALSE + ) + return(resultsDataModelSpecification) } ) ) diff --git a/R/Module-CohortGenerator.R b/R/Module-CohortGenerator.R index bf390b1d..6b3932d0 100644 --- a/R/Module-CohortGenerator.R +++ b/R/Module-CohortGenerator.R @@ -67,6 +67,21 @@ CohortGeneratorModule <- R6::R6Class( tablePrefix = tablePrefix ) }, + #' @description Get the results data model specification for the module + #' @template tablePrefix + getResultsDataModelSpecification = function(tablePrefix = "") { + resultsDataModelSpecification <- CohortGenerator::readCsv( + file = system.file( + file.path("csv", "resultsDataModelSpecification.csv"), + package = "CohortGenerator" + ), + warnOnCaseMismatch = FALSE + ) + + # add the prefix to the tableName column + resultsDataModelSpecification$tableName <- paste0(tablePrefix, resultsDataModelSpecification$tableName) + return(resultsDataModelSpecification) + }, #' @description Upload the results for the module #' @template resultsConnectionDetails #' @template analysisSpecifications diff --git a/R/Module-CohortIncidence.R b/R/Module-CohortIncidence.R index 34cc9f3f..4deeeb82 100644 --- a/R/Module-CohortIncidence.R +++ b/R/Module-CohortIncidence.R @@ -95,8 +95,12 @@ CohortIncidenceModule <- R6::R6Class( target_outcome_ref$ref_id <- refId readr::write_csv(target_outcome_ref, file.path(exportFolder, paste0(self$tablePrefix,"target_outcome_ref",".csv"))) - resultsDataModel <- private$.getResultsDataModelSpecification() - readr::write_csv(resultsDataModel, file.path(exportFolder, "resultsDataModelSpecification.csv")) + resultsDataModelSpecification <- self$getResultsDataModelSpecification() + CohortGenerator::writeCsv( + x = resultsDataModelSpecification, + file.path(exportFolder, "resultsDataModelSpecification.csv"), + warnOnFileNameCaseMismatch = FALSE + ) private$.message(paste("Results available at:", resultsFolder)) }, @@ -114,11 +118,21 @@ CohortIncidenceModule <- R6::R6Class( on.exit(DatabaseConnector::disconnect(connection)) # Create the results model - sql <- ResultModelManager::generateSqlSchema(schemaDefinition = private$.getResultsDataModelSpecification()) + sql <- ResultModelManager::generateSqlSchema(schemaDefinition = self$getResultsDataModelSpecification()) sql <- SqlRender::render(sql= sql, warnOnMissingParameters = TRUE, database_schema = resultsDatabaseSchema) sql <- SqlRender::translate(sql = sql, targetDialect = resultsConnectionDetails$dbms) DatabaseConnector::executeSql(connection, sql) }, + #' @description Get the results data model specification for the module + #' @template tablePrefix + getResultsDataModelSpecification = function(tablePrefix = "") { + resultsDataModelSpecification <- CohortGenerator::readCsv( + file = private$.getResultsDataModelSpecificationFileLocation(), + warnOnCaseMismatch = FALSE + ) + resultsDataModelSpecification$tableName <-paste0(tablePrefix, self$tablePrefix, resultsDataModelSpecification$tableName) + return(resultsDataModelSpecification) + }, #' @description Upload the results for the module #' @template resultsConnectionDetails #' @template analysisSpecifications @@ -197,14 +211,6 @@ CohortIncidenceModule <- R6::R6Class( return(data) }, - .getResultsDataModelSpecification = function() { - rdms <- CohortGenerator::readCsv( - file = private$.getResultsDataModelSpecificationFileLocation(), - warnOnCaseMismatch = FALSE - ) - rdms$tableName <-paste0(self$tablePrefix, rdms$tableName) - return(rdms) - }, .getResultsDataModelSpecificationFileLocation = function() { return(system.file( file.path("csv", "cohortIncidenceRdms.csv"), diff --git a/R/Module-CohortMethod.R b/R/Module-CohortMethod.R index 533d2ccf..958de5df 100644 --- a/R/Module-CohortMethod.R +++ b/R/Module-CohortMethod.R @@ -47,9 +47,9 @@ CohortMethodModule <- R6::R6Class( # TODO: Removing this to make the upload easier #unlink(file.path(exportFolder, sprintf("Results_%s.zip", jobContext$moduleExecutionSettings$cdmDatabaseMetaData$databaseId))) - resultsDataModel <- CohortGenerator::readCsv(file = system.file("csv", "resultsDataModelSpecification.csv", package = "CohortMethod")) + resultsDataModelSpecification <- self$getResultsDataModelSpecification() CohortGenerator::writeCsv( - x = resultsDataModel, + x = resultsDataModelSpecification, file = file.path(exportFolder, "resultsDataModelSpecification.csv"), warnOnFileNameCaseMismatch = FALSE ) @@ -67,6 +67,21 @@ CohortMethodModule <- R6::R6Class( tablePrefix = tablePrefix ) }, + #' @description Get the results data model specification for the module + #' @template tablePrefix + getResultsDataModelSpecification = function(tablePrefix = "") { + resultsDataModelSpecification <- CohortGenerator::readCsv( + file = system.file( + file.path("csv", "resultsDataModelSpecification.csv"), + package = "CohortMethod" + ), + warnOnCaseMismatch = FALSE + ) + + # add the prefix to the tableName column + resultsDataModelSpecification$tableName <- paste0(tablePrefix, resultsDataModelSpecification$tableName) + return(resultsDataModelSpecification) + }, #' @description Upload the results for the module #' @template resultsConnectionDetails #' @template analysisSpecifications diff --git a/R/Module-EvidenceSynthesis.R b/R/Module-EvidenceSynthesis.R index db4162d9..5c6c3632 100644 --- a/R/Module-EvidenceSynthesis.R +++ b/R/Module-EvidenceSynthesis.R @@ -72,6 +72,18 @@ EvidenceSynthesisModule <- R6::R6Class( sql <- SqlRender::translate(sql = sql, targetDialect = resultsConnectionDetails$dbms) DatabaseConnector::executeSql(connection, sql) }, + #' @description Get the results data model specification for the module + #' @template tablePrefix + getResultsDataModelSpecification = function(tablePrefix = "") { + resultsDataModelSpecification <- CohortGenerator::readCsv( + file = private$.getResultsDataModelSpecificationFileLocation(), + warnOnCaseMismatch = FALSE + ) + + # add the prefix to the tableName column + resultsDataModelSpecification$tableName <- paste0(tablePrefix, resultsDataModelSpecification$tableName) + return(resultsDataModelSpecification) + }, #' @description Upload the results for the module #' @template resultsConnectionDetails #' @template analysisSpecifications diff --git a/R/Module-PatientLevelPrediction.R b/R/Module-PatientLevelPrediction.R index 7c63443f..695886f1 100644 --- a/R/Module-PatientLevelPrediction.R +++ b/R/Module-PatientLevelPrediction.R @@ -73,7 +73,7 @@ PatientLevelPredictionModule <- R6::R6Class( fileAppend = NULL ) - resultsDataModel <- private$.getResultsDataModelSpecification() + resultsDataModel <- self$getResultsDataModelSpecification() CohortGenerator::writeCsv( x = resultsDataModel, file = file.path(resultsFolder, "resultsDataModelSpecification.csv"), @@ -97,6 +97,17 @@ PatientLevelPredictionModule <- R6::R6Class( tablePrefix = tablePrefix ) }, + #' @description Get the results data model specification for the module + #' @template tablePrefix + getResultsDataModelSpecification = function(tablePrefix = "") { + resultsDataModelSpecification <- CohortGenerator::readCsv( + file = private$.getResultsDataModelSpecificationFileLocation() + ) + + # 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 @@ -174,13 +185,6 @@ PatientLevelPredictionModule <- R6::R6Class( return(modelDesignList) }, - .getResultsDataModelSpecification = function() { - rdms <- CohortGenerator::readCsv( - file = private$.getResultsDataModelSpecificationFileLocation() - ) - rdms$tableName <-paste0(self$tablePrefix, rdms$tableName) - return(rdms) - }, .getResultsDataModelSpecificationFileLocation = function() { return(system.file( file.path("settings", "resultsDataModelSpecification.csv"), diff --git a/R/Module-SelfControlledCaseSeries.R b/R/Module-SelfControlledCaseSeries.R index fafaaec8..c417cbfa 100644 --- a/R/Module-SelfControlledCaseSeries.R +++ b/R/Module-SelfControlledCaseSeries.R @@ -53,7 +53,7 @@ SelfControlledCaseSeriesModule <- R6::R6Class( # TODO: Removing this to make the upload easier #unlink(file.path(exportFolder, sprintf("Results_%s.zip", jobContext$moduleExecutionSettings$cdmDatabaseMetaData$databaseId))) - resultsDataModel <- CohortGenerator::readCsv(file = system.file("csv", "resultsDataModelSpecification.csv", package = "SelfControlledCaseSeries")) + resultsDataModel <- self$getResultsDataModelSpecification() resultsDataModel <- resultsDataModel[file.exists(file.path(exportFolder, paste0(resultsDataModel$tableName, ".csv"))), ] if (any(!startsWith(resultsDataModel$tableName, self$tablePrefix))) { stop("Table names do not have required prefix") @@ -80,6 +80,18 @@ SelfControlledCaseSeriesModule <- R6::R6Class( databaseSchema = resultsDatabaseSchema, ) }, + #' @description Get the results data model specification for the module + #' @template tablePrefix + getResultsDataModelSpecification = function(tablePrefix = "") { + resultsDataModelSpecification <- CohortGenerator::readCsv( + file = system.file("csv", "resultsDataModelSpecification.csv", package = "SelfControlledCaseSeries"), + warnOnCaseMismatch = FALSE + ) + + # add the prefix to the tableName column + resultsDataModelSpecification$tableName <- paste0(tablePrefix, tablePrefix, resultsDataModelSpecification$tableName) + return(resultsDataModelSpecification) + }, #' @description Upload the results for the module #' @template resultsConnectionDetails #' @template analysisSpecifications diff --git a/R/Module-StrategusModule.R b/R/StrategusModule.R similarity index 98% rename from R/Module-StrategusModule.R rename to R/StrategusModule.R index 2b0df6cd..6697599f 100644 --- a/R/Module-StrategusModule.R +++ b/R/StrategusModule.R @@ -72,6 +72,10 @@ 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 + getResultsDataModelSpecification = function(tablePrefix = "") { + }, #' @description Upload the results for the module #' @template resultsConnectionDetails #' @template analysisSpecifications diff --git a/_pkgdown.yml b/_pkgdown.yml index 885ee2a4..c5084301 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -1,15 +1,16 @@ +url: https://ohdsi.github.io/Strategus/ template: params: bootswatch: cosmo - home: links: - text: Ask a question href: http://forums.ohdsi.org - navbar: structure: - right: [hades, github] + right: + - hades + - github components: hades: text: hadesLogo diff --git a/extras/DocumentResultsDataModel.R b/extras/DocumentResultsDataModel.R new file mode 100644 index 00000000..b6944ffe --- /dev/null +++ b/extras/DocumentResultsDataModel.R @@ -0,0 +1,191 @@ +# ------------------------------------------------------------------------------ +# This script does the following: +# - Uses a local PG instance to create the results data model. The data +# model is then exported to produce a SQL script that is then used by GHA +# to build the SchemaSpy results data model documentation. +# - Creates the SchemaSpy SchemaMeta.xml used to build the documentation. +# This XML contains the table descriptions, column descriptions and +# FK relationships between the entities. +# (https://schemaspy.readthedocs.io/en/latest/configuration/schemaMeta.html) +# +# Notes about resources found in the /extras/rdms directory: +# - table_descriptions.csv: Hand currated table descriptions. Column descriptions +# come from the module rdms files. +# - SqlExtractor.java: Program to parse out the OhdsiShinyModules R files to +# extract the SQL used by the results viewer. The output of this program is +# contained in ohdsi_shiny_modules_sql_queries.csv +# - SqlJoinRelationshipExtractor.java: Program to parse +# ohdsi_shiny_modules_sql_queries.csv and identify the JOIN clauses to +# document the relationships in the data model. Results of this program are +# in ohdsi_shiny_modules_table_relationships.csv. +# - results_table_realtionships.xlsx: Manually reviewed the ohdsi_shiny_modules_table_relationships.csv +# and extracted the list of tables and their foreign key relationships. +# - results_table_relationships.csv: Exported the unique entries from +# results_table_realtionships.xlsx. This resource is then used when constructing +# the SchemaSpy SchemaMeta.xml +# ------------------------------------------------------------------------------ +library(Strategus) +library(dplyr) + +# fullResultsDataModel will hold the full results model to create the +# SchemaSpyMeta.xml +fullResultsDataModel <- tibble::tibble() +rdms <- CohortGenerator::readCsv( + file = system.file( + file.path("csv", "databaseMetaDataRdms.csv"), + package = "Strategus" + ), + warnOnCaseMismatch = F +) +rdms$tableDefinedBy <- "Strategus" + +fullResultsDataModel <- fullResultsDataModel %>% + bind_rows(rdms %>% select(tableDefinedBy, tableName, columnName, description)) + +sql <- "-- Strategus Tables\n" +sql <- paste0(sql, ResultModelManager::generateSqlSchema(schemaDefinition = rdms)) + +# Iterate over all of the modules in the project +# and produce the full results data model specification +# for each module +moduleFileList <- list.files("./R", pattern = "^Module-.*\\.R$") +fileNameCleaned <- sub("^Module-", "", moduleFileList) # Remove "Module-" +fileNameCleaned <- sub("\\.R$", "", fileNameCleaned) # Remove ".R" +moduleList <- paste0(fileNameCleaned, "Module") + +for(module in moduleList) { + m <- get(module)$new() + rdms <- m$getResultsDataModelSpecification() + + sql <- paste0(sql, "-- ", module, " Tables\n") + sql <- paste0(sql, ResultModelManager::generateSqlSchema(schemaDefinition = rdms)) + + if (!"description" %in% colnames(rdms)) { + rdms$description <- "" + } + rdms$tableDefinedBy <- module + + fullResultsDataModel <- fullResultsDataModel %>% + bind_rows(rdms %>% select(tableDefinedBy, tableName, columnName, description)) +} + +# NOTE: This code was to initially save the table information to a csv file +# that will be manually edited to include the table descriptions +# tableDescriptions <- fullResultsDataModel %>% +# select(tableDefinedBy, tableName) %>% +# distinct() %>% +# mutate(description = "") %>% +# arrange(tableName) +# CohortGenerator::writeCsv( +# x = tableDescriptions, +# file = "./extras/rdms/table_descriptions.csv" +# ) + +# Save the OHDSI-SQL +SqlRender::writeSql( + sql = sql, + targetFile = "./extras/rdms/full_data_model_ohdsi.sql" +) + +# Render for PostgreSQL +pgSql <- SqlRender::render( + sql = sql, + database_schema = "results" +) +pgSql <- SqlRender::translate( + sql = pgSql, + targetDialect = "postgresql" +) +SqlRender::writeSql( + sql = pgSql, + targetFile = "./extras/rdms/full_data_model_pg.sql" +) + +# Write out the SchemaSpy SchemaMeta.xml --------------------------- +library(xml2) + +# Create the root element with attributes +schemaMeta <- xml_new_root("schemaMeta", + "xmlns:xsi" = "http://www.w3.org/2001/XMLSchema-instance", + "xsi:noNamespaceSchemaLocation" = "http://schemaspy.org/xsd/6/schemameta.xsd") + +# Add comments node +xml_add_child( + schemaMeta, + "comments", + "The tables in the results data model are grouped using a unique prefix for + each Strategus module. For example, the CharacterizationModule results tables + all start with \"c_\".") + +# Create tables node +tables <- xml_add_child(schemaMeta, "tables") + +# Iterate over the fullResultsDataModel to create the descriptions +# of the tables & columns. +uniqueTableNames <- unique(fullResultsDataModel$tableName) +tableDescriptions <- CohortGenerator::readCsv( + file = "./extras/rdms/table_descriptions.csv" +) +resultsTableRelationships <-CohortGenerator::readCsv( + file = "./extras/rdms/results_table_relationships.csv" +) +for (i in seq_along(uniqueTableNames)) { + # Add table node with attributes + currentTableName <- uniqueTableNames[i] + #print(currentTableName) + # Get the table description, if it exists + currentTableDescriptionInfo <- tableDescriptions %>% + filter(.data$tableName == currentTableName) + currentTableDescription <- "" + if (nrow(currentTableDescriptionInfo) == 1) { + currentTableDescription <- paste0(currentTableDescriptionInfo$tableDefinedBy[1], ": ", currentTableDescriptionInfo$description[1]) + } + table <- xml_add_child(tables, "table", name = currentTableName, comments = currentTableDescription) + + # Get the columns + columnsForCurrentTable <- fullResultsDataModel %>% + filter(.data$tableName == currentTableName) + + for (j in 1:nrow(columnsForCurrentTable)) { + curColumnName <- columnsForCurrentTable$columnName[j] + description <- columnsForCurrentTable$description[j] + #print(paste0(" -- ", curColumnName)) + # Add column node with attributes + columnNode <- xml_add_child(table, "column", name = curColumnName, comments = description) + # Determine if this table + column has a FK relationship to any other tables + curColumnFk <- resultsTableRelationships %>% + filter(.data$tableName == currentTableName & .data$columnName == curColumnName) + if (nrow(curColumnFk) > 0) { + #print(paste0("-- FK FOUND FOR: ", currentTableName, ".", curColumnName)) + for (k in 1:nrow(curColumnFk)) { + fkTable <- curColumnFk$fkTableName[k] + fkColumn <- curColumnFk$fkColumnName[k] + xml_add_child(columnNode, "foreignKey", table = fkTable, column = fkColumn) + } + } + } +} + +# Write the XML string to a file, omitting the XML declaration +write_xml(schemaMeta, "./extras/rdms/schema_meta.xml") + + +# Used to create the DB locally to assist in documenting the +# results model. +# connectionDetails <- DatabaseConnector::createConnectionDetails( +# dbms = "postgresql", +# server = "127.0.0.1/strategus", +# user = "user", +# password = "password" +# ) +# connection <- DatabaseConnector::connect(connectionDetails) +# DatabaseConnector::executeSql( +# connection = connection, +# sql = "drop schema results cascade;create schema results;" +# ) +# sql <- SqlRender::readSql("./extras/rdms/full_data_model_pg.sql") +# DatabaseConnector::executeSql( +# connection = connection, +# sql = sql +# ) +# DatabaseConnector::disconnect(connection) diff --git a/extras/PackageMaintenance.R b/extras/PackageMaintenance.R index 0ec81f11..2339e6ce 100644 --- a/extras/PackageMaintenance.R +++ b/extras/PackageMaintenance.R @@ -14,6 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +# Go document the full results data model -> DocumentResultsDataModel.R + # Manually delete package from library. Avoids "Already in use" message when rebuilding unloadNamespace("Strategus") .rs.restartR() @@ -65,7 +67,6 @@ unlink("inst/doc/IntroductionToStrategus.tex") pkgdown::build_site() OhdsiRTools::fixHadesLogo() - # Produce a study analysis specification for testing ----------- library(Strategus) cohortDefinitionSet <- getCohortDefinitionSet( diff --git a/extras/rdms/SqlExtractor.java b/extras/rdms/SqlExtractor.java new file mode 100644 index 00000000..f92a8e70 --- /dev/null +++ b/extras/rdms/SqlExtractor.java @@ -0,0 +1,132 @@ +import java.io.*; +import java.nio.file.*; +import java.util.regex.*; +import java.util.List; +import java.util.ArrayList; + +public class SqlExtractor { + + // Method to scan a directory and process all .R files + public static void scanDirectory(String directoryPath, String outputCsvPath) { + try { + // Collect all .R files in the directory + List rFiles = getRFiles(directoryPath); + + // Create a list to store SQL extractions + List extractedData = new ArrayList<>(); + int totalSqlExcerpts = 0; + + // Process each R file + for (File file : rFiles) { + List sqlQueries = extractSqlFromFile(file); + extractedData.addAll(sqlQueries); + totalSqlExcerpts += sqlQueries.size(); + // Output the number of SQL queries found in each file + System.out.println(file.getName() + " - " + sqlQueries.size() + " SQL statements found"); + } + + // Write extracted SQL to CSV + writeCsv(outputCsvPath, extractedData); + + System.out.println("Extraction complete. Total SQL excerpts extracted: " + totalSqlExcerpts); + System.out.println("Results saved to: " + outputCsvPath); + } catch (IOException e) { + e.printStackTrace(); + } + } + + // Method to get all .R files from a directory + private static List getRFiles(String directoryPath) throws IOException { + List rFiles = new ArrayList<>(); + Files.walk(Paths.get(directoryPath)) + .filter(Files::isRegularFile) + .filter(path -> path.toString().endsWith(".R")) + .forEach(path -> rFiles.add(path.toFile())); + return rFiles; + } + + // Method to extract SQL queries from a file, including start and end line numbers + private static List extractSqlFromFile(File file) throws IOException { + List sqlQueries = new ArrayList<>(); + BufferedReader reader = new BufferedReader(new FileReader(file)); + String line; + boolean capturingSql = false; + StringBuilder sqlBuilder = new StringBuilder(); + char quoteChar = 0; // To store the opening quote character (' or ") + int lineNumber = 0; + int startLineNumber = 0; + + // Regex to detect the start of the SQL query: `sql <- "..."` or `sql <- '...'` + Pattern startPattern = Pattern.compile("sql\\s*<-\\s*(['\"])(.*)"); // Detects start with either single or double quotes + + while ((line = reader.readLine()) != null) { + lineNumber++; // Increment the line number for each line read + if (capturingSql) { + // Continue capturing until the matching quote character is found + int closingQuoteIndex = line.indexOf(quoteChar); + if (closingQuoteIndex != -1) { + sqlBuilder.append(line, 0, closingQuoteIndex); // Capture the SQL until the closing quote + sqlQueries.add(new String[]{ + "\"" + file.getName() + "\"", + "\"" + startLineNumber + "\"", + "\"" + lineNumber + "\"", + "\"" + sqlBuilder.toString().trim() + "\"" + }); // Save the captured SQL + capturingSql = false; // Stop capturing + } else { + sqlBuilder.append(line.trim()).append(" "); // Continue capturing across lines + } + } else { + // Check if the line contains the start of the SQL query + Matcher startMatcher = startPattern.matcher(line); + if (startMatcher.find()) { + quoteChar = startMatcher.group(1).charAt(0); // Capture the opening quote character (either ' or ") + sqlBuilder.setLength(0); // Clear the builder + sqlBuilder.append(startMatcher.group(2)); // Start capturing after the opening quote + startLineNumber = lineNumber; // Set the line number where SQL starts + + // Check if the SQL ends on the same line + int closingQuoteIndex = sqlBuilder.indexOf(Character.toString(quoteChar)); + if (closingQuoteIndex != -1) { + sqlQueries.add(new String[]{ + "\"" + file.getName() + "\"", + "\"" + startLineNumber + "\"", + "\"" + lineNumber + "\"", + "\"" + sqlBuilder.substring(0, closingQuoteIndex).trim() + "\"" + }); // Capture the SQL before the closing quote + capturingSql = false; + } else { + capturingSql = true; // SQL spans multiple lines + } + } + } + } + reader.close(); + return sqlQueries; + } + + // Method to write the extracted SQL queries to a CSV file with start and end line numbers + private static void writeCsv(String csvPath, List data) throws IOException { + FileWriter csvWriter = new FileWriter(csvPath); + // Update column headings to exactly match your request + csvWriter.append("\"fileName\",\"startLine\",\"endLine\",\"sqlQuery\"\n"); + + for (String[] row : data) { + csvWriter.append(String.join(",", row)).append("\n"); + } + csvWriter.flush(); + csvWriter.close(); + } + + public static void main(String[] args) { + if (args.length < 2) { + System.out.println("Usage: java SqlExtractor "); + return; + } + + String directoryPath = args[0]; + String outputCsvPath = args[1]; + + scanDirectory(directoryPath, outputCsvPath); + } +} diff --git a/extras/rdms/SqlJoinRelationshipExtractor.java b/extras/rdms/SqlJoinRelationshipExtractor.java new file mode 100644 index 00000000..48e28d6a --- /dev/null +++ b/extras/rdms/SqlJoinRelationshipExtractor.java @@ -0,0 +1,92 @@ +import java.io.*; +import java.util.*; +import java.util.regex.*; + +public class SqlJoinRelationshipExtractor { + + // Method to analyze SQL queries and extract the FROM and JOIN relationships, including multiple conditions (AND/OR) + public static void extractSqlJoins(String inputCsvFilePath, String outputCsvFilePath) { + try { + BufferedReader csvReader = new BufferedReader(new FileReader(inputCsvFilePath)); + FileWriter csvWriter = new FileWriter(outputCsvFilePath); + + String row; + boolean isFirstRow = true; + + // Write the header of the output CSV + csvWriter.append("fileName,startLine,endLine,fromClause,joinRelationship\n"); + + // Pattern to match FROM clause + Pattern fromPattern = Pattern.compile("from\\s+([\\w.@]+)\\s+([\\w@]+)", Pattern.CASE_INSENSITIVE); + // Pattern to match JOIN clauses, including AND/OR conditions + Pattern joinPattern = Pattern.compile("join\\s+([\\w.@]+)\\s+([\\w@]+)\\s+on\\s+(.+?)(?=\\s+join|\\s+where|;|$)", Pattern.CASE_INSENSITIVE); + + // Process each row of the CSV (from SqlExtractor) + while ((row = csvReader.readLine()) != null) { + if (isFirstRow) { + isFirstRow = false; // Skip the header + continue; + } + + // Split the row into columns (fileName, startLine, endLine, sqlQuery) + String[] columns = row.split(",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)"); + if (columns.length < 4) continue; // Ensure row has the necessary columns + + String fileName = columns[0].replace("\"", ""); // Extract fileName + String startLine = columns[1].replace("\"", ""); // Extract startLine + String endLine = columns[2].replace("\"", ""); // Extract endLine + String sqlQuery = columns[3].replace("\"", ""); // Extract the SQL query + + // Capture the FROM clause + String fromClause = ""; + Matcher fromMatcher = fromPattern.matcher(sqlQuery); + if (fromMatcher.find()) { + fromClause = "FROM " + fromMatcher.group(1) + " " + fromMatcher.group(2); + } + + // Extract JOIN clauses including AND/OR conditions + Matcher joinMatcher = joinPattern.matcher(sqlQuery); + while (joinMatcher.find()) { + // Capture the full JOIN clause + String fullJoinClause = "JOIN " + joinMatcher.group(1) + " " + joinMatcher.group(2) + " ON " + joinMatcher.group(3).trim(); + + // Split the join conditions by AND/OR (but keep AND/OR in the condition for clarity) + String[] joinConditions = joinMatcher.group(3).split("(?<=\\))\\s+(AND|OR)\\s+"); + + // For each condition in the JOIN clause, create a new row + for (String condition : joinConditions) { + String joinRelationship = "JOIN " + joinMatcher.group(1) + " " + joinMatcher.group(2) + " ON " + condition.trim(); + + // Write fileName, startLine, endLine, fromClause, and each joinRelationship to the CSV + csvWriter.append(fileName).append(",") + .append(startLine).append(",") + .append(endLine).append(",") + .append("\"").append(fromClause).append("\",") + .append("\"").append(joinRelationship).append("\"\n"); + } + } + } + + csvReader.close(); + csvWriter.flush(); + csvWriter.close(); + + System.out.println("SQL FROM and JOIN relationships extraction complete. Results saved to: " + outputCsvFilePath); + + } catch (IOException e) { + e.printStackTrace(); + } + } + + public static void main(String[] args) { + if (args.length < 2) { + System.out.println("Usage: java SqlJoinRelationshipExtractor "); + return; + } + + String inputCsvFilePath = args[0]; + String outputCsvFilePath = args[1]; + + extractSqlJoins(inputCsvFilePath, outputCsvFilePath); + } +} diff --git a/extras/rdms/full_data_model_ohdsi.sql b/extras/rdms/full_data_model_ohdsi.sql new file mode 100644 index 00000000..f68efe65 --- /dev/null +++ b/extras/rdms/full_data_model_ohdsi.sql @@ -0,0 +1,1677 @@ +-- Strategus Tables +{DEFAULT @table_prefix = ''} +{DEFAULT @database_meta_data = database_meta_data} + +CREATE TABLE @database_schema.@table_prefix@database_meta_data ( + cdm_source_name VARCHAR, + cdm_source_abbreviation VARCHAR, + cdm_holder VARCHAR, + source_description VARCHAR, + source_documentation_reference VARCHAR, + cdm_etl_reference VARCHAR, + source_release_date DATE, + cdm_release_date DATE, + cdm_version VARCHAR, + cdm_version_concept_id INT, + vocabulary_version VARCHAR, + database_id VARCHAR NOT NULL, + max_obs_period_end_date DATE, + PRIMARY KEY(database_id) +); +-- CharacterizationModule Tables +{DEFAULT @table_prefix = ''} +{DEFAULT @c_time_to_event = c_time_to_event} +{DEFAULT @c_rechallenge_fail_case_series = c_rechallenge_fail_case_series} +{DEFAULT @c_dechallenge_rechallenge = c_dechallenge_rechallenge} +{DEFAULT @c_analysis_ref = c_analysis_ref} +{DEFAULT @c_covariate_ref = c_covariate_ref} +{DEFAULT @c_covariates = c_covariates} +{DEFAULT @c_covariates_continuous = c_covariates_continuous} +{DEFAULT @c_settings = c_settings} +{DEFAULT @c_cohort_details = c_cohort_details} +{DEFAULT @c_cohort_counts = c_cohort_counts} + +CREATE TABLE @database_schema.@table_prefix@c_time_to_event ( + database_id VARCHAR(100) NOT NULL, + target_cohort_definition_id BIGINT NOT NULL, + outcome_cohort_definition_id BIGINT NOT NULL, + outcome_type VARCHAR(100) NOT NULL, + target_outcome_type VARCHAR(40) NOT NULL, + time_to_event INT NOT NULL, + num_events INT, + time_scale VARCHAR(20) NOT NULL, + PRIMARY KEY(database_id,target_cohort_definition_id,outcome_cohort_definition_id,outcome_type,target_outcome_type,time_to_event,time_scale) +); + +CREATE TABLE @database_schema.@table_prefix@c_rechallenge_fail_case_series ( + database_id VARCHAR(100) NOT NULL, + dechallenge_stop_interval INT NOT NULL, + dechallenge_evaluation_window INT NOT NULL, + target_cohort_definition_id BIGINT NOT NULL, + outcome_cohort_definition_id BIGINT NOT NULL, + person_key INT NOT NULL, + subject_id BIGINT, + dechallenge_exposure_number INT, + dechallenge_exposure_start_date_offset INT, + dechallenge_exposure_end_date_offset INT, + dechallenge_outcome_number INT, + dechallenge_outcome_start_date_offset INT, + rechallenge_exposure_number INT, + rechallenge_exposure_start_date_offset INT, + rechallenge_exposure_end_date_offset INT, + rechallenge_outcome_number INT, + rechallenge_outcome_start_date_offset INT, + PRIMARY KEY(database_id,dechallenge_stop_interval,dechallenge_evaluation_window,target_cohort_definition_id,outcome_cohort_definition_id,person_key) +); + +CREATE TABLE @database_schema.@table_prefix@c_dechallenge_rechallenge ( + database_id VARCHAR(100) NOT NULL, + dechallenge_stop_interval INT NOT NULL, + dechallenge_evaluation_window INT NOT NULL, + target_cohort_definition_id BIGINT NOT NULL, + outcome_cohort_definition_id BIGINT NOT NULL, + num_exposure_eras INT, + num_persons_exposed INT, + num_cases INT, + dechallenge_attempt INT, + dechallenge_fail INT, + dechallenge_success INT, + rechallenge_attempt INT, + rechallenge_fail INT, + rechallenge_success INT, + pct_dechallenge_attempt FLOAT, + pct_dechallenge_success FLOAT, + pct_dechallenge_fail FLOAT, + pct_rechallenge_attempt FLOAT, + pct_rechallenge_success FLOAT, + pct_rechallenge_fail FLOAT, + PRIMARY KEY(database_id,dechallenge_stop_interval,dechallenge_evaluation_window,target_cohort_definition_id,outcome_cohort_definition_id) +); + +CREATE TABLE @database_schema.@table_prefix@c_analysis_ref ( + database_id VARCHAR(100) NOT NULL, + setting_id VARCHAR(30) NOT NULL, + analysis_id INT NOT NULL, + analysis_name VARCHAR, + domain_id VARCHAR, + start_day INT, + end_day INT, + is_binary VARCHAR(1), + missing_means_zero VARCHAR(1), + PRIMARY KEY(database_id,setting_id,analysis_id) +); + +CREATE TABLE @database_schema.@table_prefix@c_covariate_ref ( + database_id VARCHAR(100) NOT NULL, + setting_id VARCHAR(30) NOT NULL, + covariate_id BIGINT NOT NULL, + covariate_name VARCHAR, + analysis_id INT, + concept_id BIGINT, + value_as_concept_id INT, + collisions INT, + PRIMARY KEY(database_id,setting_id,covariate_id) +); + +CREATE TABLE @database_schema.@table_prefix@c_covariates ( + database_id VARCHAR(100) NOT NULL, + setting_id VARCHAR(30) NOT NULL, + cohort_type VARCHAR(12) NOT NULL, + target_cohort_id INT NOT NULL, + outcome_cohort_id INT NOT NULL, + min_characterization_mean FLOAT NOT NULL, + covariate_id BIGINT NOT NULL, + sum_value INT, + average_value FLOAT, + PRIMARY KEY(database_id,setting_id,cohort_type,target_cohort_id,outcome_cohort_id,min_characterization_mean,covariate_id) +); + +CREATE TABLE @database_schema.@table_prefix@c_covariates_continuous ( + database_id VARCHAR(100) NOT NULL, + setting_id VARCHAR(30) NOT NULL, + cohort_type VARCHAR(12) NOT NULL, + target_cohort_id INT NOT NULL, + outcome_cohort_id INT NOT NULL, + covariate_id BIGINT NOT NULL, + count_value INT, + min_value FLOAT, + max_value FLOAT, + average_value FLOAT, + standard_deviation FLOAT, + median_value FLOAT, + p_10_value FLOAT, + p_25_value FLOAT, + p_75_value FLOAT, + p_90_value FLOAT, + PRIMARY KEY(database_id,setting_id,cohort_type,target_cohort_id,outcome_cohort_id,covariate_id) +); + +CREATE TABLE @database_schema.@table_prefix@c_settings ( + setting_id VARCHAR(30) NOT NULL, + database_id VARCHAR(100) NOT NULL, + covariate_setting_json VARCHAR, + case_covariate_setting_json VARCHAR, + min_prior_observation INT, + outcome_washout_days INT, + risk_window_start INT, + risk_window_end INT, + start_anchor VARCHAR(15), + end_anchor VARCHAR(15), + case_pre_target_duration INT, + case_post_outcome_duration INT, + PRIMARY KEY(setting_id,database_id) +); + +CREATE TABLE @database_schema.@table_prefix@c_cohort_details ( + database_id VARCHAR(100) NOT NULL, + setting_id VARCHAR(30) NOT NULL, + cohort_type VARCHAR(12) NOT NULL, + target_cohort_id INT NOT NULL, + outcome_cohort_id INT NOT NULL, + PRIMARY KEY(database_id,setting_id,cohort_type,target_cohort_id,outcome_cohort_id) +); + +CREATE TABLE @database_schema.@table_prefix@c_cohort_counts ( + database_id VARCHAR(100), + cohort_type VARCHAR(12), + target_cohort_id INT, + outcome_cohort_id INT, + risk_window_start INT, + risk_window_end INT, + start_anchor VARCHAR(15), + end_anchor VARCHAR(15), + min_prior_observation INT, + outcome_washout_days INT, + row_count INT, + person_count INT, + min_exposure_time BIGINT, + mean_exposure_time BIGINT, + max_exposure_time BIGINT +); +-- CohortDiagnosticsModule Tables +{DEFAULT @table_prefix = ''} +{DEFAULT @cd_cohort = cd_cohort} +{DEFAULT @cd_subset_definition = cd_subset_definition} +{DEFAULT @cd_cohort_count = cd_cohort_count} +{DEFAULT @cd_cohort_inclusion = cd_cohort_inclusion} +{DEFAULT @cd_cohort_inc_result = cd_cohort_inc_result} +{DEFAULT @cd_cohort_inc_stats = cd_cohort_inc_stats} +{DEFAULT @cd_cohort_relationships = cd_cohort_relationships} +{DEFAULT @cd_cohort_summary_stats = cd_cohort_summary_stats} +{DEFAULT @cd_concept = cd_concept} +{DEFAULT @cd_concept_ancestor = cd_concept_ancestor} +{DEFAULT @cd_concept_relationship = cd_concept_relationship} +{DEFAULT @cd_concept_sets = cd_concept_sets} +{DEFAULT @cd_concept_synonym = cd_concept_synonym} +{DEFAULT @cd_database = cd_database} +{DEFAULT @cd_domain = cd_domain} +{DEFAULT @cd_incidence_rate = cd_incidence_rate} +{DEFAULT @cd_included_source_concept = cd_included_source_concept} +{DEFAULT @cd_index_event_breakdown = cd_index_event_breakdown} +{DEFAULT @cd_metadata = cd_metadata} +{DEFAULT @cd_orphan_concept = cd_orphan_concept} +{DEFAULT @cd_relationship = cd_relationship} +{DEFAULT @cd_resolved_concepts = cd_resolved_concepts} +{DEFAULT @cd_temporal_analysis_ref = cd_temporal_analysis_ref} +{DEFAULT @cd_temporal_covariate_ref = cd_temporal_covariate_ref} +{DEFAULT @cd_temporal_covariate_value = cd_temporal_covariate_value} +{DEFAULT @cd_temporal_covariate_value_dist = cd_temporal_covariate_value_dist} +{DEFAULT @cd_temporal_time_ref = cd_temporal_time_ref} +{DEFAULT @cd_time_series = cd_time_series} +{DEFAULT @cd_visit_context = cd_visit_context} +{DEFAULT @cd_vocabulary = cd_vocabulary} + +CREATE TABLE @database_schema.@table_prefix@cd_cohort ( + cohort_id BIGINT NOT NULL, + cohort_name VARCHAR, + metadata VARCHAR, + json VARCHAR, + sql VARCHAR, + subset_parent BIGINT, + subset_definition_id BIGINT, + is_subset INT, + PRIMARY KEY(cohort_id) +); + +CREATE TABLE @database_schema.@table_prefix@cd_subset_definition ( + subset_definition_id BIGINT NOT NULL, + json VARCHAR NOT NULL, + PRIMARY KEY(subset_definition_id,json) +); + +CREATE TABLE @database_schema.@table_prefix@cd_cohort_count ( + cohort_id BIGINT NOT NULL, + cohort_entries FLOAT, + cohort_subjects FLOAT, + database_id VARCHAR NOT NULL, + PRIMARY KEY(cohort_id,database_id) +); + +CREATE TABLE @database_schema.@table_prefix@cd_cohort_inclusion ( + database_id VARCHAR NOT NULL, + cohort_id BIGINT NOT NULL, + rule_sequence BIGINT NOT NULL, + name VARCHAR, + description VARCHAR, + PRIMARY KEY(database_id,cohort_id,rule_sequence) +); + +CREATE TABLE @database_schema.@table_prefix@cd_cohort_inc_result ( + database_id VARCHAR NOT NULL, + cohort_id BIGINT NOT NULL, + mode_id BIGINT NOT NULL, + inclusion_rule_mask BIGINT NOT NULL, + person_count FLOAT, + PRIMARY KEY(database_id,cohort_id,mode_id,inclusion_rule_mask) +); + +CREATE TABLE @database_schema.@table_prefix@cd_cohort_inc_stats ( + database_id VARCHAR NOT NULL, + cohort_id BIGINT NOT NULL, + rule_sequence BIGINT NOT NULL, + mode_id BIGINT NOT NULL, + person_count FLOAT, + gain_count FLOAT, + person_total FLOAT, + PRIMARY KEY(database_id,cohort_id,rule_sequence,mode_id) +); + +CREATE TABLE @database_schema.@table_prefix@cd_cohort_relationships ( + database_id VARCHAR NOT NULL, + cohort_id BIGINT NOT NULL, + comparator_cohort_id BIGINT NOT NULL, + start_day BIGINT NOT NULL, + end_day FLOAT NOT NULL, + subjects BIGINT, + sub_cs_before_ts BIGINT, + sub_cs_on_ts BIGINT, + sub_cs_after_ts BIGINT, + sub_cs_before_te BIGINT, + sub_cs_on_te BIGINT, + sub_cs_after_te BIGINT, + sub_cs_window_t BIGINT, + sub_ce_window_t BIGINT, + sub_cs_window_ts BIGINT, + sub_cs_window_te BIGINT, + sub_ce_window_ts BIGINT, + sub_ce_window_te BIGINT, + sub_c_within_t BIGINT, + c_days_before_ts BIGINT, + c_days_before_te BIGINT, + c_days_within_t_days BIGINT, + c_days_after_ts BIGINT, + c_days_after_te BIGINT, + t_days BIGINT, + c_days BIGINT, + PRIMARY KEY(database_id,cohort_id,comparator_cohort_id,start_day,end_day) +); + +CREATE TABLE @database_schema.@table_prefix@cd_cohort_summary_stats ( + database_id VARCHAR NOT NULL, + cohort_id BIGINT NOT NULL, + mode_id BIGINT NOT NULL, + base_count FLOAT, + final_count FLOAT, + PRIMARY KEY(database_id,cohort_id,mode_id) +); + +CREATE TABLE @database_schema.@table_prefix@cd_concept ( + concept_id BIGINT NOT NULL, + concept_name VARCHAR(255), + domain_id VARCHAR(20), + vocabulary_id VARCHAR(50), + concept_class_id VARCHAR(20), + standard_concept VARCHAR(1), + concept_code VARCHAR(255), + valid_start_date DATE, + valid_end_date DATE, + invalid_reason VARCHAR, + PRIMARY KEY(concept_id) +); + +CREATE TABLE @database_schema.@table_prefix@cd_concept_ancestor ( + ancestor_concept_id BIGINT NOT NULL, + descendant_concept_id BIGINT NOT NULL, + min_levels_of_separation INT, + max_levels_of_separation INT, + PRIMARY KEY(ancestor_concept_id,descendant_concept_id) +); + +CREATE TABLE @database_schema.@table_prefix@cd_concept_relationship ( + concept_id_1 BIGINT NOT NULL, + concept_id_2 BIGINT NOT NULL, + relationship_id VARCHAR(20) NOT NULL, + valid_start_date DATE, + valid_end_date DATE, + invalid_reason VARCHAR(1), + PRIMARY KEY(concept_id_1,concept_id_2,relationship_id) +); + +CREATE TABLE @database_schema.@table_prefix@cd_concept_sets ( + cohort_id BIGINT NOT NULL, + concept_set_id INT NOT NULL, + concept_set_sql VARCHAR, + concept_set_name VARCHAR(255), + concept_set_expression VARCHAR, + PRIMARY KEY(cohort_id,concept_set_id) +); + +CREATE TABLE @database_schema.@table_prefix@cd_concept_synonym ( + concept_id BIGINT NOT NULL, + concept_synonym_name VARCHAR NOT NULL, + language_concept_id BIGINT NOT NULL, + PRIMARY KEY(concept_id,concept_synonym_name,language_concept_id) +); + +CREATE TABLE @database_schema.@table_prefix@cd_database ( + database_id VARCHAR NOT NULL, + database_name VARCHAR, + description VARCHAR, + is_meta_analysis VARCHAR(1), + vocabulary_version VARCHAR, + vocabulary_version_cdm VARCHAR, + PRIMARY KEY(database_id) +); + +CREATE TABLE @database_schema.@table_prefix@cd_domain ( + domain_id VARCHAR(20) NOT NULL, + domain_name VARCHAR(255), + domain_concept_id BIGINT, + PRIMARY KEY(domain_id) +); + +CREATE TABLE @database_schema.@table_prefix@cd_incidence_rate ( + cohort_count FLOAT, + person_years FLOAT, + gender VARCHAR NOT NULL, + age_group VARCHAR NOT NULL, + calendar_year VARCHAR(4) NOT NULL, + incidence_rate FLOAT, + cohort_id BIGINT NOT NULL, + database_id VARCHAR NOT NULL, + PRIMARY KEY(gender,age_group,calendar_year,cohort_id,database_id) +); + +CREATE TABLE @database_schema.@table_prefix@cd_included_source_concept ( + database_id VARCHAR NOT NULL, + cohort_id BIGINT NOT NULL, + concept_set_id INT NOT NULL, + concept_id BIGINT NOT NULL, + source_concept_id BIGINT NOT NULL, + concept_subjects FLOAT, + concept_count FLOAT, + PRIMARY KEY(database_id,cohort_id,concept_set_id,concept_id,source_concept_id) +); + +CREATE TABLE @database_schema.@table_prefix@cd_index_event_breakdown ( + concept_id BIGINT NOT NULL, + concept_count FLOAT, + subject_count FLOAT, + cohort_id BIGINT NOT NULL, + database_id VARCHAR NOT NULL, + domain_field VARCHAR NOT NULL, + domain_table VARCHAR NOT NULL, + PRIMARY KEY(concept_id,cohort_id,database_id,domain_field,domain_table) +); + +CREATE TABLE @database_schema.@table_prefix@cd_metadata ( + database_id VARCHAR NOT NULL, + start_time VARCHAR NOT NULL, + variable_field VARCHAR NOT NULL, + value_field VARCHAR, + PRIMARY KEY(database_id,start_time,variable_field) +); + +CREATE TABLE @database_schema.@table_prefix@cd_orphan_concept ( + cohort_id BIGINT NOT NULL, + concept_set_id INT NOT NULL, + database_id VARCHAR NOT NULL, + concept_id BIGINT NOT NULL, + concept_count FLOAT, + concept_subjects FLOAT, + PRIMARY KEY(cohort_id,concept_set_id,database_id,concept_id) +); + +CREATE TABLE @database_schema.@table_prefix@cd_relationship ( + relationship_id VARCHAR(20) NOT NULL, + relationship_name VARCHAR(255), + is_hierarchical VARCHAR(1), + defines_ancestry VARCHAR(1), + reverse_relationship_id VARCHAR(20) NOT NULL, + relationship_concept_id BIGINT NOT NULL, + PRIMARY KEY(relationship_id,reverse_relationship_id,relationship_concept_id) +); + +CREATE TABLE @database_schema.@table_prefix@cd_resolved_concepts ( + cohort_id BIGINT NOT NULL, + concept_set_id INT NOT NULL, + concept_id BIGINT NOT NULL, + database_id VARCHAR NOT NULL, + PRIMARY KEY(cohort_id,concept_set_id,concept_id,database_id) +); + +CREATE TABLE @database_schema.@table_prefix@cd_temporal_analysis_ref ( + analysis_id INT NOT NULL, + analysis_name VARCHAR, + domain_id VARCHAR(20) NOT NULL, + is_binary VARCHAR(1), + missing_means_zero VARCHAR(1), + PRIMARY KEY(analysis_id,domain_id) +); + +CREATE TABLE @database_schema.@table_prefix@cd_temporal_covariate_ref ( + covariate_id BIGINT NOT NULL, + covariate_name VARCHAR, + analysis_id INT, + concept_id BIGINT, + PRIMARY KEY(covariate_id) +); + +CREATE TABLE @database_schema.@table_prefix@cd_temporal_covariate_value ( + cohort_id BIGINT NOT NULL, + time_id INT NOT NULL, + covariate_id BIGINT NOT NULL, + sum_value FLOAT, + mean FLOAT, + sd FLOAT, + database_id VARCHAR NOT NULL, + PRIMARY KEY(cohort_id,time_id,covariate_id,database_id) +); + +CREATE TABLE @database_schema.@table_prefix@cd_temporal_covariate_value_dist ( + cohort_id BIGINT NOT NULL, + time_id INT NOT NULL, + covariate_id BIGINT NOT NULL, + count_value FLOAT, + min_value FLOAT, + max_value FLOAT, + mean FLOAT, + sd FLOAT, + median_value FLOAT, + p_10_value FLOAT, + p_25_value FLOAT, + p_75_value FLOAT, + p_90_value FLOAT, + database_id VARCHAR NOT NULL, + PRIMARY KEY(cohort_id,time_id,covariate_id,database_id) +); + +CREATE TABLE @database_schema.@table_prefix@cd_temporal_time_ref ( + time_id INT NOT NULL, + start_day FLOAT, + end_day FLOAT, + PRIMARY KEY(time_id) +); + +CREATE TABLE @database_schema.@table_prefix@cd_time_series ( + cohort_id BIGINT NOT NULL, + database_id VARCHAR NOT NULL, + period_begin DATE NOT NULL, + period_end DATE NOT NULL, + series_type VARCHAR NOT NULL, + calendar_interval VARCHAR NOT NULL, + gender VARCHAR NOT NULL, + age_group VARCHAR NOT NULL, + records BIGINT, + subjects BIGINT, + person_days BIGINT, + person_days_in BIGINT, + records_start BIGINT, + subjects_start BIGINT, + subjects_start_in BIGINT, + records_end BIGINT, + subjects_end BIGINT, + subjects_end_in BIGINT, + PRIMARY KEY(cohort_id,database_id,period_begin,period_end,series_type,calendar_interval,gender,age_group) +); + +CREATE TABLE @database_schema.@table_prefix@cd_visit_context ( + cohort_id BIGINT NOT NULL, + visit_concept_id BIGINT NOT NULL, + visit_context VARCHAR NOT NULL, + subjects FLOAT, + database_id VARCHAR NOT NULL, + PRIMARY KEY(cohort_id,visit_concept_id,visit_context,database_id) +); + +CREATE TABLE @database_schema.@table_prefix@cd_vocabulary ( + vocabulary_id VARCHAR(50), + vocabulary_name VARCHAR(255), + vocabulary_reference VARCHAR, + vocabulary_version VARCHAR, + vocabulary_concept_id BIGINT +); +-- CohortGeneratorModule Tables +{DEFAULT @table_prefix = ''} +{DEFAULT @cg_cohort_definition = cg_cohort_definition} +{DEFAULT @cg_cohort_generation = cg_cohort_generation} +{DEFAULT @cg_cohort_inclusion = cg_cohort_inclusion} +{DEFAULT @cg_cohort_inc_result = cg_cohort_inc_result} +{DEFAULT @cg_cohort_inc_stats = cg_cohort_inc_stats} +{DEFAULT @cg_cohort_summary_stats = cg_cohort_summary_stats} +{DEFAULT @cg_cohort_censor_stats = cg_cohort_censor_stats} +{DEFAULT @cg_cohort_count = cg_cohort_count} +{DEFAULT @cg_cohort_count_neg_ctrl = cg_cohort_count_neg_ctrl} +{DEFAULT @cg_cohort_subset_definition = cg_cohort_subset_definition} +{DEFAULT @cg_cohort_definition_neg_ctrl = cg_cohort_definition_neg_ctrl} + +CREATE TABLE @database_schema.@table_prefix@cg_cohort_definition ( + cohort_definition_id BIGINT NOT NULL, + cohort_name VARCHAR, + description VARCHAR, + json TEXT, + sql_command TEXT, + subset_parent BIGINT, + is_subset INT, + subset_definition_id BIGINT, + PRIMARY KEY(cohort_definition_id) +); + +CREATE TABLE @database_schema.@table_prefix@cg_cohort_generation ( + cohort_id BIGINT NOT NULL, + cohort_name VARCHAR, + generation_status VARCHAR, + start_time TIMESTAMP, + end_time TIMESTAMP, + database_id VARCHAR NOT NULL, + PRIMARY KEY(cohort_id,database_id) +); + +CREATE TABLE @database_schema.@table_prefix@cg_cohort_inclusion ( + cohort_definition_id BIGINT NOT NULL, + rule_sequence INT NOT NULL, + name VARCHAR NOT NULL, + description VARCHAR, + PRIMARY KEY(cohort_definition_id,rule_sequence,name) +); + +CREATE TABLE @database_schema.@table_prefix@cg_cohort_inc_result ( + database_id VARCHAR NOT NULL, + cohort_definition_id BIGINT NOT NULL, + inclusion_rule_mask INT NOT NULL, + person_count BIGINT NOT NULL, + mode_id INT NOT NULL, + PRIMARY KEY(database_id,cohort_definition_id,inclusion_rule_mask,person_count,mode_id) +); + +CREATE TABLE @database_schema.@table_prefix@cg_cohort_inc_stats ( + database_id VARCHAR NOT NULL, + cohort_definition_id BIGINT NOT NULL, + rule_sequence INT NOT NULL, + person_count BIGINT NOT NULL, + gain_count BIGINT NOT NULL, + person_total BIGINT NOT NULL, + mode_id INT NOT NULL, + PRIMARY KEY(database_id,cohort_definition_id,rule_sequence,person_count,gain_count,person_total,mode_id) +); + +CREATE TABLE @database_schema.@table_prefix@cg_cohort_summary_stats ( + database_id VARCHAR NOT NULL, + cohort_definition_id BIGINT NOT NULL, + base_count BIGINT NOT NULL, + final_count BIGINT NOT NULL, + mode_id INT NOT NULL, + PRIMARY KEY(database_id,cohort_definition_id,base_count,final_count,mode_id) +); + +CREATE TABLE @database_schema.@table_prefix@cg_cohort_censor_stats ( + cohort_definition_id BIGINT NOT NULL, + lost_count BIGINT NOT NULL, + database_id VARCHAR NOT NULL, + PRIMARY KEY(cohort_definition_id,lost_count,database_id) +); + +CREATE TABLE @database_schema.@table_prefix@cg_cohort_count ( + database_id VARCHAR NOT NULL, + cohort_id BIGINT NOT NULL, + cohort_entries BIGINT NOT NULL, + cohort_subjects BIGINT NOT NULL, + PRIMARY KEY(database_id,cohort_id,cohort_entries,cohort_subjects) +); + +CREATE TABLE @database_schema.@table_prefix@cg_cohort_count_neg_ctrl ( + database_id VARCHAR NOT NULL, + cohort_id BIGINT NOT NULL, + cohort_entries BIGINT NOT NULL, + cohort_subjects BIGINT NOT NULL, + PRIMARY KEY(database_id,cohort_id,cohort_entries,cohort_subjects) +); + +CREATE TABLE @database_schema.@table_prefix@cg_cohort_subset_definition ( + subset_definition_id BIGINT NOT NULL, + json TEXT, + PRIMARY KEY(subset_definition_id) +); + +CREATE TABLE @database_schema.@table_prefix@cg_cohort_definition_neg_ctrl ( + cohort_id BIGINT NOT NULL, + outcome_concept_id BIGINT, + cohort_name VARCHAR, + occurrence_type VARCHAR, + detect_on_descendants INT, + PRIMARY KEY(cohort_id) +); +-- CohortIncidenceModule Tables +{DEFAULT @table_prefix = ''} +{DEFAULT @ci_incidence_summary = ci_incidence_summary} +{DEFAULT @ci_target_def = ci_target_def} +{DEFAULT @ci_outcome_def = ci_outcome_def} +{DEFAULT @ci_tar_def = ci_tar_def} +{DEFAULT @ci_age_group_def = ci_age_group_def} +{DEFAULT @ci_subgroup_def = ci_subgroup_def} +{DEFAULT @ci_target_outcome_ref = ci_target_outcome_ref} + +CREATE TABLE @database_schema.@table_prefix@ci_incidence_summary ( + ref_id INT, + database_id VARCHAR(255), + source_name VARCHAR(255), + target_cohort_definition_id BIGINT, + tar_id BIGINT, + subgroup_id BIGINT, + outcome_id BIGINT, + age_group_id INT, + gender_id INT, + gender_name VARCHAR(255), + start_year INT, + persons_at_risk_pe BIGINT, + persons_at_risk BIGINT, + person_days_pe BIGINT, + person_days BIGINT, + person_outcomes_pe BIGINT, + person_outcomes BIGINT, + outcomes_pe BIGINT, + outcomes BIGINT, + incidence_proportion_p100p FLOAT, + incidence_rate_p100py FLOAT +); + +CREATE TABLE @database_schema.@table_prefix@ci_target_def ( + ref_id INT NOT NULL, + target_cohort_definition_id BIGINT NOT NULL, + target_name VARCHAR(255), + PRIMARY KEY(ref_id,target_cohort_definition_id) +); + +CREATE TABLE @database_schema.@table_prefix@ci_outcome_def ( + ref_id INT NOT NULL, + outcome_id BIGINT NOT NULL, + outcome_cohort_definition_id BIGINT, + outcome_name VARCHAR(255), + clean_window BIGINT, + excluded_cohort_definition_id BIGINT, + PRIMARY KEY(ref_id,outcome_id) +); + +CREATE TABLE @database_schema.@table_prefix@ci_tar_def ( + ref_id INT NOT NULL, + tar_id BIGINT NOT NULL, + tar_start_with VARCHAR(10), + tar_start_offset BIGINT, + tar_end_with VARCHAR(10), + tar_end_offset BIGINT, + PRIMARY KEY(ref_id,tar_id) +); + +CREATE TABLE @database_schema.@table_prefix@ci_age_group_def ( + ref_id INT NOT NULL, + age_group_id INT NOT NULL, + age_group_name VARCHAR(255), + min_age INT, + max_age INT, + PRIMARY KEY(ref_id,age_group_id) +); + +CREATE TABLE @database_schema.@table_prefix@ci_subgroup_def ( + ref_id INT NOT NULL, + subgroup_id BIGINT NOT NULL, + subgroup_name VARCHAR(255), + PRIMARY KEY(ref_id,subgroup_id) +); + +CREATE TABLE @database_schema.@table_prefix@ci_target_outcome_ref ( + ref_id INT NOT NULL, + target_cohort_id BIGINT NOT NULL, + outcome_cohort_id BIGINT NOT NULL, + PRIMARY KEY(ref_id,target_cohort_id,outcome_cohort_id) +); +-- CohortMethodModule Tables +{DEFAULT @table_prefix = ''} +{DEFAULT @cm_attrition = cm_attrition} +{DEFAULT @cm_follow_up_dist = cm_follow_up_dist} +{DEFAULT @cm_analysis = cm_analysis} +{DEFAULT @cm_result = cm_result} +{DEFAULT @cm_interaction_result = cm_interaction_result} +{DEFAULT @cm_covariate = cm_covariate} +{DEFAULT @cm_covariate_analysis = cm_covariate_analysis} +{DEFAULT @cm_covariate_balance = cm_covariate_balance} +{DEFAULT @cm_diagnostics_summary = cm_diagnostics_summary} +{DEFAULT @cm_target_comparator_outcome = cm_target_comparator_outcome} +{DEFAULT @cm_kaplan_meier_dist = cm_kaplan_meier_dist} +{DEFAULT @cm_likelihood_profile = cm_likelihood_profile} +{DEFAULT @cm_preference_score_dist = cm_preference_score_dist} +{DEFAULT @cm_propensity_model = cm_propensity_model} +{DEFAULT @cm_shared_covariate_balance = cm_shared_covariate_balance} + +CREATE TABLE @database_schema.@table_prefix@cm_attrition ( + sequence_number INT NOT NULL, + description VARCHAR, + subjects INT, + exposure_id BIGINT NOT NULL, + target_id BIGINT NOT NULL, + comparator_id BIGINT NOT NULL, + analysis_id INT NOT NULL, + outcome_id BIGINT NOT NULL, + database_id VARCHAR NOT NULL, + PRIMARY KEY(sequence_number,exposure_id,target_id,comparator_id,analysis_id,outcome_id,database_id) +); + +CREATE TABLE @database_schema.@table_prefix@cm_follow_up_dist ( + target_id BIGINT NOT NULL, + comparator_id BIGINT NOT NULL, + outcome_id BIGINT NOT NULL, + analysis_id INT NOT NULL, + target_min_days FLOAT, + target_p_10_days FLOAT, + target_p_25_days FLOAT, + target_median_days FLOAT, + target_p_75_days FLOAT, + target_p_90_days FLOAT, + target_max_days FLOAT, + comparator_min_days FLOAT, + comparator_p_10_days FLOAT, + comparator_p_25_days FLOAT, + comparator_median_days FLOAT, + comparator_p_75_days FLOAT, + comparator_p_90_days FLOAT, + comparator_max_days FLOAT, + target_min_date DATE, + target_max_date DATE, + comparator_min_date DATE, + comparator_max_date DATE, + database_id VARCHAR NOT NULL, + PRIMARY KEY(target_id,comparator_id,outcome_id,analysis_id,database_id) +); + +CREATE TABLE @database_schema.@table_prefix@cm_analysis ( + analysis_id INT NOT NULL, + description VARCHAR, + definition VARCHAR, + PRIMARY KEY(analysis_id) +); + +CREATE TABLE @database_schema.@table_prefix@cm_result ( + analysis_id INT NOT NULL, + target_id BIGINT NOT NULL, + comparator_id BIGINT NOT NULL, + outcome_id BIGINT NOT NULL, + rr FLOAT, + ci_95_lb FLOAT, + ci_95_ub FLOAT, + p FLOAT, + one_sided_p FLOAT, + target_subjects INT, + comparator_subjects INT, + target_days INT, + comparator_days INT, + target_outcomes INT, + comparator_outcomes INT, + log_rr FLOAT, + se_log_rr FLOAT, + llr FLOAT, + calibrated_rr FLOAT, + calibrated_ci_95_lb FLOAT, + calibrated_ci_95_ub FLOAT, + calibrated_p FLOAT, + calibrated_one_sided_p FLOAT, + calibrated_log_rr FLOAT, + calibrated_se_log_rr FLOAT, + target_estimator VARCHAR, + database_id VARCHAR NOT NULL, + PRIMARY KEY(analysis_id,target_id,comparator_id,outcome_id,database_id) +); + +CREATE TABLE @database_schema.@table_prefix@cm_interaction_result ( + analysis_id INT NOT NULL, + target_id BIGINT NOT NULL, + comparator_id BIGINT NOT NULL, + outcome_id BIGINT NOT NULL, + interaction_covariate_id INT NOT NULL, + rr FLOAT, + ci_95_lb FLOAT, + ci_95_ub FLOAT, + p FLOAT, + target_subjects INT, + comparator_subjects INT, + target_days INT, + comparator_days INT, + target_outcomes INT, + comparator_outcomes INT, + log_rr FLOAT, + se_log_rr FLOAT, + calibrated_rr FLOAT, + calibrated_ci_95_lb FLOAT, + calibrated_ci_95_ub FLOAT, + calibrated_p FLOAT, + calibrated_log_rr FLOAT, + calibrated_se_log_rr FLOAT, + target_estimator VARCHAR, + database_id VARCHAR NOT NULL, + PRIMARY KEY(analysis_id,target_id,comparator_id,outcome_id,interaction_covariate_id,database_id) +); + +CREATE TABLE @database_schema.@table_prefix@cm_covariate ( + covariate_id BIGINT NOT NULL, + covariate_name VARCHAR, + analysis_id INT NOT NULL, + covariate_analysis_id INT, + database_id VARCHAR NOT NULL, + PRIMARY KEY(covariate_id,analysis_id,database_id) +); + +CREATE TABLE @database_schema.@table_prefix@cm_covariate_analysis ( + covariate_analysis_id INT NOT NULL, + covariate_analysis_name VARCHAR, + analysis_id INT NOT NULL, + PRIMARY KEY(covariate_analysis_id,analysis_id) +); + +CREATE TABLE @database_schema.@table_prefix@cm_covariate_balance ( + database_id VARCHAR NOT NULL, + target_id BIGINT NOT NULL, + comparator_id BIGINT NOT NULL, + outcome_id BIGINT NOT NULL, + analysis_id INT NOT NULL, + covariate_id BIGINT NOT NULL, + target_mean_before FLOAT, + comparator_mean_before FLOAT, + mean_before FLOAT, + std_diff_before FLOAT, + mean_after FLOAT, + target_mean_after FLOAT, + comparator_mean_after FLOAT, + std_diff_after FLOAT, + target_std_diff FLOAT, + comparator_std_diff FLOAT, + target_comparator_std_diff FLOAT, + PRIMARY KEY(database_id,target_id,comparator_id,outcome_id,analysis_id,covariate_id) +); + +CREATE TABLE @database_schema.@table_prefix@cm_diagnostics_summary ( + analysis_id INT NOT NULL, + target_id BIGINT NOT NULL, + comparator_id BIGINT NOT NULL, + outcome_id BIGINT NOT NULL, + database_id VARCHAR NOT NULL, + max_sdm FLOAT, + shared_max_sdm FLOAT, + equipoise FLOAT, + mdrr FLOAT, + attrition_fraction FLOAT, + generalizability_max_sdm FLOAT, + ease FLOAT, + balance_diagnostic VARCHAR(20), + shared_balance_diagnostic VARCHAR(20), + equipoise_diagnostic VARCHAR(20), + mdrr_diagnostic VARCHAR(20), + attrition_diagnostic VARCHAR(20), + generalizability_diagnostic VARCHAR(20), + ease_diagnostic VARCHAR(20), + unblind INT, + unblind_for_evidence_synthesis INT, + PRIMARY KEY(analysis_id,target_id,comparator_id,outcome_id,database_id) +); + +CREATE TABLE @database_schema.@table_prefix@cm_target_comparator_outcome ( + outcome_id BIGINT NOT NULL, + outcome_of_interest INT, + true_effect_size FLOAT, + target_id BIGINT NOT NULL, + comparator_id BIGINT NOT NULL, + PRIMARY KEY(outcome_id,target_id,comparator_id) +); + +CREATE TABLE @database_schema.@table_prefix@cm_kaplan_meier_dist ( + time_day INT NOT NULL, + target_survival FLOAT, + target_survival_lb FLOAT, + target_survival_ub FLOAT, + comparator_survival FLOAT, + comparator_survival_lb FLOAT, + comparator_survival_ub FLOAT, + target_at_risk INT, + comparator_at_risk INT, + target_id BIGINT NOT NULL, + comparator_id BIGINT NOT NULL, + outcome_id BIGINT NOT NULL, + analysis_id INT NOT NULL, + database_id VARCHAR NOT NULL, + PRIMARY KEY(time_day,target_id,comparator_id,outcome_id,analysis_id,database_id) +); + +CREATE TABLE @database_schema.@table_prefix@cm_likelihood_profile ( + log_rr FLOAT NOT NULL, + log_likelihood FLOAT, + target_id BIGINT NOT NULL, + comparator_id BIGINT NOT NULL, + outcome_id BIGINT NOT NULL, + analysis_id INT NOT NULL, + database_id VARCHAR NOT NULL, + PRIMARY KEY(log_rr,target_id,comparator_id,outcome_id,analysis_id,database_id) +); + +CREATE TABLE @database_schema.@table_prefix@cm_preference_score_dist ( + analysis_id INT NOT NULL, + target_id BIGINT NOT NULL, + comparator_id BIGINT NOT NULL, + database_id VARCHAR NOT NULL, + preference_score FLOAT NOT NULL, + target_density FLOAT, + comparator_density FLOAT, + PRIMARY KEY(analysis_id,target_id,comparator_id,database_id,preference_score) +); + +CREATE TABLE @database_schema.@table_prefix@cm_propensity_model ( + target_id BIGINT NOT NULL, + comparator_id BIGINT NOT NULL, + analysis_id INT NOT NULL, + database_id VARCHAR NOT NULL, + covariate_id BIGINT NOT NULL, + coefficient FLOAT, + PRIMARY KEY(target_id,comparator_id,analysis_id,database_id,covariate_id) +); + +CREATE TABLE @database_schema.@table_prefix@cm_shared_covariate_balance ( + database_id VARCHAR NOT NULL, + target_id BIGINT NOT NULL, + comparator_id BIGINT NOT NULL, + analysis_id INT NOT NULL, + covariate_id BIGINT NOT NULL, + mean_before FLOAT, + target_mean_before FLOAT, + comparator_mean_before FLOAT, + std_diff_before FLOAT, + mean_after FLOAT, + target_mean_after FLOAT, + comparator_mean_after FLOAT, + std_diff_after FLOAT, + target_std_diff FLOAT, + comparator_std_diff FLOAT, + target_comparator_std_diff FLOAT, + PRIMARY KEY(database_id,target_id,comparator_id,analysis_id,covariate_id) +); +-- EvidenceSynthesisModule Tables +{DEFAULT @table_prefix = ''} +{DEFAULT @es_analysis = es_analysis} +{DEFAULT @es_cm_diagnostics_summary = es_cm_diagnostics_summary} +{DEFAULT @es_cm_result = es_cm_result} +{DEFAULT @es_sccs_diagnostics_summary = es_sccs_diagnostics_summary} +{DEFAULT @es_sccs_result = es_sccs_result} + +CREATE TABLE @database_schema.@table_prefix@es_analysis ( + evidence_synthesis_analysis_id INT NOT NULL, + evidence_synthesis_description VARCHAR(255), + source_method VARCHAR(100), + definition VARCHAR, + PRIMARY KEY(evidence_synthesis_analysis_id) +); + +CREATE TABLE @database_schema.@table_prefix@es_cm_diagnostics_summary ( + target_id INT NOT NULL, + comparator_id INT NOT NULL, + outcome_id INT NOT NULL, + analysis_id INT NOT NULL, + evidence_synthesis_analysis_id INT NOT NULL, + mdrr FLOAT, + i_2 FLOAT, + tau FLOAT, + ease FLOAT, + mdrr_diagnostic VARCHAR(13), + i_2_diagnostic VARCHAR(13), + tau_diagnostic VARCHAR(13), + ease_diagnostic VARCHAR(13), + unblind INT, + PRIMARY KEY(target_id,comparator_id,outcome_id,analysis_id,evidence_synthesis_analysis_id) +); + +CREATE TABLE @database_schema.@table_prefix@es_cm_result ( + target_id INT NOT NULL, + comparator_id INT NOT NULL, + outcome_id INT NOT NULL, + analysis_id INT NOT NULL, + evidence_synthesis_analysis_id INT NOT NULL, + rr FLOAT, + ci_95_lb FLOAT, + ci_95_ub FLOAT, + p FLOAT, + one_sided_p FLOAT, + log_rr FLOAT, + se_log_rr FLOAT, + target_subjects INT, + comparator_subjects INT, + target_days INT, + comparator_days INT, + target_outcomes INT, + comparator_outcomes INT, + n_databases INT, + calibrated_rr FLOAT, + calibrated_ci_95_lb FLOAT, + calibrated_ci_95_ub FLOAT, + calibrated_p FLOAT, + calibrated_one_sided_p FLOAT, + calibrated_log_rr FLOAT, + calibrated_se_log_rr FLOAT, + PRIMARY KEY(target_id,comparator_id,outcome_id,analysis_id,evidence_synthesis_analysis_id) +); + +CREATE TABLE @database_schema.@table_prefix@es_sccs_diagnostics_summary ( + exposures_outcome_set_id INT NOT NULL, + covariate_id INT NOT NULL, + analysis_id INT NOT NULL, + evidence_synthesis_analysis_id INT NOT NULL, + mdrr FLOAT, + i_2 FLOAT, + tau FLOAT, + ease FLOAT, + mdrr_diagnostic VARCHAR(13), + i_2_diagnostic VARCHAR(13), + tau_diagnostic VARCHAR(13), + ease_diagnostic VARCHAR(13), + unblind INT, + PRIMARY KEY(exposures_outcome_set_id,covariate_id,analysis_id,evidence_synthesis_analysis_id) +); + +CREATE TABLE @database_schema.@table_prefix@es_sccs_result ( + analysis_id INT NOT NULL, + exposures_outcome_set_id INT NOT NULL, + covariate_id INT NOT NULL, + evidence_synthesis_analysis_id INT NOT NULL, + rr FLOAT, + ci_95_lb FLOAT, + ci_95_ub FLOAT, + p FLOAT, + one_sided_p FLOAT, + outcome_subjects INT, + outcome_events INT, + outcome_observation_periods INT, + covariate_subjects INT, + covariate_days INT, + covariate_eras INT, + covariate_outcomes INT, + observed_days INT, + n_databases INT, + log_rr FLOAT, + se_log_rr FLOAT, + calibrated_rr FLOAT, + calibrated_ci_95_lb FLOAT, + calibrated_ci_95_ub FLOAT, + calibrated_p FLOAT, + calibrated_one_sided_p FLOAT, + calibrated_log_rr FLOAT, + calibrated_se_log_rr FLOAT, + PRIMARY KEY(analysis_id,exposures_outcome_set_id,covariate_id,evidence_synthesis_analysis_id) +); +-- PatientLevelPredictionModule Tables +{DEFAULT @table_prefix = ''} +{DEFAULT @plp_cohorts = plp_cohorts} +{DEFAULT @plp_cohort_definition = plp_cohort_definition} +{DEFAULT @plp_database_meta_data = plp_database_meta_data} +{DEFAULT @plp_database_details = plp_database_details} +{DEFAULT @plp_tars = plp_tars} +{DEFAULT @plp_population_settings = plp_population_settings} +{DEFAULT @plp_covariate_settings = plp_covariate_settings} +{DEFAULT @plp_model_settings = plp_model_settings} +{DEFAULT @plp_split_settings = plp_split_settings} +{DEFAULT @plp_plp_data_settings = plp_plp_data_settings} +{DEFAULT @plp_feature_engineering_settings = plp_feature_engineering_settings} +{DEFAULT @plp_tidy_covariates_settings = plp_tidy_covariates_settings} +{DEFAULT @plp_sample_settings = plp_sample_settings} +{DEFAULT @plp_model_designs = plp_model_designs} +{DEFAULT @plp_diagnostics = plp_diagnostics} +{DEFAULT @plp_diagnostic_summary = plp_diagnostic_summary} +{DEFAULT @plp_diagnostic_predictors = plp_diagnostic_predictors} +{DEFAULT @plp_diagnostic_participants = plp_diagnostic_participants} +{DEFAULT @plp_diagnostic_outcomes = plp_diagnostic_outcomes} +{DEFAULT @plp_diagnostic_designs = plp_diagnostic_designs} +{DEFAULT @plp_models = plp_models} +{DEFAULT @plp_recalibrations = plp_recalibrations} +{DEFAULT @plp_performances = plp_performances} +{DEFAULT @plp_attrition = plp_attrition} +{DEFAULT @plp_prediction_distribution = plp_prediction_distribution} +{DEFAULT @plp_covariate_summary = plp_covariate_summary} +{DEFAULT @plp_threshold_summary = plp_threshold_summary} +{DEFAULT @plp_calibration_summary = plp_calibration_summary} +{DEFAULT @plp_evaluation_statistics = plp_evaluation_statistics} +{DEFAULT @plp_demographic_summary = plp_demographic_summary} + +CREATE TABLE @database_schema.@table_prefix@plp_cohorts ( + cohort_id INT NOT NULL, + cohort_definition_id BIGINT, + cohort_name VARCHAR, + PRIMARY KEY(cohort_id) +); + +CREATE TABLE @database_schema.@table_prefix@plp_cohort_definition ( + cohort_definition_id BIGINT, + cohort_name VARCHAR, + description TEXT, + json TEXT, + sql_command TEXT +); + +CREATE TABLE @database_schema.@table_prefix@plp_database_meta_data ( + database_id VARCHAR NOT NULL, + cdm_source_name VARCHAR, + cdm_source_abbreviation VARCHAR, + cdm_holder VARCHAR, + source_description TEXT, + source_documentation_reference VARCHAR, + cdm_etl_reference VARCHAR, + source_release_date VARCHAR, + cdm_release_date VARCHAR, + cdm_version VARCHAR, + vocabulary_version VARCHAR, + max_obs_period_end_date VARCHAR, + PRIMARY KEY(database_id) +); + +CREATE TABLE @database_schema.@table_prefix@plp_database_details ( + database_id INT NOT NULL, + database_meta_data_id VARCHAR, + PRIMARY KEY(database_id) +); + +CREATE TABLE @database_schema.@table_prefix@plp_tars ( + tar_id INT NOT NULL, + tar_start_day INT, + tar_start_anchor VARCHAR, + tar_end_day INT, + tar_end_anchor VARCHAR, + PRIMARY KEY(tar_id) +); + +CREATE TABLE @database_schema.@table_prefix@plp_population_settings ( + population_setting_id INT NOT NULL, + population_settings_json TEXT, + PRIMARY KEY(population_setting_id) +); + +CREATE TABLE @database_schema.@table_prefix@plp_covariate_settings ( + covariate_setting_id INT NOT NULL, + covariate_settings_json TEXT, + PRIMARY KEY(covariate_setting_id) +); + +CREATE TABLE @database_schema.@table_prefix@plp_model_settings ( + model_setting_id INT NOT NULL, + model_type VARCHAR, + model_settings_json VARCHAR, + PRIMARY KEY(model_setting_id) +); + +CREATE TABLE @database_schema.@table_prefix@plp_split_settings ( + split_setting_id INT NOT NULL, + split_settings_json TEXT, + PRIMARY KEY(split_setting_id) +); + +CREATE TABLE @database_schema.@table_prefix@plp_plp_data_settings ( + plp_data_setting_id INT NOT NULL, + plp_data_settings_json TEXT, + PRIMARY KEY(plp_data_setting_id) +); + +CREATE TABLE @database_schema.@table_prefix@plp_feature_engineering_settings ( + feature_engineering_setting_id INT NOT NULL, + feature_engineering_settings_json TEXT, + PRIMARY KEY(feature_engineering_setting_id) +); + +CREATE TABLE @database_schema.@table_prefix@plp_tidy_covariates_settings ( + tidy_covariates_setting_id INT NOT NULL, + tidy_covariates_settings_json TEXT, + PRIMARY KEY(tidy_covariates_setting_id) +); + +CREATE TABLE @database_schema.@table_prefix@plp_sample_settings ( + sample_setting_id INT NOT NULL, + sample_settings_json TEXT, + PRIMARY KEY(sample_setting_id) +); + +CREATE TABLE @database_schema.@table_prefix@plp_model_designs ( + model_design_id INT NOT NULL, + target_id INT, + outcome_id INT, + tar_id INT, + plp_data_setting_id INT, + population_setting_id INT, + model_setting_id INT, + covariate_setting_id INT, + sample_setting_id INT, + split_setting_id INT, + feature_engineering_setting_id INT, + tidy_covariates_setting_id INT, + PRIMARY KEY(model_design_id) +); + +CREATE TABLE @database_schema.@table_prefix@plp_diagnostics ( + diagnostic_id INT NOT NULL, + model_design_id INT, + database_id INT, + execution_date_time VARCHAR, + PRIMARY KEY(diagnostic_id) +); + +CREATE TABLE @database_schema.@table_prefix@plp_diagnostic_summary ( + diagnostic_id INT, + probast_id VARCHAR, + result_value VARCHAR +); + +CREATE TABLE @database_schema.@table_prefix@plp_diagnostic_predictors ( + diagnostic_id INT, + days_to_event INT, + outcome_at_time INT, + observed_at_start_of_day BIGINT, + input_type VARCHAR +); + +CREATE TABLE @database_schema.@table_prefix@plp_diagnostic_participants ( + diagnostic_id INT, + design VARCHAR, + metric VARCHAR, + value FLOAT, + probast_id VARCHAR +); + +CREATE TABLE @database_schema.@table_prefix@plp_diagnostic_outcomes ( + diagnostic_id INT, + xvalue INT, + outcome_percent FLOAT, + aggregation VARCHAR, + probast_id VARCHAR, + input_type VARCHAR +); + +CREATE TABLE @database_schema.@table_prefix@plp_diagnostic_designs ( + diagnostic_id INT NOT NULL, + probast_id VARCHAR, + value VARCHAR, + PRIMARY KEY(diagnostic_id) +); + +CREATE TABLE @database_schema.@table_prefix@plp_models ( + model_id INT NOT NULL, + analysis_id VARCHAR, + model_design_id INT, + database_id INT, + model_type VARCHAR, + plp_model_file TEXT, + train_details TEXT, + preprocessing TEXT, + execution_date_time VARCHAR, + training_time VARCHAR, + intercept FLOAT, + PRIMARY KEY(model_id) +); + +CREATE TABLE @database_schema.@table_prefix@plp_recalibrations ( + recalibration_id INT NOT NULL, + original_model_id INT, + recalibrated_model_id INT, + recalibration_type VARCHAR, + recalibration_json VARCHAR, + PRIMARY KEY(recalibration_id) +); + +CREATE TABLE @database_schema.@table_prefix@plp_performances ( + performance_id INT NOT NULL, + model_design_id INT, + development_database_id INT, + validation_database_id INT, + target_id INT, + outcome_id INT, + tar_id INT, + plp_data_setting_id INT, + population_setting_id INT, + model_development INT, + execution_date_time VARCHAR, + plp_version VARCHAR, + PRIMARY KEY(performance_id) +); + +CREATE TABLE @database_schema.@table_prefix@plp_attrition ( + performance_id INT, + outcome_id INT, + description VARCHAR, + target_count INT, + unique_people INT, + outcomes INT +); + +CREATE TABLE @database_schema.@table_prefix@plp_prediction_distribution ( + performance_id INT, + evaluation VARCHAR, + class_label INT, + person_count INT, + average_predicted_probability FLOAT, + st_dev_predicted_probability FLOAT, + min_predicted_probability FLOAT, + p_05_predicted_probability FLOAT, + p_25_predicted_probability FLOAT, + median_predicted_probability FLOAT, + p_75_predicted_probability FLOAT, + p_95_predicted_probability FLOAT, + max_predicted_probability FLOAT +); + +CREATE TABLE @database_schema.@table_prefix@plp_covariate_summary ( + performance_id INT, + covariate_id BIGINT, + covariate_name VARCHAR, + concept_id FLOAT, + covariate_value FLOAT, + covariate_count INT, + covariate_mean FLOAT, + covariate_st_dev FLOAT, + with_no_outcome_covariate_count INT, + with_no_outcome_covariate_mean FLOAT, + with_no_outcome_covariate_st_dev FLOAT, + with_outcome_covariate_count INT, + with_outcome_covariate_mean FLOAT, + with_outcome_covariate_st_dev FLOAT, + standardized_mean_diff FLOAT +); + +CREATE TABLE @database_schema.@table_prefix@plp_threshold_summary ( + performance_id INT, + evaluation VARCHAR, + prediction_threshold FLOAT, + preference_threshold FLOAT, + positive_count INT, + negative_count INT, + true_count INT, + false_count INT, + true_positive_count INT, + true_negative_count INT, + false_positive_count INT, + false_negative_count INT, + f_1_score FLOAT, + accuracy FLOAT, + sensitivity FLOAT, + false_negative_rate FLOAT, + false_positive_rate FLOAT, + specificity FLOAT, + positive_predictive_value FLOAT, + false_discovery_rate FLOAT, + negative_predictive_value FLOAT, + false_omission_rate FLOAT, + positive_likelihood_ratio FLOAT, + negative_likelihood_ratio FLOAT, + diagnostic_odds_ratio FLOAT +); + +CREATE TABLE @database_schema.@table_prefix@plp_calibration_summary ( + performance_id INT, + evaluation VARCHAR, + prediction_threshold FLOAT, + person_count_at_risk INT, + person_count_with_outcome INT, + average_predicted_probability FLOAT, + st_dev_predicted_probability FLOAT, + min_predicted_probability FLOAT, + p_25_predicted_probability FLOAT, + median_predicted_probability FLOAT, + p_75_predicted_probability FLOAT, + max_predicted_probability FLOAT, + observed_incidence FLOAT +); + +CREATE TABLE @database_schema.@table_prefix@plp_evaluation_statistics ( + performance_id INT, + evaluation VARCHAR, + metric VARCHAR, + value FLOAT +); + +CREATE TABLE @database_schema.@table_prefix@plp_demographic_summary ( + performance_id INT, + evaluation VARCHAR, + age_group VARCHAR, + gen_group VARCHAR, + person_count_at_risk INT, + person_count_with_outcome INT, + average_predicted_probability FLOAT, + st_dev_predicted_probability FLOAT, + min_predicted_probability FLOAT, + p_25_predicted_probability FLOAT, + p_50_predicted_probability FLOAT, + p_75_predicted_probability FLOAT, + max_predicted_probability FLOAT +); +-- SelfControlledCaseSeriesModule Tables +{DEFAULT @table_prefix = ''} +{DEFAULT @sccs_analysis = sccs_analysis} +{DEFAULT @sccs_covariate_analysis = sccs_covariate_analysis} +{DEFAULT @sccs_covariate = sccs_covariate} +{DEFAULT @sccs_era = sccs_era} +{DEFAULT @sccs_exposures_outcome_set = sccs_exposures_outcome_set} +{DEFAULT @sccs_exposure = sccs_exposure} +{DEFAULT @sccs_spline = sccs_spline} +{DEFAULT @sccs_censor_model = sccs_censor_model} +{DEFAULT @sccs_result = sccs_result} +{DEFAULT @sccs_covariate_result = sccs_covariate_result} +{DEFAULT @sccs_attrition = sccs_attrition} +{DEFAULT @sccs_likelihood_profile = sccs_likelihood_profile} +{DEFAULT @sccs_time_trend = sccs_time_trend} +{DEFAULT @sccs_time_to_event = sccs_time_to_event} +{DEFAULT @sccs_age_spanning = sccs_age_spanning} +{DEFAULT @sccs_calendar_time_spanning = sccs_calendar_time_spanning} +{DEFAULT @sccs_event_dep_observation = sccs_event_dep_observation} +{DEFAULT @sccs_diagnostics_summary = sccs_diagnostics_summary} + +CREATE TABLE @database_schema.@table_prefix@sccs_analysis ( + analysis_id INT NOT NULL, + description VARCHAR, + definition VARCHAR, + PRIMARY KEY(analysis_id) +); + +CREATE TABLE @database_schema.@table_prefix@sccs_covariate_analysis ( + analysis_id INT NOT NULL, + covariate_analysis_id INT NOT NULL, + covariate_analysis_name VARCHAR, + variable_of_interest INT, + PRIMARY KEY(analysis_id,covariate_analysis_id) +); + +CREATE TABLE @database_schema.@table_prefix@sccs_covariate ( + analysis_id INT NOT NULL, + exposures_outcome_set_id INT NOT NULL, + covariate_id INT NOT NULL, + covariate_name VARCHAR, + era_id INT, + covariate_analysis_id INT, + database_id VARCHAR NOT NULL, + PRIMARY KEY(analysis_id,exposures_outcome_set_id,covariate_id,database_id) +); + +CREATE TABLE @database_schema.@table_prefix@sccs_era ( + exposures_outcome_set_id INT NOT NULL, + analysis_id INT NOT NULL, + era_type VARCHAR NOT NULL, + era_id INT NOT NULL, + era_name VARCHAR, + database_id VARCHAR NOT NULL, + PRIMARY KEY(exposures_outcome_set_id,analysis_id,era_type,era_id,database_id) +); + +CREATE TABLE @database_schema.@table_prefix@sccs_exposures_outcome_set ( + exposures_outcome_set_id INT NOT NULL, + outcome_id INT, + nesting_cohort_id INT, + PRIMARY KEY(exposures_outcome_set_id) +); + +CREATE TABLE @database_schema.@table_prefix@sccs_exposure ( + exposures_outcome_set_id INT NOT NULL, + era_id INT NOT NULL, + true_effect_size FLOAT, + PRIMARY KEY(exposures_outcome_set_id,era_id) +); + +CREATE TABLE @database_schema.@table_prefix@sccs_spline ( + analysis_id INT NOT NULL, + exposures_outcome_set_id INT NOT NULL, + database_id VARCHAR NOT NULL, + spline_type VARCHAR NOT NULL, + knot_month FLOAT NOT NULL, + rr FLOAT, + PRIMARY KEY(analysis_id,exposures_outcome_set_id,database_id,spline_type,knot_month) +); + +CREATE TABLE @database_schema.@table_prefix@sccs_censor_model ( + analysis_id INT NOT NULL, + exposures_outcome_set_id INT NOT NULL, + database_id VARCHAR NOT NULL, + parameter_id INT NOT NULL, + parameter_value FLOAT, + model_type VARCHAR, + PRIMARY KEY(analysis_id,exposures_outcome_set_id,database_id,parameter_id) +); + +CREATE TABLE @database_schema.@table_prefix@sccs_result ( + analysis_id INT NOT NULL, + exposures_outcome_set_id INT NOT NULL, + covariate_id INT NOT NULL, + rr FLOAT, + ci_95_lb FLOAT, + ci_95_ub FLOAT, + p FLOAT, + one_sided_p FLOAT, + outcome_subjects INT, + outcome_events INT, + outcome_observation_periods INT, + covariate_subjects INT, + covariate_days INT, + covariate_eras INT, + covariate_outcomes INT, + observed_days BIGINT, + log_rr FLOAT, + se_log_rr FLOAT, + llr FLOAT, + calibrated_rr FLOAT, + calibrated_ci_95_lb FLOAT, + calibrated_ci_95_ub FLOAT, + calibrated_p FLOAT, + calibrated_one_sided_p FLOAT, + calibrated_log_rr FLOAT, + calibrated_se_log_rr FLOAT, + database_id VARCHAR NOT NULL, + PRIMARY KEY(analysis_id,exposures_outcome_set_id,covariate_id,database_id) +); + +CREATE TABLE @database_schema.@table_prefix@sccs_covariate_result ( + analysis_id INT NOT NULL, + exposures_outcome_set_id INT NOT NULL, + database_id VARCHAR NOT NULL, + covariate_id INT NOT NULL, + rr FLOAT, + ci_95_lb FLOAT, + ci_95_ub FLOAT, + PRIMARY KEY(analysis_id,exposures_outcome_set_id,database_id,covariate_id) +); + +CREATE TABLE @database_schema.@table_prefix@sccs_attrition ( + sequence_number INT NOT NULL, + description VARCHAR, + analysis_id INT NOT NULL, + exposures_outcome_set_id INT NOT NULL, + covariate_id INT NOT NULL, + database_id VARCHAR NOT NULL, + outcome_subjects INT, + outcome_events INT, + outcome_observation_periods INT, + observed_days BIGINT, + PRIMARY KEY(sequence_number,analysis_id,exposures_outcome_set_id,covariate_id,database_id) +); + +CREATE TABLE @database_schema.@table_prefix@sccs_likelihood_profile ( + log_rr FLOAT NOT NULL, + log_likelihood FLOAT, + covariate_id INT NOT NULL, + exposures_outcome_set_id INT NOT NULL, + analysis_id INT NOT NULL, + database_id VARCHAR NOT NULL, + PRIMARY KEY(log_rr,covariate_id,exposures_outcome_set_id,analysis_id,database_id) +); + +CREATE TABLE @database_schema.@table_prefix@sccs_time_trend ( + analysis_id INT NOT NULL, + exposures_outcome_set_id INT NOT NULL, + database_id VARCHAR NOT NULL, + calendar_year INT NOT NULL, + calendar_month INT NOT NULL, + observed_subjects INT, + ratio FLOAT, + adjusted_ratio FLOAT, + PRIMARY KEY(analysis_id,exposures_outcome_set_id,database_id,calendar_year,calendar_month) +); + +CREATE TABLE @database_schema.@table_prefix@sccs_time_to_event ( + analysis_id INT NOT NULL, + exposures_outcome_set_id INT NOT NULL, + database_id VARCHAR NOT NULL, + era_id INT NOT NULL, + week INT NOT NULL, + observed_subjects INT, + outcomes INT, + PRIMARY KEY(analysis_id,exposures_outcome_set_id,database_id,era_id,week) +); + +CREATE TABLE @database_schema.@table_prefix@sccs_age_spanning ( + analysis_id INT NOT NULL, + exposures_outcome_set_id INT NOT NULL, + database_id VARCHAR NOT NULL, + age_month INT NOT NULL, + cover_before_after_subjects INT, + PRIMARY KEY(analysis_id,exposures_outcome_set_id,database_id,age_month) +); + +CREATE TABLE @database_schema.@table_prefix@sccs_calendar_time_spanning ( + analysis_id INT NOT NULL, + exposures_outcome_set_id INT NOT NULL, + database_id VARCHAR NOT NULL, + calendar_year INT NOT NULL, + calendar_month INT NOT NULL, + cover_before_after_subjects INT, + PRIMARY KEY(analysis_id,exposures_outcome_set_id,database_id,calendar_year,calendar_month) +); + +CREATE TABLE @database_schema.@table_prefix@sccs_event_dep_observation ( + analysis_id INT NOT NULL, + exposures_outcome_set_id INT NOT NULL, + database_id VARCHAR NOT NULL, + months_to_end INT NOT NULL, + censored INT NOT NULL, + outcomes INT, + PRIMARY KEY(analysis_id,exposures_outcome_set_id,database_id,months_to_end,censored) +); + +CREATE TABLE @database_schema.@table_prefix@sccs_diagnostics_summary ( + analysis_id INT NOT NULL, + exposures_outcome_set_id INT NOT NULL, + covariate_id INT NOT NULL, + database_id VARCHAR NOT NULL, + mdrr FLOAT, + ease FLOAT, + time_trend_p FLOAT, + pre_exposure_p FLOAT, + mdrr_diagnostic VARCHAR(20), + ease_diagnostic VARCHAR(20), + time_trend_diagnostic VARCHAR(20), + pre_exposure_diagnostic VARCHAR(20), + unblind INT, + unblind_for_evidence_synthesis INT, + PRIMARY KEY(analysis_id,exposures_outcome_set_id,covariate_id,database_id) +); diff --git a/extras/rdms/full_data_model_pg.sql b/extras/rdms/full_data_model_pg.sql new file mode 100644 index 00000000..1f5df959 --- /dev/null +++ b/extras/rdms/full_data_model_pg.sql @@ -0,0 +1,1414 @@ +-- Strategus Tables +CREATE TABLE results.database_meta_data ( + cdm_source_name VARCHAR, + cdm_source_abbreviation VARCHAR, + cdm_holder VARCHAR, + source_description VARCHAR, + source_documentation_reference VARCHAR, + cdm_etl_reference VARCHAR, + source_release_date DATE, + cdm_release_date DATE, + cdm_version VARCHAR, + cdm_version_concept_id INT, + vocabulary_version VARCHAR, + database_id VARCHAR NOT NULL, + max_obs_period_end_date DATE, + PRIMARY KEY(database_id) +); +-- CharacterizationModule Tables +CREATE TABLE results.c_time_to_event ( + database_id VARCHAR(100) NOT NULL, + target_cohort_definition_id BIGINT NOT NULL, + outcome_cohort_definition_id BIGINT NOT NULL, + outcome_type VARCHAR(100) NOT NULL, + target_outcome_type VARCHAR(40) NOT NULL, + time_to_event INT NOT NULL, + num_events INT, + time_scale VARCHAR(20) NOT NULL, + PRIMARY KEY(database_id,target_cohort_definition_id,outcome_cohort_definition_id,outcome_type,target_outcome_type,time_to_event,time_scale) +); +CREATE TABLE results.c_rechallenge_fail_case_series ( + database_id VARCHAR(100) NOT NULL, + dechallenge_stop_interval INT NOT NULL, + dechallenge_evaluation_window INT NOT NULL, + target_cohort_definition_id BIGINT NOT NULL, + outcome_cohort_definition_id BIGINT NOT NULL, + person_key INT NOT NULL, + subject_id BIGINT, + dechallenge_exposure_number INT, + dechallenge_exposure_start_date_offset INT, + dechallenge_exposure_end_date_offset INT, + dechallenge_outcome_number INT, + dechallenge_outcome_start_date_offset INT, + rechallenge_exposure_number INT, + rechallenge_exposure_start_date_offset INT, + rechallenge_exposure_end_date_offset INT, + rechallenge_outcome_number INT, + rechallenge_outcome_start_date_offset INT, + PRIMARY KEY(database_id,dechallenge_stop_interval,dechallenge_evaluation_window,target_cohort_definition_id,outcome_cohort_definition_id,person_key) +); +CREATE TABLE results.c_dechallenge_rechallenge ( + database_id VARCHAR(100) NOT NULL, + dechallenge_stop_interval INT NOT NULL, + dechallenge_evaluation_window INT NOT NULL, + target_cohort_definition_id BIGINT NOT NULL, + outcome_cohort_definition_id BIGINT NOT NULL, + num_exposure_eras INT, + num_persons_exposed INT, + num_cases INT, + dechallenge_attempt INT, + dechallenge_fail INT, + dechallenge_success INT, + rechallenge_attempt INT, + rechallenge_fail INT, + rechallenge_success INT, + pct_dechallenge_attempt NUMERIC, + pct_dechallenge_success NUMERIC, + pct_dechallenge_fail NUMERIC, + pct_rechallenge_attempt NUMERIC, + pct_rechallenge_success NUMERIC, + pct_rechallenge_fail NUMERIC, + PRIMARY KEY(database_id,dechallenge_stop_interval,dechallenge_evaluation_window,target_cohort_definition_id,outcome_cohort_definition_id) +); +CREATE TABLE results.c_analysis_ref ( + database_id VARCHAR(100) NOT NULL, + setting_id VARCHAR(30) NOT NULL, + analysis_id INT NOT NULL, + analysis_name VARCHAR, + domain_id VARCHAR, + start_day INT, + end_day INT, + is_binary VARCHAR(1), + missing_means_zero VARCHAR(1), + PRIMARY KEY(database_id,setting_id,analysis_id) +); +CREATE TABLE results.c_covariate_ref ( + database_id VARCHAR(100) NOT NULL, + setting_id VARCHAR(30) NOT NULL, + covariate_id BIGINT NOT NULL, + covariate_name VARCHAR, + analysis_id INT, + concept_id BIGINT, + value_as_concept_id INT, + collisions INT, + PRIMARY KEY(database_id,setting_id,covariate_id) +); +CREATE TABLE results.c_covariates ( + database_id VARCHAR(100) NOT NULL, + setting_id VARCHAR(30) NOT NULL, + cohort_type VARCHAR(12) NOT NULL, + target_cohort_id INT NOT NULL, + outcome_cohort_id INT NOT NULL, + min_characterization_mean NUMERIC NOT NULL, + covariate_id BIGINT NOT NULL, + sum_value INT, + average_value NUMERIC, + PRIMARY KEY(database_id,setting_id,cohort_type,target_cohort_id,outcome_cohort_id,min_characterization_mean,covariate_id) +); +CREATE TABLE results.c_covariates_continuous ( + database_id VARCHAR(100) NOT NULL, + setting_id VARCHAR(30) NOT NULL, + cohort_type VARCHAR(12) NOT NULL, + target_cohort_id INT NOT NULL, + outcome_cohort_id INT NOT NULL, + covariate_id BIGINT NOT NULL, + count_value INT, + min_value NUMERIC, + max_value NUMERIC, + average_value NUMERIC, + standard_deviation NUMERIC, + median_value NUMERIC, + p_10_value NUMERIC, + p_25_value NUMERIC, + p_75_value NUMERIC, + p_90_value NUMERIC, + PRIMARY KEY(database_id,setting_id,cohort_type,target_cohort_id,outcome_cohort_id,covariate_id) +); +CREATE TABLE results.c_settings ( + setting_id VARCHAR(30) NOT NULL, + database_id VARCHAR(100) NOT NULL, + covariate_setting_json VARCHAR, + case_covariate_setting_json VARCHAR, + min_prior_observation INT, + outcome_washout_days INT, + risk_window_start INT, + risk_window_end INT, + start_anchor VARCHAR(15), + end_anchor VARCHAR(15), + case_pre_target_duration INT, + case_post_outcome_duration INT, + PRIMARY KEY(setting_id,database_id) +); +CREATE TABLE results.c_cohort_details ( + database_id VARCHAR(100) NOT NULL, + setting_id VARCHAR(30) NOT NULL, + cohort_type VARCHAR(12) NOT NULL, + target_cohort_id INT NOT NULL, + outcome_cohort_id INT NOT NULL, + PRIMARY KEY(database_id,setting_id,cohort_type,target_cohort_id,outcome_cohort_id) +); +CREATE TABLE results.c_cohort_counts ( + database_id VARCHAR(100), + cohort_type VARCHAR(12), + target_cohort_id INT, + outcome_cohort_id INT, + risk_window_start INT, + risk_window_end INT, + start_anchor VARCHAR(15), + end_anchor VARCHAR(15), + min_prior_observation INT, + outcome_washout_days INT, + row_count INT, + person_count INT, + min_exposure_time BIGINT, + mean_exposure_time BIGINT, + max_exposure_time BIGINT +); +-- CohortDiagnosticsModule Tables +CREATE TABLE results.cd_cohort ( + cohort_id BIGINT NOT NULL, + cohort_name VARCHAR, + metadata VARCHAR, + json VARCHAR, + sql VARCHAR, + subset_parent BIGINT, + subset_definition_id BIGINT, + is_subset INT, + PRIMARY KEY(cohort_id) +); +CREATE TABLE results.cd_subset_definition ( + subset_definition_id BIGINT NOT NULL, + json VARCHAR NOT NULL, + PRIMARY KEY(subset_definition_id,json) +); +CREATE TABLE results.cd_cohort_count ( + cohort_id BIGINT NOT NULL, + cohort_entries NUMERIC, + cohort_subjects NUMERIC, + database_id VARCHAR NOT NULL, + PRIMARY KEY(cohort_id,database_id) +); +CREATE TABLE results.cd_cohort_inclusion ( + database_id VARCHAR NOT NULL, + cohort_id BIGINT NOT NULL, + rule_sequence BIGINT NOT NULL, + name VARCHAR, + description VARCHAR, + PRIMARY KEY(database_id,cohort_id,rule_sequence) +); +CREATE TABLE results.cd_cohort_inc_result ( + database_id VARCHAR NOT NULL, + cohort_id BIGINT NOT NULL, + mode_id BIGINT NOT NULL, + inclusion_rule_mask BIGINT NOT NULL, + person_count NUMERIC, + PRIMARY KEY(database_id,cohort_id,mode_id,inclusion_rule_mask) +); +CREATE TABLE results.cd_cohort_inc_stats ( + database_id VARCHAR NOT NULL, + cohort_id BIGINT NOT NULL, + rule_sequence BIGINT NOT NULL, + mode_id BIGINT NOT NULL, + person_count NUMERIC, + gain_count NUMERIC, + person_total NUMERIC, + PRIMARY KEY(database_id,cohort_id,rule_sequence,mode_id) +); +CREATE TABLE results.cd_cohort_relationships ( + database_id VARCHAR NOT NULL, + cohort_id BIGINT NOT NULL, + comparator_cohort_id BIGINT NOT NULL, + start_day BIGINT NOT NULL, + end_day NUMERIC NOT NULL, + subjects BIGINT, + sub_cs_before_ts BIGINT, + sub_cs_on_ts BIGINT, + sub_cs_after_ts BIGINT, + sub_cs_before_te BIGINT, + sub_cs_on_te BIGINT, + sub_cs_after_te BIGINT, + sub_cs_window_t BIGINT, + sub_ce_window_t BIGINT, + sub_cs_window_ts BIGINT, + sub_cs_window_te BIGINT, + sub_ce_window_ts BIGINT, + sub_ce_window_te BIGINT, + sub_c_within_t BIGINT, + c_days_before_ts BIGINT, + c_days_before_te BIGINT, + c_days_within_t_days BIGINT, + c_days_after_ts BIGINT, + c_days_after_te BIGINT, + t_days BIGINT, + c_days BIGINT, + PRIMARY KEY(database_id,cohort_id,comparator_cohort_id,start_day,end_day) +); +CREATE TABLE results.cd_cohort_summary_stats ( + database_id VARCHAR NOT NULL, + cohort_id BIGINT NOT NULL, + mode_id BIGINT NOT NULL, + base_count NUMERIC, + final_count NUMERIC, + PRIMARY KEY(database_id,cohort_id,mode_id) +); +CREATE TABLE results.cd_concept ( + concept_id BIGINT NOT NULL, + concept_name VARCHAR(255), + domain_id VARCHAR(20), + vocabulary_id VARCHAR(50), + concept_class_id VARCHAR(20), + standard_concept VARCHAR(1), + concept_code VARCHAR(255), + valid_start_date DATE, + valid_end_date DATE, + invalid_reason VARCHAR, + PRIMARY KEY(concept_id) +); +CREATE TABLE results.cd_concept_ancestor ( + ancestor_concept_id BIGINT NOT NULL, + descendant_concept_id BIGINT NOT NULL, + min_levels_of_separation INT, + max_levels_of_separation INT, + PRIMARY KEY(ancestor_concept_id,descendant_concept_id) +); +CREATE TABLE results.cd_concept_relationship ( + concept_id_1 BIGINT NOT NULL, + concept_id_2 BIGINT NOT NULL, + relationship_id VARCHAR(20) NOT NULL, + valid_start_date DATE, + valid_end_date DATE, + invalid_reason VARCHAR(1), + PRIMARY KEY(concept_id_1,concept_id_2,relationship_id) +); +CREATE TABLE results.cd_concept_sets ( + cohort_id BIGINT NOT NULL, + concept_set_id INT NOT NULL, + concept_set_sql VARCHAR, + concept_set_name VARCHAR(255), + concept_set_expression VARCHAR, + PRIMARY KEY(cohort_id,concept_set_id) +); +CREATE TABLE results.cd_concept_synonym ( + concept_id BIGINT NOT NULL, + concept_synonym_name VARCHAR NOT NULL, + language_concept_id BIGINT NOT NULL, + PRIMARY KEY(concept_id,concept_synonym_name,language_concept_id) +); +CREATE TABLE results.cd_database ( + database_id VARCHAR NOT NULL, + database_name VARCHAR, + description VARCHAR, + is_meta_analysis VARCHAR(1), + vocabulary_version VARCHAR, + vocabulary_version_cdm VARCHAR, + PRIMARY KEY(database_id) +); +CREATE TABLE results.cd_domain ( + domain_id VARCHAR(20) NOT NULL, + domain_name VARCHAR(255), + domain_concept_id BIGINT, + PRIMARY KEY(domain_id) +); +CREATE TABLE results.cd_incidence_rate ( + cohort_count NUMERIC, + person_years NUMERIC, + gender VARCHAR NOT NULL, + age_group VARCHAR NOT NULL, + calendar_year VARCHAR(4) NOT NULL, + incidence_rate NUMERIC, + cohort_id BIGINT NOT NULL, + database_id VARCHAR NOT NULL, + PRIMARY KEY(gender,age_group,calendar_year,cohort_id,database_id) +); +CREATE TABLE results.cd_included_source_concept ( + database_id VARCHAR NOT NULL, + cohort_id BIGINT NOT NULL, + concept_set_id INT NOT NULL, + concept_id BIGINT NOT NULL, + source_concept_id BIGINT NOT NULL, + concept_subjects NUMERIC, + concept_count NUMERIC, + PRIMARY KEY(database_id,cohort_id,concept_set_id,concept_id,source_concept_id) +); +CREATE TABLE results.cd_index_event_breakdown ( + concept_id BIGINT NOT NULL, + concept_count NUMERIC, + subject_count NUMERIC, + cohort_id BIGINT NOT NULL, + database_id VARCHAR NOT NULL, + domain_field VARCHAR NOT NULL, + domain_table VARCHAR NOT NULL, + PRIMARY KEY(concept_id,cohort_id,database_id,domain_field,domain_table) +); +CREATE TABLE results.cd_metadata ( + database_id VARCHAR NOT NULL, + start_time VARCHAR NOT NULL, + variable_field VARCHAR NOT NULL, + value_field VARCHAR, + PRIMARY KEY(database_id,start_time,variable_field) +); +CREATE TABLE results.cd_orphan_concept ( + cohort_id BIGINT NOT NULL, + concept_set_id INT NOT NULL, + database_id VARCHAR NOT NULL, + concept_id BIGINT NOT NULL, + concept_count NUMERIC, + concept_subjects NUMERIC, + PRIMARY KEY(cohort_id,concept_set_id,database_id,concept_id) +); +CREATE TABLE results.cd_relationship ( + relationship_id VARCHAR(20) NOT NULL, + relationship_name VARCHAR(255), + is_hierarchical VARCHAR(1), + defines_ancestry VARCHAR(1), + reverse_relationship_id VARCHAR(20) NOT NULL, + relationship_concept_id BIGINT NOT NULL, + PRIMARY KEY(relationship_id,reverse_relationship_id,relationship_concept_id) +); +CREATE TABLE results.cd_resolved_concepts ( + cohort_id BIGINT NOT NULL, + concept_set_id INT NOT NULL, + concept_id BIGINT NOT NULL, + database_id VARCHAR NOT NULL, + PRIMARY KEY(cohort_id,concept_set_id,concept_id,database_id) +); +CREATE TABLE results.cd_temporal_analysis_ref ( + analysis_id INT NOT NULL, + analysis_name VARCHAR, + domain_id VARCHAR(20) NOT NULL, + is_binary VARCHAR(1), + missing_means_zero VARCHAR(1), + PRIMARY KEY(analysis_id,domain_id) +); +CREATE TABLE results.cd_temporal_covariate_ref ( + covariate_id BIGINT NOT NULL, + covariate_name VARCHAR, + analysis_id INT, + concept_id BIGINT, + PRIMARY KEY(covariate_id) +); +CREATE TABLE results.cd_temporal_covariate_value ( + cohort_id BIGINT NOT NULL, + time_id INT NOT NULL, + covariate_id BIGINT NOT NULL, + sum_value NUMERIC, + mean NUMERIC, + sd NUMERIC, + database_id VARCHAR NOT NULL, + PRIMARY KEY(cohort_id,time_id,covariate_id,database_id) +); +CREATE TABLE results.cd_temporal_covariate_value_dist ( + cohort_id BIGINT NOT NULL, + time_id INT NOT NULL, + covariate_id BIGINT NOT NULL, + count_value NUMERIC, + min_value NUMERIC, + max_value NUMERIC, + mean NUMERIC, + sd NUMERIC, + median_value NUMERIC, + p_10_value NUMERIC, + p_25_value NUMERIC, + p_75_value NUMERIC, + p_90_value NUMERIC, + database_id VARCHAR NOT NULL, + PRIMARY KEY(cohort_id,time_id,covariate_id,database_id) +); +CREATE TABLE results.cd_temporal_time_ref ( + time_id INT NOT NULL, + start_day NUMERIC, + end_day NUMERIC, + PRIMARY KEY(time_id) +); +CREATE TABLE results.cd_time_series ( + cohort_id BIGINT NOT NULL, + database_id VARCHAR NOT NULL, + period_begin DATE NOT NULL, + period_end DATE NOT NULL, + series_type VARCHAR NOT NULL, + calendar_interval VARCHAR NOT NULL, + gender VARCHAR NOT NULL, + age_group VARCHAR NOT NULL, + records BIGINT, + subjects BIGINT, + person_days BIGINT, + person_days_in BIGINT, + records_start BIGINT, + subjects_start BIGINT, + subjects_start_in BIGINT, + records_end BIGINT, + subjects_end BIGINT, + subjects_end_in BIGINT, + PRIMARY KEY(cohort_id,database_id,period_begin,period_end,series_type,calendar_interval,gender,age_group) +); +CREATE TABLE results.cd_visit_context ( + cohort_id BIGINT NOT NULL, + visit_concept_id BIGINT NOT NULL, + visit_context VARCHAR NOT NULL, + subjects NUMERIC, + database_id VARCHAR NOT NULL, + PRIMARY KEY(cohort_id,visit_concept_id,visit_context,database_id) +); +CREATE TABLE results.cd_vocabulary ( + vocabulary_id VARCHAR(50), + vocabulary_name VARCHAR(255), + vocabulary_reference VARCHAR, + vocabulary_version VARCHAR, + vocabulary_concept_id BIGINT +); +-- CohortGeneratorModule Tables +CREATE TABLE results.cg_cohort_definition ( + cohort_definition_id BIGINT NOT NULL, + cohort_name VARCHAR, + description VARCHAR, + json TEXT, + sql_command TEXT, + subset_parent BIGINT, + is_subset INT, + subset_definition_id BIGINT, + PRIMARY KEY(cohort_definition_id) +); +CREATE TABLE results.cg_cohort_generation ( + cohort_id BIGINT NOT NULL, + cohort_name VARCHAR, + generation_status VARCHAR, + start_time TIMESTAMP, + end_time TIMESTAMP, + database_id VARCHAR NOT NULL, + PRIMARY KEY(cohort_id,database_id) +); +CREATE TABLE results.cg_cohort_inclusion ( + cohort_definition_id BIGINT NOT NULL, + rule_sequence INT NOT NULL, + name VARCHAR NOT NULL, + description VARCHAR, + PRIMARY KEY(cohort_definition_id,rule_sequence,name) +); +CREATE TABLE results.cg_cohort_inc_result ( + database_id VARCHAR NOT NULL, + cohort_definition_id BIGINT NOT NULL, + inclusion_rule_mask INT NOT NULL, + person_count BIGINT NOT NULL, + mode_id INT NOT NULL, + PRIMARY KEY(database_id,cohort_definition_id,inclusion_rule_mask,person_count,mode_id) +); +CREATE TABLE results.cg_cohort_inc_stats ( + database_id VARCHAR NOT NULL, + cohort_definition_id BIGINT NOT NULL, + rule_sequence INT NOT NULL, + person_count BIGINT NOT NULL, + gain_count BIGINT NOT NULL, + person_total BIGINT NOT NULL, + mode_id INT NOT NULL, + PRIMARY KEY(database_id,cohort_definition_id,rule_sequence,person_count,gain_count,person_total,mode_id) +); +CREATE TABLE results.cg_cohort_summary_stats ( + database_id VARCHAR NOT NULL, + cohort_definition_id BIGINT NOT NULL, + base_count BIGINT NOT NULL, + final_count BIGINT NOT NULL, + mode_id INT NOT NULL, + PRIMARY KEY(database_id,cohort_definition_id,base_count,final_count,mode_id) +); +CREATE TABLE results.cg_cohort_censor_stats ( + cohort_definition_id BIGINT NOT NULL, + lost_count BIGINT NOT NULL, + database_id VARCHAR NOT NULL, + PRIMARY KEY(cohort_definition_id,lost_count,database_id) +); +CREATE TABLE results.cg_cohort_count ( + database_id VARCHAR NOT NULL, + cohort_id BIGINT NOT NULL, + cohort_entries BIGINT NOT NULL, + cohort_subjects BIGINT NOT NULL, + PRIMARY KEY(database_id,cohort_id,cohort_entries,cohort_subjects) +); +CREATE TABLE results.cg_cohort_count_neg_ctrl ( + database_id VARCHAR NOT NULL, + cohort_id BIGINT NOT NULL, + cohort_entries BIGINT NOT NULL, + cohort_subjects BIGINT NOT NULL, + PRIMARY KEY(database_id,cohort_id,cohort_entries,cohort_subjects) +); +CREATE TABLE results.cg_cohort_subset_definition ( + subset_definition_id BIGINT NOT NULL, + json TEXT, + PRIMARY KEY(subset_definition_id) +); +CREATE TABLE results.cg_cohort_definition_neg_ctrl ( + cohort_id BIGINT NOT NULL, + outcome_concept_id BIGINT, + cohort_name VARCHAR, + occurrence_type VARCHAR, + detect_on_descendants INT, + PRIMARY KEY(cohort_id) +); +-- CohortIncidenceModule Tables +CREATE TABLE results.ci_incidence_summary ( + ref_id INT, + database_id VARCHAR(255), + source_name VARCHAR(255), + target_cohort_definition_id BIGINT, + tar_id BIGINT, + subgroup_id BIGINT, + outcome_id BIGINT, + age_group_id INT, + gender_id INT, + gender_name VARCHAR(255), + start_year INT, + persons_at_risk_pe BIGINT, + persons_at_risk BIGINT, + person_days_pe BIGINT, + person_days BIGINT, + person_outcomes_pe BIGINT, + person_outcomes BIGINT, + outcomes_pe BIGINT, + outcomes BIGINT, + incidence_proportion_p100p NUMERIC, + incidence_rate_p100py NUMERIC +); +CREATE TABLE results.ci_target_def ( + ref_id INT NOT NULL, + target_cohort_definition_id BIGINT NOT NULL, + target_name VARCHAR(255), + PRIMARY KEY(ref_id,target_cohort_definition_id) +); +CREATE TABLE results.ci_outcome_def ( + ref_id INT NOT NULL, + outcome_id BIGINT NOT NULL, + outcome_cohort_definition_id BIGINT, + outcome_name VARCHAR(255), + clean_window BIGINT, + excluded_cohort_definition_id BIGINT, + PRIMARY KEY(ref_id,outcome_id) +); +CREATE TABLE results.ci_tar_def ( + ref_id INT NOT NULL, + tar_id BIGINT NOT NULL, + tar_start_with VARCHAR(10), + tar_start_offset BIGINT, + tar_end_with VARCHAR(10), + tar_end_offset BIGINT, + PRIMARY KEY(ref_id,tar_id) +); +CREATE TABLE results.ci_age_group_def ( + ref_id INT NOT NULL, + age_group_id INT NOT NULL, + age_group_name VARCHAR(255), + min_age INT, + max_age INT, + PRIMARY KEY(ref_id,age_group_id) +); +CREATE TABLE results.ci_subgroup_def ( + ref_id INT NOT NULL, + subgroup_id BIGINT NOT NULL, + subgroup_name VARCHAR(255), + PRIMARY KEY(ref_id,subgroup_id) +); +CREATE TABLE results.ci_target_outcome_ref ( + ref_id INT NOT NULL, + target_cohort_id BIGINT NOT NULL, + outcome_cohort_id BIGINT NOT NULL, + PRIMARY KEY(ref_id,target_cohort_id,outcome_cohort_id) +); +-- CohortMethodModule Tables +CREATE TABLE results.cm_attrition ( + sequence_number INT NOT NULL, + description VARCHAR, + subjects INT, + exposure_id BIGINT NOT NULL, + target_id BIGINT NOT NULL, + comparator_id BIGINT NOT NULL, + analysis_id INT NOT NULL, + outcome_id BIGINT NOT NULL, + database_id VARCHAR NOT NULL, + PRIMARY KEY(sequence_number,exposure_id,target_id,comparator_id,analysis_id,outcome_id,database_id) +); +CREATE TABLE results.cm_follow_up_dist ( + target_id BIGINT NOT NULL, + comparator_id BIGINT NOT NULL, + outcome_id BIGINT NOT NULL, + analysis_id INT NOT NULL, + target_min_days NUMERIC, + target_p_10_days NUMERIC, + target_p_25_days NUMERIC, + target_median_days NUMERIC, + target_p_75_days NUMERIC, + target_p_90_days NUMERIC, + target_max_days NUMERIC, + comparator_min_days NUMERIC, + comparator_p_10_days NUMERIC, + comparator_p_25_days NUMERIC, + comparator_median_days NUMERIC, + comparator_p_75_days NUMERIC, + comparator_p_90_days NUMERIC, + comparator_max_days NUMERIC, + target_min_date DATE, + target_max_date DATE, + comparator_min_date DATE, + comparator_max_date DATE, + database_id VARCHAR NOT NULL, + PRIMARY KEY(target_id,comparator_id,outcome_id,analysis_id,database_id) +); +CREATE TABLE results.cm_analysis ( + analysis_id INT NOT NULL, + description VARCHAR, + definition VARCHAR, + PRIMARY KEY(analysis_id) +); +CREATE TABLE results.cm_result ( + analysis_id INT NOT NULL, + target_id BIGINT NOT NULL, + comparator_id BIGINT NOT NULL, + outcome_id BIGINT NOT NULL, + rr NUMERIC, + ci_95_lb NUMERIC, + ci_95_ub NUMERIC, + p NUMERIC, + one_sided_p NUMERIC, + target_subjects INT, + comparator_subjects INT, + target_days INT, + comparator_days INT, + target_outcomes INT, + comparator_outcomes INT, + log_rr NUMERIC, + se_log_rr NUMERIC, + llr NUMERIC, + calibrated_rr NUMERIC, + calibrated_ci_95_lb NUMERIC, + calibrated_ci_95_ub NUMERIC, + calibrated_p NUMERIC, + calibrated_one_sided_p NUMERIC, + calibrated_log_rr NUMERIC, + calibrated_se_log_rr NUMERIC, + target_estimator VARCHAR, + database_id VARCHAR NOT NULL, + PRIMARY KEY(analysis_id,target_id,comparator_id,outcome_id,database_id) +); +CREATE TABLE results.cm_interaction_result ( + analysis_id INT NOT NULL, + target_id BIGINT NOT NULL, + comparator_id BIGINT NOT NULL, + outcome_id BIGINT NOT NULL, + interaction_covariate_id INT NOT NULL, + rr NUMERIC, + ci_95_lb NUMERIC, + ci_95_ub NUMERIC, + p NUMERIC, + target_subjects INT, + comparator_subjects INT, + target_days INT, + comparator_days INT, + target_outcomes INT, + comparator_outcomes INT, + log_rr NUMERIC, + se_log_rr NUMERIC, + calibrated_rr NUMERIC, + calibrated_ci_95_lb NUMERIC, + calibrated_ci_95_ub NUMERIC, + calibrated_p NUMERIC, + calibrated_log_rr NUMERIC, + calibrated_se_log_rr NUMERIC, + target_estimator VARCHAR, + database_id VARCHAR NOT NULL, + PRIMARY KEY(analysis_id,target_id,comparator_id,outcome_id,interaction_covariate_id,database_id) +); +CREATE TABLE results.cm_covariate ( + covariate_id BIGINT NOT NULL, + covariate_name VARCHAR, + analysis_id INT NOT NULL, + covariate_analysis_id INT, + database_id VARCHAR NOT NULL, + PRIMARY KEY(covariate_id,analysis_id,database_id) +); +CREATE TABLE results.cm_covariate_analysis ( + covariate_analysis_id INT NOT NULL, + covariate_analysis_name VARCHAR, + analysis_id INT NOT NULL, + PRIMARY KEY(covariate_analysis_id,analysis_id) +); +CREATE TABLE results.cm_covariate_balance ( + database_id VARCHAR NOT NULL, + target_id BIGINT NOT NULL, + comparator_id BIGINT NOT NULL, + outcome_id BIGINT NOT NULL, + analysis_id INT NOT NULL, + covariate_id BIGINT NOT NULL, + target_mean_before NUMERIC, + comparator_mean_before NUMERIC, + mean_before NUMERIC, + std_diff_before NUMERIC, + mean_after NUMERIC, + target_mean_after NUMERIC, + comparator_mean_after NUMERIC, + std_diff_after NUMERIC, + target_std_diff NUMERIC, + comparator_std_diff NUMERIC, + target_comparator_std_diff NUMERIC, + PRIMARY KEY(database_id,target_id,comparator_id,outcome_id,analysis_id,covariate_id) +); +CREATE TABLE results.cm_diagnostics_summary ( + analysis_id INT NOT NULL, + target_id BIGINT NOT NULL, + comparator_id BIGINT NOT NULL, + outcome_id BIGINT NOT NULL, + database_id VARCHAR NOT NULL, + max_sdm NUMERIC, + shared_max_sdm NUMERIC, + equipoise NUMERIC, + mdrr NUMERIC, + attrition_fraction NUMERIC, + generalizability_max_sdm NUMERIC, + ease NUMERIC, + balance_diagnostic VARCHAR(20), + shared_balance_diagnostic VARCHAR(20), + equipoise_diagnostic VARCHAR(20), + mdrr_diagnostic VARCHAR(20), + attrition_diagnostic VARCHAR(20), + generalizability_diagnostic VARCHAR(20), + ease_diagnostic VARCHAR(20), + unblind INT, + unblind_for_evidence_synthesis INT, + PRIMARY KEY(analysis_id,target_id,comparator_id,outcome_id,database_id) +); +CREATE TABLE results.cm_target_comparator_outcome ( + outcome_id BIGINT NOT NULL, + outcome_of_interest INT, + true_effect_size NUMERIC, + target_id BIGINT NOT NULL, + comparator_id BIGINT NOT NULL, + PRIMARY KEY(outcome_id,target_id,comparator_id) +); +CREATE TABLE results.cm_kaplan_meier_dist ( + time_day INT NOT NULL, + target_survival NUMERIC, + target_survival_lb NUMERIC, + target_survival_ub NUMERIC, + comparator_survival NUMERIC, + comparator_survival_lb NUMERIC, + comparator_survival_ub NUMERIC, + target_at_risk INT, + comparator_at_risk INT, + target_id BIGINT NOT NULL, + comparator_id BIGINT NOT NULL, + outcome_id BIGINT NOT NULL, + analysis_id INT NOT NULL, + database_id VARCHAR NOT NULL, + PRIMARY KEY(time_day,target_id,comparator_id,outcome_id,analysis_id,database_id) +); +CREATE TABLE results.cm_likelihood_profile ( + log_rr NUMERIC NOT NULL, + log_likelihood NUMERIC, + target_id BIGINT NOT NULL, + comparator_id BIGINT NOT NULL, + outcome_id BIGINT NOT NULL, + analysis_id INT NOT NULL, + database_id VARCHAR NOT NULL, + PRIMARY KEY(log_rr,target_id,comparator_id,outcome_id,analysis_id,database_id) +); +CREATE TABLE results.cm_preference_score_dist ( + analysis_id INT NOT NULL, + target_id BIGINT NOT NULL, + comparator_id BIGINT NOT NULL, + database_id VARCHAR NOT NULL, + preference_score NUMERIC NOT NULL, + target_density NUMERIC, + comparator_density NUMERIC, + PRIMARY KEY(analysis_id,target_id,comparator_id,database_id,preference_score) +); +CREATE TABLE results.cm_propensity_model ( + target_id BIGINT NOT NULL, + comparator_id BIGINT NOT NULL, + analysis_id INT NOT NULL, + database_id VARCHAR NOT NULL, + covariate_id BIGINT NOT NULL, + coefficient NUMERIC, + PRIMARY KEY(target_id,comparator_id,analysis_id,database_id,covariate_id) +); +CREATE TABLE results.cm_shared_covariate_balance ( + database_id VARCHAR NOT NULL, + target_id BIGINT NOT NULL, + comparator_id BIGINT NOT NULL, + analysis_id INT NOT NULL, + covariate_id BIGINT NOT NULL, + mean_before NUMERIC, + target_mean_before NUMERIC, + comparator_mean_before NUMERIC, + std_diff_before NUMERIC, + mean_after NUMERIC, + target_mean_after NUMERIC, + comparator_mean_after NUMERIC, + std_diff_after NUMERIC, + target_std_diff NUMERIC, + comparator_std_diff NUMERIC, + target_comparator_std_diff NUMERIC, + PRIMARY KEY(database_id,target_id,comparator_id,analysis_id,covariate_id) +); +-- EvidenceSynthesisModule Tables +CREATE TABLE results.es_analysis ( + evidence_synthesis_analysis_id INT NOT NULL, + evidence_synthesis_description VARCHAR(255), + source_method VARCHAR(100), + definition VARCHAR, + PRIMARY KEY(evidence_synthesis_analysis_id) +); +CREATE TABLE results.es_cm_diagnostics_summary ( + target_id INT NOT NULL, + comparator_id INT NOT NULL, + outcome_id INT NOT NULL, + analysis_id INT NOT NULL, + evidence_synthesis_analysis_id INT NOT NULL, + mdrr NUMERIC, + i_2 NUMERIC, + tau NUMERIC, + ease NUMERIC, + mdrr_diagnostic VARCHAR(13), + i_2_diagnostic VARCHAR(13), + tau_diagnostic VARCHAR(13), + ease_diagnostic VARCHAR(13), + unblind INT, + PRIMARY KEY(target_id,comparator_id,outcome_id,analysis_id,evidence_synthesis_analysis_id) +); +CREATE TABLE results.es_cm_result ( + target_id INT NOT NULL, + comparator_id INT NOT NULL, + outcome_id INT NOT NULL, + analysis_id INT NOT NULL, + evidence_synthesis_analysis_id INT NOT NULL, + rr NUMERIC, + ci_95_lb NUMERIC, + ci_95_ub NUMERIC, + p NUMERIC, + one_sided_p NUMERIC, + log_rr NUMERIC, + se_log_rr NUMERIC, + target_subjects INT, + comparator_subjects INT, + target_days INT, + comparator_days INT, + target_outcomes INT, + comparator_outcomes INT, + n_databases INT, + calibrated_rr NUMERIC, + calibrated_ci_95_lb NUMERIC, + calibrated_ci_95_ub NUMERIC, + calibrated_p NUMERIC, + calibrated_one_sided_p NUMERIC, + calibrated_log_rr NUMERIC, + calibrated_se_log_rr NUMERIC, + PRIMARY KEY(target_id,comparator_id,outcome_id,analysis_id,evidence_synthesis_analysis_id) +); +CREATE TABLE results.es_sccs_diagnostics_summary ( + exposures_outcome_set_id INT NOT NULL, + covariate_id INT NOT NULL, + analysis_id INT NOT NULL, + evidence_synthesis_analysis_id INT NOT NULL, + mdrr NUMERIC, + i_2 NUMERIC, + tau NUMERIC, + ease NUMERIC, + mdrr_diagnostic VARCHAR(13), + i_2_diagnostic VARCHAR(13), + tau_diagnostic VARCHAR(13), + ease_diagnostic VARCHAR(13), + unblind INT, + PRIMARY KEY(exposures_outcome_set_id,covariate_id,analysis_id,evidence_synthesis_analysis_id) +); +CREATE TABLE results.es_sccs_result ( + analysis_id INT NOT NULL, + exposures_outcome_set_id INT NOT NULL, + covariate_id INT NOT NULL, + evidence_synthesis_analysis_id INT NOT NULL, + rr NUMERIC, + ci_95_lb NUMERIC, + ci_95_ub NUMERIC, + p NUMERIC, + one_sided_p NUMERIC, + outcome_subjects INT, + outcome_events INT, + outcome_observation_periods INT, + covariate_subjects INT, + covariate_days INT, + covariate_eras INT, + covariate_outcomes INT, + observed_days INT, + n_databases INT, + log_rr NUMERIC, + se_log_rr NUMERIC, + calibrated_rr NUMERIC, + calibrated_ci_95_lb NUMERIC, + calibrated_ci_95_ub NUMERIC, + calibrated_p NUMERIC, + calibrated_one_sided_p NUMERIC, + calibrated_log_rr NUMERIC, + calibrated_se_log_rr NUMERIC, + PRIMARY KEY(analysis_id,exposures_outcome_set_id,covariate_id,evidence_synthesis_analysis_id) +); +-- PatientLevelPredictionModule Tables +CREATE TABLE results.plp_cohorts ( + cohort_id INT NOT NULL, + cohort_definition_id BIGINT, + cohort_name VARCHAR, + PRIMARY KEY(cohort_id) +); +CREATE TABLE results.plp_cohort_definition ( + cohort_definition_id BIGINT, + cohort_name VARCHAR, + description TEXT, + json TEXT, + sql_command TEXT +); +CREATE TABLE results.plp_database_meta_data ( + database_id VARCHAR NOT NULL, + cdm_source_name VARCHAR, + cdm_source_abbreviation VARCHAR, + cdm_holder VARCHAR, + source_description TEXT, + source_documentation_reference VARCHAR, + cdm_etl_reference VARCHAR, + source_release_date VARCHAR, + cdm_release_date VARCHAR, + cdm_version VARCHAR, + vocabulary_version VARCHAR, + max_obs_period_end_date VARCHAR, + PRIMARY KEY(database_id) +); +CREATE TABLE results.plp_database_details ( + database_id INT NOT NULL, + database_meta_data_id VARCHAR, + PRIMARY KEY(database_id) +); +CREATE TABLE results.plp_tars ( + tar_id INT NOT NULL, + tar_start_day INT, + tar_start_anchor VARCHAR, + tar_end_day INT, + tar_end_anchor VARCHAR, + PRIMARY KEY(tar_id) +); +CREATE TABLE results.plp_population_settings ( + population_setting_id INT NOT NULL, + population_settings_json TEXT, + PRIMARY KEY(population_setting_id) +); +CREATE TABLE results.plp_covariate_settings ( + covariate_setting_id INT NOT NULL, + covariate_settings_json TEXT, + PRIMARY KEY(covariate_setting_id) +); +CREATE TABLE results.plp_model_settings ( + model_setting_id INT NOT NULL, + model_type VARCHAR, + model_settings_json VARCHAR, + PRIMARY KEY(model_setting_id) +); +CREATE TABLE results.plp_split_settings ( + split_setting_id INT NOT NULL, + split_settings_json TEXT, + PRIMARY KEY(split_setting_id) +); +CREATE TABLE results.plp_plp_data_settings ( + plp_data_setting_id INT NOT NULL, + plp_data_settings_json TEXT, + PRIMARY KEY(plp_data_setting_id) +); +CREATE TABLE results.plp_feature_engineering_settings ( + feature_engineering_setting_id INT NOT NULL, + feature_engineering_settings_json TEXT, + PRIMARY KEY(feature_engineering_setting_id) +); +CREATE TABLE results.plp_tidy_covariates_settings ( + tidy_covariates_setting_id INT NOT NULL, + tidy_covariates_settings_json TEXT, + PRIMARY KEY(tidy_covariates_setting_id) +); +CREATE TABLE results.plp_sample_settings ( + sample_setting_id INT NOT NULL, + sample_settings_json TEXT, + PRIMARY KEY(sample_setting_id) +); +CREATE TABLE results.plp_model_designs ( + model_design_id INT NOT NULL, + target_id INT, + outcome_id INT, + tar_id INT, + plp_data_setting_id INT, + population_setting_id INT, + model_setting_id INT, + covariate_setting_id INT, + sample_setting_id INT, + split_setting_id INT, + feature_engineering_setting_id INT, + tidy_covariates_setting_id INT, + PRIMARY KEY(model_design_id) +); +CREATE TABLE results.plp_diagnostics ( + diagnostic_id INT NOT NULL, + model_design_id INT, + database_id INT, + execution_date_time VARCHAR, + PRIMARY KEY(diagnostic_id) +); +CREATE TABLE results.plp_diagnostic_summary ( + diagnostic_id INT, + probast_id VARCHAR, + result_value VARCHAR +); +CREATE TABLE results.plp_diagnostic_predictors ( + diagnostic_id INT, + days_to_event INT, + outcome_at_time INT, + observed_at_start_of_day BIGINT, + input_type VARCHAR +); +CREATE TABLE results.plp_diagnostic_participants ( + diagnostic_id INT, + design VARCHAR, + metric VARCHAR, + value NUMERIC, + probast_id VARCHAR +); +CREATE TABLE results.plp_diagnostic_outcomes ( + diagnostic_id INT, + xvalue INT, + outcome_percent NUMERIC, + aggregation VARCHAR, + probast_id VARCHAR, + input_type VARCHAR +); +CREATE TABLE results.plp_diagnostic_designs ( + diagnostic_id INT NOT NULL, + probast_id VARCHAR, + value VARCHAR, + PRIMARY KEY(diagnostic_id) +); +CREATE TABLE results.plp_models ( + model_id INT NOT NULL, + analysis_id VARCHAR, + model_design_id INT, + database_id INT, + model_type VARCHAR, + plp_model_file TEXT, + train_details TEXT, + preprocessing TEXT, + execution_date_time VARCHAR, + training_time VARCHAR, + intercept NUMERIC, + PRIMARY KEY(model_id) +); +CREATE TABLE results.plp_recalibrations ( + recalibration_id INT NOT NULL, + original_model_id INT, + recalibrated_model_id INT, + recalibration_type VARCHAR, + recalibration_json VARCHAR, + PRIMARY KEY(recalibration_id) +); +CREATE TABLE results.plp_performances ( + performance_id INT NOT NULL, + model_design_id INT, + development_database_id INT, + validation_database_id INT, + target_id INT, + outcome_id INT, + tar_id INT, + plp_data_setting_id INT, + population_setting_id INT, + model_development INT, + execution_date_time VARCHAR, + plp_version VARCHAR, + PRIMARY KEY(performance_id) +); +CREATE TABLE results.plp_attrition ( + performance_id INT, + outcome_id INT, + description VARCHAR, + target_count INT, + unique_people INT, + outcomes INT +); +CREATE TABLE results.plp_prediction_distribution ( + performance_id INT, + evaluation VARCHAR, + class_label INT, + person_count INT, + average_predicted_probability NUMERIC, + st_dev_predicted_probability NUMERIC, + min_predicted_probability NUMERIC, + p_05_predicted_probability NUMERIC, + p_25_predicted_probability NUMERIC, + median_predicted_probability NUMERIC, + p_75_predicted_probability NUMERIC, + p_95_predicted_probability NUMERIC, + max_predicted_probability NUMERIC +); +CREATE TABLE results.plp_covariate_summary ( + performance_id INT, + covariate_id BIGINT, + covariate_name VARCHAR, + concept_id NUMERIC, + covariate_value NUMERIC, + covariate_count INT, + covariate_mean NUMERIC, + covariate_st_dev NUMERIC, + with_no_outcome_covariate_count INT, + with_no_outcome_covariate_mean NUMERIC, + with_no_outcome_covariate_st_dev NUMERIC, + with_outcome_covariate_count INT, + with_outcome_covariate_mean NUMERIC, + with_outcome_covariate_st_dev NUMERIC, + standardized_mean_diff NUMERIC +); +CREATE TABLE results.plp_threshold_summary ( + performance_id INT, + evaluation VARCHAR, + prediction_threshold NUMERIC, + preference_threshold NUMERIC, + positive_count INT, + negative_count INT, + true_count INT, + false_count INT, + true_positive_count INT, + true_negative_count INT, + false_positive_count INT, + false_negative_count INT, + f_1_score NUMERIC, + accuracy NUMERIC, + sensitivity NUMERIC, + false_negative_rate NUMERIC, + false_positive_rate NUMERIC, + specificity NUMERIC, + positive_predictive_value NUMERIC, + false_discovery_rate NUMERIC, + negative_predictive_value NUMERIC, + false_omission_rate NUMERIC, + positive_likelihood_ratio NUMERIC, + negative_likelihood_ratio NUMERIC, + diagnostic_odds_ratio NUMERIC +); +CREATE TABLE results.plp_calibration_summary ( + performance_id INT, + evaluation VARCHAR, + prediction_threshold NUMERIC, + person_count_at_risk INT, + person_count_with_outcome INT, + average_predicted_probability NUMERIC, + st_dev_predicted_probability NUMERIC, + min_predicted_probability NUMERIC, + p_25_predicted_probability NUMERIC, + median_predicted_probability NUMERIC, + p_75_predicted_probability NUMERIC, + max_predicted_probability NUMERIC, + observed_incidence NUMERIC +); +CREATE TABLE results.plp_evaluation_statistics ( + performance_id INT, + evaluation VARCHAR, + metric VARCHAR, + value NUMERIC +); +CREATE TABLE results.plp_demographic_summary ( + performance_id INT, + evaluation VARCHAR, + age_group VARCHAR, + gen_group VARCHAR, + person_count_at_risk INT, + person_count_with_outcome INT, + average_predicted_probability NUMERIC, + st_dev_predicted_probability NUMERIC, + min_predicted_probability NUMERIC, + p_25_predicted_probability NUMERIC, + p_50_predicted_probability NUMERIC, + p_75_predicted_probability NUMERIC, + max_predicted_probability NUMERIC +); +-- SelfControlledCaseSeriesModule Tables +CREATE TABLE results.sccs_analysis ( + analysis_id INT NOT NULL, + description VARCHAR, + definition VARCHAR, + PRIMARY KEY(analysis_id) +); +CREATE TABLE results.sccs_covariate_analysis ( + analysis_id INT NOT NULL, + covariate_analysis_id INT NOT NULL, + covariate_analysis_name VARCHAR, + variable_of_interest INT, + PRIMARY KEY(analysis_id,covariate_analysis_id) +); +CREATE TABLE results.sccs_covariate ( + analysis_id INT NOT NULL, + exposures_outcome_set_id INT NOT NULL, + covariate_id INT NOT NULL, + covariate_name VARCHAR, + era_id INT, + covariate_analysis_id INT, + database_id VARCHAR NOT NULL, + PRIMARY KEY(analysis_id,exposures_outcome_set_id,covariate_id,database_id) +); +CREATE TABLE results.sccs_era ( + exposures_outcome_set_id INT NOT NULL, + analysis_id INT NOT NULL, + era_type VARCHAR NOT NULL, + era_id INT NOT NULL, + era_name VARCHAR, + database_id VARCHAR NOT NULL, + PRIMARY KEY(exposures_outcome_set_id,analysis_id,era_type,era_id,database_id) +); +CREATE TABLE results.sccs_exposures_outcome_set ( + exposures_outcome_set_id INT NOT NULL, + outcome_id INT, + nesting_cohort_id INT, + PRIMARY KEY(exposures_outcome_set_id) +); +CREATE TABLE results.sccs_exposure ( + exposures_outcome_set_id INT NOT NULL, + era_id INT NOT NULL, + true_effect_size NUMERIC, + PRIMARY KEY(exposures_outcome_set_id,era_id) +); +CREATE TABLE results.sccs_spline ( + analysis_id INT NOT NULL, + exposures_outcome_set_id INT NOT NULL, + database_id VARCHAR NOT NULL, + spline_type VARCHAR NOT NULL, + knot_month NUMERIC NOT NULL, + rr NUMERIC, + PRIMARY KEY(analysis_id,exposures_outcome_set_id,database_id,spline_type,knot_month) +); +CREATE TABLE results.sccs_censor_model ( + analysis_id INT NOT NULL, + exposures_outcome_set_id INT NOT NULL, + database_id VARCHAR NOT NULL, + parameter_id INT NOT NULL, + parameter_value NUMERIC, + model_type VARCHAR, + PRIMARY KEY(analysis_id,exposures_outcome_set_id,database_id,parameter_id) +); +CREATE TABLE results.sccs_result ( + analysis_id INT NOT NULL, + exposures_outcome_set_id INT NOT NULL, + covariate_id INT NOT NULL, + rr NUMERIC, + ci_95_lb NUMERIC, + ci_95_ub NUMERIC, + p NUMERIC, + one_sided_p NUMERIC, + outcome_subjects INT, + outcome_events INT, + outcome_observation_periods INT, + covariate_subjects INT, + covariate_days INT, + covariate_eras INT, + covariate_outcomes INT, + observed_days BIGINT, + log_rr NUMERIC, + se_log_rr NUMERIC, + llr NUMERIC, + calibrated_rr NUMERIC, + calibrated_ci_95_lb NUMERIC, + calibrated_ci_95_ub NUMERIC, + calibrated_p NUMERIC, + calibrated_one_sided_p NUMERIC, + calibrated_log_rr NUMERIC, + calibrated_se_log_rr NUMERIC, + database_id VARCHAR NOT NULL, + PRIMARY KEY(analysis_id,exposures_outcome_set_id,covariate_id,database_id) +); +CREATE TABLE results.sccs_covariate_result ( + analysis_id INT NOT NULL, + exposures_outcome_set_id INT NOT NULL, + database_id VARCHAR NOT NULL, + covariate_id INT NOT NULL, + rr NUMERIC, + ci_95_lb NUMERIC, + ci_95_ub NUMERIC, + PRIMARY KEY(analysis_id,exposures_outcome_set_id,database_id,covariate_id) +); +CREATE TABLE results.sccs_attrition ( + sequence_number INT NOT NULL, + description VARCHAR, + analysis_id INT NOT NULL, + exposures_outcome_set_id INT NOT NULL, + covariate_id INT NOT NULL, + database_id VARCHAR NOT NULL, + outcome_subjects INT, + outcome_events INT, + outcome_observation_periods INT, + observed_days BIGINT, + PRIMARY KEY(sequence_number,analysis_id,exposures_outcome_set_id,covariate_id,database_id) +); +CREATE TABLE results.sccs_likelihood_profile ( + log_rr NUMERIC NOT NULL, + log_likelihood NUMERIC, + covariate_id INT NOT NULL, + exposures_outcome_set_id INT NOT NULL, + analysis_id INT NOT NULL, + database_id VARCHAR NOT NULL, + PRIMARY KEY(log_rr,covariate_id,exposures_outcome_set_id,analysis_id,database_id) +); +CREATE TABLE results.sccs_time_trend ( + analysis_id INT NOT NULL, + exposures_outcome_set_id INT NOT NULL, + database_id VARCHAR NOT NULL, + calendar_year INT NOT NULL, + calendar_month INT NOT NULL, + observed_subjects INT, + ratio NUMERIC, + adjusted_ratio NUMERIC, + PRIMARY KEY(analysis_id,exposures_outcome_set_id,database_id,calendar_year,calendar_month) +); +CREATE TABLE results.sccs_time_to_event ( + analysis_id INT NOT NULL, + exposures_outcome_set_id INT NOT NULL, + database_id VARCHAR NOT NULL, + era_id INT NOT NULL, + week INT NOT NULL, + observed_subjects INT, + outcomes INT, + PRIMARY KEY(analysis_id,exposures_outcome_set_id,database_id,era_id,week) +); +CREATE TABLE results.sccs_age_spanning ( + analysis_id INT NOT NULL, + exposures_outcome_set_id INT NOT NULL, + database_id VARCHAR NOT NULL, + age_month INT NOT NULL, + cover_before_after_subjects INT, + PRIMARY KEY(analysis_id,exposures_outcome_set_id,database_id,age_month) +); +CREATE TABLE results.sccs_calendar_time_spanning ( + analysis_id INT NOT NULL, + exposures_outcome_set_id INT NOT NULL, + database_id VARCHAR NOT NULL, + calendar_year INT NOT NULL, + calendar_month INT NOT NULL, + cover_before_after_subjects INT, + PRIMARY KEY(analysis_id,exposures_outcome_set_id,database_id,calendar_year,calendar_month) +); +CREATE TABLE results.sccs_event_dep_observation ( + analysis_id INT NOT NULL, + exposures_outcome_set_id INT NOT NULL, + database_id VARCHAR NOT NULL, + months_to_end INT NOT NULL, + censored INT NOT NULL, + outcomes INT, + PRIMARY KEY(analysis_id,exposures_outcome_set_id,database_id,months_to_end,censored) +); +CREATE TABLE results.sccs_diagnostics_summary ( + analysis_id INT NOT NULL, + exposures_outcome_set_id INT NOT NULL, + covariate_id INT NOT NULL, + database_id VARCHAR NOT NULL, + mdrr NUMERIC, + ease NUMERIC, + time_trend_p NUMERIC, + pre_exposure_p NUMERIC, + mdrr_diagnostic VARCHAR(20), + ease_diagnostic VARCHAR(20), + time_trend_diagnostic VARCHAR(20), + pre_exposure_diagnostic VARCHAR(20), + unblind INT, + unblind_for_evidence_synthesis INT, + PRIMARY KEY(analysis_id,exposures_outcome_set_id,covariate_id,database_id) +); diff --git a/extras/rdms/ohdsi_shiny_modules_sql_queries.csv b/extras/rdms/ohdsi_shiny_modules_sql_queries.csv new file mode 100644 index 00000000..04bec28e --- /dev/null +++ b/extras/rdms/ohdsi_shiny_modules_sql_queries.csv @@ -0,0 +1,136 @@ +"fileName","startLine","endLine","sqlQuery" +"characterization-caseSeries.R","195","224","SELECT distinct s.database_id, d.CDM_SOURCE_ABBREVIATION as database_name,s.setting_id, s.RISK_WINDOW_START, s.RISK_WINDOW_END, s.START_ANCHOR, s.END_ANCHOR, ct1.cohort_name as target_name, ct2.cohort_name as outcome_name from @schema.@c_table_prefixsettings s inner join @schema.@database_meta_table d on s.database_id = d.database_id inner join @schema.@c_table_prefixcohort_details cd on s.setting_id = cd.setting_id and s.database_id = cd.database_id and cd.target_cohort_id = @target_id and cd.outcome_cohort_id = @outcome_id and cd.cohort_type = 'Cases' inner join @schema.@cg_table_prefixcohort_definition ct1 on ct1.cohort_definition_id = cd.target_cohort_id inner join @schema.@cg_table_prefixcohort_definition ct2 on ct2.cohort_definition_id = cd.outcome_cohort_id ;" +"characterization-caseSeries.R","275","306","SELECT case when cov.cohort_type = 'CasesBefore' then 'Before' when cov.cohort_type = 'CasesBetween' then 'During' when cov.cohort_type = 'CaseAfter' then 'After' end as type, cr.covariate_name, s.min_prior_observation, s.outcome_washout_days, s.case_post_outcome_duration, s.case_pre_target_duration, cov.covariate_id, cov.sum_value, cov.average_value from @schema.@c_table_prefixcovariates cov inner join @schema.@c_table_prefixcovariate_ref cr on cov.setting_id = cr.setting_id and cov.database_id = cr.database_id and cov.covariate_id = cr.covariate_id inner join @schema.@c_table_prefixsettings s on cov.setting_id = s.setting_id and cov.database_id = s.database_id where cov.target_cohort_id = @target_id and cov.outcome_cohort_id = @outcome_id and cov.cohort_type in ('CasesBetween','CasesAfter','CasesBefore') --and cov.setting_id = @setting_id and s.risk_window_start = @risk_window_start and s.risk_window_end = @risk_window_end and s.start_anchor = '@start_anchor' and s.end_anchor = '@end_anchor' and cov.database_id = '@database_id' and cr.analysis_id in (109, 110, 217, 218, 305, 417, 418, 505, 605, 713, 805, 926, 927) ;" +"characterization-caseSeries.R","328","361","SELECTcase when cov.cohort_type = 'CasesBefore' then 'Before' when cov.cohort_type = 'CasesBetween' then 'During' when cov.cohort_type = 'CasesAfter' then 'After' end as type, cr.covariate_name, s.min_prior_observation, s.outcome_washout_days, s.case_post_outcome_duration, s.case_pre_target_duration, cov.covariate_id, cov.count_value, cov.min_value, cov.max_value, cov.average_value, cov.standard_deviation, cov.median_value, cov.p_10_value, cov.p_25_value, cov.p_75_value, cov.p_90_value from @schema.@c_table_prefixcovariates_continuous cov inner join @schema.@c_table_prefixcovariate_ref cr on cov.setting_id = cr.setting_id and cov.database_id = cr.database_id and cov.covariate_id = cr.covariate_id inner join @schema.@c_table_prefixsettings s on cov.setting_id = s.setting_id and cov.database_id = s.database_id where cov.target_cohort_id = @target_id and cov.outcome_cohort_id = @outcome_id and cov.cohort_type in ('CasesBetween','CasesAfter','CasesBefore') and s.risk_window_start = @risk_window_start and s.risk_window_end = @risk_window_end and s.start_anchor = '@start_anchor' and s.end_anchor = '@end_anchor' and cov.database_id = '@database_id' and cr.analysis_id in (109, 110, 217, 218, 305, 417, 418, 505, 605, 713, 805, 926, 927) ;" +"characterization-cohorts.R","791","810","select ref.covariate_name, s.min_prior_observation, cov.target_cohort_id as cohort_definition_id, cov.* from @schema.@c_table_prefixCOVARIATES cov inner join @schema.@c_table_prefixcovariate_ref ref on cov.covariate_id = ref.covariate_id and cov.setting_id = ref.setting_id and cov.database_id = ref.database_id inner join @schema.@c_table_prefixsettings s on s.database_id = cov.database_id and s.setting_id = cov.setting_id where cov.target_cohort_id in (@target_ids) and cov.cohort_type = 'Target' AND cov.database_id in (@database_ids) AND cov.average_value >= @min_threshold;" +"characterization-cohorts.R","902","925","select ref.covariate_name, s.min_prior_observation, cov.target_cohort_id as cohort_definition_id, cov.*, d.CDM_SOURCE_ABBREVIATION as database_name from @schema.@c_table_prefixCOVARIATES_continuous cov inner join @schema.@c_table_prefixcovariate_ref ref on cov.covariate_id = ref.covariate_id and cov.setting_id = ref.setting_id and cov.database_id = ref.database_id inner join @schema.@c_table_prefixsettings s on cov.setting_id = s.setting_id and cov.database_id = s.database_id inner join @schema.@database_meta_table d on s.database_id = d.database_id where cov.target_cohort_id in (@target_ids) and cov.cohort_type = 'Target' AND cov.database_id in (@database_ids);" +"characterization-cohorts.R","990","999","select distinct d.database_id, d.cdm_source_abbreviation as database_name from @schema.@database_table d inner join @schema.@c_table_prefixcohort_details cd on d.database_id = cd.database_id where cd.target_cohort_id = @target_id and cd.cohort_type = 'Target' ;" +"characterization-dechallengeRechallenge.R","329","337","SELECT DISTINCT t.COHORT_NAME as target, dr.TARGET_COHORT_DEFINITION_ID, o.COHORT_NAME as outcome, dr.OUTCOME_COHORT_DEFINITION_ID FROM @schema.@c_table_prefixDECHALLENGE_RECHALLENGE dr inner join @schema.@cg_table_prefixCOHORT_DEFINITION t on dr.TARGET_COHORT_DEFINITION_ID = t.COHORT_DEFINITION_ID inner join @schema.@cg_table_prefixCOHORT_DEFINITION o on dr.OUTCOME_COHORT_DEFINITION_ID = o.COHORT_DEFINITION_ID ;" +"characterization-dechallengeRechallenge.R","390","395","SELECT distinct d.CDM_SOURCE_ABBREVIATION as database_name, dr.*FROM @schema.@c_table_prefixDECHALLENGE_RECHALLENGE dr inner join @schema.@database_table d on dr.database_id = d.database_id where dr.TARGET_COHORT_DEFINITION_ID = @target_id and dr.OUTCOME_COHORT_DEFINITION_ID = @outcome_id;" +"characterization-dechallengeRechallenge.R","433","438","SELECT * FROM @schema.@c_table_prefixRECHALLENGE_FAIL_CASE_SERIES where TARGET_COHORT_DEFINITION_ID = @target_id and OUTCOME_COHORT_DEFINITION_ID = @outcome_id and DATABASE_ID = '@database_id' and DECHALLENGE_STOP_INTERVAL = @dechallenge_stop_interval and DECHALLENGE_EVALUATION_WINDOW = @dechallenge_evaluation_window;" +"characterization-dechallengeRechallenge.R","476","480","SELECT cc.database_id, cc.cohort_id, cc.cohort_entries, cc.cohort_subjects FROM @schema.@cg_table_prefixCOHORT_COUNT cc where cc.cohort_id = @cohort_id ;" +"characterization-incidence.R","1702","1724","select d.cdm_source_abbreviation, i.*, ct1.cohort_name as target_name, ct2.cohort_name as outcome_namefrom ( select od.outcome_cohort_definition_id, od.clean_window, agd.age_group_name, tad.tar_start_with, tad.tar_start_offset, tad.tar_end_with, tad.tar_end_offset, sd.subgroup_name, i.* from @result_schema.@incidence_table_prefixINCIDENCE_SUMMARY i join @result_schema.@incidence_table_prefixOUTCOME_DEF od on i.outcome_id = od.outcome_id and i.ref_id = od.ref_id join @result_schema.@incidence_table_prefixTAR_DEF tad on i.tar_id = tad.tar_id and i.ref_id = tad.ref_id join @result_schema.@incidence_table_prefixSUBGROUP_DEF sd on i.subgroup_id = sd.subgroup_id and i.ref_id = sd.ref_id left join @result_schema.@incidence_table_prefixAGE_GROUP_DEF agd on i.age_group_id = agd.age_group_id and i.ref_id = agd.ref_id ) i inner join @result_schema.@database_table_name d on d.database_id = i.database_id inner join @result_schema.@cg_table_prefixcohort_definition ct1 on ct1.cohort_definition_id = i.target_cohort_definition_id inner join @result_schema.@cg_table_prefixcohort_definition ct2 on ct2.cohort_definition_id = i.outcome_cohort_definition_id where i.target_cohort_definition_id in (@target_ids) and i.outcome_cohort_definition_id in (@outcome_ids);" +"characterization-incidence.R","1800","1803","select outcome_id, outcome_name from @result_schema.@incidence_table_prefixOUTCOME_DEF" +"characterization-incidence.R","1879","1881","SELECT TAR_ID, TAR_START_WITH, TAR_START_OFFSET,TAR_END_WITH, TAR_END_OFFSET from @schema.@ci_table_prefixtar_def;" +"characterization-riskFactors.R","208","225","SELECT cohort_type, min_prior_observation, outcome_washout_days, row_count, person_count from @schema.@c_table_prefixcohort_counts where database_id = '@database_id' and target_cohort_id = @target_id and outcome_cohort_id in (@outcome_id, 0) and (risk_window_start = @risk_window_start OR risk_window_start is NULL) and (risk_window_end = @risk_window_end OR risk_window_end is NULL) and (start_anchor = '@start_anchor' OR start_anchor is NULL) and (end_anchor = '@end_anchor' OR end_anchor is NULL) and cohort_type in ('Cases','Exclude','Target') ;" +"characterization-riskFactors.R","256","272","SELECT distinct setting_idfrom @schema.@c_table_prefixsettings where database_id = '@database_id' and risk_window_start = @risk_window_start and risk_window_end = @risk_window_end and start_anchor = '@start_anchor' and end_anchor = '@end_anchor' union SELECT distinct setting_id from @schema.@c_table_prefixsettings where database_id = '@database_id' and risk_window_start is NULL ;" +"characterization-riskFactors.R","287","308","SELECT distinct cov.cohort_type, cr.covariate_name, s.min_prior_observation, s.outcome_washout_days, cov.covariate_id, cov.sum_value, cov.average_value from @schema.@c_table_prefixcovariates cov inner join @schema.@c_table_prefixcovariate_ref cr on cov.setting_id = cr.setting_id and cov.database_id = cr.database_id and cov.covariate_id = cr.covariate_id inner join @schema.@c_table_prefixsettings s on cov.setting_id = s.setting_id and cov.database_id = s.database_id where cov.target_cohort_id = @target_id and cov.outcome_cohort_id in (0,@outcome_id) and cov.cohort_type in ('Target','Cases', 'Exclude') and cov.database_id = '@database_id' and cov.setting_id in (@setting_ids) and cr.analysis_id not in (109, 110, 217, 218, 305, 417, 418, 505, 605, 713, 805, 926, 927) ;" +"characterization-riskFactors.R","328","350","SELECT distinct cov.cohort_type, cr.covariate_name, s.min_prior_observation, s.outcome_washout_days,cov.covariate_id, cov.count_value, cov.min_value, cov.max_value, cov.average_value, cov.standard_deviation, cov.median_value, cov.p_10_value, cov.p_25_value, cov.p_75_value, cov.p_90_value from @schema.@c_table_prefixcovariates_continuous cov inner join @schema.@c_table_prefixcovariate_ref cr on cov.setting_id = cr.setting_id and cov.database_id = cr.database_id and cov.covariate_id = cr.covariate_id inner join @schema.@c_table_prefixsettings s on cov.setting_id = s.setting_id and cov.database_id = s.database_id where cov.target_cohort_id = @target_id and cov.outcome_cohort_id in (0,@outcome_id) and cov.cohort_type in ('Target','Cases', 'Exclude') and cov.database_id = '@database_id' and cov.setting_id in (@setting_ids) and cr.analysis_id not in (109, 110, 217, 218, 305, 417, 418, 505, 605, 713, 805, 926, 927) ;" +"characterization-timeToEvent.R","265","270","SELECT tte.*, d.CDM_SOURCE_ABBREVIATION as database_name FROM @schema.@c_table_prefixTIME_TO_EVENT tte inner join @schema.@database_table d on tte.database_id = d.database_id where tte.TARGET_COHORT_DEFINITION_ID = @target_id and tte.OUTCOME_COHORT_DEFINITION_ID = @outcome_id;" +"cohort-diagnostics-characterization.R","923","933","SELECT @select_stament FROM @results_database_schema.@table_prefixtemporal_covariate_ref tcr INNER JOIN @results_database_schema.@table_prefixtemporal_analysis_ref tar ON tar.analysis_id = tcr.analysis_id LEFT JOIN @results_database_schema.@table_prefixtemporal_covariate_value tcv ON ( tcr.covariate_id = tcv.covariate_id ) LEFT JOIN @results_database_schema.@table_prefixtemporal_time_ref ttr ON ttr.time_id = tcv.time_id WHERE tcr.covariate_id IS NOT NULL" +"cohort-diagnostics-conceptsInDataSource.R","80","117","SELECT concepts.*,c.concept_name, c.vocabulary_id, c.domain_id, c.standard_concept, c.concept_code FROM ( SELECT isc.database_id, isc.cohort_id, isc.concept_id, 0 source_concept_id, max(concept_subjects) concept_subjects, sum(concept_count) concept_count FROM @schema.@table_name isc WHERE isc.cohort_id = @cohort_id AND isc.database_id IN (@database_ids) GROUP BY isc.database_id, isc.cohort_id, isc.concept_id UNION SELECT c.database_id, c.cohort_id, c.source_concept_id as concept_id, 1 source_concept_id, max(c.concept_subjects) concept_subjects, sum(c.concept_count) concept_count FROM @schema.@table_name c WHERE c.cohort_id = @cohort_id AND c.database_id IN (@database_ids) GROUP BY c.database_id, c.cohort_id, c.source_concept_id ) concepts INNER JOIN @schema.@concept_table c ON concepts.concept_id = c.concept_id WHERE c.invalid_reason IS NULL;" +"cohort-diagnostics-databaseInformation.R","61","63","SELECT *FROM @schema.@metadata WHERE database_id = @database_id;" +"cohort-diagnostics-definition.R","213","214","SELECT * FROM @schema.@cohort_table WHERE cohort_id IN (@cohort_ids)" +"cohort-diagnostics-definition.R","447","450","SELECT ics.*FROM @schema.@table_name ics WHERE ics.cohort_id = @cohort_id AND database_id in (@database_ids);" +"cohort-diagnostics-incidenceRates.R","20","20","SELECT DISTINCT age_group FROM @schema.@ir_table WHERE person_years >= @person_years" +"cohort-diagnostics-incidenceRates.R","31","31","SELECT DISTINCT calendar_year FROM @schema.@ir_table WHERE person_years >= @person_years" +"cohort-diagnostics-incidenceRates.R","45","45","SELECT DISTINCT gender FROM @schema.@ir_table WHERE person_years >= @person_years" +"cohort-diagnostics-incidenceRates.R","57","63","SELECTmin(incidence_rate) as min_ir, max(incidence_rate) as max_ir FROM @schema.@ir_table WHERE person_years >= @person_years AND incidence_rate > 0.0" +"cohort-diagnostics-incidenceRates.R","118","128","SELECT ir.*, cc.cohort_subjectsFROM @schema.@ir_table ir INNER JOIN @schema.@cc_table cc ON ( ir.database_id = cc.database_id AND ir.cohort_id = cc.cohort_id ) WHERE ir.cohort_id in (@cohort_ids) AND ir.database_id in (@database_ids) {@gender == TRUE} ? {AND ir.gender IS NOT NULL} : { AND ir.gender IS NULL} {@age_group == TRUE} ? {AND ir.age_group IS NOT NULL} : { AND ir.age_group IS NULL} {@calendar_year == TRUE} ? {AND ir.calendar_year IS NOT NULL} : { AND ir.calendar_year IS NULL} AND ir.person_years > @personYears;" +"cohort-diagnostics-indexEventBreakdown.R","99","109","SELECT index_event_breakdown.*,concept.concept_name, concept.domain_id, concept.vocabulary_id, concept.standard_concept, concept.concept_code FROM @schema.@table_name index_event_breakdown INNER JOIN @vocabulary_database_schema.@concept_table concept ON index_event_breakdown.concept_id = concept.concept_id WHERE database_id in (@database_id) AND cohort_id in (@cohort_ids);" +"cohort-diagnostics-main.R","19","19","SELECT table_name FROM information_schema.tables where table_schema = '@schema'" +"cohort-diagnostics-main.R","83","83","SELECT * FROM @schema.@table LIMIT 1" +"cohort-diagnostics-main.R","101","109","select c.relname as table_name from pg_class c inner join pg_namespace n on n.oid = c.relnamespace where c.relkind = 'r' and n.nspname not in ('information_schema','pg_catalog') and c.reltuples != 0 and n.nspname = '@schema'" +"cohort-diagnostics-main.R","366","367","SELECT * FROM @schema.@table_name;" +"cohort-diagnostics-orphanConcepts.R","129","153","SELECT c.concept_id, c.concept_name, c.vocabulary_id, c.concept_code, CASE WHEN c.standard_concept = 'S' THEN 'Standard' ELSE 'Non-standard' END as standard_concept %s FROM @schema.@orphan_table_name oc INNER JOIN @schema.@cs_table_name cs ON oc.cohort_id = cs.cohort_id AND oc.concept_set_id = cs.concept_set_id INNER JOIN @vocabulary_database_schema.@concept_table c ON oc.concept_id = c.concept_id WHERE oc.cohort_id = @cohort_id AND database_id in (@database_ids) {@search_str != ''} ? {AND lower(CONCAT(c.concept_id, c.concept_name, c.vocabulary_id, c.concept_code)) LIKE lower('%%@search_str%%')} {@use_concept_set_id} ? { AND oc.concept_set_id IN (@concept_set_id)} GROUP BY c.concept_id, c.concept_name, c.vocabulary_id, c.concept_code, c.standard_concept {@sort_by != \" +"cohort-diagnostics-shared.R","93","99","SELECT cc.*, db.database_name# FROM @schema.@table_name cc # INNER JOIN @schema.@database_table db ON db.database_id = cc.database_id # WHERE cc.cohort_id IS NOT NULL # {@use_database_ids} ? { AND cc.database_id in (@database_ids)} # {@cohort_ids != ''} ? { AND cc.cohort_id in (@cohort_ids)} # ;" +"cohort-diagnostics-shared.R","101","106","SELECT cc.*FROM @schema.@table_name cc WHERE cc.cohort_id IS NOT NULL {@use_database_ids} ? { AND cc.database_id in (@database_ids)} {@cohort_ids != ''} ? { AND cc.cohort_id in (@cohort_ids)} ;" +"cohort-diagnostics-shared.R","129","131","SELECT *FROM @schema.@database_table WHERE database_id in (@database_ids);" +"cohort-diagnostics-shared.R","986","990","SELECT *FROM @schema.@table_name WHERE database_id in (@database_id) {@cohort_ids != ''} ? { AND cohort_id in (@cohort_ids)} ;" +"cohort-diagnostics-visitContext.R","91","97","SELECT visit_context.*,standard_concept.concept_name AS visit_concept_name FROM @schema.@table_name visit_context INNER JOIN @vocabulary_database_schema.@concept_table standard_concept ON visit_context.visit_concept_id = standard_concept.concept_id WHERE database_id in (@database_id) AND cohort_id in (@cohort_ids);" +"cohort-generator-main.R","643","650","SELECT cc.cohort_id, cc.cohort_entries, cc.cohort_subjects,dt.cdm_source_name, cd.cohort_name FROM @schema.@cg_table_prefixCOHORT_COUNT cc join @schema.@database_table_prefix@database_table dt on cc.database_id = dt.database_id join @schema.@cg_table_prefixCOHORT_DEFINITION cd on cd.cohort_definition_id = cc.cohort_id ;" +"cohort-generator-main.R","667","672","SELECT cg.cohort_id, cg.cohort_name,cg.generation_status, cg.start_time, cg.end_time, dt.cdm_source_name from @schema.@cg_table_prefixCOHORT_GENERATION cg join @schema.@database_table_prefix@database_table dt on cg.database_id = dt.database_id ;" +"cohort-generator-main.R","708","715","SELECT css.cohort_definition_id, css.base_count, css.final_count, css.mode_id,dt.cdm_source_name, cd.cohort_name FROM @schema.@cg_table_prefixCOHORT_SUMMARY_STATS css join @schema.@database_table_prefix@database_table dt on css.database_id = dt.database_id join @schema.@cg_table_prefixCOHORT_DEFINITION cd on cd.cohort_definition_id = css.cohort_definition_id ;" +"cohort-generator-main.R","734","738","SELECT ci.cohort_definition_id, ci.rule_sequence, ci.name as rule_name,cd.cohort_name FROM @schema.@cg_table_prefixCOHORT_INCLUSION ci join @schema.@cg_table_prefixCOHORT_DEFINITION cd on cd.cohort_definition_id = ci.cohort_definition_id ;" +"cohort-generator-main.R","753","757","SELECT cir.database_id, cir.cohort_definition_id, cir.inclusion_rule_mask, cir.person_count, cir.mode_id,dt.cdm_source_name FROM @schema.@cg_table_prefixCOHORT_INC_RESULT cir join @schema.@database_table_prefix@database_table dt on cir.database_id = dt.database_id ;" +"data-diagnostic-drill.R","254","255","SELECT * FROM @schema.@dd_table_prefixdata_diagnostics_output WHERE analysis_name = '@analysis_name' and database_id = '@database_id';" +"data-diagnostic-drill.R","276","276","SELECT distinct database_id FROM @schema.@dd_table_prefixdata_diagnostics_summary;" +"data-diagnostic-drill.R","303","304","SELECT * FROM @schema.@dd_table_prefixdata_diagnostics_summary WHERE analysis_name in ('@analysis');" +"data-diagnostic-drill.R","333","334","SELECT distinct database_id FROM @schema.@dd_table_prefixdata_diagnostics_summary WHERE analysis_name in ('@analysis');" +"data-diagnostic-summary.R","145","146","SELECT distinct sum.analysis_name FROM @schema.@dd_table_prefixdata_diagnostics_summary as sum;" +"data-diagnostic-summary.R","169","176","SELECT distinct sum.analysis_id, sum.analysis_name, sum.database_id, sum.total_fails FROM @schema.@dd_table_prefixdata_diagnostics_summary as sum where sum.analysis_name in (@names);" +"datasources-main.R","192","193","SELECT * from @schema.@database_table ;" +"estimation-cohort-method-attrition.R","120","130","SELECT cmat.* FROM @schema.@cm_table_prefixattrition cmat WHERE cmat.target_id = @target_id AND cmat.comparator_id = @comparator_id AND cmat.outcome_id = @outcome_id AND cmat.analysis_id = @analysis_id AND cmat.database_id = '@database_id';" +"estimation-cohort-method-covariateBalance.R","330","334","select distinct d.cdm_source_abbreviation, i.database_id from @result_schema.@cm_table_prefixCOVARIATE_BALANCE i inner join @result_schema.@database_table_name d on d.database_id = i.database_id ;" +"estimation-cohort-method-covariateBalance.R","359","380","SELECT cmscb.database_id, cmc.covariate_name, --cmc.analysis_id analysis_id, cmscb.target_mean_before before_matching_mean_treated, cmscb.comparator_mean_before before_matching_mean_comparator, abs(cmscb.std_diff_before) abs_before_matching_std_diff, --absBeforeMatchingStdDiff cmscb.target_mean_after after_matching_mean_treated, cmscb.comparator_mean_after after_matching_mean_comparator, abs(cmscb.std_diff_after) abs_after_matching_std_diff FROM @results_schema.@cm_table_prefixshared_covariate_balance cmscb JOIN @results_schema.@cm_table_prefixcovariate cmc ON cmscb.covariate_id = cmc.covariate_id AND cmscb.analysis_id = cmc.analysis_id AND cmscb.database_id = cmc.database_id -- database_id optional -- JOIN @results_schema.@cm_table_prefixcovariate_analysis cmca ON cmca.analysis_id = cmc.analysis_id -- question: shouldn't we have a covariate_analysis_id in @table_prefixcovariate table? WHERE cmscb.target_id = @target_id AND cmscb.comparator_id = @comparator_id AND cmscb.analysis_id = @analysis_id --AND cmc.covariate_analysis_id = @covariate_analysis_id AND cmscb.database_id = '@database_id'" +"estimation-cohort-method-covariateBalance.R","601","602","select distinct covariate_analysis_id, covariate_analysis_name from @result_schema.@cm_table_prefixCOVARIATE_ANALYSIS;" +"estimation-cohort-method-covariateBalance.R","632","651","SELECT DISTINCT dmd.cdm_source_abbreviation database_name, cmds.analysis_id, cmds.target_id, cmds.comparator_id, cmds.outcome_id, cmds.max_sdm, cmds.ease FROM @schema.@cm_table_prefixdiagnostics_summary cmds INNER JOIN @schema.@database_table dmd ON dmd.database_id = cmds.database_id where cmds.target_id = @target_id and cmds.comparator_id = @comparator_id and cmds.outcome_id = @outcome_id and cmds.analysis_id = @analysis_id and cmds.database_id = '@database_id' ;" +"estimation-cohort-method-diagnostics.R","63","94","SELECT DISTINCT dmd.cdm_source_abbreviation database_name, cma.description analysis, cgcd1.cohort_name target, cgcd2.cohort_name comparator, cgcd3.cohort_name outcome, cmds.max_sdm, cmds.shared_max_sdm, cmds.equipoise, cmds.mdrr, cmds.ease, cmds.balance_diagnostic, cmds.shared_balance_diagnostic, -- added back cmds.equipoise_diagnostic, cmds.mdrr_diagnostic, cmds.ease_diagnostic, cmds.unblind FROM @schema.@cm_table_prefixdiagnostics_summary cmds INNER JOIN @schema.@cm_table_prefixanalysis cma ON cmds.analysis_id = cma.analysis_id INNER JOIN @schema.@database_table dmd ON dmd.database_id = cmds.database_id INNER JOIN @schema.@cg_table_prefixcohort_definition cgcd1 ON cmds.target_id = cgcd1.cohort_definition_id INNER JOIN @schema.@cg_table_prefixcohort_definition cgcd2 ON cmds.comparator_id = cgcd2.cohort_definition_id INNER JOIN @schema.@cg_table_prefixcohort_definition cgcd3 ON cmds.outcome_id = cgcd3.cohort_definition_id where cgcd1.cohort_definition_id in (@targets) {@use_comparators}?{and cgcd2.cohort_definition_id in (@comparators)} and cgcd3.cohort_definition_id in (@outcomes) {@use_analyses}?{and cma.analysis_id in (@analyses)} ;" +"estimation-cohort-method-kaplainMeier.R","144","155","SELECT * FROM @schema.@cm_table_prefixkaplan_meier_dist cmkmd WHERE cmkmd.target_id = @target_id AND cmkmd.comparator_id = @comparator_id AND cmkmd.outcome_id = @outcome_id AND cmkmd.analysis_id = @analysis_id AND cmkmd.database_id = '@database_id';" +"estimation-cohort-method-populationCharacteristics.R","176","202","SELECT cmcb.database_id, cmcb.covariate_id, cmc.covariate_name, cmc.covariate_analysis_id analysis_id, cmcb.target_mean_before before_ps_adjustment_mean_treated, cmcb.comparator_mean_before before_ps_adjustment_mean_comparator, abs(cmcb.std_diff_before) abs_before_ps_adjustment_std_diff, cmcb.target_mean_after after_ps_adjustment_mean_treated, cmcb.comparator_mean_after after_ps_adjustment_mean_comparator, abs(cmcb.std_diff_after) abs_after_ps_adjustment_std_diff FROM (select * from @schema.@cm_table_prefixcovariate_balance WHERE target_id = @target_id AND comparator_id = @comparator_id AND outcome_id = @outcome_id AND analysis_id = @analysis_id AND database_id = '@database_id' ) as cmcb INNER JOIN @schema.@cm_table_prefixcovariate cmc ON cmcb.covariate_id = cmc.covariate_id AND cmcb.analysis_id = cmc.analysis_id AND cmcb.database_id = cmc.database_id -- database_id optional" +"estimation-cohort-method-power.R","394","399","SELECT cma.* FROM @schema.@cm_table_prefixanalysis cma" +"estimation-cohort-method-power.R","423","433","SELECT * FROM @schema.@cm_table_prefixfollow_up_dist cmfud WHERE cmfud.target_id = @target_id AND cmfud.comparator_id = @comparator_id AND cmfud.outcome_id = @outcome_id AND cmfud.analysis_id = @analysis_id" +"estimation-cohort-method-propensityModel.R","145","171","SELECT cmc.covariate_id, cmc.covariate_name, cmpm.coefficient FROM ( SELECT covariate_id, covariate_name FROM @schema.@cm_table_prefixcovariate WHERE analysis_id = @analysis_id AND database_id = '@database_id' UNION SELECT 0 as covariate_id, 'intercept' as covariate_name) cmc JOIN @schema.@cm_table_prefixpropensity_model cmpm ON cmc.covariate_id = cmpm.covariate_id WHERE cmpm.target_id = @target_id AND cmpm.comparator_id = @comparator_id AND cmpm.analysis_id = @analysis_id AND cmpm.database_id = '@database_id'" +"estimation-cohort-method-propensityScoreDistribution.R","139","149","SELECT database_id, target_id, comparator_id, outcome_id, analysis_id, equipoise FROM @schema.@cm_table_prefixdiagnostics_summary cmpsd WHERE cmpsd.target_id = @target_id AND cmpsd.comparator_id = @comparator_id AND cmpsd.analysis_id = @analysis_id AND cmpsd.outcome_id = @outcome_id" +"estimation-cohort-method-propensityScoreDistribution.R","187","196","SELECT * FROM @schema.@cm_table_prefixpreference_score_dist cmpsd WHERE cmpsd.target_id = @target_id AND cmpsd.comparator_id = @comparator_id AND cmpsd.analysis_id = @analysis_id" +"estimation-cohort-method-results.R","297","356","SELECT cma.analysis_id, cma.description description, dmd.database_id database_id, dmd.cdm_source_abbreviation cdm_source_abbreviation, cmr.target_id, cg1.cohort_name as target, cmr.outcome_id, cg2.cohort_name as outcome, cmr.comparator_id, cg3.cohort_name as comparator, case when COALESCE(cmds.unblind, 0) = 0 then NULL else cmr.rr end rr, case when COALESCE(cmds.unblind, 0) = 0 then NULL else cmr.ci_95_lb end ci_95_lb, case when COALESCE(cmds.unblind, 0) = 0 then NULL else cmr.ci_95_ub end ci_95_ub, case when COALESCE(cmds.unblind, 0) = 0 then NULL else cmr.p end p, case when COALESCE(cmds.unblind, 0) = 0 then NULL else cmr.log_rr end log_rr, case when COALESCE(cmds.unblind, 0) = 0 then NULL else cmr.se_log_rr end se_log_rr, cmr.target_subjects, cmr.comparator_subjects, cmr.target_days, cmr.comparator_days, cmr.target_outcomes, cmr.comparator_outcomes, case when COALESCE(cmds.unblind, 0) = 0 then NULL else cmr.calibrated_rr end calibrated_rr, case when COALESCE(cmds.unblind, 0) = 0 then NULL else cmr.calibrated_ci_95_lb end calibrated_ci_95_lb, case when COALESCE(cmds.unblind, 0) = 0 then NULL else cmr.calibrated_ci_95_ub end calibrated_ci_95_ub, case when COALESCE(cmds.unblind, 0) = 0 then NULL else cmr.calibrated_p end calibrated_p, case when COALESCE(cmds.unblind, 0) = 0 then NULL else cmr.calibrated_log_rr end calibrated_log_rr, case when COALESCE(cmds.unblind, 0) = 0 then NULL else cmr.calibrated_se_log_rr end calibrated_se_log_rr, COALESCE(cmds.unblind, 0) unblind FROM @schema.@cm_table_prefixanalysis cma JOIN @schema.@cm_table_prefixresult cmr on cmr.analysis_id = cma.analysis_id JOIN @schema.@database_table dmd on dmd.database_id = cmr.database_id LEFT JOIN @schema.@cm_table_prefixdiagnostics_summary cmds on cmds.analysis_id = cmr.analysis_id AND cmds.target_id = cmr.target_id AND cmds.comparator_id = cmr.comparator_id AND cmds.outcome_id = cmr.outcome_id AND cmds.database_id = cmr.database_id inner join @schema.@cg_table_prefixcohort_definition cg1 on cg1.cohort_definition_id = cmr.target_id inner join @schema.@cg_table_prefixcohort_definition cg2 on cg2.cohort_definition_id = cmr.outcome_id inner join @schema.@cg_table_prefixcohort_definition cg3 on cg3.cohort_definition_id = cmr.comparator_id where cmr.target_id in (@targets) {@use_comparators}?{and cmr.comparator_id in (@comparators)} and cmr.outcome_id in (@outcomes) ;" +"estimation-cohort-method-results.R","386","461","select r.analysis_id, a.description, 0 as database_id, ev.evidence_synthesis_description as cdm_source_abbreviation, r.target_id, c1.cohort_name as target, r.outcome_id, c3.cohort_name as outcome, r.comparator_id, c2.cohort_name as comparator, NULL as rr, NULL as ci_95_lb, NULL as ci_95_ub, NULL as p, NULL as log_rr, NULL as se_log_rr, 0 as target_subjects, 0 as comparator_subjects, 0 as target_days, 0 as comparator_days, 0 as target_outcomes, 0 as comparator_outcomes, r.calibrated_rr, r.calibrated_ci_95_lb, r.calibrated_ci_95_ub, r.calibrated_p, r.calibrated_log_rr, r.calibrated_se_log_rr, 1 unblind from @schema.@es_table_prefixcm_result as r inner join @schema.@cm_table_prefixtarget_comparator_outcome as tco on r.target_id = tco.target_id and r.comparator_id = tco.comparator_id and r.outcome_id = tco.outcome_id inner join @schema.@es_table_prefixcm_diagnostics_summary as unblind on r.analysis_id = unblind.analysis_id and r.target_id = unblind.target_id and r.comparator_id = unblind.comparator_id and r.outcome_id = unblind.outcome_id inner join @schema.@cg_table_prefixcohort_definition as c1 on c1.cohort_definition_id = r.target_id inner join @schema.@cg_table_prefixcohort_definition as c2 on c2.cohort_definition_id = r.comparator_id inner join @schema.@cg_table_prefixcohort_definition as c3 on c3.cohort_definition_id = r.outcome_id inner join @schema.@cm_table_prefixanalysis as a on a.analysis_id = r.analysis_id inner join @schema.@es_table_prefixanalysis as ev on ev.evidence_synthesis_analysis_id = r.evidence_synthesis_analysis_id where r.calibrated_rr != 0 and tco.outcome_of_interest = 1 and unblind.unblind = 1 and r.target_id in (@target_ids) and r.outcome_id = @outcome_id ;" +"estimation-cohort-method-systematicError.R","161","174","SELECT cmr.*, cmtco.true_effect_size effect_size FROM @schema.@cm_table_prefixresult cmr JOIN @schema.@cm_table_prefixtarget_comparator_outcome cmtco ON cmr.target_id = cmtco.target_id AND cmr.comparator_id = cmtco.comparator_id AND cmr.outcome_id = cmtco.outcome_id WHERE cmtco.outcome_of_interest != 1 AND cmr.target_id = @target_id AND cmr.comparator_id = @comparator_id AND cmr.analysis_id = @analysis_id" +"estimation-cohort-method-systematicError.R","321","338","SELECT DISTINCT dmd.cdm_source_abbreviation database_name, cmds.analysis_id, cmds.target_id, cmds.comparator_id, cmds.max_sdm, cmds.ease FROM @schema.@cm_table_prefixdiagnostics_summary cmds INNER JOIN @schema.@database_table dmd ON dmd.database_id = cmds.database_id where cmds.target_id = @target_id and cmds.comparator_id = @comparator_id and cmds.analysis_id = @analysis_id and cmds.database_id = '@database_id' ;" +"estimation-sccs-diagnostics.R","57","102","SELECT d.cdm_source_abbreviation as database_name, a.description as analysis, c2.cohort_name as target, c3.cohort_name as indication, c.cohort_name as outcome, cov.covariate_name, ds.* FROM @schema.@sccs_table_prefixdiagnostics_summary ds inner join @schema.@sccs_table_prefixexposures_outcome_set eos on ds.exposures_outcome_set_id = eos.exposures_outcome_set_id inner join @schema.@cg_table_prefixcohort_definition as c on c.cohort_definition_id = eos.outcome_id INNER JOIN @schema.@database_table_prefix@database_table d on d.database_id = ds.database_id INNER JOIN @schema.@sccs_table_prefixanalysis a on a.analysis_id = ds.analysis_id INNER JOIN @schema.@sccs_table_prefixcovariate cov on cov.covariate_id = ds.covariate_id and cov.exposures_outcome_set_id = ds.exposures_outcome_set_id and cov.analysis_id = ds.analysis_id and cov.database_id = ds.database_id inner join @schema.@cg_table_prefixcohort_definition as c2 on cov.era_id = c2.cohort_definition_id left join @schema.@cg_table_prefixcohort_definition as c3 on eos.nesting_cohort_id = c3.cohort_definition_id where cov.era_id in (@target_ids) and eos.outcome_id in (@outcome_ids) ;" +"estimation-sccs-results-full.R","459","467","SELECT * FROM @schema.@sccs_table_prefixattrition WHERE database_id = '@database_id' AND analysis_id = @analysis_id AND exposures_outcome_set_id = @exposures_outcome_set_id AND covariate_id = @covariate_id" +"estimation-sccs-results-full.R","489","517","SELECT CASE WHEN era.era_name IS NULL THEN sc.covariate_name ELSE CONCAT(sc.covariate_name, ' : ', era.era_name) END as covariate_name, scr.covariate_id, scr.rr, scr.ci_95_lb, scr.ci_95_ub FROM @schema.@sccs_table_prefixcovariate_result scr INNER JOIN @schema.@sccs_table_prefixcovariate sc ON ( sc.exposures_outcome_set_id = scr.exposures_outcome_set_id AND sc.database_id = scr.database_id AND sc.analysis_id = scr.analysis_id AND sc.covariate_id = scr.covariate_id ) LEFT JOIN @schema.@cg_table_prefixcohort_definition cd ON cd.cohort_definition_id = sc.era_id LEFT JOIN @schema.@sccs_table_prefixera era ON ( era.exposures_outcome_set_id = scr.exposures_outcome_set_id AND era.database_id = scr.database_id AND era.analysis_id = scr.analysis_id AND era.era_id = sc.era_id ) WHERE scr.database_id = '@database_id' AND scr.analysis_id = @analysis_id --AND sc.era_id = @exposure_id --AND scr.rr IS NOT NULL AND scr.exposures_outcome_set_id = @exposures_outcome_set_id" +"estimation-sccs-results-full.R","539","545","SELECT * FROM @schema.@sccs_table_prefixtime_trend WHERE database_id = '@database_id' AND analysis_id = @analysis_id AND exposures_outcome_set_id = @exposures_outcome_set_id" +"estimation-sccs-results-full.R","567","575","SELECT pre_exposure_p FROM @schema.@sccs_table_prefixdiagnostics_summary WHERE database_id = '@database_id' AND covariate_id = @covariate_id AND analysis_id = @analysis_id AND exposures_outcome_set_id = @exposures_outcome_set_id" +"estimation-sccs-results-full.R","593","601","SELECT * , @p as p FROM @schema.@sccs_table_prefixtime_to_event WHERE database_id = '@database_id' AND era_id = @exposure_id AND analysis_id = @analysis_id AND exposures_outcome_set_id = @exposures_outcome_set_id;" +"estimation-sccs-results-full.R","627","634","SELECT * FROM @schema.@sccs_table_prefixevent_dep_observation WHERE database_id = '@database_id' AND analysis_id = @analysis_id AND exposures_outcome_set_id = @exposures_outcome_set_id;" +"estimation-sccs-results-full.R","654","661","SELECT * FROM @schema.@sccs_table_prefixage_spanning WHERE database_id = '@database_id' AND analysis_id = @analysis_id AND exposures_outcome_set_id = @exposures_outcome_set_id" +"estimation-sccs-results-full.R","680","687","SELECT * FROM @schema.@sccs_table_prefixcalendar_time_spanning WHERE database_id = '@database_id' AND analysis_id = @analysis_id AND exposures_outcome_set_id = @exposures_outcome_set_id" +"estimation-sccs-results-full.R","708","716","SELECT * FROM @schema.@sccs_table_prefixspline WHERE database_id = '@database_id' AND analysis_id = @analysis_id AND exposures_outcome_set_id = @exposures_outcome_set_id AND spline_type = '@spline_type';" +"estimation-sccs-results-full.R","740","766","SELECT r.ci_95_lb, r.ci_95_ub, r.log_rr, r.se_log_rr, r.calibrated_ci_95_lb, r.calibrated_ci_95_ub, r.calibrated_log_rr, r.calibrated_se_log_rr, r.exposures_outcome_set_id, e.true_effect_size, c.exposures_outcome_set_id FROM @schema.@sccs_table_prefixresult r INNER JOIN @schema.@sccs_table_prefixexposure e on r.exposures_outcome_set_id = e.exposures_outcome_set_id INNER JOIN @schema.@sccs_table_prefixcovariate c on e.era_id = c.era_id and e.exposures_outcome_set_id = c.exposures_outcome_set_id and c.database_id = r.database_id and c.analysis_id = r.analysis_id and c.covariate_id = r.covariate_id WHERE r.database_id = '@database_id' AND r.analysis_id = @analysis_id AND r.covariate_id = @covariate_id AND e.true_effect_size is not NULL -- AND e.era_id = @era_id ;" +"estimation-sccs-results-full.R","780","784","SELECT top 1 ds.easeFROM @schema.@sccs_table_prefixdiagnostics_summary ds WHERE ds.database_id = '@database_id' AND ds.analysis_id = @analysis_id AND ds.covariate_id = @covariate_id;" +"estimation-sccs-results.R","250","344","SELECT ds.cdm_source_abbreviation as database_name, sr.database_id, sc.covariate_id, sc.covariate_name, sc.era_id, sc.covariate_analysis_id, sr.analysis_id, a.description, eos.outcome_id, cg1.cohort_name as outcome, cg2.cohort_name as target, cg3.cohort_name as indication, eos.nesting_cohort_id as indication_id, eos.exposures_outcome_set_id, sr.outcome_subjects, sr.outcome_events, sr.outcome_observation_periods, sr.covariate_subjects, sr.covariate_days, sr.covariate_eras, sr.covariate_outcomes, sr.observed_days, case when COALESCE(sds.unblind, 0) = 0 then NULL else sr.rr end rr, case when COALESCE(sds.unblind, 0) = 0 then NULL else sr.ci_95_lb end ci_95_lb, case when COALESCE(sds.unblind, 0) = 0 then NULL else sr.ci_95_ub end ci_95_ub, case when COALESCE(sds.unblind, 0) = 0 then NULL else sr.p end p, case when COALESCE(sds.unblind, 0) = 0 then NULL else sr.log_rr end log_rr, case when COALESCE(sds.unblind, 0) = 0 then NULL else sr.se_log_rr end se_log_rr, case when COALESCE(sds.unblind, 0) = 0 then NULL else sr.calibrated_rr end calibrated_rr, case when COALESCE(sds.unblind, 0) = 0 then NULL else sr.calibrated_ci_95_lb end calibrated_ci_95_lb, case when COALESCE(sds.unblind, 0) = 0 then NULL else sr.calibrated_ci_95_ub end calibrated_ci_95_ub, case when COALESCE(sds.unblind, 0) = 0 then NULL else sr.calibrated_p end calibrated_p, case when COALESCE(sds.unblind, 0) = 0 then NULL else sr.calibrated_log_rr end calibrated_log_rr, case when COALESCE(sds.unblind, 0) = 0 then NULL else sr.calibrated_se_log_rr end calibrated_se_log_rr, case when COALESCE(sds.unblind, 0) = 0 then NULL else sr.llr end llr, sds.mdrr, --sds.ease, --sds.time_trend_p, --sds.pre_exposure_p, --sds.mdrr_diagnostic, --sds.ease_diagnostic, --sds.time_trend_diagnostic, --sds.pre_exposure_diagnostic, sds.unblind FROM @schema.@sccs_table_prefixresult sr INNER JOIN @schema.@database_table_prefix@database_table ds ON sr.database_id = ds.database_id INNER JOIN @schema.@sccs_table_prefixdiagnostics_summary sds ON ( sds.exposures_outcome_set_id = sr.exposures_outcome_set_id AND sds.database_id = sr.database_id AND sds.analysis_id = sr.analysis_id AND sds.covariate_id = sr.covariate_id ) INNER JOIN @schema.@sccs_table_prefixcovariate sc ON ( sc.exposures_outcome_set_id = sr.exposures_outcome_set_id AND sc.database_id = sr.database_id AND sc.analysis_id = sr.analysis_id AND sc.covariate_id = sr.covariate_id ) INNER JOIN @schema.@sccs_table_prefixexposures_outcome_set eos ON eos.exposures_outcome_set_id = sr.exposures_outcome_set_id INNER JOIN @schema.@sccs_table_prefixanalysis a on a.analysis_id = sr.analysis_id inner join @schema.@cg_table_prefixcohort_definition cg1 on cg1.cohort_definition_id = eos.outcome_id inner join @schema.@cg_table_prefixcohort_definition as cg2 on cg2.cohort_definition_id = sc.era_id left join @schema.@cg_table_prefixcohort_definition as cg3 on eos.nesting_cohort_id = cg3.cohort_definition_id WHERE eos.outcome_id IN (@outcome_ids) AND sc.era_id IN (@exposure_ids) ;" +"estimation-sccs-results.R","372","459","select distinctev.evidence_synthesis_description as database_name, 0 as database_id, cov.covariate_id, -- exists? cov.covariate_name, cov.era_id, 0 as covariate_analysis_id, esr.analysis_id, a.description, eos.outcome_id, c3.cohort_name as outcome, c1.cohort_name as target, c4.cohort_name as indication, eos.nesting_cohort_id as indication_id, eos.exposures_outcome_set_id, esr.outcome_subjects, esr.outcome_events, esr.outcome_observation_periods, esr.covariate_subjects, esr.covariate_days, esr.covariate_eras, esr.covariate_outcomes, esr.observed_days, esr.rr, esr.ci_95_lb, esr.ci_95_ub, esr.p, esr.log_rr, esr.se_log_rr, esr.calibrated_rr, esr.calibrated_ci_95_lb, esr.calibrated_ci_95_ub, esr.calibrated_p, esr.calibrated_log_rr, esr.calibrated_se_log_rr, NULL as llr, esd.mdrr, esd.unblind as unblind from @schema.@es_table_prefixsccs_result as esr inner join @schema.@sccs_table_prefixexposures_outcome_set as eos on esr.exposures_outcome_set_id = eos.exposures_outcome_set_id inner join @schema.@sccs_table_prefixcovariate as cov on esr.covariate_id = cov.covariate_id and esr.analysis_id = cov.analysis_id and esr.exposures_outcome_set_id = cov.exposures_outcome_set_id inner join @schema.@es_table_prefixsccs_diagnostics_summary as esd on esr.analysis_id = esd.analysis_id and esr.exposures_outcome_set_id = esd.exposures_outcome_set_id and esr.covariate_id = esd.covariate_id and esr.evidence_synthesis_analysis_id = esd.evidence_synthesis_analysis_id inner join @schema.@cg_table_prefixcohort_definition as c1 on c1.cohort_definition_id = cov.era_id inner join @schema.@cg_table_prefixcohort_definition as c3 on c3.cohort_definition_id = eos.outcome_id inner join @schema.@sccs_table_prefixanalysis as a on a.analysis_id = esr.analysis_id inner join @schema.@es_table_prefixanalysis as ev on ev.evidence_synthesis_analysis_id = esr.evidence_synthesis_analysis_id left join @schema.@cg_table_prefixcohort_definition as c4 on eos.nesting_cohort_id = c4.cohort_definition_id where esr.calibrated_rr != 0 and esd.unblind = 1 and cov.era_id in (@target_ids) and eos.outcome_id in (@outcome_id) ;" +"helpers-getPredictionResult.R","15","15","SELECT * FROM @schema.@table_name WHERE performance_id = @performance_id" +"helpers-sccsDataPulls.R","6","22","select distinct c.cohort_name as name, eos.outcome_id from @schema.@sccs_table_prefixexposures_outcome_set as eos inner join @schema.@cg_table_prefixcohort_definition as c on c.cohort_definition_id = eos.outcome_id inner join @schema.@sccs_table_prefixexposure as e on e.exposures_outcome_set_id = eos.exposures_outcome_set_id --where e.true_effect_size != 1 ;" +"helpers-sccsDataPulls.R","41","59","SELECTe.era_id AS exposure_id, c2.cohort_name as exposure_name, coalesce(c.cohort_definition_id, -1) as indication_id, coalesce(c.cohort_name, 'No indication') as indication_name FROM @schema.@sccs_table_prefixexposures_outcome_set eos LEFT JOIN @schema.@cg_table_prefixcohort_definition c on eos.nesting_cohort_id = c.cohort_definition_id INNER JOIN @schema.@sccs_table_prefixcovariate cov ON eos.exposures_outcome_set_id = cov.exposures_outcome_set_id INNER JOIN @schema.@sccs_table_prefixexposure e ON eos.exposures_outcome_set_id = e.exposures_outcome_set_id AND cov.era_id = e.era_id INNER JOIN @schema.@cg_table_prefixcohort_definition c2 on e.era_id = c2.cohort_definition_id GROUP BY c.cohort_definition_id, c.cohort_name, e.era_id, c2.cohort_name" +"helpers-sccsDataPulls.R","77","99","select distinct c1.cohort_name as name, e.era_id as exposure_id from @schema.@sccs_table_prefixresult r INNER JOIN @schema.@sccs_table_prefixexposures_outcome_set eos ON r.exposures_outcome_set_id = eos.exposures_outcome_set_id INNER JOIN @schema.@sccs_table_prefixcovariate cov ON r.exposures_outcome_set_id = cov.exposures_outcome_set_id AND r.analysis_id = cov.analysis_id AND r.covariate_id = cov.covariate_id INNER JOIN @schema.@sccs_table_prefixexposure e ON r.exposures_outcome_set_id = e.exposures_outcome_set_id AND cov.era_id = e.era_id INNER JOIN @schema.@cg_table_prefixcohort_definition as c1 on c1.cohort_definition_id = e.era_id WHERE e.true_effect_size IS NULL ;" +"helpers-sccsDataPulls.R","119","129","select distinct ds.cdm_source_abbreviation as database_name, r.database_id from @schema.@database_table_prefix@database_table ds inner join @schema.@sccs_table_prefixresult as r on r.database_id = ds.database_id;" +"helpers-sccsDataPulls.R","150","161","select distinct a.description as name, r.analysis_id from @schema.@sccs_table_prefixresult as r inner join @schema.@sccs_table_prefixanalysis as a on r.analysis_id = a.analysis_id ;" +"helpers-sccsDataPulls.R","186","217","SELECT CASE WHEN era.era_name IS NULL THEN sc.covariate_name ELSE CONCAT(sc.covariate_name, ' : ', era.era_name) END as covariate_name, scr.covariate_id, scr.rr, scr.ci_95_lb, scr.ci_95_ub FROM @schema.@sccs_table_prefixcovariate_result scr INNER JOIN @schema.@sccs_table_prefixcovariate sc ON ( sc.exposures_outcome_set_id = scr.exposures_outcome_set_id AND sc.database_id = scr.database_id AND sc.analysis_id = scr.analysis_id AND sc.covariate_id = scr.covariate_id ) LEFT JOIN @schema.@cg_table_prefixcohort_definition cd ON cd.cohort_definition_id = sc.era_id LEFT JOIN @schema.@sccs_table_prefixera era ON ( era.exposures_outcome_set_id = scr.exposures_outcome_set_id AND era.database_id = scr.database_id AND era.analysis_id = scr.analysis_id AND era.era_id = sc.era_id ) INNER JOIN @schema.@sccs_table_prefixexposures_outcome_set eos ON eos.exposures_outcome_set_id = scr.exposures_outcome_set_id WHERE scr.database_id = '@database_id' AND scr.analysis_id = @analysis_id AND eos.outcome_id = @outcome_id AND sc.era_id = @exposure_id AND scr.rr IS NOT NULL" +"helpers-sccsDataPulls.R","236","245","SELECT tt.* FROM @schema.@sccs_table_prefixtime_trend tt inner join @schema.@sccs_table_prefixexposures_outcome_set eos on tt.exposures_outcome_set_id = eos.exposures_outcome_set_id WHERE database_id = '@database_id' AND analysis_id = @analysis_id AND outcome_id = @outcome_id" +"helpers-sccsDataPulls.R","265","275","SELECT ds.pre_exposure_p FROM @schema.@sccs_table_prefixdiagnostics_summary ds inner join @schema.@sccs_table_prefixexposures_outcome_set eos on ds.exposures_outcome_set_id = eos.exposures_outcome_set_id WHERE ds.database_id = '@database_id' AND ds.covariate_id = @covariate_id AND ds.analysis_id = @analysis_id AND eos.outcome_id = @outcome_id" +"helpers-sccsDataPulls.R","288","298","SELECT tte.*, @p as p FROM @schema.@sccs_table_prefixtime_to_event tte inner join @schema.@sccs_table_prefixexposures_outcome_set eos on tte.exposures_outcome_set_id = eos.exposures_outcome_set_id WHERE tte.database_id = '@database_id' AND tte.era_id = @exposure_id AND tte.analysis_id = @analysis_id AND eos.outcome_id = @outcome_id" +"helpers-sccsDataPulls.R","324","335","SELECT a.* FROM @schema.@sccs_table_prefixattrition a inner join @schema.@sccs_table_prefixexposures_outcome_set eos on a.exposures_outcome_set_id = eos.exposures_outcome_set_id WHERE a.database_id = '@database_id' AND a.analysis_id = @analysis_id AND eos.outcome_id = @outcome_id AND a.covariate_id = @covariate_id" +"helpers-sccsDataPulls.R","351","361","SELECT o.* FROM @schema.@sccs_table_prefixevent_dep_observation o inner join @schema.@sccs_table_prefixexposures_outcome_set eos on o.exposures_outcome_set_id = eos.exposures_outcome_set_id WHERE o.database_id = '@database_id' AND o.analysis_id = @analysis_id AND eos.outcome_id = @outcome_id" +"helpers-sccsDataPulls.R","376","386","SELECT asp.* FROM @schema.@sccs_table_prefixage_spanning asp inner join @schema.@sccs_table_prefixexposures_outcome_set eos on asp.exposures_outcome_set_id = eos.exposures_outcome_set_id WHERE asp.database_id = '@database_id' AND asp.analysis_id = @analysis_id AND eos.outcome_id = @outcome_id" +"helpers-sccsDataPulls.R","401","411","SELECT ts.* FROM @schema.@sccs_table_prefixcalendar_time_spanning ts inner join @schema.@sccs_table_prefixexposures_outcome_set eos on ts.exposures_outcome_set_id = eos.exposures_outcome_set_id WHERE ts.database_id = '@database_id' AND ts.analysis_id = @analysis_id AND eos.outcome_id = @outcome_id" +"helpers-sccsDataPulls.R","428","439","SELECT s.* FROM @schema.@sccs_table_prefixspline s inner join @schema.@sccs_table_prefixexposures_outcome_set eos on s.exposures_outcome_set_id = eos.exposures_outcome_set_id WHERE s.database_id = '@database_id' AND s.analysis_id = @analysis_id AND eos.outcome_id = @outcome_id AND s.spline_type = '@spline_type';" +"helpers-sccsDataPulls.R","457","474","SELECT ci_95_lb, ci_95_ub, log_rr, se_log_rr, calibrated_ci_95_lb, calibrated_ci_95_ub, calibrated_log_rr, calibrated_se_log_rr, true_effect_size FROM @schema.@sccs_table_prefixresult sr INNER JOIN @schema.@sccs_table_prefixcovariate sc ON ( sc.exposures_outcome_set_id = sr.exposures_outcome_set_id AND sc.database_id = sr.database_id AND sc.analysis_id = sr.analysis_id AND sc.covariate_id = sr.covariate_id ) INNER JOIN @schema.@sccs_table_prefixexposure se ON ( se.exposures_outcome_set_id = sr.exposures_outcome_set_id AND se.era_id = sc.era_id ) WHERE sr.database_id = '@database_id' AND sr.analysis_id = @analysis_id AND sr.covariate_id = @covariate_id" +"helpers-sccsDataPulls.R","491","510","SELECT ds.* FROM @schema.@sccs_table_prefixdiagnostics_summary ds inner join @schema.@sccs_table_prefixexposures_outcome_set eos on ds.exposures_outcome_set_id = eos.exposures_outcome_set_id inner join @schema.@sccs_table_prefixcovariate cov on cov.covariate_id = ds.covariate_id and cov.exposures_outcome_set_id = ds.exposures_outcome_set_id and cov.analysis_id = ds.analysis_id and cov.database_id = ds.database_id WHERE ds.database_id = '@database_id' AND ds.analysis_id = @analysis_id AND ds.covariate_id = @covariate_id AND eos.outcome_id = @outcome_id AND cov.era_id = @exposure_id" +"patient-level-prediction-covariateSummary.R","286","287","SELECT train_details FROM @schema.@plp_table_prefixmodels WHERE database_id = @database_id and model_design_id = @model_design_id;" +"patient-level-prediction-covariateSummary.R","444","444","SELECT * FROM @schema.@plp_table_prefixcovariate_summary WHERE performance_id = @performance_id;" +"patient-level-prediction-covariateSummary.R","477","478","SELECT intercept FROM @schema.@plp_table_prefixmodels WHERE database_id = @database_id and model_design_id = @model_design_id" +"patient-level-prediction-designSummary.R","271","281","SELECT distinct cohorts.cohort_id, cohorts.cohort_name FROM @schema.@plp_table_prefixmodel_designs as model_designs inner join (SELECT c.cohort_id, cd.cohort_name FROM @schema.@plp_table_prefixcohorts c inner join @schema.@cg_table_prefixcohort_definition cd on c.cohort_definition_id = cd.cohort_definition_id ) AS cohorts ON model_designs.@type_id = cohorts.cohort_id ;" +"patient-level-prediction-designSummary.R","310","368","SELECT model_designs.model_design_id, model_settings.model_type AS model_type, targets.cohort_name AS target, outcomes.cohort_name AS outcome, tars.tar_start_day, tars.tar_start_anchor, tars.tar_end_day, tars.tar_end_anchor, COUNT(distinct diag.database_id) as diag_databases, COUNT(distinct d.database_id) dev_databases, MIN(p.value) min_AUROC, AVG(p.value) mean_AUROC, MAX(p.value) max_AUROC, COUNT(distinct v.database_id) val_databases FROM @schema.@plp_table_prefixmodel_designs as model_designs inner join @schema.@plp_table_prefixmodel_settings as model_settings on model_designs.model_setting_id = model_settings.model_setting_id LEFT JOIN @schema.@plp_table_prefixperformances AS results on model_designs.model_design_id = results.model_design_id LEFT JOIN (select * from @schema.@plp_table_prefixEVALUATION_STATISTICS where EVALUATION = 'Test' and METRIC = 'AUROC') p on p.performance_id = results.performance_id LEFT JOIN (SELECT c.cohort_id, cd.cohort_name FROM @schema.@plp_table_prefixcohorts c inner join @schema.@cg_table_prefixcohort_definition cd on c.cohort_definition_id = cd.cohort_definition_id ) AS targets ON model_designs.target_id = targets.cohort_id LEFT JOIN (SELECT c.cohort_id, cd.cohort_name FROM @schema.@plp_table_prefixcohorts c inner join @schema.@cg_table_prefixcohort_definition cd on c.cohort_definition_id = cd.cohort_definition_id ) AS outcomes ON model_designs.outcome_id = outcomes.cohort_id LEFT JOIN @schema.@plp_table_prefixtars AS tars ON model_designs.tar_id = tars.tar_id LEFT JOIN @schema.@plp_table_prefixdatabase_details AS d ON results.development_database_id = d.database_id LEFT JOIN @schema.@plp_table_prefixdatabase_details AS v ON results.validation_database_id = v.database_id LEFT JOIN @schema.@plp_table_prefixdiagnostics AS diag ON results.development_database_id = diag.database_id WHERE targets.cohort_id in (@target_ids) AND outcomes.cohort_id in (@outcome_ids) GROUP BY model_designs.model_design_id, model_settings.model_type, targets.cohort_name, outcomes.cohort_name, tars.tar_start_day, tars.tar_start_anchor, tars.tar_end_day, tars.tar_end_anchor;" +"patient-level-prediction-diagnostics.R","428","460","SELECT distinct design.MODEL_DESIGN_ID,diagnostics.diagnostic_id, database.DATABASE_NAME, cohortT.COHORT_NAME target_name, cohortO.COHORT_NAME outcome_name, summary.PROBAST_ID, summary.RESULT_VALUE from (select * from @schema.@plp_table_prefixDIAGNOSTICS where MODEL_DESIGN_ID = @model_design_id) as diagnostics inner join @schema.@plp_table_prefixMODEL_DESIGNS design on diagnostics.MODEL_DESIGN_ID = design.MODEL_DESIGN_ID inner join @schema.@plp_table_prefixDIAGNOSTIC_SUMMARY summary on diagnostics.DIAGNOSTIC_ID = summary.DIAGNOSTIC_ID inner join (select dd.database_id, md.cdm_source_abbreviation as database_name from @schema.@database_table_prefixdatabase_meta_data md inner join @schema.@plp_table_prefixdatabase_details dd on md.database_id = dd.database_meta_data_id) as database on database.database_id = diagnostics.database_id inner join @schema.@plp_table_prefixCOHORTS cohortT on cohortT.cohort_id = design.target_id inner join @schema.@plp_table_prefixCOHORTS cohortO on cohortO.cohort_id = design.outcome_id;" +"patient-level-prediction-diagnostics.R","505","505","SELECT * FROM @schema.@plp_table_prefix@table_name WHERE diagnostic_id = @diagnostic_id;" +"patient-level-prediction-diagnostics.R","538","538","SELECT * FROM @schema.@plp_table_prefix@table_name WHERE diagnostic_id = @diagnostic_id;" +"patient-level-prediction-diagnostics.R","557","557","SELECT * FROM @schema.@plp_table_prefix@table_name WHERE diagnostic_id = @diagnostic_id;" +"patient-level-prediction-modelSummary.R","224","224","SELECT * FROM @schema.@plp_table_prefixattrition WHERE performance_id = @performance_id;" +"patient-level-prediction-modelSummary.R","253","303","SELECT distinct results.performance_id, results.model_design_id, results.development_database_id, results.validation_database_id, d.database_acronym AS Dev, v.database_acronym AS Val, targets.cohort_name AS T, outcomes.cohort_name AS O, results.execution_date_time as time_stamp, tars.tar_start_day, tars.tar_start_anchor, tars.tar_end_day, tars.tar_end_anchor, ROUND(aucResult.auc, 3) as auroc, ROUND(auprcResult.auprc,4) as auprc, nResult.population_size, oResult.outcome_count, ROUND(nTest.test_size*100.0/nResult.population_size, 1) as eval_percent, ROUND(oResult.outcome_count*100.0/nResult.population_size,4) as outcome_percent, results.model_development FROM (select * from @schema.@plp_table_prefixperformances where model_design_id = @model_design_id) AS results inner join @schema.@plp_table_prefixmodel_designs as model_designs on model_designs.model_design_id = results.model_design_id LEFT JOIN (SELECT c.cohort_id, cd.cohort_name FROM @schema.@plp_table_prefixcohorts c inner join @schema.@cg_table_prefixcohort_definition cd on c.cohort_definition_id = cd.cohort_definition_id ) AS targets ON results.target_id = targets.cohort_id LEFT JOIN (SELECT c.cohort_id, cd.cohort_name FROM @schema.@plp_table_prefixcohorts c inner join @schema.@cg_table_prefixcohort_definition cd on c.cohort_definition_id = cd.cohort_definition_id ) AS outcomes ON results.outcome_id = outcomes.cohort_id LEFT JOIN (select dd.database_id, md.cdm_source_abbreviation database_acronym from @schema.@database_table_prefix@database_table md inner join @schema.@plp_table_prefixdatabase_details dd on md.database_id = dd.database_meta_data_id) AS d ON results.development_database_id = d.database_id LEFT JOIN (select dd.database_id, md.cdm_source_abbreviation database_acronym from @schema.@database_table_prefix@database_table md inner join @schema.@plp_table_prefixdatabase_details dd on md.database_id = dd.database_meta_data_id) AS v ON results.validation_database_id = v.database_id LEFT JOIN @schema.@plp_table_prefixtars AS tars ON results.tar_id = tars.tar_id LEFT JOIN (SELECT performance_id, value AS auc FROM @schema.@plp_table_prefixevaluation_statistics where metric = 'AUROC' and evaluation in ('Test','Validation') ) AS aucResult ON results.performance_id = aucResult.performance_id LEFT JOIN (SELECT performance_id, value AS auprc FROM @schema.@plp_table_prefixevaluation_statistics where metric = 'AUPRC' and evaluation in ('Test','Validation') ) AS auprcResult ON results.performance_id = auprcResult.performance_id LEFT JOIN (SELECT performance_id, sum(value) AS population_size FROM @schema.@plp_table_prefixevaluation_statistics where metric = 'populationSize' and evaluation in ('Train','Test','Validation') group by performance_id) AS nResult ON results.performance_id = nResult.performance_id LEFT JOIN (SELECT performance_id, sum(value) AS outcome_count FROM @schema.@plp_table_prefixevaluation_statistics where metric = 'outcomeCount' and evaluation in ('Train','Test','Validation') group by performance_id) AS oResult ON results.performance_id = oResult.performance_id LEFT JOIN (SELECT performance_id, value AS test_size FROM @schema.@plp_table_prefixevaluation_statistics where metric = 'populationSize' and evaluation in ('Test', 'Validation') ) AS nTest ON results.performance_id = nTest.performance_id;" +"patient-level-prediction-settings.R","350","380","SELECT tempD.dev_db, tempV.val_db FROM (select * from @schema.@plp_table_prefixperformances WHERE performance_id = @performance_id) perf inner join (select dd.database_id, dmd.cdm_source_name as dev_db from @schema.@plp_table_prefixdatabase_details as dd inner join @schema.@database_table_prefixdatabase_meta_data as dmd on dd.database_meta_data_id = dmd.database_id) tempD on tempD.database_id = perf.development_database_id inner join (select dd.database_id, dmd.cdm_source_name as val_db from @schema.@plp_table_prefixdatabase_details as dd inner join @schema.@database_table_prefixdatabase_meta_data dmd on dd.database_meta_data_id = dmd.database_id) tempV on tempV.database_id = perf.validation_database_id ;" +"patient-level-prediction-settings.R","412","414","SELECT * FROM @schema.@plp_table_prefixmodel_designs WHERE model_design_id = @model_design_id;" +"patient-level-prediction-settings.R","437","437","SELECT * FROM @schema.@plp_table_prefixmodel_settings WHERE model_setting_id = @model_setting_id;" +"patient-level-prediction-settings.R","452","452","SELECT * FROM @schema.@plp_table_prefixcovariate_settings WHERE covariate_setting_id = @setting_id;" +"patient-level-prediction-settings.R","467","467","SELECT * FROM @schema.@plp_table_prefixpopulation_settings WHERE population_setting_id = @setting_id;" +"patient-level-prediction-settings.R","482","482","SELECT * FROM @schema.@plp_table_prefixfeature_engineering_settings WHERE feature_engineering_setting_id = @setting_id;" +"patient-level-prediction-settings.R","494","494","SELECT * FROM @schema.@plp_table_prefixtidy_covariates_settings WHERE tidy_covariates_setting_id = @setting_id;" +"patient-level-prediction-settings.R","507","507","SELECT * FROM @schema.@plp_table_prefixplp_data_settings WHERE plp_data_setting_id = @setting_id;" +"patient-level-prediction-settings.R","520","520","SELECT * FROM @schema.@plp_table_prefixsample_settings WHERE sample_setting_id = @setting_id;" +"patient-level-prediction-settings.R","533","533","SELECT * FROM @schema.@plp_table_prefixsplit_settings WHERE split_setting_id = @setting_id;" +"patient-level-prediction-settings.R","546","550","SELECT c.*, cd.json as cohort_jsonFROM @schema.@plp_table_prefixcohorts c inner join @schema.@cg_table_prefixcohort_definition cd on c.cohort_definition_id = cd.cohort_definition_id WHERE c.cohort_id = @setting_id;" +"patient-level-prediction-settings.R","564","568","SELECT c.*, cd.json as cohort_jsonFROM @schema.@plp_table_prefixcohorts c inner join @schema.@cg_table_prefixcohort_definition cd on c.cohort_definition_id = cd.cohort_definition_id WHERE c.cohort_id = @setting_id;" +"patient-level-prediction-validation.R","256","311","SELECT results.performance_id, results.model_design_id, --databases.database_acronym AS Dev, d.database_acronym AS Val, targets.cohort_name AS target, outcomes.cohort_name AS outcome, results.population_setting_id, -- pop and plp_data settings? tars.tar_start_day, tars.tar_start_anchor, tars.tar_end_day, tars.tar_end_anchor, ROUND(aucResult.auc, 3) as auroc, ROUND(auclbResult.auclb, 3) as auroclb, ROUND(aucubResult.aucub, 3) as aurocub, ROUND(auprcResult.auprc,4) as auprc, nResult.population_size, oResult.outcome_count, ROUND(nTest.test_size*100.0/nResult.population_size, 1) as eval_percent, ROUND(oResult.outcome_count*100.0/nResult.population_size,4) as outcome_percent, ROUND(calibration_in_large, 3) as calibration_in_large FROM (SELECT * FROM @schema.@plp_table_appendperformances where model_design_id = @model_design_id and development_database_id = @development_database_id ) AS results LEFT JOIN (SELECT a.cohort_id, b.cohort_name FROM @schema.@plp_table_appendcohorts as a inner join @schema.@cg_table_appendcohort_definition as b on a.cohort_definition_id = b.cohort_definition_id) AS targets ON results.target_id = targets.cohort_id LEFT JOIN (SELECT a.cohort_id, b.cohort_name FROM @schema.@plp_table_appendcohorts as a inner join @schema.@cg_table_appendcohort_definition as b on a.cohort_definition_id = b.cohort_definition_id ) AS outcomes ON results.outcome_id = outcomes.cohort_id LEFT JOIN (select dd.database_id, md.cdm_source_abbreviation database_acronym from @schema.@database_table_appenddatabase_meta_data md inner join @schema.@plp_table_appenddatabase_details dd on md.database_id = dd.database_meta_data_id) AS d ON results.validation_database_id = d.database_id LEFT JOIN @schema.@plp_table_appendtars AS tars ON results.tar_id = tars.tar_id LEFT JOIN (SELECT performance_id, value AS auc FROM @schema.@plp_table_appendevaluation_statistics where metric = 'AUROC' and evaluation in ('Test','Validation') ) AS aucResult ON results.performance_id = aucResult.performance_id LEFT JOIN (SELECT performance_id, value AS auclb FROM @schema.@plp_table_appendevaluation_statistics where metric = '95% lower AUROC' and evaluation in ('Test','Validation') ) AS auclbResult ON results.performance_id = auclbResult.performance_id LEFT JOIN (SELECT performance_id, value AS aucub FROM @schema.@plp_table_appendevaluation_statistics where metric = '95% upper AUROC' and evaluation in ('Test','Validation') ) AS aucubResult ON results.performance_id = aucubResult.performance_id LEFT JOIN (SELECT performance_id, value AS auprc FROM @schema.@plp_table_appendevaluation_statistics where metric = 'AUPRC' and evaluation in ('Test','Validation') ) AS auprcResult ON results.performance_id = auprcResult.performance_id LEFT JOIN (SELECT performance_id, value AS calibration_in_large FROM @schema.@plp_table_appendevaluation_statistics where metric = 'calibrationInLarge intercept' and evaluation in ('Test','Validation') ) AS CalibrationInLargeResult ON results.performance_id = CalibrationInLargeResult.performance_id LEFT JOIN (SELECT performance_id, sum(value) AS population_size FROM @schema.@plp_table_appendevaluation_statistics where metric = 'populationSize' and evaluation in ('Test','Train','Validation') group by performance_id) AS nResult ON results.performance_id = nResult.performance_id LEFT JOIN (SELECT performance_id, sum(value) AS outcome_count FROM @schema.@plp_table_appendevaluation_statistics where metric = 'outcomeCount' and evaluation in ('Test','Train','Validation') group by performance_id) AS oResult ON results.performance_id = oResult.performance_id LEFT JOIN (SELECT performance_id, value AS test_size FROM @schema.@plp_table_appendevaluation_statistics where metric = 'populationSize' and evaluation in ('Test','Validation')) AS nTest ON results.performance_id = nTest.performance_id;" +"phevaluator-main.R","532","533","SELECT * FROM @schema.@pv_table_prefixALGORITHM_PERFORMANCE_RESULTS ;" +"phevaluator-main.R","560","561","SELECT * FROM @schema.@pv_table_prefixCOHORT_DEFINITION_SET ;" +"phevaluator-main.R","577","578","SELECT * FROM @schema.@pv_table_prefixDIAGNOSTICS ;" +"phevaluator-main.R","593","594","SELECT * FROM @schema.@pv_table_prefixEVALUATION_INPUT_PARAMETERS ;" +"phevaluator-main.R","609","610","SELECT * FROM @schema.@pv_table_prefixMODEL_COVARIATES ;" +"phevaluator-main.R","633","634","SELECT * FROM @schema.@pv_table_prefixMODEL_COVARIATE_SUMMARY ;" +"phevaluator-main.R","666","667","SELECT * FROM @schema.@pv_table_prefixMODEL_INPUT_PARAMETERS ;" +"phevaluator-main.R","682","683","SELECT * FROM @schema.@pv_table_prefixMODEL_PERFORMANCE ;" +"phevaluator-main.R","698","699","SELECT * FROM @schema.@pv_table_prefixTEST_SUBJECTS ;" +"phevaluator-main.R","714","715","SELECT * FROM @schema.@pv_table_prefixTEST_SUBJECTS_COVARIATES ;" +"report-main.R","772","772","select distinct * from @schema.@cg_table_prefixcohort_definition order by cohort_name;" +"report-main.R","843","911","select distinct tid, oid from ( {@characterization} ? { select distinct TARGET_COHORT_ID as tid, OUTCOME_COHORT_ID as oid from @schema.@c_table_prefixcohort_details where TARGET_COHORT_ID != 0 and OUTCOME_COHORT_ID != 0 } {@cohort_incidence} ? { {@characterization}?{union} select distinct TARGET_COHORT_DEFINITION_ID as tid, OUTCOME_COHORT_DEFINITION_ID as oid from @schema.@ci_table_prefixincidence_summary } {@cohort_method} ? { {@cohort_incidence | @characterization}?{union} select distinct TARGET_ID as tid, OUTCOME_ID as oid from @schema.@cm_table_prefixtarget_comparator_outcome where OUTCOME_OF_INTEREST = 1 } {@prediction} ? { {@cohort_method | @cohort_incidence | @characterization}?{union} select distinct c1.cohort_definition_id as tid, c2.cohort_definition_id as oid from @schema.@plp_table_prefixmodel_designs md inner join @schema.@plp_table_prefixcohorts c1 on c1.cohort_id = md.target_id inner join @schema.@plp_table_prefixcohorts c2 on c2.cohort_id = md.outcome_id } {@sccs} ? { {@cohort_method | @cohort_incidence | @characterization | @prediction}?{union} SELECT distinct cov.era_id as tid, eos.outcome_id as oid FROM @schema.@sccs_table_prefixdiagnostics_summary ds inner join @schema.@sccs_table_prefixexposures_outcome_set eos on ds.exposures_outcome_set_id = eos.exposures_outcome_set_id INNER JOIN @schema.@sccs_table_prefixcovariate cov on cov.covariate_id = ds.covariate_id and cov.exposures_outcome_set_id = ds.exposures_outcome_set_id and cov.analysis_id = ds.analysis_id and cov.database_id = ds.database_id -- adding code to remove the negative controls INNER JOIN @schema.@sccs_table_prefixexposure e ON e.exposures_outcome_set_id = ds.exposures_outcome_set_id AND e.era_id = cov.era_id where e.true_effect_size is NULL } ) temp_t_o ;" diff --git a/extras/rdms/ohdsi_shiny_modules_table_relationships.csv b/extras/rdms/ohdsi_shiny_modules_table_relationships.csv new file mode 100644 index 00000000..1c9929e2 --- /dev/null +++ b/extras/rdms/ohdsi_shiny_modules_table_relationships.csv @@ -0,0 +1,126 @@ +fileName,startLine,endLine,fromClause,joinRelationship +characterization-caseSeries.R,195,224,"FROM @schema.@c_table_prefixsettings s","JOIN @schema.@database_meta_table d ON s.database_id = d.database_id inner" +characterization-caseSeries.R,195,224,"FROM @schema.@c_table_prefixsettings s","JOIN @schema.@c_table_prefixcohort_details cd ON s.setting_id = cd.setting_id and s.database_id = cd.database_id and cd.target_cohort_id = @target_id and cd.outcome_cohort_id = @outcome_id and cd.cohort_type = 'Cases' inner" +characterization-caseSeries.R,195,224,"FROM @schema.@c_table_prefixsettings s","JOIN @schema.@cg_table_prefixcohort_definition ct1 ON ct1.cohort_definition_id = cd.target_cohort_id inner" +characterization-caseSeries.R,195,224,"FROM @schema.@c_table_prefixsettings s","JOIN @schema.@cg_table_prefixcohort_definition ct2 ON ct2.cohort_definition_id = cd.outcome_cohort_id" +characterization-caseSeries.R,275,306,"FROM @schema.@c_table_prefixcovariates cov","JOIN @schema.@c_table_prefixcovariate_ref cr ON cov.setting_id = cr.setting_id and cov.database_id = cr.database_id and cov.covariate_id = cr.covariate_id inner" +characterization-caseSeries.R,275,306,"FROM @schema.@c_table_prefixcovariates cov","JOIN @schema.@c_table_prefixsettings s ON cov.setting_id = s.setting_id and cov.database_id = s.database_id" +characterization-caseSeries.R,328,361,"FROM @schema.@c_table_prefixcovariates_continuous cov","JOIN @schema.@c_table_prefixcovariate_ref cr ON cov.setting_id = cr.setting_id and cov.database_id = cr.database_id and cov.covariate_id = cr.covariate_id inner" +characterization-caseSeries.R,328,361,"FROM @schema.@c_table_prefixcovariates_continuous cov","JOIN @schema.@c_table_prefixsettings s ON cov.setting_id = s.setting_id and cov.database_id = s.database_id" +characterization-cohorts.R,791,810,"FROM @schema.@c_table_prefixCOVARIATES cov","JOIN @schema.@c_table_prefixcovariate_ref ref ON cov.covariate_id = ref.covariate_id and cov.setting_id = ref.setting_id and cov.database_id = ref.database_id inner" +characterization-cohorts.R,791,810,"FROM @schema.@c_table_prefixCOVARIATES cov","JOIN @schema.@c_table_prefixsettings s ON s.database_id = cov.database_id and s.setting_id = cov.setting_id" +characterization-cohorts.R,902,925,"FROM @schema.@c_table_prefixCOVARIATES_continuous cov","JOIN @schema.@c_table_prefixcovariate_ref ref ON cov.covariate_id = ref.covariate_id and cov.setting_id = ref.setting_id and cov.database_id = ref.database_id inner" +characterization-cohorts.R,902,925,"FROM @schema.@c_table_prefixCOVARIATES_continuous cov","JOIN @schema.@c_table_prefixsettings s ON cov.setting_id = s.setting_id and cov.database_id = s.database_id inner" +characterization-cohorts.R,902,925,"FROM @schema.@c_table_prefixCOVARIATES_continuous cov","JOIN @schema.@database_meta_table d ON s.database_id = d.database_id" +characterization-cohorts.R,990,999,"FROM @schema.@database_table d","JOIN @schema.@c_table_prefixcohort_details cd ON d.database_id = cd.database_id" +characterization-dechallengeRechallenge.R,329,337,"FROM @schema.@c_table_prefixDECHALLENGE_RECHALLENGE dr","JOIN @schema.@cg_table_prefixCOHORT_DEFINITION t ON dr.TARGET_COHORT_DEFINITION_ID = t.COHORT_DEFINITION_ID inner" +characterization-dechallengeRechallenge.R,329,337,"FROM @schema.@c_table_prefixDECHALLENGE_RECHALLENGE dr","JOIN @schema.@cg_table_prefixCOHORT_DEFINITION o ON dr.OUTCOME_COHORT_DEFINITION_ID = o.COHORT_DEFINITION_ID" +characterization-dechallengeRechallenge.R,390,395,"FROM @schema.@c_table_prefixDECHALLENGE_RECHALLENGE dr","JOIN @schema.@database_table d ON dr.database_id = d.database_id" +characterization-incidence.R,1702,1724,"FROM @result_schema.@incidence_table_prefixINCIDENCE_SUMMARY i","JOIN @result_schema.@incidence_table_prefixOUTCOME_DEF od ON i.outcome_id = od.outcome_id and i.ref_id = od.ref_id" +characterization-incidence.R,1702,1724,"FROM @result_schema.@incidence_table_prefixINCIDENCE_SUMMARY i","JOIN @result_schema.@incidence_table_prefixTAR_DEF tad ON i.tar_id = tad.tar_id and i.ref_id = tad.ref_id" +characterization-incidence.R,1702,1724,"FROM @result_schema.@incidence_table_prefixINCIDENCE_SUMMARY i","JOIN @result_schema.@incidence_table_prefixSUBGROUP_DEF sd ON i.subgroup_id = sd.subgroup_id and i.ref_id = sd.ref_id left" +characterization-incidence.R,1702,1724,"FROM @result_schema.@incidence_table_prefixINCIDENCE_SUMMARY i","JOIN @result_schema.@incidence_table_prefixAGE_GROUP_DEF agd ON i.age_group_id = agd.age_group_id and i.ref_id = agd.ref_id ) i inner" +characterization-incidence.R,1702,1724,"FROM @result_schema.@incidence_table_prefixINCIDENCE_SUMMARY i","JOIN @result_schema.@database_table_name d ON d.database_id = i.database_id inner" +characterization-incidence.R,1702,1724,"FROM @result_schema.@incidence_table_prefixINCIDENCE_SUMMARY i","JOIN @result_schema.@cg_table_prefixcohort_definition ct1 ON ct1.cohort_definition_id = i.target_cohort_definition_id inner" +characterization-incidence.R,1702,1724,"FROM @result_schema.@incidence_table_prefixINCIDENCE_SUMMARY i","JOIN @result_schema.@cg_table_prefixcohort_definition ct2 ON ct2.cohort_definition_id = i.outcome_cohort_definition_id" +characterization-riskFactors.R,287,308,"FROM @schema.@c_table_prefixcovariates cov","JOIN @schema.@c_table_prefixcovariate_ref cr ON cov.setting_id = cr.setting_id and cov.database_id = cr.database_id and cov.covariate_id = cr.covariate_id inner" +characterization-riskFactors.R,287,308,"FROM @schema.@c_table_prefixcovariates cov","JOIN @schema.@c_table_prefixsettings s ON cov.setting_id = s.setting_id and cov.database_id = s.database_id" +characterization-riskFactors.R,328,350,"FROM @schema.@c_table_prefixcovariates_continuous cov","JOIN @schema.@c_table_prefixcovariate_ref cr ON cov.setting_id = cr.setting_id and cov.database_id = cr.database_id and cov.covariate_id = cr.covariate_id inner" +characterization-riskFactors.R,328,350,"FROM @schema.@c_table_prefixcovariates_continuous cov","JOIN @schema.@c_table_prefixsettings s ON cov.setting_id = s.setting_id and cov.database_id = s.database_id" +characterization-timeToEvent.R,265,270,"FROM @schema.@c_table_prefixTIME_TO_EVENT tte","JOIN @schema.@database_table d ON tte.database_id = d.database_id" +cohort-diagnostics-characterization.R,923,933,"FROM @results_database_schema.@table_prefixtemporal_covariate_ref tcr","JOIN @results_database_schema.@table_prefixtemporal_analysis_ref tar ON tar.analysis_id = tcr.analysis_id LEFT" +cohort-diagnostics-characterization.R,923,933,"FROM @results_database_schema.@table_prefixtemporal_covariate_ref tcr","JOIN @results_database_schema.@table_prefixtemporal_covariate_value tcv ON ( tcr.covariate_id = tcv.covariate_id ) LEFT" +cohort-diagnostics-characterization.R,923,933,"FROM @results_database_schema.@table_prefixtemporal_covariate_ref tcr","JOIN @results_database_schema.@table_prefixtemporal_time_ref ttr ON ttr.time_id = tcv.time_id" +cohort-diagnostics-conceptsInDataSource.R,80,117,"FROM @schema.@table_name isc","JOIN @schema.@concept_table c ON concepts.concept_id = c.concept_id" +cohort-diagnostics-incidenceRates.R,118,128,"FROM @schema.@ir_table ir","JOIN @schema.@cc_table cc ON ( ir.database_id = cc.database_id AND ir.cohort_id = cc.cohort_id )" +cohort-diagnostics-indexEventBreakdown.R,99,109,"FROM @schema.@table_name index_event_breakdown","JOIN @vocabulary_database_schema.@concept_table concept ON index_event_breakdown.concept_id = concept.concept_id" +cohort-diagnostics-main.R,101,109,"FROM pg_class c","JOIN pg_namespace n ON n.oid = c.relnamespace" +cohort-diagnostics-orphanConcepts.R,129,153,"FROM @schema.@orphan_table_name oc","JOIN @schema.@cs_table_name cs ON oc.cohort_id = cs.cohort_id AND oc.concept_set_id = cs.concept_set_id INNER" +cohort-diagnostics-orphanConcepts.R,129,153,"FROM @schema.@orphan_table_name oc","JOIN @vocabulary_database_schema.@concept_table c ON oc.concept_id = c.concept_id" +cohort-diagnostics-shared.R,93,99,"FROM @schema.@table_name cc","JOIN @schema.@database_table db ON db.database_id = cc.database_id #" +cohort-diagnostics-visitContext.R,91,97,"FROM @schema.@table_name visit_context","JOIN @vocabulary_database_schema.@concept_table standard_concept ON visit_context.visit_concept_id = standard_concept.concept_id" +cohort-generator-main.R,643,650,"FROM @schema.@cg_table_prefixCOHORT_COUNT cc","JOIN @schema.@database_table_prefix@database_table dt ON cc.database_id = dt.database_id" +cohort-generator-main.R,643,650,"FROM @schema.@cg_table_prefixCOHORT_COUNT cc","JOIN @schema.@cg_table_prefixCOHORT_DEFINITION cd ON cd.cohort_definition_id = cc.cohort_id" +cohort-generator-main.R,667,672,"FROM @schema.@cg_table_prefixCOHORT_GENERATION cg","JOIN @schema.@database_table_prefix@database_table dt ON cg.database_id = dt.database_id" +cohort-generator-main.R,708,715,"FROM @schema.@cg_table_prefixCOHORT_SUMMARY_STATS css","JOIN @schema.@database_table_prefix@database_table dt ON css.database_id = dt.database_id" +cohort-generator-main.R,708,715,"FROM @schema.@cg_table_prefixCOHORT_SUMMARY_STATS css","JOIN @schema.@cg_table_prefixCOHORT_DEFINITION cd ON cd.cohort_definition_id = css.cohort_definition_id" +cohort-generator-main.R,734,738,"FROM @schema.@cg_table_prefixCOHORT_INCLUSION ci","JOIN @schema.@cg_table_prefixCOHORT_DEFINITION cd ON cd.cohort_definition_id = ci.cohort_definition_id" +cohort-generator-main.R,753,757,"FROM @schema.@cg_table_prefixCOHORT_INC_RESULT cir","JOIN @schema.@database_table_prefix@database_table dt ON cir.database_id = dt.database_id" +estimation-cohort-method-covariateBalance.R,330,334,"FROM @result_schema.@cm_table_prefixCOVARIATE_BALANCE i","JOIN @result_schema.@database_table_name d ON d.database_id = i.database_id" +estimation-cohort-method-covariateBalance.R,359,380,"FROM @results_schema.@cm_table_prefixshared_covariate_balance cmscb","JOIN @results_schema.@cm_table_prefixcovariate cmc ON cmscb.covariate_id = cmc.covariate_id AND cmscb.analysis_id = cmc.analysis_id AND cmscb.database_id = cmc.database_id -- database_id optional --" +estimation-cohort-method-covariateBalance.R,359,380,"FROM @results_schema.@cm_table_prefixshared_covariate_balance cmscb","JOIN @results_schema.@cm_table_prefixcovariate_analysis cmca ON cmca.analysis_id = cmc.analysis_id -- question: shouldn't we have a covariate_analysis_id in @table_prefixcovariate table?" +estimation-cohort-method-covariateBalance.R,632,651,"FROM @schema.@cm_table_prefixdiagnostics_summary cmds","JOIN @schema.@database_table dmd ON dmd.database_id = cmds.database_id" +estimation-cohort-method-diagnostics.R,63,94,"FROM @schema.@cm_table_prefixdiagnostics_summary cmds","JOIN @schema.@cm_table_prefixanalysis cma ON cmds.analysis_id = cma.analysis_id INNER" +estimation-cohort-method-diagnostics.R,63,94,"FROM @schema.@cm_table_prefixdiagnostics_summary cmds","JOIN @schema.@database_table dmd ON dmd.database_id = cmds.database_id INNER" +estimation-cohort-method-diagnostics.R,63,94,"FROM @schema.@cm_table_prefixdiagnostics_summary cmds","JOIN @schema.@cg_table_prefixcohort_definition cgcd1 ON cmds.target_id = cgcd1.cohort_definition_id INNER" +estimation-cohort-method-diagnostics.R,63,94,"FROM @schema.@cm_table_prefixdiagnostics_summary cmds","JOIN @schema.@cg_table_prefixcohort_definition cgcd2 ON cmds.comparator_id = cgcd2.cohort_definition_id INNER" +estimation-cohort-method-diagnostics.R,63,94,"FROM @schema.@cm_table_prefixdiagnostics_summary cmds","JOIN @schema.@cg_table_prefixcohort_definition cgcd3 ON cmds.outcome_id = cgcd3.cohort_definition_id" +estimation-cohort-method-populationCharacteristics.R,176,202,"FROM @schema.@cm_table_prefixcovariate_balance WHERE","JOIN @schema.@cm_table_prefixcovariate cmc ON cmcb.covariate_id = cmc.covariate_id AND cmcb.analysis_id = cmc.analysis_id AND cmcb.database_id = cmc.database_id -- database_id optional" +estimation-cohort-method-propensityModel.R,145,171,"FROM @schema.@cm_table_prefixcovariate WHERE","JOIN @schema.@cm_table_prefixpropensity_model cmpm ON cmc.covariate_id = cmpm.covariate_id" +estimation-cohort-method-results.R,297,356,"FROM @schema.@cm_table_prefixanalysis cma","JOIN @schema.@cm_table_prefixresult cmr ON cmr.analysis_id = cma.analysis_id" +estimation-cohort-method-results.R,297,356,"FROM @schema.@cm_table_prefixanalysis cma","JOIN @schema.@database_table dmd ON dmd.database_id = cmr.database_id LEFT" +estimation-cohort-method-results.R,297,356,"FROM @schema.@cm_table_prefixanalysis cma","JOIN @schema.@cm_table_prefixdiagnostics_summary cmds ON cmds.analysis_id = cmr.analysis_id AND cmds.target_id = cmr.target_id AND cmds.comparator_id = cmr.comparator_id AND cmds.outcome_id = cmr.outcome_id AND cmds.database_id = cmr.database_id inner" +estimation-cohort-method-results.R,297,356,"FROM @schema.@cm_table_prefixanalysis cma","JOIN @schema.@cg_table_prefixcohort_definition cg1 ON cg1.cohort_definition_id = cmr.target_id inner" +estimation-cohort-method-results.R,297,356,"FROM @schema.@cm_table_prefixanalysis cma","JOIN @schema.@cg_table_prefixcohort_definition cg2 ON cg2.cohort_definition_id = cmr.outcome_id inner" +estimation-cohort-method-results.R,297,356,"FROM @schema.@cm_table_prefixanalysis cma","JOIN @schema.@cg_table_prefixcohort_definition cg3 ON cg3.cohort_definition_id = cmr.comparator_id" +estimation-cohort-method-systematicError.R,161,174,"FROM @schema.@cm_table_prefixresult cmr","JOIN @schema.@cm_table_prefixtarget_comparator_outcome cmtco ON cmr.target_id = cmtco.target_id AND cmr.comparator_id = cmtco.comparator_id AND cmr.outcome_id = cmtco.outcome_id" +estimation-cohort-method-systematicError.R,321,338,"FROM @schema.@cm_table_prefixdiagnostics_summary cmds","JOIN @schema.@database_table dmd ON dmd.database_id = cmds.database_id" +estimation-sccs-diagnostics.R,57,102,"FROM @schema.@sccs_table_prefixdiagnostics_summary ds","JOIN @schema.@sccs_table_prefixexposures_outcome_set eos ON ds.exposures_outcome_set_id = eos.exposures_outcome_set_id inner" +estimation-sccs-diagnostics.R,57,102,"FROM @schema.@sccs_table_prefixdiagnostics_summary ds","JOIN @schema.@database_table_prefix@database_table d ON d.database_id = ds.database_id INNER" +estimation-sccs-diagnostics.R,57,102,"FROM @schema.@sccs_table_prefixdiagnostics_summary ds","JOIN @schema.@sccs_table_prefixanalysis a ON a.analysis_id = ds.analysis_id INNER" +estimation-sccs-diagnostics.R,57,102,"FROM @schema.@sccs_table_prefixdiagnostics_summary ds","JOIN @schema.@sccs_table_prefixcovariate cov ON cov.covariate_id = ds.covariate_id and cov.exposures_outcome_set_id = ds.exposures_outcome_set_id and cov.analysis_id = ds.analysis_id and cov.database_id = ds.database_id inner" +estimation-sccs-results-full.R,489,517,"FROM @schema.@sccs_table_prefixcovariate_result scr","JOIN @schema.@sccs_table_prefixcovariate sc ON ( sc.exposures_outcome_set_id = scr.exposures_outcome_set_id AND sc.database_id = scr.database_id AND sc.analysis_id = scr.analysis_id AND sc.covariate_id = scr.covariate_id ) LEFT" +estimation-sccs-results-full.R,489,517,"FROM @schema.@sccs_table_prefixcovariate_result scr","JOIN @schema.@cg_table_prefixcohort_definition cd ON cd.cohort_definition_id = sc.era_id LEFT" +estimation-sccs-results-full.R,489,517,"FROM @schema.@sccs_table_prefixcovariate_result scr","JOIN @schema.@sccs_table_prefixera era ON ( era.exposures_outcome_set_id = scr.exposures_outcome_set_id AND era.database_id = scr.database_id AND era.analysis_id = scr.analysis_id AND era.era_id = sc.era_id )" +estimation-sccs-results-full.R,740,766,"FROM @schema.@sccs_table_prefixresult r","JOIN @schema.@sccs_table_prefixexposure e ON r.exposures_outcome_set_id = e.exposures_outcome_set_id INNER" +estimation-sccs-results-full.R,740,766,"FROM @schema.@sccs_table_prefixresult r","JOIN @schema.@sccs_table_prefixcovariate c ON e.era_id = c.era_id and e.exposures_outcome_set_id = c.exposures_outcome_set_id and c.database_id = r.database_id and c.analysis_id = r.analysis_id and c.covariate_id = r.covariate_id" +estimation-sccs-results.R,250,344,"FROM @schema.@sccs_table_prefixresult sr","JOIN @schema.@database_table_prefix@database_table ds ON sr.database_id = ds.database_id INNER" +estimation-sccs-results.R,250,344,"FROM @schema.@sccs_table_prefixresult sr","JOIN @schema.@sccs_table_prefixdiagnostics_summary sds ON ( sds.exposures_outcome_set_id = sr.exposures_outcome_set_id AND sds.database_id = sr.database_id AND sds.analysis_id = sr.analysis_id AND sds.covariate_id = sr.covariate_id ) INNER" +estimation-sccs-results.R,250,344,"FROM @schema.@sccs_table_prefixresult sr","JOIN @schema.@sccs_table_prefixcovariate sc ON ( sc.exposures_outcome_set_id = sr.exposures_outcome_set_id AND sc.database_id = sr.database_id AND sc.analysis_id = sr.analysis_id AND sc.covariate_id = sr.covariate_id ) INNER" +estimation-sccs-results.R,250,344,"FROM @schema.@sccs_table_prefixresult sr","JOIN @schema.@sccs_table_prefixexposures_outcome_set eos ON eos.exposures_outcome_set_id = sr.exposures_outcome_set_id INNER" +estimation-sccs-results.R,250,344,"FROM @schema.@sccs_table_prefixresult sr","JOIN @schema.@sccs_table_prefixanalysis a ON a.analysis_id = sr.analysis_id inner" +estimation-sccs-results.R,250,344,"FROM @schema.@sccs_table_prefixresult sr","JOIN @schema.@cg_table_prefixcohort_definition cg1 ON cg1.cohort_definition_id = eos.outcome_id inner" +helpers-sccsDataPulls.R,41,59,"FROM @schema.@sccs_table_prefixexposures_outcome_set eos","JOIN @schema.@cg_table_prefixcohort_definition c ON eos.nesting_cohort_id = c.cohort_definition_id INNER" +helpers-sccsDataPulls.R,41,59,"FROM @schema.@sccs_table_prefixexposures_outcome_set eos","JOIN @schema.@sccs_table_prefixcovariate cov ON eos.exposures_outcome_set_id = cov.exposures_outcome_set_id INNER" +helpers-sccsDataPulls.R,41,59,"FROM @schema.@sccs_table_prefixexposures_outcome_set eos","JOIN @schema.@sccs_table_prefixexposure e ON eos.exposures_outcome_set_id = e.exposures_outcome_set_id AND cov.era_id = e.era_id INNER" +helpers-sccsDataPulls.R,41,59,"FROM @schema.@sccs_table_prefixexposures_outcome_set eos","JOIN @schema.@cg_table_prefixcohort_definition c2 ON e.era_id = c2.cohort_definition_id GROUP BY c.cohort_definition_id, c.cohort_name, e.era_id, c2.cohort_name" +helpers-sccsDataPulls.R,77,99,"FROM @schema.@sccs_table_prefixresult r","JOIN @schema.@sccs_table_prefixexposures_outcome_set eos ON r.exposures_outcome_set_id = eos.exposures_outcome_set_id INNER" +helpers-sccsDataPulls.R,77,99,"FROM @schema.@sccs_table_prefixresult r","JOIN @schema.@sccs_table_prefixcovariate cov ON r.exposures_outcome_set_id = cov.exposures_outcome_set_id AND r.analysis_id = cov.analysis_id AND r.covariate_id = cov.covariate_id INNER" +helpers-sccsDataPulls.R,77,99,"FROM @schema.@sccs_table_prefixresult r","JOIN @schema.@sccs_table_prefixexposure e ON r.exposures_outcome_set_id = e.exposures_outcome_set_id AND cov.era_id = e.era_id INNER" +helpers-sccsDataPulls.R,186,217,"FROM @schema.@sccs_table_prefixcovariate_result scr","JOIN @schema.@sccs_table_prefixcovariate sc ON ( sc.exposures_outcome_set_id = scr.exposures_outcome_set_id AND sc.database_id = scr.database_id AND sc.analysis_id = scr.analysis_id AND sc.covariate_id = scr.covariate_id ) LEFT" +helpers-sccsDataPulls.R,186,217,"FROM @schema.@sccs_table_prefixcovariate_result scr","JOIN @schema.@cg_table_prefixcohort_definition cd ON cd.cohort_definition_id = sc.era_id LEFT" +helpers-sccsDataPulls.R,186,217,"FROM @schema.@sccs_table_prefixcovariate_result scr","JOIN @schema.@sccs_table_prefixera era ON ( era.exposures_outcome_set_id = scr.exposures_outcome_set_id AND era.database_id = scr.database_id AND era.analysis_id = scr.analysis_id AND era.era_id = sc.era_id ) INNER" +helpers-sccsDataPulls.R,186,217,"FROM @schema.@sccs_table_prefixcovariate_result scr","JOIN @schema.@sccs_table_prefixexposures_outcome_set eos ON eos.exposures_outcome_set_id = scr.exposures_outcome_set_id" +helpers-sccsDataPulls.R,236,245,"FROM @schema.@sccs_table_prefixtime_trend tt","JOIN @schema.@sccs_table_prefixexposures_outcome_set eos ON tt.exposures_outcome_set_id = eos.exposures_outcome_set_id" +helpers-sccsDataPulls.R,265,275,"FROM @schema.@sccs_table_prefixdiagnostics_summary ds","JOIN @schema.@sccs_table_prefixexposures_outcome_set eos ON ds.exposures_outcome_set_id = eos.exposures_outcome_set_id" +helpers-sccsDataPulls.R,288,298,"FROM @schema.@sccs_table_prefixtime_to_event tte","JOIN @schema.@sccs_table_prefixexposures_outcome_set eos ON tte.exposures_outcome_set_id = eos.exposures_outcome_set_id" +helpers-sccsDataPulls.R,324,335,"FROM @schema.@sccs_table_prefixattrition a","JOIN @schema.@sccs_table_prefixexposures_outcome_set eos ON a.exposures_outcome_set_id = eos.exposures_outcome_set_id" +helpers-sccsDataPulls.R,351,361,"FROM @schema.@sccs_table_prefixevent_dep_observation o","JOIN @schema.@sccs_table_prefixexposures_outcome_set eos ON o.exposures_outcome_set_id = eos.exposures_outcome_set_id" +helpers-sccsDataPulls.R,376,386,"FROM @schema.@sccs_table_prefixage_spanning asp","JOIN @schema.@sccs_table_prefixexposures_outcome_set eos ON asp.exposures_outcome_set_id = eos.exposures_outcome_set_id" +helpers-sccsDataPulls.R,401,411,"FROM @schema.@sccs_table_prefixcalendar_time_spanning ts","JOIN @schema.@sccs_table_prefixexposures_outcome_set eos ON ts.exposures_outcome_set_id = eos.exposures_outcome_set_id" +helpers-sccsDataPulls.R,428,439,"FROM @schema.@sccs_table_prefixspline s","JOIN @schema.@sccs_table_prefixexposures_outcome_set eos ON s.exposures_outcome_set_id = eos.exposures_outcome_set_id" +helpers-sccsDataPulls.R,457,474,"FROM @schema.@sccs_table_prefixresult sr","JOIN @schema.@sccs_table_prefixcovariate sc ON ( sc.exposures_outcome_set_id = sr.exposures_outcome_set_id AND sc.database_id = sr.database_id AND sc.analysis_id = sr.analysis_id AND sc.covariate_id = sr.covariate_id ) INNER" +helpers-sccsDataPulls.R,457,474,"FROM @schema.@sccs_table_prefixresult sr","JOIN @schema.@sccs_table_prefixexposure se ON ( se.exposures_outcome_set_id = sr.exposures_outcome_set_id AND se.era_id = sc.era_id )" +helpers-sccsDataPulls.R,491,510,"FROM @schema.@sccs_table_prefixdiagnostics_summary ds","JOIN @schema.@sccs_table_prefixexposures_outcome_set eos ON ds.exposures_outcome_set_id = eos.exposures_outcome_set_id inner" +helpers-sccsDataPulls.R,491,510,"FROM @schema.@sccs_table_prefixdiagnostics_summary ds","JOIN @schema.@sccs_table_prefixcovariate cov ON cov.covariate_id = ds.covariate_id and cov.exposures_outcome_set_id = ds.exposures_outcome_set_id and cov.analysis_id = ds.analysis_id and cov.database_id = ds.database_id" +patient-level-prediction-designSummary.R,271,281,"FROM @schema.@plp_table_prefixmodel_designs as","JOIN @schema.@cg_table_prefixcohort_definition cd ON c.cohort_definition_id = cd.cohort_definition_id ) AS cohorts ON model_designs.@type_id = cohorts.cohort_id" +patient-level-prediction-designSummary.R,310,368,"FROM @schema.@plp_table_prefixmodel_designs as","JOIN @schema.@cg_table_prefixcohort_definition cd ON c.cohort_definition_id = cd.cohort_definition_id ) AS targets ON model_designs.target_id = targets.cohort_id LEFT" +patient-level-prediction-designSummary.R,310,368,"FROM @schema.@plp_table_prefixmodel_designs as","JOIN @schema.@cg_table_prefixcohort_definition cd ON c.cohort_definition_id = cd.cohort_definition_id ) AS outcomes ON model_designs.outcome_id = outcomes.cohort_id LEFT" +patient-level-prediction-diagnostics.R,428,460,"FROM @schema.@plp_table_prefixDIAGNOSTICS where","JOIN @schema.@plp_table_prefixMODEL_DESIGNS design ON diagnostics.MODEL_DESIGN_ID = design.MODEL_DESIGN_ID inner" +patient-level-prediction-diagnostics.R,428,460,"FROM @schema.@plp_table_prefixDIAGNOSTICS where","JOIN @schema.@plp_table_prefixDIAGNOSTIC_SUMMARY summary ON diagnostics.DIAGNOSTIC_ID = summary.DIAGNOSTIC_ID inner" +patient-level-prediction-diagnostics.R,428,460,"FROM @schema.@plp_table_prefixDIAGNOSTICS where","JOIN @schema.@plp_table_prefixdatabase_details dd ON md.database_id = dd.database_meta_data_id) as database on database.database_id = diagnostics.database_id inner" +patient-level-prediction-diagnostics.R,428,460,"FROM @schema.@plp_table_prefixDIAGNOSTICS where","JOIN @schema.@plp_table_prefixCOHORTS cohortT ON cohortT.cohort_id = design.target_id inner" +patient-level-prediction-diagnostics.R,428,460,"FROM @schema.@plp_table_prefixDIAGNOSTICS where","JOIN @schema.@plp_table_prefixCOHORTS cohortO ON cohortO.cohort_id = design.outcome_id" +patient-level-prediction-modelSummary.R,253,303,"FROM @schema.@plp_table_prefixperformances where","JOIN @schema.@cg_table_prefixcohort_definition cd ON c.cohort_definition_id = cd.cohort_definition_id ) AS targets ON results.target_id = targets.cohort_id LEFT" +patient-level-prediction-modelSummary.R,253,303,"FROM @schema.@plp_table_prefixperformances where","JOIN @schema.@cg_table_prefixcohort_definition cd ON c.cohort_definition_id = cd.cohort_definition_id ) AS outcomes ON results.outcome_id = outcomes.cohort_id LEFT" +patient-level-prediction-modelSummary.R,253,303,"FROM @schema.@plp_table_prefixperformances where","JOIN @schema.@plp_table_prefixdatabase_details dd ON md.database_id = dd.database_meta_data_id) AS d ON results.development_database_id = d.database_id LEFT" +patient-level-prediction-modelSummary.R,253,303,"FROM @schema.@plp_table_prefixperformances where","JOIN @schema.@plp_table_prefixdatabase_details dd ON md.database_id = dd.database_meta_data_id) AS v ON results.validation_database_id = v.database_id LEFT" +patient-level-prediction-settings.R,350,380,"FROM @schema.@plp_table_prefixperformances WHERE","JOIN @schema.@database_table_prefixdatabase_meta_data dmd ON dd.database_meta_data_id = dmd.database_id) tempV on tempV.database_id = perf.validation_database_id" +patient-level-prediction-settings.R,546,550,"FROM @schema.@plp_table_prefixcohorts c","JOIN @schema.@cg_table_prefixcohort_definition cd ON c.cohort_definition_id = cd.cohort_definition_id" +patient-level-prediction-settings.R,564,568,"FROM @schema.@plp_table_prefixcohorts c","JOIN @schema.@cg_table_prefixcohort_definition cd ON c.cohort_definition_id = cd.cohort_definition_id" +patient-level-prediction-validation.R,256,311,"FROM @schema.@plp_table_appendperformances where","JOIN @schema.@plp_table_appenddatabase_details dd ON md.database_id = dd.database_meta_data_id) AS d ON results.validation_database_id = d.database_id LEFT" +report-main.R,843,911,"FROM @schema.@c_table_prefixcohort_details where","JOIN @schema.@plp_table_prefixcohorts c1 ON c1.cohort_id = md.target_id inner" +report-main.R,843,911,"FROM @schema.@c_table_prefixcohort_details where","JOIN @schema.@plp_table_prefixcohorts c2 ON c2.cohort_id = md.outcome_id } {@sccs} ? { {@cohort_method | @cohort_incidence | @characterization | @prediction}?{union} SELECT distinct cov.era_id as tid, eos.outcome_id as oid FROM @schema.@sccs_table_prefixdiagnostics_summary ds inner" +report-main.R,843,911,"FROM @schema.@c_table_prefixcohort_details where","JOIN @schema.@sccs_table_prefixexposures_outcome_set eos ON ds.exposures_outcome_set_id = eos.exposures_outcome_set_id INNER" +report-main.R,843,911,"FROM @schema.@c_table_prefixcohort_details where","JOIN @schema.@sccs_table_prefixcovariate cov ON cov.covariate_id = ds.covariate_id and cov.exposures_outcome_set_id = ds.exposures_outcome_set_id and cov.analysis_id = ds.analysis_id and cov.database_id = ds.database_id -- adding code to remove the negative controls INNER" +report-main.R,843,911,"FROM @schema.@c_table_prefixcohort_details where","JOIN @schema.@sccs_table_prefixexposure e ON e.exposures_outcome_set_id = ds.exposures_outcome_set_id AND e.era_id = cov.era_id" diff --git a/extras/rdms/results_table_relationships.csv b/extras/rdms/results_table_relationships.csv new file mode 100644 index 00000000..ae805e9b --- /dev/null +++ b/extras/rdms/results_table_relationships.csv @@ -0,0 +1,140 @@ +table_name,column_name,fk_table_name,fk_column_name +c_settings,database_id,database_meta_data,database_id +c_settings,setting_id,c_cohort_details,setting_id +c_settings,database_id,c_cohort_details,database_id +c_cohort_details,target_cohort_id,cg_cohort_definition,cohort_definition_id +c_cohort_details,outcome_cohort_id,cg_cohort_definition,cohort_definition_id +c_covariates,setting_id,c_covariate_ref,setting_id +c_covariates,database_id,c_covariate_ref,database_id +c_covariates,covariate_id,c_covariate_ref,covariate_id +c_covariates,setting_id,c_settings,setting_id +c_covariates,database_id,c_settings,database_id +c_covariates_continuous,setting_id,c_covariate_ref,setting_id +c_covariates_continuous,database_id,c_covariate_ref,database_id +c_covariates_continuous,setting_id,c_settings,setting_id +c_covariates,setting_id,c_settings,database_id +c_covariates,database_id,c_settings,setting_id +c_covariates_continuous,covariate_id,c_covariate_ref,covariate_id +c_covariates_continuous,database_id,c_settings,database_id +c_covariates_continuous,database_id,database_meta_data,database_id +database_meta_data,database_id,c_cohort_details,database_id +c_dechallenge_rechallenge,target_cohort_definition_id,cg_cohort_definition,cohort_definition_id +c_dechallenge_rechallenge,outcome_cohort_definition_id,cg_cohort_definition,cohort_definition_id +c_dechallenge_rechallenge,database_id,database_meta_data,database_id +ci_incidence_summary,outcome_id,ci_outcome_def,outcome_id +ci_incidence_summary,ref_id,ci_outcome_def,ref_id +ci_incidence_summary,ref_id,ci_tar_def,ref_id +ci_incidence_summary,tar_id,ci_tar_def,ref_id +ci_incidence_summary,subgroup_id,ci_subgroup_def,subgroup_id +ci_incidence_summary,ref_id,ci_subgroup_def,ref_id +ci_incidence_summary,age_group_id,ci_age_group_def,age_group_id +ci_incidence_summary,ref_id,ci_age_group_def,ref_id +ci_incidence_summary,database_id,database_meta_data,database_id +ci_incidence_summary,target_cohort_definition_id,cg_cohort_definition,cohort_definition_id +ci_incidence_summary,outcome_cohort_definition_id,cg_cohort_definition,cohort_definition_id +c_time_to_event,database_id,database_meta_data,database_id +cd_temporal_covariate_ref,analysis_id,cd_temporal_analysis_ref,analysis_id +cd_temporal_covariate_ref,covariate_id,cd_temporal_covariate_value,covariate_id +cd_temporal_covariate_ref,time_id,cd_temporal_time_ref,time_id +cd_included_source_concept,concept_id,cd_concept,concept_id +cd_incidence_rate,database_id,cd_cohort_count,database_id +cd_incidence_rate,cohort_id,cd_cohort_count,cohort_id +cd_index_event_breakdown,concept_id,cd_concept,concept_id +cd_orphan_concept,cohort_id,cd_concept_sets,cohort_id +cd_orphan_concept,concept_set_id,cd_concept_sets,concept_set_id +cd_orphan_concept,concept_id,cd_concept,concept_id +cd_cohort_count,database_id,database_meta_data,database_id +cd_visit_context,concept_id,cd_concept,concept_id +cg_cohort_count,database_id,database_meta_data,database_id +cg_cohort_count,cohort_id,cg_cohort_definition,cohort_definition_id +cg_cohort_generation,database_id,database_meta_data,database_id +cg_cohort_summary_stats,database_id,database_meta_data,database_id +cg_cohort_summary_stats,cohort_definition_id,cg_cohort_definition,cohort_definition_id +cg_cohort_inclusion,cohort_definition_id,cg_cohort_definition,cohort_definition_id +cg_cohort_inc_result,database_id,database_meta_data,database_id +cm_covariate_balance,database_id,database_meta_data,database_id +cm_shared_covariate_balance,covariate_id,cm_covariate,covariate_id +cm_shared_covariate_balance,analysis_id,cm_covariate,analysis_id +cm_shared_covariate_balance,database_id,cm_covariate,database_id +cm_shared_covariate_balance,analysis_id,cm_covariate_analysis,analysis_id +cm_diagnostics_summary,database_id,database_meta_data,database_id +cm_diagnostics_summary,analysis_id,cm_analysis,analysis_id +cm_diagnostics_summary,target_id,cg_cohort_definition,cohort_definition_id +cm_diagnostics_summary,comparator_id,cg_cohort_definition,cohort_definition_id +cm_diagnostics_summary,outcome_id,cg_cohort_definition,cohort_definition_id +cm_covariate_balance,covariate_id,cm_covariate,covariate_id +cm_covariate_balance,analysis_id,cm_covariate,analysis_id +cm_covariate_balance,database_id,cm_covariate,database_id +cm_covariate,covariate_id,cm_propensity_model,covariate_id +cm_analysis,analysis_id,cm_result,analysis_id +cm_analysis,database_id,database_meta_data,database_id +cm_analysis,analysis_id,cm_diagnostics_summary,analysis_id +cm_analysis,target_id,cm_diagnostics_summary,target_id +cm_analysis,comparator_id,cm_diagnostics_summary,comparator_id +cm_analysis,outcome_id,cm_diagnostics_summary,outcome_id +cm_analysis,database_id,cm_diagnostics_summary,database_id +cm_analysis,target_id,cg_cohort_definition,cohort_definition_id +cm_analysis,outcome_id,cg_cohort_definition,cohort_definition_id +cm_analysis,comparator_id,cg_cohort_definition,cohort_definition_id +cm_result,target_id,cm_target_comparator_outcome,target_id +cm_result,comparator_id,cm_target_comparator_outcome,comparator_id +cm_result,outcome_id,cm_target_comparator_outcome,outcome_id +sccs_diagnostics_summary,exposures_outcome_set_id,sccs_exposures_outcome_set,exposures_outcome_set_id +sccs_diagnostics_summary,database_id,database_meta_data,database_id +sccs_diagnostics_summary,analysis_id,sccs_analysis,analysis_id +sccs_diagnostics_summary,covariate_id,sccs_covariate,covariate_id +sccs_diagnostics_summary,exposures_outcome_set_id,sccs_covariate,exposures_outcome_set_id +sccs_diagnostics_summary,database_id,sccs_covariate,database_id +sccs_covariate_result,exposures_outcome_set_id,sccs_covariate,exposures_outcome_set_id +sccs_covariate_result,database_id,sccs_covariate,database_id +sccs_covariate_result,analysis_id,sccs_covariate,analysis_id +sccs_covariate_result,covariate_id,sccs_covariate,covariate_id +sccs_covariate_result,era_id,cg_cohort_definition,cohort_definition_id +sccs_covariate_result,exposures_outcome_set_id,sccs_era,exposures_outcome_set_id +sccs_covariate_result,database_id,sccs_era,database_id +sccs_covariate_result,analysis_id,sccs_era,analysis_id +sccs_covariate_result,era_id,sccs_era,era_id +sccs_result,exposures_outcome_set_id,sccs_exposure,exposures_outcome_set_id +sccs_result,era_id,sccs_covariate,era_id +sccs_result,exposures_outcome_set_id,sccs_covariate,exposures_outcome_set_id +sccs_result,database_id,sccs_covariate,database_id +sccs_result,covariate_id,sccs_covariate,covariate_id +sccs_result,database_id,database_meta_data,database_id +sccs_result,exposures_outcome_set_id,sccs_diagnostics_summary,exposures_outcome_set_id +sccs_result,database_id,sccs_diagnostics_summary,database_id +sccs_result,analysis_id,sccs_diagnostics_summary,analysis_id +sccs_result,covariate_id,sccs_diagnostics_summary,covariate_id +sccs_result,analysis_id,sccs_covariate,analysis_id +sccs_result,exposures_outcome_set_id,sccs_exposures_outcome_set,exposures_outcome_set_id +sccs_result,analysis_id,sccs_analysis,analysis_id +sccs_result,outcome_id,cg_cohort_definition,cohort_definition_id +sccs_exposures_outcome_set,nesting_cohort_id,cg_cohort_definition,cohort_definition_id +sccs_exposures_outcome_set,exposures_outcome_set_id,sccs_covariate,exposures_outcome_set_id +sccs_exposures_outcome_set,exposures_outcome_set_id,sccs_exposure,exposures_outcome_set_id +sccs_exposures_outcome_set,era_id,sccs_exposure,era_id +sccs_exposures_outcome_set,era_id,cg_cohort_definition,era_id +sccs_result,exposures_outcome_set_id,sccs_exposures_outcome_set,exposures_outcome_set_id +sccs_covariate_result,exposures_outcome_set_id,sccs_exposures_outcome_set,exposures_outcome_set_id +sccs_time_trend,exposures_outcome_set_id,sccs_exposures_outcome_set,exposures_outcome_set_id +sccs_diagnostics_summary,exposures_outcome_set_id,sccs_exposures_outcome_set,exposures_outcome_set_id +sccs_time_to_event,exposures_outcome_set_id,sccs_exposures_outcome_set,exposures_outcome_set_id +sccs_attrition,exposures_outcome_set_id,sccs_exposures_outcome_set,exposures_outcome_set_id +sccs_event_dep_observation,exposures_outcome_set_id,sccs_exposures_outcome_set,exposures_outcome_set_id +sccs_age_spanning,exposures_outcome_set_id,sccs_exposures_outcome_set,exposures_outcome_set_id +sccs_calendar_time_spanning,exposures_outcome_set_id,sccs_exposures_outcome_set,exposures_outcome_set_id +sccs_spline,exposures_outcome_set_id,sccs_exposures_outcome_set,exposures_outcome_set_id +sccs_diagnostics_summary,analysis_id,sccs_covariate,analysis_id +plp_model_designs,target_id,cg_cohort_definition,cohort_definition_id +plp_model_designs,outcome_id,cg_cohort_definition,cohort_definition_id +plp_diagnostics,model_design_id,plp_model_designs,model_design_id +plp_diagnostics,diagnostic_id,plp_diagnostic_summary,diagnostic_id +plp_diagnostics,database_id,database_meta_data,database_id +plp_diagnostics,target_id,plp_cohorts,cohort_id +plp_diagnostics,outcome_id,plp_cohorts,cohort_id +plp_performances,target_id,cg_cohort_definition,cohort_definition_id +plp_performances,outcome_id,cg_cohort_definition,cohort_definition_id +plp_performances,development_database_id,database_meta_data,database_id +plp_performances,validation_database_id,database_meta_data,database_id +plp_performances,database_id,database_meta_data,database_id +plp_cohorts,cohort_definition_id,cg_cohort_definition,cohort_definition_id +c_cohort_details,target_id,cg_cohort_definition,cohort_definition_id diff --git a/extras/rdms/results_table_relationships.xlsx b/extras/rdms/results_table_relationships.xlsx new file mode 100644 index 00000000..ea97eea1 Binary files /dev/null and b/extras/rdms/results_table_relationships.xlsx differ diff --git a/extras/rdms/run-local.txt b/extras/rdms/run-local.txt new file mode 100644 index 00000000..2405217c --- /dev/null +++ b/extras/rdms/run-local.txt @@ -0,0 +1 @@ +"E:\Program Files\Amazon Corretto\jdk17.0.12_7\bin\java.exe" -jar schemaspy-6.2.4.jar -vizjs -dp E:\jdbcDrivers -configFile schemaspy-config.properties -meta schema_meta.xml -desc "Results data model" -noTablePaging -noimplied diff --git a/extras/rdms/schema_meta.xml b/extras/rdms/schema_meta.xml new file mode 100644 index 00000000..8d1a4f91 --- /dev/null +++ b/extras/rdms/schema_meta.xml @@ -0,0 +1,1505 @@ + + + The tables in the results data model are grouped using a unique prefix for + each Strategus module. For example, the CharacterizationModule results tables + all start with "c_". + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + +
+ + + + + + + + + +
+ + + +
+ + + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + +
+ + + + + + + + + + + +
+ + + + + +
+ + + + + + + +
+ + + + + + +
+ + + + +
+ + + + + + + +
+ + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + +
+ + + + + + + + + + +
+ + + + + +
+ + + + + + + + + + + + + +
+ + + + + + + +
+ + + + + +
+ + + + + + +
+ + + + + + + + + +
+ + + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + + + + +
+ + + + + + + + + +
+ + + + + + + +
+ + + + + + + + +
+ + + + + + + + +
+ + + + + + + + + + +
+ + + + +
+ + + + + + + + + +
+ + + + + +
+ + + +
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + + +
+ + + + + + + +
+ + + + + + +
+ + + + +
+ + + + +
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + +
+ + + + + + + + + + + + + + + +
+ + + + + + + + +
+ + + + + + + + +
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+ + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+ + + + + + +
+ + + +
+ + + +
+ + + + +
+ + + +
+ + + +
+ + + +
+ + + +
+ + + +
+ + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
+ + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + + +
+ + + + +
+ + + + + + + + + + + + +
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + +
+ + + + + + + + + + + + + + +
+ + + + +
+ + + + + +
+ + + + + + + + +
+ + + + + + + +
+ + + + + + + + + +
+ + + + +
+ + + + + + + + + +
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + + + + + + +
+ + + + + + + + + + + +
+ + + + + + + + + + +
+ + + + + + + + +
+ + + + + + + + + +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
diff --git a/extras/rdms/schemaspy-6.2.4.jar b/extras/rdms/schemaspy-6.2.4.jar new file mode 100644 index 00000000..39a8b006 Binary files /dev/null and b/extras/rdms/schemaspy-6.2.4.jar differ diff --git a/extras/rdms/schemaspy-config.properties b/extras/rdms/schemaspy-config.properties new file mode 100644 index 00000000..a0d9ba45 --- /dev/null +++ b/extras/rdms/schemaspy-config.properties @@ -0,0 +1,10 @@ +schemaspy.t=pgsql + +schemaspy.host=127.0.0.1 +schemaspy.port=5432 +schemaspy.db=strategus +schemaspy.u=user +schemaspy.p=password + +schemaspy.o=./public +schemaspy.s=results diff --git a/extras/rdms/table_descriptions.csv b/extras/rdms/table_descriptions.csv new file mode 100644 index 00000000..646daf44 --- /dev/null +++ b/extras/rdms/table_descriptions.csv @@ -0,0 +1,129 @@ +table_defined_by,table_name,description +CharacterizationModule,c_analysis_ref,"Analysis reference" +CharacterizationModule,c_cohort_counts,"Cohort counts" +CharacterizationModule,c_cohort_details,"Cohort details" +CharacterizationModule,c_covariate_ref,"Covariate reference" +CharacterizationModule,c_covariates,"Binary covariates" +CharacterizationModule,c_covariates_continuous,"Continuous covariates" +CharacterizationModule,c_dechallenge_rechallenge,"Dechallenge rechallenge" +CharacterizationModule,c_rechallenge_fail_case_series,"Rechallenge fail case series" +CharacterizationModule,c_settings,"Settings" +CharacterizationModule,c_time_to_event,"Time to event" +CohortDiagnosticsModule,cd_cohort,"Cohort details" +CohortDiagnosticsModule,cd_cohort_count,"Cohort counts" +CohortDiagnosticsModule,cd_cohort_inc_result,"Cohort inclusion results" +CohortDiagnosticsModule,cd_cohort_inc_stats,"Cohort inclusion statstics" +CohortDiagnosticsModule,cd_cohort_inclusion,"Cohort inclusion info" +CohortDiagnosticsModule,cd_cohort_overlap,"Cohort overlap" +CohortDiagnosticsModule,cd_cohort_relationships,"Cohort relationships" +CohortDiagnosticsModule,cd_cohort_summary_stats,"Cohort summary stats" +CohortDiagnosticsModule,cd_concept,"Concept lookup table" +CohortDiagnosticsModule,cd_concept_ancestor,"Concept ancestor" +CohortDiagnosticsModule,cd_concept_relationship,"Concept Relationship" +CohortDiagnosticsModule,cd_concept_sets,"Concept sets" +CohortDiagnosticsModule,cd_concept_synonym,"Concept synonym" +CohortDiagnosticsModule,cd_database,"CDM database information for Cohort Diagnostics" +CohortDiagnosticsModule,cd_domain,"Domain from the vocabulary" +CohortDiagnosticsModule,cd_incidence_rate,"Incidence rate for Cohort Diagnostics" +CohortDiagnosticsModule,cd_included_source_concept,"Included source concepts" +CohortDiagnosticsModule,cd_index_event_breakdown,"Index event breakdown" +CohortDiagnosticsModule,cd_metadata,"Metadata for the database and runtime environment used for Cohort Diagnostics" +CohortDiagnosticsModule,cd_orphan_concept,"Orphan concept list" +CohortDiagnosticsModule,cd_relationship,"Relationships" +CohortDiagnosticsModule,cd_resolved_concepts,"Resolved concepts" +CohortDiagnosticsModule,cd_subset_definition,"Cohort subset definition" +CohortDiagnosticsModule,cd_temporal_analysis_ref,"Temporal analysis reference" +CohortDiagnosticsModule,cd_temporal_covariate_ref,"Covariate reference" +CohortDiagnosticsModule,cd_temporal_covariate_value,"Binary covariate values" +CohortDiagnosticsModule,cd_temporal_covariate_value_dist,"Continuous covariate values" +CohortDiagnosticsModule,cd_temporal_time_ref,"Temporal time reference" +CohortDiagnosticsModule,cd_time_series,"Time series information" +CohortDiagnosticsModule,cd_visit_context,"Visit context" +CohortDiagnosticsModule,cd_vocabulary,"Vocabulary information" +CohortGeneratorModule,cg_cohort_censor_stats,"Cohort censor statistics" +CohortGeneratorModule,cg_cohort_count,"Cohort counts" +CohortGeneratorModule,cg_cohort_count_neg_ctrl,"Negative control outcome cohort counts" +CohortGeneratorModule,cg_cohort_definition,"Cohort definitions" +CohortGeneratorModule,cg_cohort_definition_neg_ctrl,"Negative control outcome cohort definitions" +CohortGeneratorModule,cg_cohort_generation,"Cohort generation times" +CohortGeneratorModule,cg_cohort_inc_result,"Cohort inclusion results" +CohortGeneratorModule,cg_cohort_inc_stats,"Cohort inclusion statistics" +CohortGeneratorModule,cg_cohort_inclusion,"Cohort inclusion information" +CohortGeneratorModule,cg_cohort_subset_definition,"Cohort subset definitions" +CohortGeneratorModule,cg_cohort_summary_stats,"Cohort summary statistics" +CohortIncidenceModule,ci_age_group_def,"Age group definitions" +CohortIncidenceModule,ci_incidence_summary,"Incidence rate/proportion summary" +CohortIncidenceModule,ci_outcome_def,"Outcome cohort definitions" +CohortIncidenceModule,ci_subgroup_def,"Subgroup definitions" +CohortIncidenceModule,ci_tar_def,"Time-at-risk definitions" +CohortIncidenceModule,ci_target_def,"Target cohort definitions" +CohortIncidenceModule,ci_target_outcome_ref,"Target outcome cross reference" +CohortMethodModule,cm_analysis,"Analysis reference" +CohortMethodModule,cm_attrition,"Attrition table" +CohortMethodModule,cm_covariate,"Covariate reference" +CohortMethodModule,cm_covariate_analysis,"Covariate analysis reference" +CohortMethodModule,cm_covariate_balance,"Covariate balance" +CohortMethodModule,cm_diagnostics_summary,"Diagnostics summary" +CohortMethodModule,cm_follow_up_dist,"Follow up distribution" +CohortMethodModule,cm_interaction_result,"Study results for interaction effects" +CohortMethodModule,cm_kaplan_meier_dist,"Kaplan Meier distribution" +CohortMethodModule,cm_likelihood_profile,"Likelihood Profile" +CohortMethodModule,cm_preference_score_dist,"Preference score distribution" +CohortMethodModule,cm_propensity_model,"Propensity model" +CohortMethodModule,cm_result,"Study results for main effects" +CohortMethodModule,cm_shared_covariate_balance,"Shared covariate balance" +CohortMethodModule,cm_target_comparator_outcome,"Target comparator outcome reference" +Strategus,database_meta_data,"Metadata for each CDM database" +EvidenceSynthesisModule,es_analysis,"Analysis reference" +EvidenceSynthesisModule,es_cm_diagnostics_summary,"Cohort method diagnostics summary" +EvidenceSynthesisModule,es_cm_result,"Cohort method results" +EvidenceSynthesisModule,es_sccs_diagnostics_summary,"Self controlled case series diagnostics summary" +EvidenceSynthesisModule,es_sccs_result,"Self controlled case series results" +PatientLevelPredictionModule,plp_attrition,"Attrition information" +PatientLevelPredictionModule,plp_calibration_summary,"Calibration summary" +PatientLevelPredictionModule,plp_cohort_definition,"Cohort definitions" +PatientLevelPredictionModule,plp_cohorts,"Cohort identifier reference" +PatientLevelPredictionModule,plp_covariate_settings,"Covariate settings" +PatientLevelPredictionModule,plp_covariate_summary,"Covariate summary" +PatientLevelPredictionModule,plp_database_details,"CDM database details" +PatientLevelPredictionModule,plp_database_meta_data,"CDM database metadata" +PatientLevelPredictionModule,plp_demographic_summary,"Demographic summary" +PatientLevelPredictionModule,plp_diagnostic_designs,"Diagnostic designs" +PatientLevelPredictionModule,plp_diagnostic_outcomes,"Diagnostic outcomes" +PatientLevelPredictionModule,plp_diagnostic_participants,"Diagnostic participants" +PatientLevelPredictionModule,plp_diagnostic_predictors,"Diagnostic predictors" +PatientLevelPredictionModule,plp_diagnostic_summary,"Diagnostic summary" +PatientLevelPredictionModule,plp_diagnostics,"Diagnostics" +PatientLevelPredictionModule,plp_evaluation_statistics,"Evaluation statistics" +PatientLevelPredictionModule,plp_feature_engineering_settings,"Feature engineering settings" +PatientLevelPredictionModule,plp_model_designs,"Model designs" +PatientLevelPredictionModule,plp_model_settings,"Model settings" +PatientLevelPredictionModule,plp_models,"Models" +PatientLevelPredictionModule,plp_performances,"Model performance" +PatientLevelPredictionModule,plp_plp_data_settings,"PLP data settings" +PatientLevelPredictionModule,plp_population_settings,"Population settings" +PatientLevelPredictionModule,plp_prediction_distribution,"Prediction distribution" +PatientLevelPredictionModule,plp_recalibrations,"Recalibrations" +PatientLevelPredictionModule,plp_sample_settings,"Sample settings" +PatientLevelPredictionModule,plp_split_settings,"Split settings" +PatientLevelPredictionModule,plp_tars,"Time-at-risk settings" +PatientLevelPredictionModule,plp_threshold_summary,"Threshold summary" +PatientLevelPredictionModule,plp_tidy_covariates_settings,"Tidy covariate settings" +SelfControlledCaseSeriesModule,sccs_age_spanning,"Age spanning diagnostic" +SelfControlledCaseSeriesModule,sccs_analysis,"Analysis reference" +SelfControlledCaseSeriesModule,sccs_attrition,"Attrition table" +SelfControlledCaseSeriesModule,sccs_calendar_time_spanning,"Calendar time spanning diagnostic" +SelfControlledCaseSeriesModule,sccs_censor_model,"Event-dependent observation censoring model" +SelfControlledCaseSeriesModule,sccs_covariate,"Covariate reference" +SelfControlledCaseSeriesModule,sccs_covariate_analysis,"Covariate analysis" +SelfControlledCaseSeriesModule,sccs_covariate_result,"Covariate results" +SelfControlledCaseSeriesModule,sccs_diagnostics_summary,"Diagnostic summary" +SelfControlledCaseSeriesModule,sccs_era,"Era reference" +SelfControlledCaseSeriesModule,sccs_event_dep_observation,"Event-dependent observation diagnostic" +SelfControlledCaseSeriesModule,sccs_exposure,"Exposure reference" +SelfControlledCaseSeriesModule,sccs_exposures_outcome_set,"Exposure outcome set reference" +SelfControlledCaseSeriesModule,sccs_likelihood_profile,"Likelihood profile" +SelfControlledCaseSeriesModule,sccs_result,"Results" +SelfControlledCaseSeriesModule,sccs_spline,"Season, age, and calendar time splines" +SelfControlledCaseSeriesModule,sccs_time_to_event,"Time-to-event diagnostic" +SelfControlledCaseSeriesModule,sccs_time_trend,"Time trend diagnostic" diff --git a/extras/rdms/table_relationships.xml b/extras/rdms/table_relationships.xml new file mode 100644 index 00000000..ec43f7f8 --- /dev/null +++ b/extras/rdms/table_relationships.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + +
+ + + + +
+
+
\ No newline at end of file diff --git a/inst/csv/cohortIncidenceRdms.csv b/inst/csv/cohortIncidenceRdms.csv index 3a9d90f9..93b73049 100644 --- a/inst/csv/cohortIncidenceRdms.csv +++ b/inst/csv/cohortIncidenceRdms.csv @@ -1,48 +1,48 @@ table_name,column_name,data_type,is_required,primary_key,description -incidence_summary,ref_id,int,no,no, -incidence_summary,database_id,varchar(255),yes,no, -incidence_summary,source_name,varchar(255),no,no, -incidence_summary,target_cohort_definition_id,bigint,no,no, -incidence_summary,tar_id,bigint,no,no, -incidence_summary,subgroup_id,bigint,no,no, -incidence_summary,outcome_id,bigint,no,no, -incidence_summary,age_group_id,int,no,no, -incidence_summary,gender_id,int,no,no, -incidence_summary,gender_name,varchar(255),no,no, -incidence_summary,start_year,int,no,no, -incidence_summary,persons_at_risk_pe,bigint,no,no, -incidence_summary,persons_at_risk,bigint,no,no, -incidence_summary,person_days_pe,bigint,no,no, -incidence_summary,person_days,bigint,no,no, -incidence_summary,person_outcomes_pe,bigint,no,no, -incidence_summary,person_outcomes,bigint,no,no, -incidence_summary,outcomes_pe,bigint,no,no, -incidence_summary,outcomes,bigint,no,no, -incidence_summary,incidence_proportion_p100p,float,no,no, -incidence_summary,incidence_rate_p100py,float,no,no, -target_def,ref_id,int,yes,yes, -target_def,target_cohort_definition_id,bigint,yes,yes, -target_def,target_name,varchar(255),no,no, -outcome_def,ref_id,int,yes,yes, -outcome_def,outcome_id,bigint,yes,yes, -outcome_def,outcome_cohort_definition_id,bigint,no,no, -outcome_def,outcome_name,varchar(255),no,no, -outcome_def,clean_window,bigint,no,no, -outcome_def,excluded_cohort_definition_id,bigint,no,no, -tar_def,ref_id,int,yes,yes, -tar_def,tar_id,bigint,yes,yes, -tar_def,tar_start_with,varchar(10),no,no, -tar_def,tar_start_offset,bigint,no,no, -tar_def,tar_end_with,varchar(10),no,no, -tar_def,tar_end_offset,bigint,no,no, -age_group_def,ref_id,int,yes,yes, -age_group_def,age_group_id,int,yes,yes, -age_group_def,age_group_name,varchar(255),yes,no, -age_group_def,min_age,int,no,no, -age_group_def,max_age,int,no,no, -subgroup_def,ref_id,int,yes,yes, -subgroup_def,subgroup_id,bigint,no,yes, -subgroup_def,subgroup_name,varchar(255),no,no, -target_outcome_ref,ref_id,int,yes,yes, -target_outcome_ref,target_cohort_id,bigint,yes,yes, -target_outcome_ref,outcome_cohort_id,bigint,yes,yes, +incidence_summary,ref_id,int,no,no,The reference identifier for the analysis +incidence_summary,database_id,varchar(255),yes,no,The database identifier +incidence_summary,source_name,varchar(255),no,no,The source name for the database +incidence_summary,target_cohort_definition_id,bigint,no,no,Target cohort identifier +incidence_summary,tar_id,bigint,no,no,Time-at-risk identifier +incidence_summary,subgroup_id,bigint,no,no,Subgroup identifier +incidence_summary,outcome_id,bigint,no,no,Outcome cohort identifier +incidence_summary,age_group_id,int,no,no,Age group identifier +incidence_summary,gender_id,int,no,no,Gender identifier +incidence_summary,gender_name,varchar(255),no,no,Gender name +incidence_summary,start_year,int,no,no,Start year +incidence_summary,persons_at_risk_pe,bigint,no,no,Persons at risk pre-exclude (counts before excluding time at risk) +incidence_summary,persons_at_risk,bigint,no,no,Persons at risk +incidence_summary,person_days_pe,bigint,no,no,Person days pre-exclude (counts before excluding time at risk) +incidence_summary,person_days,bigint,no,no,Person days +incidence_summary,person_outcomes_pe,bigint,no,no,Person outcomes pre-exclude (counts before excluding time at risk) +incidence_summary,person_outcomes,bigint,no,no,Person outcomes +incidence_summary,outcomes_pe,bigint,no,no,Outcomes pre-exclude (counts before excluding time at risk) +incidence_summary,outcomes,bigint,no,no,Outcomes +incidence_summary,incidence_proportion_p100p,float,no,no,Incidence proportion (person_outcomes / persons_at_risk) per 100 people +incidence_summary,incidence_rate_p100py,float,no,no,Incidence rate (outcomes / time_at_risk) per 100 person years +target_def,ref_id,int,yes,yes,The reference identifier for the analysis +target_def,target_cohort_definition_id,bigint,yes,yes,Target cohort identifier +target_def,target_name,varchar(255),no,no,Target cohort name +outcome_def,ref_id,int,yes,yes,The reference identifier for the analysis +outcome_def,outcome_id,bigint,yes,yes,Outcome identifier +outcome_def,outcome_cohort_definition_id,bigint,no,no,Outcome cohort identifier +outcome_def,outcome_name,varchar(255),no,no,Outcome name +outcome_def,clean_window,bigint,no,no,Clean window +outcome_def,excluded_cohort_definition_id,bigint,no,no,Excluded cohort identifier +tar_def,ref_id,int,yes,yes,The reference identifier for the analysis +tar_def,tar_id,bigint,yes,yes,Time-at-risk identifier +tar_def,tar_start_with,varchar(10),no,no,Time-at-risk start anchor +tar_def,tar_start_offset,bigint,no,no,Time-at-risk start offset in days +tar_def,tar_end_with,varchar(10),no,no,Time-at-risk end anchor +tar_def,tar_end_offset,bigint,no,no,Time-at-risk end offset in days +age_group_def,ref_id,int,yes,yes,The reference identifier for the analysis +age_group_def,age_group_id,int,yes,yes,Age group identifier +age_group_def,age_group_name,varchar(255),yes,no,Age group name +age_group_def,min_age,int,no,no,Minimum age +age_group_def,max_age,int,no,no,Maximum age +subgroup_def,ref_id,int,yes,yes,The reference identifier for the analysis +subgroup_def,subgroup_id,bigint,no,yes,The subgroup identifier +subgroup_def,subgroup_name,varchar(255),no,no,The subgroup name +target_outcome_ref,ref_id,int,yes,yes,The reference identifier for the analysis +target_outcome_ref,target_cohort_id,bigint,yes,yes,The target cohort identifier +target_outcome_ref,outcome_cohort_id,bigint,yes,yes,The outcome cohort identifier diff --git a/man/CharacterizationModule.Rd b/man/CharacterizationModule.Rd index 9220b6c7..dadf9ce9 100644 --- a/man/CharacterizationModule.Rd +++ b/man/CharacterizationModule.Rd @@ -23,6 +23,7 @@ package version 2.0.1 \item \href{#method-CharacterizationModule-new}{\code{CharacterizationModule$new()}} \item \href{#method-CharacterizationModule-execute}{\code{CharacterizationModule$execute()}} \item \href{#method-CharacterizationModule-createResultsDataModel}{\code{CharacterizationModule$createResultsDataModel()}} +\item \href{#method-CharacterizationModule-getResultsDataModelSpecification}{\code{CharacterizationModule$getResultsDataModelSpecification()}} \item \href{#method-CharacterizationModule-uploadResults}{\code{CharacterizationModule$uploadResults()}} \item \href{#method-CharacterizationModule-createModuleSpecifications}{\code{CharacterizationModule$createModuleSpecifications()}} \item \href{#method-CharacterizationModule-clone}{\code{CharacterizationModule$clone()}} @@ -104,6 +105,27 @@ is an object of class \code{connectionDetails} as created by the \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-CharacterizationModule-getResultsDataModelSpecification}{}}} +\subsection{Method \code{getResultsDataModelSpecification()}}{ +Get the results data model specification for the module +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{CharacterizationModule$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{
}} diff --git a/man/CohortDiagnosticsModule.Rd b/man/CohortDiagnosticsModule.Rd index f629a784..1fd94e7c 100644 --- a/man/CohortDiagnosticsModule.Rd +++ b/man/CohortDiagnosticsModule.Rd @@ -23,6 +23,7 @@ against the OMOP Common Data Model. \item \href{#method-CohortDiagnosticsModule-new}{\code{CohortDiagnosticsModule$new()}} \item \href{#method-CohortDiagnosticsModule-execute}{\code{CohortDiagnosticsModule$execute()}} \item \href{#method-CohortDiagnosticsModule-createResultsDataModel}{\code{CohortDiagnosticsModule$createResultsDataModel()}} +\item \href{#method-CohortDiagnosticsModule-getResultsDataModelSpecification}{\code{CohortDiagnosticsModule$getResultsDataModelSpecification()}} \item \href{#method-CohortDiagnosticsModule-uploadResults}{\code{CohortDiagnosticsModule$uploadResults()}} \item \href{#method-CohortDiagnosticsModule-createModuleSpecifications}{\code{CohortDiagnosticsModule$createModuleSpecifications()}} \item \href{#method-CohortDiagnosticsModule-validateModuleSpecifications}{\code{CohortDiagnosticsModule$validateModuleSpecifications()}} @@ -104,6 +105,27 @@ is an object of class \code{connectionDetails} as created by the \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-CohortDiagnosticsModule-getResultsDataModelSpecification}{}}} +\subsection{Method \code{getResultsDataModelSpecification()}}{ +Get the results data model specification for the module +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{CohortDiagnosticsModule$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{
}} diff --git a/man/CohortGeneratorModule.Rd b/man/CohortGeneratorModule.Rd index 07e34d9e..e0bcfcf1 100644 --- a/man/CohortGeneratorModule.Rd +++ b/man/CohortGeneratorModule.Rd @@ -28,6 +28,7 @@ analysis specification} \item \href{#method-CohortGeneratorModule-new}{\code{CohortGeneratorModule$new()}} \item \href{#method-CohortGeneratorModule-execute}{\code{CohortGeneratorModule$execute()}} \item \href{#method-CohortGeneratorModule-createResultsDataModel}{\code{CohortGeneratorModule$createResultsDataModel()}} +\item \href{#method-CohortGeneratorModule-getResultsDataModelSpecification}{\code{CohortGeneratorModule$getResultsDataModelSpecification()}} \item \href{#method-CohortGeneratorModule-uploadResults}{\code{CohortGeneratorModule$uploadResults()}} \item \href{#method-CohortGeneratorModule-createModuleSpecifications}{\code{CohortGeneratorModule$createModuleSpecifications()}} \item \href{#method-CohortGeneratorModule-createCohortSharedResourceSpecifications}{\code{CohortGeneratorModule$createCohortSharedResourceSpecifications()}} @@ -113,6 +114,27 @@ is an object of class \code{connectionDetails} as created by the \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-CohortGeneratorModule-getResultsDataModelSpecification}{}}} +\subsection{Method \code{getResultsDataModelSpecification()}}{ +Get the results data model specification for the module +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{CohortGeneratorModule$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{
}} diff --git a/man/CohortIncidenceModule.Rd b/man/CohortIncidenceModule.Rd index fc702867..e1b88bf1 100644 --- a/man/CohortIncidenceModule.Rd +++ b/man/CohortIncidenceModule.Rd @@ -22,6 +22,7 @@ Computes incidence rates for cohorts against the OMOP CDM \item \href{#method-CohortIncidenceModule-new}{\code{CohortIncidenceModule$new()}} \item \href{#method-CohortIncidenceModule-execute}{\code{CohortIncidenceModule$execute()}} \item \href{#method-CohortIncidenceModule-createResultsDataModel}{\code{CohortIncidenceModule$createResultsDataModel()}} +\item \href{#method-CohortIncidenceModule-getResultsDataModelSpecification}{\code{CohortIncidenceModule$getResultsDataModelSpecification()}} \item \href{#method-CohortIncidenceModule-uploadResults}{\code{CohortIncidenceModule$uploadResults()}} \item \href{#method-CohortIncidenceModule-createModuleSpecifications}{\code{CohortIncidenceModule$createModuleSpecifications()}} \item \href{#method-CohortIncidenceModule-validateModuleSpecifications}{\code{CohortIncidenceModule$validateModuleSpecifications()}} @@ -103,6 +104,27 @@ is an object of class \code{connectionDetails} as created by the \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-CohortIncidenceModule-getResultsDataModelSpecification}{}}} +\subsection{Method \code{getResultsDataModelSpecification()}}{ +Get the results data model specification for the module +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{CohortIncidenceModule$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{
}} diff --git a/man/CohortMethodModule.Rd b/man/CohortMethodModule.Rd index 80f98c1c..a3f8752c 100644 --- a/man/CohortMethodModule.Rd +++ b/man/CohortMethodModule.Rd @@ -16,6 +16,7 @@ database in the OMOP Common Data Model. \item \href{#method-CohortMethodModule-new}{\code{CohortMethodModule$new()}} \item \href{#method-CohortMethodModule-execute}{\code{CohortMethodModule$execute()}} \item \href{#method-CohortMethodModule-createResultsDataModel}{\code{CohortMethodModule$createResultsDataModel()}} +\item \href{#method-CohortMethodModule-getResultsDataModelSpecification}{\code{CohortMethodModule$getResultsDataModelSpecification()}} \item \href{#method-CohortMethodModule-uploadResults}{\code{CohortMethodModule$uploadResults()}} \item \href{#method-CohortMethodModule-createModuleSpecifications}{\code{CohortMethodModule$createModuleSpecifications()}} \item \href{#method-CohortMethodModule-validateModuleSpecifications}{\code{CohortMethodModule$validateModuleSpecifications()}} @@ -93,6 +94,27 @@ is an object of class \code{connectionDetails} as created by the \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-CohortMethodModule-getResultsDataModelSpecification}{}}} +\subsection{Method \code{getResultsDataModelSpecification()}}{ +Get the results data model specification for the module +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{CohortMethodModule$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{
}} diff --git a/man/EvidenceSynthesisModule.Rd b/man/EvidenceSynthesisModule.Rd index 020c99e9..9d51658d 100644 --- a/man/EvidenceSynthesisModule.Rd +++ b/man/EvidenceSynthesisModule.Rd @@ -19,6 +19,7 @@ for performing meta-analysis and forest plots \item \href{#method-EvidenceSynthesisModule-new}{\code{EvidenceSynthesisModule$new()}} \item \href{#method-EvidenceSynthesisModule-execute}{\code{EvidenceSynthesisModule$execute()}} \item \href{#method-EvidenceSynthesisModule-createResultsDataModel}{\code{EvidenceSynthesisModule$createResultsDataModel()}} +\item \href{#method-EvidenceSynthesisModule-getResultsDataModelSpecification}{\code{EvidenceSynthesisModule$getResultsDataModelSpecification()}} \item \href{#method-EvidenceSynthesisModule-uploadResults}{\code{EvidenceSynthesisModule$uploadResults()}} \item \href{#method-EvidenceSynthesisModule-validateModuleSpecifications}{\code{EvidenceSynthesisModule$validateModuleSpecifications()}} \item \href{#method-EvidenceSynthesisModule-createEvidenceSynthesisSource}{\code{EvidenceSynthesisModule$createEvidenceSynthesisSource()}} @@ -105,6 +106,27 @@ is an object of class \code{connectionDetails} as created by the \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-EvidenceSynthesisModule-getResultsDataModelSpecification}{}}} +\subsection{Method \code{getResultsDataModelSpecification()}}{ +Get the results data model specification for the module +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{EvidenceSynthesisModule$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{
}} diff --git a/man/PatientLevelPredictionModule.Rd b/man/PatientLevelPredictionModule.Rd index 368256e1..35c43d3e 100644 --- a/man/PatientLevelPredictionModule.Rd +++ b/man/PatientLevelPredictionModule.Rd @@ -23,6 +23,7 @@ database in the OMOP Common Data Model. \item \href{#method-PatientLevelPredictionModule-new}{\code{PatientLevelPredictionModule$new()}} \item \href{#method-PatientLevelPredictionModule-execute}{\code{PatientLevelPredictionModule$execute()}} \item \href{#method-PatientLevelPredictionModule-createResultsDataModel}{\code{PatientLevelPredictionModule$createResultsDataModel()}} +\item \href{#method-PatientLevelPredictionModule-getResultsDataModelSpecification}{\code{PatientLevelPredictionModule$getResultsDataModelSpecification()}} \item \href{#method-PatientLevelPredictionModule-uploadResults}{\code{PatientLevelPredictionModule$uploadResults()}} \item \href{#method-PatientLevelPredictionModule-createModuleSpecifications}{\code{PatientLevelPredictionModule$createModuleSpecifications()}} \item \href{#method-PatientLevelPredictionModule-validateModuleSpecifications}{\code{PatientLevelPredictionModule$validateModuleSpecifications()}} @@ -104,6 +105,27 @@ is an object of class \code{connectionDetails} as created by the \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-PatientLevelPredictionModule-getResultsDataModelSpecification}{}}} +\subsection{Method \code{getResultsDataModelSpecification()}}{ +Get the results data model specification for the module +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{PatientLevelPredictionModule$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{
}} diff --git a/man/SelfControlledCaseSeriesModule.Rd b/man/SelfControlledCaseSeriesModule.Rd index 38795c4b..49d8ce72 100644 --- a/man/SelfControlledCaseSeriesModule.Rd +++ b/man/SelfControlledCaseSeriesModule.Rd @@ -24,6 +24,7 @@ in an observational database in the OMOP Common Data Model. \item \href{#method-SelfControlledCaseSeriesModule-new}{\code{SelfControlledCaseSeriesModule$new()}} \item \href{#method-SelfControlledCaseSeriesModule-execute}{\code{SelfControlledCaseSeriesModule$execute()}} \item \href{#method-SelfControlledCaseSeriesModule-createResultsDataModel}{\code{SelfControlledCaseSeriesModule$createResultsDataModel()}} +\item \href{#method-SelfControlledCaseSeriesModule-getResultsDataModelSpecification}{\code{SelfControlledCaseSeriesModule$getResultsDataModelSpecification()}} \item \href{#method-SelfControlledCaseSeriesModule-uploadResults}{\code{SelfControlledCaseSeriesModule$uploadResults()}} \item \href{#method-SelfControlledCaseSeriesModule-createModuleSpecifications}{\code{SelfControlledCaseSeriesModule$createModuleSpecifications()}} \item \href{#method-SelfControlledCaseSeriesModule-validateModuleSpecifications}{\code{SelfControlledCaseSeriesModule$validateModuleSpecifications()}} @@ -105,6 +106,29 @@ is an object of class \code{connectionDetails} as created by the \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-SelfControlledCaseSeriesModule-getResultsDataModelSpecification}{}}} +\subsection{Method \code{getResultsDataModelSpecification()}}{ +Get the results data model specification for the module +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{SelfControlledCaseSeriesModule$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{
}} diff --git a/man/StrategusModule.Rd b/man/StrategusModule.Rd index 4b819059..eda82f6d 100644 --- a/man/StrategusModule.Rd +++ b/man/StrategusModule.Rd @@ -32,6 +32,7 @@ specification.} \item \href{#method-StrategusModule-new}{\code{StrategusModule$new()}} \item \href{#method-StrategusModule-execute}{\code{StrategusModule$execute()}} \item \href{#method-StrategusModule-createResultsDataModel}{\code{StrategusModule$createResultsDataModel()}} +\item \href{#method-StrategusModule-getResultsDataModelSpecification}{\code{StrategusModule$getResultsDataModelSpecification()}} \item \href{#method-StrategusModule-uploadResults}{\code{StrategusModule$uploadResults()}} \item \href{#method-StrategusModule-createModuleSpecifications}{\code{StrategusModule$createModuleSpecifications()}} \item \href{#method-StrategusModule-createSharedResourcesSpecifications}{\code{StrategusModule$createSharedResourcesSpecifications()}} @@ -107,6 +108,27 @@ is an object of class \code{connectionDetails} as created by the \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-StrategusModule-getResultsDataModelSpecification}{}}} +\subsection{Method \code{getResultsDataModelSpecification()}}{ +Get the results data model specification for the module +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{StrategusModule$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{
}} diff --git a/tests/testthat/test-Modules.R b/tests/testthat/test-Modules.R new file mode 100644 index 00000000..c70782d4 --- /dev/null +++ b/tests/testthat/test-Modules.R @@ -0,0 +1,42 @@ +library(testthat) +library(Strategus) + +testResultsDataModelFormat <- function(moduleName) { + module <- get(moduleName)$new() + rdms <- module$getResultsDataModelSpecification() + expect_true(all(CohortGenerator::isSnakeCase(rdms$tableName))) + expect_true(all(CohortGenerator::isSnakeCase(rdms$columnName))) + +} + +test_that("CharacterizationModule results data model is in correct format", { + testResultsDataModelFormat("CharacterizationModule") +}) + +test_that("CohortDiagnosticsModule results data model is in correct format", { + testResultsDataModelFormat("CohortDiagnosticsModule") +}) + +test_that("CohortGeneratorModule results data model is in correct format", { + testResultsDataModelFormat("CohortGeneratorModule") +}) + +test_that("CohortIncidenceModule results data model is in correct format", { + testResultsDataModelFormat("CohortIncidenceModule") +}) + +test_that("CohortMethodModule results data model is in correct format", { + testResultsDataModelFormat("CohortMethodModule") +}) + +test_that("EvidenceSynthesisModule results data model is in correct format", { + testResultsDataModelFormat("EvidenceSynthesisModule") +}) + +test_that("PatientLevelPredictionModule results data model is in correct format", { + testResultsDataModelFormat("PatientLevelPredictionModule") +}) + +test_that("SelfControlledCaseSeriesModule results data model is in correct format", { + testResultsDataModelFormat("SelfControlledCaseSeriesModule") +})