Skip to content

Commit

Permalink
198 Include user's card labels when generating the report (#835)
Browse files Browse the repository at this point in the history
This PR allows end user to use their Card Name (label) to be passed to
the Card Content. There are no more hardcoded titles. The hardcoded
titles will be only used if Card Name (label0) is empty.

A follow-up after
insightsengineering/teal.reporter#219

---------

Signed-off-by: André Veríssimo <211358+averissimo@users.noreply.github.com>
Co-authored-by: André Veríssimo <211358+averissimo@users.noreply.github.com>
Co-authored-by: unknown <kirar.kartikeya1@gmail.com>
  • Loading branch information
3 people authored Oct 13, 2023
1 parent 672f9f9 commit e5e8dae
Show file tree
Hide file tree
Showing 38 changed files with 317 additions and 318 deletions.
3 changes: 2 additions & 1 deletion .lintr
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
linters: linters_with_defaults(
line_length_linter = line_length_linter(120),
cyclocomp_linter = NULL,
object_usage_linter = NULL
object_usage_linter = NULL,
indentation_linter = NULL
)
15 changes: 8 additions & 7 deletions R/tm_a_gee.R
Original file line number Diff line number Diff line change
Expand Up @@ -547,14 +547,15 @@ srv_gee <- function(id,
title = label
)

