Skip to content

Commit c51c46f

Browse files
Require positive epi/norepi rates for SOFA CV score 3
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 14bed76 commit c51c46f

12 files changed

Lines changed: 195 additions & 24 deletions

File tree

‎mimic-iii/concepts/pivot/pivoted_sofa.sql‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ WITH co AS
228228
-- Cardiovascular
229229
, cast(case
230230
when rate_dopamine > 15 or rate_epinephrine > 0.1 or rate_norepinephrine > 0.1 then 4
231-
when rate_dopamine > 5 or rate_epinephrine <= 0.1 or rate_norepinephrine <= 0.1 then 3
231+
when rate_dopamine > 5 or (rate_epinephrine > 0 and rate_epinephrine <= 0.1) or (rate_norepinephrine > 0 and rate_norepinephrine <= 0.1) then 3
232232
when rate_dopamine > 0 or rate_dobutamine > 0 then 2
233233
when meanbp_min < 70 then 1
234234
when coalesce(meanbp_min, rate_dopamine, rate_dobutamine, rate_epinephrine, rate_norepinephrine) is null then null

‎mimic-iii/concepts/severityscores/sofa.sql‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ left join `physionet-data.mimiciii_derived.gcs_first_day` gcs
218218
-- Cardiovascular
219219
, case
220220
when rate_dopamine > 15 or rate_epinephrine > 0.1 or rate_norepinephrine > 0.1 then 4
221-
when rate_dopamine > 5 or rate_epinephrine <= 0.1 or rate_norepinephrine <= 0.1 then 3
221+
when rate_dopamine > 5 or (rate_epinephrine > 0 and rate_epinephrine <= 0.1) or (rate_norepinephrine > 0 and rate_norepinephrine <= 0.1) then 3
222222
when rate_dopamine > 0 or rate_dobutamine > 0 then 2
223223
when meanbp_min < 70 then 1
224224
when coalesce(meanbp_min, rate_dopamine, rate_dobutamine, rate_epinephrine, rate_norepinephrine) is null then null

‎mimic-iii/concepts_duckdb/pivot/pivoted_sofa.sql‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,13 @@ WITH co AS (
175175
CAST(CASE
176176
WHEN rate_dopamine > 15 OR rate_epinephrine > 0.1 OR rate_norepinephrine > 0.1
177177
THEN 4
178-
WHEN rate_dopamine > 5 OR rate_epinephrine <= 0.1 OR rate_norepinephrine <= 0.1
178+
WHEN rate_dopamine > 5
179+
OR (
180+
rate_epinephrine > 0 AND rate_epinephrine <= 0.1
181+
)
182+
OR (
183+
rate_norepinephrine > 0 AND rate_norepinephrine <= 0.1
184+
)
179185
THEN 3
180186
WHEN rate_dopamine > 0 OR rate_dobutamine > 0
181187
THEN 2

‎mimic-iii/concepts_duckdb/severityscores/sofa.sql‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,13 @@ WITH wt AS (
186186
CASE
187187
WHEN rate_dopamine > 15 OR rate_epinephrine > 0.1 OR rate_norepinephrine > 0.1
188188
THEN 4
189-
WHEN rate_dopamine > 5 OR rate_epinephrine <= 0.1 OR rate_norepinephrine <= 0.1
189+
WHEN rate_dopamine > 5
190+
OR (
191+
rate_epinephrine > 0 AND rate_epinephrine <= 0.1
192+
)
193+
OR (
194+
rate_norepinephrine > 0 AND rate_norepinephrine <= 0.1
195+
)
190196
THEN 3
191197
WHEN rate_dopamine > 0 OR rate_dobutamine > 0
192198
THEN 2

‎mimic-iii/concepts_postgres/pivot/pivoted_sofa.sql‎

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,36 @@
11
-- THIS SCRIPT IS AUTOMATICALLY GENERATED. DO NOT EDIT IT DIRECTLY.
22
DROP TABLE IF EXISTS mimiciii_derived.pivoted_sofa; CREATE TABLE mimiciii_derived.pivoted_sofa AS
3-
/* ------------------------------------------------------------------ */ /* Title: Sequential Organ Failure Assessment (SOFA) */ /* This query extracts the sequential organ failure assessment (formally: sepsis-related organ failure assessment). */ /* This score is a measure of organ failure for patients in the ICU. */ /* The score is calculated for every hour of the patient's ICU stay. */ /* However, as the calculation window is 24 hours, care should be taken when */ /* using the score before the end of the first day. */ /* ------------------------------------------------------------------ */ /* Reference for SOFA: */ /* Jean-Louis Vincent, Rui Moreno, Jukka Takala, Sheila Willatts, Arnaldo De Mendonça, */ /* Hajo Bruining, C. K. Reinhart, Peter M Suter, and L. G. Thijs. */ /* "The SOFA (Sepsis-related Organ Failure Assessment) score to describe organ dysfunction/failure." */ /* Intensive care medicine 22, no. 7 (1996): 707-710. */ /* Variables used in SOFA: */ /* GCS, MAP, FiO2, Ventilation status (sourced FROM `physionet-data.mimiciii_clinical.chartevents`) */ /* Creatinine, Bilirubin, FiO2, PaO2, Platelets (sourced FROM `physionet-data.mimiciii_clinical.labevents`) */ /* Dopamine, Dobutamine, Epinephrine, Norepinephrine (sourced FROM `physionet-data.mimiciii_clinical.inputevents_mv` and INPUTEVENTS_CV) */ /* Urine output (sourced from OUTPUTEVENTS) */ /* The following views required to run this query: */ /* 1) pivoted_bg_art - generated by pivoted-bg.sql */ /* 2) pivoted_uo - generated by pivoted-uo.sql */ /* 3) pivoted_lab - generated by pivoted-lab.sql */ /* 4) pivoted_gcs - generated by pivoted-gcs.sql */ /* 5) ventilation_durations - generated by ../durations/ventilation_durations.sql */ /* 6) norepinephrine_dose - generated by ../durations/norepinephrine-dose.sql */ /* 7) epinephrine_dose - generated by ../durations/epinephrine-dose.sql */ /* 8) dopamine_dose - generated by ../durations/dopamine-dose.sql */ /* 9) dobutamine_dose - generated by ../durations/dobutamine-dose.sql */ /* Note: */ /* The score is calculated for only adult ICU patients, */ /* generate a row for every hour the patient was in the ICU */
3+
/* ------------------------------------------------------------------ */
4+
/* Title: Sequential Organ Failure Assessment (SOFA) */
5+
/* This query extracts the sequential organ failure assessment (formally: sepsis-related organ failure assessment). */
6+
/* This score is a measure of organ failure for patients in the ICU. */
7+
/* The score is calculated for every hour of the patient's ICU stay. */
8+
/* However, as the calculation window is 24 hours, care should be taken when */
9+
/* using the score before the end of the first day. */
10+
/* ------------------------------------------------------------------ */
11+
/* Reference for SOFA: */
12+
/* Jean-Louis Vincent, Rui Moreno, Jukka Takala, Sheila Willatts, Arnaldo De Mendonça, */
13+
/* Hajo Bruining, C. K. Reinhart, Peter M Suter, and L. G. Thijs. */
14+
/* "The SOFA (Sepsis-related Organ Failure Assessment) score to describe organ dysfunction/failure." */
15+
/* Intensive care medicine 22, no. 7 (1996): 707-710. */
16+
/* Variables used in SOFA: */
17+
/* GCS, MAP, FiO2, Ventilation status (sourced FROM `physionet-data.mimiciii_clinical.chartevents`) */
18+
/* Creatinine, Bilirubin, FiO2, PaO2, Platelets (sourced FROM `physionet-data.mimiciii_clinical.labevents`) */
19+
/* Dopamine, Dobutamine, Epinephrine, Norepinephrine (sourced FROM `physionet-data.mimiciii_clinical.inputevents_mv` and INPUTEVENTS_CV) */
20+
/* Urine output (sourced from OUTPUTEVENTS) */
21+
/* The following views required to run this query: */
22+
/* 1) pivoted_bg_art - generated by pivoted-bg.sql */
23+
/* 2) pivoted_uo - generated by pivoted-uo.sql */
24+
/* 3) pivoted_lab - generated by pivoted-lab.sql */
25+
/* 4) pivoted_gcs - generated by pivoted-gcs.sql */
26+
/* 5) ventilation_durations - generated by ../durations/ventilation_durations.sql */
27+
/* 6) norepinephrine_dose - generated by ../durations/norepinephrine-dose.sql */
28+
/* 7) epinephrine_dose - generated by ../durations/epinephrine-dose.sql */
29+
/* 8) dopamine_dose - generated by ../durations/dopamine-dose.sql */
30+
/* 9) dobutamine_dose - generated by ../durations/dobutamine-dose.sql */
31+
/* Note: */
32+
/* The score is calculated for only adult ICU patients, */
33+
/* generate a row for every hour the patient was in the ICU */
434
WITH co AS (
535
SELECT
636
ih.icustay_id,
@@ -144,7 +174,9 @@ WITH co AS (
144174
AND co.endtime > dob.starttime
145175
AND co.endtime <= dob.endtime
146176
), scorecalc AS (
147-
/* Calculate the final score */ /* note that if the underlying data is missing, the component is null */ /* eventually these are treated as 0 (normal), but knowing when data is missing is useful for debugging */
177+
/* Calculate the final score */
178+
/* note that if the underlying data is missing, the component is null */
179+
/* eventually these are treated as 0 (normal), but knowing when data is missing is useful for debugging */
148180
SELECT
149181
scorecomp.*, /* Respiration */
150182
CAST(CASE
@@ -189,7 +221,13 @@ WITH co AS (
189221
CAST(CASE
190222
WHEN rate_dopamine > 15 OR rate_epinephrine > 0.1 OR rate_norepinephrine > 0.1
191223
THEN 4
192-
WHEN rate_dopamine > 5 OR rate_epinephrine <= 0.1 OR rate_norepinephrine <= 0.1
224+
WHEN rate_dopamine > 5
225+
OR (
226+
rate_epinephrine > 0 AND rate_epinephrine <= 0.1
227+
)
228+
OR (
229+
rate_norepinephrine > 0 AND rate_norepinephrine <= 0.1
230+
)
193231
THEN 3
194232
WHEN rate_dopamine > 0 OR rate_dobutamine > 0
195233
THEN 2

‎mimic-iii/concepts_postgres/severityscores/sofa.sql‎

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,32 @@
11
-- THIS SCRIPT IS AUTOMATICALLY GENERATED. DO NOT EDIT IT DIRECTLY.
22
DROP TABLE IF EXISTS mimiciii_derived.sofa; CREATE TABLE mimiciii_derived.sofa AS
3-
/* ------------------------------------------------------------------ */ /* Title: Sequential Organ Failure Assessment (SOFA) */ /* This query extracts the sequential organ failure assessment (formally: sepsis-related organ failure assessment). */ /* This score is a measure of organ failure for patients in the ICU. */ /* The score is calculated on the first day of each ICU patients' stay. */ /* ------------------------------------------------------------------ */ /* Reference for SOFA: */ /* Jean-Louis Vincent, Rui Moreno, Jukka Takala, Sheila Willatts, Arnaldo De Mendonça, */ /* Hajo Bruining, C. K. Reinhart, Peter M Suter, and L. G. Thijs. */ /* "The SOFA (Sepsis-related Organ Failure Assessment) score to describe organ dysfunction/failure." */ /* Intensive care medicine 22, no. 7 (1996): 707-710. */ /* Variables used in SOFA: */ /* GCS, MAP, FiO2, Ventilation status (sourced FROM `physionet-data.mimiciii_clinical.chartevents`) */ /* Creatinine, Bilirubin, FiO2, PaO2, Platelets (sourced FROM `physionet-data.mimiciii_clinical.labevents`) */ /* Dobutamine, Epinephrine, Norepinephrine (sourced FROM `physionet-data.mimiciii_clinical.inputevents_mv` and INPUTEVENTS_CV) */ /* Urine output (sourced from OUTPUTEVENTS) */ /* The following views required to run this query: */ /* 1) urine_output_first_day - generated by urine-output-first-day.sql */ /* 2) vitals_first_day - generated by vitals-first-day.sql */ /* 3) gcs_first_day - generated by gcs-first-day.sql */ /* 4) labs_first_day - generated by labs-first-day.sql */ /* 5) blood_gas_first_day_arterial - generated by blood-gas-first-day-arterial.sql */ /* 6) echodata - generated by echo-data.sql */ /* 7) ventilation_durations - generated by ventilation_durations.sql */ /* Note: */ /* The score is calculated for *all* ICU patients, with the assumption that the user will subselect appropriate ICUSTAY_IDs. */ /* For example, the score is calculated for neonates, but it is likely inappropriate to actually use the score values for these patients. */
3+
/* ------------------------------------------------------------------ */
4+
/* Title: Sequential Organ Failure Assessment (SOFA) */
5+
/* This query extracts the sequential organ failure assessment (formally: sepsis-related organ failure assessment). */
6+
/* This score is a measure of organ failure for patients in the ICU. */
7+
/* The score is calculated on the first day of each ICU patients' stay. */
8+
/* ------------------------------------------------------------------ */
9+
/* Reference for SOFA: */
10+
/* Jean-Louis Vincent, Rui Moreno, Jukka Takala, Sheila Willatts, Arnaldo De Mendonça, */
11+
/* Hajo Bruining, C. K. Reinhart, Peter M Suter, and L. G. Thijs. */
12+
/* "The SOFA (Sepsis-related Organ Failure Assessment) score to describe organ dysfunction/failure." */
13+
/* Intensive care medicine 22, no. 7 (1996): 707-710. */
14+
/* Variables used in SOFA: */
15+
/* GCS, MAP, FiO2, Ventilation status (sourced FROM `physionet-data.mimiciii_clinical.chartevents`) */
16+
/* Creatinine, Bilirubin, FiO2, PaO2, Platelets (sourced FROM `physionet-data.mimiciii_clinical.labevents`) */
17+
/* Dobutamine, Epinephrine, Norepinephrine (sourced FROM `physionet-data.mimiciii_clinical.inputevents_mv` and INPUTEVENTS_CV) */
18+
/* Urine output (sourced from OUTPUTEVENTS) */
19+
/* The following views required to run this query: */
20+
/* 1) urine_output_first_day - generated by urine-output-first-day.sql */
21+
/* 2) vitals_first_day - generated by vitals-first-day.sql */
22+
/* 3) gcs_first_day - generated by gcs-first-day.sql */
23+
/* 4) labs_first_day - generated by labs-first-day.sql */
24+
/* 5) blood_gas_first_day_arterial - generated by blood-gas-first-day-arterial.sql */
25+
/* 6) echodata - generated by echo-data.sql */
26+
/* 7) ventilation_durations - generated by ventilation_durations.sql */
27+
/* Note: */
28+
/* The score is calculated for *all* ICU patients, with the assumption that the user will subselect appropriate ICUSTAY_IDs. */
29+
/* For example, the score is calculated for neonates, but it is likely inappropriate to actually use the score values for these patients. */
430
WITH wt AS (
531
SELECT
632
ie.icustay_id, /* ensure weight is measured in kg */
@@ -115,7 +141,9 @@ WITH wt AS (
115141
bg.icustay_id NULLS FIRST,
116142
bg.charttime NULLS FIRST
117143
), pafi2 AS (
118-
/* because pafi has an interaction between vent/PaO2:FiO2, we need two columns for the score */ /* it can happen that the lowest unventilated PaO2/FiO2 is 68, but the lowest ventilated PaO2/FiO2 is 120 */ /* in this case, the SOFA score is 3, *not* 4. */
144+
/* because pafi has an interaction between vent/PaO2:FiO2, we need two columns for the score */
145+
/* it can happen that the lowest unventilated PaO2/FiO2 is 68, but the lowest ventilated PaO2/FiO2 is 120 */
146+
/* in this case, the SOFA score is 3, *not* 4. */
119147
SELECT
120148
icustay_id,
121149
MIN(CASE WHEN isvent = 0 THEN pao2fio2 ELSE NULL END) AS pao2fio2_novent_min,
@@ -154,7 +182,9 @@ WITH wt AS (
154182
LEFT JOIN mimiciii_derived.gcs_first_day AS gcs
155183
ON ie.icustay_id = gcs.icustay_id
156184
), scorecalc AS (
157-
/* Calculate the final score */ /* note that if the underlying data is missing, the component is null */ /* eventually these are treated as 0 (normal), but knowing when data is missing is useful for debugging */
185+
/* Calculate the final score */
186+
/* note that if the underlying data is missing, the component is null */
187+
/* eventually these are treated as 0 (normal), but knowing when data is missing is useful for debugging */
158188
SELECT
159189
icustay_id, /* Respiration */
160190
CASE
@@ -199,7 +229,13 @@ WITH wt AS (
199229
CASE
200230
WHEN rate_dopamine > 15 OR rate_epinephrine > 0.1 OR rate_norepinephrine > 0.1
201231
THEN 4
202-
WHEN rate_dopamine > 5 OR rate_epinephrine <= 0.1 OR rate_norepinephrine <= 0.1
232+
WHEN rate_dopamine > 5
233+
OR (
234+
rate_epinephrine > 0 AND rate_epinephrine <= 0.1
235+
)
236+
OR (
237+
rate_norepinephrine > 0 AND rate_norepinephrine <= 0.1
238+
)
203239
THEN 3
204240
WHEN rate_dopamine > 0 OR rate_dobutamine > 0
205241
THEN 2

‎mimic-iv/concepts/firstday/first_day_sofa.sql‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ WITH vaso_stg AS (
196196
OR rate_norepinephrine > 0.1
197197
THEN 4
198198
WHEN rate_dopamine > 5
199-
OR rate_epinephrine <= 0.1
200-
OR rate_norepinephrine <= 0.1
199+
OR (rate_epinephrine > 0 AND rate_epinephrine <= 0.1)
200+
OR (rate_norepinephrine > 0 AND rate_norepinephrine <= 0.1)
201201
THEN 3
202202
WHEN rate_dopamine > 0 OR rate_dobutamine > 0 THEN 2
203203
WHEN mbp_min < 70 THEN 1

‎mimic-iv/concepts/score/sofa.sql‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,8 @@ WITH co AS (
280280
OR rate_norepinephrine > 0.1
281281
THEN 4
282282
WHEN rate_dopamine > 5
283-
OR rate_epinephrine <= 0.1
284-
OR rate_norepinephrine <= 0.1
283+
OR (rate_epinephrine > 0 AND rate_epinephrine <= 0.1)
284+
OR (rate_norepinephrine > 0 AND rate_norepinephrine <= 0.1)
285285
THEN 3
286286
WHEN rate_dopamine > 0
287287
OR rate_dobutamine > 0

‎mimic-iv/concepts_duckdb/firstday/first_day_sofa.sql‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,13 @@ WITH vaso_stg AS (
150150
CASE
151151
WHEN rate_dopamine > 15 OR rate_epinephrine > 0.1 OR rate_norepinephrine > 0.1
152152
THEN 4
153-
WHEN rate_dopamine > 5 OR rate_epinephrine <= 0.1 OR rate_norepinephrine <= 0.1
153+
WHEN rate_dopamine > 5
154+
OR (
155+
rate_epinephrine > 0 AND rate_epinephrine <= 0.1
156+
)
157+
OR (
158+
rate_norepinephrine > 0 AND rate_norepinephrine <= 0.1
159+
)
154160
THEN 3
155161
WHEN rate_dopamine > 0 OR rate_dobutamine > 0
156162
THEN 2

‎mimic-iv/concepts_duckdb/score/sofa.sql‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,13 @@ WITH co AS (
240240
CASE
241241
WHEN rate_dopamine > 15 OR rate_epinephrine > 0.1 OR rate_norepinephrine > 0.1
242242
THEN 4
243-
WHEN rate_dopamine > 5 OR rate_epinephrine <= 0.1 OR rate_norepinephrine <= 0.1
243+
WHEN rate_dopamine > 5
244+
OR (
245+
rate_epinephrine > 0 AND rate_epinephrine <= 0.1
246+
)
247+
OR (
248+
rate_norepinephrine > 0 AND rate_norepinephrine <= 0.1
249+
)
244250
THEN 3
245251
WHEN rate_dopamine > 0 OR rate_dobutamine > 0
246252
THEN 2

0 commit comments

Comments
 (0)