From 1899063428992fdfd4fc1057c115183e630f1cd4 Mon Sep 17 00:00:00 2001 From: m7pr Date: Wed, 27 Nov 2024 10:49:24 +0100 Subject: [PATCH] revert changes for vitals --- R/tm_g_pp_vitals.R | 71 ++++++++++++++-------------------------------- 1 file changed, 22 insertions(+), 49 deletions(-) diff --git a/R/tm_g_pp_vitals.R b/R/tm_g_pp_vitals.R index 84ed2e0d2..c19df3344 100644 --- a/R/tm_g_pp_vitals.R +++ b/R/tm_g_pp_vitals.R @@ -123,7 +123,7 @@ template_vitals <- function(dataname = "ANL", color = paramcd_levels_e ) - plot <- ggplot2::ggplot(data = vitals, mapping = ggplot2::aes(x = xaxis)) + # replaced VSDY + result_plot <- ggplot2::ggplot(data = vitals, mapping = ggplot2::aes(x = xaxis)) + # replaced VSDY ggplot2::geom_line( data = vitals, mapping = ggplot2::aes(y = aval_var, color = paramcd), @@ -172,6 +172,8 @@ template_vitals <- function(dataname = "ANL", labs + ggthemes + themes + + print(result_plot) }, env = list( dataname = as.name(dataname), @@ -209,16 +211,6 @@ template_vitals <- function(dataname = "ANL", #' #' @inherit module_arguments return #' -#' -#' @section Decorating `tm_g_pp_vitals`: -#' -#' This module generates the following objects, which can be modified in place using decorators: -#' - `plot` (`ggplot2`) -#' -#' For additional details and examples of decorators, refer to the vignette -#' `vignette("decorate-modules-output", package = "teal")` or the [`teal_transform_module()`] documentation. -#' -#' #' @examplesShinylive #' library(teal.modules.clinical) #' interactive <- function() TRUE @@ -279,8 +271,7 @@ tm_g_pp_vitals <- function(label, plot_width = NULL, pre_output = NULL, post_output = NULL, - ggplot2_args = teal.widgets::ggplot2_args(), - decorators = NULL) { + ggplot2_args = teal.widgets::ggplot2_args()) { if (lifecycle::is_present(aval)) { aval_var <- aval warning( @@ -316,15 +307,6 @@ tm_g_pp_vitals <- function(label, checkmate::assert_multi_class(aval_var, c("choices_selected", "data_extract_spec"), null.ok = TRUE) checkmate::assert_multi_class(xaxis, c("choices_selected", "data_extract_spec"), null.ok = TRUE) - if (checkmate::test_list(decorators, "teal_transform_module", null.ok = TRUE)) { - decorators <- if (checkmate::test_names(names(decorators), subset.of = c("default", "plot"))) { - lapply(decorators, list) - } else { - list(default = decorators) - } - } - assert_decorators(decorators, null.ok = TRUE, names = c("default", "plot")) - args <- as.list(environment()) data_extract_list <- list( paramcd = `if`(is.null(paramcd), NULL, cs_to_des_select(paramcd, dataname = dataname)), @@ -346,8 +328,7 @@ tm_g_pp_vitals <- function(label, patient_col = patient_col, plot_height = plot_height, plot_width = plot_width, - ggplot2_args = ggplot2_args, - decorators = decorators + ggplot2_args = ggplot2_args ) ), datanames = c(dataname, parentname) @@ -397,7 +378,6 @@ ui_g_vitals <- function(id, ...) { data_extract_spec = ui_args$aval_var, is_single_dataset = is_single_dataset_value ), - ui_decorate_teal_data(ns("decorator"), decorators = subset_decorators("plot", ui_args$decorators)), teal.widgets::panel_item( title = "Plot settings", collapsed = TRUE, @@ -429,8 +409,7 @@ srv_g_vitals <- function(id, plot_height, plot_width, label, - ggplot2_args, - decorators) { + ggplot2_args) { with_reporter <- !missing(reporter) && inherits(reporter, "Reporter") with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI") checkmate::assert_class(data, "reactive") @@ -450,19 +429,19 @@ srv_g_vitals <- function(id, ) observeEvent(patient_data_base(), - handlerExpr = { - teal.widgets::updateOptionalSelectInput( - session, - "patient_id", - choices = patient_data_base(), - selected = if (length(patient_data_base()) == 1) { - patient_data_base() - } else { - intersect(patient_id(), patient_data_base()) - } - ) - }, - ignoreInit = TRUE + handlerExpr = { + teal.widgets::updateOptionalSelectInput( + session, + "patient_id", + choices = patient_data_base(), + selected = if (length(patient_data_base()) == 1) { + patient_data_base() + } else { + intersect(patient_id(), patient_data_base()) + } + ) + }, + ignoreInit = TRUE ) # Vitals tab ---- @@ -574,13 +553,7 @@ srv_g_vitals <- function(id, teal.code::eval_code(as.expression(unlist(my_calls))) }) - decorated_all_q <- srv_decorate_teal_data( - id = "decorator", - data = all_q, - decorators = subset_decorators("plot", decorators), - expr = print(plot) - ) - plot_r <- reactive(decorated_all_q()[["plot"]]) + plot_r <- reactive(all_q()[["result_plot"]]) pws <- teal.widgets::plot_with_settings_srv( id = "vitals_plot", @@ -591,7 +564,7 @@ srv_g_vitals <- function(id, teal.widgets::verbatim_popup_srv( id = "rcode", - verbatim_content = reactive(teal.code::get_code(req(decorated_all_q()))), + verbatim_content = reactive(teal.code::get_code(all_q())), title = label ) @@ -610,7 +583,7 @@ srv_g_vitals <- function(id, card$append_text("Comment", "header3") card$append_text(comment) } - card$append_src(teal.code::get_code(req(decorated_all_q()))) + card$append_src(teal.code::get_code(all_q())) card } teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun)