Skip to content

Commit

Permalink
rename mimic_* to mimiciv_*
Browse files Browse the repository at this point in the history
  • Loading branch information
alistairewj committed Jul 11, 2022
1 parent 69361e4 commit 8ed4060
Show file tree
Hide file tree
Showing 61 changed files with 238 additions and 238 deletions.
8 changes: 4 additions & 4 deletions mimic-iv/concepts/comorbidity/charlson.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ WITH diag AS
hadm_id
, CASE WHEN icd_version = 9 THEN icd_code ELSE NULL END AS icd9_code
, CASE WHEN icd_version = 10 THEN icd_code ELSE NULL END AS icd10_code
FROM `physionet-data.mimic_hosp.diagnoses_icd` diag
FROM `physionet-data.mimiciv_hosp.diagnoses_icd` diag
)
, com AS
(
Expand Down Expand Up @@ -253,7 +253,7 @@ WITH diag AS
SUBSTR(icd10_code, 1, 3) IN ('B20','B21','B22','B24')
THEN 1
ELSE 0 END) AS aids
FROM `physionet-data.mimic_hosp.admissions` ad
FROM `physionet-data.mimiciv_hosp.admissions` ad
LEFT JOIN diag
ON ad.hadm_id = diag.hadm_id
GROUP BY ad.hadm_id
Expand All @@ -268,7 +268,7 @@ WITH diag AS
WHEN age <= 60 THEN 2
WHEN age <= 70 THEN 3
ELSE 4 END AS age_score
FROM `physionet-data.mimic_derived.age`
FROM `physionet-data.mimiciv_derived.age`
)
SELECT
ad.subject_id
Expand Down Expand Up @@ -303,7 +303,7 @@ SELECT
+ 2*paraplegia + 2*renal_disease
+ 6*aids
AS charlson_comorbidity_index
FROM `physionet-data.mimic_hosp.admissions` ad
FROM `physionet-data.mimiciv_hosp.admissions` ad
LEFT JOIN com
ON ad.hadm_id = com.hadm_id
LEFT JOIN ag
Expand Down
4 changes: 2 additions & 2 deletions mimic-iv/concepts/demographics/age.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ SELECT
, pa.anchor_age
, pa.anchor_year
, DATETIME_DIFF(ad.admittime, DATETIME(pa.anchor_year, 1, 1, 0, 0, 0), YEAR) + pa.anchor_age AS age
FROM `physionet-data.mimic_hosp.admissions` ad
INNER JOIN `physionet-data.mimic_hosp.patients` pa
FROM `physionet-data.mimiciv_hosp.admissions` ad
INNER JOIN `physionet-data.mimiciv_hosp.patients` pa
ON ad.subject_id = pa.subject_id
;
6 changes: 3 additions & 3 deletions mimic-iv/concepts/demographics/icustay_detail.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ SELECT ie.subject_id, ie.hadm_id, ie.stay_id
WHEN DENSE_RANK() OVER (PARTITION BY ie.hadm_id ORDER BY ie.intime) = 1 THEN True
ELSE False END AS first_icu_stay

FROM `physionet-data.mimic_icu.icustays` ie
INNER JOIN `physionet-data.mimic_hosp.admissions` adm
FROM `physionet-data.mimiciv_icu.icustays` ie
INNER JOIN `physionet-data.mimiciv_hosp.admissions` adm
ON ie.hadm_id = adm.hadm_id
INNER JOIN `physionet-data.mimic_hosp.patients` pat
INNER JOIN `physionet-data.mimiciv_hosp.patients` pat
ON ie.subject_id = pat.subject_id
2 changes: 1 addition & 1 deletion mimic-iv/concepts/demographics/icustay_hourly.sql
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ select
-- we allow 24 hours before ICU admission (to grab labs before admit)
, GENERATE_ARRAY(-24, CEIL(DATETIME_DIFF(it.outtime_hr, it.intime_hr, HOUR))) as hrs

