Skip to content

Commit

Permalink
fixing namespacing in phevaluator.main server, updating code to creat…
Browse files Browse the repository at this point in the history
…e PV data, updating PV data per new spec
  • Loading branch information
nhall6 committed Jun 29, 2023
1 parent 95be4fe commit 2a72ff8
Show file tree
Hide file tree
Showing 3 changed files with 162 additions and 162 deletions.
20 changes: 10 additions & 10 deletions R/phevaluator-main.R
Original file line number Diff line number Diff line change
Expand Up @@ -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-")
Expand Down
304 changes: 152 additions & 152 deletions extras/codeToCreatePhevaluatorDatabase.R
Original file line number Diff line number Diff line change
@@ -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)



Expand All @@ -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
)







Expand Down
Binary file modified tests/resources/pvDatabase/phevaluator.sqlite
Binary file not shown.

0 comments on commit 2a72ff8

Please sign in to comment.