Closed gemini-wenb closed 4 months ago
Good catch, thanks Bijun for implementing the fix! I tested it and it works as expected now. Just 2 small things:
- Could you add a note about the bug fix in
NEWS.md
?- We could potentially add a unit test like this (feel free to edit)?
testthat::test_that("Encounters with no frailty condition are returned with frailty = 0", { set.seed(2) cohort_dum <- data.table(genc_id=c(1), age=c(89)) ipdiag_dum <- dummy_diag(nid=1, nrow=10, ipdiagnosis=T, pattern ="A05$") # no frailty condition testthat::expect_warning(res <- frailty_score(cohort_dum, ipdiag_dum, NULL)) testthat::expect_equal(res$frailty_score_derived, c(0)) })
Thanks for reviewing @loffleraSMH and great suggestions! I've added the unit test and updated NEWS.md.
Thanks @gemini-wenb! Everything looks good now. Feel free to go ahead and merge this.
The function calculates frailty score as expected and assigns 0 to encounters without any frailty conditions. At the step of returning results, it calls the object without the rows with zero scores. This PR fixed the bug by calling the correct object to return.