from `physionet-data.mimic_derived.icustay_times` it
from `physionet-data.mimiciv_derived.icustay_times` it
)
SELECT stay_id
, CAST(hr AS INT64) as hr
Expand Down
4 changes: 2 additions & 2 deletions mimic-iv/concepts/demographics/icustay_times.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ WITH t1 AS
select ce.stay_id
, min(charttime) as intime_hr
, max(charttime) as outtime_hr
FROM `physionet-data.mimic_icu.chartevents` ce
FROM `physionet-data.mimiciv_icu.chartevents` ce
-- only look at heart rate
where ce.itemid = 220045
group by ce.stay_id
Expand All @@ -16,6 +16,6 @@ select
ie.subject_id, ie.hadm_id, ie.stay_id
, t1.intime_hr
, t1.outtime_hr
FROM `physionet-data.mimic_icu.icustays` ie
FROM `physionet-data.mimiciv_icu.icustays` ie
left join t1
on ie.stay_id = t1.stay_id;
6 changes: 3 additions & 3 deletions mimic-iv/concepts/demographics/weight_durations.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ WITH wt_stg as
else 'daily' end as weight_type
-- TODO: eliminate obvious outliers if there is a reasonable weight
, c.valuenum as weight
FROM `physionet-data.mimic_icu.chartevents` c
FROM `physionet-data.mimiciv_icu.chartevents` c
WHERE c.valuenum IS NOT NULL
AND c.itemid in
(
Expand Down Expand Up @@ -42,7 +42,7 @@ WITH wt_stg as
else wt_stg1.charttime end as starttime
, wt_stg1.weight
from wt_stg1
INNER JOIN `physionet-data.mimic_icu.icustays` ie
INNER JOIN `physionet-data.mimiciv_icu.icustays` ie
on ie.stay_id = wt_stg1.stay_id
)
, wt_stg3 as
Expand Down Expand Up @@ -87,7 +87,7 @@ WITH wt_stg as
, wt.starttime as endtime
, wt.weight
, wt.weight_type
from `physionet-data.mimic_icu.icustays` ie
from `physionet-data.mimiciv_icu.icustays` ie
inner join
-- the below subquery returns one row for each unique stay_id
-- the row contains: the first starttime and the corresponding weight
Expand Down
4 changes: 2 additions & 2 deletions mimic-iv/concepts/firstday/first_day_bg.sql
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ select
, MIN(glucose) AS glucose_min, MAX(glucose) AS glucose_max
, MIN(potassium) AS potassium_min, MAX(potassium) AS potassium_max
, MIN(sodium) AS sodium_min, MAX(sodium) AS sodium_max
FROM `physionet-data.mimic_icu.icustays` ie
LEFT JOIN `physionet-data.mimic_derived.bg` bg
FROM `physionet-data.mimiciv_icu.icustays` ie
LEFT JOIN `physionet-data.mimiciv_derived.bg` bg
ON ie.subject_id = bg.subject_id
AND bg.charttime >= DATETIME_SUB(ie.intime, INTERVAL '6' HOUR)
AND bg.charttime <= DATETIME_ADD(ie.intime, INTERVAL '1' DAY)
Expand Down
4 changes: 2 additions & 2 deletions mimic-iv/concepts/firstday/first_day_bg_art.sql
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ select
, MIN(glucose) AS glucose_min, MAX(glucose) AS glucose_max
, MIN(potassium) AS potassium_min, MAX(potassium) AS potassium_max
, MIN(sodium) AS sodium_min, MAX(sodium) AS sodium_max
FROM `physionet-data.mimic_icu.icustays` ie
LEFT JOIN `physionet-data.mimic_derived.bg` bg
FROM `physionet-data.mimiciv_icu.icustays` ie
LEFT JOIN `physionet-data.mimiciv_derived.bg` bg
ON ie.subject_id = bg.subject_id
AND bg.specimen = 'ART.'
AND bg.charttime >= DATETIME_SUB(ie.intime, INTERVAL '6' HOUR)
Expand Down
4 changes: 2 additions & 2 deletions mimic-iv/concepts/firstday/first_day_gcs.sql
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ WITH gcs_final AS
PARTITION BY gcs.stay_id
ORDER BY gcs.GCS
) as gcs_seq
FROM `physionet-data.mimic_derived.gcs` gcs
FROM `physionet-data.mimiciv_derived.gcs` gcs
)
SELECT
ie.subject_id
Expand All @@ -33,7 +33,7 @@ SELECT
, gcs_verbal
, gcs_eyes
, gcs_unable
FROM `physionet-data.mimic_icu.icustays` ie
FROM `physionet-data.mimiciv_icu.icustays` ie
LEFT JOIN gcs_final gs
ON ie.stay_id = gs.stay_id
AND gs.gcs_seq = 1
Expand Down
8 changes: 4 additions & 4 deletions mimic-iv/concepts/firstday/first_day_height.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ WITH ce AS
SELECT
c.stay_id
, AVG(valuenum) as Height_chart
FROM `physionet-data.mimic_icu.chartevents` c
INNER JOIN `physionet-data.mimic_icu.icustays` ie ON
FROM `physionet-data.mimiciv_icu.chartevents` c
INNER JOIN `physionet-data.mimiciv_icu.icustays` ie ON
c.stay_id = ie.stay_id
AND c.charttime BETWEEN DATETIME_SUB(ie.intime, INTERVAL '1' DAY) AND DATETIME_ADD(ie.intime, INTERVAL '1' DAY)
WHERE c.valuenum IS NOT NULL
Expand All @@ -22,8 +22,8 @@ SELECT
ie.subject_id
, ie.stay_id
, ROUND(AVG(height), 2) AS height
FROM `physionet-data.mimic_icu.icustays` ie
LEFT JOIN `physionet-data.mimic_derived.height` ht
FROM `physionet-data.mimiciv_icu.icustays` ie
LEFT JOIN `physionet-data.mimiciv_derived.height` ht
ON ie.stay_id = ht.stay_id
AND ht.charttime >= DATETIME_SUB(ie.intime, INTERVAL '6' HOUR)
AND ht.charttime <= DATETIME_ADD(ie.intime, INTERVAL '1' DAY)
Expand Down
22 changes: 11 additions & 11 deletions mimic-iv/concepts/firstday/first_day_lab.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ WITH cbc AS
, MAX(platelet) as platelets_max
, MIN(wbc) as wbc_min
, MAX(wbc) as wbc_max
FROM `physionet-data.mimic_icu.icustays` ie
LEFT JOIN `physionet-data.mimic_derived.complete_blood_count` le
FROM `physionet-data.mimiciv_icu.icustays` ie
LEFT JOIN `physionet-data.mimiciv_derived.complete_blood_count` le
ON le.subject_id = ie.subject_id
AND le.charttime >= DATETIME_SUB(ie.intime, INTERVAL '6' HOUR)
AND le.charttime <= DATETIME_ADD(ie.intime, INTERVAL '1' DAY)
Expand All @@ -33,8 +33,8 @@ WITH cbc AS
, MIN(glucose) AS glucose_min, MAX(glucose) AS glucose_max
, MIN(sodium) AS sodium_min, MAX(sodium) AS sodium_max
, MIN(potassium) AS potassium_min, MAX(potassium) AS potassium_max
FROM `physionet-data.mimic_icu.icustays` ie
LEFT JOIN `physionet-data.mimic_derived.chemistry` le
FROM `physionet-data.mimiciv_icu.icustays` ie
LEFT JOIN `physionet-data.mimiciv_derived.chemistry` le
ON le.subject_id = ie.subject_id
AND le.charttime >= DATETIME_SUB(ie.intime, INTERVAL '6' HOUR)
AND le.charttime <= DATETIME_ADD(ie.intime, INTERVAL '1' DAY)
Expand All @@ -54,8 +54,8 @@ WITH cbc AS
, MIN(immature_granulocytes) AS imm_granulocytes_min, MAX(immature_granulocytes) AS imm_granulocytes_max
, MIN(metamyelocytes) AS metas_min, MAX(metamyelocytes) AS metas_max
, MIN(nrbc) AS nrbc_min, MAX(nrbc) AS nrbc_max
FROM `physionet-data.mimic_icu.icustays` ie
LEFT JOIN `physionet-data.mimic_derived.blood_differential` le
FROM `physionet-data.mimiciv_icu.icustays` ie
LEFT JOIN `physionet-data.mimiciv_derived.blood_differential` le
ON le.subject_id = ie.subject_id
AND le.charttime >= DATETIME_SUB(ie.intime, INTERVAL '6' HOUR)
AND le.charttime <= DATETIME_ADD(ie.intime, INTERVAL '1' DAY)
Expand All @@ -71,8 +71,8 @@ WITH cbc AS
, MIN(inr) AS inr_min, MAX(inr) AS inr_max
, MIN(pt) AS pt_min, MAX(pt) AS pt_max
, MIN(ptt) AS ptt_min, MAX(ptt) AS ptt_max
FROM `physionet-data.mimic_icu.icustays` ie
LEFT JOIN `physionet-data.mimic_derived.coagulation` le
FROM `physionet-data.mimiciv_icu.icustays` ie
LEFT JOIN `physionet-data.mimiciv_derived.coagulation` le
ON le.subject_id = ie.subject_id
AND le.charttime >= DATETIME_SUB(ie.intime, INTERVAL '6' HOUR)
AND le.charttime <= DATETIME_ADD(ie.intime, INTERVAL '1' DAY)
Expand All @@ -94,8 +94,8 @@ WITH cbc AS
, MIN(ck_mb) AS ck_mb_min, MAX(ck_mb) AS ck_mb_max
, MIN(ggt) AS ggt_min, MAX(ggt) AS ggt_max
, MIN(ld_ldh) AS ld_ldh_min, MAX(ld_ldh) AS ld_ldh_max
FROM `physionet-data.mimic_icu.icustays` ie
LEFT JOIN `physionet-data.mimic_derived.enzyme` le
FROM `physionet-data.mimiciv_icu.icustays` ie
LEFT JOIN `physionet-data.mimiciv_derived.enzyme` le
ON le.subject_id = ie.subject_id
AND le.charttime >= DATETIME_SUB(ie.intime, INTERVAL '6' HOUR)
AND le.charttime <= DATETIME_ADD(ie.intime, INTERVAL '1' DAY)
Expand Down Expand Up @@ -152,7 +152,7 @@ ie.subject_id
, ck_mb_min, ck_mb_max
, ggt_min, ggt_max
, ld_ldh_min, ld_ldh_max
FROM `physionet-data.mimic_icu.icustays` ie
FROM `physionet-data.mimiciv_icu.icustays` ie
LEFT JOIN cbc
ON ie.stay_id = cbc.stay_id
LEFT JOIN chem
Expand Down
4 changes: 2 additions & 2 deletions mimic-iv/concepts/firstday/first_day_rrt.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ select
, MAX(dialysis_present) AS dialysis_present
, MAX(dialysis_active) AS dialysis_active
, STRING_AGG(DISTINCT dialysis_type, ', ') AS dialysis_type
FROM `physionet-data.mimic_icu.icustays` ie
LEFT JOIN `physionet-data.mimic_derived.rrt` rrt
FROM `physionet-data.mimiciv_icu.icustays` ie
LEFT JOIN `physionet-data.mimiciv_derived.rrt` rrt
ON ie.stay_id = rrt.stay_id
AND rrt.charttime >= DATETIME_SUB(ie.intime, INTERVAL '6' HOUR)
AND rrt.charttime <= DATETIME_ADD(ie.intime, INTERVAL '1' DAY)
Expand Down
36 changes: 18 additions & 18 deletions mimic-iv/concepts/firstday/first_day_sofa.sql
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,29 @@
with vaso_stg as
(
select ie.stay_id, 'norepinephrine' AS treatment, vaso_rate as rate
FROM `physionet-data.mimic_icu.icustays` ie
INNER JOIN `physionet-data.mimic_derived.norepinephrine` mv
FROM `physionet-data.mimiciv_icu.icustays` ie
INNER JOIN `physionet-data.mimiciv_derived.norepinephrine` mv
ON ie.stay_id = mv.stay_id
AND mv.starttime >= DATETIME_SUB(ie.intime, INTERVAL '6' HOUR)
AND mv.starttime <= DATETIME_ADD(ie.intime, INTERVAL '1' DAY)
UNION ALL
select ie.stay_id, 'epinephrine' AS treatment, vaso_rate as rate
FROM `physionet-data.mimic_icu.icustays` ie
INNER JOIN `physionet-data.mimic_derived.epinephrine` mv
FROM `physionet-data.mimiciv_icu.icustays` ie
INNER JOIN `physionet-data.mimiciv_derived.epinephrine` mv
ON ie.stay_id = mv.stay_id
AND mv.starttime >= DATETIME_SUB(ie.intime, INTERVAL '6' HOUR)
AND mv.starttime <= DATETIME_ADD(ie.intime, INTERVAL '1' DAY)
UNION ALL
select ie.stay_id, 'dobutamine' AS treatment, vaso_rate as rate
FROM `physionet-data.mimic_icu.icustays` ie
INNER JOIN `physionet-data.mimic_derived.dobutamine` mv
FROM `physionet-data.mimiciv_icu.icustays` ie
INNER JOIN `physionet-data.mimiciv_derived.dobutamine` mv
ON ie.stay_id = mv.stay_id
AND mv.starttime >= DATETIME_SUB(ie.intime, INTERVAL '6' HOUR)
AND mv.starttime <= DATETIME_ADD(ie.intime, INTERVAL '1' DAY)
UNION ALL
select ie.stay_id, 'dopamine' AS treatment, vaso_rate as rate
FROM `physionet-data.mimic_icu.icustays` ie
INNER JOIN `physionet-data.mimic_derived.dopamine` mv
FROM `physionet-data.mimiciv_icu.icustays` ie
INNER JOIN `physionet-data.mimiciv_derived.dopamine` mv
ON ie.stay_id = mv.stay_id
AND mv.starttime >= DATETIME_SUB(ie.intime, INTERVAL '6' HOUR)
AND mv.starttime <= DATETIME_ADD(ie.intime, INTERVAL '1' DAY)
Expand All @@ -64,7 +64,7 @@ with vaso_stg as
, max(CASE WHEN treatment = 'epinephrine' THEN rate ELSE NULL END) as rate_epinephrine
, max(CASE WHEN treatment = 'dopamine' THEN rate ELSE NULL END) as rate_dopamine
, max(CASE WHEN treatment = 'dobutamine' THEN rate ELSE NULL END) as rate_dobutamine
from `physionet-data.mimic_icu.icustays` ie
from `physionet-data.mimiciv_icu.icustays` ie
LEFT JOIN vaso_stg v
ON ie.stay_id = v.stay_id
GROUP BY ie.stay_id
Expand All @@ -75,12 +75,12 @@ with vaso_stg as
select ie.stay_id, bg.charttime
, bg.pao2fio2ratio
, case when vd.stay_id is not null then 1 else 0 end as IsVent
from `physionet-data.mimic_icu.icustays` ie
LEFT JOIN `physionet-data.mimic_derived.bg` bg
from `physionet-data.mimiciv_icu.icustays` ie
LEFT JOIN `physionet-data.mimiciv_derived.bg` bg
ON ie.subject_id = bg.subject_id
AND bg.charttime >= DATETIME_SUB(ie.intime, INTERVAL '6' HOUR)
AND bg.charttime <= DATETIME_ADD(ie.intime, INTERVAL '1' DAY)
LEFT JOIN `physionet-data.mimic_derived.ventilation` vd
LEFT JOIN `physionet-data.mimiciv_derived.ventilation` vd
ON ie.stay_id = vd.stay_id
AND bg.charttime >= vd.starttime
AND bg.charttime <= vd.endtime
Expand Down Expand Up @@ -117,18 +117,18 @@ select ie.stay_id
, uo.UrineOutput

, gcs.gcs_min
from `physionet-data.mimic_icu.icustays` ie
from `physionet-data.mimiciv_icu.icustays` ie
left join vaso_mv mv
on ie.stay_id = mv.stay_id
left join pafi2 pf
on ie.stay_id = pf.stay_id
left join `physionet-data.mimic_derived.first_day_vitalsign` v
left join `physionet-data.mimiciv_derived.first_day_vitalsign` v
on ie.stay_id = v.stay_id
left join `physionet-data.mimic_derived.first_day_lab` l
left join `physionet-data.mimiciv_derived.first_day_lab` l
on ie.stay_id = l.stay_id
left join `physionet-data.mimic_derived.first_day_urine_output` uo
left join `physionet-data.mimiciv_derived.first_day_urine_output` uo
on ie.stay_id = uo.stay_id
left join `physionet-data.mimic_derived.first_day_gcs` gcs
left join `physionet-data.mimiciv_derived.first_day_gcs` gcs
on ie.stay_id = gcs.stay_id
)
, scorecalc as
Expand Down Expand Up @@ -217,7 +217,7 @@ select ie.subject_id, ie.hadm_id, ie.stay_id
, cardiovascular
, cns
, renal
from `physionet-data.mimic_icu.icustays` ie
from `physionet-data.mimiciv_icu.icustays` ie
left join scorecalc s
on ie.stay_id = s.stay_id
;
4 changes: 2 additions & 2 deletions mimic-iv/concepts/firstday/first_day_urine_output.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ SELECT
ie.subject_id
, ie.stay_id
, SUM(urineoutput) AS urineoutput
FROM `physionet-data.mimic_icu.icustays` ie
FROM `physionet-data.mimiciv_icu.icustays` ie
-- Join to the outputevents table to get urine output
LEFT JOIN `physionet-data.mimic_derived.urine_output` uo
LEFT JOIN `physionet-data.mimiciv_derived.urine_output` uo
ON ie.stay_id = uo.stay_id
-- ensure the data occurs during the first day
AND uo.charttime >= ie.intime
Expand Down
4 changes: 2 additions & 2 deletions mimic-iv/concepts/firstday/first_day_vitalsign.sql
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ ie.subject_id
, MIN(glucose) AS glucose_min
, MAX(glucose) AS glucose_max
, AVG(glucose) AS glucose_mean
FROM `physionet-data.mimic_icu.icustays` ie
LEFT JOIN `physionet-data.mimic_derived.vitalsign` ce
FROM `physionet-data.mimiciv_icu.icustays` ie
LEFT JOIN `physionet-data.mimiciv_derived.vitalsign` ce
ON ie.stay_id = ce.stay_id
AND ce.charttime >= DATETIME_SUB(ie.intime, INTERVAL '6' HOUR)
AND ce.charttime <= DATETIME_ADD(ie.intime, INTERVAL '1' DAY)
Expand Down
4 changes: 2 additions & 2 deletions mimic-iv/concepts/firstday/first_day_weight.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ SELECT
, AVG(ce.weight) AS weight
, MIN(ce.weight) AS weight_min
, MAX(ce.weight) AS weight_max
FROM `physionet-data.mimic_icu.icustays` ie
FROM `physionet-data.mimiciv_icu.icustays` ie
-- admission weight
LEFT JOIN `physionet-data.mimic_derived.weight_durations` ce
LEFT JOIN `physionet-data.mimiciv_derived.weight_durations` ce
ON ie.stay_id = ce.stay_id
-- we filter to weights documented during or before the 1st day
AND ce.starttime <= DATETIME_ADD(ie.intime, INTERVAL '1' DAY)
Expand Down
Loading

0 comments on commit 8ed4060

Please sign in to comment.