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.55k stars 1.51k forks source link

Ventilator duration inconsistent with charted data #618

Open SSMK-wq opened 5 years ago

SSMK-wq commented 5 years ago

Prerequisites

Description

Hello,

I was looking at the chartevents table for patients who were on ventilation. I was able to see that their ventilation duration was for example 100 hours but the PEEP and Fi02 readings are captured only for 2 days/48 hours.

For example subject_id = 1354 was in icu from 18th - 22nd but his/her PEEP/Fio2 readings were captured only till 19th in chartevents table.

Similarly subject_id = 78996

I see similar scenario for several other subjects. data is missing for several other subjects like this.

Is this expected or am I making any mistake? Please find the query that I tried. I understand it has lot of itemids but these were used for PEEP and Fi02. few may not be directly related. I was expecting to see the readings till 22nd. I mean for his full duration.

select min(charttime), max(charttime) from `physionet-data.mimiciii_clinical`.chartevents where subject_id = 1354 and icustay_id = 224934 and itemid in (1096, 505, 506, 60, 437, 3555, 8053,1227,686,5964,8345,8357,6349,6350,6985,7534,7802,7803,6489,6601, 6859,6889,6924, 6943,224699,224700,220339,1040,1206,185, 186,189,190,191,727,3420,3421,3422,1863, 5955,2518,2981,7018,7041,7570,8517,226754,227009,227010,160,727,3420,223835)

alistairewj commented 5 years ago

chartevents is the raw data, so this isn't a case of missing data. Rather this is a case of the derived view being incorrect for this icustay_id (224934). All the tables in the mimiciii_derived schema are calculated using code in this repository, e.g. the ventdurations code is here: https://github.com/MIT-LCP/mimic-code/blob/master/concepts/durations/ventilation-durations.sql

We've been working on an improvement to the ventilation durations to better handle oxygen therapy/non-invasive ventilation but haven't quite managed to push it out yet. If you have a list of the subjects where you think the query is incorrect I'd more than welcome you posting it here!

SSMK-wq commented 5 years ago

Just to make sure, I got it right. If you are asking me whether I can provide the list of subjects that has similar issue, then yes, I can provide the list

SSMK-wq commented 4 years ago

Am trying to get the above info. But can I also make sure that icustay_ids are not repeated for patients. If patient A has icustay_id = 21222(just an example), then no other patient can share the same icustay_id during throughout his encounter with the hospital?

alistairewj commented 4 years ago

Yes, that is correct.

alistairewj commented 4 years ago

Actually I just reviewed that patient and the query is working fine. The issue is you are including "Inspired O2 Fraction" as one of your items that indicate ventilation (itemid 223835), but the documentation of this item does not indicate a patient is mechanically ventilated.

SSMK-wq commented 4 years ago

Actually what I am trying to do is find out people who have been mechanically ventilated for 4 days or more and extract their baseline covariates (age,gender,ethnicity etc) along with PEEP and Fio2 values.

Just to make sure I got it right. Are you saying that people who are mechanically ventilated may not always have Fio2 captured?

Sorry, I might be wrong due to my limited knowledge with clinical research. But is it even possible to be MV but not have Fi02 captured? 223835 is itemid for Fi02

I was thinking that people who are MV will definitely have PEEP and Fio2 recorded?

Kindly request you to guide me on this. Anyway sharing the query what I wrote

Query

`with

vent as (SELECT distinct icustay_id from physionet-data.mimiciii_derived.ventdurations where icustay_id is not null and duration_hours >= 96),

icu as (select icustay_id, hadm_id,subject_id, gender,ethnicity,admission_age as age,intime,outtime,los_icu,los_hospital,hospital_expire_flag as expire_flag from physionet-data.mimiciii_derived.icustay_detail where admission_type in ('EMERGENCY','URGENT')),

pefi as (select subject_id,hadm_id,icustay_id,charttime,itemid, case when itemid in (60,437,505,506,686,220339,224700) then 'PEEP' ELSE 'Fi02/100' END AS item_name, value from physionet-data.mimiciii_clinical.chartevents where itemid in (223835,3420,160,727,60,437,505,506,686,220339,224700) and (error is null or error = 0))

select * from (select b.subject_id,b.hadm_id,a.icustay_id,b.age,b.gender,b.los_icu,b.los_hospital,c.charttime,c.itemid,c.item_name,c.value, DENSE_RANK() OVER (PARTITION BY b.subject_id ORDER BY b.subject_id,b.icustay_id asc) as rank from vent a inner join icu b using (icustay_id) inner join pefi c using (icustay_id) where b.age > 17 and b.los_icu > 3 order by b.subject_id) where rank = 1`

alistairewj commented 4 years ago

I don't think you can make the logic that simple since PEEP and FiO2 can be documented at the same time for patients who are not mechanically ventilated.

