insightsengineering / teal.reporter

Create and preview reports with Shiny modules
https://insightsengineering.github.io/teal.reporter/
Other
8 stars 9 forks source link

[Feature Request]: Include user's card labels when generating the report #198

Closed anajens closed 9 months ago

anajens commented 11 months ago

Feature description

It would be helpful if the user's card labels are included in the report because the default module labels (eg "summary table") are too general.
Screen Shot 2023-08-02 at 11 28 48 AM

Code of Conduct

Contribution Guidelines

Security Policy

m7pr commented 9 months ago

@anajens would be able to provide some more context? Are you using any online app hosted on shinyapps? Is this some local code? Could you upload the code so I can reproduce the behavior?

Report labels are often hardcoded by card_fun in teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun) where you can specify what is added to appended text card$append_text("Your custom text", "header2") once the card on the module is added.

To get custom labels be passed to a report card I think we should start changing the behavior in here https://github.com/insightsengineering/teal.reporter/blob/4fa942ec6c8c72f466505b969244c7a70d7e9f28/R/AddCardModule.R#L83

anajens commented 9 months ago

Hi @m7pr thanks for taking a look this!

This issue was from the last round of teal apps UAT and I used the safety app. You can reproduce this example with the current version: https://genentech.shinyapps.io/nest_safety_main/

In a nutshell, I think if the user takes the time to create meaningful labels for each card added to the report they should not be removed when the report is generated.

m7pr commented 9 months ago

Thanks @anajens . For now I think the Card Names/Labels are just use in Reporter Preview module, but each card takes the content directly from how the module specified report content.

m7pr commented 9 months ago

Ok, I see it now. For teal.modules.clinical modules there are specific card_funs that set a specific report card title, no matter what the provided card name is https://github.com/search?q=repo%3Ainsightsengineering%2Fteal.modules.clinical%20set_name&type=code

m7pr commented 9 months ago

To make your requested change we would need to

  1. extend the implementation of card_fun in add_card_button_srv
  2. edit all teal.modules.clinical and teal.modules.general modules so that they have default card label and appended text, but if the card name/label is provided, then those should be overwritten by provided card name/label
  3. update all vignettes and examples
  4. decide the best behavior for 2.
    • e.g. the default card label can be filled for the user in Add Card module, depending on what module was used to generate the Report Card, so that user knows there are some default values

I think I will need to double check with the team on how to proceed