Skip to content

Commit

Permalink
carry over formatting to postgres scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
alistairewj committed Mar 23, 2023
1 parent 773b417 commit f02600d
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 9 deletions.
3 changes: 2 additions & 1 deletion mimic-iv/concepts_postgres/medication/dobutamine.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
-- THIS SCRIPT IS AUTOMATICALLY GENERATED. DO NOT EDIT IT DIRECTLY.
DROP TABLE IF EXISTS dobutamine; CREATE TABLE dobutamine AS
-- This query extracts dose+durations of dopamine administration
-- This query extracts dose+durations of dobutamine administration
-- Local hospital dosage guidance: 2 mcg/kg/min (low) - 40 mcg/kg/min (max)
SELECT
stay_id, linkorderid
-- all rows in mcg/kg/min
Expand Down
1 change: 1 addition & 0 deletions mimic-iv/concepts_postgres/medication/dopamine.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
-- THIS SCRIPT IS AUTOMATICALLY GENERATED. DO NOT EDIT IT DIRECTLY.
DROP TABLE IF EXISTS dopamine; CREATE TABLE dopamine AS
-- This query extracts dose+durations of dopamine administration
-- Local hospital dosage guidance: 2 mcg/kg/min (low) - 10 mcg/kg/min (high)
SELECT
stay_id, linkorderid
-- all rows in mcg/kg/min
Expand Down
1 change: 1 addition & 0 deletions mimic-iv/concepts_postgres/medication/epinephrine.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
-- THIS SCRIPT IS AUTOMATICALLY GENERATED. DO NOT EDIT IT DIRECTLY.
DROP TABLE IF EXISTS epinephrine; CREATE TABLE epinephrine AS
-- This query extracts dose+durations of epinephrine administration
-- Local hospital dosage guidance: 0.2 mcg/kg/min (low) - 2 mcg/kg/min (high)
SELECT
stay_id, linkorderid
-- all rows in mcg/kg/min
Expand Down
1 change: 1 addition & 0 deletions mimic-iv/concepts_postgres/medication/milrinone.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
-- THIS SCRIPT IS AUTOMATICALLY GENERATED. DO NOT EDIT IT DIRECTLY.
DROP TABLE IF EXISTS milrinone; CREATE TABLE milrinone AS
-- This query extracts dose+durations of milrinone administration
-- Local hospital dosage guidance: 0.5 mcg/kg/min (usual)
SELECT
stay_id, linkorderid
-- all rows in mcg/kg/min
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,27 @@ DROP TABLE IF EXISTS norepinephrine_equivalent_dose; CREATE TABLE norepinephrine
-- This query calculates norepinephrine equivalent dose for vasopressors.
-- Based on "Vasopressor dose equivalence: A scoping review and
-- suggested formula" by Goradia et al. 2020.

-- The relevant table makes the following equivalences:
-- Norepinephrine - 1:1 - comparison dose of 0.1 ug/kg/min
-- Epinephrine - 1:1 [0.7, 1.4] - 0.1 ug/kg/min
-- Dopamine - 1:100 [75.2, 144.4] - 10 ug/kg/min
-- Metaraminol - 1:8 [8.3] - 0.8 ug/kg/min
-- Phenylephrine - 1:10 [1.1, 16.3] - 1 ug/kg/min
-- Vasopressin - 1:0.4 [0.3, 0.4] - 0.04 units/min
-- Angiotensin II - 1:0.1 [0.07, 0.13] - 0.01 ug/kg/min

SELECT stay_id, starttime, endtime
-- calculate the dose
-- all sources are in mcg/kg/min,
-- except vasopressin which is in units/hour
, ROUND(CAST(
COALESCE(norepinephrine, 0)
+ COALESCE(epinephrine, 0)
+ COALESCE(phenylephrine / 10, 0)
+ COALESCE(dopamine / 100, 0)
-- + metaraminol/8 -- metaraminol not used in BIDMC
+ COALESCE(vasopressin * 2.5, 0)
+ COALESCE(vasopressin * 2.5 / 60, 0)
-- angiotensin_ii*10 -- angiotensin ii rarely used, though
-- it could be included due to norepinephrine sparing effects
AS NUMERIC), 4) AS norepinephrine_equivalent_dose
Expand Down
1 change: 1 addition & 0 deletions mimic-iv/concepts_postgres/medication/phenylephrine.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
-- THIS SCRIPT IS AUTOMATICALLY GENERATED. DO NOT EDIT IT DIRECTLY.
DROP TABLE IF EXISTS phenylephrine; CREATE TABLE phenylephrine AS
-- This query extracts dose+durations of phenylephrine administration
-- Local hospital dosage guidance: 0.5 mcg/kg/min (low) - 5 mcg/kg/min (high)
SELECT
stay_id, linkorderid
-- one row in mcg/min, the rest in mcg/kg/min
Expand Down
14 changes: 7 additions & 7 deletions mimic-iv/concepts_postgres/medication/vasoactive_agent.sql
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ WITH tm AS (
-- left join to raw data tables to combine doses
SELECT t.stay_id, t.starttime, t.endtime
-- inopressors/vasopressors
, dop.vaso_rate AS dopamine
, epi.vaso_rate AS epinephrine
, nor.vaso_rate AS norepinephrine
, phe.vaso_rate AS phenylephrine
, vas.vaso_rate AS vasopressin
, dop.vaso_rate AS dopamine -- mcg/kg/min
, epi.vaso_rate AS epinephrine -- mcg/kg/min
, nor.vaso_rate AS norepinephrine -- mcg/kg/min
, phe.vaso_rate AS phenylephrine -- mcg/kg/min
, vas.vaso_rate AS vasopressin -- units/hour
-- inodialators
, dob.vaso_rate AS dobutamine
, mil.vaso_rate AS milrinone
, dob.vaso_rate AS dobutamine -- mcg/kg/min
, mil.vaso_rate AS milrinone -- mcg/kg/min
-- isoproterenol is used in CCU/CVICU but not in metavision
-- other drugs not included here but (rarely) used in the BIDMC:
-- angiotensin II, methylene blue
Expand Down
3 changes: 3 additions & 0 deletions mimic-iv/concepts_postgres/medication/vasopressin.sql
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
-- THIS SCRIPT IS AUTOMATICALLY GENERATED. DO NOT EDIT IT DIRECTLY.
DROP TABLE IF EXISTS vasopressin; CREATE TABLE vasopressin AS
-- This query extracts dose+durations of vasopressin administration
-- Local hospital dosage guidance: 1.2 units/hour (low) - 2.4 units/hour (high)
SELECT
stay_id, linkorderid
-- three rows in units/min, rest in units/hour
-- the three rows in units/min look reasonable and
-- fit with the patient course

-- convert all rows to units/hour
, CASE WHEN rateuom = 'units/min' THEN rate * 60.0
ELSE rate END AS vaso_rate
, amount AS vaso_amount
Expand Down

0 comments on commit f02600d

Please sign in to comment.