forked from OHDSI/ShinyDeploy
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathglobal.R
32 lines (28 loc) · 1.61 KB
/
global.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
library(DatabaseConnector)
source("DataPulls.R")
source("PlotsAndTables.R")
# connectionDetails <- createConnectionDetails(dbms = 'postgresql', server = 'localhost/ohdsi', user
# = 'postgres', password = Sys.getenv('pwPostgres'), schema = 'legend')
connectionDetails <- createConnectionDetails(dbms = "postgresql",
server = paste(Sys.getenv("shinydbServer"),
Sys.getenv("shinydbDatabase"),
sep = "/"),
port = Sys.getenv("shinydbPort"),
user = Sys.getenv("shinydbUser"),
password = Sys.getenv("shinydbPw"))
connection <- connect(connectionDetails)
renderTranslateExecuteSql(connection, "USE @schema;", schema = Sys.getenv("shinydbSchema"))
indications <- getIndications(connection)
exposures <- getExposures(connection)
exposures$exposureGroup[exposures$exposureGroup == "Drug" | exposures$exposureGroup == "Procedure"] <- "Drug or procedure"
exposureGroups <- unique(exposures[, c("indicationId", "exposureGroup")])
outcomes <- getOutcomes(connection)
databases <- getDatabases(connection)
databases <- databases[!databases$isMetaAnalysis, ]
# Sort for display:
indications <- indications[order(indications$indicationId), ]
exposures <- exposures[order(exposures$exposureName), ]
outcomes <- outcomes[order(outcomes$outcomeName), ]
databases <- databases[order(databases$databaseId), ]
writeLines("Closing connection")
disconnect(connection)