diff --git a/SQL_Queries/codes.sql b/SQL_Queries/codes.sql index 4596806..a3ddaf5 100644 --- a/SQL_Queries/codes.sql +++ b/SQL_Queries/codes.sql @@ -1,8 +1,9 @@ +SET SEARCH_PATH TO public,mimiciii; SELECT i.icustay_id, d.subject_id, d.hadm_id, array_agg(d.icd9_code ORDER BY seq_num ASC) AS icd9_codes -FROM mimiciii.diagnoses_icd d - LEFT OUTER JOIN (SELECT ccs_matched_id, icd9_code from mimiciii.ccs_dx) c +FROM diagnoses_icd d + LEFT OUTER JOIN (SELECT ccs_matched_id, icd9_code from ccs_dx) c ON c.icd9_code = d.icd9_code INNER JOIN icustays i ON i.hadm_id = d.hadm_id AND i.subject_id = d.subject_id diff --git a/SQL_Queries/debug_statics.sql b/SQL_Queries/debug_statics.sql index f1960b4..b68f8f2 100644 --- a/SQL_Queries/debug_statics.sql +++ b/SQL_Queries/debug_statics.sql @@ -1,5 +1,5 @@ \echo "This file is just for debugging" -SET search_path TO mimiciii; +SET search_path TO public,mimiciii; select distinct i.subject_id, i.hadm_id, diff --git a/mimic_direct_extract.py b/mimic_direct_extract.py index 9c6a66f..c65e683 100644 --- a/mimic_direct_extract.py +++ b/mimic_direct_extract.py @@ -734,7 +734,7 @@ def plot_variable_histograms(col_names, df): help='Postgres host. Try "/var/run/postgresql/" for Unix domain socket errors.') ap.add_argument('--psql_dbname', type=str, default='mimic', help='Postgres database name.') - ap.add_argument('--psql_schema_name', type=str, default='mimiciii', + ap.add_argument('--psql_schema_name', type=str, default='public,mimiciii', help='Postgres database name.') ap.add_argument('--psql_user', type=str, default=None, help='Postgres user.') diff --git a/mimic_querier.py b/mimic_querier.py index a5c76c6..8150d51 100644 --- a/mimic_querier.py +++ b/mimic_querier.py @@ -25,7 +25,7 @@ def __init__( self, exclusion_criteria_template_vars={}, query_args={}, # passed wholesale to psycopg2.connect - schema_name='mimiciii' + schema_name='public,mimiciii' ): """ A class to facilitate repeated Queries to a MIMIC psql database """ self.exclusion_criteria_template_vars = {} diff --git a/utils/niv-durations.sql b/utils/niv-durations.sql index 3c69fec..62e6c16 100755 --- a/utils/niv-durations.sql +++ b/utils/niv-durations.sql @@ -4,7 +4,7 @@ -- events can then be used for various purposes: calculating the total duration -- of mechanical ventilation, cross-checking values (e.g. PaO2:FiO2 on vent), etc -SET SEARCH_PATH TO 'mimiciii'; +SET SEARCH_PATH TO public,mimiciii; -- The query's logic is roughly: -- 1) The presence of a mechanical ventilation setting starts a new ventilation event diff --git a/utils/setup_user_env.sh b/utils/setup_user_env.sh index 2dfb58a..81f5d6d 100755 --- a/utils/setup_user_env.sh +++ b/utils/setup_user_env.sh @@ -10,7 +10,7 @@ mkdir -p $MIMIC_EXTRACT_OUTPUT_DIR export DBUSER=bnestor export DBNAME=mimic -export SCHEMA=mimiciii +export SCHEMA=public,mimiciii export HOST=mimic export DBSTRING="dbname=$DBNAME options=--search_path=$SCHEMA" alias psql="psql -h $HOST -U $DBUSER "