Skip to content

Commit 7d72fef

Browse files
committed
rerun convert shell script to incorporate round/cast changes
1 parent f66606f commit 7d72fef

File tree

8 files changed

+34
-28
lines changed

8 files changed

+34
-28
lines changed

mimic-iv/concepts/postgres/demographics/icustay_detail.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ SELECT ie.subject_id, ie.hadm_id, ie.stay_id
1818

1919
-- icu level factors
2020
, ie.intime as icu_intime, ie.outtime as icu_outtime
21-
, ROUND( CAST( DATETIME_DIFF(ie.outtime, ie.intime, 'HOUR')/24.0 as numeric), 2) as los_icu
21+
, ROUND(CAST(DATETIME_DIFF(ie.outtime, ie.intime, 'HOUR')/24.0 AS NUMERIC), 2) as los_icu
2222
, DENSE_RANK() OVER (PARTITION BY ie.hadm_id ORDER BY ie.intime) AS icustay_seq
2323

2424
-- first ICU stay *for the current hospitalization*

mimic-iv/concepts/postgres/firstday/first_day_height.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ WITH ce AS
2323
SELECT
2424
ie.subject_id
2525
, ie.stay_id
26-
, ROUND( CAST( AVG(height) as numeric), 2) AS height
26+
, ROUND(CAST(AVG(height) AS NUMERIC), 2) AS height
2727
FROM mimiciv_icu.icustays ie
2828
LEFT JOIN mimiciv_derived.height ht
2929
ON ie.stay_id = ht.stay_id

mimic-iv/concepts/postgres/measurement/blood_differential.sql

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,31 +96,31 @@ subject_id, hadm_id, charttime, specimen_id
9696

9797
, wbc
9898
-- impute absolute count if percentage & WBC is available
99-
, ROUND( CAST( CASE
99+
, ROUND(CAST(CASE
100100
WHEN basophils_abs IS NULL AND basophils IS NOT NULL AND impute_abs = 1
101101
THEN basophils * wbc / 100
102102
ELSE basophils_abs
103-
END as numeric), 4) AS basophils_abs
104-
, ROUND( CAST( CASE
103+
END AS NUMERIC), 4) AS basophils_abs
104+
, ROUND(CAST(CASE
105105
WHEN eosinophils_abs IS NULL AND eosinophils IS NOT NULL AND impute_abs = 1
106106
THEN eosinophils * wbc / 100
107107
ELSE eosinophils_abs
108-
END as numeric), 4) AS eosinophils_abs
109-
, ROUND( CAST( CASE
108+
END AS NUMERIC), 4) AS eosinophils_abs
109+
, ROUND(CAST(CASE
110110
WHEN lymphocytes_abs IS NULL AND lymphocytes IS NOT NULL AND impute_abs = 1
111111
THEN lymphocytes * wbc / 100
112112
ELSE lymphocytes_abs
113-
END as numeric), 4) AS lymphocytes_abs
114-
, ROUND( CAST( CASE
113+
END AS NUMERIC), 4) AS lymphocytes_abs
114+
, ROUND(CAST(CASE
115115
WHEN monocytes_abs IS NULL AND monocytes IS NOT NULL AND impute_abs = 1
116116
THEN monocytes * wbc / 100
117117
ELSE monocytes_abs
118-
END as numeric), 4) AS monocytes_abs
119-
, ROUND( CAST( CASE
118+
END AS NUMERIC), 4) AS monocytes_abs
119+
, ROUND(CAST(CASE
120120
WHEN neutrophils_abs IS NULL AND neutrophils IS NOT NULL AND impute_abs = 1
121121
THEN neutrophils * wbc / 100
122122
ELSE neutrophils_abs
123-
END as numeric), 4) AS neutrophils_abs
123+
END AS NUMERIC), 4) AS neutrophils_abs
124124

125125
, basophils
126126
, eosinophils