### REPORTER
if (with_reporter) {
card_fun <- function(comment) {
card <- teal::TealReportCard$new()
card$set_name("Generalized Estimating Equations (GEE) Analysis Table")
card$append_text("Generalized Estimating Equations (GEE) Analysis Table", "header2")
if (with_filter) {
card$append_fs(filter_panel_api$get_filter_state())
}
card_fun <- function(comment, label) {
card <- teal::report_card_template(
title = "Generalized Estimating Equations (GEE) Analysis Table",
label = label,
with_filter = with_filter,
filter_panel_api = filter_panel_api
)
table_type <- switch(input$output_table,
"t_gee_cov" = "Residual Covariance Matrix Estimate",
"t_gee_coef" = "Model Coefficients",
Expand Down
26 changes: 11 additions & 15 deletions R/tm_a_mmrm.R
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,10 @@ template_mmrm_tables <- function(parentname,
layout_list <- add_expr(
layout_list,
substitute(
expr =
rtables::add_overall_col(total_label) %>%
rtables::split_rows_by(visit_var) %>%
tern.mmrm::summarize_lsmeans(arms = FALSE) %>%
rtables::append_topleft(paste0(" ", paramcd)),
expr = rtables::add_overall_col(total_label) %>%
rtables::split_rows_by(visit_var) %>%
tern.mmrm::summarize_lsmeans(arms = FALSE) %>%
rtables::append_topleft(paste0(" ", paramcd)),
env = list(
total_label = total_label,
visit_var = visit_var,
Expand Down Expand Up @@ -1432,20 +1431,17 @@ srv_mmrm <- function(id,

### REPORTER
if (with_reporter) {
card_fun <- function(comment) {
card <- teal::TealReportCard$new()
card$set_name("MMRM")
card$append_text("Mixed Model Repeated Measurements (MMRM) Analysis", "header2")
card$append_text(
paste(
card_fun <- function(comment, label) {
card <- teal::report_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,
filter_panel_api = filter_panel_api
)
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: 7 additions & 7 deletions R/tm_g_barchart_simple.R
Original file line number Diff line number Diff line change
Expand Up @@ -538,13 +538,13 @@ srv_g_barchart_simple <- function(id,

### REPORTER
if (with_reporter) {
card_fun <- function(comment) {
card <- teal::TealReportCard$new()
card$set_name("Barchart Plot")
card$append_text("Barchart Plot", "header2")
if (with_filter) {
card$append_fs(filter_panel_api$get_filter_state())
}
card_fun <- function(comment, label) {
card <- teal::report_card_template(
title = "Barchart Plot",
label = label,
with_filter = with_filter,
filter_panel_api = filter_panel_api
)
card$append_text("Plot", "header3")
card$append_plot(plot_r(), dim = pws$dim())
if (!comment == "") {
Expand Down
16 changes: 8 additions & 8 deletions R/tm_g_ci.R
Original file line number Diff line number Diff line change
Expand Up @@ -483,14 +483,14 @@ srv_g_ci <- function(id, # nolint

### REPORTER
if (with_reporter) {
card_fun <- function(comment) {
card <- teal::TealReportCard$new()
card$set_name("CI Plot")
card$append_text("CI Plot", "header2")
card$append_text("Confidence Interval Plot", "header3")
if (with_filter) {
card$append_fs(filter_panel_api$get_filter_state())
}
card_fun <- function(comment, label) {
card <- teal::report_card_template(
title = "CI Plot",
label = label,
description = "Confidence Interval Plot",
with_filter = with_filter,
filter_panel_api = filter_panel_api
)
card$append_text("Plot", "header3")
card$append_plot(plot_r(), dim = pws$dim())
if (!comment == "") {
Expand Down
14 changes: 7 additions & 7 deletions R/tm_g_forest_rsp.R
Original file line number Diff line number Diff line change
Expand Up @@ -718,13 +718,13 @@ srv_g_forest_rsp <- function(id,

### REPORTER
if (with_reporter) {
card_fun <- function(comment) {
card <- teal::TealReportCard$new()
card$set_name("Forest Response Plot")
card$append_text("Forest Response Plot", "header2")
if (with_filter) {
card$append_fs(filter_panel_api$get_filter_state())
}
card_fun <- function(comment, label) {
card <- teal::report_card_template(
title = "Forest Response Plot",
label = label,
with_filter = with_filter,
filter_panel_api = filter_panel_api
)
card$append_text("Plot", "header3")
card$append_plot(plot_r(), dim = pws$dim())
if (!comment == "") {
Expand Down
14 changes: 7 additions & 7 deletions R/tm_g_forest_tte.R
Original file line number Diff line number Diff line change
Expand Up @@ -652,13 +652,13 @@ srv_g_forest_tte <- function(id,

### REPORTER
if (with_reporter) {
card_fun <- function(comment) {
card <- teal::TealReportCard$new()
card$set_name("Forest Survival Plot")
card$append_text("Forest Survival Plot", "header2")
if (with_filter) {
card$append_fs(filter_panel_api$get_filter_state())
}
card_fun <- function(comment, label) {
card <- teal::report_card_template(
title = "Forest Survival Plot",
label = label,
with_filter = with_filter,
filter_panel_api = filter_panel_api
)
card$append_text("Plot", "header3")
card$append_plot(plot_r(), dim = pws$dim())
if (!comment == "") {
Expand Down
14 changes: 7 additions & 7 deletions R/tm_g_ipp.R
Original file line number Diff line number Diff line change
Expand Up @@ -611,13 +611,13 @@ srv_g_ipp <- function(id,

### REPORTER
if (with_reporter) {
card_fun <- function(comment) {
card <- teal::TealReportCard$new()
card$set_name("Individual Patient Plot")
card$append_text("Individual Patient Plot", "header2")
if (with_filter) {
card$append_fs(filter_panel_api$get_filter_state())
}
card_fun <- function(comment, label) {
card <- teal::report_card_template(
title = "Individual Patient Plot",
label = label,
with_filter = with_filter,
filter_panel_api = filter_panel_api
)
card$append_text("Plot", "header3")
card$append_plot(plot_r(), dim = pws$dim())
if (!comment == "") {
Expand Down
16 changes: 8 additions & 8 deletions R/tm_g_km.R
Original file line number Diff line number Diff line change
Expand Up @@ -773,14 +773,14 @@ srv_g_km <- function(id,

### REPORTER
if (with_reporter) {
card_fun <- function(comment) {
card <- teal::TealReportCard$new()
card$set_name("Kaplan Meier Plot")
card$append_text("Kaplan Meier Plot", "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_fun <- function(comment, label) {
card <- teal::report_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,
filter_panel_api = filter_panel_api
)
card$append_text("Plot", "header3")
card$append_plot(plot_r(), dim = pws$dim())
if (!comment == "") {
Expand Down
14 changes: 7 additions & 7 deletions R/tm_g_lineplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -648,13 +648,13 @@ srv_g_lineplot <- function(id,

### REPORTER
if (with_reporter) {
card_fun <- function(comment) {
card <- teal::TealReportCard$new()
card$set_name("Line Plot")
card$append_text("Line Plot", "header2")
if (with_filter) {
card$append_fs(filter_panel_api$get_filter_state())
}
card_fun <- function(comment, label) {
card <- teal::report_card_template(
title = "Line Plot",
label = label,
with_filter = with_filter,
filter_panel_api = filter_panel_api
)
card$append_text("Plot", "header3")
card$append_plot(plot_r(), dim = pws$dim())
if (!comment == "") {
Expand Down
14 changes: 7 additions & 7 deletions R/tm_g_pp_adverse_events.R
Original file line number Diff line number Diff line change
Expand Up @@ -575,13 +575,13 @@ srv_g_adverse_events <- function(id,

### REPORTER
if (with_reporter) {
card_fun <- function(comment) {
card <- teal::TealReportCard$new()
card$set_name("Patient Profile Adverse Events")
card$append_text("Patient Profile Adverse Events", "header2")
if (with_filter) {
card$append_fs(filter_panel_api$get_filter_state())
}
card_fun <- function(comment, label) {
card <- teal::report_card_template(
title = "Patient Profile Adverse Events Plot",
label = label,
with_filter = with_filter,
filter_panel_api = filter_panel_api
)
card$append_text("Table", "header3")
card$append_table(teal.code::dev_suppress(all_q()[["table"]]))
card$append_text("Plot", "header3")
Expand Down
20 changes: 11 additions & 9 deletions R/tm_g_pp_patient_timeline.R
Original file line number Diff line number Diff line change
Expand Up @@ -831,8 +831,10 @@ srv_g_patient_timeline <- function(id,
shiny::validate(
shiny::need(
!input$relday_x_axis ||
(sum(stats::complete.cases(p_time_data_pat[, c(aerelday_start_name, aerelday_end_name)])) > 0 ||
sum(stats::complete.cases(p_time_data_pat[, c(dsrelday_start_name, dsrelday_end_name)])) > 0),
(
sum(stats::complete.cases(p_time_data_pat[, c(aerelday_start_name, aerelday_end_name)])) > 0 ||
sum(stats::complete.cases(p_time_data_pat[, c(dsrelday_start_name, dsrelday_end_name)])) > 0
),
"Selected patient is not in dataset (either due to filtering or missing values). Consider relaxing filters."
)
)
Expand Down Expand Up @@ -894,13 +896,13 @@ srv_g_patient_timeline <- function(id,

### REPORTER
if (with_reporter) {
card_fun <- function(comment) {
card <- teal::TealReportCard$new()
card$set_name("Patient Profile Timeline Plot")
card$append_text("Patient Profile Timeline Plot", "header2")
if (with_filter) {
card$append_fs(filter_panel_api$get_filter_state())
}
card_fun <- function(comment, label) {
card <- teal::report_card_template(
title = "Patient Profile Timeline Plot",
label = label,
with_filter = with_filter,
filter_panel_api = filter_panel_api
)
card$append_text("Plot", "header3")
card$append_plot(plot_r(), dim = pws$dim())
if (!comment == "") {
Expand Down
14 changes: 7 additions & 7 deletions R/tm_g_pp_therapy.R
Original file line number Diff line number Diff line change
Expand Up @@ -696,13 +696,13 @@ srv_g_therapy <- function(id,

### REPORTER
if (with_reporter) {
card_fun <- function(comment) {
card <- teal::TealReportCard$new()
card$set_name("Patient Profile Therapy")
card$append_text("Patient Profile Therapy", "header2")
if (with_filter) {
card$append_fs(filter_panel_api$get_filter_state())
}
card_fun <- function(comment, label) {
card <- teal::report_card_template(
title = "Patient Profile Therapy",
label = label,
with_filter = with_filter,
filter_panel_api = filter_panel_api
)
card$append_text("Table", "header3")
card$append_table(teal.code::dev_suppress(all_q()[["therapy_table"]]))
card$append_text("Plot", "header3")
Expand Down
14 changes: 7 additions & 7 deletions R/tm_g_pp_vitals.R
Original file line number Diff line number Diff line change
Expand Up @@ -528,13 +528,13 @@ srv_g_vitals <- function(id,

### REPORTER
if (with_reporter) {
card_fun <- function(comment) {
card <- teal::TealReportCard$new()
card$set_name("Patient Profile Vitals Plot")
card$append_text("Patient Profile Vitals Plot", "header2")
if (with_filter) {
card$append_fs(filter_panel_api$get_filter_state())
}
card_fun <- function(comment, label) {
card <- teal::report_card_template(
title = "Patient Profile Vitals Plot",
label = label,
with_filter = with_filter,
filter_panel_api = filter_panel_api
)
card$append_text("Plot", "header3")
card$append_plot(plot_r(), dim = pws$dim())
if (!comment == "") {
Expand Down
14 changes: 7 additions & 7 deletions R/tm_t_abnormality.R
Original file line number Diff line number Diff line change
Expand Up @@ -647,13 +647,13 @@ srv_t_abnormality <- function(id,

### REPORTER
if (with_reporter) {
card_fun <- function(comment) {
card <- teal::TealReportCard$new()
card$set_name("Abnormality Summary Table")
card$append_text("Abnormality Summary Table", "header2")
if (with_filter) {
card$append_fs(filter_panel_api$get_filter_state())
}
card_fun <- function(comment, label) {
card <- teal::report_card_template(
title = "Abnormality Summary Table",
label = label,
with_filter = with_filter,
filter_panel_api = filter_panel_api
)
card$append_text("Table", "header3")
card$append_table(table_r())
if (!comment == "") {
Expand Down
16 changes: 8 additions & 8 deletions R/tm_t_abnormality_by_worst_grade.R
Original file line number Diff line number Diff line change
Expand Up @@ -664,14 +664,14 @@ srv_t_abnormality_by_worst_grade <- function(id, # nolint

### REPORTER
if (with_reporter) {
card_fun <- function(comment) {
card <- teal::TealReportCard$new()
card$set_name("Laboratory Test Results Table")
card$append_text("Laboratory Test Results Table", "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_fun <- function(comment, label) {
card <- teal::report_card_template(
title = "Laboratory Test Results Table",
label = label,
description = "Laboratory test results with highest grade post-baseline Table",
with_filter = with_filter,
filter_panel_api = filter_panel_api
)
card$append_text("Table", "header3")
card$append_table(table_r())
if (!comment == "") {
Expand Down
16 changes: 8 additions & 8 deletions R/tm_t_ancova.R
Original file line number Diff line number Diff line change
Expand Up @@ -945,14 +945,14 @@ srv_ancova <- function(id,

### REPORTER
if (with_reporter) {
card_fun <- function(comment) {
card <- teal::TealReportCard$new()
card$set_name("ANCOVA")
card$append_text("ANCOVA", "header2")
card$append_text("Analysis of Covariance", "header3")
if (with_filter) {
card$append_fs(filter_panel_api$get_filter_state())
}
card_fun <- function(comment, label) {
card <- teal::report_card_template(
title = "ANCOVA",
label = label,
description = "Analysis of Covariance",
with_filter = with_filter,
filter_panel_api = filter_panel_api
)
card$append_text("Table", "header3")
card$append_table(table_r())
if (!comment == "") {
Expand Down
Loading

0 comments on commit e5e8dae

Please sign in to comment.