[minimal reproducible example] that demonstrates the incorrect behaviour in the function above:
cwf = disability(admdad, ipdiag, erdiag )
cwt = disability(admdad, ipdiag, erdiag, component_wise = T )
## number of unique encounters do not match up.
lunique(cwf[disability==T,]$genc_id)
lunique(cwt$genc_id) #extra encounters when component_wise=T
Please list (if known), any impact to research projects, or internal tools/processes:
The function identifies disability status correctly
The extra encounters returned when component_wise=T are attributed to presence of encounters in ip/er-diagnoisis table but are NOT in the admdad (or user input cohort).
This bug should not have substantial impact because in most use case, users would left-join the results to their cohort, which will yield correct identification of disability status.
Suggested fix:
This bug can be fixed by restricting output genc_id to only those found in the input cohort, just like how it is done when component_wise is set to False:
For the developer: Once the bug is resolved, please add the reproducible example above as a test in the tests/testthat directory.
Please identify the affected function:
disability()
[minimal reproducible example] that demonstrates the incorrect behaviour in the function above:
Please list (if known), any impact to research projects, or internal tools/processes:
Suggested fix: This bug can be fixed by restricting output genc_id to only those found in the input cohort, just like how it is done when component_wise is set to False:
For the developer: Once the bug is resolved, please add the reproducible example above as a test in the
tests/testthat
directory.Any suggested developers?
Any suggested reviewers?
*