Skip to content

[AUMC] Error in difftimes for second ICU stays #20

@prockenschaub

Description

@prockenschaub

AUMCdb, like eICU, does not provide dates but instead reports times since admission. For this reason, both databases are loaded in ricu via that load_eiau function.

Problem

The calculation of times -- while similar -- is not equal between eICU and AUMCdb. While in eICU times denote the number of minutes from unit admit time, in AUMCdb they represent milliseconds since the first ICU admission. That is, while eICU provides the time since current admission, AUMCdb gives the time since the first admission. load_eiau however treats them both the same, which leads to incorrect times for AUMCdb

Example

library(ricu)

# Two admissions for one patient. Note that the first admittedat is always 0, 
# whereas the second is relative to the first
aumc$admissions[aumc$admissions$patientid == 38, c("admissionid", "admittedat", "dischargedat")]
#>    admissionid admittedat dischargedat
#> 1:          40          0     56820000
#> 2:          41  164280000    325620000

# For heart rates during the first admission, everything works correctly
aumc$numericitems[aumc$numericitems$admissionid == 40 & aumc$numericitems$itemid == 6640, c("admissionid", "measuredat", "value")][1]
#>    admissionid measuredat value
#> 1:          40     300000    86
load_concepts("hr", "aumc", patient_ids = 40, interval = mins(1L))[1]
#>   admissionid measuredat    hr
#>         <int> <drtn>     <dbl>
#> 1          40 5 mins        86
ricu:::ms_as_mins(300000 - 0) # <-- correct
#> Time difference of 5 mins

# For heart rates during the second admission, ricu calculates difftimes since *first* admission 
aumc$numericitems[aumc$numericitems$admissionid == 41 & aumc$numericitems$itemid == 6640, c("admissionid", "measuredat", "value")][1]
#>    admissionid measuredat value
#> 1:          41  167280000   118
load_concepts("hr", "aumc", patient_ids = 41, interval = mins(1L))[1]
#>   admissionid measuredat    hr
#>         <int> <drtn>     <dbl>
#> 1          41 2788 mins    118
ricu:::ms_as_mins(167280000 - 0) # <-- incorrect
#> Time difference of 2788 mins
ricu:::ms_as_mins(167280000 - 164280000) # <-- should be this
#> Time difference of 50 mins

Note that the output above has been been shortened a little for readability.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions