Skip to content

Commit

Permalink
Merge pull request MIT-LCP#395 from MIT-LCP/icustay
Browse files Browse the repository at this point in the history
Icustay script minor changes
  • Loading branch information
alistairewj authored Mar 22, 2018
2 parents a0ae6e3 + 55a9238 commit 71f22b9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
-- ------------------------------------------------------------------
-- Title: Detailed information on ICUSTAY_ID
-- Description: This query provides a useful set of information regarding patient
-- ICU stays. The information is combined from the admissions, patients, and
-- icustays tables. It includes age, length of stay, sequence, and expiry flags.
-- ICU stays. The information is combined from the admissions, patients, and
-- icustays tables. It includes age, length of stay, sequence, and expiry flags.
-- MIMIC version: MIMIC-III v1.3
-- ------------------------------------------------------------------

Expand All @@ -16,18 +16,18 @@ CREATE MATERIALIZED VIEW icustay_detail as
SELECT ie.subject_id, ie.hadm_id, ie.icustay_id

-- patient level factors
, pat.gender
, pat.gender, pat.dod

-- hospital level factors
, adm.admittime, adm.dischtime
, ROUND( (CAST(EXTRACT(epoch FROM adm.dischtime - adm.admittime)/(60*60*24) AS numeric)), 4) AS los_hospital
, ROUND( (CAST(EXTRACT(epoch FROM adm.admittime - pat.dob)/(60*60*24*365.242) AS numeric)), 4) AS age
, adm.ethnicity, adm.ADMISSION_TYPE
, ROUND( (CAST(EXTRACT(epoch FROM adm.admittime - pat.dob)/(60*60*24*365.242) AS numeric)), 4) AS admission_age
, adm.ethnicity, adm.admission_type
, adm.hospital_expire_flag
, DENSE_RANK() OVER (PARTITION BY adm.subject_id ORDER BY adm.admittime) AS hospstay_seq
, CASE
WHEN DENSE_RANK() OVER (PARTITION BY adm.subject_id ORDER BY adm.admittime) = 1 THEN 'Y'
ELSE 'N' END AS first_hosp_stay
WHEN DENSE_RANK() OVER (PARTITION BY adm.subject_id ORDER BY adm.admittime) = 1 THEN True
ELSE False END AS first_hosp_stay

-- icu level factors
, ie.intime, ie.outtime
Expand All @@ -36,8 +36,8 @@ SELECT ie.subject_id, ie.hadm_id, ie.icustay_id

-- first ICU stay *for the current hospitalization*
, CASE
WHEN DENSE_RANK() OVER (PARTITION BY ie.hadm_id ORDER BY ie.intime) = 1 THEN 'Y'
ELSE 'N' END AS first_icu_stay
WHEN DENSE_RANK() OVER (PARTITION BY ie.hadm_id ORDER BY ie.intime) = 1 THEN True
ELSE False END AS first_icu_stay

FROM icustays ie
INNER JOIN admissions adm
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion concepts/make-concepts.sql
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

\echo 'Directory 3 of 9: demographics'
\i demographics/HeightWeightQuery.sql
\i demographics/icustay_detail.sql
\i demographics/icustay-detail.sql

\echo 'Directory 4 of 9: firstday'
-- data which is extracted from a patient's first ICU stay
Expand Down

0 comments on commit 71f22b9

Please sign in to comment.