On Thu, Nov 7, 2019, 11:46 PM SSMK-wq notifications@github.com wrote:

Actually what I am trying to do is find out people who have been mechanically ventilated for 4 days or more and extract their baseline covariates (age,gender,ethnicity etc) along with PEEP and Fio2 values.

Just to make sure I got it right. You are saying that people who are mechanically ventilated may not always have Fio2 captured?

Because, I was thinking that people who are MV will definitely have PEEP and Fio2 recorded?

`with

vent as (SELECT distinct icustay_id from physionet-data.mimiciii_derived.ventdurations where icustay_id is not null and duration_hours >= 96),

icu as (select icustay_id, hadm_id,subject_id, gender,ethnicity,admission_age as age,intime,outtime,los_icu,los_hospital,hospital_expire_flag as expire_flag from physionet-data.mimiciii_derived.icustay_detail where admission_type in ('EMERGENCY','URGENT')),

pefi as (select subject_id,hadm_id,icustay_id,charttime,itemid, case when itemid in (60,437,505,506,686,220339,224700) then 'PEEP' ELSE 'Fi02/100' END AS item_name, value from physionet-data.mimiciii_clinical.chartevents where itemid in (223835,3420,160,727,60,437,505,506,686,220339,224700) and error <> 1)

select * from (select b.subject_id,b.hadm_id,a.icustay_id,b.age,b.gender,b.los_icu,b.los_hospital,c.charttime,c.itemid,c.item_name,c.value, DENSE_RANK() OVER (PARTITION BY b.subject_id ORDER BY b.subject_id,b.icustay_id asc) as rank from vent a inner join icu b using (icustay_id) inner join pefi c using (icustay_id) where b.age > 17 and b.los_icu > 3 order by b.subject_id) where rank = 1`

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/MIT-LCP/mimic-code/issues/618?email_source=notifications&email_token=AAJZE5FADLNPGCDKPQQ4FZTQSTVJFA5CNFSM4I3ENN22YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEDOW6AQ#issuecomment-551382786, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJZE5DIZTSWN36XOVE22YDQSTVJFANCNFSM4I3ENN2Q .

SSMK-wq commented 4 years ago

Hi,

Yes, I understand. But the issue here is person who are MV for say 100 hours, doesn't have PEEP and Fi02 captured for 100 hours but they have for say 28/30 hours. When in icu under MV, aren't these readings supposed to be captured for the full duration of MV? I only look for these readings among patients who have been MV as shown in my query above.

Thanks for patiently answering my query

alistairewj commented 4 years ago

No problem - which patient is MV for 100 hours with no FiO2/PEEP? You are right that it is extremely unlikely for that to happen.

SSMK-wq commented 4 years ago

The vent duration and readings captured are inconsistent. You can check for

a) subject_id = 27157 in icustay_id = 247368 - who has been in MV for more than 96 hours but has only one FiO2 reading and more than 80 PEEP readings.

b) subject_id = 9 or subject_id = 17352 or subject_id = 17259 - who is MV for more than 96 hours, we only see PEEP readings and he/she doesn't have Fi02 readings at all.

c) subject_id = 16770 and icustay_id = 202492 has only records for 2 days when he is MV for more than 96 hours (4 days)

d) subject_id = 2322 in icustay_id = 207672 - has only PEEP readings and no Fio2.

e) subject_id = 55921 in icustay_id = 286161 have break in their PEEP readings.

f) You can also try subject_id = 38 and icustay_id = 248910 who doesn't have Fio2/100 values at all. Instead I see it is coded as None, Frequent, rare etc

itemids used for Fio2/100 - 223835,3420,160,727

itemids used for PEEP - 60,437,505,506,686,220339,224700

Please note that I have used error is null or error = 0 in the query shared earlier to fetch valid records from chartevents

am I missing something here?

SSMK-wq commented 4 years ago

Hello @alistairewj , Did you get a chance to look at this?

SSMK-wq commented 4 years ago

Here is the full list from my datatset where I saw the difference in PEEP and Fio2 count. All these subjects were mechanically ventilated. So, I expect to see PEEP and Fio2 measurements for all these patients. But for some reason as shown in the list below, more than half of the dataset doesn't have Fio2/100 item.

I understand it's a huge list but just sharing it to help you debug

subject_id icustay_id Fi02/100 PEEP
9 220597 0 34
31 254478 0 45
36 211200 0 34
38 248910 403 159
94 213450 0 151
96 211943 0 110
101 233111 0 59
106 252051 0 40
117 217966 0 77
124 256064 144 155
santinon commented 6 months ago

Just can we argue the fact that the Fio2 measurements are very missing, right ? (both in mimic 3 and 4). Or did you get different results ?