Skip to content

Commit 547f623

Browse files
committed
move search_path into make concepts call
1 parent 1b110f1 commit 547f623

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

mimic-iv/concepts_postgres/README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33
This folder contains scripts to generate useful abstractions of raw MIMIC-IV data ("concepts"). The
44
scripts are intended to be run against the MIMIC-IV data in a PostgreSQL database.
55

6-
**Most of these scripts are automatically generated by a shell script in the parent folder.** If you would like to contribute a correction, please look at the conversion shell script to ensure you edit the right script!
6+
**These scripts are automatically generated by a shell script in the concepts folder.**
7+
If you would like to contribute a correction, please look at the conversion shell script to ensure you edit the right script!
78

89
To generate concepts, change to this directory and run `psql`. Then within psql, run:
910

1011
```sql
11-
-- NOTE: many scripts *require* you to use mimiciv_derived as the schema for outputting concepts
12-
-- change the search path at your peril!
13-
set search_path to mimiciv_derived, mimiciv_hosp, mimiciv_icu, mimiciv_ed;
1412
\i postgres-functions.sql -- only needs to be run once
1513
\i postgres-make-concepts.sql
1614
```

mimic-iv/concepts_postgres/postgres-functions.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
-- FROM table CROSS JOIN UNNEST(table.column) AS col -> ???? (see icustay-hours)
33
-- ???(column) -> PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY column) (not sure how to do median in BQ)
44

5+
-- Set the search_path so all functions are generated on the mimiciv_derived schema
6+
SET search_path TO mimiciv_derived, mimiciv_core, mimiciv_hosp, mimiciv_icu, mimiciv_ed;
7+
58
CREATE OR REPLACE FUNCTION REGEXP_EXTRACT(str TEXT, pattern TEXT) RETURNS TEXT AS $$
69
BEGIN
710
RETURN substring(str from pattern);

mimic-iv/concepts_postgres/postgres-make-concepts.sql

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66
\echo '==='
77
\echo ''
88

9+
-- Set the search_path, i.e. the location at which we generate tables.
10+
-- postgres looks at schemas sequentially, so this will generate tables on the mimiciv_derived schema
11+
12+
-- NOTE: many scripts *require* you to use mimic_derived as the schema for outputting concepts
13+
-- change the search path at your peril!
14+
SET search_path TO mimiciv_derived, mimiciv_core, mimiciv_hosp, mimiciv_icu, mimiciv_ed;
15+
916
-- dependencies
1017
\i demographics/icustay_times.sql
1118
\i demographics/weight_durations.sql

0 commit comments

Comments
 (0)