From 572233c4bb529553b1e8c391a808c336192adafc Mon Sep 17 00:00:00 2001 From: Alistair Johnson Date: Thu, 23 Mar 2023 16:43:33 -0400 Subject: [PATCH] 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 --- mimic-iv/concepts/convert_bigquery_to_postgres.sh | 14 ++++++++------ .../medication/norepinephrine.sql | 4 +++- .../concepts_postgres/postgres-make-concepts.sql | 1 + 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/mimic-iv/concepts/convert_bigquery_to_postgres.sh b/mimic-iv/concepts/convert_bigquery_to_postgres.sh index fdf73dc95..6d5f4b0f5 100755 --- a/mimic-iv/concepts/convert_bigquery_to_postgres.sh +++ b/mimic-iv/concepts/convert_bigquery_to_postgres.sh @@ -126,22 +126,24 @@ do tbl="${fn%????}" echo -n " ${tbl} " - if [[ "$DIR_AND_TABLES_TO_PREBUILD" =~ "$d.$tbl" ]]; then + # check if var2 is in var1 + if echo "$DIR_AND_TABLES_TO_PREBUILD" | grep -wq "$d.$tbl"; then echo -n "(prebuilt!) .." continue - elif [[ "$DIR_AND_TABLES_TO_SKIP" =~ "$d.$tbl" ]]; then + elif echo "$DIR_AND_TABLES_TO_SKIP" | grep -wq "$d.$tbl"; then echo -n "(skipping!) .." continue - else - echo -n ".." fi # re-write the script into psql using regex # the if statement ensures we do not overwrite tables which are already written in psql - if ! [[ "$DIR_AND_TABLES_ALREADY_IN_PSQL" =~ "$d.$tbl" ]]; then + if ! echo "$DIR_AND_TABLES_ALREADY_IN_PSQL" | grep -wq "$d.$tbl"; then echo "-- THIS SCRIPT IS AUTOMATICALLY GENERATED. DO NOT EDIT IT DIRECTLY." > "${TARGET_PATH}/${d}/${tbl}.sql" echo "DROP TABLE IF EXISTS ${tbl}; CREATE TABLE ${tbl} AS" >> "${TARGET_PATH}/${d}/${tbl}.sql" 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}" + echo -n ".." + else + echo -n "(psql!) .." fi # add statement to generate this table @@ -167,7 +169,7 @@ do # convert the bigquery script to psql and output it to the appropriate subfolder echo -n " ${d}.${tbl} .." - if ! [[ "$DIR_AND_TABLES_ALREADY_IN_PSQL" =~ "$d.$tbl" ]]; then + if ! echo "$DIR_AND_TABLES_ALREADY_IN_PSQL" | grep -wq "$d.$tbl"; then echo "-- THIS SCRIPT IS AUTOMATICALLY GENERATED. DO NOT EDIT IT DIRECTLY." > "$TARGET_PATH/${d}/${tbl}.sql" echo "DROP TABLE IF EXISTS ${tbl}; CREATE TABLE ${tbl} AS" >> "$TARGET_PATH/${d}/${tbl}.sql" diff --git a/mimic-iv/concepts_postgres/medication/norepinephrine.sql b/mimic-iv/concepts_postgres/medication/norepinephrine.sql index 539d7a904..09b1e4dcf 100644 --- a/mimic-iv/concepts_postgres/medication/norepinephrine.sql +++ b/mimic-iv/concepts_postgres/medication/norepinephrine.sql @@ -1,10 +1,12 @@ -- THIS SCRIPT IS AUTOMATICALLY GENERATED. DO NOT EDIT IT DIRECTLY. -DROP TABLE IF EXISTS norepinephrine; CREATE TABLE norepinephrine AS +DROP TABLE IF EXISTS norepinephrine; CREATE TABLE norepinephrine AS -- This query extracts dose+durations of norepinephrine administration +-- Local hospital dosage guidance: 0.03 mcg/kg/min (low), 0.5 mcg/kg/min (high) SELECT stay_id, linkorderid -- two rows in mg/kg/min... rest in mcg/kg/min -- the rows in mg/kg/min are documented incorrectly + -- all rows converted into mcg/kg/min (equiv to ug/kg/min) , CASE WHEN rateuom = 'mg/kg/min' AND patientweight = 1 THEN rate -- below row is written for completion, but doesn't impact rows WHEN rateuom = 'mg/kg/min' THEN rate * 1000.0 diff --git a/mimic-iv/concepts_postgres/postgres-make-concepts.sql b/mimic-iv/concepts_postgres/postgres-make-concepts.sql index e9b283c19..9c8b99fed 100644 --- a/mimic-iv/concepts_postgres/postgres-make-concepts.sql +++ b/mimic-iv/concepts_postgres/postgres-make-concepts.sql @@ -53,6 +53,7 @@ SET search_path TO mimiciv_derived, mimiciv_hosp, mimiciv_icu, mimiciv_ed; \i medication/epinephrine.sql \i medication/milrinone.sql \i medication/neuroblock.sql +\i medication/norepinephrine.sql \i medication/phenylephrine.sql \i medication/vasopressin.sql