Closed VoyagerWSH closed 2 years ago
There are definitely a few inconsistencies in the ED stay data which are just due to the nature of the environment. It's hard to come up with a fixed reason as it varies: sometimes patients are "admitted" to the ED for observation, sometimes they leave the ED and come back, sometimes there are two registrations, etc etc. Never found a consistent reason for multiple ED stays corresponding to the same hospitalization (if we did, we would have made it simpler!).
Two questions: Should the
stay_id
for these examples be updated to be the very firsttransfer_id
?
It would be possible but I'm not sure you would fix more problems than you introduce. We did experiment with this before releasing the data. It's much much more straightforward with ICU patients, because (1) they move units far less frequently, and (2) their transfers are often simply bed changes rather than room changes.
More broadly is our intuition --- that a
hadm_id
should be associated with at most onestay_id
, which can then correspond to multipletransfer_ids
--- correct?
Yes, that's correct. stay_id
will only correspond to multiple transfer_id
for ICU stays. I can actually give you the logic that was used in the icustays table:
...
-- create a flag indicating if this is a new stay
-- flag == 1 if it's the first transfer into an ICU
, CASE
-- if this row follows an ICU stay, *and* it's also an icu stay
-- then set it to 0, so we do not flag it as a new ICU stay
-- ultimately, we will group this row with the prior rows into a single stay
WHEN s.is_icu = 1 AND LAG(s.is_icu) OVER fn = 1 THEN 0
-- otherwise, set the flag to 1 if it's an icu (is_icu),
-- *or* if the row is directly following an ICU stay (LAG()) - this ends the prior ICU stay
ELSE s.is_icu + COALESCE(LAG(s.is_icu) OVER fn, 0)
END AS icu_flag
...
, SUM(icu_flag) OVER (PARTITION BY hadm_id ORDER BY intime) AS icu_partition
...
, FIRST_VALUE(transfer_id) OVER w AS stay_id
...
WINDOW w AS (
PARTITION BY hadm_id, icu_partition
ORDER BY intime
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
)
We don't use this logic in the edstays table, so there's no grouping of stay_id
there.
I see. We might just drop all the hadm_id
that are mapped to multiple stay_id
for our analysis. Thanks for your explanation!
Prerequisites
Description
In the
edstays
table of MIMIC-IV-ED_v2.0, we find that, for a given patient, multiple unique stay_id map to the samehadm_id
. Precisely, there are 600 uniquehadm_id
that had more than one unique stay_id associated with it.As an example,
hadm_id
21436543 has the following three stay_id linked to it: 30523998, 32093485, and 33998754. We have inspectedhadm_id
21436543 intransfers.csv.gz
, and it shows that this patient has transferred three times in ED before being admitted, creating three uniquetransfer_id
that are exactly the same as the threestay_id
. Here are some code that one can use to reproduce this result:We have one idea for what might be going on. The documentation of the transfer table states that “the
stay_id
present in theicustays
andedstays
tables is derived from transfer_id. For example, three contiguous ICU stays will have three separatetransfer_id
for each distinct physical location (e.g. a patient could move from one bed to another). The entire stay will have a singlestay_id
, which will be equal to thetransfer_id
of the first physical location.”Two questions: Should the
stay_id
for these examples be updated to be the very firsttransfer_id
? More broadly is our intuition --- that ahadm_id
should be associated with at most onestay_id
, which can then correspond to multipletransfer_ids
--- correct?Thanks!