11
11
-- specimen_id *may* have different storetimes, so this is taking the latest
12
12
, MAX (storetime) AS storetime
13
13
, 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
15
15
, MAX (CASE WHEN itemid = 50801 THEN valuenum ELSE NULL END) AS aado2
16
16
, MAX (CASE WHEN itemid = 50802 THEN valuenum ELSE NULL END) AS baseexcess
17
17
, MAX (CASE WHEN itemid = 50803 THEN valuenum ELSE NULL END) AS bicarbonate
@@ -48,7 +48,7 @@ FROM mimic_hosp.labevents le
48
48
where le .ITEMID in
49
49
-- blood gases
50
50
(
51
- 52028 -- specimen
51
+ 52033 -- specimen
52
52
, 50801 -- aado2
53
53
, 50802 -- base excess
54
54
, 50803 -- bicarb
@@ -127,22 +127,6 @@ where bg.po2 is not null
127
127
select bg.*
128
128
, ROW_NUMBER() OVER (partition by bg .subject_id , bg .charttime order by s2 .charttime DESC ) as lastRowFiO2
129
129
, 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
146
130
from stg2 bg
147
131
left join stg_fio2 s2
148
132
-- same patient
@@ -156,14 +140,8 @@ select
156
140
stg3 .subject_id
157
141
, stg3 .hadm_id
158
142
, stg3 .charttime
159
- -- raw data indicating sample type
143
+ -- drop down text indicating the specimen type
160
144
, 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
167
145
168
146
-- oxygen related parameters
169
147
, so2
0 commit comments