-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mimic-iv/concepts: fix postgres-make-concepts
and minor updates
#1363
Merged
alistairewj
merged 8 commits into
MIT-LCP:main
from
schu:schu/fix-mimic-iv-concepts-postgres-setup
Oct 4, 2022
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b6d6b6d
mimic-iv/concepts/convert_bigquery_to_postgres: fix regular expressions
schu f689125
mimic-iv/concepts: fix relation names
schu f9de3b7
mimic-iv/concepts/postgres/medication: add remaining files
schu b6b3fb5
mimic-iv/concepts/postgres/postgres-make-concepts: fix order
schu 842e1b6
add CAST(... AS NUMERIC) for ROUND() calls, remove perl regex
alistairewj 5eb083e
add cast as numeric to round statement
alistairewj f66606f
move table check code into an array, add tables to it
alistairewj 7d72fef
rerun convert shell script to incorporate round/cast changes
alistairewj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
-- 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 | ||
select | ||
stay_id, linkorderid | ||
-- all rows in mcg/kg/min | ||
, rate as vaso_rate | ||
, amount as vaso_amount | ||
, starttime | ||
, endtime | ||
from mimiciv_icu.inputevents | ||
where itemid = 221986 -- milrinone |
24 changes: 24 additions & 0 deletions
24
mimic-iv/concepts/postgres/medication/norepinephrine_equivalent_dose.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
-- THIS SCRIPT IS AUTOMATICALLY GENERATED. DO NOT EDIT IT DIRECTLY. | ||
DROP TABLE IF EXISTS norepinephrine_equivalent_dose; CREATE TABLE norepinephrine_equivalent_dose AS | ||
-- This query calculates norepinephrine equivalent dose for vasopressors. | ||
-- Based on "Vasopressor dose equivalence: A scoping review and suggested formula" | ||
-- by Goradia et al. 2020. | ||
SELECT stay_id, starttime, endtime | ||
-- calculate the dose | ||
, 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) | ||
-- angotensin_ii*10 -- angitensin ii rarely used, currently not incorporated | ||
-- (it could be included due to norepinephrine sparing effects) | ||
as numeric), 4) AS norepinephrine_equivalent_dose | ||
-- angotensin_ii*10 -- angitensin ii rarely used, currently not incorporated | ||
-- (it could be included due to norepinephrine sparing effects) | ||
FROM mimiciv_derived.vasoactive_agent | ||
WHERE norepinephrine IS NOT NULL | ||
OR epinephrine IS NOT NULL | ||
OR phenylephrine IS NOT NULL | ||
OR dopamine IS NOT NULL | ||
OR vasopressin IS NOT NULL; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The regex is rather fragile.
Would it be possible to always
ROUND(CAST(... as numeric), ...)
in the BigQuery SQL code to make the transformation for postgres unnecessary? For examplemimic-code/mimic-iv/concepts/measurement/urine_output_rate.sql
Line 80 in 14b9f5f
CAST
. In the postgres code this leads toROUND(CAST(CAST(... as numeric) as numeric), 4)
.Ideas welcome.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah these regexes are in general terrifying.... since we're starting to come up with non-standard rules for the SQL, we should probably put them somewhere. First thought is the style guide might be a reasonable place (albeit not perfect).
I think the change you're suggesting makes sense, and I'd be happy to get rid of the perl regex, so I'll investigate by bringing this into a branch (tests won't run successfully on external PRs).