eth-mds / ricu

🏥 ICU data with R 🏥
https://eth-mds.github.io/ricu/
GNU General Public License v3.0
34 stars 11 forks source link

Recursively passing arguments to lower-level concepts #18

Open prockenschaub opened 1 year ago

prockenschaub commented 1 year ago

Some callbacks rely on additional arguments depending on the database. For example, eICU does not contain reliable fluid sampling so sepsis definitions may need to be based on antibiotics alone. susp_inf allows to specify the si_mode parameter to do so.

library(ricu)
so <- load_concepts("sofa", "eicu_demo", verbose = FALSE)
si <- load_concepts("susp_inf", "eicu_demo", si_mode = "abx", verbose = FALSE)
se <- sep3(sofa = so, susp_inf = si)

This will lead to a different result than the default sepsis-3 calculation:

se_std <- load_concepts("sep3", "eicu_demo", verbose = FALSE)
setequal(se, se_std)
#> [1] FALSE

Problem

Currently, the above cannot be loaded directly

se_std <- load_concepts("sep3", "eicu_demo", verbose = FALSE)
setequal(se, se_std)
#> Error in `assert_that()`:
#> ! setequal(x = names(dots), y = concepts) is not TRUE

The reason for this is twofold:

  1. collect_dots currently only allows for concepts to be passed via ..., which leads to the above error when the sep3 callback is executed. I may be missing something here but to me this seems unnecessarily restrictive.
  2. Even if collect_dots accepted other parameters, those parameters would not be be passed down to the lower-level concepts.

https://github.com/eth-mds/ricu/blob/4a64d6bf9e94455ebaa599728b720ea33b599ab5/R/concept-load.R#L496-L498

(Potential) Solution

Change the behaviour of collect_dots and add ... to ext.

dplecko commented 6 months ago

I think this may be more complex than it seems; not sure how simple the fix is. We definitely need @nbenn to have a look at this.