I'm currently running MIMIC-III on PostgreSQL through pgAdmin III on a windows installation, and I just tried going through the last part of the 'Patient age and mortality' tutorial. I noticed a couple of things that didn't work on my installation of MIMIC.
The main thing was the 'months_between' function, supposedly it doesn't exist on PostgreSQL. I think the query on the website could be for an Oracle installation.
Here is the full query I ran that resulted in what I was looking for (changed lines marked with %):
WITH first_admission_time AS (
SELECT
p.subject_id, p.dob, p.gender,
MIN (a.admittime) AS first_admittime
%FROM mimiciii.patients p
%INNER JOIN mimiciii.admissions a
ON p.subject_id = a.subject_id
%GROUP BY p.subject_id, p.dob, p.gender, a.hadm_id
ORDER BY a.hadm_id, p.subject_id
),
age AS (
SELECT
subject_id, dob, gender, first_admittime,
% age(first_admittime, dob)
AS first_admit_age,
CASE
% WHEN age(first_admittime, dob) > '89 years'
% THEN '>89'
% WHEN age(first_admittime, dob) >= '15 years'
THEN 'adult'
% WHEN age(first_admittime, dob) <= '1 year'
THEN 'neonate'
ELSE 'middle'
END AS age_group
FROM first_admission_time
ORDER BY subject_id
)
SELECT *
FROM age;
This query gives the age in years, months, days, and hours so there could be a more relevant function depending on what you need age for. The reasons behind these changes are outlined below:
Since the tutorial page says that the tutorial should be run on a PostgreSQL installation I'm concerned that maybe my set-up or query is incorrect. I also have limited programming/sql knowledge so something else may have gone wrong along the way.
Another interesting note is that there were no patients in the database with an age between 5 months and 14 years. Is this because there is no data from the paediatric ICU?