mimic-iv/concepts/postgres/measurement/height.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ WITH ht_in AS
66
SELECT
77
c.subject_id, c.stay_id, c.charttime
88
-- Ensure that all heights are in centimeters
9-
, ROUND( CAST( c.valuenum * 2.54 as numeric), 2) AS height
9+
, ROUND(CAST(c.valuenum * 2.54 AS NUMERIC), 2) AS height
1010
, c.valuenum as height_orig
1111
FROM mimiciv_icu.chartevents c
1212
WHERE c.valuenum IS NOT NULL
@@ -18,7 +18,7 @@ WITH ht_in AS
1818
SELECT
1919
c.subject_id, c.stay_id, c.charttime
2020
-- Ensure that all heights are in centimeters
21-
, ROUND( CAST( c.valuenum as numeric), 2) AS height
21+
, ROUND(CAST(c.valuenum AS NUMERIC), 2) AS height
2222
FROM mimiciv_icu.chartevents c
2323
WHERE c.valuenum IS NOT NULL
2424
-- Height cm

mimic-iv/concepts/postgres/measurement/urine_output_rate.sql

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ select
7979
, ur.urineoutput_6hr
8080
, ur.urineoutput_12hr
8181
, ur.urineoutput_24hr
82-
, CASE WHEN uo_tm_6hr >= 6 THEN ROUND( CAST( CAST((ur.urineoutput_6hr/wd.weight/uo_tm_6hr) AS NUMERIC) as numeric), 4) END AS uo_mlkghr_6hr
83-
, CASE WHEN uo_tm_12hr >= 12 THEN ROUND( CAST( CAST((ur.urineoutput_12hr/wd.weight/uo_tm_12hr) AS NUMERIC) as numeric), 4) END AS uo_mlkghr_12hr
84-
, CASE WHEN uo_tm_24hr >= 24 THEN ROUND( CAST( CAST((ur.urineoutput_24hr/wd.weight/uo_tm_24hr) AS NUMERIC) as numeric), 4) END AS uo_mlkghr_24hr
82+
, CASE WHEN uo_tm_6hr >= 6 THEN ROUND(CAST((ur.urineoutput_6hr/wd.weight/uo_tm_6hr) AS NUMERIC), 4) END AS uo_mlkghr_6hr
83+
, CASE WHEN uo_tm_12hr >= 12 THEN ROUND(CAST((ur.urineoutput_12hr/wd.weight/uo_tm_12hr) AS NUMERIC), 4) END AS uo_mlkghr_12hr
84+
, CASE WHEN uo_tm_24hr >= 24 THEN ROUND(CAST((ur.urineoutput_24hr/wd.weight/uo_tm_24hr) AS NUMERIC), 4) END AS uo_mlkghr_24hr
8585
-- time of earliest UO measurement that was used to calculate the rate
86-
, ROUND( CAST( uo_tm_6hr as numeric), 2) AS uo_tm_6hr
87-
, ROUND( CAST( uo_tm_12hr as numeric), 2) AS uo_tm_12hr
88-
, ROUND( CAST( uo_tm_24hr as numeric), 2) AS uo_tm_24hr
86+
, ROUND(CAST(uo_tm_6hr AS NUMERIC), 2) AS uo_tm_6hr
87+
, ROUND(CAST(uo_tm_12hr AS NUMERIC), 2) AS uo_tm_12hr
88+
, ROUND(CAST(uo_tm_24hr AS NUMERIC), 2) AS uo_tm_24hr
8989
from ur_stg ur
9090
LEFT JOIN mimiciv_derived.weight_durations wd
9191
ON ur.stay_id = wd.stay_id

