forked from Erinaceida/mimic3cancerpromin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
00 create trans admissions and select cancer admissions.txt
61 lines (60 loc) · 1.42 KB
/
00 create trans admissions and select cancer admissions.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// create transactional table from admissions
CREATE TABLE mimiciii.admission_trans AS
(SELECT DISTINCT
admissions.subject_id,
admissions.hadm_id,
'admission' AS activity,
admissions.admittime AS charttime
FROM
mimiciii.admissions
WHERE admittime IS NOT NULL
UNION ALL
SELECT DISTINCT
admissions.subject_id,
admissions.hadm_id,
'discharge',
admissions.dischtime
FROM
mimiciii.admissions
WHERE dischtime IS NOT NULL
UNION ALL
SELECT DISTINCT
admissions.subject_id,
admissions.hadm_id,
'death',
admissions.deathtime
FROM
mimiciii.admissions
WHERE deathtime IS NOT NULL
UNION ALL
SELECT DISTINCT
admissions.subject_id,
admissions.hadm_id,
'ED registration',
admissions.edregtime
FROM
mimiciii.admissions
WHERE edregtime IS NOT NULL
UNION ALL
SELECT DISTINCT
admissions.subject_id,
admissions.hadm_id,
'ED out',
admissions.edouttime
FROM
mimiciii.admissions
WHERE edouttime IS NOT NULL)
ORDER BY subject_id, hadm_id, charttime, activity;
//select admission records of cancer patients
CREATE TABLE cancer.admissions AS
SELECT DISTINCT
admission_trans.subject_id,
admission_trans.hadm_id,
admission_trans.activity,
admission_trans.charttime
FROM
mimiciii.admission_trans,
mimiciii.diagnoses_icd
WHERE
admission_trans.hadm_id = diagnoses_icd.hadm_id AND
diagnoses_icd.icd9_code BETWEEN '14%' AND '24%';