1.软件准备
7-zip:配置环境变量(安装路径)
Postgressql:配置环境变量(安装路径/bin)
Navicat
2.文件夹准备
MIMIC-IV3.0数据:MIMIC-IV v3.0 (physionet.org)
MIMIC-IV3.0安装代码:https://github.com/MIT-LCP/mimic-code
简化流程(将所需sql都复制到MIMIC-IV3.0文件夹路径下),包括:create.sql, load_7z.sql, index.sql, function.sql 和 concepts_postgres文件夹
注意事项:更改create.sql中admissions里language VARCHAR(10)为language VARCHAR(100)
3.开始安装
打开Postgres依次运行以下代码
Drop database if exists mimiciv3;
create database mimiciv3 owner postgres;
\c mimiciv3;
\set mimic_data_dir '你的MIMIC数据存放路径'
\encoding 'utf8'
\i 代码存放路径/create.sql
\i 代码存放路径/load_7z.sql
\i 代码存放路径/index.sql
\i 代码存放路径/functions.sql
\i 代码存放路径/postgres-make-concepts.sql (先更改里面的路径与其本身存放路径一致)
4.单独运行icu_hourly, sofa, sepsis3.sql
先更改icu_hourly里面的代码为:
-- THIS SCRIPT IS AUTOMATICALLY GENERATED. DO NOT EDIT IT DIRECTLY. DROP TABLE IF EXISTS mimiciv_derived.icustay_hourly; CREATE TABLE mimiciv_derived.icustay_hourly AS /* This query generates a row for every hour the patient is in the ICU. */ /* The hours are based on clock-hours (i.e. 02:00, 03:00). */ /* The hour clock starts 24 hours before the first heart rate measurement. */ /* Note that the time of the first heart rate measurement is ceilinged to */ /* the hour. */ /* this query extracts the cohort and every possible hour they were in the ICU */ /* this table can be to other tables on stay_id and (ENDTIME - 1 hour,ENDTIME] */ /* get first/last measurement time */ WITH all_hours AS ( SELECT it.stay_id, /* round the intime up to the nearest hour */ CASE WHEN DATE_TRUNC('HOUR', it.intime_hr) = it.intime_hr 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 */ 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(ARRAY[all_hours.hrs]) AS _t(hr_unnested)
而后正常运行sofa和sepsis3