Skip to content

Commit

Permalink
moved changes to concepts
Browse files Browse the repository at this point in the history
  • Loading branch information
aegis301 committed Jan 18, 2023
1 parent b1cdb21 commit 86a3515
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
21 changes: 18 additions & 3 deletions mimic-iv/concepts/organfailure/kdigo_stages.sql
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ with cr_stg AS
when cr.creat >= (cr.creat_low_past_48hr+0.3) then 1
when cr.creat >= (cr.creat_low_past_7day*1.5) then 1
else 0 end as aki_stage_creat
FROM `physionet-data.mimiciv_derived.kdigo_creatinine` cr
FROM `physionet-data.mimiciv_derived.kdigo_creatinine`
)
-- stages for UO / creat
, uo_stg as
Expand All @@ -50,7 +50,7 @@ with cr_stg AS
WHEN uo.uo_tm_12hr >= 5 AND uo.uo_rt_12hr < 0.5 THEN 2
WHEN uo.uo_tm_6hr >= 2 AND uo.uo_rt_6hr < 0.5 THEN 1
ELSE 0 END AS aki_stage_uo
from `physionet-data.mimiciv_derived.kdigo_uo` uo
FROM `physionet-data.mimiciv_derived.kdigo_uo` uo
INNER JOIN `physionet-data.mimiciv_icu.icustays` ie
ON uo.stay_id = ie.stay_id
)
Expand All @@ -64,6 +64,16 @@ with cr_stg AS
SELECT
stay_id, charttime
FROM uo_stg
),
-- get CRRT data
crrt_stg AS (
SELECT
stay_id,
charttime,
CASE
WHEN charttime IS NOT NULL THEN 3
ELSE NULL END AS aki_stage_crrt
FROM `physionet-data.mimic_derived.crrt`
)
select
ie.subject_id
Expand All @@ -78,10 +88,12 @@ select
, uo.uo_rt_12hr
, uo.uo_rt_24hr
, uo.aki_stage_uo
, crrt.aki_stage_crrt
-- Classify AKI using both creatinine/urine output criteria
, GREATEST(
COALESCE(cr.aki_stage_creat,0),
COALESCE(uo.aki_stage_uo,0)
COALESCE(uo.aki_stage_uo,0),
COALESCE(crrt.aki_stage_crrt,0)
) AS aki_stage
FROM `physionet-data.mimiciv_icu.icustays` ie
-- get all possible charttimes as listed in tm_stg
Expand All @@ -93,4 +105,7 @@ LEFT JOIN cr_stg cr
LEFT JOIN uo_stg uo
ON ie.stay_id = uo.stay_id
AND tm.charttime = uo.charttime
LEFT JOIN crrt_stg crrt
ON ie.stay_id = crrt.stay_id
AND tm.charttime = crrt.charttime
;
19 changes: 2 additions & 17 deletions mimic-iv/concepts_postgres/organfailure/kdigo_stages.sql
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ with cr_stg AS
WHEN uo.uo_tm_12hr >= 5 AND uo.uo_rt_12hr < 0.5 THEN 2
WHEN uo.uo_tm_6hr >= 2 AND uo.uo_rt_6hr < 0.5 THEN 1
ELSE 0 END AS aki_stage_uo
from mimiciv_derived.kdigo_uo uo
FROM mimiciv_derived.kdigo_uo uo
INNER JOIN mimiciv_icu.icustays ie
ON uo.stay_id = ie.stay_id
)
Expand All @@ -66,16 +66,6 @@ with cr_stg AS
SELECT
stay_id, charttime
FROM uo_stg
),
-- get CRRT data
crrt_stg AS (
SELECT
stay_id,
charttime,
CASE
WHEN charttime IS NOT NULL THEN 3
ELSE NULL END AS aki_stage_crrt
FROM mimic_derived.crrt
)
select
ie.subject_id
Expand All @@ -90,12 +80,10 @@ select
, uo.uo_rt_12hr
, uo.uo_rt_24hr
, uo.aki_stage_uo
, crrt.aki_stage_crrt
-- Classify AKI using both creatinine/urine output criteria
, GREATEST(
COALESCE(cr.aki_stage_creat,0),
COALESCE(uo.aki_stage_uo,0),
COALESCE(crrt.aki_stage_crrt,0)
COALESCE(uo.aki_stage_uo,0)
) AS aki_stage
FROM mimiciv_icu.icustays ie
-- get all possible charttimes as listed in tm_stg
Expand All @@ -107,7 +95,4 @@ LEFT JOIN cr_stg cr
LEFT JOIN uo_stg uo
ON ie.stay_id = uo.stay_id
AND tm.charttime = uo.charttime
LEFT JOIN crrt_stg crrt
ON ie.stay_id = crrt.stay_id
AND tm.charttime = crrt.charttime
;

0 comments on commit 86a3515

Please sign in to comment.