Skip to content

Commit e61e312

Browse files
authored
Merge pull request #1200 from MIT-LCP/bg_fix
bg fix
2 parents ccb6972 + d5c1939 commit e61e312

File tree

1 file changed

+3
-25
lines changed
  • mimic-iv/concepts/measurement

1 file changed

+3
-25
lines changed

mimic-iv/concepts/measurement/bg.sql

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ select
1111
-- specimen_id *may* have different storetimes, so this is taking the latest
1212
, MAX(storetime) AS storetime
1313
, le.specimen_id
14-
, MAX(CASE WHEN itemid = 52028 THEN value ELSE NULL END) AS specimen
14+
, MAX(CASE WHEN itemid = 52033 THEN value ELSE NULL END) AS specimen
1515
, MAX(CASE WHEN itemid = 50801 THEN valuenum ELSE NULL END) AS aado2
1616
, MAX(CASE WHEN itemid = 50802 THEN valuenum ELSE NULL END) AS baseexcess
1717
, MAX(CASE WHEN itemid = 50803 THEN valuenum ELSE NULL END) AS bicarbonate
@@ -48,7 +48,7 @@ FROM mimic_hosp.labevents le
4848
where le.ITEMID in
4949
-- blood gases
5050
(
51-
52028 -- specimen
51+
52033 -- specimen
5252
, 50801 -- aado2
5353
, 50802 -- base excess
5454
, 50803 -- bicarb
@@ -127,22 +127,6 @@ where bg.po2 is not null
127127
select bg.*
128128
, ROW_NUMBER() OVER (partition by bg.subject_id, bg.charttime order by s2.charttime DESC) as lastRowFiO2
129129
, s2.fio2_chartevents
130-
-- create our specimen prediction
131-
, 1/(1+exp(-(-0.02544
132-
+ 0.04598 * po2
133-
+ coalesce(-0.15356 * spo2 , -0.15356 * 97.49420 + 0.13429)
134-
+ coalesce( 0.00621 * fio2_chartevents , 0.00621 * 51.49550 + -0.24958)
135-
+ coalesce( 0.10559 * hemoglobin , 0.10559 * 10.32307 + 0.05954)
136-
+ coalesce( 0.13251 * so2 , 0.13251 * 93.66539 + -0.23172)
137-
+ coalesce(-0.01511 * pco2 , -0.01511 * 42.08866 + -0.01630)
138-
+ coalesce( 0.01480 * fio2 , 0.01480 * 63.97836 + -0.31142)
139-
+ coalesce(-0.00200 * aado2 , -0.00200 * 442.21186 + -0.01328)
140-
+ coalesce(-0.03220 * bicarbonate , -0.03220 * 22.96894 + -0.06535)
141-
+ coalesce( 0.05384 * totalco2 , 0.05384 * 24.72632 + -0.01405)
142-
+ coalesce( 0.08202 * lactate , 0.08202 * 3.06436 + 0.06038)
143-
+ coalesce( 0.10956 * ph , 0.10956 * 7.36233 + -0.00617)
144-
+ coalesce( 0.00848 * o2flow , 0.00848 * 7.59362 + -0.35803)
145-
))) as specimen_prob
146130
from stg2 bg
147131
left join stg_fio2 s2
148132
-- same patient
@@ -156,14 +140,8 @@ select
156140
stg3.subject_id
157141
, stg3.hadm_id
158142
, stg3.charttime
159-
-- raw data indicating sample type
143+
-- drop down text indicating the specimen type
160144
, specimen
161-
-- prediction of specimen for obs missing the actual specimen
162-
, case
163-
when specimen is not null then specimen
164-
when specimen_prob > 0.75 then 'ART.'
165-
else null end as specimen_pred
166-
, specimen_prob
167145

168146
-- oxygen related parameters
169147
, so2

0 commit comments

Comments
 (0)