R/app_server.R

Defines functions app_server

#' @import shiny
app_server <- function(input, output, session) {
  # All indices in the ES server
  
  rv <- reactiveValues()
  rv$allIndices <- elastic::index_stats(esConn, index = NULL, metric = c("docs", "store"))$indices
  
  # List the first level callModules here
  indexSelected <- callModule(mod_index_chooser_server, "index_chooser_ui_1", rv$allIndices, "medical_notes")
  
  
  observe(print(indexSelected()))
  
}

# Values for Elasticsearch connection
esUser <- Sys.getenv("ELASTICSEARCH_USER")
esPassword <- Sys.getenv("ELASTICSEARCH_PASSWORD")
esHost <- ifelse(Sys.getenv("ELASTICSEARCH_HOST") == "", "localhost", Sys.getenv("ELASTICSEARCH_HOST"))
esPort <- ifelse(Sys.getenv("ELASTICSEARCH_PORT") == "", 8080, Sys.getenv("ELASTICSEARCH_PORT"))
esDefaultIndex <- ifelse(Sys.getenv("ELASTICSEARCH_INDEX") == "", "medical_notes_2020", Sys.getenv("ELASTICSEARCH_INDEX"))

if (esUser == "") {
  esConn <- elastic::connect(host = esHost,
                             port = esPort,
                             transport_schema = "http") 
} else {
  esConn <- elastic::connect(host = esHost,
                             port = esPort,
                             transport_schema = "http",
                             user = esUser,
                             pwd = esPassword)  
}
dkincaid/MedicalNotesApp documentation built on Feb. 13, 2020, 1:31 a.m.