Skip to content

Commit

Permalink
fix: exclude non-ml units
Browse files Browse the repository at this point in the history
  • Loading branch information
aegis301 committed Feb 26, 2024
1 parent 27f75b8 commit 90f5e00
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions mimic-iv/concepts_postgres/measurement/daily_fluid_in.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ CREATE TABLE mimiciv_derived.daily_fluid_in AS
WITH RECURSIVE infusion_days AS
(
SELECT stay_id,
CAST(starttime AS DATE) AS infusion_date,
CASE
CAST(starttime AS DATE) AS infusion_date,
CASE
WHEN CAST(starttime AS DATE) = CAST(endtime AS DATE) THEN amount
ELSE amount / EXTRACT(EPOCH FROM (endtime - starttime)) / 3600 * (24 - EXTRACT(HOUR FROM starttime))
END AS daily_amount,
endtime
endtime
FROM mimiciv_icu.inputevents
WHERE amountuom = 'ml'
)
SELECT stay_id, infusion_date, SUM(daily_amount) AS total_daily_amount
FROM infusion_days
Expand Down

0 comments on commit 90f5e00

Please sign in to comment.