fix(mimic-iv): retain device-only rows in oxygen_delivery - #2071
Open
acnimma wants to merge 1 commit into
Open
Conversation
The FULL OUTER JOIN of O2 flow and delivery devices filtered with WHERE ce.rn = 1, which dropped rows where only a device (itemid 226732) was charted. Filter rn in ce_stg3 before the join so device-only rows are retained. Regenerate postgres and duckdb dialect copies. Fixes MIT-LCP#1570
Chessing234
reviewed
Jul 29, 2026
Chessing234
left a comment
Contributor
There was a problem hiding this comment.
the post-join where ce.rn = 1 was definitely nuking device-only rows from the full outer join — moving the rn filter into ce_stg3 first is the right shape. coalesce on subject/stay/charttime was already there so device-only keys should survive. if you haven't already, worth a quick count of rows where o2_flow is null but o2_delivery_device_1 isn't, before vs after.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
rnince_stg3before the FULL OUTER JOIN inoxygen_delivery.sqlWHERE ce.rn = 1ran after the joinTest plan
pytest tests/test_transpile.py -k oxygen_deliverypasses locallyoxygen_deliveryFULL OUTER JOINs O2 flow (ce_stg2) with delivery devices (o2, itemid 226732), then appliedWHERE ce.rn = 1. That filter drops rows whereceis NULL, so stays with device charting but no flow (e.g.stay_id = 30813912in #1570) never appear in the derived table. Move thern = 1filter intoce_stg3before the join so device-only rows are kept. Regenerate postgres and duckdb dialect copies from the BigQuery source.Fixes #1570