Too many new ventilations in ventdurations
There are a lot of new ventilations added by the new ventdurations script (https://github.com/MIT-LCP/mimic-code/blob/master/etc/ventilation-durations.sql).
In a prior version of the script (https://github.com/MIT-LCP/mimic-code/blob/d23d5de5b768cb9ea7dd2fd13a6da85eb35e5e1c/etc/ventilation-durations.sql), we had this:
mimic=# select count(distinct icustay_id) mimic-# FROM ventdurations v mimic-# WHERE v.duration_hours > 0; count
26866
In the new version, we have a lot more:
mimic=# select count(distinct icustay_id) mimic-# FROM ventdurations_new v mimic-# WHERE v.duration_hours > 0; count
50353
So this issue primarily occurred because we added non-invasive ventilation and/or oxygen as a flag for extubation (i.e. if a patient is on oxygen, they have been extubated/are no longer on mechanical ventilation, this was done in commit https://github.com/MIT-LCP/mimic-code/commit/7abf1d1a125c4adea60f014d3c5dd6134685780d). However, the first instance of NIV/oxygen delivery resulted in a "0th" mechanical ventilation event, and this was treated as a valid duration even if the patient was never eventually ventilated. That's fixed now, but I'll leave this open for a bit as I'm going to do some edge case testing on the query.
The updates seem to have taken this down to a reasonable range:
mimic=# select count(distinct icustay_id) mimic-# FROM ventdurations v mimic-# WHERE v.duration_hours > 0; count
27707
Made another update to improve the precision, particularly around spontaneous breathing trials and extubations. Not much of a change in the total number of patients:
select count(distinct icustay_id) from ventdurations;
count
-------
26796
(1 row)
... but you should see a reduction in the number of on/off occurrences, i.e. there should be a lower number of longer duration ventilation events.