Skip to content

Commit 4417494

Browse files
fix(mimic-iv): filter CRP to mg/L rows in inflammation concept
Itemid 50889 rows with missing valueuom are excluded; mg/L is the expected unit for C-reactive protein in hosp.labevents. Fixes #1922 Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent ce56b1b commit 4417494

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

mimic-iv/concepts/measurement/inflammation.sql

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,20 @@ SELECT
44
, MAX(charttime) AS charttime
55
, le.specimen_id
66
-- convert from itemid into a meaningful column
7-
, MAX(CASE WHEN itemid = 50889 THEN valuenum ELSE NULL END) AS crp
7+
, MAX(
8+
CASE
9+
WHEN itemid = 50889 AND valueuom = 'mg/L' THEN valuenum ELSE NULL
10+
END
11+
) AS crp
812
FROM `physionet-data.mimiciv_hosp.labevents` le
913
WHERE le.itemid IN
1014
(
1115
-- 51652 -- high sensitivity CRP
1216
50889 -- crp
1317
)
1418
AND valuenum IS NOT NULL
19+
-- CRP (50889) rows with missing valueuom are excluded; mg/L is the expected unit
20+
AND (itemid != 50889 OR valueuom = 'mg/L')
1521
-- lab values cannot be 0 and cannot be negative
1622
AND valuenum > 0
1723
GROUP BY le.specimen_id

0 commit comments

Comments
 (0)