mimic-code icon indicating copy to clipboard operation
mimic-code copied to clipboard

MIMIC-IV get death_in_hosp variable

Open marinaperezs opened this issue 1 year ago • 1 comments

Hi everyone !

I'm working with MIMIC-IV 2.0 and I need to get a new column called death_in_hosp. This new column is binary and it should have a 1 if the patient died during a hospital admission (in icu or not) and a 0 if the patient didn't die during a hospital admission. I have another column called death_in_icu which has a 1 if the patient died during an icu stay and a 0 otherwise, so this new column should be different, it doesn't matter if the death occurred during an icu admission or not.

I have tried to do it using the fields deathtime, dischtime and admittime from the table physionet-data.mimiciv_hosp.patients because these are not linked to an icu stay but to a hospital admission, but I cannot get it, so any help would be appreciated !!!

Thank you so much !!! :)

marinaperezs avatar Sep 30 '22 07:09 marinaperezs

Hi Marina,

The changelog of the official project page seems to describe exactly what you want:

patients

dod is now populated with out-of-hospital mortality from state death records. For patients admitted to the ICU, this change has increased capture of date of death from 8,223 records to 23,844 (i.e. we now have out-of-hospital mortality for an additional 15,621 ICU patients).

I believe the documentation page might be confusing as it does not describe the changes past version 1.0.

To answer your question, the you can look at the dischtime in conjunction with dod to determine whether the patient has died in hospital. If you're working with postgres, the following query should do the trick:

WITH last_admission AS (
    SELECT MAX(dischtime) as dischtime, subject_id
    FROM mimiciv_hosp.admissions
    GROUP BY (subject_id)
)

SELECT patients.subject_id, (
        CASE
            WHEN dischtime IS NOT NULL and dod IS NOT NULL THEN DATE(dischtime) = dod
        ELSE false  -- You can change this to NULL if you want NULLs for subjects for which death in hospital can't be confirmed 
        END
    ) AS died_in_hospital
FROM mimiciv_hosp.patients
INNER JOIN last_admission ON patients.subject_id = last_admission.subject_id

marceliwac avatar Oct 03 '22 20:10 marceliwac