ONCSG5 ;Hines OIFO/GWB - Automatic Staging Tables ;08/08/11
;;2.2;ONCOLOGY;**1**;Jul 31, 2013;Build 8
;
;GENITOURINARY SITES
;
PEN36 ;Penis - 3rd, 4th, 5th and 6th editions
K SG
I M=1 S SG=4
E I M=0 D PENNM
I '$D(SG) S SG=99
Q
PENNM I (T=4)!(N=3) S SG=4
E I (T="IS")!(T="A"),N=0 S SG=0
E I T=1,N=0 S SG=1
E I T=1,N=1 S SG=2
E I T=2,(N=0)!(N=1) S SG=2
E I (T=1)!(T=2),N=2 S SG=3
E I T=3,(N=0)!(N=1)!(N=2) S SG=3
Q
;
PEN7 ;Penis - 7th edition
S TNM=T_N_M D K TNM Q
.I TNM="IS00" S SG=0 Q ;0 Tis N0 M0
.I TNM="A00" S SG=0 Q ; Ta N0 M0
.I TNM="1A00" S SG=1 Q ;I T1a N0 M0
.I TNM="1B00" S SG=2 Q ;II T1b N0 M0
.I TNM=200 S SG=2 Q ; T2 N0 M0
.I TNM=300 S SG=2 Q ; T3 N0 M0
.I $E(T,1)=1,N=1,M=0 S SG="3A" Q ;IIIA T1 N1 M0
.I $E(T,1)=2,N=1,M=0 S SG="3A" Q ; T2 N1 M0
.I $E(T,1)=3,N=1,M=0 S SG="3A" Q ; T3 N1 M0
.I $E(T,1)=1,N=2,M=0 S SG="3B" Q ;IIIB T1 N2 M0
.I $E(T,1)=2,N=2,M=0 S SG="3B" Q ; T2 N2 M0
.I $E(T,1)=3,N=2,M=0 S SG="3B" Q ; T3 N2 M0
.I T=4,M=0 S SG=4 Q ;IV T4 Any N M0
.I N=3,M=0 S SG=4 Q ; Any T N3 M0
.I M=1 S SG=4 Q ; Any T Any N M1
;
PROS3 ;Prostate - 3rd edition
I M!(N=1)!(N=2)!(N=3)!(T[4) S SG=4
E I T="1A"!(T="2A"),$E(N)=0,$E(M)=0,G,G'=9 S SG=$S(G=1:0,G>1:1)
E I T="1B"!(T="2B"),$E(N)=0,$E(M)=0 S SG=2
E I T=3,$E(N)=0,$E(M)=0 S SG=3
E S SG=99
Q
;
PROS4 ;Prostate - 4th edition
I M!(N=1)!(N=2)!(N=3)!(T[4) S SG=4
E I T="1A",$E(N)=0,$E(M)=0,G,G'=9 S SG=$S(G=1:0,G>1:1)
E I T="1B"!(T="1C")!(T=1),$E(N)=0,$E(M)=0 S SG=1
E I T[2,$E(N)=0,$E(M)=0 S SG=2
E I T[3,$E(N)=0,$E(M)=0 S SG=3
E S SG=99
Q
;
PROS56 ;Prostate - 5th and 6th edition
S TNM=T_N_$E(M,1) D K TNM Q
.I (G=1)&(TNM="1A00") S SG=1 Q ;I T1a N0 M0 G1
.I ((G=2)!(G=3)!(G=4))&(TNM="1A00") S SG=2 Q ;II T1a N0 M0 G2, 3-4
.I TNM="1B00" S SG=2 Q ; T1b N0 M0 Any G
.I TNM="1C00" S SG=2 Q ; T1c N0 M0 Any G
.I TNM=100 S SG=2 Q ; T1 N0 M0 Any G
.I $E(T,1)=2,N=0,M=0 S SG=2 Q ; T2 N0 M0 Any G
.I $E(T,1)=3,N=0,M=0 S SG=3 Q ;III T3 N0 M0 Any G
.I TNM=400 S SG=4 Q ;IV T4 N0 M0 Any G
.I N=1,M=0 S SG=4 Q ; Any T N1 M0 Any G
.I $E(M,1)=1 S SG=4 Q ; Any T Any N M1 Any G
;
PROS7 ;Prostate - 7th edition
;I T1a-c N0 M0 PSA<10 Gleason<=6
; T2a N0 M0 PSA<10 Gleason<=6
; T1-2a N0 M0 PSA X Gleason X
;IIA T1a-c N0 M0 PSA<20 Gleason=7
; T1a-c N0 M0 PSA>=10<20 Gleason<=6
; T2a N0 M0 PSA>=10<20 Gleason<=6
; T2a N0 M0 PSA<20 Gleason<=7
; T2b N0 M0 PSA<20 Gleason<=7
; T2b N0 M0 PSA X Gleason X
;IIB T2c N0 M0 Any PSA Any Gleason
; T1-2 N0 M0 PSA>=20 Any Gleason
; T1-2 N0 M0 Any PSA Gleason>=8
;III T3a-b N0 M0 Any PSA Any Gleason
;IV T4 N0 M0 Any PSA Any Gleason
; Any T N1 M0 Any PSA Any Gleason
; Any T Any N M1 Any PSA Any Gleason
;
N PSA,GS
S PSA=+$$GET1^DIQ(165.5,D0,684)
I (PSA=999.7)!(PSA=999.8)!(PSA=999.9) S PSA=""
I STGIND="C" S GS=+$$GET1^DIQ(165.5,D0,623,"I")
I STGIND="P" S GS=+$$GET1^DIQ(165.5,D0,250,"I")
I GS=99 S GS=""
S TNM=T_N_$E(M,1) D K TNM Q
.I ((TNM=100)!(TNM="1A00")!(TNM="1B00")!(TNM="1C00")),PSA<10,GS<7 S SG=1 Q
.I (TNM="2A00"),PSA<10,GS<7 S SG=1 Q
.I ((TNM=100)!(TNM="1A00")!(TNM="1B00")!(TNM="1C00")!(TNM=200)!(TNM="2A00")),PSA="",GS="" S SG=1 Q
.I ((TNM=100)!(TNM="1A00")!(TNM="1B00")!(TNM="1C00")),PSA<20,GS=7 S SG="2A" Q
.I ((TNM=100)!(TNM="1A00")!(TNM="1B00")!(TNM="1C00")!(TNM="2A00")),((PSA>9)&(PSA<20)),GS<7 S SG="2A" Q
.I (TNM="2A00"),PSA<20,GS<8 S SG="2A" Q
.I (TNM="2B00"),PSA<20,GS<8 S SG="2A" Q
.I (TNM="2B00"),PSA="",GS="" S SG="2A" Q
.I TNM="2C00" S SG="2B" Q
.I ((TNM=100)!(TNM="1A00")!(TNM="1B00")!(TNM="1C00")!(TNM=200)!(TNM="2A00")!(TNM="2B00")!(TNM="2C00")),PSA>19 S SG="2B" Q
.I ((TNM=100)!(TNM="1A00")!(TNM="1B00")!(TNM="1C00")!(TNM=200)!(TNM="2A00")!(TNM="2B00")!(TNM="2C00")),GS>7 S SG="2B" Q
.I ((TNM=300)!(TNM="3A00")!(TNM="3B00")) S SG=3 Q
.I TNM=400 S SG=4 Q
.I N=1,M=0 S SG=4 Q
.I $E(M,1)=1 S SG=4 Q
;
TES3 ;Testis - 3rd 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=2 Q
.I TNM=400 S SG=2 Q
.I N=1,M=0 S SG=3 Q
.I N=2,M=0 S SG=4 Q
.I N=3,M=0 S SG=4 Q
.I M=1 S SG=4 Q
;
TES4 ;Testis - 4th edition
S TNM=T_N_M D K TNM Q
.I TNM="IS00" S SG=0 Q ;0 Tis N0 M0
.I N=0,M=0 S SG=1 Q ;I Any T N0 M0
.I N=1,M=0 S SG=2 Q ;II Any T N1 M0
.I N=2,M=0 S SG=2 Q ; Any T N2 M0
.I N=3,M=0 S SG=2 Q ; Any T N3 M0
.I M=1 S SG=3 Q ;III Any T Any N M1
;
TES56 ;Testis - 5th and 6th editions
S STM=$P($G(^ONCO(165.5,D0,24)),U,8),STM=$E(STM,2)
S TNM=T_N_M_STM D K TNM,TM1,TM2,TM3,STM Q
.I TNM="IS000" S SG=0 Q ;0 Tis N0 M0 S0
.I TNM="100X" S SG=1 Q ;I T1 N0 M0 SX
.I TNM="200X" S SG=1 Q ; T2 N0 M0 SX
.I TNM="300X" S SG=1 Q ; T3 N0 M0 SX
.I TNM="400X" S SG=1 Q ; T4 N0 M0 SX
.I TNM=1000 S SG="1A" Q ;IA T1 N0 M0 S0
.I TNM=2000 S SG="1B" Q ;IB T2 N0 M0 S0
.I TNM=3000 S SG="1B" Q ; T3 N0 M0 S0
.I TNM=4000 S SG="1B" Q ; T4 N0 M0 S0
.I N=0,M=0,STM=1 S SG="1S" Q ;IS Any T N0 M0 S1
.I N=0,M=0,STM=2 S SG="1S" Q ; Any T N0 M0 S2
.I N=0,M=0,STM=3 S SG="1S" Q ; Any T N0 M0 S3
.I N=1,M=0,STM="X" S SG=2 Q ;II Any T N1 M0 SX
.I N=2,M=0,STM="X" S SG=2 Q ; Any T N2 M0 SX
.I N=3,M=0,STM="X" S SG=2 Q ; Any T N3 M0 SX
.I N=1,M=0,STM=0 S SG="2A" Q ;IIA Any T N1 M0 S0
.I N=1,M=0,STM=1 S SG="2A" Q ; Any T N1 M0 S1
.I N=2,M=0,STM=0 S SG="2B" Q ;IIB Any T N2 M0 S0
.I N=2,M=0,STM=1 S SG="2B" Q ; Any T N2 M0 S1
.I N=3,M=0,STM=0 S SG="2C" Q ;IIC Any T N3 M0 S0
.I N=3,M=0,STM=1 S SG="2C" Q ; Any T N3 M0 S1
.I M=1,STM="X" S SG=3 Q ;III Any T Any N M1 SX
.I M="1A",STM=0 S SG="3A" Q ;IIIA Any T Any N M1a S0
.I M="1A",STM=1 S SG="3A" Q ; Any T Any N M1a S1
.I N=1,M=0,STM=2 S SG="3B" Q ;IIIB Any T N1 M0 S2
.I N=2,M=0,STM=2 S SG="3B" Q ; Any T N2 M0 S2
.I N=3,M=0,STM=2 S SG="3B" Q ; Any T N3 M0 S2
.I M="1A",STM=2 S SG="3B" Q ; Any T Any N M1a S2
.I N=1,M=0,STM=3 S SG="3C" Q ;IIIC Any T N1 M0 S3
.I N=2,M=0,STM=3 S SG="3C" Q ; Any T N2 M0 S3
.I N=3,M=0,STM=3 S SG="3C" Q ; Any T N3 M0 S3
.I M="1A",STM=3 S SG="3C" Q ; Any T Any N M1a S3
.I M="1B" S SG="3C" Q ; Any T Any N M1b Any S
;
KID34 ;Kidney - 3rd and 4th editions
K SG
I M=1 S SG=4
E I M=0 D KIDNM
I '$D(SG) S SG=99
Q
KIDNM I (T=4)!(N=2)!(N=3) S SG=4
E I T=1,N=0 S SG=1
E I T=2,N=0 S SG=2
E I (T=1)!(T=2),N=1 S SG=3
E I T[3,(N=0)!(N=1) S SG=3
Q
;
KID5 ;Kidney - 5th edition
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=110 S SG=3 Q ;III T1 N1 M0
.I TNM=210 S SG=3 Q ; T2 N1 M0
.I TNM="3A00" S SG=3 Q ; T3a N0 M0
.I TNM="3A10" S SG=3 Q ; T3a N1 M0
.I TNM="3B00" S SG=3 Q ; T3b N0 M0
.I TNM="3B10" S SG=3 Q ; T3b N1 M0
.I TNM="3C00" S SG=3 Q ; T3c N0 M0
.I TNM="3C10" S SG=3 Q ; T3c N1 M0
.I TNM=400 S SG=4 Q ;IV T4 N0 M0
.I TNM=410 S SG=4 Q ; T4 N1 M0
.;per R-AD 01/13/98
.I TNM="4X0",STGIND="P" S SG=4 ; T4 NX M0 (Pathologic staging)
.I N=2,M=0 S SG=4 Q ; Any T N2 M0
.I M=1 S SG=4 Q ; Any T Any N M1
;
KID6 ;Kidney - 6th edition
S TNM=T_N_M D K TNM Q
.I $E(T,1)=1,N=0,M=0 S SG=1 Q ;I T1 N0 M0
.I TNM=200 S SG=2 Q ;II T2 N0 M0
.I $E(T,1)=1,N=1,M=0 S SG=3 Q ;III T1 N1 M0
.I TNM=210 S SG=3 Q ; T2 N1 M0
.I TNM=300 S SG=3 Q ; T3 N0 M0
.I TNM=310 S SG=3 Q ; T3 N1 M0
.I TNM="3A00" S SG=3 Q ; T3a N0 M0
.I TNM="3A10" S SG=3 Q ; T3a N1 M0
.I TNM="3B00" S SG=3 Q ; T3b N0 M0
.I TNM="3B10" S SG=3 Q ; T3b N1 M0
.I TNM="3C00" S SG=3 Q ; T3c N0 M0
.I TNM="3C10" S SG=3 Q ; T3c N1 M0
.I TNM=400 S SG=4 Q ;IV T4 N0 M0
.I TNM=410 S SG=4 Q ; T4 N1 M0
.;per R-AD 01/13/98
.I TNM="4X0",STGIND="P" S SG=4 ; T4 NX M0 (Pathologic staging)
.I N=2,M=0 S SG=4 Q ; Any T N2 M0
.I M=1 S SG=4 Q ; Any T Any N M1
;
KID7 ;Kidney - 7th edition
S TNM=$E(T,1)_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=110 S SG=3 Q ;III T1 N1 M0
.I TNM=210 S SG=3 Q ; T2 N1 M0
.I TNM=300 S SG=3 Q ; T3 N0 M0
.I TNM=310 S SG=3 Q ; T3 N1 M0
.I T=4,M=0 S SG=4 Q ;IV T4 Any N M0
.I M=1 S SG=4 Q ; Any T Any N M1
;
CLEANUP ;Cleanup
K D0,G,M,N,STGIND,T
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HONCSG5 10027 printed Dec 13, 2024@02:28:25 Page 2
ONCSG5 ;Hines OIFO/GWB - Automatic Staging Tables ;08/08/11
+1 ;;2.2;ONCOLOGY;**1**;Jul 31, 2013;Build 8
+2 ;
+3 ;GENITOURINARY SITES
+4 ;
PEN36 ;Penis - 3rd, 4th, 5th and 6th editions
+1 KILL SG
+2 IF M=1
SET SG=4
+3 IF '$TEST
IF M=0
DO PENNM
+4 IF '$DATA(SG)
SET SG=99
+5 QUIT
PENNM IF (T=4)!(N=3)
SET SG=4
+1 IF '$TEST
IF (T="IS")!(T="A")
IF N=0
SET SG=0
+2 IF '$TEST
IF T=1
IF N=0
SET SG=1
+3 IF '$TEST
IF T=1
IF N=1
SET SG=2
+4 IF '$TEST
IF T=2
IF (N=0)!(N=1)
SET SG=2
+5 IF '$TEST
IF (T=1)!(T=2)
IF N=2
SET SG=3
+6 IF '$TEST
IF T=3
IF (N=0)!(N=1)!(N=2)
SET SG=3
+7 QUIT
+8 ;
PEN7 ;Penis - 7th edition
+1 SET TNM=T_N_M
Begin DoDot:1
+2 ;0 Tis N0 M0
IF TNM="IS00"
SET SG=0
QUIT
+3 ; Ta N0 M0
IF TNM="A00"
SET SG=0
QUIT
+4 ;I T1a N0 M0
IF TNM="1A00"
SET SG=1
QUIT
+5 ;II T1b N0 M0
IF TNM="1B00"
SET SG=2
QUIT
+6 ; T2 N0 M0
IF TNM=200
SET SG=2
QUIT
+7 ; T3 N0 M0
IF TNM=300
SET SG=2
QUIT
+8 ;IIIA T1 N1 M0
IF $EXTRACT(T,1)=1
IF N=1
IF M=0
SET SG="3A"
QUIT
+9 ; T2 N1 M0
IF $EXTRACT(T,1)=2
IF N=1
IF M=0
SET SG="3A"
QUIT
+10 ; T3 N1 M0
IF $EXTRACT(T,1)=3
IF N=1
IF M=0
SET SG="3A"
QUIT
+11 ;IIIB T1 N2 M0
IF $EXTRACT(T,1)=1
IF N=2
IF M=0
SET SG="3B"
QUIT
+12 ; T2 N2 M0
IF $EXTRACT(T,1)=2
IF N=2
IF M=0
SET SG="3B"
QUIT
+13 ; T3 N2 M0
IF $EXTRACT(T,1)=3
IF N=2
IF M=0
SET SG="3B"
QUIT
+14 ;IV T4 Any N M0
IF T=4
IF M=0
SET SG=4
QUIT
+15 ; Any T N3 M0
IF N=3
IF M=0
SET SG=4
QUIT
+16 ; Any T Any N M1
IF M=1
SET SG=4
QUIT
End DoDot:1
KILL TNM
QUIT
+17 ;
PROS3 ;Prostate - 3rd edition
+1 IF M!(N=1)!(N=2)!(N=3)!(T[4)
SET SG=4
+2 IF '$TEST
IF T="1A"!(T="2A")
IF $EXTRACT(N)=0
IF $EXTRACT(M)=0
IF G
IF G'=9
SET SG=$SELECT(G=1:0,G>1:1)
+3 IF '$TEST
IF T="1B"!(T="2B")
IF $EXTRACT(N)=0
IF $EXTRACT(M)=0
SET SG=2
+4 IF '$TEST
IF T=3
IF $EXTRACT(N)=0
IF $EXTRACT(M)=0
SET SG=3
+5 IF '$TEST
SET SG=99
+6 QUIT
+7 ;
PROS4 ;Prostate - 4th edition
+1 IF M!(N=1)!(N=2)!(N=3)!(T[4)
SET SG=4
+2 IF '$TEST
IF T="1A"
IF $EXTRACT(N)=0
IF $EXTRACT(M)=0
IF G
IF G'=9
SET SG=$SELECT(G=1:0,G>1:1)
+3 IF '$TEST
IF T="1B"!(T="1C")!(T=1)
IF $EXTRACT(N)=0
IF $EXTRACT(M)=0
SET SG=1
+4 IF '$TEST
IF T[2
IF $EXTRACT(N)=0
IF $EXTRACT(M)=0
SET SG=2
+5 IF '$TEST
IF T[3
IF $EXTRACT(N)=0
IF $EXTRACT(M)=0
SET SG=3
+6 IF '$TEST
SET SG=99
+7 QUIT
+8 ;
PROS56 ;Prostate - 5th and 6th edition
+1 SET TNM=T_N_$EXTRACT(M,1)
Begin DoDot:1
+2 ;I T1a N0 M0 G1
IF (G=1)&(TNM="1A00")
SET SG=1
QUIT
+3 ;II T1a N0 M0 G2, 3-4
IF ((G=2)!(G=3)!(G=4))&(TNM="1A00")
SET SG=2
QUIT
+4 ; T1b N0 M0 Any G
IF TNM="1B00"
SET SG=2
QUIT
+5 ; T1c N0 M0 Any G
IF TNM="1C00"
SET SG=2
QUIT
+6 ; T1 N0 M0 Any G
IF TNM=100
SET SG=2
QUIT
+7 ; T2 N0 M0 Any G
IF $EXTRACT(T,1)=2
IF N=0
IF M=0
SET SG=2
QUIT
+8 ;III T3 N0 M0 Any G
IF $EXTRACT(T,1)=3
IF N=0
IF M=0
SET SG=3
QUIT
+9 ;IV T4 N0 M0 Any G
IF TNM=400
SET SG=4
QUIT
+10 ; Any T N1 M0 Any G
IF N=1
IF M=0
SET SG=4
QUIT
+11 ; Any T Any N M1 Any G
IF $EXTRACT(M,1)=1
SET SG=4
QUIT
End DoDot:1
KILL TNM
QUIT
+12 ;
PROS7 ;Prostate - 7th edition
+1 ;I T1a-c N0 M0 PSA<10 Gleason<=6
+2 ; T2a N0 M0 PSA<10 Gleason<=6
+3 ; T1-2a N0 M0 PSA X Gleason X
+4 ;IIA T1a-c N0 M0 PSA<20 Gleason=7
+5 ; T1a-c N0 M0 PSA>=10<20 Gleason<=6
+6 ; T2a N0 M0 PSA>=10<20 Gleason<=6
+7 ; T2a N0 M0 PSA<20 Gleason<=7
+8 ; T2b N0 M0 PSA<20 Gleason<=7
+9 ; T2b N0 M0 PSA X Gleason X
+10 ;IIB T2c N0 M0 Any PSA Any Gleason
+11 ; T1-2 N0 M0 PSA>=20 Any Gleason
+12 ; T1-2 N0 M0 Any PSA Gleason>=8
+13 ;III T3a-b N0 M0 Any PSA Any Gleason
+14 ;IV T4 N0 M0 Any PSA Any Gleason
+15 ; Any T N1 M0 Any PSA Any Gleason
+16 ; Any T Any N M1 Any PSA Any Gleason
+17 ;
+18 NEW PSA,GS
+19 SET PSA=+$$GET1^DIQ(165.5,D0,684)
+20 IF (PSA=999.7)!(PSA=999.8)!(PSA=999.9)
SET PSA=""
+21 IF STGIND="C"
SET GS=+$$GET1^DIQ(165.5,D0,623,"I")
+22 IF STGIND="P"
SET GS=+$$GET1^DIQ(165.5,D0,250,"I")
+23 IF GS=99
SET GS=""
+24 SET TNM=T_N_$EXTRACT(M,1)
Begin DoDot:1
+25 IF ((TNM=100)!(TNM="1A00")!(TNM="1B00")!(TNM="1C00"))
IF PSA<10
IF GS<7
SET SG=1
QUIT
+26 IF (TNM="2A00")
IF PSA<10
IF GS<7
SET SG=1
QUIT
+27 IF ((TNM=100)!(TNM="1A00")!(TNM="1B00")!(TNM="1C00")!(TNM=200)!(TNM="2A00"))
IF PSA=""
IF GS=""
SET SG=1
QUIT
+28 IF ((TNM=100)!(TNM="1A00")!(TNM="1B00")!(TNM="1C00"))
IF PSA<20
IF GS=7
SET SG="2A"
QUIT
+29 IF ((TNM=100)!(TNM="1A00")!(TNM="1B00")!(TNM="1C00")!(TNM="2A00"))
IF ((PSA>9)&(PSA<20))
IF GS<7
SET SG="2A"
QUIT
+30 IF (TNM="2A00")
IF PSA<20
IF GS<8
SET SG="2A"
QUIT
+31 IF (TNM="2B00")
IF PSA<20
IF GS<8
SET SG="2A"
QUIT
+32 IF (TNM="2B00")
IF PSA=""
IF GS=""
SET SG="2A"
QUIT
+33 IF TNM="2C00"
SET SG="2B"
QUIT
+34 IF ((TNM=100)!(TNM="1A00")!(TNM="1B00")!(TNM="1C00")!(TNM=200)!(TNM="2A00")!(TNM="2B00")!(TNM="2C00"))
IF PSA>19
SET SG="2B"
QUIT
+35 IF ((TNM=100)!(TNM="1A00")!(TNM="1B00")!(TNM="1C00")!(TNM=200)!(TNM="2A00")!(TNM="2B00")!(TNM="2C00"))
IF GS>7
SET SG="2B"
QUIT
+36 IF ((TNM=300)!(TNM="3A00")!(TNM="3B00"))
SET SG=3
QUIT
+37 IF TNM=400
SET SG=4
QUIT
+38 IF N=1
IF M=0
SET SG=4
QUIT
+39 IF $EXTRACT(M,1)=1
SET SG=4
QUIT
End DoDot:1
KILL TNM
QUIT
+40 ;
TES3 ;Testis - 3rd 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=2
QUIT
+6 IF TNM=400
SET SG=2
QUIT
+7 IF N=1
IF M=0
SET SG=3
QUIT
+8 IF N=2
IF M=0
SET SG=4
QUIT
+9 IF N=3
IF M=0
SET SG=4
QUIT
+10 IF M=1
SET SG=4
QUIT
End DoDot:1
KILL TNM
QUIT
+11 ;
TES4 ;Testis - 4th edition
+1 SET TNM=T_N_M
Begin DoDot:1
+2 ;0 Tis N0 M0
IF TNM="IS00"
SET SG=0
QUIT
+3 ;I Any T N0 M0
IF N=0
IF M=0
SET SG=1
QUIT
+4 ;II Any T N1 M0
IF N=1
IF M=0
SET SG=2
QUIT
+5 ; Any T N2 M0
IF N=2
IF M=0
SET SG=2
QUIT
+6 ; Any T N3 M0
IF N=3
IF M=0
SET SG=2
QUIT
+7 ;III Any T Any N M1
IF M=1
SET SG=3
QUIT
End DoDot:1
KILL TNM
QUIT
+8 ;
TES56 ;Testis - 5th and 6th editions
+1 SET STM=$PIECE($GET(^ONCO(165.5,D0,24)),U,8)
SET STM=$EXTRACT(STM,2)
+2 SET TNM=T_N_M_STM
Begin DoDot:1
+3 ;0 Tis N0 M0 S0
IF TNM="IS000"
SET SG=0
QUIT
+4 ;I T1 N0 M0 SX
IF TNM="100X"
SET SG=1
QUIT
+5 ; T2 N0 M0 SX
IF TNM="200X"
SET SG=1
QUIT
+6 ; T3 N0 M0 SX
IF TNM="300X"
SET SG=1
QUIT
+7 ; T4 N0 M0 SX
IF TNM="400X"
SET SG=1
QUIT
+8 ;IA T1 N0 M0 S0
IF TNM=1000
SET SG="1A"
QUIT
+9 ;IB T2 N0 M0 S0
IF TNM=2000
SET SG="1B"
QUIT
+10 ; T3 N0 M0 S0
IF TNM=3000
SET SG="1B"
QUIT
+11 ; T4 N0 M0 S0
IF TNM=4000
SET SG="1B"
QUIT
+12 ;IS Any T N0 M0 S1
IF N=0
IF M=0
IF STM=1
SET SG="1S"
QUIT
+13 ; Any T N0 M0 S2
IF N=0
IF M=0
IF STM=2
SET SG="1S"
QUIT
+14 ; Any T N0 M0 S3
IF N=0
IF M=0
IF STM=3
SET SG="1S"
QUIT
+15 ;II Any T N1 M0 SX
IF N=1
IF M=0
IF STM="X"
SET SG=2
QUIT
+16 ; Any T N2 M0 SX
IF N=2
IF M=0
IF STM="X"
SET SG=2
QUIT
+17 ; Any T N3 M0 SX
IF N=3
IF M=0
IF STM="X"
SET SG=2
QUIT
+18 ;IIA Any T N1 M0 S0
IF N=1
IF M=0
IF STM=0
SET SG="2A"
QUIT
+19 ; Any T N1 M0 S1
IF N=1
IF M=0
IF STM=1
SET SG="2A"
QUIT
+20 ;IIB Any T N2 M0 S0
IF N=2
IF M=0
IF STM=0
SET SG="2B"
QUIT
+21 ; Any T N2 M0 S1
IF N=2
IF M=0
IF STM=1
SET SG="2B"
QUIT
+22 ;IIC Any T N3 M0 S0
IF N=3
IF M=0
IF STM=0
SET SG="2C"
QUIT
+23 ; Any T N3 M0 S1
IF N=3
IF M=0
IF STM=1
SET SG="2C"
QUIT
+24 ;III Any T Any N M1 SX
IF M=1
IF STM="X"
SET SG=3
QUIT
+25 ;IIIA Any T Any N M1a S0
IF M="1A"
IF STM=0
SET SG="3A"
QUIT
+26 ; Any T Any N M1a S1
IF M="1A"
IF STM=1
SET SG="3A"
QUIT
+27 ;IIIB Any T N1 M0 S2
IF N=1
IF M=0
IF STM=2
SET SG="3B"
QUIT
+28 ; Any T N2 M0 S2
IF N=2
IF M=0
IF STM=2
SET SG="3B"
QUIT
+29 ; Any T N3 M0 S2
IF N=3
IF M=0
IF STM=2
SET SG="3B"
QUIT
+30 ; Any T Any N M1a S2
IF M="1A"
IF STM=2
SET SG="3B"
QUIT
+31 ;IIIC Any T N1 M0 S3
IF N=1
IF M=0
IF STM=3
SET SG="3C"
QUIT
+32 ; Any T N2 M0 S3
IF N=2
IF M=0
IF STM=3
SET SG="3C"
QUIT
+33 ; Any T N3 M0 S3
IF N=3
IF M=0
IF STM=3
SET SG="3C"
QUIT
+34 ; Any T Any N M1a S3
IF M="1A"
IF STM=3
SET SG="3C"
QUIT
+35 ; Any T Any N M1b Any S
IF M="1B"
SET SG="3C"
QUIT
End DoDot:1
KILL TNM,TM1,TM2,TM3,STM
QUIT
+36 ;
KID34 ;Kidney - 3rd and 4th editions
+1 KILL SG
+2 IF M=1
SET SG=4
+3 IF '$TEST
IF M=0
DO KIDNM
+4 IF '$DATA(SG)
SET SG=99
+5 QUIT
KIDNM IF (T=4)!(N=2)!(N=3)
SET SG=4
+1 IF '$TEST
IF T=1
IF N=0
SET SG=1
+2 IF '$TEST
IF T=2
IF N=0
SET SG=2
+3 IF '$TEST
IF (T=1)!(T=2)
IF N=1
SET SG=3
+4 IF '$TEST
IF T[3
IF (N=0)!(N=1)
SET SG=3
+5 QUIT
+6 ;
KID5 ;Kidney - 5th edition
+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 ;III T1 N1 M0
IF TNM=110
SET SG=3
QUIT
+5 ; T2 N1 M0
IF TNM=210
SET SG=3
QUIT
+6 ; T3a N0 M0
IF TNM="3A00"
SET SG=3
QUIT
+7 ; T3a N1 M0
IF TNM="3A10"
SET SG=3
QUIT
+8 ; T3b N0 M0
IF TNM="3B00"
SET SG=3
QUIT
+9 ; T3b N1 M0
IF TNM="3B10"
SET SG=3
QUIT
+10 ; T3c N0 M0
IF TNM="3C00"
SET SG=3
QUIT
+11 ; T3c N1 M0
IF TNM="3C10"
SET SG=3
QUIT
+12 ;IV T4 N0 M0
IF TNM=400
SET SG=4
QUIT
+13 ; T4 N1 M0
IF TNM=410
SET SG=4
QUIT
+14 ;per R-AD 01/13/98
+15 ; T4 NX M0 (Pathologic staging)
IF TNM="4X0"
IF STGIND="P"
SET SG=4
+16 ; Any T N2 M0
IF N=2
IF M=0
SET SG=4
QUIT
+17 ; Any T Any N M1
IF M=1
SET SG=4
QUIT
End DoDot:1
KILL TNM
QUIT
+18 ;
KID6 ;Kidney - 6th edition
+1 SET TNM=T_N_M
Begin DoDot:1
+2 ;I T1 N0 M0
IF $EXTRACT(T,1)=1
IF N=0
IF M=0
SET SG=1
QUIT
+3 ;II T2 N0 M0
IF TNM=200
SET SG=2
QUIT
+4 ;III T1 N1 M0
IF $EXTRACT(T,1)=1
IF N=1
IF M=0
SET SG=3
QUIT
+5 ; T2 N1 M0
IF TNM=210
SET SG=3
QUIT
+6 ; T3 N0 M0
IF TNM=300
SET SG=3
QUIT
+7 ; T3 N1 M0
IF TNM=310
SET SG=3
QUIT
+8 ; T3a N0 M0
IF TNM="3A00"
SET SG=3
QUIT
+9 ; T3a N1 M0
IF TNM="3A10"
SET SG=3
QUIT
+10 ; T3b N0 M0
IF TNM="3B00"
SET SG=3
QUIT
+11 ; T3b N1 M0
IF TNM="3B10"
SET SG=3
QUIT
+12 ; T3c N0 M0
IF TNM="3C00"
SET SG=3
QUIT
+13 ; T3c N1 M0
IF TNM="3C10"
SET SG=3
QUIT
+14 ;IV T4 N0 M0
IF TNM=400
SET SG=4
QUIT
+15 ; T4 N1 M0
IF TNM=410
SET SG=4
QUIT
+16 ;per R-AD 01/13/98
+17 ; T4 NX M0 (Pathologic staging)
IF TNM="4X0"
IF STGIND="P"
SET SG=4
+18 ; Any T N2 M0
IF N=2
IF M=0
SET SG=4
QUIT
+19 ; Any T Any N M1
IF M=1
SET SG=4
QUIT
End DoDot:1
KILL TNM
QUIT
+20 ;
KID7 ;Kidney - 7th edition
+1 SET TNM=$EXTRACT(T,1)_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 ;III T1 N1 M0
IF TNM=110
SET SG=3
QUIT
+5 ; T2 N1 M0
IF TNM=210
SET SG=3
QUIT
+6 ; T3 N0 M0
IF TNM=300
SET SG=3
QUIT
+7 ; T3 N1 M0
IF TNM=310
SET SG=3
QUIT
+8 ;IV T4 Any N M0
IF T=4
IF M=0
SET SG=4
QUIT
+9 ; Any T Any N M1
IF M=1
SET SG=4
QUIT
End DoDot:1
KILL TNM
QUIT
+10 ;
CLEANUP ;Cleanup
+1 KILL D0,G,M,N,STGIND,T