diff --git a/R/tm_a_gee.R b/R/tm_a_gee.R index bf06745ee4..7f1bd2aca1 100644 --- a/R/tm_a_gee.R +++ b/R/tm_a_gee.R @@ -547,16 +547,15 @@ srv_gee <- function(id, title = label ) + ### REPORTER if (with_reporter) { card_fun <- function(comment, label) { - card <- teal::TealReportCard$new() - title <- "Generalized Estimating Equations (GEE) Analysis Table" - title <- ifelse(label == "", title, label) - card$set_name(title) - card$append_text(title, "header2") - if (with_filter) { - card$append_fs(filter_panel_api$get_filter_state()) - } + card <- card_template( + title = "Generalized Estimating Equations (GEE) Analysis Table", + label = label, + description = NULL, + with_filter = with_filter + ) table_type <- switch(input$output_table, "t_gee_cov" = "Residual Covariance Matrix Estimate", "t_gee_coef" = "Model Coefficients", diff --git a/R/tm_a_mmrm.R b/R/tm_a_mmrm.R index 0056a9eb9e..49aae7bb3d 100644 --- a/R/tm_a_mmrm.R +++ b/R/tm_a_mmrm.R @@ -1433,21 +1433,15 @@ srv_mmrm <- function(id, ### REPORTER if (with_reporter) { card_fun <- function(comment, label) { - card <- teal::TealReportCard$new() - title <- "Mixed Model Repeated Measurements (MMRM) Analysis" - title <- ifelse(label == "", title, label) - card$set_name(title) - card$append_text(title, "header2") - card$append_text( - paste( + card <- card_template( + title = "Mixed Model Repeated Measurements (MMRM) Analysis", + label = label, + description = paste( "Mixed Models procedure analyzes results from repeated measures designs", "in which the outcome is continuous and measured at fixed time points" ), - "header3" + with_filter = with_filter ) - if (with_filter) { - card$append_fs(filter_panel_api$get_filter_state()) - } if (!is.null(table_r())) { card$append_text("Table", "header3") card$append_table(table_r()) diff --git a/R/tm_g_barchart_simple.R b/R/tm_g_barchart_simple.R index 2aff61a1cd..ffa5e8ef74 100644 --- a/R/tm_g_barchart_simple.R +++ b/R/tm_g_barchart_simple.R @@ -539,14 +539,12 @@ srv_g_barchart_simple <- function(id, ### REPORTER if (with_reporter) { card_fun <- function(comment, label) { - card <- teal::TealReportCard$new() - title <- "Barchart Plot" - title <- ifelse(label == "", title, label) - card$set_name(title) - card$append_text(title, "header2") - if (with_filter) { - card$append_fs(filter_panel_api$get_filter_state()) - } + card <- card_template( + title = "Barchart Plot", + label = label, + description = NULL, + with_filter = with_filter + ) card$append_text("Plot", "header3") card$append_plot(plot_r(), dim = pws$dim()) if (!comment == "") { diff --git a/R/tm_g_ci.R b/R/tm_g_ci.R index 7a6bfdec81..e38d9a371f 100644 --- a/R/tm_g_ci.R +++ b/R/tm_g_ci.R @@ -484,15 +484,12 @@ srv_g_ci <- function(id, # nolint ### REPORTER if (with_reporter) { card_fun <- function(comment, label) { - card <- teal::TealReportCard$new() - title <- "CI Plot" - title <- ifelse(label == "", title, label) - card$set_name(title) - card$append_text(title, "header2") - card$append_text("Confidence Interval Plot", "header3") - if (with_filter) { - card$append_fs(filter_panel_api$get_filter_state()) - } + card <- card_template( + title = "CI Plot", + label = label, + description = "Confidence Interval Plot", + with_filter = with_filter + ) card$append_text("Plot", "header3") card$append_plot(plot_r(), dim = pws$dim()) if (!comment == "") { diff --git a/R/tm_g_forest_rsp.R b/R/tm_g_forest_rsp.R index 94d36b0049..75d0fbc46e 100644 --- a/R/tm_g_forest_rsp.R +++ b/R/tm_g_forest_rsp.R @@ -719,14 +719,12 @@ srv_g_forest_rsp <- function(id, ### REPORTER if (with_reporter) { card_fun <- function(comment, label) { - card <- teal::TealReportCard$new() - title <- "Forest Response Plot" - title <- ifelse(label == "", title, label) - card$set_name(title) - card$append_text(title, "header2") - if (with_filter) { - card$append_fs(filter_panel_api$get_filter_state()) - } + card <- card_template( + title = "Forest Response Plot", + label = label, + description = NULL, + with_filter = with_filter + ) card$append_text("Plot", "header3") card$append_plot(plot_r(), dim = pws$dim()) if (!comment == "") { diff --git a/R/tm_g_forest_tte.R b/R/tm_g_forest_tte.R index 0d2277639d..0ae63244bf 100644 --- a/R/tm_g_forest_tte.R +++ b/R/tm_g_forest_tte.R @@ -653,14 +653,12 @@ srv_g_forest_tte <- function(id, ### REPORTER if (with_reporter) { card_fun <- function(comment, label) { - card <- teal::TealReportCard$new() - title <- "Forest Survival Plot" - title <- ifelse(label == "", title, label) - card$set_name(title) - card$append_text(title, "header2") - if (with_filter) { - card$append_fs(filter_panel_api$get_filter_state()) - } + card <- card_template( + title = "Forest Survival Plot", + label = label, + description = NULL, + with_filter = with_filter + ) card$append_text("Plot", "header3") card$append_plot(plot_r(), dim = pws$dim()) if (!comment == "") { diff --git a/R/tm_g_ipp.R b/R/tm_g_ipp.R index 11e9f07ff4..c042f4072b 100644 --- a/R/tm_g_ipp.R +++ b/R/tm_g_ipp.R @@ -612,14 +612,12 @@ srv_g_ipp <- function(id, ### REPORTER if (with_reporter) { card_fun <- function(comment, label) { - card <- teal::TealReportCard$new() - title <- "Individual Patient Plot" - title <- ifelse(label == "", title, label) - card$set_name(title) - card$append_text(title, "header2") - if (with_filter) { - card$append_fs(filter_panel_api$get_filter_state()) - } + card <- card_template( + title = "Individual Patient Plot", + label = label, + description = NULL, + with_filter = with_filter + ) card$append_text("Plot", "header3") card$append_plot(plot_r(), dim = pws$dim()) if (!comment == "") { diff --git a/R/tm_g_km.R b/R/tm_g_km.R index c6e6d07fae..b6ca08dc17 100644 --- a/R/tm_g_km.R +++ b/R/tm_g_km.R @@ -774,15 +774,12 @@ srv_g_km <- function(id, ### REPORTER if (with_reporter) { card_fun <- function(comment, label) { - card <- teal::TealReportCard$new() - title <- "Kaplan Meier Plot" - title <- ifelse(label == "", title, label) - card$set_name(title) - card$append_text(title, "header2") - card$append_text("Non-parametric method used to estimate the survival function from lifetime data", "header3") - if (with_filter) { - card$append_fs(filter_panel_api$get_filter_state()) - } + card <- card_template( + title = "Kaplan Meier Plot", + label = label, + description = "Non-parametric method used to estimate the survival function from lifetime data", + with_filter = with_filter + ) card$append_text("Plot", "header3") card$append_plot(plot_r(), dim = pws$dim()) if (!comment == "") { diff --git a/R/tm_g_lineplot.R b/R/tm_g_lineplot.R index a8383bc932..c3145147b9 100644 --- a/R/tm_g_lineplot.R +++ b/R/tm_g_lineplot.R @@ -649,14 +649,12 @@ srv_g_lineplot <- function(id, ### REPORTER if (with_reporter) { card_fun <- function(comment, label) { - card <- teal::TealReportCard$new() - title <- "Line Plot" - title <- ifelse(label == "", title, label) - card$set_name(title) - card$append_text(title, "header2") - if (with_filter) { - card$append_fs(filter_panel_api$get_filter_state()) - } + card <- card_template( + title = "Line Plot", + label = label, + description = NULL, + with_filter = with_filter + ) card$append_text("Plot", "header3") card$append_plot(plot_r(), dim = pws$dim()) if (!comment == "") { diff --git a/R/tm_g_pp_adverse_events.R b/R/tm_g_pp_adverse_events.R index 8f717262f3..de15394ab2 100644 --- a/R/tm_g_pp_adverse_events.R +++ b/R/tm_g_pp_adverse_events.R @@ -559,14 +559,12 @@ srv_g_adverse_events <- function(id, ### REPORTER if (with_reporter) { card_fun <- function(comment, label) { - card <- teal::TealReportCard$new() - title <- "Patient Profile Adverse Events Plot" - title <- ifelse(label == "", title, label) - card$set_name(title) - card$append_text(title, "header2") - if (with_filter) { - card$append_fs(filter_panel_api$get_filter_state()) - } + card <- card_template( + title = "Patient Profile Adverse Events Plot", + label = label, + description = NULL, + with_filter = with_filter + ) card$append_text("Plot", "header3") card$append_plot(plot_r(), dim = pws$dim()) if (!comment == "") { diff --git a/R/tm_g_pp_patient_timeline.R b/R/tm_g_pp_patient_timeline.R index 93f16a862a..7f86c4fa49 100644 --- a/R/tm_g_pp_patient_timeline.R +++ b/R/tm_g_pp_patient_timeline.R @@ -895,14 +895,12 @@ srv_g_patient_timeline <- function(id, ### REPORTER if (with_reporter) { card_fun <- function(comment, label) { - card <- teal::TealReportCard$new() - title <- "Patient Profile Timeline Plot" - title <- ifelse(label == "", title, label) - card$set_name(title) - card$append_text(title, "header2") - if (with_filter) { - card$append_fs(filter_panel_api$get_filter_state()) - } + card <- card_template( + title = "Patient Profile Timeline Plot", + label = label, + description = NULL, + with_filter = with_filter + ) card$append_text("Plot", "header3") card$append_plot(plot_r(), dim = pws$dim()) if (!comment == "") { diff --git a/R/tm_g_pp_therapy.R b/R/tm_g_pp_therapy.R index 856ef49803..e7bc0ea48e 100644 --- a/R/tm_g_pp_therapy.R +++ b/R/tm_g_pp_therapy.R @@ -683,14 +683,12 @@ srv_g_therapy <- function(id, ### REPORTER if (with_reporter) { card_fun <- function(comment, label) { - card <- teal::TealReportCard$new() - title <- "Patient Profile Therapy Plot" - title <- ifelse(label == "", title, label) - card$set_name(title) - card$append_text(title, "header2") - if (with_filter) { - card$append_fs(filter_panel_api$get_filter_state()) - } + card <- card_template( + title = "Patient Profile Therapy Plot", + label = label, + description = NULL, + with_filter = with_filter + ) card$append_text("Plot", "header3") card$append_plot(plot_r(), dim = pws$dim()) if (!comment == "") { diff --git a/R/tm_g_pp_vitals.R b/R/tm_g_pp_vitals.R index f5b029568d..a17c902861 100644 --- a/R/tm_g_pp_vitals.R +++ b/R/tm_g_pp_vitals.R @@ -529,14 +529,12 @@ srv_g_vitals <- function(id, ### REPORTER if (with_reporter) { card_fun <- function(comment, label) { - card <- teal::TealReportCard$new() - title <- "Patient Profile Vitals Plot" - title <- ifelse(label == "", title, label) - card$set_name(title) - card$append_text(title, "header2") - if (with_filter) { - card$append_fs(filter_panel_api$get_filter_state()) - } + card <- card_template( + title = "Patient Profile Vitals Plot", + label = label, + description = NULL, + with_filter = with_filter + ) card$append_text("Plot", "header3") card$append_plot(plot_r(), dim = pws$dim()) if (!comment == "") { diff --git a/R/tm_t_abnormality.R b/R/tm_t_abnormality.R index b37435214c..cc26ffe285 100644 --- a/R/tm_t_abnormality.R +++ b/R/tm_t_abnormality.R @@ -648,14 +648,12 @@ srv_t_abnormality <- function(id, ### REPORTER if (with_reporter) { card_fun <- function(comment, label) { - card <- teal::TealReportCard$new() - title <- "Abnormality Summary Table" - title <- ifelse(label == "", title, label) - card$set_name(title) - card$append_text(title, "header2") - if (with_filter) { - card$append_fs(filter_panel_api$get_filter_state()) - } + card <- card_template( + title = "Abnormality Summary Table", + label = label, + description = NULL, + with_filter = with_filter + ) card$append_text("Table", "header3") card$append_table(table_r()) if (!comment == "") { diff --git a/R/tm_t_abnormality_by_worst_grade.R b/R/tm_t_abnormality_by_worst_grade.R index e2b4ff0b9b..b5620308b8 100644 --- a/R/tm_t_abnormality_by_worst_grade.R +++ b/R/tm_t_abnormality_by_worst_grade.R @@ -665,15 +665,12 @@ srv_t_abnormality_by_worst_grade <- function(id, # nolint ### REPORTER if (with_reporter) { card_fun <- function(comment, label) { - card <- teal::TealReportCard$new() - title <- "Laboratory Test Results Table" - title <- ifelse(label == "", title, label) - card$set_name(title) - card$append_text(title, "header2") - card$append_text("Laboratory test results with highest grade post-baseline Table", "header3") - if (with_filter) { - card$append_fs(filter_panel_api$get_filter_state()) - } + card <- card_template( + title = "Laboratory Test Results Table", + label = label, + description = "Laboratory test results with highest grade post-baseline Table", + with_filter = with_filter + ) card$append_text("Table", "header3") card$append_table(table_r()) if (!comment == "") { diff --git a/R/tm_t_ancova.R b/R/tm_t_ancova.R index b1b0257e9b..b153a3b69f 100644 --- a/R/tm_t_ancova.R +++ b/R/tm_t_ancova.R @@ -946,15 +946,12 @@ srv_ancova <- function(id, ### REPORTER if (with_reporter) { card_fun <- function(comment, label) { - card <- teal::TealReportCard$new() - title <- "ANCOVA" - title <- ifelse(label == "", title, label) - card$set_name(title) - card$append_text(title, "header2") - card$append_text("Analysis of Covariance", "header3") - if (with_filter) { - card$append_fs(filter_panel_api$get_filter_state()) - } + card <- card_template( + title = "ANCOVA", + label = label, + description = "Analysis of Covariance", + with_filter = with_filter + ) card$append_text("Table", "header3") card$append_table(table_r()) if (!comment == "") { diff --git a/R/tm_t_binary_outcome.R b/R/tm_t_binary_outcome.R index b0bba79e06..d5fa1a84a6 100644 --- a/R/tm_t_binary_outcome.R +++ b/R/tm_t_binary_outcome.R @@ -1009,14 +1009,12 @@ srv_t_binary_outcome <- function(id, ### REPORTER if (with_reporter) { card_fun <- function(comment, label) { - card <- teal::TealReportCard$new() - title <- "Binary Outcome Table" - title <- ifelse(label == "", title, label) - card$set_name(title) - card$append_text(title, "header2") - if (with_filter) { - card$append_fs(filter_panel_api$get_filter_state()) - } + card <- card_template( + title = "Binary Outcome Table", + label = label, + description = NULL, + with_filter = with_filter + ) card$append_text("Table", "header3") card$append_table(table_r()) if (!comment == "") { diff --git a/R/tm_t_coxreg.R b/R/tm_t_coxreg.R index f1b9b96f2c..675ed7a0df 100644 --- a/R/tm_t_coxreg.R +++ b/R/tm_t_coxreg.R @@ -1046,13 +1046,13 @@ srv_t_coxreg <- function(id, ### REPORTER if (with_reporter) { - card_fun <- function(comment) { - card <- teal::TealReportCard$new() - card$set_name("Cox Regression Table") - card$append_text("Cox Regression Table", "header2") - if (with_filter) { - card$append_fs(filter_panel_api$get_filter_state()) - } + card_fun <- function(comment, label) { + card <- card_template( + title = "Cox Regression Table", + label = label, + description = NULL, + with_filter = with_filter + ) card$append_text("Table", "header3") card$append_table(table_r()) if (!comment == "") { diff --git a/R/tm_t_events.R b/R/tm_t_events.R index c67416235a..36340ba113 100644 --- a/R/tm_t_events.R +++ b/R/tm_t_events.R @@ -794,14 +794,12 @@ srv_t_events_byterm <- function(id, ### REPORTER if (with_reporter) { card_fun <- function(comment, label) { - card <- teal::TealReportCard$new() - title <- "Events by Term Table" - title <- ifelse(label == "", title, label) - card$set_name(title) - card$append_text(title, "header2") - if (with_filter) { - card$append_fs(filter_panel_api$get_filter_state()) - } + card <- card_template( + title = "Events by Term Table", + label = label, + description = NULL, + with_filter = with_filter + ) card$append_text("Table", "header3") card$append_table(table_r()) if (!comment == "") { diff --git a/R/tm_t_events_by_grade.R b/R/tm_t_events_by_grade.R index 12db75862d..d378626d77 100644 --- a/R/tm_t_events_by_grade.R +++ b/R/tm_t_events_by_grade.R @@ -1194,14 +1194,12 @@ srv_t_events_by_grade <- function(id, ### REPORTER if (with_reporter) { card_fun <- function(comment, label) { - card <- teal::TealReportCard$new() - title <- "Events by Grade Table" - title <- ifelse(label == "", title, label) - card$set_name(title) - card$append_text(title, "header2") - if (with_filter) { - card$append_fs(filter_panel_api$get_filter_state()) - } + card <- card_template( + title = "Events by Grade Table", + label = label, + description = NULL, + with_filter = with_filter + ) card$append_text("Table", "header3") card$append_table(table_r()) if (!comment == "") { diff --git a/R/tm_t_events_patyear.R b/R/tm_t_events_patyear.R index 9c632225c5..76c6300f93 100644 --- a/R/tm_t_events_patyear.R +++ b/R/tm_t_events_patyear.R @@ -556,14 +556,12 @@ srv_events_patyear <- function(id, ### REPORTER if (with_reporter) { card_fun <- function(comment, label) { - card <- teal::TealReportCard$new() - title <- "Event Rates Adjusted For Patient-Years Table" - title <- ifelse(label == "", title, label) - card$set_name(title) - card$append_text(title, "header2") - if (with_filter) { - card$append_fs(filter_panel_api$get_filter_state()) - } + card <- card_template( + title = "Event Rates Adjusted For Patient-Years Table", + label = label, + description = NULL, + with_filter = with_filter + ) card$append_text("Table", "header3") card$append_table(table_r()) if (!comment == "") { diff --git a/R/tm_t_events_summary.R b/R/tm_t_events_summary.R index cb88ad733e..cc1465b068 100644 --- a/R/tm_t_events_summary.R +++ b/R/tm_t_events_summary.R @@ -966,14 +966,12 @@ srv_t_events_summary <- function(id, ### REPORTER if (with_reporter) { card_fun <- function(comment, label) { - card <- teal::TealReportCard$new() - title <- "Adverse Events Summary Table" - title <- ifelse(label == "", title, label) - card$set_name(title) - card$append_text(title, "header2") - if (with_filter) { - card$append_fs(filter_panel_api$get_filter_state()) - } + card <- card_template( + title = "Adverse Events Summary Table", + label = label, + description = NULL, + with_filter = with_filter + ) card$append_text("Table", "header3") card$append_table(table_r()) if (!comment == "") { diff --git a/R/tm_t_exposure.R b/R/tm_t_exposure.R index d0b64a3873..39cc2f3663 100644 --- a/R/tm_t_exposure.R +++ b/R/tm_t_exposure.R @@ -646,14 +646,12 @@ srv_t_exposure <- function(id, ### REPORTER if (with_reporter) { card_fun <- function(comment, label) { - card <- teal::TealReportCard$new() - title <- "Exposure for Risk Management Plan Table" - title <- ifelse(label == "", title, label) - card$set_name(title) - card$append_text(title, "header2") - if (with_filter) { - card$append_fs(filter_panel_api$get_filter_state()) - } + card <- card_template( + title = "Exposure for Risk Management Plan Table", + label = label, + description = NULL, + with_filter = with_filter + ) card$append_text("Table", "header3") card$append_table(table_r()) if (!comment == "") { diff --git a/R/tm_t_logistic.R b/R/tm_t_logistic.R index a4190aa91e..6032e7310e 100644 --- a/R/tm_t_logistic.R +++ b/R/tm_t_logistic.R @@ -714,14 +714,12 @@ srv_t_logistic <- function(id, ### REPORTER if (with_reporter) { card_fun <- function(comment, label) { - card <- teal::TealReportCard$new() - title <- "Logistic Regression Table" - title <- ifelse(label == "", title, label) - card$set_name(title) - card$append_text(title, "header2") - if (with_filter) { - card$append_fs(filter_panel_api$get_filter_state()) - } + card <- card_template( + title = "Logistic Regression Table", + label = label, + description = NULL, + with_filter = with_filter + ) card$append_text("Table", "header3") card$append_table(table_r()) if (!comment == "") { diff --git a/R/tm_t_mult_events.R b/R/tm_t_mult_events.R index 234f0d37b2..809e344e6d 100644 --- a/R/tm_t_mult_events.R +++ b/R/tm_t_mult_events.R @@ -592,14 +592,12 @@ srv_t_mult_events_byterm <- function(id, ### REPORTER if (with_reporter) { card_fun <- function(comment, label) { - card <- teal::TealReportCard$new() - title <- "Multiple Events by Term Table" - title <- ifelse(label == "", title, label) - card$set_name(title) - card$append_text(title, "header2") - if (with_filter) { - card$append_fs(filter_panel_api$get_filter_state()) - } + card <- card_template( + title = "Multiple Events by Term Table", + label = label, + description = NULL, + with_filter = with_filter + ) card$append_text("Table", "header3") card$append_table(table_r()) if (!comment == "") { diff --git a/R/tm_t_pp_basic_info.R b/R/tm_t_pp_basic_info.R index 11282e75a4..e8d8063a1b 100644 --- a/R/tm_t_pp_basic_info.R +++ b/R/tm_t_pp_basic_info.R @@ -263,14 +263,12 @@ srv_t_basic_info <- function(id, ### REPORTER if (with_reporter) { card_fun <- function(comment, label) { - card <- teal::TealReportCard$new() - title <- "Patient Profile Basic Info Table" - title <- ifelse(label == "", title, label) - card$set_name(title) - card$append_text(title, "header2") - if (with_filter) { - card$append_fs(filter_panel_api$get_filter_state()) - } + card <- card_template( + title = "Patient Profile Basic Info Table", + label = label, + description = NULL, + with_filter = with_filter + ) card$append_text("Table", "header3") card$append_table(table_r()) if (!comment == "") { diff --git a/R/tm_t_pp_laboratory.R b/R/tm_t_pp_laboratory.R index 45be9a5442..5d78a96001 100644 --- a/R/tm_t_pp_laboratory.R +++ b/R/tm_t_pp_laboratory.R @@ -436,14 +436,12 @@ srv_g_laboratory <- function(id, ### REPORTER if (with_reporter) { card_fun <- function(comment, label) { - card <- teal::TealReportCard$new() - title <- "Patient Profile Laboratory Table" - title <- ifelse(label == "", title, label) - card$set_name(title) - card$append_text(title, "header2") - if (with_filter) { - card$append_fs(filter_panel_api$get_filter_state()) - } + card <- card_template( + title = "Patient Profile Laboratory Table", + label = label, + description = NULL, + with_filter = with_filter + ) card$append_text("Table", "header3") card$append_table(table_r()$raw) if (!comment == "") { diff --git a/R/tm_t_pp_medical_history.R b/R/tm_t_pp_medical_history.R index 7d8cd121ba..a343f9ff14 100644 --- a/R/tm_t_pp_medical_history.R +++ b/R/tm_t_pp_medical_history.R @@ -337,14 +337,12 @@ srv_t_medical_history <- function(id, ### REPORTER if (with_reporter) { card_fun <- function(comment, label) { - card <- teal::TealReportCard$new() - title <- "Patient Medical History Table" - title <- ifelse(label == "", title, label) - card$set_name(title) - card$append_text(title, "header2") - if (with_filter) { - card$append_fs(filter_panel_api$get_filter_state()) - } + card <- card_template( + title = "Patient Medical History Table", + label = label, + description = NULL, + with_filter = with_filter + ) card$append_text("Table", "header3") card$append_table(table_r()) if (!comment == "") { diff --git a/R/tm_t_pp_prior_medication.R b/R/tm_t_pp_prior_medication.R index 253d1ef8f2..8348b1de4c 100644 --- a/R/tm_t_pp_prior_medication.R +++ b/R/tm_t_pp_prior_medication.R @@ -345,14 +345,12 @@ srv_t_prior_medication <- function(id, if (with_reporter) { card_fun <- function(comment, label) { - card <- teal::TealReportCard$new() - title <- "Patient Prior Medication Table" - title <- ifelse(label == "", title, label) - card$set_name(title) - card$append_text(title, "header2") - if (with_filter) { - card$append_fs(filter_panel_api$get_filter_state()) - } + card <- card_template( + title = "Patient Prior Medication Table", + label = label, + description = NULL, + with_filter = with_filter + ) card$append_text("Table", "header3") card$append_table(table_r()) if (!comment == "") { diff --git a/R/tm_t_shift_by_arm_by_worst.R b/R/tm_t_shift_by_arm_by_worst.R index 2766ed9b4c..5fedb941cc 100644 --- a/R/tm_t_shift_by_arm_by_worst.R +++ b/R/tm_t_shift_by_arm_by_worst.R @@ -567,14 +567,12 @@ srv_shift_by_arm_by_worst <- function(id, ### REPORTER if (with_reporter) { card_fun <- function(comment, label) { - card <- teal::TealReportCard$new() - title <- "Shift by Arm by Worst Table" - title <- ifelse(label == "", title, label) - card$set_name(title) - card$append_text(title, "header2") - if (with_filter) { - card$append_fs(filter_panel_api$get_filter_state()) - } + card <- card_template( + title = "Shift by Arm by Worst Table", + label = label, + description = NULL, + with_filter = with_filter + ) card$append_text("Table", "header3") card$append_table(table_r()) if (!comment == "") { diff --git a/R/tm_t_shift_by_grade.R b/R/tm_t_shift_by_grade.R index 9e62180b64..5e114c4e54 100644 --- a/R/tm_t_shift_by_grade.R +++ b/R/tm_t_shift_by_grade.R @@ -887,14 +887,12 @@ srv_t_shift_by_grade <- function(id, ### REPORTER if (with_reporter) { card_fun <- function(comment, label) { - card <- teal::TealReportCard$new() - title <- "Grade Summary Table" - title <- ifelse(label == "", title, label) - card$set_name(title) - card$append_text(title, "header2") - if (with_filter) { - card$append_fs(filter_panel_api$get_filter_state()) - } + card <- card_template( + title = "Grade Summary Table", + label = label, + description = NULL, + with_filter = with_filter + ) card$append_text("Table", "header3") card$append_table(table_r()) if (!comment == "") { diff --git a/R/tm_t_smq.R b/R/tm_t_smq.R index e221467644..29bca8f6a4 100644 --- a/R/tm_t_smq.R +++ b/R/tm_t_smq.R @@ -659,14 +659,12 @@ srv_t_smq <- function(id, ### REPORTER if (with_reporter) { card_fun <- function(comment, label) { - card <- teal::TealReportCard$new() - title <- "Adverse Events Table by Standardized `MedDRA` Query (SMQ)" - title <- ifelse(label == "", title, label) - card$set_name(title) - card$append_text(title, "header2") - if (with_filter) { - card$append_fs(filter_panel_api$get_filter_state()) - } + card <- card_template( + title = "Adverse Events Table by Standardized `MedDRA` Query (SMQ)", + label = label, + description = NULL, + with_filter = with_filter + ) card$append_text("Table", "header3") card$append_table(table_r()) if (!comment == "") { diff --git a/R/tm_t_summary.R b/R/tm_t_summary.R index af27ae3528..e474c09494 100644 --- a/R/tm_t_summary.R +++ b/R/tm_t_summary.R @@ -577,14 +577,12 @@ srv_summary <- function(id, ### REPORTER if (with_reporter) { card_fun <- function(comment, label) { - card <- teal::TealReportCard$new() - title <- "Summary Table" - title <- ifelse(label == "", title, label) - card$set_name(title) - card$append_text(title, "header2") - if (with_filter) { - card$append_fs(filter_panel_api$get_filter_state()) - } + card <- card_template( + title = "Summary Table", + label = label, + description = NULL, + with_filter = with_filter + ) card$append_text("Table", "header3") card$append_table(table_r()) if (!comment == "") { diff --git a/R/tm_t_summary_by.R b/R/tm_t_summary_by.R index d19246519b..3ec4a86fbf 100644 --- a/R/tm_t_summary_by.R +++ b/R/tm_t_summary_by.R @@ -734,14 +734,12 @@ srv_summary_by <- function(id, ### REPORTER if (with_reporter) { card_fun <- function(comment, label) { - card <- teal::TealReportCard$new() - title <- "Summarize Variables by Row Groups Table" - title <- ifelse(label == "", title, label) - card$set_name(title) - card$append_text(title, "header2") - if (with_filter) { - card$append_fs(filter_panel_api$get_filter_state()) - } + card <- card_template( + title = "Summarize Variables by Row Groups Table", + label = label, + description = NULL, + with_filter = with_filter + ) card$append_text("Table", "header3") card$append_table(table_r()) if (!comment == "") { diff --git a/R/tm_t_tte.R b/R/tm_t_tte.R index 3926983458..ac8784bbf6 100644 --- a/R/tm_t_tte.R +++ b/R/tm_t_tte.R @@ -927,14 +927,12 @@ srv_t_tte <- function(id, ### REPORTER if (with_reporter) { card_fun <- function(comment, label) { - card <- teal::TealReportCard$new() - title <- "Time To Event Table" - title <- ifelse(label == "", title, label) - card$set_name(title) - card$append_text(title, "header2") - if (with_filter) { - card$append_fs(filter_panel_api$get_filter_state()) - } + card <- card_template( + title = "Time To Event Table", + label = label, + description = NULL, + with_filter = with_filter + ) card$append_text("Table", "header3") card$append_table(table_r()) if (!comment == "") { diff --git a/R/utils.R b/R/utils.R index 2b9cd61d0a..24e84a4d6d 100644 --- a/R/utils.R +++ b/R/utils.R @@ -821,6 +821,27 @@ clean_description <- function(x) { x } +#' Template function to generate reporter card for `teal.modules.clinical` +#' @param title (`character(1)`) title of the card (unless overwritten by label) +#' @param label (`character(1)`) label provided by the user when adding the card +#' @param description (`character(1)`) optional additional description +#' +#' @return (`TealReportCard`) populated with a title, description and filter state +#' +#' @keywords internal +card_template <- function(title, label, description = NULL, with_filter) { + card <- teal::TealReportCard$new() + title <- ifelse(label == "", title, label) + card$set_name(title) + card$append_text(title, "header2") + if (!is.null(description)) { + card$append_text(description, "header3") + } + if (with_filter) { + card$append_fs(filter_panel_api$get_filter_state()) + } + card +} #' Utility function for extracting `paramcd` for forest plots #'