-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updating phevaluator module and adding datasources module skeleton
- Loading branch information
Showing
7 changed files
with
237 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
# @file datasources-main.R | ||
# | ||
# Copyright 2022 Observational Health Data Sciences and Informatics | ||
# | ||
# This file is part of OhdsiShinyModules | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
|
||
|
||
#' The location of the datasources module helper file | ||
#' | ||
#' @details Returns the location of the datasources helper file | ||
#' | ||
#' @return String location of the datasources helper file | ||
#' | ||
#' @export | ||
#' | ||
datasourcesHelperFile <- function() { | ||
fileLoc <- | ||
system.file('datasources-www', "datasources.html", package = "OhdsiShinyModules") | ||
return(fileLoc) | ||
} | ||
|
||
|
||
#' The viewer of the datasources module | ||
#' | ||
#' @param id The unique reference id for the module | ||
#' | ||
#' @return The user interface to the datasources results viewer | ||
#' | ||
#' @export | ||
#' | ||
datasourcesViewer <- function(id) { | ||
ns <- shiny::NS(id) | ||
|
||
shinydashboard::box( | ||
status = 'info', | ||
width = "100%", | ||
title = shiny::span(shiny::icon("database"), "Data Sources"), | ||
solidHeader = TRUE, | ||
|
||
shinydashboard::box( | ||
collapsible = TRUE, | ||
collapsed = FALSE, | ||
title = shiny::span( shiny::icon("circle-question"), "Help & Information"), | ||
width = "100%", | ||
shiny::htmlTemplate(system.file("datasources-www", "datasources.html", package = utils::packageName())) | ||
), | ||
|
||
shiny::tabsetPanel( | ||
type = 'pills', | ||
id = ns('mainPanel'), | ||
|
||
shiny::tabPanel( | ||
title = "Data Source Information", | ||
resultTableViewer(ns("datasourcesTable")) | ||
) | ||
) | ||
) | ||
} | ||
|
||
|
||
#' The module server for the main datasources module | ||
#' | ||
#' @param id The unique reference id for the module | ||
#' @param connectionHandler A connection to the database with the results | ||
#' @param resultDatabaseSettings A named list containing the datasources results database details (schema, table prefix) | ||
#' | ||
#' @return The datasourcesmain module server | ||
#' | ||
#' @export | ||
#' | ||
|
||
phevaluatorServer <- function( | ||
id, | ||
connectionHandler, | ||
resultDatabaseSettings | ||
) { | ||
|
||
shiny::moduleServer( | ||
id, | ||
function(input, output, session) { | ||
|
||
withTooltip <- function(value, tooltip, ...) { | ||
shiny::div(style = "text-decoration: underline; text-decoration-style: dotted; cursor: help", | ||
tippy::tippy(value, tooltip, ...)) | ||
} | ||
|
||
|
||
dataTestSubjectsCovars <- getPhevalTestSubjectsCovars( | ||
connectionHandler = connectionHandler, | ||
resultsSchema = resultDatabaseSettings$schema, | ||
tablePrefix = resultDatabaseSettings$tablePrefix, | ||
databaseIds = input$selectedDatabaseIds, | ||
phenotypes = input$selectedPhenoypes | ||
) | ||
|
||
#read in custom column name colDef list from rds file, generated by | ||
#heplers-componentsCreateCustomColDefList.R | ||
|
||
phevalColList <- ParallelLogger::loadSettingsFromJson(system.file("components-columnInformation", | ||
"phevaluator-colDefs.json", | ||
package = "OhdsiShinyModules") | ||
) | ||
|
||
#define custom colDefs for SQL and JSON buttons | ||
buttonColDefs <- list( | ||
buttonSQL = reactable::colDef(header = withTooltip("SQL", "Downloads SQL code for the cohort"), | ||
html = T | ||
), | ||
buttonJSON = reactable::colDef(header = withTooltip("JSON", "Downloads JSON code for the cohort"), | ||
html = T | ||
), | ||
sql = reactable::colDef(show = F), | ||
json = reactable::colDef(show = F) | ||
) | ||
|
||
#define custom column definitions and render the result table | ||
customColDefs <- modifyList(phevalColList, buttonColDefs) | ||
|
||
|
||
resultTableServer(id = "algorithmPerformanceResultsTable", | ||
df = dataAlgorithmPerformance, | ||
colDefsInput = customColDefs) | ||
|
||
return(invisible(NULL)) | ||
|
||
|
||
|
||
|
||
}) | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.