ONCSG1 ;Hines OIFO/GWB - Automatic Staging Tables ;10/28/10
;;2.2;ONCOLOGY;**1,4**;Jul 31, 2013;Build 5
;
;DIGESTIVE SYSTEM
;
ESO1234 ;Esophagus - 1st, 2nd, 3rd and 4th editions
I M[1 S SG=4
E I T["IS",N[0,M[0 S SG=0
E I T[1,N[0,M[0 S SG=1
E I (T[2)!(T[3),N[0,M[0 S SG="2A"
E I (T[1)!(T[2),N[1,M[0 S SG="2B"
E I T[3,N[1,M[0 S SG=3
E I T[4,M[0 S SG=3
E S SG=99
Q
;
ESO56 ;Esophagus - 5th and 6th editions
S TNM=T_N_M D K TNM Q
.I TNM="IS00" S SG=0 Q ;0 Tis N0 M0
.I TNM=100 S SG=1 Q ;I T1 N0 M0
.I TNM=200 S SG="2A" Q ;IIA T2 N0 M0
.I TNM=300 S SG="2A" Q ; T3 N0 M0
.I TNM=110 S SG="2B" Q ;IIB T1 N1 M0
.I TNM=210 S SG="2B" Q ; T2 N1 M0
.I TNM=310 S SG=3 Q ;III T3 N1 M0
.I T=4,M=0 S SG=3 Q ; T4 Any N M0
.I M=1 S SG=4 Q ;IV Any T Any N M1
.I M="1A" S SG="4A" Q ;IVA Any T Any N M1a
.I M="1B" S SG="4B" Q ;IVB Any T Any N M1b
;
ESO7 ;Esophagus - 7th edition (+ some Stomach/GE Junction cases)
N VAR I (TX=67160)!(TX=67161)!(TX=67162) D G:VAR="S" ESO7A G:VAR="A" ESO7B
.S VAR="A"
.I ($E(HT,1,4)>7999)&($E(HT,1,4)<8047) S VAR="S" Q
.I ($E(HT,1,4)>8050)&($E(HT,1,4)<8032) S VAR="S" Q
.I ($E(HT,1,4)>8147)&($E(HT,1,4)<8153) S VAR="S" Q
.I ($E(HT,1,4)>8153)&($E(HT,1,4)<8158) S VAR="S" Q
.I ($E(HT,1,4)>8169)&($E(HT,1,4)<8176) S VAR="S" Q
.I ($E(HT,1,4)>8229)&($E(HT,1,4)<8232) S VAR="S" Q
.I ($E(HT,1,4)>8244)&($E(HT,1,4)<8246) S VAR="S" Q
.I ($E(HT,1,4)>8246)&($E(HT,1,4)<8249) S VAR="S" Q
.I ($E(HT,1,4)>8507)&($E(HT,1,4)<8514) S VAR="S" Q
.I ($E(HT,1,4)>8559)&($E(HT,1,4)<8571) S VAR="S" Q
.I ($E(HT,1,4)=8575)!($E(HT,1,4)=8950) S VAR="S" Q
.I ($E(HT,1,4)>8979)&($E(HT,1,4)<8982) S VAR="S" Q
.I ($E(HT,1,4)=8050)!($E(HT,1,4)=8576) S VAR="A" Q
.I ($E(HT,1,4)>8139)&($E(HT,1,4)<8148) S VAR="A" Q
.I ($E(HT,1,4)>8159)&($E(HT,1,4)<8163) S VAR="A" Q
.I ($E(HT,1,4)>8179)&($E(HT,1,4)<8222) S VAR="A" Q
.I ($E(HT,1,4)>8249)&($E(HT,1,4)<8508) S VAR="A" Q
.I ($E(HT,1,4)>8513)&($E(HT,1,4)<8552) S VAR="A" Q
.I ($E(HT,1,4)>8570)&($E(HT,1,4)<8575) S VAR="A" Q
.I ($E(HT,1,4)>8939)&($E(HT,1,4)<8942) S VAR="A" Q
I ($E(HT,1,3)>804)&($E(HT,1,3)<808) G ESO7A
E G ESO7B
ESO7A ;Squamous Cell Carcinoma
I T="IS" S TNM=T_N_M
E S TNM=$E(T,1)_N_M
D K TNM Q
.I TNM="IS00" S SG=0 Q
.I (TNM=100)&((G=1)!(G=9)) S SG="1A" Q
.I (TNM=100)&((G=2)!(G=3)) S SG="1B" Q
.I TNM=100 S SG="1A" Q
.I ((TNM=200)!(TNM=300))&((G=1)!(G=9))&((TX=67152)!(TX=67155)!(TX=67160)!(TX=67161)!(TX=67162)) S SG="1B" Q
.I ((TNM=200)!(TNM=300))&((G=1)!(G=9))&((TX=67150)!(TX=67151)!(TX=67153)!(TX=67154)) S SG="2A" Q
.I ((TNM=200)!(TNM=300))&((G=2)!(G=3))&((TX=67152)!(TX=67155)!(TX=67160)!(TX=67161)!(TX=67162)) S SG="2A" Q
.I ((TNM=200)!(TNM=300))&((G=2)!(G=3))&((TX=67150)!(TX=67151)!(TX=67153)!(TX=67154)) S SG="2B" Q
.I ((TNM=200)!(TNM=300))&(G=1) S SG="1B" Q
.I ((TNM=200)!(TNM=300))&((TX=67152)!(TX=67155)!(TX=67160)!(TX=67161)!(TX=67162)) S SG="1B" Q
.I ((TNM=200)!(TNM=300))&((TX=67150)!(TX=67151)!(TX=67153)!(TX=67154)) S SG="2A" Q
.I ((TNM=200)!(TNM=300))&((G=2)!(G=3)) S SG="2A" Q
.I (TNM=200)!(TNM=300) S SG="1B" Q
.I (TNM=110)!(TNM=210) S SG="2B" Q
.I (TNM=120)!(TNM=220) S SG="3A" Q
.I TNM=310 S SG="3A" Q
.I (T="4A")&(N=0)&(M=0) S SG="3A" Q
.I TNM=320 S SG="3B" Q
.I ((TNM="410")!(TNM="420")) S SG="3C" Q
.I (T="4B")&(M=0) S SG="3C" Q
.I (N=3)&(M=0) S SG="3C" Q
.I M=1 S SG=4 Q
;
ESO7B ;Adenocarcinoma
I T="IS" S TNM=T_N_M
E S TNM=$E(T,1)_N_M
D K TNM Q
.I TNM="IS00" S SG=0 Q
.I (TNM=100)&((G=1)!(G=2)!(G=9)) S SG="1A" Q
.I (TNM=100)&(G=3) S SG="1B" Q
.I (TNM=200)&((G=1)!(G=2)!(G=9)) S SG="1B" Q
.I (TNM=200)&(G=3) S SG="2A" Q
.I (TNM=300) S SG="2B" Q
.I ((TNM=110)!(TNM=210)) S SG="2B" Q
.I ((TNM=120)!(TNM=220)) S SG="3A" Q
.I TNM=310 S SG="3A" Q
.I (T="4A")&(N=0)&(M=0) S SG="3A" Q
.I TNM=320 S SG="3B" Q
.I ((TNM="410")!(TNM="420")) S SG="3C" Q
.I (T="4B")&(M=0) S SG="3C" Q
.I (N=3)&(M=0) S SG="3C" Q
.I M=1 S SG=4 Q
;
STO34 ;Stomach - 3rd and 4th editions
S TNM=T_N_M D K TNM Q
.I TNM="IS00" S SG=0 Q ;0 Tis N0 M0
.I TNM=100 S SG="1A" Q ;IA T1 N0 M0
.I TNM=110 S SG="1B" Q ;IB T1 N1 M0
.I TNM=200 S SG="1B" Q ; T2 N0 M0
.I TNM=120 S SG=2 Q ;II T1 N2 M0
.I TNM=210 S SG=2 Q ; T2 N1 M0
.I TNM=300 S SG=2 Q ; T3 N0 M0
.I TNM=220 S SG="3A" Q ;IIIA T2 N2 M0
.I TNM=310 S SG="3A" Q ; T3 N1 M0
.I TNM=400 S SG="3A" Q ; T4 N0 M0
.I TNM=320 S SG="3B" Q ;IIIB T3 N2 M0
.I TNM=410 S SG="3B" Q ; T4 N1 M0
.I TNM=420 S SG=4 Q ;IV T4 N2 M0
.I M=1 S SG=4 Q ; Any T Any N M1
;
STO5 ;Stomach - 5th edition
S TNM=T_N_M D K TNM Q
.I TNM="IS00" S SG=0 Q ;0 Tis N0 M0
.I TNM=100 S SG="1A" Q ;IA T1 N0 M0
.I TNM=110 S SG="1B" Q ;IB T1 N1 M0
.I TNM=200 S SG="1B" Q ; T2 N0 M0
.I TNM=120 S SG=2 Q ;II T1 N2 M0
.I TNM=210 S SG=2 Q ; T2 N1 M0
.I TNM=300 S SG=2 Q ; T3 N0 M0
.I TNM=220 S SG="3A" Q ;IIIA T2 N2 M0
.I TNM=310 S SG="3A" Q ; T3 N1 M0
.I TNM=400 S SG="3A" Q ; T4 N0 M0
.I TNM=320 S SG="3B" Q ;IIIB T3 N2 M0
.I TNM=410 S SG=4 Q ;IV T4 N1 M0
.I TNM=130 S SG=4 Q ; T1 N3 M0
.I TNM=230 S SG=4 Q ; T2 N3 M0
.I TNM=330 S SG=4 Q ; T3 N3 M0
.I TNM=420 S SG=4 Q ; T4 N2 M0
.I TNM=430 S SG=4 Q ; T4 N3 M0
.I M=1 S SG=4 Q ; Any T Any N M1
;
STO6 ;Stomach - 6th edition
S TNM=T_N_M D K TNM Q
.I TNM="IS00" S SG=0 Q ;0 Tis N0 M0
.I TNM=100 S SG="1A" Q ;IA T1 N0 M0
.I TNM=110 S SG="1B" Q ;IB T1 N1 M0
.I TNM="2A00" S SG="1B" Q ; T2a N0 M0
.I TNM="2B00" S SG="1B" Q ; T2b N0 M0
.I TNM=120 S SG=2 Q ;II T1 N2 M0
.I TNM="2A10" S SG=2 Q ; T2a N1 M0
.I TNM="2B10" S SG=2 Q ; T2b N1 M0
.I TNM=300 S SG=2 Q ; T3 N0 M0
.I TNM="2A20" S SG="3A" Q ;IIIA T2a N2 M0
.I TNM="2B20" S SG="3A" Q ; T2b N2 M0
.I TNM=310 S SG="3A" Q ; T3 N1 M0
.I TNM=400 S SG="3A" Q ; T4 N0 M0
.I TNM=320 S SG="3B" Q ;IIIB T3 N2 M0
.I TNM=410 S SG=4 Q ;IV T4 N1 M0
.I TNM=130 S SG=4 Q ; T1 N3 M0
.I TNM="2A30" S SG=4 Q ; T2a N3 M0
.I TNM="2B30" S SG=4 Q ; T2b N3 M0
.I TNM=330 S SG=4 Q ; T3 N3 M0
.I TNM=420 S SG=4 Q ; T4 N2 M0
.I TNM=430 S SG=4 Q ; T4 N3 M0
.I M=1 S SG=4 Q ; Any T Any N M1
;
STO7 ;Stomach - 7th edition
I $E(T,1)=1 S T=$E(T,1)
I $E(N,1)=3 S N=$E(N,1)
S TNM=T_N_M D K TNM Q
.I TNM="IS00" S SG=0 Q ;0 Tis N0 M0
.I TNM=100 S SG="1A" Q ;IA T1 N0 M0
.I TNM=200 S SG="1B" Q ;IB T2 N0 M0
.I TNM=110 S SG="1B" Q ; T1 N1 M0
.I TNM=300 S SG="2A" Q ;IIA T3 N0 M0
.I TNM=210 S SG="2A" Q ; T2 N1 M0
.I TNM=120 S SG="2A" Q ; T1 N2 M0
.I TNM="4A00" S SG="2B" Q ;IIB T4a N0 M0
.I TNM=310 S SG="2B" Q ; T3 N1 M0
.I TNM=220 S SG="2B" Q ; T2 N2 M0
.I TNM=130 S SG="2B" Q ; T1 N3 M0
.I TNM="4A10" S SG="3A" Q ;IIIA T4a N1 M0
.I TNM=320 S SG="3A" Q ; T3 N2 M0
.I TNM=230 S SG="3A" Q ; T2 N3 M0
.I TNM="4B00" S SG="3B" Q ;IIIB T4b N0 M0
.I TNM="4B10" S SG="3B" Q ; T4b N1 M0
.I TNM="4A20" S SG="3B" Q ; T4a N2 M0
.I TNM=330 S SG="3B" Q ; T3 N3 M0
.I TNM="4B20" S SG="3C" Q ;IIIC T4b N2 M0
.I TNM="4B30" S SG="3C" Q ; T4b N3 M0
.I TNM="4A30" S SG="3C" Q ; T4a N3 M0
.I M=1 S SG=4 Q ; Any T Any N M1
;
SI456 ;Small Intestine - 4th, 5th and 6th editions
I M S SG=4
E I T["IS",N[0,M[0 S SG=0
E I (T[1)!(T[2),N[0,M[0 S SG=1
E I (T[3)!(T[4),N[0,M[0 S SG=2
E I N[1,M[0 S SG=3
E S SG=99
Q
;
SI7 ;Small Intestine - 7th edition
S TNM=T_N_M D K TNM Q
.I TNM="IS00" S SG=0 Q ;0 Tis N0 M0
.I TNM="1A00" S SG=1 Q ;I T1a N0 M0
.I TNM="1B00" S SG=1 Q ;I T1b N0 M0
.I TNM=200 S SG=1 Q ; T2 N0 M0
.I TNM=300 S SG="2A" Q ;IIA T3 N0 M0
.I TNM=400 S SG="2B" Q ;IIB T0 N0 M0
.I N=1,M=0 S SG="3A" Q ;IIIA Any T N1 M0
.I N=2,M=0 S SG="3B" Q ;IIIB Any T N2 M0
.I M=1 S SG=4 Q ;IV Any T Any N M1
;
APP7 ;Appendix- 7th edition
N HT14
S HT14=$E(HT,1,4)
I (HT14=8153)!(HT14=8240)!(HT14=8241)!(HT14=8242)!(HT14=8246)!(HT14=8249) G APP7B
;
APP7A ;Carcinoma
S TNM=T_N_M D K TNM Q
.I TNM="IS00" S SG=0 Q ;0 Tis N0 M0
.I TNM=100 S SG=1 Q ;I T1 N0 M0
.I TNM=200 S SG=1 Q ;I T2 N0 M0
.I TNM=300 S SG="2A" Q ;IIA T3 N0 M0
.I TNM="4A00" S SG="2B" Q ;IIB T4a N0 M0
.I TNM="4B00" S SG="2C" Q ;IIC T4b N0 M0
.I TNM=110 S SG="3A" Q ;IIIA T1 N1 M0
.I TNM=210 S SG="3A" Q ; T2 N1 M0
.I TNM=310 S SG="3B" Q ;IIIB T3 N1 M0
.I TNM=410 S SG="3B" Q ; T4 N1 M0
.I N=2,M=0 S SG="3C" Q ;IIIC Any T N2 M0
.I N=0,M="1A",G=1 S SG="4A" Q ;IVA Any T N0 M1a G1
.I N=0,M="1A",(G=2)!(G=3) S SG="4B" Q ;IVB Any T N0 M1a G2,3
.I N=1,M="1A" S SG="4B" Q ; Any T N1 M1a Any G
.I N=2,M="1A" S SG="4B" Q ; Any T N2 M1a Any G
.I M="1B" S SG="4C" Q ;IVC Any T Any N M1b Any G
;
APP7B ;Carcinoid
S TNM=T_N_M D K TNM Q
.I TNM=100 S SG=1 Q ;I T1 N0 M0
.I TNM=200 S SG=2 Q ;II T2 N0 M0
.I TNM=300 S SG=2 Q ; T3 N0 M0
.I TNM=400 S SG=3 Q ;III T4 N0 M0
.I N=1,M=0 S SG=3 Q ; Any T N1 M0
.I M=1 S SG=4 Q ;IV Any T Any N M1
;
COL34 ;Colon and Rectum - 3rd and 4th editions
S TNM=T_N_M D K TNM Q
.I TNM="IS00" S SG=0 Q ;0 Tis N0 M0
.I TNM=100 S SG=1 Q ;I T1 N0 M0
.I TNM=200 S SG=1 Q ; T2 N0 M0
.I TNM=300 S SG=2 Q ;II T3 N0 M0
.I TNM=400 S SG=2 Q ; T4 N0 M0
.I N=1,M=0 S SG=3 Q ;III Any T N1 M0
.I N=2,M=0 S SG=3 Q ; Any T N2 M0
.I N=3,M=0 S SG=3 Q ; Any T N3 M0
.I M=1 S SG=4 Q ;IV Any T Any N M1
;
COL5 ;Colon and Rectum - 5th edition
S TNM=T_N_M D K TNM Q
.I TNM="IS00" S SG=0 Q ;0 Tis N0 M0
.I TNM=100 S SG=1 Q ;I T1 N0 M0
.I TNM=200 S SG=1 Q ; T2 N0 M0
.I TNM=300 S SG=2 Q ;II T3 N0 M0
.I TNM=400 S SG=2 Q ; T4 N0 M0
.I N=1,M=0 S SG=3 Q ;III Any T N1 M0
.I N=2,M=0 S SG=3 Q ; Any T N2 M0
.I M=1 S SG=4 Q ;IV Any T Any N M1
;
COL6 ;Colon and Rectum - 6th edition
S TNM=T_N_M D K TNM Q
.I TNM="IS00" S SG=0 Q ;0 Tis N0 M0
.I TNM=100 S SG=1 Q ;I T1 N0 M0
.I TNM=200 S SG=1 Q ; T2 N0 M0
.I TNM=300 S SG="2A" Q ;IIA T3 N0 M0
.I TNM=400 S SG="2B" Q ;IIB T4 N0 M0
.I TNM=110 S SG="3A" Q ;IIIA T1 N1 M0
.I TNM=210 S SG="3A" Q ; T2 N1 M0
.I TNM=310 S SG="3B" Q ;IIIB T3 N1 M0
.I TNM=410 S SG="3B" Q ; T4 N1 M0
.I N=2,M=0 S SG="3C" Q ;IIIC Any T N2 M0
.I M=1 S SG=4 Q ;IV Any T Any N M1
;
COL7 ;Colon and Rectum - 7th edition
S TNM=T_N_M D K TNM Q
.I TNM="IS00" S SG=0 Q
.I TNM=100 S SG=1 Q
.I TNM=200 S SG=1 Q
.I TNM=300 S SG="2A" Q
.I TNM="4A00" S SG="2B" Q
.I TNM="4B00" S SG="2C" Q
.I ((T=1)!(T=2))&($E(N,1)=1)&(M=0) S SG="3A" Q
.I TNM="12A0" S SG="3A" Q
.I ((T=3)!(T="4A"))&($E(N,1)=1)&(M=0) S SG="3B" Q
.I ((TNM="22A0")!(TNM="32A0")) S SG="3B" Q
.I ((TNM="12B0")!(TNM="22B0")) S SG="3B" Q
.I TNM="4A2A0" S SG="3C" Q
.I ((TNM="32B0")!(TNM="4A2B0")!(TNM="4A20")) S SG="3C" Q
.I ((TNM="4B10")!(TNM="4B20")) S SG="3C" Q
.I ((TNM="4B1A0")!(TNM="4B1B0")!(TNM="4B1C0")!(TNM="4B2A0")!(TNM="4B2B0")) S SG="3C" Q
.I M="1A" S SG="4A" Q
.I M="1B" S SG="4B" Q
;
AC ;Anus - all editions
S TNM=T_N_M D K TNM Q
.I TNM="IS00" S SG=0 Q ;0 Tis N0 M0
.I TNM=100 S SG=1 Q ;I T1 N0 M0
.I TNM=200 S SG=2 Q ;II T2 N0 M0
.I TNM=300 S SG=2 Q ; T3 N0 M0
.I TNM=110 S SG="3A" Q ;IIIA T1 N1 M0
.I TNM=210 S SG="3A" Q ; T2 N1 M0
.I TNM=310 S SG="3A" Q ; T3 N1 M0
.I TNM=400 S SG="3A" Q ; T4 N0 M0
.I TNM=410 S SG="3B" Q ;IIIB T4 N1 M0
.I N=2,M=0 S SG="3B" Q ; Any T N2 M0
.I N=3,M=0 S SG="3B" Q ; Any T N3 M0
.I M=1 S SG=4 Q ;IV Any T Any N M1
;
GIST ;Gastrointestinal Stromal Tumor - 7th Edition
N MR
S MR=$P($G(^ONCO(165.5,D0,2.3)),U,9)
I MR="" W !!?12,"MITOTIC RATE is required for AJCC 7th Edition GIST staging." Q
I $E(TX,3,4)=16 G GASTRIC
SI ;Small Intestinal GIST - 7th Edition
S TNM=T_N_M D K TNM Q
.I TNM=100,MR="L" S SG=1 Q ;I T1 N0 M0 Low
.I TNM=200,MR="L" S SG=1 Q ; T2 N0 M0 Low
.I TNM=300,MR="L" S SG=2 Q ;II T3 N0 M0 Low
.I TNM=100,MR="H" S SG="3A" Q ;IIIA T1 N0 M0 High
.I TNM=400,MR="L" S SG="3A" Q ; T4 N0 M0 Low
.I TNM=200,MR="H" S SG="3B" Q ;IIIB T2 N0 M0 High
.I TNM=300,MR="H" S SG="3B" Q ; T3 N0 M0 High
.I TNM=400,MR="H" S SG="3B" Q ; T4 N0 M0 High
.I N=1,M=0 S SG=4 Q ;IV Any T N1 M0 Any rate
.I M=1 S SG=4 Q ; Any T Any N M1 Any rate
;
GASTRIC ;Gastric GIST
S TNM=T_N_M D K TNM Q
.I TNM=100,MR="L" S SG="1A" Q ;IA T1 N0 M0 Low
.I TNM=200,MR="L" S SG="1A" Q ; T2 N0 M0 Low
.I TNM=300,MR="L" S SG="1B" Q ;IB T3 N0 M0 Low
.I TNM=100,MR="H" S SG=2 Q ;II T1 N0 M0 High
.I TNM=200,MR="H" S SG=2 Q ; T2 N0 M0 High
.I TNM=400,MR="L" S SG=2 Q ; T4 N0 M0 Low
.I TNM=300,MR="H" S SG="3A" Q ;IIIA T3 N0 M0 High
.I TNM=400,MR="H" S SG="3B" Q ;IIIB T4 N0 M0 High
.I N=1,M=0 S SG=4 Q ;IV Any T N1 M0 Any rate
.I M=1 S SG=4 Q ; Any T Any N M1 Any rate
;
NT ;Neuroendocrine Tumor - 7th Edition
S TNM=$E(T,1)_N_M D K TNM Q
.I TNM="IS00",$E(TX,3,4)=16 S SG=0 Q ;0 Tis* N0 M0
.I TNM=100 S SG=1 Q ;I T1 N0 M0
.I TNM=200 S SG="2A" Q ;IIA T2 N0 M0
.I TNM=300 S SG="2B" Q ;IIB T3 N0 M0
.I TNM=400 S SG="3A" Q ;IIIA T4 N0 M0
.I N=1,M=0 S SG="3B" Q ;IIIB Any T N1 M0
.I M=1 S SG=4 Q ;IV Any T Any N M1
; ;Note: TIS applies only to stomach
;
CLEANUP ;Cleanup
K D0,G,HT,M,N,SG,T,TX
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HONCSG1 15754 printed Nov 22, 2024@17:38:22 Page 2
ONCSG1 ;Hines OIFO/GWB - Automatic Staging Tables ;10/28/10
+1 ;;2.2;ONCOLOGY;**1,4**;Jul 31, 2013;Build 5
+2 ;
+3 ;DIGESTIVE SYSTEM
+4 ;
ESO1234 ;Esophagus - 1st, 2nd, 3rd and 4th editions
+1 IF M[1
SET SG=4
+2 IF '$TEST
IF T["IS"
IF N[0
IF M[0
SET SG=0
+3 IF '$TEST
IF T[1
IF N[0
IF M[0
SET SG=1
+4 IF '$TEST
IF (T[2)!(T[3)
IF N[0
IF M[0
SET SG="2A"
+5 IF '$TEST
IF (T[1)!(T[2)
IF N[1
IF M[0
SET SG="2B"
+6 IF '$TEST
IF T[3
IF N[1
IF M[0
SET SG=3
+7 IF '$TEST
IF T[4
IF M[0
SET SG=3
+8 IF '$TEST
SET SG=99
+9 QUIT
+10 ;
ESO56 ;Esophagus - 5th and 6th editions
+1 SET TNM=T_N_M
Begin DoDot:1
+2 ;0 Tis N0 M0
IF TNM="IS00"
SET SG=0
QUIT
+3 ;I T1 N0 M0
IF TNM=100
SET SG=1
QUIT
+4 ;IIA T2 N0 M0
IF TNM=200
SET SG="2A"
QUIT
+5 ; T3 N0 M0
IF TNM=300
SET SG="2A"
QUIT
+6 ;IIB T1 N1 M0
IF TNM=110
SET SG="2B"
QUIT
+7 ; T2 N1 M0
IF TNM=210
SET SG="2B"
QUIT
+8 ;III T3 N1 M0
IF TNM=310
SET SG=3
QUIT
+9 ; T4 Any N M0
IF T=4
IF M=0
SET SG=3
QUIT
+10 ;IV Any T Any N M1
IF M=1
SET SG=4
QUIT
+11 ;IVA Any T Any N M1a
IF M="1A"
SET SG="4A"
QUIT
+12 ;IVB Any T Any N M1b
IF M="1B"
SET SG="4B"
QUIT
End DoDot:1
KILL TNM
QUIT
+13 ;
ESO7 ;Esophagus - 7th edition (+ some Stomach/GE Junction cases)
+1 NEW VAR
IF (TX=67160)!(TX=67161)!(TX=67162)
Begin DoDot:1
+2 SET VAR="A"
+3 IF ($EXTRACT(HT,1,4)>7999)&($EXTRACT(HT,1,4)<8047)
SET VAR="S"
QUIT
+4 IF ($EXTRACT(HT,1,4)>8050)&($EXTRACT(HT,1,4)<8032)
SET VAR="S"
QUIT
+5 IF ($EXTRACT(HT,1,4)>8147)&($EXTRACT(HT,1,4)<8153)
SET VAR="S"
QUIT
+6 IF ($EXTRACT(HT,1,4)>8153)&($EXTRACT(HT,1,4)<8158)
SET VAR="S"
QUIT
+7 IF ($EXTRACT(HT,1,4)>8169)&($EXTRACT(HT,1,4)<8176)
SET VAR="S"
QUIT
+8 IF ($EXTRACT(HT,1,4)>8229)&($EXTRACT(HT,1,4)<8232)
SET VAR="S"
QUIT
+9 IF ($EXTRACT(HT,1,4)>8244)&($EXTRACT(HT,1,4)<8246)
SET VAR="S"
QUIT
+10 IF ($EXTRACT(HT,1,4)>8246)&($EXTRACT(HT,1,4)<8249)
SET VAR="S"
QUIT
+11 IF ($EXTRACT(HT,1,4)>8507)&($EXTRACT(HT,1,4)<8514)
SET VAR="S"
QUIT
+12 IF ($EXTRACT(HT,1,4)>8559)&($EXTRACT(HT,1,4)<8571)
SET VAR="S"
QUIT
+13 IF ($EXTRACT(HT,1,4)=8575)!($EXTRACT(HT,1,4)=8950)
SET VAR="S"
QUIT
+14 IF ($EXTRACT(HT,1,4)>8979)&($EXTRACT(HT,1,4)<8982)
SET VAR="S"
QUIT
+15 IF ($EXTRACT(HT,1,4)=8050)!($EXTRACT(HT,1,4)=8576)
SET VAR="A"
QUIT
+16 IF ($EXTRACT(HT,1,4)>8139)&($EXTRACT(HT,1,4)<8148)
SET VAR="A"
QUIT
+17 IF ($EXTRACT(HT,1,4)>8159)&($EXTRACT(HT,1,4)<8163)
SET VAR="A"
QUIT
+18 IF ($EXTRACT(HT,1,4)>8179)&($EXTRACT(HT,1,4)<8222)
SET VAR="A"
QUIT
+19 IF ($EXTRACT(HT,1,4)>8249)&($EXTRACT(HT,1,4)<8508)
SET VAR="A"
QUIT
+20 IF ($EXTRACT(HT,1,4)>8513)&($EXTRACT(HT,1,4)<8552)
SET VAR="A"
QUIT
+21 IF ($EXTRACT(HT,1,4)>8570)&($EXTRACT(HT,1,4)<8575)
SET VAR="A"
QUIT
+22 IF ($EXTRACT(HT,1,4)>8939)&($EXTRACT(HT,1,4)<8942)
SET VAR="A"
QUIT
End DoDot:1
if VAR="S"
GOTO ESO7A
if VAR="A"
GOTO ESO7B
+23 IF ($EXTRACT(HT,1,3)>804)&($EXTRACT(HT,1,3)<808)
GOTO ESO7A
+24 IF '$TEST
GOTO ESO7B
ESO7A ;Squamous Cell Carcinoma
+1 IF T="IS"
SET TNM=T_N_M
+2 IF '$TEST
SET TNM=$EXTRACT(T,1)_N_M
+3 Begin DoDot:1
+4 IF TNM="IS00"
SET SG=0
QUIT
+5 IF (TNM=100)&((G=1)!(G=9))
SET SG="1A"
QUIT
+6 IF (TNM=100)&((G=2)!(G=3))
SET SG="1B"
QUIT
+7 IF TNM=100
SET SG="1A"
QUIT
+8 IF ((TNM=200)!(TNM=300))&((G=1)!(G=9))&((TX=67152)!(TX=67155)!(TX=67160)!(TX=67161)!(TX=67162))
SET SG="1B"
QUIT
+9 IF ((TNM=200)!(TNM=300))&((G=1)!(G=9))&((TX=67150)!(TX=67151)!(TX=67153)!(TX=67154))
SET SG="2A"
QUIT
+10 IF ((TNM=200)!(TNM=300))&((G=2)!(G=3))&((TX=67152)!(TX=67155)!(TX=67160)!(TX=67161)!(TX=67162))
SET SG="2A"
QUIT
+11 IF ((TNM=200)!(TNM=300))&((G=2)!(G=3))&((TX=67150)!(TX=67151)!(TX=67153)!(TX=67154))
SET SG="2B"
QUIT
+12 IF ((TNM=200)!(TNM=300))&(G=1)
SET SG="1B"
QUIT
+13 IF ((TNM=200)!(TNM=300))&((TX=67152)!(TX=67155)!(TX=67160)!(TX=67161)!(TX=67162))
SET SG="1B"
QUIT
+14 IF ((TNM=200)!(TNM=300))&((TX=67150)!(TX=67151)!(TX=67153)!(TX=67154))
SET SG="2A"
QUIT
+15 IF ((TNM=200)!(TNM=300))&((G=2)!(G=3))
SET SG="2A"
QUIT
+16 IF (TNM=200)!(TNM=300)
SET SG="1B"
QUIT
+17 IF (TNM=110)!(TNM=210)
SET SG="2B"
QUIT
+18 IF (TNM=120)!(TNM=220)
SET SG="3A"
QUIT
+19 IF TNM=310
SET SG="3A"
QUIT
+20 IF (T="4A")&(N=0)&(M=0)
SET SG="3A"
QUIT
+21 IF TNM=320
SET SG="3B"
QUIT
+22 IF ((TNM="410")!(TNM="420"))
SET SG="3C"
QUIT
+23 IF (T="4B")&(M=0)
SET SG="3C"
QUIT
+24 IF (N=3)&(M=0)
SET SG="3C"
QUIT
+25 IF M=1
SET SG=4
QUIT
End DoDot:1
KILL TNM
QUIT
+26 ;
ESO7B ;Adenocarcinoma
+1 IF T="IS"
SET TNM=T_N_M
+2 IF '$TEST
SET TNM=$EXTRACT(T,1)_N_M
+3 Begin DoDot:1
+4 IF TNM="IS00"
SET SG=0
QUIT
+5 IF (TNM=100)&((G=1)!(G=2)!(G=9))
SET SG="1A"
QUIT
+6 IF (TNM=100)&(G=3)
SET SG="1B"
QUIT
+7 IF (TNM=200)&((G=1)!(G=2)!(G=9))
SET SG="1B"
QUIT
+8 IF (TNM=200)&(G=3)
SET SG="2A"
QUIT
+9 IF (TNM=300)
SET SG="2B"
QUIT
+10 IF ((TNM=110)!(TNM=210))
SET SG="2B"
QUIT
+11 IF ((TNM=120)!(TNM=220))
SET SG="3A"
QUIT
+12 IF TNM=310
SET SG="3A"
QUIT
+13 IF (T="4A")&(N=0)&(M=0)
SET SG="3A"
QUIT
+14 IF TNM=320
SET SG="3B"
QUIT
+15 IF ((TNM="410")!(TNM="420"))
SET SG="3C"
QUIT
+16 IF (T="4B")&(M=0)
SET SG="3C"
QUIT
+17 IF (N=3)&(M=0)
SET SG="3C"
QUIT
+18 IF M=1
SET SG=4
QUIT
End DoDot:1
KILL TNM
QUIT
+19 ;
STO34 ;Stomach - 3rd and 4th editions
+1 SET TNM=T_N_M
Begin DoDot:1
+2 ;0 Tis N0 M0
IF TNM="IS00"
SET SG=0
QUIT
+3 ;IA T1 N0 M0
IF TNM=100
SET SG="1A"
QUIT
+4 ;IB T1 N1 M0
IF TNM=110
SET SG="1B"
QUIT
+5 ; T2 N0 M0
IF TNM=200
SET SG="1B"
QUIT
+6 ;II T1 N2 M0
IF TNM=120
SET SG=2
QUIT
+7 ; T2 N1 M0
IF TNM=210
SET SG=2
QUIT
+8 ; T3 N0 M0
IF TNM=300
SET SG=2
QUIT
+9 ;IIIA T2 N2 M0
IF TNM=220
SET SG="3A"
QUIT
+10 ; T3 N1 M0
IF TNM=310
SET SG="3A"
QUIT
+11 ; T4 N0 M0
IF TNM=400
SET SG="3A"
QUIT
+12 ;IIIB T3 N2 M0
IF TNM=320
SET SG="3B"
QUIT
+13 ; T4 N1 M0
IF TNM=410
SET SG="3B"
QUIT
+14 ;IV T4 N2 M0
IF TNM=420
SET SG=4
QUIT
+15 ; Any T Any N M1
IF M=1
SET SG=4
QUIT
End DoDot:1
KILL TNM
QUIT
+16 ;
STO5 ;Stomach - 5th edition
+1 SET TNM=T_N_M
Begin DoDot:1
+2 ;0 Tis N0 M0
IF TNM="IS00"
SET SG=0
QUIT
+3 ;IA T1 N0 M0
IF TNM=100
SET SG="1A"
QUIT
+4 ;IB T1 N1 M0
IF TNM=110
SET SG="1B"
QUIT
+5 ; T2 N0 M0
IF TNM=200
SET SG="1B"
QUIT
+6 ;II T1 N2 M0
IF TNM=120
SET SG=2
QUIT
+7 ; T2 N1 M0
IF TNM=210
SET SG=2
QUIT
+8 ; T3 N0 M0
IF TNM=300
SET SG=2
QUIT
+9 ;IIIA T2 N2 M0
IF TNM=220
SET SG="3A"
QUIT
+10 ; T3 N1 M0
IF TNM=310
SET SG="3A"
QUIT
+11 ; T4 N0 M0
IF TNM=400
SET SG="3A"
QUIT
+12 ;IIIB T3 N2 M0
IF TNM=320
SET SG="3B"
QUIT
+13 ;IV T4 N1 M0
IF TNM=410
SET SG=4
QUIT
+14 ; T1 N3 M0
IF TNM=130
SET SG=4
QUIT
+15 ; T2 N3 M0
IF TNM=230
SET SG=4
QUIT
+16 ; T3 N3 M0
IF TNM=330
SET SG=4
QUIT
+17 ; T4 N2 M0
IF TNM=420
SET SG=4
QUIT
+18 ; T4 N3 M0
IF TNM=430
SET SG=4
QUIT
+19 ; Any T Any N M1
IF M=1
SET SG=4
QUIT
End DoDot:1
KILL TNM
QUIT
+20 ;
STO6 ;Stomach - 6th edition
+1 SET TNM=T_N_M
Begin DoDot:1
+2 ;0 Tis N0 M0
IF TNM="IS00"
SET SG=0
QUIT
+3 ;IA T1 N0 M0
IF TNM=100
SET SG="1A"
QUIT
+4 ;IB T1 N1 M0
IF TNM=110
SET SG="1B"
QUIT
+5 ; T2a N0 M0
IF TNM="2A00"
SET SG="1B"
QUIT
+6 ; T2b N0 M0
IF TNM="2B00"
SET SG="1B"
QUIT
+7 ;II T1 N2 M0
IF TNM=120
SET SG=2
QUIT
+8 ; T2a N1 M0
IF TNM="2A10"
SET SG=2
QUIT
+9 ; T2b N1 M0
IF TNM="2B10"
SET SG=2
QUIT
+10 ; T3 N0 M0
IF TNM=300
SET SG=2
QUIT
+11 ;IIIA T2a N2 M0
IF TNM="2A20"
SET SG="3A"
QUIT
+12 ; T2b N2 M0
IF TNM="2B20"
SET SG="3A"
QUIT
+13 ; T3 N1 M0
IF TNM=310
SET SG="3A"
QUIT
+14 ; T4 N0 M0
IF TNM=400
SET SG="3A"
QUIT
+15 ;IIIB T3 N2 M0
IF TNM=320
SET SG="3B"
QUIT
+16 ;IV T4 N1 M0
IF TNM=410
SET SG=4
QUIT
+17 ; T1 N3 M0
IF TNM=130
SET SG=4
QUIT
+18 ; T2a N3 M0
IF TNM="2A30"
SET SG=4
QUIT
+19 ; T2b N3 M0
IF TNM="2B30"
SET SG=4
QUIT
+20 ; T3 N3 M0
IF TNM=330
SET SG=4
QUIT
+21 ; T4 N2 M0
IF TNM=420
SET SG=4
QUIT
+22 ; T4 N3 M0
IF TNM=430
SET SG=4
QUIT
+23 ; Any T Any N M1
IF M=1
SET SG=4
QUIT
End DoDot:1
KILL TNM
QUIT
+24 ;
STO7 ;Stomach - 7th edition
+1 IF $EXTRACT(T,1)=1
SET T=$EXTRACT(T,1)
+2 IF $EXTRACT(N,1)=3
SET N=$EXTRACT(N,1)
+3 SET TNM=T_N_M
Begin DoDot:1
+4 ;0 Tis N0 M0
IF TNM="IS00"
SET SG=0
QUIT
+5 ;IA T1 N0 M0
IF TNM=100
SET SG="1A"
QUIT
+6 ;IB T2 N0 M0
IF TNM=200
SET SG="1B"
QUIT
+7 ; T1 N1 M0
IF TNM=110
SET SG="1B"
QUIT
+8 ;IIA T3 N0 M0
IF TNM=300
SET SG="2A"
QUIT
+9 ; T2 N1 M0
IF TNM=210
SET SG="2A"
QUIT
+10 ; T1 N2 M0
IF TNM=120
SET SG="2A"
QUIT
+11 ;IIB T4a N0 M0
IF TNM="4A00"
SET SG="2B"
QUIT
+12 ; T3 N1 M0
IF TNM=310
SET SG="2B"
QUIT
+13 ; T2 N2 M0
IF TNM=220
SET SG="2B"
QUIT
+14 ; T1 N3 M0
IF TNM=130
SET SG="2B"
QUIT
+15 ;IIIA T4a N1 M0
IF TNM="4A10"
SET SG="3A"
QUIT
+16 ; T3 N2 M0
IF TNM=320
SET SG="3A"
QUIT
+17 ; T2 N3 M0
IF TNM=230
SET SG="3A"
QUIT
+18 ;IIIB T4b N0 M0
IF TNM="4B00"
SET SG="3B"
QUIT
+19 ; T4b N1 M0
IF TNM="4B10"
SET SG="3B"
QUIT
+20 ; T4a N2 M0
IF TNM="4A20"
SET SG="3B"
QUIT
+21 ; T3 N3 M0
IF TNM=330
SET SG="3B"
QUIT
+22 ;IIIC T4b N2 M0
IF TNM="4B20"
SET SG="3C"
QUIT
+23 ; T4b N3 M0
IF TNM="4B30"
SET SG="3C"
QUIT
+24 ; T4a N3 M0
IF TNM="4A30"
SET SG="3C"
QUIT
+25 ; Any T Any N M1
IF M=1
SET SG=4
QUIT
End DoDot:1
KILL TNM
QUIT
+26 ;
SI456 ;Small Intestine - 4th, 5th and 6th editions
+1 IF M
SET SG=4
+2 IF '$TEST
IF T["IS"
IF N[0
IF M[0
SET SG=0
+3 IF '$TEST
IF (T[1)!(T[2)
IF N[0
IF M[0
SET SG=1
+4 IF '$TEST
IF (T[3)!(T[4)
IF N[0
IF M[0
SET SG=2
+5 IF '$TEST
IF N[1
IF M[0
SET SG=3
+6 IF '$TEST
SET SG=99
+7 QUIT
+8 ;
SI7 ;Small Intestine - 7th edition
+1 SET TNM=T_N_M
Begin DoDot:1
+2 ;0 Tis N0 M0
IF TNM="IS00"
SET SG=0
QUIT
+3 ;I T1a N0 M0
IF TNM="1A00"
SET SG=1
QUIT
+4 ;I T1b N0 M0
IF TNM="1B00"
SET SG=1
QUIT
+5 ; T2 N0 M0
IF TNM=200
SET SG=1
QUIT
+6 ;IIA T3 N0 M0
IF TNM=300
SET SG="2A"
QUIT
+7 ;IIB T0 N0 M0
IF TNM=400
SET SG="2B"
QUIT
+8 ;IIIA Any T N1 M0
IF N=1
IF M=0
SET SG="3A"
QUIT
+9 ;IIIB Any T N2 M0
IF N=2
IF M=0
SET SG="3B"
QUIT
+10 ;IV Any T Any N M1
IF M=1
SET SG=4
QUIT
End DoDot:1
KILL TNM
QUIT
+11 ;
APP7 ;Appendix- 7th edition
+1 NEW HT14
+2 SET HT14=$EXTRACT(HT,1,4)
+3 IF (HT14=8153)!(HT14=8240)!(HT14=8241)!(HT14=8242)!(HT14=8246)!(HT14=8249)
GOTO APP7B
+4 ;
APP7A ;Carcinoma
+1 SET TNM=T_N_M
Begin DoDot:1
+2 ;0 Tis N0 M0
IF TNM="IS00"
SET SG=0
QUIT
+3 ;I T1 N0 M0
IF TNM=100
SET SG=1
QUIT
+4 ;I T2 N0 M0
IF TNM=200
SET SG=1
QUIT
+5 ;IIA T3 N0 M0
IF TNM=300
SET SG="2A"
QUIT
+6 ;IIB T4a N0 M0
IF TNM="4A00"
SET SG="2B"
QUIT
+7 ;IIC T4b N0 M0
IF TNM="4B00"
SET SG="2C"
QUIT
+8 ;IIIA T1 N1 M0
IF TNM=110
SET SG="3A"
QUIT
+9 ; T2 N1 M0
IF TNM=210
SET SG="3A"
QUIT
+10 ;IIIB T3 N1 M0
IF TNM=310
SET SG="3B"
QUIT
+11 ; T4 N1 M0
IF TNM=410
SET SG="3B"
QUIT
+12 ;IIIC Any T N2 M0
IF N=2
IF M=0
SET SG="3C"
QUIT
+13 ;IVA Any T N0 M1a G1
IF N=0
IF M="1A"
IF G=1
SET SG="4A"
QUIT
+14 ;IVB Any T N0 M1a G2,3
IF N=0
IF M="1A"
IF (G=2)!(G=3)
SET SG="4B"
QUIT
+15 ; Any T N1 M1a Any G
IF N=1
IF M="1A"
SET SG="4B"
QUIT
+16 ; Any T N2 M1a Any G
IF N=2
IF M="1A"
SET SG="4B"
QUIT
+17 ;IVC Any T Any N M1b Any G
IF M="1B"
SET SG="4C"
QUIT
End DoDot:1
KILL TNM
QUIT
+18 ;
APP7B ;Carcinoid
+1 SET TNM=T_N_M
Begin DoDot:1
+2 ;I T1 N0 M0
IF TNM=100
SET SG=1
QUIT
+3 ;II T2 N0 M0
IF TNM=200
SET SG=2
QUIT
+4 ; T3 N0 M0
IF TNM=300
SET SG=2
QUIT
+5 ;III T4 N0 M0
IF TNM=400
SET SG=3
QUIT
+6 ; Any T N1 M0
IF N=1
IF M=0
SET SG=3
QUIT
+7 ;IV Any T Any N M1
IF M=1
SET SG=4
QUIT
End DoDot:1
KILL TNM
QUIT
+8 ;
COL34 ;Colon and Rectum - 3rd and 4th editions
+1 SET TNM=T_N_M
Begin DoDot:1
+2 ;0 Tis N0 M0
IF TNM="IS00"
SET SG=0
QUIT
+3 ;I T1 N0 M0
IF TNM=100
SET SG=1
QUIT
+4 ; T2 N0 M0
IF TNM=200
SET SG=1
QUIT
+5 ;II T3 N0 M0
IF TNM=300
SET SG=2
QUIT
+6 ; T4 N0 M0
IF TNM=400
SET SG=2
QUIT
+7 ;III Any T N1 M0
IF N=1
IF M=0
SET SG=3
QUIT
+8 ; Any T N2 M0
IF N=2
IF M=0
SET SG=3
QUIT
+9 ; Any T N3 M0
IF N=3
IF M=0
SET SG=3
QUIT
+10 ;IV Any T Any N M1
IF M=1
SET SG=4
QUIT
End DoDot:1
KILL TNM
QUIT
+11 ;
COL5 ;Colon and Rectum - 5th edition
+1 SET TNM=T_N_M
Begin DoDot:1
+2 ;0 Tis N0 M0
IF TNM="IS00"
SET SG=0
QUIT
+3 ;I T1 N0 M0
IF TNM=100
SET SG=1
QUIT
+4 ; T2 N0 M0
IF TNM=200
SET SG=1
QUIT
+5 ;II T3 N0 M0
IF TNM=300
SET SG=2
QUIT
+6 ; T4 N0 M0
IF TNM=400
SET SG=2
QUIT
+7 ;III Any T N1 M0
IF N=1
IF M=0
SET SG=3
QUIT
+8 ; Any T N2 M0
IF N=2
IF M=0
SET SG=3
QUIT
+9 ;IV Any T Any N M1
IF M=1
SET SG=4
QUIT
End DoDot:1
KILL TNM
QUIT
+10 ;
COL6 ;Colon and Rectum - 6th edition
+1 SET TNM=T_N_M
Begin DoDot:1
+2 ;0 Tis N0 M0
IF TNM="IS00"
SET SG=0
QUIT
+3 ;I T1 N0 M0
IF TNM=100
SET SG=1
QUIT
+4 ; T2 N0 M0
IF TNM=200
SET SG=1
QUIT
+5 ;IIA T3 N0 M0
IF TNM=300
SET SG="2A"
QUIT
+6 ;IIB T4 N0 M0
IF TNM=400
SET SG="2B"
QUIT
+7 ;IIIA T1 N1 M0
IF TNM=110
SET SG="3A"
QUIT
+8 ; T2 N1 M0
IF TNM=210
SET SG="3A"
QUIT
+9 ;IIIB T3 N1 M0
IF TNM=310
SET SG="3B"
QUIT
+10 ; T4 N1 M0
IF TNM=410
SET SG="3B"
QUIT
+11 ;IIIC Any T N2 M0
IF N=2
IF M=0
SET SG="3C"
QUIT
+12 ;IV Any T Any N M1
IF M=1
SET SG=4
QUIT
End DoDot:1
KILL TNM
QUIT
+13 ;
COL7 ;Colon and Rectum - 7th edition
+1 SET TNM=T_N_M
Begin DoDot:1
+2 IF TNM="IS00"
SET SG=0
QUIT
+3 IF TNM=100
SET SG=1
QUIT
+4 IF TNM=200
SET SG=1
QUIT
+5 IF TNM=300
SET SG="2A"
QUIT
+6 IF TNM="4A00"
SET SG="2B"
QUIT
+7 IF TNM="4B00"
SET SG="2C"
QUIT
+8 IF ((T=1)!(T=2))&($EXTRACT(N,1)=1)&(M=0)
SET SG="3A"
QUIT
+9 IF TNM="12A0"
SET SG="3A"
QUIT
+10 IF ((T=3)!(T="4A"))&($EXTRACT(N,1)=1)&(M=0)
SET SG="3B"
QUIT
+11 IF ((TNM="22A0")!(TNM="32A0"))
SET SG="3B"
QUIT
+12 IF ((TNM="12B0")!(TNM="22B0"))
SET SG="3B"
QUIT
+13 IF TNM="4A2A0"
SET SG="3C"
QUIT
+14 IF ((TNM="32B0")!(TNM="4A2B0")!(TNM="4A20"))
SET SG="3C"
QUIT
+15 IF ((TNM="4B10")!(TNM="4B20"))
SET SG="3C"
QUIT
+16 IF ((TNM="4B1A0")!(TNM="4B1B0")!(TNM="4B1C0")!(TNM="4B2A0")!(TNM="4B2B0"))
SET SG="3C"
QUIT
+17 IF M="1A"
SET SG="4A"
QUIT
+18 IF M="1B"
SET SG="4B"
QUIT
End DoDot:1
KILL TNM
QUIT
+19 ;
AC ;Anus - all editions
+1 SET TNM=T_N_M
Begin DoDot:1
+2 ;0 Tis N0 M0
IF TNM="IS00"
SET SG=0
QUIT
+3 ;I T1 N0 M0
IF TNM=100
SET SG=1
QUIT
+4 ;II T2 N0 M0
IF TNM=200
SET SG=2
QUIT
+5 ; T3 N0 M0
IF TNM=300
SET SG=2
QUIT
+6 ;IIIA T1 N1 M0
IF TNM=110
SET SG="3A"
QUIT
+7 ; T2 N1 M0
IF TNM=210
SET SG="3A"
QUIT
+8 ; T3 N1 M0
IF TNM=310
SET SG="3A"
QUIT
+9 ; T4 N0 M0
IF TNM=400
SET SG="3A"
QUIT
+10 ;IIIB T4 N1 M0
IF TNM=410
SET SG="3B"
QUIT
+11 ; Any T N2 M0
IF N=2
IF M=0
SET SG="3B"
QUIT
+12 ; Any T N3 M0
IF N=3
IF M=0
SET SG="3B"
QUIT
+13 ;IV Any T Any N M1
IF M=1
SET SG=4
QUIT
End DoDot:1
KILL TNM
QUIT
+14 ;
GIST ;Gastrointestinal Stromal Tumor - 7th Edition
+1 NEW MR
+2 SET MR=$PIECE($GET(^ONCO(165.5,D0,2.3)),U,9)
+3 IF MR=""
WRITE !!?12,"MITOTIC RATE is required for AJCC 7th Edition GIST staging."
QUIT
+4 IF $EXTRACT(TX,3,4)=16
GOTO GASTRIC
SI ;Small Intestinal GIST - 7th Edition
+1 SET TNM=T_N_M
Begin DoDot:1
+2 ;I T1 N0 M0 Low
IF TNM=100
IF MR="L"
SET SG=1
QUIT
+3 ; T2 N0 M0 Low
IF TNM=200
IF MR="L"
SET SG=1
QUIT
+4 ;II T3 N0 M0 Low
IF TNM=300
IF MR="L"
SET SG=2
QUIT
+5 ;IIIA T1 N0 M0 High
IF TNM=100
IF MR="H"
SET SG="3A"
QUIT
+6 ; T4 N0 M0 Low
IF TNM=400
IF MR="L"
SET SG="3A"
QUIT
+7 ;IIIB T2 N0 M0 High
IF TNM=200
IF MR="H"
SET SG="3B"
QUIT
+8 ; T3 N0 M0 High
IF TNM=300
IF MR="H"
SET SG="3B"
QUIT
+9 ; T4 N0 M0 High
IF TNM=400
IF MR="H"
SET SG="3B"
QUIT
+10 ;IV Any T N1 M0 Any rate
IF N=1
IF M=0
SET SG=4
QUIT
+11 ; Any T Any N M1 Any rate
IF M=1
SET SG=4
QUIT
End DoDot:1
KILL TNM
QUIT
+12 ;
GASTRIC ;Gastric GIST
+1 SET TNM=T_N_M
Begin DoDot:1
+2 ;IA T1 N0 M0 Low
IF TNM=100
IF MR="L"
SET SG="1A"
QUIT
+3 ; T2 N0 M0 Low
IF TNM=200
IF MR="L"
SET SG="1A"
QUIT
+4 ;IB T3 N0 M0 Low
IF TNM=300
IF MR="L"
SET SG="1B"
QUIT
+5 ;II T1 N0 M0 High
IF TNM=100
IF MR="H"
SET SG=2
QUIT
+6 ; T2 N0 M0 High
IF TNM=200
IF MR="H"
SET SG=2
QUIT
+7 ; T4 N0 M0 Low
IF TNM=400
IF MR="L"
SET SG=2
QUIT
+8 ;IIIA T3 N0 M0 High
IF TNM=300
IF MR="H"
SET SG="3A"
QUIT
+9 ;IIIB T4 N0 M0 High
IF TNM=400
IF MR="H"
SET SG="3B"
QUIT
+10 ;IV Any T N1 M0 Any rate
IF N=1
IF M=0
SET SG=4
QUIT
+11 ; Any T Any N M1 Any rate
IF M=1
SET SG=4
QUIT
End DoDot:1
KILL TNM
QUIT
+12 ;
NT ;Neuroendocrine Tumor - 7th Edition
+1 SET TNM=$EXTRACT(T,1)_N_M
Begin DoDot:1
+2 ;0 Tis* N0 M0
IF TNM="IS00"
IF $EXTRACT(TX,3,4)=16
SET SG=0
QUIT
+3 ;I T1 N0 M0
IF TNM=100
SET SG=1
QUIT
+4 ;IIA T2 N0 M0
IF TNM=200
SET SG="2A"
QUIT
+5 ;IIB T3 N0 M0
IF TNM=300
SET SG="2B"
QUIT
+6 ;IIIA T4 N0 M0
IF TNM=400
SET SG="3A"
QUIT
+7 ;IIIB Any T N1 M0
IF N=1
IF M=0
SET SG="3B"
QUIT
+8 ;IV Any T Any N M1
IF M=1
SET SG=4
QUIT
End DoDot:1
KILL TNM
QUIT
+9 ; ;Note: TIS applies only to stomach
+10 ;
CLEANUP ;Cleanup
+1 KILL D0,G,HT,M,N,SG,T,TX