-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAJCC.sql
57 lines (57 loc) · 3.81 KB
/
AJCC.sql
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
CASE
WHEN IFNULL({Medical\Staging T (Stage)},'x',{Medical\Staging T (Stage)}) = 'T4'
OR IFNULL({Medical\Staging N (Regional Lymph Nodes)},'x',{Medical\Staging N (Regional Lymph Nodes)}) = 'N+'
OR IFNULL({Medical\Staging M (Metastases)},'x',{Medical\Staging M (Metastases)}) = 'M+'
THEN 'IV'
WHEN IFNULL({Medical\Staging N (Regional Lymph Nodes)},'x',{Medical\Staging N (Regional Lymph Nodes)}) = 'N0'
AND IFNULL({Medical\Staging M (Metastases)},'x',{Medical\Staging M (Metastases)}) = 'M0'
THEN CASE
WHEN substring(IFNULL({Medical\Staging T (Stage)},'x',{Medical\Staging T (Stage)}),1,2) = 'T3'
THEN 'III'
WHEN IFNULL({Medical\Staging T (Stage)},'x',{Medical\Staging T (Stage)}) = 'T2c'
OR ( ( substring(IFNULL({Medical\Staging T (Stage)},'x',{Medical\Staging T (Stage)}),1,2) = 'T1'
OR substring(IFNULL({Medical\Staging T (Stage)},'x',{Medical\Staging T (Stage)}),1,2) = 'T2')
AND ( IFNULL({Medical\PSA Level at Diagnosis},-1,{Medical\PSA Level at Diagnosis}) >= 20
OR IFNULL({Query\Practical\GleasonScore},-1,{Query\Practical\GleasonScore}) >= 8))
THEN 'IIB'
WHEN ( IFNULL({Medical\Staging T (Stage)},'x',{Medical\Staging T (Stage)}) = 'T2b'
AND ( ( IFNULL({Query\Practical\GleasonScore},-1,{Query\Practical\GleasonScore}) = -1
AND IFNULL({Medical\PSA Level at Diagnosis},-1,{Medical\PSA Level at Diagnosis}) = -1)
OR( IFNULL({Query\Practical\GleasonScore},9999,{Query\Practical\GleasonScore}) <= 7
AND IFNULL({Medical\PSA Level at Diagnosis},9999,{Medical\PSA Level at Diagnosis}) <20)
)
)
OR ( ( IFNULL({Medical\Staging T (Stage)},'x',{Medical\Staging T (Stage)}) = 'T2b'
OR IFNULL({Medical\Staging T (Stage)},'x',{Medical\Staging T (Stage)}) = 'T2'
)
AND IFNULL({Medical\PSA Level at Diagnosis},9999,{Medical\PSA Level at Diagnosis}) <20
AND IFNULL({Medical\PSA Level at Diagnosis},-9,{Medical\PSA Level at Diagnosis}) >=10
AND IFNULL({Query\Practical\GleasonScore},9999,{Query\Practical\GleasonScore}) <= 6
)
OR ( IFNULL({Medical\Staging T (Stage)},'x',{Medical\Staging T (Stage)}) = 'T2a'
AND IFNULL({Query\Practical\GleasonScore},9999,{Query\Practical\GleasonScore}) = 7
AND IFNULL({Medical\PSA Level at Diagnosis},9999,{Medical\PSA Level at Diagnosis}) <20
)
OR ( substring(IFNULL({Medical\Staging T (Stage)},'x',{Medical\Staging T (Stage)}),1,2) = 'T1'
AND (
( IFNULL({Query\Practical\GleasonScore},9999,{Query\Practical\GleasonScore}) <= 6
AND IFNULL({Medical\PSA Level at Diagnosis},9999,{Medical\PSA Level at Diagnosis}) <20
AND IFNULL({Medical\PSA Level at Diagnosis},-1,{Medical\PSA Level at Diagnosis}) >=10)
OR ( IFNULL({Query\Practical\GleasonScore},9999,{Query\Practical\GleasonScore}) = 7
AND IFNULL({Medical\PSA Level at Diagnosis},9999,{Medical\PSA Level at Diagnosis}) <20)
)
)
THEN 'IIA'
WHEN (( substring(IFNULL({Medical\Staging T (Stage)},'x',{Medical\Staging T (Stage)}),1,2) = 'T1'
OR IFNULL({Medical\Staging T (Stage)},'x',{Medical\Staging T (Stage)}) = 'T2a')
AND IFNULL({Query\Practical\GleasonScore},-1,{Query\Practical\GleasonScore}) = -1
AND IFNULL({Medical\PSA Level at Diagnosis},-1,{Medical\PSA Level at Diagnosis}) = -1)
OR ( ( IFNULL({Medical\Staging T (Stage)},'x',{Medical\Staging T (Stage)}) = 'T2a'
OR substring(IFNULL({Medical\Staging T (Stage)},'x',{Medical\Staging T (Stage)}),1,2) = 'T1')
AND IFNULL({Query\Practical\GleasonScore},9999,{Query\Practical\GleasonScore}) <= 6
AND IFNULL({Medical\PSA Level at Diagnosis},9999,{Medical\PSA Level at Diagnosis}) < 10)
THEN 'I'
ELSE 'U'
END
ELSE 'U'
END