Downgrading the ID from icustay to patient leads to incorrect negative times.
x <- load_concepts('death', 'mimic_demo')
x
#> # A `ts_tbl`: 40 β 3
#> # Id var: `icustay_id`
#> # Index var: `index_var` (1 hours)
#> icustay_id index_var death
#> <int> <drtn> <lgl>
#> 1 201006 151 hours TRUE
#> ...
change_id(x, 'subject_id', 'mimic_demo')[icustay_id == 201006]
#> # An `id_tbl`: 1 β 4
#> # Id var: `subject_id`
#> subject_id icustay_id index_var death
#> <int> <int> <drtn> <lgl>
#> 1 10076 201006 -36212946 mins TRUE
The above should be positive, as it would otherwise imply negative lifetime. I believe the issue is the following substraction in change_id_helper, which works fine for upgrade_id but is incorrect for downgrade_id.
Downgrading the ID from
icustay
topatient
leads to incorrect negative times.The above should be positive, as it would otherwise imply negative lifetime. I believe the issue is the following substraction in
change_id_helper
, which works fine forupgrade_id
but is incorrect fordowngrade_id
.https://github.com/eth-mds/ricu/blob/9e76c074250046da93870063c3b7ed57d274b790/R/data-utils.R#L753
For
downgrade_id
, this should be an addition.