mimic-iv/concepts/postgres/measurement/vitalsign.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ select
1414
, AVG(case when itemid = 220180 and valuenum > 0 and valuenum < 300 then valuenum else null end) as dbp_ni
1515
, AVG(case when itemid = 220181 and valuenum > 0 and valuenum < 300 then valuenum else null end) as mbp_ni
1616
, AVG(case when itemid in (220210,224690) and valuenum > 0 and valuenum < 70 then valuenum else null end) as resp_rate
17-
, ROUND( CAST(
17+
, ROUND(CAST(
1818
AVG(case when itemid in (223761) and valuenum > 70 and valuenum < 120 then (valuenum-32)/1.8 -- converted to degC in valuenum call
1919
when itemid in (223762) and valuenum > 10 and valuenum < 50 then valuenum else null end)
20-
as numeric), 2) as temperature
20+
AS NUMERIC), 2) as temperature
2121
, MAX(CASE WHEN itemid = 224642 THEN value ELSE NULL END) AS temperature_site
2222
, AVG(case when itemid in (220277) and valuenum > 0 and valuenum <= 100 then valuenum else null end) as spo2
2323
, AVG(case when itemid in (225664,220621,226537) and valuenum > 0 then valuenum else null end) as glucose

mimic-iv/concepts/postgres/medication/norepinephrine_equivalent_dose.sql

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@ DROP TABLE IF EXISTS norepinephrine_equivalent_dose; CREATE TABLE norepinephrine
55
-- by Goradia et al. 2020.
66
SELECT stay_id, starttime, endtime
77
-- calculate the dose
8-
, ROUND( CAST( COALESCE(norepinephrine, 0)
8+
, ROUND(CAST(
9+
COALESCE(norepinephrine, 0)
910
+ COALESCE(epinephrine, 0)
1011
+ COALESCE(phenylephrine/10, 0)
1112
+ COALESCE(dopamine/100, 0)
1213
-- + metaraminol/8 -- metaraminol not used in BIDMC
1314
+ COALESCE(vasopressin*2.5, 0)
1415
-- angotensin_ii*10 -- angitensin ii rarely used, currently not incorporated
1516
-- (it could be included due to norepinephrine sparing effects)
16-
as numeric), 4) AS norepinephrine_equivalent_dose
17+
AS NUMERIC), 4) AS norepinephrine_equivalent_dose
1718
-- angotensin_ii*10 -- angitensin ii rarely used, currently not incorporated
1819
-- (it could be included due to norepinephrine sparing effects)
1920
FROM mimiciv_derived.vasoactive_agent

mimic-iv/concepts/postgres/postgres-make-concepts.sql

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
\i measurement/coagulation.sql
2626
\i measurement/complete_blood_count.sql
2727
\i measurement/creatinine_baseline.sql
28+
\i measurement/differential_detailed.sql
2829
\i measurement/enzyme.sql
2930
\i measurement/gcs.sql
3031
\i measurement/height.sql
@@ -49,8 +50,6 @@
4950
\i medication/norepinephrine.sql
5051
\i medication/phenylephrine.sql
5152
\i medication/vasopressin.sql
52-
\i medication/vasoactive_agent.sql
53-
\i medication/norepinephrine_equivalent_dose.sql
5453

5554
-- treatment
5655
\i treatment/crrt.sql
@@ -71,7 +70,6 @@
7170

7271
-- organfailure
7372
\i organfailure/kdigo_creatinine.sql
74-
\i organfailure/kdigo_stages.sql
7573
\i organfailure/meld.sql
7674

7775
-- score
@@ -85,6 +83,13 @@
8583
-- sepsis
8684
\i sepsis/suspicion_of_infection.sql
8785

88-
-- final tables dependent on previous concepts
86+
-- final tables which were dependent on one or more prior tables
87+
\i demographics/icustay_times.sql
88+
\i demographics/weight_durations.sql
89+
\i measurement/urine_output.sql
90+
\i organfailure/kdigo_uo.sql
91+
\i organfailure/kdigo_stages.sql
8992
\i firstday/first_day_sofa.sql
9093
\i sepsis/sepsis3.sql
94+
\i medication/vasoactive_agent.sql
95+
\i medication/norepinephrine_equivalent_dose.sql

0 commit comments

Comments
 (0)