generated from ohdsi-studies/StudyRepoTemplate
-
Notifications
You must be signed in to change notification settings - Fork 3
/
CreateResultsDataModel.R
40 lines (35 loc) · 1.67 KB
/
CreateResultsDataModel.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
################################################################################
# INSTRUCTIONS: The code below assumes you have access to a PostgreSQL database
# and permissions to create tables in an existing schema specified by the
# resultsDatabaseSchema parameter.
#
# See the Working with results section
# of the UsingThisTemplate.md for more details.
#
# More information about working with results produced by running Strategus
# is found at:
# https://ohdsi.github.io/Strategus/articles/WorkingWithResults.html
# ##############################################################################
# Code for creating the result schema and tables in a PostgreSQL database
resultsDatabaseSchema <- "results"
analysisSpecifications <- ParallelLogger::loadSettingsFromJson(
fileName = "inst/sampleStudy/sampleStudyAnalysisSpecification.json"
)
resultsDatabaseConnectionDetails <- DatabaseConnector::createConnectionDetails(
dbms = "postgresql",
server = Sys.getenv("OHDSI_RESULTS_DATABASE_SERVER"),
user = Sys.getenv("OHDSI_RESULTS_DATABASE_USER"),
password = Sys.getenv("OHDSI_RESULTS_DATABASE_PASSWORD")
)
# Create results data model -------------------------
# Use the 1st results folder to define the results data model
resultsFolder <- list.dirs(path = "results", full.names = T, recursive = F)[1]
resultsDataModelSettings <- Strategus::createResultsDataModelSettings(
resultsDatabaseSchema = resultsDatabaseSchema,
resultsFolder = file.path(resultsFolder, "strategusOutput")
)
Strategus::createResultDataModel(
analysisSpecifications = analysisSpecifications,
resultsDataModelSettings = resultsDataModelSettings,
resultsConnectionDetails = resultsDatabaseConnectionDetails
)