CREATE TABLE "USER8"."TEST_TABLE_Alex20" AS
(
SELECT me."SUBJECT_ID", icus."ICUSTAY_ID", icus."GENDER", dd."ETHNICITY_DESCR", icus."DOB", icus."HOSPITAL_ADMIT_DT", icus."HOSPITAL_DISCH_DT",
icus."DOD", icus."ICUSTAY_AGE_GROUP", icus."WEIGHT_FIRST", icus."WEIGHT_MIN", icus."WEIGHT_MAX",
mi."LABEL", me."VOLUME", me."DOSE", me."CHARTTIME"
--SELECT COUNT(DISTINCT icus."HADM_ID")
FROM "MIMIC2V26"."comorbidity_scores" cs, "MIMIC2V26"."medevents" me, "MIMIC2V26"."d_meditems" mi,
"MIMIC2V26"."icustay_detail" icus, "MIMIC2V26"."admissions" adm, "MIMIC2V26"."demographic_detail" dd
WHERE cs."SUBJECT_ID" = me."SUBJECT_ID"
AND cs."CONGESTIVE_HEART_FAILURE" > 0
AND me."CUID" = 1 -- Care unit id == CCU
AND (
UPPER(mi."LABEL") LIKE UPPER('%Epinephrine-k%')
OR UPPER(mi."LABEL") LIKE UPPER('%Milrinone%')
OR UPPER(mi."LABEL") LIKE UPPER('%Dopamine Drip%')
OR UPPER(mi."LABEL") LIKE UPPER('%Epinephrine Drip%')
OR UPPER(mi."LABEL") LIKE UPPER('%Dobutamine%')
OR UPPER(mi."LABEL") LIKE UPPER('%Epinephrine%')
)
AND mi."ITEMID" = me."ITEMID"
AND icus."HADM_ID" = adm."HADM_ID"
AND icus."ICUSTAY_ID" = me."ICUSTAY_ID"
AND icus."SUBJECT_ID" = me."SUBJECT_ID"
AND dd."SUBJECT_ID" = icus."SUBJECT_ID"
AND (
days_between(me."CHARTTIME", adm."ADMIT_DT") = 0
OR days_between(me."CHARTTIME", adm."DISCH_DT") = 0
)
--group by me."SUBJECT_ID";
)
CREATE TABLE "USER8"."TEST_TABLE_Alex20" AS ( SELECT me."SUBJECT_ID", icus."ICUSTAY_ID", icus."GENDER", dd."ETHNICITY_DESCR", icus."DOB", icus."HOSPITAL_ADMIT_DT", icus."HOSPITAL_DISCH_DT", icus."DOD", icus."ICUSTAY_AGE_GROUP", icus."WEIGHT_FIRST", icus."WEIGHT_MIN", icus."WEIGHT_MAX", mi."LABEL", me."VOLUME", me."DOSE", me."CHARTTIME" --SELECT COUNT(DISTINCT icus."HADM_ID") FROM "MIMIC2V26"."comorbidity_scores" cs, "MIMIC2V26"."medevents" me, "MIMIC2V26"."d_meditems" mi, "MIMIC2V26"."icustay_detail" icus, "MIMIC2V26"."admissions" adm, "MIMIC2V26"."demographic_detail" dd WHERE cs."SUBJECT_ID" = me."SUBJECT_ID" AND cs."CONGESTIVE_HEART_FAILURE" > 0 AND me."CUID" = 1 -- Care unit id == CCU AND ( UPPER(mi."LABEL") LIKE UPPER('%Epinephrine-k%') OR UPPER(mi."LABEL") LIKE UPPER('%Milrinone%') OR UPPER(mi."LABEL") LIKE UPPER('%Dopamine Drip%') OR UPPER(mi."LABEL") LIKE UPPER('%Epinephrine Drip%') OR UPPER(mi."LABEL") LIKE UPPER('%Dobutamine%') OR UPPER(mi."LABEL") LIKE UPPER('%Epinephrine%') ) AND mi."ITEMID" = me."ITEMID" AND icus."HADM_ID" = adm."HADM_ID" AND icus."ICUSTAY_ID" = me."ICUSTAY_ID" AND icus."SUBJECT_ID" = me."SUBJECT_ID" AND dd."SUBJECT_ID" = icus."SUBJECT_ID" AND ( days_between(me."CHARTTIME", adm."ADMIT_DT") = 0 OR days_between(me."CHARTTIME", adm."DISCH_DT") = 0 ) --group by me."SUBJECT_ID"; )