Skip to content

Commit bd5077a

Browse files
author
Alistair Johnson
committed
move firstday scripts earlier for dependencies
1 parent 66ca29d commit bd5077a

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

mimic-iv/concepts/convert_bigquery_to_postgres.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,13 @@ do
4747
echo -n " ${d}.${tbl} .."
4848
echo "-- THIS SCRIPT IS AUTOMATICALLY GENERATED. DO NOT EDIT IT DIRECTLY." > "postgres/${d}/${tbl}.sql"
4949
echo "DROP TABLE IF EXISTS ${tbl}; CREATE TABLE ${tbl} AS " >> "postgres/${d}/${tbl}.sql"
50-
cat "${d}/${tbl}.sql" | sed -r -e "${REGEX_ARRAY}" | sed -r -e "${REGEX_HOUR_INTERVAL}" | sed -r -e "${REGEX_INT}" | sed -r -e "${REGEX_DATETIME_DIFF}" | sed -r -e "${REGEX_SCHEMA}" | sed -r -e "${REGEX_INTERVAL}" | sed -r -e "${REGEX_SECONDS}" | perl -0777 -pe "${PERL_REGEX_ROUND}" >> "postgres/${d}/${tbl}.sql"
50+
51+
# for two scripts, add a perl replace to cast rounded values as numeric
52+
if [[ "${tbl}" == "icustay_times" ]] || [[ "${tbl}" == "urine_output" ]]; then
53+
cat "${d}/${tbl}.sql" | sed -r -e "${REGEX_ARRAY}" | sed -r -e "${REGEX_HOUR_INTERVAL}" | sed -r -e "${REGEX_INT}" | sed -r -e "${REGEX_DATETIME_DIFF}" | sed -r -e "${REGEX_SCHEMA}" | sed -r -e "${REGEX_INTERVAL}" | sed -r -e "${REGEX_SECONDS}" | perl -0777 -pe "${PERL_REGEX_ROUND}" >> "postgres/${d}/${tbl}.sql"
54+
else
55+
cat "${d}/${tbl}.sql" | sed -r -e "${REGEX_ARRAY}" | sed -r -e "${REGEX_HOUR_INTERVAL}" | sed -r -e "${REGEX_INT}" | sed -r -e "${REGEX_DATETIME_DIFF}" | sed -r -e "${REGEX_SCHEMA}" | sed -r -e "${REGEX_INTERVAL}" | sed -r -e "${REGEX_SECONDS}" >> "postgres/${d}/${tbl}.sql"
56+
fi
5157

5258
# write out a call to this script in the make concepts file
5359
echo "\i ${d}/${tbl}.sql" >> postgres/postgres-make-concepts.sql
@@ -60,13 +66,12 @@ echo " done!"
6066
# (3) add a line to the postgres-make-concepts.sql script to generate this table
6167

6268
# order of the folders is important for a few tables here:
63-
# * firstday should go last
6469
# * scores (sofa et al) depend on labs, icustay_hourly
6570
# * sepsis depends on score (sofa.sql in particular)
66-
# * organfailure depends on measurement
71+
# * organfailure depends on measurement and firstday
6772
# the order *only* matters during the conversion step because our loop is
6873
# inserting table build commands into the postgres-make-concepts.sql file
69-
for d in demographics measurement comorbidity medication organfailure treatment score sepsis firstday score sepsis;
74+
for d in demographics measurement comorbidity medication treatment firstday organfailure score sepsis score sepsis;
7075
do
7176
mkdir -p "postgres/${d}"
7277
echo -n "${d}:"

0 commit comments

Comments
 (0)