rm(list=ls())

setwd("C:/Users/victor/Desktop/TFG/r-analytics-master")

source("required_folder_checker.R")
source("argument_hasher.R")
source("dependency_installer.R")
source("connection_parameters.R")
source("necessary_function_table1s.R")

dep_list = c("jsonlite", "stringr","DSI","DSOpal","DSLite", "fields", "metafor", "ggplot2", "gridExtra", "data.table", "dsBaseClient")
install_dependencies(dep_list)


dir.create("./demographic_analisis", showWarnings = FALSE)
setwd("./demographic_analisis")


aux <- connect()
connections <- aux[[1]]
inp <- aux[[2]]

hasOutput  <- checkHasOutput(inp)

name <- getHname(inp)

png(paste(name,".png",sep=""),width=800, height=400)

res <- obtainData(connections, hasOutput, inp)

print(res)
dev.off()

datashield.logout(connections) 

res


