Skip to content

Commit 86a3515

Browse files
committed
moved changes to concepts
1 parent b1cdb21 commit 86a3515

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

mimic-iv/concepts/organfailure/kdigo_stages.sql

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ with cr_stg AS
2626
when cr.creat >= (cr.creat_low_past_48hr+0.3) then 1
2727
when cr.creat >= (cr.creat_low_past_7day*1.5) then 1
2828
else 0 end as aki_stage_creat
29-
FROM `physionet-data.mimiciv_derived.kdigo_creatinine` cr
29+
FROM `physionet-data.mimiciv_derived.kdigo_creatinine`
3030
)
3131
-- stages for UO / creat
3232
, uo_stg as
@@ -50,7 +50,7 @@ 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
5656
)
@@ -64,6 +64,16 @@ with cr_stg AS
6464
SELECT
6565
stay_id, charttime
6666
FROM uo_stg
67+
),
68+
-- get CRRT data
69+
crrt_stg AS (
70+
SELECT
71+
stay_id,
72+
charttime,
73+
CASE
74+
WHEN charttime IS NOT NULL THEN 3
75+
ELSE NULL END AS aki_stage_crrt
76+
FROM `physionet-data.mimic_derived.crrt`
6777
)
6878
select
6979
ie.subject_id
@@ -78,10 +88,12 @@ select
7888
, uo.uo_rt_12hr
7989
, uo.uo_rt_24hr
8090
, uo.aki_stage_uo
91+
, crrt.aki_stage_crrt
8192
-- Classify AKI using both creatinine/urine output criteria
8293
, GREATEST(
8394
COALESCE(cr.aki_stage_creat,0),
84-
COALESCE(uo.aki_stage_uo,0)
95+
COALESCE(uo.aki_stage_uo,0),
96+
COALESCE(crrt.aki_stage_crrt,0)
8597
) AS aki_stage
8698
FROM `physionet-data.mimiciv_icu.icustays` ie
8799
-- get all possible charttimes as listed in tm_stg
@@ -93,4 +105,7 @@ LEFT JOIN cr_stg cr
93105
LEFT JOIN uo_stg uo
94106
ON ie.stay_id = uo.stay_id
95107
AND tm.charttime = uo.charttime
108+
LEFT JOIN crrt_stg crrt
109+
ON ie.stay_id = crrt.stay_id
110+
AND tm.charttime = crrt.charttime
96111
;

mimic-iv/concepts_postgres/organfailure/kdigo_stages.sql

Lines changed: 2 additions & 17 deletions
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
)
@@ -66,16 +66,6 @@ with cr_stg AS
6666
SELECT
6767
stay_id, charttime
6868
FROM uo_stg
69-
),
70-
-- get CRRT data
71-
crrt_stg AS (
72-
SELECT
73-
stay_id,
74-
charttime,
75-
CASE
76-
WHEN charttime IS NOT NULL THEN 3
77-
ELSE NULL END AS aki_stage_crrt
78-
FROM mimic_derived.crrt
7969
)
8070
select
8171
ie.subject_id
@@ -90,12 +80,10 @@ select
9080
, uo.uo_rt_12hr
9181
, uo.uo_rt_24hr
9282
, uo.aki_stage_uo
93-
, crrt.aki_stage_crrt
9483
-- Classify AKI using both creatinine/urine output criteria
9584
, GREATEST(
9685
COALESCE(cr.aki_stage_creat,0),
97-
COALESCE(uo.aki_stage_uo,0),
98-
COALESCE(crrt.aki_stage_crrt,0)
86+
COALESCE(uo.aki_stage_uo,0)
9987
) AS aki_stage
10088
FROM mimiciv_icu.icustays ie
10189
-- get all possible charttimes as listed in tm_stg
@@ -107,7 +95,4 @@ LEFT JOIN cr_stg cr
10795
LEFT JOIN uo_stg uo
10896
ON ie.stay_id = uo.stay_id
10997
AND tm.charttime = uo.charttime
110-
LEFT JOIN crrt_stg crrt
111-
ON ie.stay_id = crrt.stay_id
112-
AND tm.charttime = crrt.charttime
11398
;

0 commit comments

Comments
 (0)