source: WorldVistAEHR/trunk/r/ONCOLOGY-ONC/ONCOSSA1.m@ 1111

Last change on this file since 1111 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 3.6 KB
Line 
1ONCOSSA1 ;WASH ISC/SRR-SURVIAL ANALYSIS CONT-1 ;4/16/92 18:31
2 ;;2.11;ONCOLOGY;;Mar 07, 1995
3 ;
4CHKCOND ;check condition
5 ;in: DIC,TIN,^DD(FNUM
6 ;out: P = 0 if OK
7 ; TOU = condition
8 ; FLDDAT(f) = 1^node^piece^codes for real; 0^expression for computed
9 ;do: ^DIM
10 N C,E,FLDOK,FLD,L,Q
11 S E=1,(FLDOK,P)=0,TOU="",Q=$C(34)
12 F L=1:1:$L(TIN) S C=$E(TIN,L),TOU=TOU_C S:C=Q E=1-E I C?1U,E D CHK
13 I P W !,?20,"Re-enter condition - may need explicit quotes." Q
14 I 'FLDOK W !,?20,"No valid fields - please re-enter." S P=1 Q
15 S X="S X="_TOU D ^DIM I $D(X)=0 S P=1 W !," Check MUMPS syntax."
16 Q
17 ;
18CHK ;check for field
19 S FLD=C
20CHK1 S L=L+1,C=$E(TIN,L),TOU=TOU_C I C?1UN!(C=" ") S FLD=FLD_C G CHK1
21 Q:FLD'?1U.UNP S X=FLD D ^DIC
22 I Y=-1 W !,?20,"Field ",FLD," ???" S P=1 Q
23 S FLDOK=1,X=+Y D SETFD
24 S Y=$F(TOU,FLD),X=$E(TOU,1,Y-1-$L(FLD))_"VAL("_X_")"_$E(TOU,Y,99),TOU=X
25 Q
26 ;
27SETFD ;set FLDDAT( with field info
28 ;in: X,^DD(FNUM,
29 ;out: FLDDAT(,Y
30 Q:$D(FLDDAT(X))!'$D(^DD(FNUM,X,0)) S Y=^(0)
31 I $P(Y,U,2)["C" S Y="0"_U_$P(Y,U,5,99)
32 E S %=$S($P(Y,U,2)["S":U_$P(Y,U,3),1:""),Y=$P(Y,U,4),Y="1"_U_$P(Y,";",1)_U_+$P(Y,";",2)_%
33 S FLDDAT(X)=Y
34 Q
35 ;
36GET ;get specs for survival analysis
37 ;in: ^DD(FNUM,
38 ;out: LEN = conversion divisor^duration unit^interval unit
39 ; COND = 1 for subgroup expression, 0 for group conditions
40 ; (n) = nth group condition
41 ; FLDDAT = see CHKCOND
42 ; MAXTIME= maximum time allowed
43 ; NGRPS = number of subgroups
44 ; MORTEXP= dead expression
45 ; LENEXP = duration expression
46 ; GRPEXP = subgroup expression
47 ; PLOT = 1 for curves plotted
48 ; ^TMP($J,"GRP",n) = title for nth group
49 ;do: CHKCOND,^DIC,^DIM
50 N DIC,P,TIN,TOU
51 S DIC="^DD(FNUM,",DIC("S")="I +$P(^(0),U,2)=0 "
52 S DIC("A")="Select survival DURATION field: "
53 S LEN=$S($D(ONCOS("D")):ONCOS("D"),1:""),TIN=$P(LEN,U,1)
54 I TIN'="" W !,"DURATION field: ",TIN G GET11
55GET1 S DIC(0)="AEQ" D ^DIC Q:Y<0 S TIN=$P(Y,U,2)
56GET11 S DIC(0)="E" D CHKCOND G:P GET1 S LENEXP=TOU,TIN=$P(LEN,U,2) G:TIN'="" GET21
57GET2 W !,"DURATION unit (Day, Wk, Mo, Yr): " R TIN:DTIME E S TIN="^"
58 I TIN[U S Y=-1 Q
59GET21 S TIN=$E(TIN,1) S:TIN?1L TIN=$C($A(TIN)-32)
60 I '$F("DWMY",TIN) W !,"Enter a time unit letter such as 'D' for Days" G GET2
61 S $P(LEN,U,1,2)=$S(TIN="D":"365.25^Days",TIN="W":"52^Weeks",TIN="M":"12^Mos",1:"1^Yrs")
62 S MAXTIME=+LEN*10,TIN=$P(LEN,U,3) G:TIN'="" GET23
63GET22 W !,"INTERVAL unit (Mo, Yr): Yr// " R TIN:DTIME E S TIN="^"
64 S:TIN="" TIN="Y" I TIN[U S Y=-1 Q
65GET23 S TIN=$E(TIN,1) S:TIN?1L TIN=$C($A(TIN)-32)
66 I '$F("MY",TIN) W !,"Enter 'M' for Months or 'Y' for Years" G GET22
67 I TIN="Y" S $P(LEN,U,3)="Yrs"
68 E S $P(LEN,U,3)="Mos",TIN=$P(LEN,U,1),$P(LEN,U,1)=TIN/12
69GET3 I $D(ONCOS("S")) S TIN=ONCOS("S") W !,"STATUS expression: ",TIN G GET4
70 W !,"Enter survival STATUS expression: " R TIN:DTIME E S TIN="^"
71 I TIN[U S Y=-1 Q
72 G:TIN'?."?" GET4 W !!,"Enter an expression like 'STATUS=0' to indicate"
73 W !,"that the patient is dead. In this example, 'STATUS' is"
74 W !,"the name of a field that is a set of codes, for which 1 means"
75 W !,"'living' and 0 means 'dead'.",! G GET3
76GET4 D CHKCOND G:P GET3 S MORTEXP=TOU
77 I $D(ONCOS("G")) S NGRPS=+ONCOS("G") G:NGRPS GET41
78 R !,"Number of sub-groups: 1// ",NGRPS:DTIME E S NGRPS="^"
79 S:NGRPS="" NGRPS=1 I NGRPS[U S Y=-1 Q
80GET41 I NGRPS=1 S COND=1,GRPEXP=1
81 E D SETGRPS^ONCOSSA2 G:NGRPS=1 GET41
82 I $D(ONCOS("L")) S PLOT=$S(ONCOS("L")["P":1,1:0) Q:ONCOS("L")["Y" G GET5
83 S Y="Do you want curves plotted? No// "
84 D GETYES^ONCOSINP Q:Y=-1 S PLOT=$T
85GET5 W ! S Y="Survival analysis for "
86 S Y=Y_$S(TEMPL:"template "_HEADER,1:"ALL cases")
87 S Y=Y_" - OK? Yes// " D GETYES^ONCOSINP S:'$T Y=-1
88 Q
Note: See TracBrowser for help on using the repository browser.