1.mmic-iv与mimic-iii的区别之一就是前者分了3个模块, mimic_icu,mimic_hosp和mimic_core, 而在学习过程中我们还可以观察到另外一个模块mimic_derived, 而且这个模块仅存在与谷歌云的mimic数据库中, 本地建立的数据库总虽然有这个模块,但是没有内容。由于mimic_derived 参与了很多内容的查询, 熟悉这个模块的内容还是很有必要的。今天通过手工查看mimic_derived的内容,记录在这里。
这是一个例子,中间涉及到mimic_derived 库:
-- Model for end-stage liver disease (MELD)
-- This model is used to determine prognosis and receipt of liver transplantation.--查询目的
-- Reference:
-- Kamath PS, Wiesner RH, Malinchoc M, Kremers W, Therneau TM,
-- Kosberg CL, D'Amico G, Dickson ER, Kim WR.
-- A model to predict survival in patients with end-stage liver disease.
-- Hepatology. 2001 Feb;33(2):464-70.
-- Updated January 2016 to include serum sodium, see:
-- https://optn.transplant.hrsa.gov/news/meld-serum-sodium-policy-changes/
-- Here is the relevant portion of the policy note:
-- 9.1.D MELD Score
-- Candidates who are at least 12 years old receive an initial MELD(i) score equal to:
-- 0.957 x ln(creatinine mg/dL) + 0.378 x ln(bilirubin mg/dL) + 1.120 x ln(INR) + 0.643
-- Laboratory values less than 1.0 will be set to 1.0 when calculating a candidate’s MELD
-- score.
-- The following candidates will receive a creatinine value of 4.0 mg/dL:
-- - Candidates with a creatinine value greater than 4.0 mg/dL
-- - Candidates who received two or more dialysis treatments within the prior week
-- - Candidates who received 24 hours of continuous veno-venous hemodialysis (CVVHD) within the prior week
-- The maximum MELD score is 40. The MELD score derived from this calculation will be rounded to the tenth decimal place and then multiplied by 10.
-- For candidates with an initial MELD score greater than 11, The MELD score is then recalculated as follows:
-- MELD = MELD(i) + 1.32*(137-Na) – [0.033*MELD(i)*(137-Na)]
-- Sodium values less than 125 mmol/L will be set to 125, and values greater than 137 mmol/L will be set to 137.
--以上是要解决的问题
--以下是实现的策略或者步骤
-- TODO needed in this code:
-- 1. identify 2x dialysis in the past week, or 24 hours of CVVH
-- at the moment it just checks for any dialysis on the first day
-- 2. identify cholestatic or alcoholic liver disease
-- 0.957 x ln(creatinine mg/dL) + 0.378 x ln(bilirubin mg/dL) + 1.120 x ln(INR) + 0.643 x etiology
-- (0 if cholestatic or alcoholic, 1 otherwise)
-- 3. adjust the serum sodium using the corresponding glucose measurement
-- Measured sodium + 0.024 * (Serum glucose - 100) (Hiller, 1999)
WITH cohort AS
(
SELECT
ie.subject_id
, ie.hadm_id
, ie.stay_id
, ie.intime
, ie.outtime
, labs.creatinine_max
, labs.bilirubin_total_max
, labs.inr_max
, labs.sodium_min
, r.dialysis_present AS rrt
FROM `physionet-data.mimic_icu.icustays` ie
-- join to custom tables to get more data....
LEFT JOIN `physionet-data.mimic_derived.first_day_lab` labs
ON ie.stay_id = labs.stay_id
LEFT JOIN `physionet-data.mimic_derived.first_day_rrt` r --mimic_derived这个数据库很神秘.
ON ie.stay_id = r.stay_id
)
, score as
(
SELECT
subject_id
, hadm_id
, stay_id
, rrt
, creatinine_max
, bilirubin_total_max
, inr_max
, sodium_min
-- TODO: Corrected Sodium
, CASE
WHEN sodium_min is null
THEN 0.0
WHEN sodium_min > 137
THEN 0.0
WHEN sodium_min < 125
THEN 12.0 -- 137 - 125 = 12
else 137.0-sodium_min
end as sodium_score
-- if hemodialysis, value for Creatinine is automatically set to 4.0
, CASE
WHEN rrt = 1 or creatinine_max > 4.0
THEN (0.957 * ln(4))
-- if creatinine < 1, score is 1
WHEN creatinine_max < 1
THEN (0.957 * ln(1))
else 0.957 * coalesce(ln(creatinine_max),ln(1))
end as creatinine_score
, CASE
-- if value < 1, score is 1
WHEN bilirubin_total_max < 1
THEN 0.378 * ln(1)
else 0.378 * coalesce(ln(bilirubin_total_max),ln(1))
end as bilirubin_score
, CASE
WHEN inr_max < 1
THEN ( 1.120 * ln(1) + 0.643 )
else ( 1.120 * coalesce(ln(inr_max),ln(1)) + 0.643 )
end as inr_score
FROM cohort
)
, score2 as
(
SELECT
subject_id
, hadm_id
, stay_id
, rrt
, creatinine_max
, bilirubin_total_max
, inr_max
, sodium_min
, creatinine_score
, sodium_score
, bilirubin_score
, inr_score
, CASE
WHEN (creatinine_score + bilirubin_score + inr_score) > 4
THEN 40.0
else
round(cast(creatinine_score + bilirubin_score + inr_score as numeric),1)*10
end as meld_initial
FROM score
)
SELECT
subject_id
, hadm_id
, stay_id
-- MELD Score without sodium change
, meld_initial
-- MELD Score (2016) = MELD*10 + 1.32*(137-Na) – [0.033*MELD*10*(137-Na)]
, CASE
WHEN meld_initial > 11
THEN meld_initial + 1.32*sodium_score - 0.033*meld_initial*sodium_score--计算公式
else
meld_initial
end as meld
-- original variables
, rrt
, creatinine_max
, bilirubin_total_max
, inr_max
, sodium_min
FROM score2
;
2.mimic_derived模块的信息, 抽空翻译标注一下.
这个模块中还有多个表格:表格名:age,antibiotic,apsiii,bg,blood_differential, cardiac_marker,charlson, chemistry, coagulation, complete_blood_count, creatinine_baseline, crrt, dobutamine, dopamine,enzyme, epinephrine, first_day_bg, first_day_bg_art, first_day_gcs, first_day_height, first_day_lab, first_day_rrt, first_day_sofa, first_day_urine_output, first_day_vitalsign,first_day_weight, gcs, height, heparin, icp, icustay_detail, icustay_hourly, icustay_times, inflammation, invasive_line,kdigo_creatinine, kdigo_stages, kdigo_uo, lods, meld, milrinone, neuroblock, norepineprine, norphineprine_equivalent_dose, oasis, oxygen_delivery, phenylephrine, rhythm, rrt, sapsii,sepsis3, sirs, sofa, suspicion_of_infection, urine_output, urine_output_rate, vasoactive_agent, vasopressin, ventilation, ventilation_setting, vitalsign, weight_duration.
根据这个模块进行二次查询可以省一点力气, 也可能给误导了。