Skip to content

Commit 572233c

Browse files
committed
fix: bug where norepinephrine is skipped in output to psql
was due to a regex match succeeding against similarly named norepinephrine_equivalent_dose. fix was to change to exact matching with grep. re-ran to regenerate psql concepts. fixed #1494
1 parent f02600d commit 572233c

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

mimic-iv/concepts/convert_bigquery_to_postgres.sh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,22 +126,24 @@ do
126126
tbl="${fn%????}"
127127
echo -n " ${tbl} "
128128

129-
if [[ "$DIR_AND_TABLES_TO_PREBUILD" =~ "$d.$tbl" ]]; then
129+
# check if var2 is in var1
130+
if echo "$DIR_AND_TABLES_TO_PREBUILD" | grep -wq "$d.$tbl"; then
130131
echo -n "(prebuilt!) .."
131132
continue
132-
elif [[ "$DIR_AND_TABLES_TO_SKIP" =~ "$d.$tbl" ]]; then
133+
elif echo "$DIR_AND_TABLES_TO_SKIP" | grep -wq "$d.$tbl"; then
133134
echo -n "(skipping!) .."
134135
continue
135-
else
136-
echo -n ".."
137136
fi
138137

139138
# re-write the script into psql using regex
140139
# the if statement ensures we do not overwrite tables which are already written in psql
141-
if ! [[ "$DIR_AND_TABLES_ALREADY_IN_PSQL" =~ "$d.$tbl" ]]; then
140+
if ! echo "$DIR_AND_TABLES_ALREADY_IN_PSQL" | grep -wq "$d.$tbl"; then
142141
echo "-- THIS SCRIPT IS AUTOMATICALLY GENERATED. DO NOT EDIT IT DIRECTLY." > "${TARGET_PATH}/${d}/${tbl}.sql"
143142
echo "DROP TABLE IF EXISTS ${tbl}; CREATE TABLE ${tbl} AS" >> "${TARGET_PATH}/${d}/${tbl}.sql"
144143
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_DATETIME_TRUNC}" | sed -r -e "${REGEX_SCHEMA}" | sed -r -e "${REGEX_INTERVAL}" >> "${TARGET_PATH}/${d}/${fn}"
144+
echo -n ".."
145+
else
146+
echo -n "(psql!) .."
145147
fi
146148

147149
# add statement to generate this table
@@ -167,7 +169,7 @@ do
167169

168170
# convert the bigquery script to psql and output it to the appropriate subfolder
169171
echo -n " ${d}.${tbl} .."
170-
if ! [[ "$DIR_AND_TABLES_ALREADY_IN_PSQL" =~ "$d.$tbl" ]]; then
172+
if ! echo "$DIR_AND_TABLES_ALREADY_IN_PSQL" | grep -wq "$d.$tbl"; then
171173
echo "-- THIS SCRIPT IS AUTOMATICALLY GENERATED. DO NOT EDIT IT DIRECTLY." > "$TARGET_PATH/${d}/${tbl}.sql"
172174
echo "DROP TABLE IF EXISTS ${tbl}; CREATE TABLE ${tbl} AS" >> "$TARGET_PATH/${d}/${tbl}.sql"
173175

mimic-iv/concepts_postgres/medication/norepinephrine.sql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
-- THIS SCRIPT IS AUTOMATICALLY GENERATED. DO NOT EDIT IT DIRECTLY.
2-
DROP TABLE IF EXISTS norepinephrine; CREATE TABLE norepinephrine AS
2+
DROP TABLE IF EXISTS norepinephrine; CREATE TABLE norepinephrine AS
33
-- This query extracts dose+durations of norepinephrine administration
4+
-- Local hospital dosage guidance: 0.03 mcg/kg/min (low), 0.5 mcg/kg/min (high)
45
SELECT
56
stay_id, linkorderid
67
-- two rows in mg/kg/min... rest in mcg/kg/min
78
-- the rows in mg/kg/min are documented incorrectly
9+
-- all rows converted into mcg/kg/min (equiv to ug/kg/min)
810
, CASE WHEN rateuom = 'mg/kg/min' AND patientweight = 1 THEN rate
911
-- below row is written for completion, but doesn't impact rows
1012
WHEN rateuom = 'mg/kg/min' THEN rate * 1000.0

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ SET search_path TO mimiciv_derived, mimiciv_hosp, mimiciv_icu, mimiciv_ed;
5353
\i medication/epinephrine.sql
5454
\i medication/milrinone.sql
5555
\i medication/neuroblock.sql
56+
\i medication/norepinephrine.sql
5657
\i medication/phenylephrine.sql
5758
\i medication/vasopressin.sql
5859

0 commit comments

Comments
 (0)