Skip to content

Commit

Permalink
feat: use card template to remove repeated code
Browse files Browse the repository at this point in the history
  • Loading branch information
averissimo committed Sep 28, 2023
1 parent 500b8f1 commit 75e9086
Show file tree
Hide file tree
Showing 36 changed files with 232 additions and 286 deletions.
15 changes: 7 additions & 8 deletions R/tm_a_gee.R
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
16 changes: 5 additions & 11 deletions R/tm_a_mmrm.R
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
14 changes: 6 additions & 8 deletions R/tm_g_barchart_simple.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "") {
Expand Down
15 changes: 6 additions & 9 deletions R/tm_g_ci.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "") {
Expand Down
14 changes: 6 additions & 8 deletions R/tm_g_forest_rsp.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "") {
Expand Down
14 changes: 6 additions & 8 deletions R/tm_g_forest_tte.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "") {
Expand Down
14 changes: 6 additions & 8 deletions R/tm_g_ipp.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "") {
Expand Down
15 changes: 6 additions & 9 deletions R/tm_g_km.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "") {
Expand Down
14 changes: 6 additions & 8 deletions R/tm_g_lineplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "") {
Expand Down
14 changes: 6 additions & 8 deletions R/tm_g_pp_adverse_events.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "") {
Expand Down
14 changes: 6 additions & 8 deletions R/tm_g_pp_patient_timeline.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "") {
Expand Down
14 changes: 6 additions & 8 deletions R/tm_g_pp_therapy.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "") {
Expand Down
14 changes: 6 additions & 8 deletions R/tm_g_pp_vitals.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "") {
Expand Down
14 changes: 6 additions & 8 deletions R/tm_t_abnormality.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "") {
Expand Down
15 changes: 6 additions & 9 deletions R/tm_t_abnormality_by_worst_grade.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "") {
Expand Down
15 changes: 6 additions & 9 deletions R/tm_t_ancova.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "") {
Expand Down
14 changes: 6 additions & 8 deletions R/tm_t_binary_outcome.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "") {
Expand Down
14 changes: 7 additions & 7 deletions R/tm_t_coxreg.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "") {
Expand Down
Loading

0 comments on commit 75e9086

Please sign in to comment.