Skip to content

Commit

Permalink
Merge pull request #1786 from MIT-LCP/sqlglot_fixes
Browse files Browse the repository at this point in the history
Sqlglot fixes
  • Loading branch information
tompollard authored Aug 22, 2024
2 parents 72d51fe + 40752b2 commit 3185933
Show file tree
Hide file tree
Showing 34 changed files with 260 additions and 99 deletions.
2 changes: 1 addition & 1 deletion mimic-iv/concepts_duckdb/demographics/icustay_hourly.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ SELECT
TRY_CAST(hr_unnested AS BIGINT) AS hr,
endtime + TRY_CAST(hr_unnested AS BIGINT) * INTERVAL '1' HOUR AS endtime
FROM all_hours
CROSS JOIN UNNEST(all_hours.hrs) AS _t(hr_unnested)
CROSS JOIN UNNEST(all_hours.hrs) AS _t0(hr_unnested)
4 changes: 3 additions & 1 deletion mimic-iv/concepts_duckdb/medication/antibiotic.sql
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,8 @@ FROM mimiciv_hosp.prescriptions AS pr
INNER JOIN abx
ON pr.drug = abx.drug AND pr.route = abx.route
LEFT JOIN mimiciv_icu.icustays AS ie
ON pr.hadm_id = ie.hadm_id AND pr.starttime >= ie.intime AND pr.starttime < ie.outtime
ON pr.hadm_id = ie.hadm_id
AND pr.starttime >= ie.intime
AND pr.starttime < ie.outtime
WHERE
abx.antibiotic = 1
28 changes: 21 additions & 7 deletions mimic-iv/concepts_duckdb/medication/vasoactive_agent.sql
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,32 @@ SELECT
mil.vaso_rate AS milrinone
FROM tm_lag AS t
LEFT JOIN mimiciv_derived.dobutamine AS dob
ON t.stay_id = dob.stay_id AND t.starttime >= dob.starttime AND t.endtime <= dob.endtime
ON t.stay_id = dob.stay_id
AND t.starttime >= dob.starttime
AND t.endtime <= dob.endtime
LEFT JOIN mimiciv_derived.dopamine AS dop
ON t.stay_id = dop.stay_id AND t.starttime >= dop.starttime AND t.endtime <= dop.endtime
ON t.stay_id = dop.stay_id
AND t.starttime >= dop.starttime
AND t.endtime <= dop.endtime
LEFT JOIN mimiciv_derived.epinephrine AS epi
ON t.stay_id = epi.stay_id AND t.starttime >= epi.starttime AND t.endtime <= epi.endtime
ON t.stay_id = epi.stay_id
AND t.starttime >= epi.starttime
AND t.endtime <= epi.endtime
LEFT JOIN mimiciv_derived.norepinephrine AS nor
ON t.stay_id = nor.stay_id AND t.starttime >= nor.starttime AND t.endtime <= nor.endtime
ON t.stay_id = nor.stay_id
AND t.starttime >= nor.starttime
AND t.endtime <= nor.endtime
LEFT JOIN mimiciv_derived.phenylephrine AS phe
ON t.stay_id = phe.stay_id AND t.starttime >= phe.starttime AND t.endtime <= phe.endtime
ON t.stay_id = phe.stay_id
AND t.starttime >= phe.starttime
AND t.endtime <= phe.endtime
LEFT JOIN mimiciv_derived.vasopressin AS vas
ON t.stay_id = vas.stay_id AND t.starttime >= vas.starttime AND t.endtime <= vas.endtime
ON t.stay_id = vas.stay_id
AND t.starttime >= vas.starttime
AND t.endtime <= vas.endtime
LEFT JOIN mimiciv_derived.milrinone AS mil
ON t.stay_id = mil.stay_id AND t.starttime >= mil.starttime AND t.endtime <= mil.endtime
ON t.stay_id = mil.stay_id
AND t.starttime >= mil.starttime
AND t.endtime <= mil.endtime
WHERE
NOT t.endtime IS NULL
4 changes: 3 additions & 1 deletion mimic-iv/concepts_duckdb/organfailure/kdigo_uo.sql
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,6 @@ SELECT
uo_tm_24hr
FROM uo_stg2 AS ur
LEFT JOIN mimiciv_derived.weight_durations AS wd
ON ur.stay_id = wd.stay_id AND ur.charttime >= wd.starttime AND ur.charttime < wd.endtime
ON ur.stay_id = wd.stay_id
AND ur.charttime >= wd.starttime
AND ur.charttime < wd.endtime
15 changes: 11 additions & 4 deletions mimic-iv/concepts_duckdb/score/apsiii.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ WITH pa AS (
ROW_NUMBER() OVER (PARTITION BY ie.stay_id ORDER BY bg.po2 DESC) AS rn
FROM mimiciv_derived.bg AS bg
INNER JOIN mimiciv_icu.icustays AS ie
ON bg.hadm_id = ie.hadm_id AND bg.charttime >= ie.intime AND bg.charttime < ie.outtime
ON bg.hadm_id = ie.hadm_id
AND bg.charttime >= ie.intime
AND bg.charttime < ie.outtime
LEFT JOIN mimiciv_derived.ventilation AS vd
ON ie.stay_id = vd.stay_id
AND bg.charttime >= vd.starttime
Expand All @@ -27,7 +29,9 @@ WITH pa AS (
ROW_NUMBER() OVER (PARTITION BY ie.stay_id ORDER BY bg.aado2 DESC) AS rn
FROM mimiciv_derived.bg AS bg
INNER JOIN mimiciv_icu.icustays AS ie
ON bg.hadm_id = ie.hadm_id AND bg.charttime >= ie.intime AND bg.charttime < ie.outtime
ON bg.hadm_id = ie.hadm_id
AND bg.charttime >= ie.intime
AND bg.charttime < ie.outtime
INNER JOIN mimiciv_derived.ventilation AS vd
ON ie.stay_id = vd.stay_id
AND bg.charttime >= vd.starttime
Expand Down Expand Up @@ -62,7 +66,9 @@ WITH pa AS (
END AS acidbase_score
FROM mimiciv_derived.bg AS bg
INNER JOIN mimiciv_icu.icustays AS ie
ON bg.hadm_id = ie.hadm_id AND bg.charttime >= ie.intime AND bg.charttime < ie.outtime
ON bg.hadm_id = ie.hadm_id
AND bg.charttime >= ie.intime
AND bg.charttime < ie.outtime
WHERE
NOT ph IS NULL AND NOT pco2 IS NULL AND bg.specimen = 'ART.'
), acidbase_max AS (
Expand Down Expand Up @@ -608,7 +614,8 @@ WITH pa AS (
WHEN ABS(heart_rate_max - 75) = ABS(heart_rate_min - 75)
AND smax.hr_score >= smin.hr_score
THEN smax.hr_score
WHEN ABS(heart_rate_max - 75) = ABS(heart_rate_min - 75) AND smax.hr_score < smin.hr_score
WHEN ABS(heart_rate_max - 75) = ABS(heart_rate_min - 75)
AND smax.hr_score < smin.hr_score
THEN smin.hr_score
END AS hr_score,
CASE
Expand Down
8 changes: 6 additions & 2 deletions mimic-iv/concepts_duckdb/score/lods.sql
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,18 @@ WITH cpap AS (
CASE WHEN NOT cp.stay_id IS NULL THEN 1 ELSE 0 END AS cpap
FROM mimiciv_derived.bg AS bg
INNER JOIN mimiciv_icu.icustays AS ie
ON bg.hadm_id = ie.hadm_id AND bg.charttime >= ie.intime AND bg.charttime < ie.outtime
ON bg.hadm_id = ie.hadm_id
AND bg.charttime >= ie.intime
AND bg.charttime < ie.outtime
LEFT JOIN mimiciv_derived.ventilation AS vd
ON ie.stay_id = vd.stay_id
AND bg.charttime >= vd.starttime
AND bg.charttime <= vd.endtime
AND vd.ventilation_status = 'InvasiveVent'
LEFT JOIN cpap AS cp
ON ie.stay_id = cp.stay_id AND bg.charttime >= cp.starttime AND bg.charttime <= cp.endtime
ON ie.stay_id = cp.stay_id
AND bg.charttime >= cp.starttime
AND bg.charttime <= cp.endtime
), pafi2 AS (
SELECT
stay_id,
Expand Down
22 changes: 17 additions & 5 deletions mimic-iv/concepts_duckdb/score/sapsii.sql
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ WITH co AS (
MAX(CASE WHEN REGEXP_MATCHES(LOWER(ce.value), '(cpap mask|bipap)') THEN 1 ELSE 0 END) AS cpap
FROM co
INNER JOIN mimiciv_icu.chartevents AS ce
ON co.stay_id = ce.stay_id AND ce.charttime > co.starttime AND ce.charttime <= co.endtime
ON co.stay_id = ce.stay_id
AND ce.charttime > co.starttime
AND ce.charttime <= co.endtime
WHERE
ce.itemid = 226732 AND REGEXP_MATCHES(LOWER(ce.value), '(cpap mask|bipap)')
GROUP BY
Expand Down Expand Up @@ -135,7 +137,9 @@ WITH co AS (
MIN(gcs.gcs) AS mingcs
FROM co
LEFT JOIN mimiciv_derived.gcs AS gcs
ON co.stay_id = gcs.stay_id AND co.starttime < gcs.charttime AND gcs.charttime <= co.endtime
ON co.stay_id = gcs.stay_id
AND co.starttime < gcs.charttime
AND gcs.charttime <= co.endtime
GROUP BY
co.stay_id
), vital AS (
Expand All @@ -160,7 +164,9 @@ WITH co AS (
SUM(uo.urineoutput) AS urineoutput
FROM co
LEFT JOIN mimiciv_derived.urine_output AS uo
ON co.stay_id = uo.stay_id AND co.starttime < uo.charttime AND co.endtime >= uo.charttime
ON co.stay_id = uo.stay_id
AND co.starttime < uo.charttime
AND co.endtime >= uo.charttime
GROUP BY
co.stay_id
), labs AS (
Expand Down Expand Up @@ -301,7 +307,10 @@ WITH co AS (
THEN 4
WHEN heartrate_min < 70
THEN 2
WHEN heartrate_max >= 70 AND heartrate_max < 120 AND heartrate_min >= 70 AND heartrate_min < 120
WHEN heartrate_max >= 70
AND heartrate_max < 120
AND heartrate_min >= 70
AND heartrate_min < 120
THEN 0
END AS hr_score,
CASE
Expand Down Expand Up @@ -371,7 +380,10 @@ WITH co AS (
THEN 3
WHEN potassium_max >= 5.0
THEN 3
WHEN potassium_max >= 3.0 AND potassium_max < 5.0 AND potassium_min >= 3.0 AND potassium_min < 5.0
WHEN potassium_max >= 3.0
AND potassium_max < 5.0
AND potassium_min >= 3.0
AND potassium_min < 5.0
THEN 0
END AS potassium_score,
CASE
Expand Down
36 changes: 27 additions & 9 deletions mimic-iv/concepts_duckdb/score/sofa.sql
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ WITH co AS (
MIN(vs.mbp) AS meanbp_min
FROM co
LEFT JOIN mimiciv_derived.vitalsign AS vs
ON co.stay_id = vs.stay_id AND co.starttime < vs.charttime AND co.endtime >= vs.charttime
ON co.stay_id = vs.stay_id
AND co.starttime < vs.charttime
AND co.endtime >= vs.charttime
GROUP BY
co.stay_id,
co.hr
Expand All @@ -44,7 +46,9 @@ WITH co AS (
MIN(gcs.gcs) AS gcs_min
FROM co
LEFT JOIN mimiciv_derived.gcs AS gcs
ON co.stay_id = gcs.stay_id AND co.starttime < gcs.charttime AND co.endtime >= gcs.charttime
ON co.stay_id = gcs.stay_id
AND co.starttime < gcs.charttime
AND co.endtime >= gcs.charttime
GROUP BY
co.stay_id,
co.hr
Expand All @@ -55,7 +59,9 @@ WITH co AS (
MAX(enz.bilirubin_total) AS bilirubin_max
FROM co
LEFT JOIN mimiciv_derived.enzyme AS enz
ON co.hadm_id = enz.hadm_id AND co.starttime < enz.charttime AND co.endtime >= enz.charttime
ON co.hadm_id = enz.hadm_id
AND co.starttime < enz.charttime
AND co.endtime >= enz.charttime
GROUP BY
co.stay_id,
co.hr
Expand All @@ -79,7 +85,9 @@ WITH co AS (
MIN(cbc.platelet) AS platelet_min
FROM co
LEFT JOIN mimiciv_derived.complete_blood_count AS cbc
ON co.hadm_id = cbc.hadm_id AND co.starttime < cbc.charttime AND co.endtime >= cbc.charttime
ON co.hadm_id = cbc.hadm_id
AND co.starttime < cbc.charttime
AND co.endtime >= cbc.charttime
GROUP BY
co.stay_id,
co.hr
Expand Down Expand Up @@ -109,7 +117,9 @@ WITH co AS (
) AS uo_24hr
FROM co
LEFT JOIN mimiciv_derived.urine_output_rate AS uo
ON co.stay_id = uo.stay_id AND co.starttime < uo.charttime AND co.endtime >= uo.charttime
ON co.stay_id = uo.stay_id
AND co.starttime < uo.charttime
AND co.endtime >= uo.charttime
GROUP BY
co.stay_id,
co.hr
Expand All @@ -123,13 +133,21 @@ WITH co AS (
MAX(dob.vaso_rate) AS rate_dobutamine
FROM co
LEFT JOIN mimiciv_derived.epinephrine AS epi
ON co.stay_id = epi.stay_id AND co.endtime > epi.starttime AND co.endtime <= epi.endtime
ON co.stay_id = epi.stay_id
AND co.endtime > epi.starttime
AND co.endtime <= epi.endtime
LEFT JOIN mimiciv_derived.norepinephrine AS nor
ON co.stay_id = nor.stay_id AND co.endtime > nor.starttime AND co.endtime <= nor.endtime
ON co.stay_id = nor.stay_id
AND co.endtime > nor.starttime
AND co.endtime <= nor.endtime
LEFT JOIN mimiciv_derived.dopamine AS dop
ON co.stay_id = dop.stay_id AND co.endtime > dop.starttime AND co.endtime <= dop.endtime
ON co.stay_id = dop.stay_id
AND co.endtime > dop.starttime
AND co.endtime <= dop.endtime
LEFT JOIN mimiciv_derived.dobutamine AS dob
ON co.stay_id = dob.stay_id AND co.endtime > dob.starttime AND co.endtime <= dob.endtime
ON co.stay_id = dob.stay_id
AND co.endtime > dob.starttime
AND co.endtime <= dob.endtime
WHERE
NOT epi.stay_id IS NULL
OR NOT nor.stay_id IS NULL
Expand Down
2 changes: 1 addition & 1 deletion mimic-iv/concepts_postgres/demographics/age.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ SELECT
ad.admittime,
pa.anchor_age,
pa.anchor_year, /* calculate the age as anchor_age (60) plus difference between */ /* admit year and the anchor year. */ /* the noqa retains the extra long line so the */ /* convert to postgres bash script works */
pa.anchor_age + EXTRACT(EPOCH FROM ad.admittime - TO_TIMESTAMP(TO_CHAR(pa.anchor_year, '0000') || TO_CHAR(1, '00') || TO_CHAR(1, '00') || TO_CHAR(0, '00') || TO_CHAR(0, '00') || TO_CHAR(0, '00'), 'yyyymmddHH24MISS')) / 31556908.8 AS age /* noqa: L016 */
pa.anchor_age + EXTRACT(EPOCH FROM ad.admittime - MAKE_TIMESTAMP(pa.anchor_year, 1, 1, 0, 0, 0)) / 31556908.8 AS age /* noqa: L016 */
FROM mimiciv_hosp.admissions AS ad
INNER JOIN mimiciv_hosp.patients AS pa
ON ad.subject_id = pa.subject_id
2 changes: 1 addition & 1 deletion mimic-iv/concepts_postgres/demographics/icustay_detail.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ SELECT
adm.admittime,
adm.dischtime,
EXTRACT(EPOCH FROM adm.dischtime - adm.admittime) / 86400.0 AS los_hospital, /* calculate the age as anchor_age (60) plus difference between */ /* admit year and the anchor year. */ /* the noqa retains the extra long line so the */ /* convert to postgres bash script works */
pat.anchor_age + EXTRACT(EPOCH FROM adm.admittime - TO_TIMESTAMP(TO_CHAR(pat.anchor_year, '0000') || TO_CHAR(1, '00') || TO_CHAR(1, '00') || TO_CHAR(0, '00') || TO_CHAR(0, '00') || TO_CHAR(0, '00'), 'yyyymmddHH24MISS')) / 31556908.8 AS admission_age, /* noqa: L016 */
pat.anchor_age + EXTRACT(EPOCH FROM adm.admittime - MAKE_TIMESTAMP(pat.anchor_year, 1, 1, 0, 0, 0)) / 31556908.8 AS admission_age, /* noqa: L016 */
adm.race,
adm.hospital_expire_flag,
DENSE_RANK() OVER (PARTITION BY adm.subject_id ORDER BY adm.admittime NULLS FIRST) AS hospstay_seq,
Expand Down
6 changes: 4 additions & 2 deletions mimic-iv/concepts_postgres/demographics/icustay_hourly.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ WITH all_hours AS (
THEN it.intime_hr
ELSE DATE_TRUNC('HOUR', it.intime_hr) + INTERVAL '1 HOUR'
END AS endtime, /* create integers for each charttime in hours from admission */ /* so 0 is admission time, 1 is one hour after admission, etc, */ /* up to ICU disch */ /* we allow 24 hours before ICU admission (to grab labs before admit) */
GENERATE_SERIES(-24, CAST(CEIL(EXTRACT(EPOCH FROM it.outtime_hr - it.intime_hr) / 3600.0) AS INT)) AS hrs /* noqa: L016 */
ARRAY(SELECT
*
FROM GENERATE_SERIES(-24, CAST(CEIL(EXTRACT(EPOCH FROM it.outtime_hr - it.intime_hr) / 3600.0) AS INT))) AS hrs /* noqa: L016 */
FROM mimiciv_derived.icustay_times AS it
)
SELECT
stay_id,
CAST(hr_unnested AS BIGINT) AS hr,
endtime + CAST(hr_unnested AS BIGINT) * INTERVAL '1 HOUR' AS endtime
FROM all_hours
CROSS JOIN UNNEST(all_hours.hrs) AS _t(hr_unnested)
CROSS JOIN UNNEST(all_hours.hrs) AS _t0(hr_unnested)
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ FROM mimiciv_icu.icustays AS ie
/* Join to the outputevents table to get urine output */
LEFT JOIN mimiciv_derived.urine_output AS uo
ON ie.stay_id = uo.stay_id
AND uo.charttime >= ie.intime
AND /* ensure the data occurs during the first day */ uo.charttime >= ie.intime
AND uo.charttime <= ie.intime + INTERVAL '1 DAY'
GROUP BY
ie.subject_id,
Expand Down
3 changes: 2 additions & 1 deletion mimic-iv/concepts_postgres/firstday/first_day_weight.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ SELECT
FROM mimiciv_icu.icustays AS ie
/* admission weight */
LEFT JOIN mimiciv_derived.weight_durations AS ce
ON ie.stay_id = ce.stay_id AND ce.starttime <= ie.intime + INTERVAL '1 DAY'
ON ie.stay_id = ce.stay_id
AND /* we filter to weights documented during or before the 1st day */ ce.starttime <= ie.intime + INTERVAL '1 DAY'
GROUP BY
ie.subject_id,
ie.stay_id
14 changes: 9 additions & 5 deletions mimic-iv/concepts_postgres/measurement/bg.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ DROP TABLE IF EXISTS mimiciv_derived.bg; CREATE TABLE mimiciv_derived.bg AS
/* The aim of this query is to pivot entries related to blood gases */ /* which were found in LABEVENTS */
WITH bg AS (
SELECT
MAX(subject_id) AS subject_id,
MAX(subject_id) AS subject_id, /* specimen_id only ever has 1 measurement for each itemid */ /* so, we may simply collapse rows using MAX() */
MAX(hadm_id) AS hadm_id,
MAX(charttime) AS charttime, /* specimen_id *may* have different storetimes, so this */ /* is taking the latest */
MAX(storetime) AS storetime,
Expand Down Expand Up @@ -57,7 +57,9 @@ WITH bg AS (
AVG(valuenum) AS spo2
FROM mimiciv_icu.chartevents
WHERE
itemid = 220277 /* O2 saturation pulseoxymetry */ AND valuenum > 0 AND valuenum <= 100
itemid = 220277 /* O2 saturation pulseoxymetry */
AND valuenum > 0
AND valuenum <= 100
GROUP BY
subject_id,
charttime
Expand All @@ -78,7 +80,9 @@ WITH bg AS (
) AS fio2_chartevents
FROM mimiciv_icu.chartevents
WHERE
itemid = 223835 /* Inspired O2 Fraction (FiO2) */ AND valuenum > 0 AND valuenum <= 100
itemid = 223835 /* Inspired O2 Fraction (FiO2) */
AND valuenum > 0
AND valuenum <= 100
GROUP BY
subject_id,
charttime
Expand All @@ -90,7 +94,7 @@ WITH bg AS (
FROM bg
LEFT JOIN stg_spo2 AS s1
ON bg.subject_id = s1.subject_id
AND s1.charttime BETWEEN bg.charttime - INTERVAL '2 HOUR' AND bg.charttime
AND /* spo2 occurred at most 2 hours before this blood gas */ s1.charttime BETWEEN bg.charttime - INTERVAL '2 HOUR' AND bg.charttime
WHERE
NOT bg.po2 IS NULL
), stg3 AS (
Expand All @@ -101,7 +105,7 @@ WITH bg AS (
FROM stg2 AS bg
LEFT JOIN stg_fio2 AS s2
ON bg.subject_id = s2.subject_id
AND s2.charttime >= bg.charttime - INTERVAL '4 HOUR'
AND /* fio2 occurred at most 4 hours before this blood gas */ s2.charttime >= bg.charttime - INTERVAL '4 HOUR'
AND s2.charttime <= bg.charttime
AND s2.fio2_chartevents > 0
/* only the row with the most recent SpO2 (if no SpO2 found lastRowSpO2 = 1) */
Expand Down
4 changes: 2 additions & 2 deletions mimic-iv/concepts_postgres/measurement/blood_differential.sql
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ WITH blood_diff AS (
MAX(CASE WHEN itemid = 51257 THEN valuenum ELSE NULL END) AS nrbc, /* utility flags which determine whether imputation is possible */
CASE
WHEN MAX(CASE WHEN itemid IN (51300, 51301, 51755) THEN valuenum ELSE NULL END) > 0
AND SUM(
AND /* and we have at least one percentage from the diff */ /* sometimes the entire diff is 0%, which looks like bad data */ SUM(
CASE
WHEN itemid IN (51146, 51200, 51244, 51245, 51254, 51256)
THEN valuenum
Expand All @@ -70,7 +70,7 @@ WITH blood_diff AS (
WHERE
le.itemid IN (51146 /* basophils */, 52069 /* Absolute basophil count */, 51199 /* Eosinophil Count */, 51200 /* Eosinophils */, 52073 /* Absolute Eosinophil count */, 51244 /* Lymphocytes */, 51245 /* Lymphocytes, Percent */, 51133 /* Absolute Lymphocyte Count */, 52769 /* Absolute Lymphocyte Count */, 51253 /* Monocyte Count */, 51254 /* Monocytes */, 52074 /* Absolute Monocyte Count */, 51256 /* Neutrophils */, 52075 /* Absolute Neutrophil Count */, 51143 /* Atypical lymphocytes */, 51144 /* Bands (%) */, 51218 /* Granulocyte Count */, 52135 /* Immature granulocytes (%) */, 51251 /* Metamyelocytes */, 51257 /* Nucleated Red Cells */ /* wbc totals measured in K/uL */ /* 52220 (wbcp) is percentage */, 51300, 51301, 51755) /* below are point of care tests which are extremely infrequent */ /* and usually low quality */ /* 51697, -- Neutrophils (mmol/L) */ /* below itemid do not have data as of MIMIC-IV v1.0 */ /* 51536, -- Absolute Lymphocyte Count */ /* 51537, -- Absolute Neutrophil */ /* 51690, -- Lymphocytes */ /* 52151, -- NRBC */
AND NOT valuenum IS NULL
AND valuenum >= 0
AND /* differential values cannot be negative */ valuenum >= 0
GROUP BY
le.specimen_id
)
Expand Down
Loading

0 comments on commit 3185933

Please sign in to comment.