-
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
DuckDB MIMIC-III concepts implementation #1529
Open
SphtKr
wants to merge
20
commits into
MIT-LCP:main
Choose a base branch
from
SphtKr:duckdb-concepts
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
b1ac9a5
First "working" version (all SQL runs except for a few pivot concepts…
4da73b2
Stripped dead code
4eb302f
Simplify pathing, strip more dead code
d1fb76b
Align with shell script version
8274982
Add requirements.txt
4b0ac76
Pulled sql out of .sh plus minor related mods
a7d0597
Add table creation/loading
92c7388
Schema support (option) to mirror psql version
be78589
Another chunk of dead code
43a67ad
Big bug in DatetimeDiff implementation!
382c7ff
Adding missing fluid_balance views
99ef1f3
missed deletion
2b877a8
Rename in line with Postgres
f74a4eb
Adding indexes
91fed32
Added checks
9dea287
Updating README.md
060cc71
Missed file rename
e36f49c
Move fake CHARTEVENTS PK to indexes script -- this may fail on machin…
SphtKr 6ba9ce7
Fixed outright errors
206c0f7
Experimental option to use integer or fractional DATETIME_DIFF function
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
WITH all_hours AS ( | ||
SELECT | ||
it.icustay_id, /* ceiling the intime to the nearest hour by adding 59 minutes then truncating */ | ||
DATE_TRUNC('hour', it.intime_hr + INTERVAL '59' minute) AS endtime, /* create integers for each charttime in hours from admission */ | ||
/* so 0 is admission time, 1 is one hour after admission, etc, up to ICU disch */ | ||
GENERATE_SERIES( | ||
-24, | ||
CAST(CEIL(EXTRACT(EPOCH FROM it.outtime_hr - it.intime_hr) / 60.0 / 60.0) AS INT) | ||
) AS hr | ||
FROM icustay_times AS it | ||
) | ||
SELECT | ||
ah.icustay_id, | ||
unnest(ah.hr) as hr, | ||
/* endtime now indexes the end time of every hour for each patient */ | ||
unnest(list_transform(hr, ahr -> ah.endtime + ahr*INTERVAL 1 hour)) AS endtime | ||
--ah.endtime+ hr*INTERVAL 1 hour as endtime | ||
FROM all_hours AS ah | ||
ORDER BY | ||
ah.icustay_id NULLS LAST |
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.
for consistency this file would be better placed in mimic-iii/concepts_duckdb/icustay_hours.sql - this seems doable with the python script