ONCSGA8B ;HINES OIFO/RTK - AJCC 8th Ed Automatic Staging Tables ;01/15/19
;;2.2;ONCOLOGY;**10,12,13,18,20**;Jul 31, 2013;Build 5
;
;
30 ;NET
S M=$E(M,2,5)
I T="T1",N="N0",M="M0" S SG=1 Q
I T="T2",N="N0",M="M0" S SG=2 Q
I T="T3",N="N0",M="M0" S SG=2 Q
I T="T4",N="N0",M="M0" S SG=3 Q
I N="N1",M="M0" S SG=3 Q
I M["M1" S SG=4
Q
31 ;NET
S M=$E(M,2,5)
I ((T="TX")!(T="T0")),((N="NX")!(N="N0")!(N="N1")!(N="N2")),M["M1" S SG=4 Q
I T="T1",N="N0",M="M0" S SG=1 Q
I T="T1",((N="N1")!(N="N2")),M="M0" S SG=3 Q
I T="T1",((N="NX")!(N="N0")!(N="N1")!(N="N2")),M["M1" S SG=4 Q
I T="T2",N="N0",M="M0" S SG=2 Q
I T="T2",((N="N1")!(N="N2")),M="M0" S SG=3 Q
I T="T2",((N="NX")!(N="N0")!(N="N1")!(N="N2")),M["M1" S SG=4 Q
I T="T3",N="N0",M="M0" S SG=2 Q
I T="T3",((N="N1")!(N="N2")),M="M0" S SG=3 Q
I T="T3",((N="NX")!(N="N0")!(N="N1")!(N="N2")),M["M1" S SG=4 Q
I T="T4",N="N0",M="M0" S SG=3 Q
I T="T4",((N="N1")!(N="N2")),M="M0" S SG=3 Q
I T="T4",((N="NX")!(N="N0")!(N="N1")!(N="N2")),M["M1" S SG=4
Q
32 ;NET
D 29^ONCSGA8A
Q
33 ;NET
S M=$E(M,2,5)
I ((T="TX")!(T="T0")),M["M1" S SG=4 Q
I T["T1",N="N0",M="M0" S SG=1 Q
I T["T1",N="N1",M="M0" S SG="3B" Q
I T["T1",M["M1" S SG=4 Q
I T="T2",N="N0",M="M0" S SG="2A" Q
I T="T2",N="N1",M="M0" S SG="3B" Q
I T="T2",M["M1" S SG=4 Q
I T="T3",N="N0",M="M0" S SG="2B" Q
I T="T3",N="N1",M="M0" S SG="3B" Q
I T="T3",M["M1" S SG=4 Q
I T="T4",N="N0",M="M0" S SG="3A" Q
I T="T4",N="N1",M="M0" S SG="3B" Q
I T="T4",M["M1" S SG=4
Q
34 ;NET
D 30
Q
35 ;THYMUS
S M=$E(M,2,5)
I ((T="T1a")!(T="T1b")),N="N0",M="M0" S SG=1 Q
I T="T2",N="N0",M="M0" S SG=2 Q
I T="T3",N="N0",M="M0" S SG="3A" Q
I T="T4",N="N0",M="M0" S SG="3B" Q
I N="N1",M="M0" S SG="4A" Q
I ((N="N0")!(N="N1")),M="M1a" S SG="4A" Q
I N="N2",((M="M0")!(M="M1a")) S SG="4B" Q
I M="M1b" S SG="4B"
Q
36 ;LUNG
S M=$E(M,2,5)
I T="TX",N="N0",M="M0" S SG="OccultCarcinoma" Q
I T="Tis",N="N0",M="M0" S SG=0 Q
I T="T1mi",N="N0",M="M0" S SG="1A1" Q
I T="T1a",N="N0",M="M0" S SG="1A1" Q
I T="T1a",N="N1",M="M0" S SG="2B" Q
I T="T1a",N="N2",M="M0" S SG="3A" Q
I T="T1a",N="N3",M="M0" S SG="3B" Q
I T="T1b",N="N0",M="M0" S SG="1A2" Q
I T="T1b",N="N1",M="M0" S SG="2B" Q
I T="T1b",N="N2",M="M0" S SG="3A" Q
I T="T1b",N="N3",M="M0" S SG="3B" Q
I T="T1c",N="N0",M="M0" S SG="1A3" Q
I T="T1c",N="N1",M="M0" S SG="2B" Q
I T="T1c",N="N2",M="M0" S SG="3A" Q
I T="T1c",N="N3",M="M0" S SG="3B" Q
I T="T2a",N="N0",M="M0" S SG="1B" Q
I T="T2a",N="N1",M="M0" S SG="2B" Q
I T="T2a",N="N2",M="M0" S SG="3A" Q
I T="T2a",N="N3",M="M0" S SG="3B" Q
I T="T2b",N="N0",M="M0" S SG="2A" Q
I T="T2b",N="N1",M="M0" S SG="2B" Q
I T="T2b",N="N2",M="M0" S SG="3A" Q
I T="T2b",N="N3",M="M0" S SG="3B" Q
I T="T3",N="N0",M="M0" S SG="2B" Q
I T="T3",N="N1",M="M0" S SG="3A" Q
I T="T3",N="N2",M="M0" S SG="3B" Q
I T="T3",N="N3",M="M0" S SG="3C" Q
I T="T4",N="N0",M="M0" S SG="3A" Q
I T="T4",N="N1",M="M0" S SG="3A" Q
I T="T4",N="N2",M="M0" S SG="3B" Q
I T="T4",N="N3",M="M0" S SG="3C" Q
I M="M1" S SG="4A" Q
I M="M1a" S SG="4A" Q
I M="M1b" S SG="4A" Q
I M="M1c" S SG="4B"
Q
37 ;MALIGNANT PLEURAL MESOTHELIOMA
S M=$E(M,2,5)
I T="T1",N="N0",M="M0" S SG="1A" Q
I ((T="T2")!(T="T3")),N="N0",M="M0" S SG="1B" Q
I T="T1",N="N1",M="M0" S SG=2 Q
I T="T2",N="N1",M="M0" S SG=2 Q
I T="T3",N="N1",M="M0" S SG="3A" Q
I ((T="T1")!(T="T2")!(T="T3")),N="N2",M="M0" S SG="3B" Q
I T="T4",M="M0" S SG="3B" Q
I M="M1" S SG=4
Q
381 ;BONE
S M=$E(M,2,5)
I T="T1",N="N0",M="M0",((G=1)!(G=9)) S SG="1A" Q
I T="T2",N="N0",M="M0",((G=1)!(G=9)) S SG="1B" Q
I T="T3",N="N0",M="M0",((G=1)!(G=9)) S SG="1B" Q
I T="T1",N="N0",M="M0",((G=2)!(G=3)) S SG="2A" Q
I T="T2",N="N0",M="M0",((G=2)!(G=3)) S SG="2B" Q
I T="T3",N="N0",M="M0",((G=2)!(G=3)) S SG=3 Q
I N="N0",M="M1a" S SG="4A" Q
I N="N1" S SG="4A" Q
I M="M1b" S SG="4B"
Q
41 ;SOFT TISSUE
S M=$E(M,2,5)
I T="T1",N="N0",M="M0",((G=1)!(G=9)) S SG="1A" Q
I ((T="T2")!(T="T3")!(T="T4")),N="N0",M="M0",((G=1)!(G=9)) S SG="1B" Q
I T="T1",N="N0",M="M0",((G=2)!(G=3)) S SG=2 Q
I T="T2",N="N0",M="M0",((G=2)!(G=3)) S SG="3A" Q
I ((T="T3")!(T="T4")),N="N0",M="M0",((G=2)!(G=3)) S SG="3B" Q
I N="N1",M="M0" S SG=4 Q
I M="M1" S SG=4
Q
431 ;GIST
S M=$E(M,2,5)
I ((T="T1")!(T="T2")),N="N0",M="M0",MTRT="L" S SG="1A" Q
I T="T3",N="N0",M="M0",MTRT="L" S SG="1B" Q
I T="T1",N="N0",M="M0",MTRT="H" S SG=2 Q
I T="T2",N="N0",M="M0",MTRT="H" S SG=2 Q
I T="T4",N="N0",M="M0",MTRT="L" S SG=3 Q
I T="T3",N="N0",M="M0",MTRT="H" S SG="3A" Q
I T="T4",N="N0",M="M0",MTRT="H" S SG="3B" Q
I N="N1",M="M0" S SG=4 Q
I M="M1" S SG=4
Q
432 ;GIST
S M=$E(M,2,5)
I ((T="T1")!(T="T2")),N="N0",M="M0",MTRT="L" S SG=1 Q
I T="T3",N="N0",M="M0",MTRT="L" S SG=2 Q
I T="T1",N="N0",M="M0",MTRT="H" S SG="3A" Q
I T="T4",N="N0",M="M0",MTRT="L" S SG="3A" Q
I T="T2",N="N0",M="M0",MTRT="H" S SG="3B" Q
I T="T3",N="N0",M="M0",MTRT="H" S SG="3B" Q
I T="T4",N="N0",M="M0",MTRT="H" S SG="3B" Q
I N="N1",M="M0" S SG=4 Q
I M="M1" S SG=4
Q
44 ;SOFT TISSUE
S M=$E(M,2,5)
I T="T1",N="N0",M="M0",((G=1)!(G=9)) S SG="1A" Q
I ((T="T2")!(T="T3")!(T="T4")),N="N0",M="M0",((G=1)!(G=9)) S SG="1B" Q
I T="T1",N="N0",M="M0",((G=2)!(G=3)) S SG=2 Q
I T="T2",N="N0",M="M0",((G=2)!(G=3)) S SG="3A" Q
I ((T="T3")!(T="T4")),N="N0",M="M0",((G=2)!(G=3)) S SG="3B" Q
I N="N1",M="M0" S SG="3B" Q
I M="M1" S SG=4
Q
46 ;MERKEL CELL
S M=$E(M,2,5)
I STGIND'="P" D
.I T="Tis",N="N0",M="M0" S SG=0 Q
.I T="T1",N="N0",M="M0" S SG=1 Q
.I ((T="T2")!(T="T3")),N="N0",M="M0" S SG="2A" Q
.I T="T4",N="N0",M="M0" S SG="2B" Q
.I ((T="T0")!(T="T1")!(T="T2")!(T="T3")!(T="T4")),((N="N1")!(N="N2")!(N="N3")),M="M0" S SG=3 Q
.I ((T="T0")!(T="T1")!(T="T2")!(T="T3")!(T="T4")),M["M1" S SG=4 Q
I STGIND="P" D
.I T="Tis",N="N0",M="M0" S SG=0 Q
.I T="T1",N="N0",M="M0" S SG=1 Q
.I ((T="T2")!(T="T3")),N="N0",M="M0" S SG="2A" Q
.I T="T4",N="N0",M="M0" S SG="2B" Q
.I ((T="T1")!(T="T2")!(T="T3")!(T="T4")),N="N1a",M="M0",PNSFX'="(f)" S SG="3A" Q
.I T="T0",N="N1b",M="M0" S SG="3A" Q
.I ((T="T1")!(T="T2")!(T="T3")!(T="T4")),((N="N1b")!(N="N2")!(N="N3")),M="M0" S SG="3B" Q
.I ((T="T0")!(T="T1")!(T="T2")!(T="T3")!(T="T4")),M["M1" S SG=4 Q
Q
47 ;MELANOMA OF THE SKIN
S M=$E(M,2,5)
I STGIND'="P" D
.I T="Tis",N="N0",M="M0" S SG=0 Q
.I T="T1a",N="N0",M="M0" S SG="1A" Q
.I T="T1b",N="N0",M="M0" S SG="1B" Q
.I T="T2a",N="N0",M="M0" S SG="1B" Q
.I T="T2b",N="N0",M="M0" S SG="2A" Q
.I T="T3a",N="N0",M="M0" S SG="2A" Q
.I T="T3b",N="N0",M="M0" S SG="2B" Q
.I T="T4a",N="N0",M="M0" S SG="2B" Q
.I T="T4b",N="N0",M="M0" S SG="2C" Q
.I N'="NX",N'="N0",M="M0" S SG=3 Q
.I M["M1" S SG=4 Q
I STGIND="P" D
.I T="Tis",N="N0",M="M0" S SG=0 Q
.I ((T="T1a")!(T="T1b")),N="N0",M="M0" S SG="1A" Q
.I T="T2a",N="N0",M="M0" S SG="1B" Q
.I ((T="T2b")!(T="T3a")),N="N0",M="M0" S SG="2A" Q
.I ((T="T3b")!(T="T4a")),N="N0",M="M0" S SG="2B" Q
.I T="T4b",N="N0",M="M0" S SG="2C" Q
.I T="T0",((N="N1b")!(N="N1c")),M="M0" S SG="3B" Q
.I T="T0",((N="N2b")!(N="N2c")!(N="N3b")!(N="N3c")),M="M0" S SG="3C" Q
.I ((T="T1a")!(T="T1b")!(T="T2a")),((N="N1a")!(N="N2a")),M="M0" S SG="3A" Q
.I ((T="T1a")!(T="T1b")!(T="T2a")),((N="N1b")!(N="N1c")!(N="N2b")),M="M0" S SG="3B" Q
.I ((T="T2b")!(T="T3a")),((N="N1a")!(N="N1b")!(N="N1c")!(N="N2a")!(N="N2b")),M="M0" S SG="3B" Q
.I ((T="T1a")!(T="T1b")!(T="T2a")!(T="T2b")!(T="T3a")),((N="N2c")!(N="N3a")!(N="N3b")!(N="N3c")),M="M0" S SG="3C" Q
.I ((T="T3b")!(T="T4a")),((N'="NX")&(N'="N0")),M="M0" S SG="3C" Q
.I T="T4b",((N="N1a")!(N="N1b")!(N="N1c")!(N="N2a")!(N="N2b")!(N="N2c")),M="M0" S SG="3C" Q
.I T="T4b",((N="N3a")!(N="N3b")!(N="N3c")),M="M0" S SG="3D" Q
.I M["M1" S SG=4 Q
Q
48 ;BREAST
S M=$E(M,2,3) ;can strip,only use char 2-3 b/c M0(i+) treated same as M0
I STGIND'="P" D
.I T["Tis",N="N0",M="M0" S SG=0 Q
.I ((T["T1")&(N="N0")&(M="M0"))!((T="T0")&(N="N1mi")&(M="M0"))!((T["T1")&(N="N1mi")&(M="M0")) D 1^ONCSGA8X
.I ((T="T0")&(N["N1")&(M="M0"))!((T["T1")&(N["N1")&(M="M0"))&((T="T2")&(N="N0")&(M="M0")) D 2^ONCSGA8X
.I ((T="T2")&(N["N1")&(M="M0"))!((T="T3")&(N="N0")&(M="M0")) D 3^ONCSGA8X
.I ((T="T0")&(N="N2")&(M="M0"))!((T["T1")&(N="N2")&(M="M0"))!((T="T2")&(N="N2")&(M="M0"))!((T="T3")&(N["N1")&(M="M0"))!((T="T3")&(N="N2")&(M="M0")) D 4^ONCSGA8X
.I ((T="T4")&(N="N0")&(M="M0"))!((T="T4")&(N["N1")&(M="M0"))!((T="T4")&(N="N2")&(M="M0"))!((N="N3")&(M="M0")) D 5^ONCSGA8X
.I M="M1" S SG=4
I STGIND="P" D
.I T["Tis",N="N0",M="M0" S SG=0 Q
.I ((T["T1")&(N="N0")&(M="M0"))!((T="T0")&(N="N1mi")&(M="M0"))!((T["T1")&(N="N1mi")&(M="M0")) D 1^ONCSGA8X
.I ((T="T0")&(N["N1")&(M="M0"))!((T["T1")&(N["N1")&(M="M0"))!((T="T2")&(N="N0")&(M="M0")) D 2^ONCSGA8X
.I ((T="T2")&(N["N1")&(M="M0"))!((T="T3")&(N="N0")&(M="M0")) D 3^ONCSGA8X
.I ((T="T0")&(N="N2")&(M="M0"))!((T["T1")&(N="N2")&(M="M0"))!((T="T2")&(N="N2")&(M="M0"))!((T="T3")&(N["N1")&(M="M0"))!((T="T3")&(N="N2")&(M="M0")) D 4^ONCSGA8X
.I ((T="T4")&(N="N0")&(M="M0"))!((T="T4")&(N["N1")&(M="M0"))!((T="T4")&(N="N2")&(M="M0"))!((N="N3")&(M="M0")) D 5^ONCSGA8X
.I M="M1" S SG=4
Q
;
50 ;VULVA
S M=$E(M,2,5)
I T="T1",N="N0",M="M0" S SG=1 Q
I T="T1a",N="N0",M="M0" S SG="1A" Q
I T="T1b",N="N0",M="M0" S SG="1B" Q
I T="T2",N="N0",M="M0" S SG=2 Q
I (($E(T,1,2)="T1")!($E(T,1,2)="T2")),(($E(N,1,2)="N1")!($E(N,1,2)="N2")),M="M0" S SG=3 Q
I (($E(T,1,2)="T1")!($E(T,1,2)="T2")),N="N1",M="M0" S SG="3A" Q
I (($E(T,1,2)="T1")!($E(T,1,2)="T2")),((N="N2a")!(N="N2b")),M="M0" S SG="3B" Q
I (($E(T,1,2)="T1")!($E(T,1,2)="T2")),N="N2c",M="M0" S SG="3C" Q
I (($E(T,1,2)="T1")!($E(T,1,2)="T2")!($E(T,1,2)="T3")),N="N3",((M="M0")!(M="M1")) S SG=4 Q
I (($E(T,1,2)="T1")!($E(T,1,2)="T2")),N="N3",M="M1" S SG="4A" Q
I T="T3",M="M0" S SG="4A" Q
I M="M1" S SG="4B"
Q
51 ;VAGINA
S M=$E(M,2,5)
I T="T1a",N="N0",M="M0" S SG="1A" Q
I T="T1b",N="N0",M="M0" S SG="1B" Q
I T="T2a",N="N0",M="M0" S SG="2A" Q
I T="T2b",N="N0",M="M0" S SG="2B" Q
I (($E(T,1,2)="T1")!($E(T,1,2)="T2")!($E(T,1,2)="T3")),N="N1",((M="M0")!(M="M1")) S SG=3 Q
I T="T3",N="N0",M="M1" S SG=3 Q
I T="T4",M="M0" S SG="4A" Q
I M="M1" S SG="4B"
Q
52 ;CERVIX UTERI
S M=$E(M,2,5)
I $P($G(^ONCO(165.5,D0,0)),"^",16)>3201231 D V529^ONCSGA8C Q
I T="T1",M="M0" S SG=1 Q
I T="T1a",M="M0" S SG="1A" Q
I T="T1a1",M="M0" S SG="1A1" Q
I T="T1a2",M="M0" S SG="1A2" Q
I T="T1b",M="M1" S SG="1B" Q
I T="T1b1",M="M0" S SG="1B1" Q
I T="T1b2",M="M0" S SG="1B2" Q
I T="T2",M="M0" S SG=2 Q
I T="T2a",M="M0" S SG="2A" Q
I T="T2a1",M="M0" S SG="2A1" Q
I T="T2a2",M="M0" S SG="2A2" Q
I T="T2b",M="M0" S SG="2B" Q
I T="T3",M="M0" S SG=3 Q
I T="T3a",M="M0" S SG="3A" Q
I T="T3b",M="M0" S SG="3B" Q
I T="T4",M="M0" S SG="4A" Q
I M="M1" S SG="4B"
Q
53 ;CORPUS UTERI
S M=$E(M,2,5)
I T="T1",N="N0",M="M0" S SG=1 Q
I T="T1a",N="N0",M="M0" S SG="1A" Q
I T="T1b",N="N0",M="M0" S SG="1B" Q
I T="T2",N="N0",M="M0" S SG=2 Q
I T="T3",N="N0",M="M1" S SG=3 Q
I T="T3a",N="N0",M="M0" S SG="3A" Q
I T="T3b",N="N0",M="M0" S SG="3B" Q
I (($E(T,1,2)="T1")!($E(T,1,2)="T2")!($E(T,1,2)="T3")),((N="N1")!(N="N1mi")!(N="N1a")),M="M0" S SG="3C1" Q
I (($E(T,1,2)="T1")!($E(T,1,2)="T2")!($E(T,1,2)="T3")),((N="N2")!(N="N2mi")!(N="N2a")),M="M0" S SG="3C2" Q
I T="T4",M="M0" S SG="4A" Q
I M="M1" S SG="4B"
Q
541 ;CORPUS UTERI
S M=$E(M,2,5)
I T="T1",N="N0",M="M0" S SG=1 Q
I T="T1a",N="N0",M="M0" S SG="1A" Q
I T="T1b",N="N0",M="M0" S SG="1B" Q
I T="T2",N="N0",M="M0" S SG=2 Q
I T="T3a",N="N0",M="M0" S SG="3A" Q
I T="T3b",N="N0",M="M0" S SG="3B" Q
I (($E(T,1,2)="T1")!($E(T,1,2)="T2")!($E(T,1,2)="T3")),N="N1",M="M0" S SG="3C" Q
I T="T4",M="M0" S SG="4A" Q
I M="M1" S SG="4B"
Q
542 ;CORPUS UTERI
S M=$E(M,2,5)
I T="T1",N="N0",M="M0" S SG=1 Q
I T="T1a",N="N0",M="M0" S SG="1A" Q
I T="T1b",N="N0",M="M0" S SG="1B" Q
I T="T1c",N="N0",M="M0" S SG="1C" Q
I T="T2",N="N0",M="M0" S SG=2 Q
I T="T3a",N="N0",M="M0" S SG="3A" Q
I T="T3b",N="N0",M="M0" S SG="3B" Q
I (($E(T,1,2)="T1")!($E(T,1,2)="T2")!($E(T,1,2)="T3")),N="N1",M="M0" S SG="3C" Q
I T="T4",M="M0" S SG="4A" Q
I M="M1" S SG="4B"
Q
55 ;OVARY, FALLOPIAN TUBE AND PRIMARY PERITONEAL CARCINOMA
S M=$E(M,2,5)
I T="T1",N="N0",M="M0" S SG=1 Q
I T="T1a",N="N0",M="M0" S SG="1A" Q
I T="T1b",N="N0",M="M0" S SG="1B" Q
I T="T1c",N="N0",M="M0" S SG="1C" Q
I T="T2",N="N0",M="M0" S SG=2 Q
I T="T2a",N="N0",M="M0" S SG="2A" Q
I T="T2b",N="N0",M="M0" S SG="2B" Q
I (($E(T,1,2)="T1")!($E(T,1,2)="T2")),N="N1",M="M0" S SG="3A1" Q
I T="T3a",((N="NX")!(N="N0")!(N="N1")),M="M0" S SG="3A2" Q
I T="T3b",((N="NX")!(N="N0")!(N="N1")),M="M0" S SG="3B" Q
I T="T3c",((N="NX")!(N="N0")!(N="N1")),M="M0" S SG="3C" Q
I M="M1" S SG=4 Q
I M="M1a" S SG="4A" Q
I M="M1b" S SG="4B"
Q
56 ;GTN
S M=$E(M,2,5)
I T="T1",M="M0" S SG=1
I T="T1",M="M1a" S SG=3
I T="T1",M="M1b" S SG=4
I T="T2",M="M0" S SG=2
I T="T1",M="M1a" S SG=3
I T="T1",M="M1b" S SG=4
I SG'="",RSCORE'="" S SG=SG_":"_RSCORE
Q
57 ;PENIS
S M=$E(M,2,5)
I T="Tis",N="N0",M="M0" S SG="0is" Q
I T="Ta",N="N0",M="M0" S SG="0a" Q
I T="T1a",N="N0",M="M0" S SG=1 Q
I T="T1b",N="N0",M="M0" S SG="2A" Q
I T="T2",N="N0",M="M0" S SG="2A" Q
I T="T3",N="N0",M="M0" S SG="2B" Q
I (($E(T,1,2)="T1")!($E(T,1,2)="T2")!($E(T,1,2)="T3")),N="N1",M="M0" S SG="3A" Q
I (($E(T,1,2)="T1")!($E(T,1,2)="T2")!($E(T,1,2)="T3")),N="N2",M="M0" S SG="3B" Q
I T="T4",M="M0" S SG=4 Q
I N="N3",M="M0" S SG=4 Q
I M="M1" S SG=4
Q
;
CLEANUP ;Cleanup
K M,N,SG,T
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HONCSGA8B 13717 printed Nov 22, 2024@17:38:30 Page 2
ONCSGA8B ;HINES OIFO/RTK - AJCC 8th Ed Automatic Staging Tables ;01/15/19
+1 ;;2.2;ONCOLOGY;**10,12,13,18,20**;Jul 31, 2013;Build 5
+2 ;
+3 ;
30 ;NET
+1 SET M=$EXTRACT(M,2,5)
+2 IF T="T1"
IF N="N0"
IF M="M0"
SET SG=1
QUIT
+3 IF T="T2"
IF N="N0"
IF M="M0"
SET SG=2
QUIT
+4 IF T="T3"
IF N="N0"
IF M="M0"
SET SG=2
QUIT
+5 IF T="T4"
IF N="N0"
IF M="M0"
SET SG=3
QUIT
+6 IF N="N1"
IF M="M0"
SET SG=3
QUIT
+7 IF M["M1"
SET SG=4
+8 QUIT
31 ;NET
+1 SET M=$EXTRACT(M,2,5)
+2 IF ((T="TX")!(T="T0"))
IF ((N="NX")!(N="N0")!(N="N1")!(N="N2"))
IF M["M1"
SET SG=4
QUIT
+3 IF T="T1"
IF N="N0"
IF M="M0"
SET SG=1
QUIT
+4 IF T="T1"
IF ((N="N1")!(N="N2"))
IF M="M0"
SET SG=3
QUIT
+5 IF T="T1"
IF ((N="NX")!(N="N0")!(N="N1")!(N="N2"))
IF M["M1"
SET SG=4
QUIT
+6 IF T="T2"
IF N="N0"
IF M="M0"
SET SG=2
QUIT
+7 IF T="T2"
IF ((N="N1")!(N="N2"))
IF M="M0"
SET SG=3
QUIT
+8 IF T="T2"
IF ((N="NX")!(N="N0")!(N="N1")!(N="N2"))
IF M["M1"
SET SG=4
QUIT
+9 IF T="T3"
IF N="N0"
IF M="M0"
SET SG=2
QUIT
+10 IF T="T3"
IF ((N="N1")!(N="N2"))
IF M="M0"
SET SG=3
QUIT
+11 IF T="T3"
IF ((N="NX")!(N="N0")!(N="N1")!(N="N2"))
IF M["M1"
SET SG=4
QUIT
+12 IF T="T4"
IF N="N0"
IF M="M0"
SET SG=3
QUIT
+13 IF T="T4"
IF ((N="N1")!(N="N2"))
IF M="M0"
SET SG=3
QUIT
+14 IF T="T4"
IF ((N="NX")!(N="N0")!(N="N1")!(N="N2"))
IF M["M1"
SET SG=4
+15 QUIT
32 ;NET
+1 DO 29^ONCSGA8A
+2 QUIT
33 ;NET
+1 SET M=$EXTRACT(M,2,5)
+2 IF ((T="TX")!(T="T0"))
IF M["M1"
SET SG=4
QUIT
+3 IF T["T1"
IF N="N0"
IF M="M0"
SET SG=1
QUIT
+4 IF T["T1"
IF N="N1"
IF M="M0"
SET SG="3B"
QUIT
+5 IF T["T1"
IF M["M1"
SET SG=4
QUIT
+6 IF T="T2"
IF N="N0"
IF M="M0"
SET SG="2A"
QUIT
+7 IF T="T2"
IF N="N1"
IF M="M0"
SET SG="3B"
QUIT
+8 IF T="T2"
IF M["M1"
SET SG=4
QUIT
+9 IF T="T3"
IF N="N0"
IF M="M0"
SET SG="2B"
QUIT
+10 IF T="T3"
IF N="N1"
IF M="M0"
SET SG="3B"
QUIT
+11 IF T="T3"
IF M["M1"
SET SG=4
QUIT
+12 IF T="T4"
IF N="N0"
IF M="M0"
SET SG="3A"
QUIT
+13 IF T="T4"
IF N="N1"
IF M="M0"
SET SG="3B"
QUIT
+14 IF T="T4"
IF M["M1"
SET SG=4
+15 QUIT
34 ;NET
+1 DO 30
+2 QUIT
35 ;THYMUS
+1 SET M=$EXTRACT(M,2,5)
+2 IF ((T="T1a")!(T="T1b"))
IF N="N0"
IF M="M0"
SET SG=1
QUIT
+3 IF T="T2"
IF N="N0"
IF M="M0"
SET SG=2
QUIT
+4 IF T="T3"
IF N="N0"
IF M="M0"
SET SG="3A"
QUIT
+5 IF T="T4"
IF N="N0"
IF M="M0"
SET SG="3B"
QUIT
+6 IF N="N1"
IF M="M0"
SET SG="4A"
QUIT
+7 IF ((N="N0")!(N="N1"))
IF M="M1a"
SET SG="4A"
QUIT
+8 IF N="N2"
IF ((M="M0")!(M="M1a"))
SET SG="4B"
QUIT
+9 IF M="M1b"
SET SG="4B"
+10 QUIT
36 ;LUNG
+1 SET M=$EXTRACT(M,2,5)
+2 IF T="TX"
IF N="N0"
IF M="M0"
SET SG="OccultCarcinoma"
QUIT
+3 IF T="Tis"
IF N="N0"
IF M="M0"
SET SG=0
QUIT
+4 IF T="T1mi"
IF N="N0"
IF M="M0"
SET SG="1A1"
QUIT
+5 IF T="T1a"
IF N="N0"
IF M="M0"
SET SG="1A1"
QUIT
+6 IF T="T1a"
IF N="N1"
IF M="M0"
SET SG="2B"
QUIT
+7 IF T="T1a"
IF N="N2"
IF M="M0"
SET SG="3A"
QUIT
+8 IF T="T1a"
IF N="N3"
IF M="M0"
SET SG="3B"
QUIT
+9 IF T="T1b"
IF N="N0"
IF M="M0"
SET SG="1A2"
QUIT
+10 IF T="T1b"
IF N="N1"
IF M="M0"
SET SG="2B"
QUIT
+11 IF T="T1b"
IF N="N2"
IF M="M0"
SET SG="3A"
QUIT
+12 IF T="T1b"
IF N="N3"
IF M="M0"
SET SG="3B"
QUIT
+13 IF T="T1c"
IF N="N0"
IF M="M0"
SET SG="1A3"
QUIT
+14 IF T="T1c"
IF N="N1"
IF M="M0"
SET SG="2B"
QUIT
+15 IF T="T1c"
IF N="N2"
IF M="M0"
SET SG="3A"
QUIT
+16 IF T="T1c"
IF N="N3"
IF M="M0"
SET SG="3B"
QUIT
+17 IF T="T2a"
IF N="N0"
IF M="M0"
SET SG="1B"
QUIT
+18 IF T="T2a"
IF N="N1"
IF M="M0"
SET SG="2B"
QUIT
+19 IF T="T2a"
IF N="N2"
IF M="M0"
SET SG="3A"
QUIT
+20 IF T="T2a"
IF N="N3"
IF M="M0"
SET SG="3B"
QUIT
+21 IF T="T2b"
IF N="N0"
IF M="M0"
SET SG="2A"
QUIT
+22 IF T="T2b"
IF N="N1"
IF M="M0"
SET SG="2B"
QUIT
+23 IF T="T2b"
IF N="N2"
IF M="M0"
SET SG="3A"
QUIT
+24 IF T="T2b"
IF N="N3"
IF M="M0"
SET SG="3B"
QUIT
+25 IF T="T3"
IF N="N0"
IF M="M0"
SET SG="2B"
QUIT
+26 IF T="T3"
IF N="N1"
IF M="M0"
SET SG="3A"
QUIT
+27 IF T="T3"
IF N="N2"
IF M="M0"
SET SG="3B"
QUIT
+28 IF T="T3"
IF N="N3"
IF M="M0"
SET SG="3C"
QUIT
+29 IF T="T4"
IF N="N0"
IF M="M0"
SET SG="3A"
QUIT
+30 IF T="T4"
IF N="N1"
IF M="M0"
SET SG="3A"
QUIT
+31 IF T="T4"
IF N="N2"
IF M="M0"
SET SG="3B"
QUIT
+32 IF T="T4"
IF N="N3"
IF M="M0"
SET SG="3C"
QUIT
+33 IF M="M1"
SET SG="4A"
QUIT
+34 IF M="M1a"
SET SG="4A"
QUIT
+35 IF M="M1b"
SET SG="4A"
QUIT
+36 IF M="M1c"
SET SG="4B"
+37 QUIT
37 ;MALIGNANT PLEURAL MESOTHELIOMA
+1 SET M=$EXTRACT(M,2,5)
+2 IF T="T1"
IF N="N0"
IF M="M0"
SET SG="1A"
QUIT
+3 IF ((T="T2")!(T="T3"))
IF N="N0"
IF M="M0"
SET SG="1B"
QUIT
+4 IF T="T1"
IF N="N1"
IF M="M0"
SET SG=2
QUIT
+5 IF T="T2"
IF N="N1"
IF M="M0"
SET SG=2
QUIT
+6 IF T="T3"
IF N="N1"
IF M="M0"
SET SG="3A"
QUIT
+7 IF ((T="T1")!(T="T2")!(T="T3"))
IF N="N2"
IF M="M0"
SET SG="3B"
QUIT
+8 IF T="T4"
IF M="M0"
SET SG="3B"
QUIT
+9 IF M="M1"
SET SG=4
+10 QUIT
381 ;BONE
+1 SET M=$EXTRACT(M,2,5)
+2 IF T="T1"
IF N="N0"
IF M="M0"
IF ((G=1)!(G=9))
SET SG="1A"
QUIT
+3 IF T="T2"
IF N="N0"
IF M="M0"
IF ((G=1)!(G=9))
SET SG="1B"
QUIT
+4 IF T="T3"
IF N="N0"
IF M="M0"
IF ((G=1)!(G=9))
SET SG="1B"
QUIT
+5 IF T="T1"
IF N="N0"
IF M="M0"
IF ((G=2)!(G=3))
SET SG="2A"
QUIT
+6 IF T="T2"
IF N="N0"
IF M="M0"
IF ((G=2)!(G=3))
SET SG="2B"
QUIT
+7 IF T="T3"
IF N="N0"
IF M="M0"
IF ((G=2)!(G=3))
SET SG=3
QUIT
+8 IF N="N0"
IF M="M1a"
SET SG="4A"
QUIT
+9 IF N="N1"
SET SG="4A"
QUIT
+10 IF M="M1b"
SET SG="4B"
+11 QUIT
41 ;SOFT TISSUE
+1 SET M=$EXTRACT(M,2,5)
+2 IF T="T1"
IF N="N0"
IF M="M0"
IF ((G=1)!(G=9))
SET SG="1A"
QUIT
+3 IF ((T="T2")!(T="T3")!(T="T4"))
IF N="N0"
IF M="M0"
IF ((G=1)!(G=9))
SET SG="1B"
QUIT
+4 IF T="T1"
IF N="N0"
IF M="M0"
IF ((G=2)!(G=3))
SET SG=2
QUIT
+5 IF T="T2"
IF N="N0"
IF M="M0"
IF ((G=2)!(G=3))
SET SG="3A"
QUIT
+6 IF ((T="T3")!(T="T4"))
IF N="N0"
IF M="M0"
IF ((G=2)!(G=3))
SET SG="3B"
QUIT
+7 IF N="N1"
IF M="M0"
SET SG=4
QUIT
+8 IF M="M1"
SET SG=4
+9 QUIT
431 ;GIST
+1 SET M=$EXTRACT(M,2,5)
+2 IF ((T="T1")!(T="T2"))
IF N="N0"
IF M="M0"
IF MTRT="L"
SET SG="1A"
QUIT
+3 IF T="T3"
IF N="N0"
IF M="M0"
IF MTRT="L"
SET SG="1B"
QUIT
+4 IF T="T1"
IF N="N0"
IF M="M0"
IF MTRT="H"
SET SG=2
QUIT
+5 IF T="T2"
IF N="N0"
IF M="M0"
IF MTRT="H"
SET SG=2
QUIT
+6 IF T="T4"
IF N="N0"
IF M="M0"
IF MTRT="L"
SET SG=3
QUIT
+7 IF T="T3"
IF N="N0"
IF M="M0"
IF MTRT="H"
SET SG="3A"
QUIT
+8 IF T="T4"
IF N="N0"
IF M="M0"
IF MTRT="H"
SET SG="3B"
QUIT
+9 IF N="N1"
IF M="M0"
SET SG=4
QUIT
+10 IF M="M1"
SET SG=4
+11 QUIT
432 ;GIST
+1 SET M=$EXTRACT(M,2,5)
+2 IF ((T="T1")!(T="T2"))
IF N="N0"
IF M="M0"
IF MTRT="L"
SET SG=1
QUIT
+3 IF T="T3"
IF N="N0"
IF M="M0"
IF MTRT="L"
SET SG=2
QUIT
+4 IF T="T1"
IF N="N0"
IF M="M0"
IF MTRT="H"
SET SG="3A"
QUIT
+5 IF T="T4"
IF N="N0"
IF M="M0"
IF MTRT="L"
SET SG="3A"
QUIT
+6 IF T="T2"
IF N="N0"
IF M="M0"
IF MTRT="H"
SET SG="3B"
QUIT
+7 IF T="T3"
IF N="N0"
IF M="M0"
IF MTRT="H"
SET SG="3B"
QUIT
+8 IF T="T4"
IF N="N0"
IF M="M0"
IF MTRT="H"
SET SG="3B"
QUIT
+9 IF N="N1"
IF M="M0"
SET SG=4
QUIT
+10 IF M="M1"
SET SG=4
+11 QUIT
44 ;SOFT TISSUE
+1 SET M=$EXTRACT(M,2,5)
+2 IF T="T1"
IF N="N0"
IF M="M0"
IF ((G=1)!(G=9))
SET SG="1A"
QUIT
+3 IF ((T="T2")!(T="T3")!(T="T4"))
IF N="N0"
IF M="M0"
IF ((G=1)!(G=9))
SET SG="1B"
QUIT
+4 IF T="T1"
IF N="N0"
IF M="M0"
IF ((G=2)!(G=3))
SET SG=2
QUIT
+5 IF T="T2"
IF N="N0"
IF M="M0"
IF ((G=2)!(G=3))
SET SG="3A"
QUIT
+6 IF ((T="T3")!(T="T4"))
IF N="N0"
IF M="M0"
IF ((G=2)!(G=3))
SET SG="3B"
QUIT
+7 IF N="N1"
IF M="M0"
SET SG="3B"
QUIT
+8 IF M="M1"
SET SG=4
+9 QUIT
46 ;MERKEL CELL
+1 SET M=$EXTRACT(M,2,5)
+2 IF STGIND'="P"
Begin DoDot:1
+3 IF T="Tis"
IF N="N0"
IF M="M0"
SET SG=0
QUIT
+4 IF T="T1"
IF N="N0"
IF M="M0"
SET SG=1
QUIT
+5 IF ((T="T2")!(T="T3"))
IF N="N0"
IF M="M0"
SET SG="2A"
QUIT
+6 IF T="T4"
IF N="N0"
IF M="M0"
SET SG="2B"
QUIT
+7 IF ((T="T0")!(T="T1")!(T="T2")!(T="T3")!(T="T4"))
IF ((N="N1")!(N="N2")!(N="N3"))
IF M="M0"
SET SG=3
QUIT
+8 IF ((T="T0")!(T="T1")!(T="T2")!(T="T3")!(T="T4"))
IF M["M1"
SET SG=4
QUIT
End DoDot:1
+9 IF STGIND="P"
Begin DoDot:1
+10 IF T="Tis"
IF N="N0"
IF M="M0"
SET SG=0
QUIT
+11 IF T="T1"
IF N="N0"
IF M="M0"
SET SG=1
QUIT
+12 IF ((T="T2")!(T="T3"))
IF N="N0"
IF M="M0"
SET SG="2A"
QUIT
+13 IF T="T4"
IF N="N0"
IF M="M0"
SET SG="2B"
QUIT
+14 IF ((T="T1")!(T="T2")!(T="T3")!(T="T4"))
IF N="N1a"
IF M="M0"
IF PNSFX'="(f)"
SET SG="3A"
QUIT
+15 IF T="T0"
IF N="N1b"
IF M="M0"
SET SG="3A"
QUIT
+16 IF ((T="T1")!(T="T2")!(T="T3")!(T="T4"))
IF ((N="N1b")!(N="N2")!(N="N3"))
IF M="M0"
SET SG="3B"
QUIT
+17 IF ((T="T0")!(T="T1")!(T="T2")!(T="T3")!(T="T4"))
IF M["M1"
SET SG=4
QUIT
End DoDot:1
+18 QUIT
47 ;MELANOMA OF THE SKIN
+1 SET M=$EXTRACT(M,2,5)
+2 IF STGIND'="P"
Begin DoDot:1
+3 IF T="Tis"
IF N="N0"
IF M="M0"
SET SG=0
QUIT
+4 IF T="T1a"
IF N="N0"
IF M="M0"
SET SG="1A"
QUIT
+5 IF T="T1b"
IF N="N0"
IF M="M0"
SET SG="1B"
QUIT
+6 IF T="T2a"
IF N="N0"
IF M="M0"
SET SG="1B"
QUIT
+7 IF T="T2b"
IF N="N0"
IF M="M0"
SET SG="2A"
QUIT
+8 IF T="T3a"
IF N="N0"
IF M="M0"
SET SG="2A"
QUIT
+9 IF T="T3b"
IF N="N0"
IF M="M0"
SET SG="2B"
QUIT
+10 IF T="T4a"
IF N="N0"
IF M="M0"
SET SG="2B"
QUIT
+11 IF T="T4b"
IF N="N0"
IF M="M0"
SET SG="2C"
QUIT
+12 IF N'="NX"
IF N'="N0"
IF M="M0"
SET SG=3
QUIT
+13 IF M["M1"
SET SG=4
QUIT
End DoDot:1
+14 IF STGIND="P"
Begin DoDot:1
+15 IF T="Tis"
IF N="N0"
IF M="M0"
SET SG=0
QUIT
+16 IF ((T="T1a")!(T="T1b"))
IF N="N0"
IF M="M0"
SET SG="1A"
QUIT
+17 IF T="T2a"
IF N="N0"
IF M="M0"
SET SG="1B"
QUIT
+18 IF ((T="T2b")!(T="T3a"))
IF N="N0"
IF M="M0"
SET SG="2A"
QUIT
+19 IF ((T="T3b")!(T="T4a"))
IF N="N0"
IF M="M0"
SET SG="2B"
QUIT
+20 IF T="T4b"
IF N="N0"
IF M="M0"
SET SG="2C"
QUIT
+21 IF T="T0"
IF ((N="N1b")!(N="N1c"))
IF M="M0"
SET SG="3B"
QUIT
+22 IF T="T0"
IF ((N="N2b")!(N="N2c")!(N="N3b")!(N="N3c"))
IF M="M0"
SET SG="3C"
QUIT
+23 IF ((T="T1a")!(T="T1b")!(T="T2a"))
IF ((N="N1a")!(N="N2a"))
IF M="M0"
SET SG="3A"
QUIT
+24 IF ((T="T1a")!(T="T1b")!(T="T2a"))
IF ((N="N1b")!(N="N1c")!(N="N2b"))
IF M="M0"
SET SG="3B"
QUIT
+25 IF ((T="T2b")!(T="T3a"))
IF ((N="N1a")!(N="N1b")!(N="N1c")!(N="N2a")!(N="N2b"))
IF M="M0"
SET SG="3B"
QUIT
+26 IF ((T="T1a")!(T="T1b")!(T="T2a")!(T="T2b")!(T="T3a"))
IF ((N="N2c")!(N="N3a")!(N="N3b")!(N="N3c"))
IF M="M0"
SET SG="3C"
QUIT
+27 IF ((T="T3b")!(T="T4a"))
IF ((N'="NX")&(N'="N0"))
IF M="M0"
SET SG="3C"
QUIT
+28 IF T="T4b"
IF ((N="N1a")!(N="N1b")!(N="N1c")!(N="N2a")!(N="N2b")!(N="N2c"))
IF M="M0"
SET SG="3C"
QUIT
+29 IF T="T4b"
IF ((N="N3a")!(N="N3b")!(N="N3c"))
IF M="M0"
SET SG="3D"
QUIT
+30 IF M["M1"
SET SG=4
QUIT
End DoDot:1
+31 QUIT
48 ;BREAST
+1 ;can strip,only use char 2-3 b/c M0(i+) treated same as M0
SET M=$EXTRACT(M,2,3)
+2 IF STGIND'="P"
Begin DoDot:1
+3 IF T["Tis"
IF N="N0"
IF M="M0"
SET SG=0
QUIT
+4 IF ((T["T1")&(N="N0")&(M="M0"))!((T="T0")&(N="N1mi")&(M="M0"))!((T["T1")&(N="N1mi")&(M="M0"))
DO 1^ONCSGA8X
+5 IF ((T="T0")&(N["N1")&(M="M0"))!((T["T1")&(N["N1")&(M="M0"))&((T="T2")&(N="N0")&(M="M0"))
DO 2^ONCSGA8X
+6 IF ((T="T2")&(N["N1")&(M="M0"))!((T="T3")&(N="N0")&(M="M0"))
DO 3^ONCSGA8X
+7 IF ((T="T0")&(N="N2")&(M="M0"))!((T["T1")&(N="N2")&(M="M0"))!((T="T2")&(N="N2")&(M="M0"))!((T="T3")&(N["N1")&(M="M0"))!((T="T3")&(N="N2")&(M="M0"))
DO 4^ONCSGA8X
+8 IF ((T="T4")&(N="N0")&(M="M0"))!((T="T4")&(N["N1")&(M="M0"))!((T="T4")&(N="N2")&(M="M0"))!((N="N3")&(M="M0"))
DO 5^ONCSGA8X
+9 IF M="M1"
SET SG=4
End DoDot:1
+10 IF STGIND="P"
Begin DoDot:1
+11 IF T["Tis"
IF N="N0"
IF M="M0"
SET SG=0
QUIT
+12 IF ((T["T1")&(N="N0")&(M="M0"))!((T="T0")&(N="N1mi")&(M="M0"))!((T["T1")&(N="N1mi")&(M="M0"))
DO 1^ONCSGA8X
+13 IF ((T="T0")&(N["N1")&(M="M0"))!((T["T1")&(N["N1")&(M="M0"))!((T="T2")&(N="N0")&(M="M0"))
DO 2^ONCSGA8X
+14 IF ((T="T2")&(N["N1")&(M="M0"))!((T="T3")&(N="N0")&(M="M0"))
DO 3^ONCSGA8X
+15 IF ((T="T0")&(N="N2")&(M="M0"))!((T["T1")&(N="N2")&(M="M0"))!((T="T2")&(N="N2")&(M="M0"))!((T="T3")&(N["N1")&(M="M0"))!((T="T3")&(N="N2")&(M="M0"))
DO 4^ONCSGA8X
+16 IF ((T="T4")&(N="N0")&(M="M0"))!((T="T4")&(N["N1")&(M="M0"))!((T="T4")&(N="N2")&(M="M0"))!((N="N3")&(M="M0"))
DO 5^ONCSGA8X
+17 IF M="M1"
SET SG=4
End DoDot:1
+18 QUIT
+19 ;
50 ;VULVA
+1 SET M=$EXTRACT(M,2,5)
+2 IF T="T1"
IF N="N0"
IF M="M0"
SET SG=1
QUIT
+3 IF T="T1a"
IF N="N0"
IF M="M0"
SET SG="1A"
QUIT
+4 IF T="T1b"
IF N="N0"
IF M="M0"
SET SG="1B"
QUIT
+5 IF T="T2"
IF N="N0"
IF M="M0"
SET SG=2
QUIT
+6 IF (($EXTRACT(T,1,2)="T1")!($EXTRACT(T,1,2)="T2"))
IF (($EXTRACT(N,1,2)="N1")!($EXTRACT(N,1,2)="N2"))
IF M="M0"
SET SG=3
QUIT
+7 IF (($EXTRACT(T,1,2)="T1")!($EXTRACT(T,1,2)="T2"))
IF N="N1"
IF M="M0"
SET SG="3A"
QUIT
+8 IF (($EXTRACT(T,1,2)="T1")!($EXTRACT(T,1,2)="T2"))
IF ((N="N2a")!(N="N2b"))
IF M="M0"
SET SG="3B"
QUIT
+9 IF (($EXTRACT(T,1,2)="T1")!($EXTRACT(T,1,2)="T2"))
IF N="N2c"
IF M="M0"
SET SG="3C"
QUIT
+10 IF (($EXTRACT(T,1,2)="T1")!($EXTRACT(T,1,2)="T2")!($EXTRACT(T,1,2)="T3"))
IF N="N3"
IF ((M="M0")!(M="M1"))
SET SG=4
QUIT
+11 IF (($EXTRACT(T,1,2)="T1")!($EXTRACT(T,1,2)="T2"))
IF N="N3"
IF M="M1"
SET SG="4A"
QUIT
+12 IF T="T3"
IF M="M0"
SET SG="4A"
QUIT
+13 IF M="M1"
SET SG="4B"
+14 QUIT
51 ;VAGINA
+1 SET M=$EXTRACT(M,2,5)
+2 IF T="T1a"
IF N="N0"
IF M="M0"
SET SG="1A"
QUIT
+3 IF T="T1b"
IF N="N0"
IF M="M0"
SET SG="1B"
QUIT
+4 IF T="T2a"
IF N="N0"
IF M="M0"
SET SG="2A"
QUIT
+5 IF T="T2b"
IF N="N0"
IF M="M0"
SET SG="2B"
QUIT
+6 IF (($EXTRACT(T,1,2)="T1")!($EXTRACT(T,1,2)="T2")!($EXTRACT(T,1,2)="T3"))
IF N="N1"
IF ((M="M0")!(M="M1"))
SET SG=3
QUIT
+7 IF T="T3"
IF N="N0"
IF M="M1"
SET SG=3
QUIT
+8 IF T="T4"
IF M="M0"
SET SG="4A"
QUIT
+9 IF M="M1"
SET SG="4B"
+10 QUIT
52 ;CERVIX UTERI
+1 SET M=$EXTRACT(M,2,5)
+2 IF $PIECE($GET(^ONCO(165.5,D0,0)),"^",16)>3201231
DO V529^ONCSGA8C
QUIT
+3 IF T="T1"
IF M="M0"
SET SG=1
QUIT
+4 IF T="T1a"
IF M="M0"
SET SG="1A"
QUIT
+5 IF T="T1a1"
IF M="M0"
SET SG="1A1"
QUIT
+6 IF T="T1a2"
IF M="M0"
SET SG="1A2"
QUIT
+7 IF T="T1b"
IF M="M1"
SET SG="1B"
QUIT
+8 IF T="T1b1"
IF M="M0"
SET SG="1B1"
QUIT
+9 IF T="T1b2"
IF M="M0"
SET SG="1B2"
QUIT
+10 IF T="T2"
IF M="M0"
SET SG=2
QUIT
+11 IF T="T2a"
IF M="M0"
SET SG="2A"
QUIT
+12 IF T="T2a1"
IF M="M0"
SET SG="2A1"
QUIT
+13 IF T="T2a2"
IF M="M0"
SET SG="2A2"
QUIT
+14 IF T="T2b"
IF M="M0"
SET SG="2B"
QUIT
+15 IF T="T3"
IF M="M0"
SET SG=3
QUIT
+16 IF T="T3a"
IF M="M0"
SET SG="3A"
QUIT
+17 IF T="T3b"
IF M="M0"
SET SG="3B"
QUIT
+18 IF T="T4"
IF M="M0"
SET SG="4A"
QUIT
+19 IF M="M1"
SET SG="4B"
+20 QUIT
53 ;CORPUS UTERI
+1 SET M=$EXTRACT(M,2,5)
+2 IF T="T1"
IF N="N0"
IF M="M0"
SET SG=1
QUIT
+3 IF T="T1a"
IF N="N0"
IF M="M0"
SET SG="1A"
QUIT
+4 IF T="T1b"
IF N="N0"
IF M="M0"
SET SG="1B"
QUIT
+5 IF T="T2"
IF N="N0"
IF M="M0"
SET SG=2
QUIT
+6 IF T="T3"
IF N="N0"
IF M="M1"
SET SG=3
QUIT
+7 IF T="T3a"
IF N="N0"
IF M="M0"
SET SG="3A"
QUIT
+8 IF T="T3b"
IF N="N0"
IF M="M0"
SET SG="3B"
QUIT
+9 IF (($EXTRACT(T,1,2)="T1")!($EXTRACT(T,1,2)="T2")!($EXTRACT(T,1,2)="T3"))
IF ((N="N1")!(N="N1mi")!(N="N1a"))
IF M="M0"
SET SG="3C1"
QUIT
+10 IF (($EXTRACT(T,1,2)="T1")!($EXTRACT(T,1,2)="T2")!($EXTRACT(T,1,2)="T3"))
IF ((N="N2")!(N="N2mi")!(N="N2a"))
IF M="M0"
SET SG="3C2"
QUIT
+11 IF T="T4"
IF M="M0"
SET SG="4A"
QUIT
+12 IF M="M1"
SET SG="4B"
+13 QUIT
541 ;CORPUS UTERI
+1 SET M=$EXTRACT(M,2,5)
+2 IF T="T1"
IF N="N0"
IF M="M0"
SET SG=1
QUIT
+3 IF T="T1a"
IF N="N0"
IF M="M0"
SET SG="1A"
QUIT
+4 IF T="T1b"
IF N="N0"
IF M="M0"
SET SG="1B"
QUIT
+5 IF T="T2"
IF N="N0"
IF M="M0"
SET SG=2
QUIT
+6 IF T="T3a"
IF N="N0"
IF M="M0"
SET SG="3A"
QUIT
+7 IF T="T3b"
IF N="N0"
IF M="M0"
SET SG="3B"
QUIT
+8 IF (($EXTRACT(T,1,2)="T1")!($EXTRACT(T,1,2)="T2")!($EXTRACT(T,1,2)="T3"))
IF N="N1"
IF M="M0"
SET SG="3C"
QUIT
+9 IF T="T4"
IF M="M0"
SET SG="4A"
QUIT
+10 IF M="M1"
SET SG="4B"
+11 QUIT
542 ;CORPUS UTERI
+1 SET M=$EXTRACT(M,2,5)
+2 IF T="T1"
IF N="N0"
IF M="M0"
SET SG=1
QUIT
+3 IF T="T1a"
IF N="N0"
IF M="M0"
SET SG="1A"
QUIT
+4 IF T="T1b"
IF N="N0"
IF M="M0"
SET SG="1B"
QUIT
+5 IF T="T1c"
IF N="N0"
IF M="M0"
SET SG="1C"
QUIT
+6 IF T="T2"
IF N="N0"
IF M="M0"
SET SG=2
QUIT
+7 IF T="T3a"
IF N="N0"
IF M="M0"
SET SG="3A"
QUIT
+8 IF T="T3b"
IF N="N0"
IF M="M0"
SET SG="3B"
QUIT
+9 IF (($EXTRACT(T,1,2)="T1")!($EXTRACT(T,1,2)="T2")!($EXTRACT(T,1,2)="T3"))
IF N="N1"
IF M="M0"
SET SG="3C"
QUIT
+10 IF T="T4"
IF M="M0"
SET SG="4A"
QUIT
+11 IF M="M1"
SET SG="4B"
+12 QUIT
55 ;OVARY, FALLOPIAN TUBE AND PRIMARY PERITONEAL CARCINOMA
+1 SET M=$EXTRACT(M,2,5)
+2 IF T="T1"
IF N="N0"
IF M="M0"
SET SG=1
QUIT
+3 IF T="T1a"
IF N="N0"
IF M="M0"
SET SG="1A"
QUIT
+4 IF T="T1b"
IF N="N0"
IF M="M0"
SET SG="1B"
QUIT
+5 IF T="T1c"
IF N="N0"
IF M="M0"
SET SG="1C"
QUIT
+6 IF T="T2"
IF N="N0"
IF M="M0"
SET SG=2
QUIT
+7 IF T="T2a"
IF N="N0"
IF M="M0"
SET SG="2A"
QUIT
+8 IF T="T2b"
IF N="N0"
IF M="M0"
SET SG="2B"
QUIT
+9 IF (($EXTRACT(T,1,2)="T1")!($EXTRACT(T,1,2)="T2"))
IF N="N1"
IF M="M0"
SET SG="3A1"
QUIT
+10 IF T="T3a"
IF ((N="NX")!(N="N0")!(N="N1"))
IF M="M0"
SET SG="3A2"
QUIT
+11 IF T="T3b"
IF ((N="NX")!(N="N0")!(N="N1"))
IF M="M0"
SET SG="3B"
QUIT
+12 IF T="T3c"
IF ((N="NX")!(N="N0")!(N="N1"))
IF M="M0"
SET SG="3C"
QUIT
+13 IF M="M1"
SET SG=4
QUIT
+14 IF M="M1a"
SET SG="4A"
QUIT
+15 IF M="M1b"
SET SG="4B"
+16 QUIT
56 ;GTN
+1 SET M=$EXTRACT(M,2,5)
+2 IF T="T1"
IF M="M0"
SET SG=1
+3 IF T="T1"
IF M="M1a"
SET SG=3
+4 IF T="T1"
IF M="M1b"
SET SG=4
+5 IF T="T2"
IF M="M0"
SET SG=2
+6 IF T="T1"
IF M="M1a"
SET SG=3
+7 IF T="T1"
IF M="M1b"
SET SG=4
+8 IF SG'=""
IF RSCORE'=""
SET SG=SG_":"_RSCORE
+9 QUIT
57 ;PENIS
+1 SET M=$EXTRACT(M,2,5)
+2 IF T="Tis"
IF N="N0"
IF M="M0"
SET SG="0is"
QUIT
+3 IF T="Ta"
IF N="N0"
IF M="M0"
SET SG="0a"
QUIT
+4 IF T="T1a"
IF N="N0"
IF M="M0"
SET SG=1
QUIT
+5 IF T="T1b"
IF N="N0"
IF M="M0"
SET SG="2A"
QUIT
+6 IF T="T2"
IF N="N0"
IF M="M0"
SET SG="2A"
QUIT
+7 IF T="T3"
IF N="N0"
IF M="M0"
SET SG="2B"
QUIT
+8 IF (($EXTRACT(T,1,2)="T1")!($EXTRACT(T,1,2)="T2")!($EXTRACT(T,1,2)="T3"))
IF N="N1"
IF M="M0"
SET SG="3A"
QUIT
+9 IF (($EXTRACT(T,1,2)="T1")!($EXTRACT(T,1,2)="T2")!($EXTRACT(T,1,2)="T3"))
IF N="N2"
IF M="M0"
SET SG="3B"
QUIT
+10 IF T="T4"
IF M="M0"
SET SG=4
QUIT
+11 IF N="N3"
IF M="M0"
SET SG=4
QUIT
+12 IF M="M1"
SET SG=4
+13 QUIT
+14 ;
CLEANUP ;Cleanup
+1 KILL M,N,SG,T
+2 QUIT