insightsengineering / tern

Table, Listings, and Graphs (TLG) library for common outputs used in clinical trials
https://insightsengineering.github.io/tern/
Other
77 stars 22 forks source link

refactor `summarize_change` function, #1345

Closed shajoezhu closed 3 weeks ago

shajoezhu commented 4 weeks ago

Rationale:

Issue was identified via updating the lbt03 template in scda.test using pharamverseadam data,

https://github.com/insightsengineering/scda.test/pull/153/files#diff-612b47e07d81651ea501f536e8b1e59b19e5018ba14f7cfe1efe13544df8620c

zero was reported, after some investigation, we found out in recent admiral, there was a change to set CHG to NA for baseline values, discussion was tracked in https://github.com/pharmaverse/admiral/issues/2484

For lbt03 table, the summary statistics should be based on baseline AVAL values for baseline section, but for other visits in AVISIT, use CHG values, baseline values are flagged via baseline_flag: ABLFL

TODO:

  1. update summarize_change function
  2. update a_change_from_baseline function, better handle NA, can preprocess them to zeros
  3. adding test cases, allow CHG input to be NA
Melkiades commented 3 weeks ago

The LBT03 template is the result of a junction between the analysis of AVAL at baseline and CHG at visit time. AVAL is summarized for baseline visits and and CHG is summarized for post-baseline visits.