Skip to content

Errors in the charttime or stayid of chartevens #1961

Open

Description

@zheng523

I used the following code to explore whether there are any chartevents that happened after ICU stay:

SELECT 
ce.stay_id,
ce.charttime, 
ce.itemid,
ie.intime,
ie.outtime,
EXTRACT(EPOCH FROM (ce.charttime - ie.outtime))/3600/24 AS days_diff
FROM mimiciv_icu.chartevents AS ce
LEFT JOIN mimiciv_icu.icustays AS ie
ON ce.stay_id = ie.stay_id
WHERE ce.charttime > ie.outtime
ORDER BY days_diff DESC;

To my surprise, there are 407966 records of chartevents that happened after ICU stay. Some of them happened many days or even years after ICU outtime. Compare to the 432997491 records of all chartevents, they are not too many though. How did it happen?

Activity

  1. chessing234 commented on Jul 19, 2026

    @chessing234
    Contributor

    charttime after outtime shows up a lot in the raw data — usually late charting / device data, not a stay_id join bug. if you need in-icu only, filter charttime between intime and outtime.

  2. chessing234 commented on Jul 31, 2026

    @chessing234
    Contributor

    opened docs + audit queries in #2151 — charttime after outtime is common late charting / device clocks, not usually a stay_id join bug. filter explicitly if you need in-icu only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions