diff --git a/R/phevaluator-main.R b/R/phevaluator-main.R index 8b04d7e2..487fe0f0 100644 --- a/R/phevaluator-main.R +++ b/R/phevaluator-main.R @@ -445,47 +445,47 @@ phevaluatorServer <- function( customColDefs <- utils::modifyList(phevalColList, buttonColDefs) - resultTableServer(id = ns("algorithmPerformanceResultsTable"), - df = dataAlgorithmPerformance, + resultTableServer(id = "algorithmPerformanceResultsTable", + df = dataAlgorithmPerformance(), colDefsInput = customColDefs, downloadedFileName = "algorithmPerformanceResultsTable-") - resultTableServer(id = ns("cohortDefinitionSetTable"), + resultTableServer(id = "cohortDefinitionSetTable", df = dataCohortDefinitionSet, colDefsInput = customColDefs, downloadedFileName = "cohortDefinitionSetTable-") - resultTableServer(id = ns("diagnosticsTable"), + resultTableServer(id = "diagnosticsTable", df = dataDiagnostics, colDefsInput = customColDefs, downloadedFileName = "diagnosticsTable-") - resultTableServer(id = ns("evaluationInputParametersTable"), + resultTableServer(id = "evaluationInputParametersTable", df = dataEvalInputParams, colDefsInput = customColDefs, downloadedFileName = "evaluationInputParametersTable-") - resultTableServer(id = ns("modelCovariatesTable"), + resultTableServer(id = "modelCovariatesTable", df = dataModelCovars, colDefsInput = customColDefs, downloadedFileName = "modelCovariatesTable-") - resultTableServer(id = ns("modelInputParametersTable"), + resultTableServer(id = "modelInputParametersTable", df = dataModelInputParams, colDefsInput = customColDefs, downloadedFileName = "modelInputParametersTable-") - resultTableServer(id = ns("modelPerformanceTable"), + resultTableServer(id = "modelPerformanceTable", df = dataModelPerformance, colDefsInput = customColDefs, downloadedFileName = "modelPerformanceTable-") - resultTableServer(id = ns("testSubjectsTable"), + resultTableServer(id = "testSubjectsTable", df = dataTestSubjects, colDefsInput = customColDefs, downloadedFileName = "testSubjectsTable-") - resultTableServer(id = ns("testSubjectsCovariatesTable"), + resultTableServer(id = "testSubjectsCovariatesTable", df = dataTestSubjectsCovars, colDefsInput = customColDefs, downloadedFileName = "testSubjectsCovariatesTable-") diff --git a/extras/codeToCreatePhevaluatorDatabase.R b/extras/codeToCreatePhevaluatorDatabase.R index 42017756..befa7c47 100644 --- a/extras/codeToCreatePhevaluatorDatabase.R +++ b/extras/codeToCreatePhevaluatorDatabase.R @@ -1,48 +1,48 @@ -# #load specification -# -# mypath <- "D:/shiny/resultModelSpecs" -# serverPV <- "tests/resources/pvDatabase/phevaluator.sqlite" -# -# #delete entire database -# unlink(serverPV) -# -# #load tje results data model spec -# specification <- ResultModelManager::loadResultsDataModelSpecifications(file.path(mypath, -# "resultsDataModelSpecificationReordered.csv") -# ) -# -# #create sql to generate schema -# sql <- ResultModelManager::generateSqlSchema(schemaDefinition = specification) -# -# #create the schema -# connectionDetails <- DatabaseConnector::createConnectionDetails(dbms = "sqlite", -# server = serverPV) -# -# -# # #need to re run the below qns when re-making the database -# qns <- ResultModelManager::createQueryNamespace(connectionDetails = connectionDetails, -# tableSpecification = specification, -# tablePrefix = "", -# database_schema = "main") -# #execute the SQL -# qns$executeSql(sql) -# -# -# #upload the results to the schema -# ResultModelManager::uploadResults(connectionDetails = connectionDetails, -# schema = "main", -# resultsFolder = file.path(mypath, "results"), -# tablePrefix = "", -# specifications = specification, -# purgeSiteDataBeforeUploading = F) -# -# #DBI::dbConnect(RSQLite::SQLite(), dbname = "phevaluator.sqlite") -# -# #create connection to DB -# connection <- DatabaseConnector::connect(connectionDetails = connectionDetails) -# -# #disconnect -# DatabaseConnector::disconnect(connection) +#load specification + + mypath <- "D:/shiny/resultModelSpecs" + serverPV <- "tests/resources/pvDatabase/phevaluator.sqlite" + + #delete entire database + unlink(serverPV) + + #load tje results data model spec + specification <- ResultModelManager::loadResultsDataModelSpecifications(file.path(mypath, + "resultsDataModelSpecificationReordered.csv") + ) + + #create sql to generate schema + sql <- ResultModelManager::generateSqlSchema(schemaDefinition = specification) + + #create the schema + connectionDetails <- DatabaseConnector::createConnectionDetails(dbms = "sqlite", + server = serverPV) + + + # #need to re run the below qns when re-making the database + qns <- ResultModelManager::createQueryNamespace(connectionDetails = connectionDetails, + tableSpecification = specification, + tablePrefix = "", + database_schema = "main") + #execute the SQL + qns$executeSql(sql) + + + #upload the results to the schema + ResultModelManager::uploadResults(connectionDetails = connectionDetails, + schema = "main", + resultsFolder = file.path(mypath, "results"), + tablePrefix = "", + specifications = specification, + purgeSiteDataBeforeUploading = F) + +#DBI::dbConnect(RSQLite::SQLite(), dbname = "phevaluator.sqlite") + +#create connection to DB +connection <- DatabaseConnector::connect(connectionDetails = connectionDetails) + +#disconnect +DatabaseConnector::disconnect(connection) @@ -52,114 +52,114 @@ # code to manually create test data -resultsPV <- "D:/shiny/resultModelSpecs/results" -serverPV <- "tests/resources/pvDatabase/phevaluator.sqlite" -connectionDetailsPV <- DatabaseConnector::createConnectionDetails( - dbms = 'sqlite', - server = serverPV -) -connectionPV <- DatabaseConnector::connect( - connectionDetails = connectionDetailsPV, - dbms = 'sqlite', - user = NULL, - password = NULL, - server = serverPV, - port = NULL -) +# resultsPV <- "D:/shiny/resultModelSpecs/results" +# serverPV <- "tests/resources/pvDatabase/phevaluator.sqlite" +# connectionDetailsPV <- DatabaseConnector::createConnectionDetails( +# dbms = 'sqlite', +# server = serverPV +# ) +# connectionPV <- DatabaseConnector::connect( +# connectionDetails = connectionDetailsPV, +# dbms = 'sqlite', +# user = NULL, +# password = NULL, +# server = serverPV, +# port = NULL +# ) +# # +# DatabaseConnector::insertTable( +# connection = connectionPV, +# databaseSchema = 'main', +# tableName = 'PV_ALGORITHM_PERFORMANCE_RESULTS', +# data = read.csv(file.path(resultsPV, "pv_algorithm_performance_results.csv")), +# createTable = T, dropTableIfExists = T, +# camelCaseToSnakeCase = F +# ) +# +# DatabaseConnector::insertTable( +# connection = connectionPV, +# databaseSchema = 'main', +# tableName = 'PV_COHORT_DEFINITION_SET', +# data = read.csv(file.path(resultsPV, "pv_cohort_definition_set.csv")), +# createTable = T, dropTableIfExists = T, +# camelCaseToSnakeCase = F +# ) +# +# DatabaseConnector::insertTable( +# connection = connectionPV, +# databaseSchema = 'main', +# tableName = 'PV_DIAGNOSTICS', +# data = read.csv(file.path(resultsPV, "pv_diagnostics.csv")), +# createTable = T, dropTableIfExists = T, +# camelCaseToSnakeCase = F +# ) +# +# DatabaseConnector::insertTable( +# connection = connectionPV, +# databaseSchema = 'main', +# tableName = 'PV_EVALUATION_INPUT_PARAMETERS', +# data = read.csv(file.path(resultsPV, "pv_evaluation_input_parameters.csv")), +# createTable = T, dropTableIfExists = T, +# camelCaseToSnakeCase = F +# ) +# +# DatabaseConnector::insertTable( +# connection = connectionPV, +# databaseSchema = 'main', +# tableName = 'PV_MODEL_COVARIATES', +# data = read.csv(file.path(resultsPV, "pv_model_covariates.csv")), +# createTable = T, dropTableIfExists = T, +# camelCaseToSnakeCase = F +# ) +# +# DatabaseConnector::insertTable( +# connection = connectionPV, +# databaseSchema = 'main', +# tableName = 'PV_MODEL_INPUT_PARAMETERS', +# data = read.csv(file.path(resultsPV, "pv_model_input_parameters.csv")), +# createTable = T, dropTableIfExists = T, +# camelCaseToSnakeCase = F +# ) +# +# DatabaseConnector::insertTable( +# connection = connectionPV, +# databaseSchema = 'main', +# tableName = 'PV_MODEL_PERFORMANCE', +# data = read.csv(file.path(resultsPV, "pv_model_performance.csv")), +# createTable = T, dropTableIfExists = T, +# camelCaseToSnakeCase = F +# ) +# +# DatabaseConnector::insertTable( +# connection = connectionPV, +# databaseSchema = 'main', +# tableName = 'PV_MODEL_RUN_TIME_VALUES', +# data = read.csv(file.path(resultsPV, "pv_model_run_time_values.csv")), +# createTable = T, dropTableIfExists = T, +# camelCaseToSnakeCase = F +# ) +# +# DatabaseConnector::insertTable( +# connection = connectionPV, +# databaseSchema = 'main', +# tableName = 'PV_TEST_SUBJECTS', +# data = read.csv(file.path(resultsPV, "pv_test_subjects.csv")), +# createTable = T, dropTableIfExists = T, +# camelCaseToSnakeCase = F +# ) +# +# DatabaseConnector::insertTable( +# connection = connectionPV, +# databaseSchema = 'main', +# tableName = 'PV_TEST_SUBJECTS_COVARIATES', +# data = read.csv(file.path(resultsPV, "pv_test_subjects_covariates.csv")), +# createTable = T, dropTableIfExists = T, +# camelCaseToSnakeCase = F +# ) +# +# +# # -DatabaseConnector::insertTable( - connection = connectionPV, - databaseSchema = 'main', - tableName = 'PV_ALGORITHM_PERFORMANCE_RESULTS', - data = read.csv(file.path(resultsPV, "pv_algorithm_performance_results.csv")), - createTable = T, dropTableIfExists = T, - camelCaseToSnakeCase = F -) - -DatabaseConnector::insertTable( - connection = connectionPV, - databaseSchema = 'main', - tableName = 'PV_COHORT_DEFINITION_SET', - data = read.csv(file.path(resultsPV, "pv_cohort_definition_set.csv")), - createTable = T, dropTableIfExists = T, - camelCaseToSnakeCase = F -) - -DatabaseConnector::insertTable( - connection = connectionPV, - databaseSchema = 'main', - tableName = 'PV_DIAGNOSTICS', - data = read.csv(file.path(resultsPV, "pv_diagnostics.csv")), - createTable = T, dropTableIfExists = T, - camelCaseToSnakeCase = F -) - -DatabaseConnector::insertTable( - connection = connectionPV, - databaseSchema = 'main', - tableName = 'PV_EVALUATION_INPUT_PARAMETERS', - data = read.csv(file.path(resultsPV, "pv_evaluation_input_parameters.csv")), - createTable = T, dropTableIfExists = T, - camelCaseToSnakeCase = F -) - -DatabaseConnector::insertTable( - connection = connectionPV, - databaseSchema = 'main', - tableName = 'PV_MODEL_COVARIATES', - data = read.csv(file.path(resultsPV, "pv_model_covariates.csv")), - createTable = T, dropTableIfExists = T, - camelCaseToSnakeCase = F -) - -DatabaseConnector::insertTable( - connection = connectionPV, - databaseSchema = 'main', - tableName = 'PV_MODEL_INPUT_PARAMETERS', - data = read.csv(file.path(resultsPV, "pv_model_input_parameters.csv")), - createTable = T, dropTableIfExists = T, - camelCaseToSnakeCase = F -) - -DatabaseConnector::insertTable( - connection = connectionPV, - databaseSchema = 'main', - tableName = 'PV_MODEL_PERFORMANCE', - data = read.csv(file.path(resultsPV, "pv_model_performance.csv")), - createTable = T, dropTableIfExists = T, - camelCaseToSnakeCase = F -) - -DatabaseConnector::insertTable( - connection = connectionPV, - databaseSchema = 'main', - tableName = 'PV_MODEL_RUN_TIME_VALUES', - data = read.csv(file.path(resultsPV, "pv_model_run_time_values.csv")), - createTable = T, dropTableIfExists = T, - camelCaseToSnakeCase = F -) - -DatabaseConnector::insertTable( - connection = connectionPV, - databaseSchema = 'main', - tableName = 'PV_TEST_SUBJECTS', - data = read.csv(file.path(resultsPV, "pv_test_subjects.csv")), - createTable = T, dropTableIfExists = T, - camelCaseToSnakeCase = F -) - -DatabaseConnector::insertTable( - connection = connectionPV, - databaseSchema = 'main', - tableName = 'PV_TEST_SUBJECTS_COVARIATES', - data = read.csv(file.path(resultsPV, "pv_test_subjects_covariates.csv")), - createTable = T, dropTableIfExists = T, - camelCaseToSnakeCase = F -) - - - - diff --git a/tests/resources/pvDatabase/phevaluator.sqlite b/tests/resources/pvDatabase/phevaluator.sqlite index d4f4b6ae..4e4bc47a 100644 Binary files a/tests/resources/pvDatabase/phevaluator.sqlite and b/tests/resources/pvDatabase/phevaluator.sqlite differ