Skip to content

Commit

Permalink
revert changes for vitals
Browse files Browse the repository at this point in the history
  • Loading branch information
m7pr committed Nov 27, 2024
1 parent 93c6af5 commit 1899063
Showing 1 changed file with 22 additions and 49 deletions.
71 changes: 22 additions & 49 deletions R/tm_g_pp_vitals.R
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -172,6 +172,8 @@ template_vitals <- function(dataname = "ANL",
labs +
ggthemes +
themes

print(result_plot)
},
env = list(
dataname = as.name(dataname),
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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)),
Expand All @@ -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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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")
Expand All @@ -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 = {

Check warning on line 432 in R/tm_g_pp_vitals.R

View workflow job for this annotation

GitHub Actions / SuperLinter 🦸‍♀️ / Lint R code 🧶

file=R/tm_g_pp_vitals.R,line=432,col=17,[indentation_linter] Indentation should be 6 spaces but is 17 spaces.
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 ----
Expand Down Expand Up @@ -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",
Expand All @@ -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
)

Expand All @@ -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)
Expand Down

0 comments on commit 1899063

Please sign in to comment.