fix(mimic-iii): do not bridge paused vasopressor gaps - #2121
Conversation
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 MIT-LCP#1808
Chessing234
left a comment
There was a problem hiding this comment.
nice catch on the linkorderid collapse — that paused gap example (~6h) really shouldn't get glued into one interval. leaving vasomv_grp to merge only contiguous/overlapping bits feels like the right split. maybe worth a one-liner in the test plan for a non-paused contiguous pair still merging, just so nobody regresses that later.
|
not bridging paused vaso gaps is the right clinical call. can you cite the duration threshold you used in the pr description? |
|
keeping paused gaps as separate intervals matches the raw inputevents_mv semantics better than collapsing on linkorderid. can you add a short comment in the sql citing the paused-gap example so future edits dont reintroduce the group by? |
Chessing234
left a comment
There was a problem hiding this comment.
dropping the linkorderid min/max collapse is the right fix for paused vaso gaps — contiguous merge in vasomv_grp still covers true overlaps. mirrored across dialects which is what this repo needs. a one-line comment in the postgres/duckdb copies pointing at #1808 (like the bq file already has) would help the next reader.
|
Addressing the review notes:
|
Chessing234
left a comment
There was a problem hiding this comment.
two things here, one mechanical and one i'd like your read on.
the postgres copy doesn't match what the transpiler produces. i ran the repo's own transpiler (sqlglot 30.11.0 from requirements-lock) over your bigquery source and diffed against mimic-iii/concepts_postgres/durations/vasopressor_durations.sql as committed on this branch: sqlglot renders your four-line comment as a run of separate /* ... */ fragments on one line, but the branch has a single hand-written /* keep each MetaVision interval; do not bridge Paused gaps via linkorderid (#1808) */. the duckdb copy is byte-identical to transpiler output, so it's only the postgres file. running the same check against main returns identical for this file, so the drift starts in this branch. the generated-up-to-date job in transpile.yml diffs that folder against transpiler output, and the file header says not to edit it directly.
on the substance — i think not bridging paused gaps is the right call, but as written the query has no threshold at all despite the "duration threshold / behavior" heading. vasomv_grp only merges where s1.starttime <= t1.endtime, so once the linkorderid grouping is gone, two rows of the same order separated by one second become two separate durations. #1808's median gap of ~1h11m establishes that the paused gaps are large; it doesn't establish that small ones are absent. could you post the distribution of gaps between consecutive rows within a linkorderid — specifically how many fall under a few minutes? if there's a tail of sub-minute charting gaps then this needs a tolerance rather than zero, and that's also the number that would let the two unchecked boxes in your test plan be checked.
separately, worth calling out explicitly: the carevue branch above keeps its own gap handling, so after this change the same output table carries two different definitions of when an interval breaks depending on which system the stay came from. a line in the sql or the pr body would help anyone unioning the two.
Summary
GROUP BY linkorderid+min/maxtimesinputevents_mvrow as its own interval;vasomv_grpstill merges contiguous/overlapping intervalsWhy
vasopressor_durationsgrouped MetaVision rows bylinkorderidand tookmin(starttime)/max(endtime). That is correct when successive rows abut, but afterstatusdescription = 'Paused'there is often a multi-hour gap (examplelinkorderid = 8781494, ~6h; see #1808, median ~1h 11m). Bridging that gap overstates vasopressor exposure.Duration threshold / behavior
linkorderid)vasomv_grpTest plan
GROUP BY linkorderidremains invasomvlinkorderid = 8781494(Paused gap ~6h) yields separate durations, not one bridged intervalvasomv_grpFixes #1808