Skip to content

Commit dbf4250

Browse files
authored
Merge pull request #1403 from kiendang/kiendang/mimiciv-ed-fixes
Add correct indices for mimic-iv-ed postgres
2 parents 0f89822 + a5a4fa4 commit dbf4250

File tree

4 files changed

+67
-46
lines changed

4 files changed

+67
-46
lines changed

mimic-iv-ed/buildmimic/postgres/create.sql

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
-- File created - Wed 13 Jul 2022
99
--------------------------------------------------------
1010

11-
DROP SCHEMA IF EXISTS mimic_ed CASCADE;
12-
CREATE SCHEMA mimic_ed;
11+
DROP SCHEMA IF EXISTS mimiciv_ed CASCADE;
12+
CREATE SCHEMA mimiciv_ed;
1313

1414
/* Set the mimic_data_dir variable to point to directory containing
1515
all .csv files. If using Docker, this should not be changed here.
@@ -23,8 +23,8 @@ CREATE SCHEMA mimic_ed;
2323
-- DDL for Table diagnosis
2424
--------------------------------------------------------
2525

26-
DROP TABLE IF EXISTS mimic_ed.diagnosis CASCADE;
27-
CREATE TABLE mimic_ed.diagnosis
26+
DROP TABLE IF EXISTS mimiciv_ed.diagnosis CASCADE;
27+
CREATE TABLE mimiciv_ed.diagnosis
2828
(
2929
subject_id INTEGER NOT NULL,
3030
stay_id INTEGER NOT NULL,
@@ -38,8 +38,8 @@ CREATE TABLE mimic_ed.diagnosis
3838
-- DDL for Table edstays
3939
--------------------------------------------------------
4040

41-
DROP TABLE IF EXISTS mimic_ed.edstays CASCADE;
42-
CREATE TABLE mimic_ed.edstays
41+
DROP TABLE IF EXISTS mimiciv_ed.edstays CASCADE;
42+
CREATE TABLE mimiciv_ed.edstays
4343
(
4444
subject_id INTEGER NOT NULL,
4545
hadm_id INTEGER,
@@ -56,8 +56,8 @@ CREATE TABLE mimic_ed.edstays
5656
-- DDL for Table medrecon
5757
--------------------------------------------------------
5858

59-
DROP TABLE IF EXISTS mimic_ed.medrecon CASCADE;
60-
CREATE TABLE mimic_ed.medrecon
59+
DROP TABLE IF EXISTS mimiciv_ed.medrecon CASCADE;
60+
CREATE TABLE mimiciv_ed.medrecon
6161
(
6262
subject_id INTEGER NOT NULL,
6363
stay_id INTEGER NOT NULL,
@@ -74,8 +74,8 @@ CREATE TABLE mimic_ed.medrecon
7474
-- DDL for Table pyxis
7575
--------------------------------------------------------
7676

77-
DROP TABLE IF EXISTS mimic_ed.pyxis CASCADE;
78-
CREATE TABLE mimic_ed.pyxis
77+
DROP TABLE IF EXISTS mimiciv_ed.pyxis CASCADE;
78+
CREATE TABLE mimiciv_ed.pyxis
7979
(
8080
subject_id INTEGER NOT NULL,
8181
stay_id INTEGER NOT NULL,
@@ -90,8 +90,8 @@ CREATE TABLE mimic_ed.pyxis
9090
-- PARTITION for Table triage
9191
--------------------------------------------------------
9292

93-
DROP TABLE IF EXISTS mimic_ed.triage CASCADE;
94-
CREATE TABLE mimic_ed.triage
93+
DROP TABLE IF EXISTS mimiciv_ed.triage CASCADE;
94+
CREATE TABLE mimiciv_ed.triage
9595
(
9696
subject_id INTEGER NOT NULL,
9797
stay_id INTEGER NOT NULL,
@@ -110,8 +110,8 @@ CREATE TABLE mimic_ed.triage
110110
-- DDL for Table vitalsign
111111
--------------------------------------------------------
112112

113-
DROP TABLE IF EXISTS mimic_ed.vitalsign CASCADE;
114-
CREATE TABLE mimic_ed.vitalsign
113+
DROP TABLE IF EXISTS mimiciv_ed.vitalsign CASCADE;
114+
CREATE TABLE mimiciv_ed.vitalsign
115115
(
116116
subject_id INTEGER NOT NULL,
117117
stay_id INTEGER NOT NULL,

mimic-iv-ed/buildmimic/postgres/index.sql

Lines changed: 49 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,52 @@
44
----------------------------------------
55
----------------------------------------
66

7-
-- patients
8-
DROP INDEX IF EXISTS patients_idx01;
9-
CREATE INDEX patients_idx01
10-
ON patients (anchor_age);
11-
12-
DROP INDEX IF EXISTS patients_idx02;
13-
CREATE INDEX patients_idx02
14-
ON patients (anchor_year);
15-
16-
-- admissions
17-
18-
DROP INDEX IF EXISTS admissions_idx01;
19-
CREATE INDEX admissions_idx01
20-
ON admissions (admittime, dischtime, deathtime);
21-
22-
-- transfers
23-
24-
DROP INDEX IF EXISTS transfers_idx01;
25-
CREATE INDEX transfers_idx01
26-
ON transfers (hadm_id);
27-
28-
DROP INDEX IF EXISTS transfers_idx02;
29-
CREATE INDEX transfers_idx02
30-
ON transfers (intime);
31-
32-
DROP INDEX IF EXISTS transfers_idx03;
33-
CREATE INDEX transfers_idx03
34-
ON transfers (careunit);
7+
SET search_path TO mimiciv_ed;
8+
9+
-- diagnosis
10+
11+
DROP INDEX IF EXISTS diagnosis_idx01;
12+
CREATE INDEX diagnosis_idx01
13+
ON diagnosis (subject_id, stay_id);
14+
15+
DROP INDEX IF EXISTS diagnosis_idx02;
16+
CREATE INDEX diagnosis_idx02
17+
ON diagnosis (icd_code, icd_version);
18+
19+
-- edstays
20+
21+
DROP INDEX IF EXISTS edstays_idx01;
22+
CREATE INDEX edstays_idx01
23+
ON edstays (subject_id, hadm_id, stay_id);
24+
25+
DROP INDEX IF EXISTS edstays_idx02;
26+
CREATE INDEX edstays_idx02
27+
ON edstays (intime, outtime);
28+
29+
-- medrecon
30+
31+
DROP INDEX IF EXISTS medrecon_idx01;
32+
CREATE INDEX medrecon_idx01
33+
ON medrecon (subject_id, stay_id, charttime);
34+
35+
-- pyxis
36+
37+
DROP INDEX IF EXISTS pyxis_idx01;
38+
CREATE INDEX pyxis_idx01
39+
ON pyxis (subject_id, stay_id, charttime);
40+
41+
DROP INDEX IF EXISTS pyxis_idx02;
42+
CREATE INDEX pyxis_idx02
43+
ON pyxis (gsn);
44+
45+
-- triage
46+
47+
DROP INDEX IF EXISTS triage_idx01;
48+
CREATE INDEX triage_idx01
49+
ON triage (subject_id, stay_id);
50+
51+
-- vitalsign
52+
53+
DROP INDEX IF EXISTS vitalsign_idx01;
54+
CREATE INDEX vitalsign_idx01
55+
ON vitalsign (subject_id, stay_id, charttime);

mimic-iv-ed/buildmimic/postgres/load.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
\cd :mimic_data_dir
1616

1717
-- If running scripts individually, you can set the schema where all tables are created as follows:
18-
SET search_path TO mimic_ed;
18+
SET search_path TO mimiciv_ed;
1919
-- Restoring the search path to its default value can be accomplished as follows:
2020
-- SET search_path TO "$user",public;
2121

@@ -73,4 +73,4 @@ SET search_path TO mimic_ed;
7373
\copy vitalsign from 'vitalsign.csv' delimiter ',' csv header NULL ''
7474
\echo 'Table vitalsign successfully generated.'
7575
\echo 'All tables generated.'
76-
\echo 'THE END.'
76+
\echo 'THE END.'

mimic-iv-ed/buildmimic/postgres/load_gz.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
\cd :mimic_data_dir
1616

1717
-- If running scripts individually, you can set the schema where all tables are created as follows:
18-
SET search_path TO mimic_ed;
18+
SET search_path TO mimiciv_ed;
1919
-- Restoring the search path to its default value can be accomplished as follows:
2020
-- SET search_path TO "$user",public;
2121

@@ -74,4 +74,4 @@ SET search_path TO mimic_ed;
7474
\copy vitalsign from PROGRAM 'gzip -dc vitalsign.csv.gz' delimiter ',' csv header NULL ''
7575
\echo 'Table vitalsign successfully generated.'
7676
\echo 'All tables generated.'
77-
\echo 'THE END.'
77+
\echo 'THE END.'

0 commit comments

Comments
 (0)