MIT-LCP / mimic-code

MIMIC Code Repository: Code shared by the research community for the MIMIC family of databases
https://mimic.mit.edu
MIT License
2.59k stars 1.52k forks source link

ICU stays seem to include other ward transfers #978

Closed JHLiu7 closed 3 years ago

JHLiu7 commented 3 years ago

Hi there! I have another question regarding the icustays table in MIMIC-IV in the context of ICU readmission.

When looking at hospital admissions with multiple ICU stays (ordered by intime), I noticed that the intime of every stay_id (starting from the second) is equal to the outtime of its prior stay_id within the same hadm_id group. This feels like it means a direct transfer from one ICU to another ICU. But when checking out the similar scenario in MIMIC-III, none of the >3k admissions that I found with multiple ICU stays has them concatenated with each other.

I wonder if that implies a different derivation strategy or definition for stay_id based on transfers in MIMIC-IV compared to MIMIC-III (icustay_id), or if it's just the difference in data. Thank you so much!

JHLiu7 commented 3 years ago

I guess here's an example of what puzzles me. I was looking at hadm_id=22415651 and could found three icu stays (35582965, 35797310, 36061570, ordered by intime), of which the first and second stays cover transfers to ICU and also Med/Surg/Trauma transfers (based on intime and outime). This is in contrast with the third one 36061570 that did not include the Med/Surg/Trauma transfer at the end. Is it because it's close to discharge? Just wondering how I should interpret them. It seems MIMIC-III instead only covers icu transfer for each icu stay. But correct me if I'm wrong! Thanks!

stefanhgm commented 3 years ago

Hi everyone!

I stumbled upon the same issue. Since I want to predict ICU readmissions for patients that were discharged to a lower level of care or home, this is critical for me. Just to add another (simplified) example for subject_id = 10002428

eventtype careunit intime outtime
admit Medicine 2000-01-01 12:00 2000-01-01 16:00
transfer MICU 2000-01-01 16:00 2000-01-05 16:00
transfer Medicine 2000-01-05 16:00 2000-01-09 16:00
transfer MICU 2000-01-09 16:00 2000-01-16 16:00
transfer Medicine 2000-01-16 16:00 2000-01-19 16:00
discharge 2000-01-19 16:00
Expected entries in icustays: first_careunit last_careunit intime outtime
MICU MICU 2000-01-01 16:00 2000-01-05 16:00
MICU MICU 2000-01-09 16:00 2000-01-16 16:00
Given entries in icustays: first_careunit last_careunit intime outtime
MICU MICU 2000-01-01 16:00 2000-01-09 16:00
MICU MICU 2000-01-09 16:00 2000-01-16 16:00

Just as @JHLiu7 mentioned the transfer to the medical ward between two ICU stays is included, but the stay at the end is not.

I found another artifact, where no entry is created in icustays at all. Consider the transfers for hadm_id=20009330. After the ED the patient is first admitted to Neuro SICU for only a couple of minutes, which might be the reason for ignoring it. However, the subsequent stay at MICU lasts for days and there is no corresponding entry in icustays. Is the code for generating icustays from the transfers table available somewhere?

alistairewj commented 3 years ago

Thank you for raising this issue @JHLiu7 and sorry I didn't respond in a timely manner. Thanks also @stefanhgm for the clear follow up. As mentioned in MIT-LCP/mimic-iv#11, there was a change between MIMIC-III and MIMIC-IV in the definition of an icustay_id, which we now call stay_id (to help distinguish it from MIMIC-III, and because eventually we will include stays outside the ICU and having a single identifier name for all of them will be convenient). We no longer merge together nearby ICU stays unless they are adjacent. In the case above described by @stefanhgm there is a stay in a medicine ward between the ICU stays, so we should not merge these into a single ICU stay. Of course you have all found cases where we do in fact merge over the interim stays. The logic I implemented is flawed and only works for the final ICU stay for a given hospitalization, so the ICU stay before an in-hospital ICU readmission will incorporate ward stays when it shouldn't. I implemented a fix for this that will be included the next version of MIMIC-IV.

stefanhgm commented 3 years ago

Thanks for the quick follow-up and the detailed explanation.

  1. Does this also explain the problem with the missing entry in icustays I added at the end of my previous comment?
  2. Is the code for generating icustays from the transfers table available somewhere?
  3. When do you plan to release the fix? Sorry for being impatient, but I need to figure out if its worth to implement my own routine to determine the stays for my experiments. From my experience, these selection routines are very error-prone and I'd rather re-use your code.
alistairewj commented 3 years ago

Thanks for the quick follow-up and the detailed explanation.

  1. Does this also explain the problem with the missing entry in icustays I added at the end of my previous comment?

Yes! Same issue.

  1. Is the code for generating icustays from the transfers table available somewhere?

Not publicly but I'll describe the rough process in the new release.

  1. When do you plan to release the fix? Sorry for being impatient, but I need to figure out if its worth to implement my own routine to determine the stays for my experiments. From my experience, these selection routines are very error-prone and I'd rather re-use your code.

Just being reviewed at PhysioNet - so pretty soon (within the month). Trying to clean up a few of the other issues around transfers/admissions/icustays being a little bit inconsistent.

alistairewj commented 3 years ago

This is now fixed in MIMIC-IV v1.0: https://mimic-iv.mit.edu/docs/overview/changelog/#mimic-iv-v10

For example the hadm_id you provided @stefanhgm -

select * from mimic_core.transfers where hadm_id = 28662225 order by intime
Row subject_id hadm_id transfer_id eventtype careunit
1 10002428 28662225 32007337 ED Emergency Department
2 10002428 28662225 38519116 admit Medicine
3 10002428 28662225 37824512 transfer Emergency Department Observation
4 10002428 28662225 33987268 transfer Medical Intensive Care Unit (MICU)
5 10002428 28662225 32875370 transfer Medicine
6 10002428 28662225 38875437 transfer Medical Intensive Care Unit (MICU)
7 10002428 28662225 30025354 transfer Medical Intensive Care Unit (MICU)
8 10002428 28662225 38277070 transfer Medical Intensive Care Unit (MICU)
9 10002428 28662225 31606213 transfer Medicine
10 10002428 28662225 37069433 discharge null

... is now properly associated with two ICU stays:

select * from mimic_icu.icustays where hadm_id = 28662225 order by intime
Row subject_id hadm_id stay_id first_careunit last_careunit
1 10002428 28662225 33987268 Medical Intensive Care Unit (MICU) Medical Intensive Care Unit (MICU)
2 10002428 28662225 38875437 Medical Intensive Care Unit (MICU) Medical Intensive Care Unit (MICU)

Note the stay_id is identical to the first transfer_id - this will always be the case when multiple transfers are merged into a single stay_id. Note though as there is no flexibility in the assignment, I've found cases where a 3 minute ward stay breaks up the stay_id (i.e. MICU -> Medicine for 3 minutes -> MICU results in distinct stay_id for the MICU stays). Just something to keep in mind!