Skip to content

Commit 30c7bcc

Browse files
authored
Merge pull request #1461 from aegis301/kdigo-crrt
add crrt to kdigo concept
2 parents e1d2dae + d989055 commit 30c7bcc

File tree

2 files changed

+36
-16
lines changed

2 files changed

+36
-16
lines changed

mimic-iv/concepts/organfailure/kdigo_stages.sql

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,35 @@
33
-- Baseline creatinine is defined as the lowest creatinine in the past 7 days.
44

55
-- get creatinine stages
6-
with cr_stg AS
6+
WITH cr_stg AS
77
(
88
SELECT
99
cr.stay_id
1010
, cr.charttime
1111
, cr.creat_low_past_7day
1212
, cr.creat_low_past_48hr
1313
, cr.creat
14-
, case
14+
, CASE
1515
-- 3x baseline
16-
when cr.creat >= (cr.creat_low_past_7day*3.0) then 3
16+
WHEN cr.creat >= (cr.creat_low_past_7day*3.0) THEN 3
1717
-- *OR* cr >= 4.0 with associated increase
18-
when cr.creat >= 4
18+
WHEN cr.creat >= 4
1919
-- For patients reaching Stage 3 by SCr >4.0 mg/dl
2020
-- require that the patient first achieve ... acute increase >= 0.3 within 48 hr
2121
-- *or* an increase of >= 1.5 times baseline
22-
and (cr.creat_low_past_48hr <= 3.7 OR cr.creat >= (1.5*cr.creat_low_past_7day))
23-
then 3
22+
AND (cr.creat_low_past_48hr <= 3.7 OR cr.creat >= (1.5*cr.creat_low_past_7day))
23+
THEN 3
2424
-- TODO: initiation of RRT
25-
when cr.creat >= (cr.creat_low_past_7day*2.0) then 2
26-
when cr.creat >= (cr.creat_low_past_48hr+0.3) then 1
27-
when cr.creat >= (cr.creat_low_past_7day*1.5) then 1
28-
else 0 end as aki_stage_creat
25+
WHEN cr.creat >= (cr.creat_low_past_7day*2.0) THEN 2
26+
WHEN cr.creat >= (cr.creat_low_past_48hr+0.3) THEN 1
27+
WHEN cr.creat >= (cr.creat_low_past_7day*1.5) THEN 1
28+
ELSE 0 END AS aki_stage_creat
2929
FROM `physionet-data.mimiciv_derived.kdigo_creatinine` cr
3030
)
3131
-- stages for UO / creat
32-
, uo_stg as
32+
, uo_stg AS
3333
(
34-
select
34+
SELECT
3535
uo.stay_id
3636
, uo.charttime
3737
, uo.weight
@@ -50,9 +50,19 @@ with cr_stg AS
5050
WHEN uo.uo_tm_12hr >= 5 AND uo.uo_rt_12hr < 0.5 THEN 2
5151
WHEN uo.uo_tm_6hr >= 2 AND uo.uo_rt_6hr < 0.5 THEN 1
5252
ELSE 0 END AS aki_stage_uo
53-
from `physionet-data.mimiciv_derived.kdigo_uo` uo
53+
FROM `physionet-data.mimiciv_derived.kdigo_uo` uo
5454
INNER JOIN `physionet-data.mimiciv_icu.icustays` ie
5555
ON uo.stay_id = ie.stay_id
56+
),
57+
-- get CRRT data
58+
crrt_stg AS (
59+
SELECT
60+
stay_id,
61+
charttime,
62+
CASE
63+
WHEN charttime IS NOT NULL THEN 3
64+
ELSE NULL END AS aki_stage_crrt
65+
FROM `physionet-data.mimic_derived.crrt`
5666
)
5767
-- get all charttimes documented
5868
, tm_stg AS
@@ -64,8 +74,13 @@ with cr_stg AS
6474
SELECT
6575
stay_id, charttime
6676
FROM uo_stg
77+
UNION DISTINCT
78+
SELECT
79+
stay_id, charttime
80+
FROM crrt_stg
81+
6782
)
68-
select
83+
SELECT
6984
ie.subject_id
7085
, ie.hadm_id
7186
, ie.stay_id
@@ -78,10 +93,12 @@ select
7893
, uo.uo_rt_12hr
7994
, uo.uo_rt_24hr
8095
, uo.aki_stage_uo
96+
, crrt.aki_stage_crrt
8197
-- Classify AKI using both creatinine/urine output criteria
8298
, GREATEST(
8399
COALESCE(cr.aki_stage_creat,0),
84-
COALESCE(uo.aki_stage_uo,0)
100+
COALESCE(uo.aki_stage_uo,0),
101+
COALESCE(crrt.aki_stage_crrt,0)
85102
) AS aki_stage
86103
FROM `physionet-data.mimiciv_icu.icustays` ie
87104
-- get all possible charttimes as listed in tm_stg
@@ -93,4 +110,7 @@ LEFT JOIN cr_stg cr
93110
LEFT JOIN uo_stg uo
94111
ON ie.stay_id = uo.stay_id
95112
AND tm.charttime = uo.charttime
113+
LEFT JOIN crrt_stg crrt
114+
ON ie.stay_id = crrt.stay_id
115+
AND tm.charttime = crrt.charttime
96116
;

mimic-iv/concepts_postgres/organfailure/kdigo_stages.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ with cr_stg AS
5252
WHEN uo.uo_tm_12hr >= 5 AND uo.uo_rt_12hr < 0.5 THEN 2
5353
WHEN uo.uo_tm_6hr >= 2 AND uo.uo_rt_6hr < 0.5 THEN 1
5454
ELSE 0 END AS aki_stage_uo
55-
from mimiciv_derived.kdigo_uo uo
55+
FROM mimiciv_derived.kdigo_uo uo
5656
INNER JOIN mimiciv_icu.icustays ie
5757
ON uo.stay_id = ie.stay_id
5858
)

0 commit comments

Comments
 (0)