Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions mimic-iv/concepts/measurement/vitalsign.sql
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,13 @@ SELECT
AND valuenum < 120
THEN (valuenum - 32) / 1.8
-- already in degC, no conversion necessary
WHEN itemid IN (223762)
-- includes core/blood temps (CCO) and Arctic Sun/Alsius temps
WHEN itemid IN (223762, 226329, 227632, 227634)
AND valuenum > 10
AND valuenum < 50
THEN valuenum END)
AS NUMERIC), 2) AS temperature
, MAX(CASE WHEN itemid = 224642 THEN value END
, MAX(CASE WHEN itemid IN (224642, 227630, 227631) THEN value END
) AS temperature_site
, AVG(CASE WHEN itemid IN (220277)
AND valuenum > 0
Expand Down Expand Up @@ -91,10 +92,14 @@ WHERE ce.stay_id IS NOT NULL
, 220621 -- Glucose (serum)
, 226537 -- Glucose (whole blood)
-- TEMPERATURE
-- 226329 -- Blood Temperature CCO (C)
, 226329 -- Blood Temperature CCO (C)
, 227632 -- Arctic Sun/Alsius Temp #1 C
, 227634 -- Arctic Sun/Alsius Temp #2 C
, 223762 -- "Temperature Celsius"
, 223761 -- "Temperature Fahrenheit"
, 224642 -- Temperature Site
, 227630 -- Arctic Sun Temp #1 Location
, 227631 -- Arctic Sun Temp #2 Location
)
GROUP BY ce.subject_id, ce.stay_id, ce.charttime
;
11 changes: 8 additions & 3 deletions mimic-iv/concepts_duckdb/measurement/vitalsign.sql
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ SELECT
THEN (
valuenum - 32
) / 1.8
WHEN itemid IN (223762) AND valuenum > 10 AND valuenum < 50
WHEN itemid IN (223762, 226329, 227632, 227634) AND valuenum > 10 AND valuenum < 50
THEN valuenum
END
) AS DECIMAL(38, 9)),
2
) AS temperature,
MAX(CASE WHEN itemid = 224642 THEN value END) AS temperature_site,
MAX(CASE WHEN itemid IN (224642, 227630, 227631) THEN value END) AS temperature_site,
AVG(
CASE WHEN itemid IN (220277) AND valuenum > 0 AND valuenum <= 100 THEN valuenum END
) AS spo2,
Expand All @@ -72,9 +72,14 @@ WHERE
225664,
220621,
226537,
226329,
227632,
227634,
223762,
223761,
224642
224642,
227630,
227631
)
GROUP BY
ce.subject_id,
Expand Down
17 changes: 12 additions & 5 deletions mimic-iv/concepts_postgres/measurement/vitalsign.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
-- THIS SCRIPT IS AUTOMATICALLY GENERATED. DO NOT EDIT IT DIRECTLY.
DROP TABLE IF EXISTS mimiciv_derived.vitalsign; CREATE TABLE mimiciv_derived.vitalsign AS
/* This query pivots the vital signs for the entire patient stay. */ /* The result is a tabler with stay_id, charttime, and various */ /* vital signs, with one row per charted time. */
/* This query pivots the vital signs for the entire patient stay. */
/* The result is a tabler with stay_id, charttime, and various */
/* vital signs, with one row per charted time. */
SELECT
ce.subject_id,
ce.stay_id,
Expand Down Expand Up @@ -42,13 +44,13 @@ SELECT
THEN CAST((
valuenum - 32
) AS DOUBLE PRECISION) / 1.8
WHEN itemid IN (223762) AND valuenum > 10 AND valuenum < 50
WHEN itemid IN (223762, 226329, 227632, 227634) AND valuenum > 10 AND valuenum < 50
THEN valuenum
END
) AS DECIMAL(38, 9)),
2
) AS temperature,
MAX(CASE WHEN itemid = 224642 THEN value END) AS temperature_site,
MAX(CASE WHEN itemid IN (224642, 227630, 227631) THEN value END) AS temperature_site,
AVG(
CASE WHEN itemid IN (220277) AND valuenum > 0 AND valuenum <= 100 THEN valuenum END
) AS spo2,
Expand All @@ -72,10 +74,15 @@ WHERE
220277, /* SPO2, peripheral */ /* GLUCOSE, both lab and fingerstick */
225664, /* Glucose finger stick */
220621, /* Glucose (serum) */
226537, /* Glucose (whole blood) */ /* TEMPERATURE */ /* 226329 -- Blood Temperature CCO (C) */
226537, /* Glucose (whole blood) */ /* TEMPERATURE */
226329, /* Blood Temperature CCO (C) */
227632, /* Arctic Sun/Alsius Temp #1 C */
227634, /* Arctic Sun/Alsius Temp #2 C */
223762, /* "Temperature Celsius" */
223761, /* "Temperature Fahrenheit" */
224642 /* Temperature Site */
224642, /* Temperature Site */
227630, /* Arctic Sun Temp #1 Location */
227631 /* Arctic Sun Temp #2 Location */
)
GROUP BY
ce.subject_id,
Expand Down