ONCOSSA4 ;WASH ISC/SRR,MLH-PLOT SURVIVAL SURVES ;11/1/93 12:33
;;2.2;ONCOLOGY;**1**;Jul 31, 2013;Build 8
PLOT ;plot survival curves
;in: CASES,HEADER,LEN,NGRPS,NMORT,NPG,XCRT,^TMP($J
;use: GRP
;out: NPG
;do: TOF^ONCOSSA3
D TOF^ONCOSSA3 Q:ONCOEX W $P(HEADER,U,1),"Survival Curve",$S(NGRPS>1:"s",1:"")
W ?IOM-30,$P(HEADER,U,2),NPG I NMORT=0 W !!,"NO deaths!",! Q
N IX,LMORT,LN,N,NLN,NX,P,XADJ,XSCL,XSIZ,YSIZ
I IOM<120 S NLN=20,XSIZ=60
E S NLN=50,XSIZ=120
S XSCL=0,YSIZ=100/NLN,LMORT=""
F GRP=1:1:NGRPS S N=CASES(GRP) D:N CPLT
S X="1;.01^3;.025^6;.05^12;.1^30;.25^60;.5^120;1",XSCL=XSCL/LEN
I XSCL>120 S XSCL=XSCL-1/120+1\1
E F GRP=1:1:99 S Y=$P(X,U,GRP) Q:Y="" I XSCL'>+Y S XSCL=$P(Y,";",2) Q
S:XSIZ=60 XSCL=XSCL+XSCL S XADJ=XSCL*LEN
F GRP=1:1:NGRPS S:$D(INS(GRP)) INTS(GRP)=INTS(GRP)\XADJ
F LN=0:1:NLN-1 D PLIN
W !?7,"0 |" F X=1:1:XSIZ W $S(X#10=0:"+",1:"-")
W !," ",$P(LEN,U,3),":",?8 S Y=$S(XSCL<.1:2,XSCL<.5:1,1:0)
F X=0:10:XSIZ W $J(X*XSCL,3,Y)," "
Q
;
CPLT ;compute plot coordinates
S P=100,(IX(GRP),Z)=0
F X=-1:0 S X=$O(^TMP($J,"KM",GRP,X)) Q:X="" D CP1 S Z=X
S INTS(GRP)=Z S:Z>XSCL XSCL=Z S LMORT=LMORT_$D(^TMP($J,"KM",GRP,Z,1))
Q
CP1 ;compute Psurv
I '$D(^TMP($J,"KM",GRP,X,1)) S N=N-^(0) Q
S Y=^TMP($J,"KM",GRP,X,1) F %=1:1:Y S N=N-1,P=P*N/(N+1)
S N=N-(+$G(^TMP($J,"KM",GRP,X,0))),Y=100-P\YSIZ S:Y&'$D(^TMP($J,"PLT",GRP,Y)) ^(Y)=X
Q
;
PLIN ;plot a line
N C
F GRP=1:1:NGRPS D:CASES(GRP) PL1
S Y="" F C=0:1:XSIZ S Y=Y_$S($D(C(C)):C(C),1:" ") Q:$O(C(C))=""
I LN#4=0 W !?5,$J(NLN-LN/NLN*100,3)," +",Y
E W !?9,"|",Y
Q
PL1 ;setup line in C(
S X=$O(^TMP($J,"PLT",GRP,LN)),Z=$S(X="":INTS(GRP),1:^(X)\XADJ),NX(GRP)=Z
F C=IX(GRP):1:Z S C(C)=$S($D(C(C)):"*",1:$C(GRP+64))
I X=""&'$E(LMORT,GRP) S CASES(GRP)=0
E S IX(GRP)=NX(GRP)
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HONCOSSA4 1837 printed Oct 16, 2024@18:26:25 Page 2
ONCOSSA4 ;WASH ISC/SRR,MLH-PLOT SURVIVAL SURVES ;11/1/93 12:33
+1 ;;2.2;ONCOLOGY;**1**;Jul 31, 2013;Build 8
PLOT ;plot survival curves
+1 ;in: CASES,HEADER,LEN,NGRPS,NMORT,NPG,XCRT,^TMP($J
+2 ;use: GRP
+3 ;out: NPG
+4 ;do: TOF^ONCOSSA3
+5 DO TOF^ONCOSSA3
if ONCOEX
QUIT
WRITE $PIECE(HEADER,U,1),"Survival Curve",$SELECT(NGRPS>1:"s",1:"")
+6 WRITE ?IOM-30,$PIECE(HEADER,U,2),NPG
IF NMORT=0
WRITE !!,"NO deaths!",!
QUIT
+7 NEW IX,LMORT,LN,N,NLN,NX,P,XADJ,XSCL,XSIZ,YSIZ
+8 IF IOM<120
SET NLN=20
SET XSIZ=60
+9 IF '$TEST
SET NLN=50
SET XSIZ=120
+10 SET XSCL=0
SET YSIZ=100/NLN
SET LMORT=""
+11 FOR GRP=1:1:NGRPS
SET N=CASES(GRP)
if N
DO CPLT
+12 SET X="1;.01^3;.025^6;.05^12;.1^30;.25^60;.5^120;1"
SET XSCL=XSCL/LEN
+13 IF XSCL>120
SET XSCL=XSCL-1/120+1\1
+14 IF '$TEST
FOR GRP=1:1:99
SET Y=$PIECE(X,U,GRP)
if Y=""
QUIT
IF XSCL'>+Y
SET XSCL=$PIECE(Y,";",2)
QUIT
+15 if XSIZ=60
SET XSCL=XSCL+XSCL
SET XADJ=XSCL*LEN
+16 FOR GRP=1:1:NGRPS
if $DATA(INS(GRP))
SET INTS(GRP)=INTS(GRP)\XADJ
+17 FOR LN=0:1:NLN-1
DO PLIN
+18 WRITE !?7,"0 |"
FOR X=1:1:XSIZ
WRITE $SELECT(X#10=0:"+",1:"-")
+19 WRITE !," ",$PIECE(LEN,U,3),":",?8
SET Y=$SELECT(XSCL<.1:2,XSCL<.5:1,1:0)
+20 FOR X=0:10:XSIZ
WRITE $JUSTIFY(X*XSCL,3,Y)," "
+21 QUIT
+22 ;
CPLT ;compute plot coordinates
+1 SET P=100
SET (IX(GRP),Z)=0
+2 FOR X=-1:0
SET X=$ORDER(^TMP($JOB,"KM",GRP,X))
if X=""
QUIT
DO CP1
SET Z=X
+3 SET INTS(GRP)=Z
if Z>XSCL
SET XSCL=Z
SET LMORT=LMORT_$DATA(^TMP($JOB,"KM",GRP,Z,1))
+4 QUIT
CP1 ;compute Psurv
+1 IF '$DATA(^TMP($JOB,"KM",GRP,X,1))
SET N=N-^(0)
QUIT
+2 SET Y=^TMP($JOB,"KM",GRP,X,1)
FOR %=1:1:Y
SET N=N-1
SET P=P*N/(N+1)
+3 SET N=N-(+$GET(^TMP($JOB,"KM",GRP,X,0)))
SET Y=100-P\YSIZ
if Y&'$DATA(^TMP($JOB,"PLT",GRP,Y))
SET ^(Y)=X
+4 QUIT
+5 ;
PLIN ;plot a line
+1 NEW C
+2 FOR GRP=1:1:NGRPS
if CASES(GRP)
DO PL1
+3 SET Y=""
FOR C=0:1:XSIZ
SET Y=Y_$SELECT($DATA(C(C)):C(C),1:" ")
if $ORDER(C(C))=""
QUIT
+4 IF LN#4=0
WRITE !?5,$JUSTIFY(NLN-LN/NLN*100,3)," +",Y
+5 IF '$TEST
WRITE !?9,"|",Y
+6 QUIT
PL1 ;setup line in C(
+1 SET X=$ORDER(^TMP($JOB,"PLT",GRP,LN))
SET Z=$SELECT(X="":INTS(GRP),1:^(X)\XADJ)
SET NX(GRP)=Z
+2 FOR C=IX(GRP):1:Z
SET C(C)=$SELECT($DATA(C(C)):"*",1:$CHAR(GRP+64))
+3 IF X=""&'$EXTRACT(LMORT,GRP)
SET CASES(GRP)=0
+4 IF '$TEST
SET IX(GRP)=NX(GRP)
+5 QUIT