Skip to content

Commit 2bed3f4

Browse files
docs(mimic-iv-ed): sample query for early prescription starttimes
Illustrate hosp.prescriptions vs edstays.intime joins for #1910. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 7f3306b commit 2bed3f4

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
-- Flag hospital prescriptions near an ED stay whose starttime precedes intime.
2+
-- Join is intentionally loose (subject_id + hadm_id) — same caveat as #1910.
3+
4+
SELECT
5+
e.stay_id,
6+
e.intime,
7+
e.outtime,
8+
pr.starttime,
9+
pr.stoptime,
10+
pr.drug
11+
FROM ed.edstays AS e
12+
INNER JOIN hosp.prescriptions AS pr
13+
ON e.subject_id = pr.subject_id
14+
AND e.hadm_id IS NOT DISTINCT FROM pr.hadm_id
15+
WHERE pr.starttime < e.intime
16+
AND pr.starttime >= e.intime - INTERVAL '6 hours'
17+
ORDER BY e.stay_id, pr.starttime
18+
LIMIT 100;

0 commit comments

Comments
 (0)