|
1 | 1 | -- THIS SCRIPT IS AUTOMATICALLY GENERATED. DO NOT EDIT IT DIRECTLY. |
2 | 2 | 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. */ |
4 | 30 | WITH wt AS ( |
5 | 31 | SELECT |
6 | 32 | ie.icustay_id, /* ensure weight is measured in kg */ |
@@ -115,7 +141,9 @@ WITH wt AS ( |
115 | 141 | bg.icustay_id NULLS FIRST, |
116 | 142 | bg.charttime NULLS FIRST |
117 | 143 | ), 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. */ |
119 | 147 | SELECT |
120 | 148 | icustay_id, |
121 | 149 | MIN(CASE WHEN isvent = 0 THEN pao2fio2 ELSE NULL END) AS pao2fio2_novent_min, |
@@ -154,7 +182,9 @@ WITH wt AS ( |
154 | 182 | LEFT JOIN mimiciii_derived.gcs_first_day AS gcs |
155 | 183 | ON ie.icustay_id = gcs.icustay_id |
156 | 184 | ), 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 */ |
158 | 188 | SELECT |
159 | 189 | icustay_id, /* Respiration */ |
160 | 190 | CASE |
@@ -199,7 +229,13 @@ WITH wt AS ( |
199 | 229 | CASE |
200 | 230 | WHEN rate_dopamine > 15 OR rate_epinephrine > 0.1 OR rate_norepinephrine > 0.1 |
201 | 231 | 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 | + ) |
203 | 239 | THEN 3 |
204 | 240 | WHEN rate_dopamine > 0 OR rate_dobutamine > 0 |
205 | 241 | THEN 2 |
|
0 commit comments