Skip to content

Commit 0b7287d

Browse files
committed
fix(mimic-iii): do not bridge paused vasopressor gaps
MetaVision vasopressor_durations collapsed rows by linkorderid with min(starttime)/max(endtime). After a Paused status that leaves a gap (median ~1h), that incorrectly counted the pause as infusion time. Keep each inputevents_mv row as its own interval; vasomv_grp still merges contiguous/overlapping intervals. Fixes #1808
1 parent 780de1c commit 0b7287d

3 files changed

Lines changed: 13 additions & 21 deletions

File tree

mimic-iii/concepts/durations/vasopressor_durations.sql

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ with io_cv as
4040
, io_mv as
4141
(
4242
select
43-
icustay_id, linkorderid, starttime, endtime
43+
icustay_id, starttime, endtime
4444
FROM `physionet-data.mimiciii_clinical.inputevents_mv` io
4545
-- Subselect the vasopressor ITEMIDs
4646
where itemid in
@@ -259,15 +259,17 @@ WHERE NOT EXISTS(SELECT * FROM vasocv s2
259259
GROUP BY s1.icustay_id, s1.starttime
260260
ORDER BY s1.icustay_id, s1.starttime
261261
)
262-
-- now we extract the associated data for metavision patients
263-
-- do not need to group by itemid because we group by linkorderid
262+
-- MetaVision rows: keep each order interval as-is.
263+
-- Do not collapse by linkorderid: Paused rows often leave multi-hour gaps
264+
-- before the next row of the same linkorderid (#1808). vasomv_grp still
265+
-- merges contiguous/overlapping intervals afterward.
264266
, vasomv as
265267
(
266268
select
267-
icustay_id, linkorderid
268-
, min(starttime) as starttime, max(endtime) as endtime
269+
icustay_id
270+
, starttime
271+
, endtime
269272
from io_mv
270-
group by icustay_id, linkorderid
271273
)
272274
, vasomv_grp as
273275
(

mimic-iii/concepts_duckdb/durations/vasopressor_durations.sql

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ WITH io_cv AS (
3030
), io_mv AS (
3131
SELECT
3232
icustay_id,
33-
linkorderid,
3433
starttime,
3534
endtime
3635
FROM mimiciii.inputevents_mv AS io
@@ -166,13 +165,9 @@ WITH io_cv AS (
166165
), vasomv AS (
167166
SELECT
168167
icustay_id,
169-
linkorderid,
170-
MIN(starttime) AS starttime,
171-
MAX(endtime) AS endtime
168+
starttime,
169+
endtime
172170
FROM io_mv
173-
GROUP BY
174-
icustay_id,
175-
linkorderid
176171
), vasomv_grp AS (
177172
SELECT
178173
s1.icustay_id,

mimic-iii/concepts_postgres/durations/vasopressor_durations.sql

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ WITH io_cv AS (
3131
), io_mv /* select only the ITEMIDs from the inputevents_mv table related to vasopressors */ AS (
3232
SELECT
3333
icustay_id,
34-
linkorderid,
3534
starttime,
3635
endtime
3736
FROM mimiciii.inputevents_mv AS io
@@ -169,16 +168,12 @@ WITH io_cv AS (
169168
ORDER BY
170169
s1.icustay_id NULLS FIRST,
171170
s1.starttime NULLS FIRST
172-
), vasomv /* now we extract the associated data for metavision patients */ /* do not need to group by itemid because we group by linkorderid */ AS (
171+
), vasomv /* keep each MetaVision interval; do not bridge Paused gaps via linkorderid (#1808) */ AS (
173172
SELECT
174173
icustay_id,
175-
linkorderid,
176-
MIN(starttime) AS starttime,
177-
MAX(endtime) AS endtime
174+
starttime,
175+
endtime
178176
FROM io_mv
179-
GROUP BY
180-
icustay_id,
181-
linkorderid
182177
), vasomv_grp AS (
183178
SELECT
184179
s1.icustay_id,

0 commit comments

Comments
 (0)