source: WorldVistAEHR/trunk/r/VA_FILEMAN-ARJT-DI-DD-DM-DT-%DT-%RCR/DIG.m@ 837

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

initial load of WorldVistAEHR

File size: 5.2 KB
RevLine 
[613]1DIG ;SFISC/GFT-SUBTOTALS & SCATTERGRAM ;28SEP2004
2 ;;22.0;VA FileMan;**2,144**;Mar 30, 1999;Build 5
3 ;Per VHA Directive 2004-038, this routine should not be modified.
4 W ! I '$D(^DOSV(0,IO(0),2)) W "NO SUB-SUB TOTALS WERE RUN" Q
5 N POP,IOP,ZTSK S:$D(^%ZTSK) %ZIS="QM" D ^%ZIS Q:POP
6 G QUE:$D(IO("Q"))
7 ;
8DQ N DXMIN,DYMIN,DXMAX,DYMAX,DXI,N,NA,DYI
9 S NA=$NA(^DOSV(0,IO(0)))
10 S X=$O(@NA@(2,"")),(DXMIN,DXMAX)=X,(DYMIN,DYMAX)=$O(^(X,"")),X=""
11 F S X=$O(@NA@(2,X)) Q:X="" S DXMAX=X,Y=$O(^(X,"")),DY=$O(^(""),-1) S:DYMIN>Y DYMIN=Y S:DY>DYMAX DYMAX=DY
12 I DXMAX-DXMIN*(DYMAX-DYMIN)=0 D STATS(NA) Q
13 ;
14 ;here's the SCATTERGRAM
15NUMNUM N DIGPG,DIGTYPE,%H,%T,%Y,%D,B,I,L,H,T,DIGC,X,Y,DX,DY,DXS,DYS,DXSC,DYSC
16 D DIGC
17 S H=DYMAX,L=DYMIN,DYS=IOSL-9,N=DYS/6
18 D S(1)
19 S DYMIN=B,DYSC=I/6,DYMAX=T,DYI=X
20DYI I T-B/DYI*6'>DYS,DYI'<2 S DYI=DYI\2 G DYI
21 S H=DXMAX,L=DXMIN,DXS=IOM-28,N=DXS/6
22 D S(2)
23 S DXMIN=B,DXSC=I/6,DXI=X,DXMAX=T,T=X*DXS/(T-B)
24 S H=""
25LOOP K ^UTILITY($J)
26 S DIGTYPE="N",H=$O(@NA@("F",H)) G END:'H
27 D TOP
28 S (B,DX,DY)="" D G LOOP:X'=U
29I2 .S (DX,X)=$O(@NA@(2,DX)) I X="" W !?5,"(TOTAL = "_B_")",! G O
30 .I DIGC(2,0)["D" D H^%DTC S X=%H
31 .S X=$J(X-DXMIN/DXSC,0,0)
32I3 .S (Y,DY)=$O(@NA@(2,DX,DY)) G I2:Y="" I DIGC(1,0)["D" S C=X,X=Y D H^%DTC S Y=%H,X=C
33 .I $D(^(DY,H,"N")) S C=^("N"),Y=$J(Y-DYMIN/DYSC,0,0),B=B+C,^(X)=C+$G(^UTILITY($J,Y,X))
34 .G I3
35O .S X=0 D X W !?12,"." D P K Y S L=0 F B=DYMIN:DYI:DYMAX S Y($J(L,0,0))=$$E(B,1),L=DYI*DYS/(DYMAX-DYMIN)+L
36 .W ".",! F Y=DYS:-1:0 D W !
37 ..I $D(Y(Y)) W ?12-$L(Y(Y)),Y(Y),"+"
38 ..E W ?12,"|"
39 ..S X="" F S X=$O(^UTILITY($J,Y,X)) Q:X="" S I=^(X) W ?X+13,$S(I>9:"*",I:I,1:"")
40 ..W ?DXS+14 I W "+",Y(Y) Q
41 ..W "|"
42 .W ?13 D P W ! S X=DXI D X W !?22,"X-AXIS: ",$P(DIGC(2),U,3)," Y-AXIS: ",$P(DIGC(1),U,3)
43 .G EOP
44END W:$E(IOST)'="C"&$Y @IOF
45 K:$D(ZTSK) ^DOSV(0,IO(0))
46Q D CLOSE^DIO4
47 Q
48 ;
49X F B=DXMIN+X:DXI*2:DXMAX S Y=$$E(B,2) W ?B-DXMIN\DXSC-($L(Y)\2)+13,Y
50 Q
51 ;
52S(C) I DIGC(C,0)["D" F B="H","L" S X=@B D H^%DTC S @B=%H
53 S B=H-L,X=1 I B>1 F C=1:1 S X=X*10 Q:B'>X
54 E S I=1 Q:'B F C=0:-1 Q:X/10'>B S X=X/10
55 S B=L-X\X*X F I=B:X/10 Q:I'<L S B=I
56 S T=H+X\X*X F I=T:-X/10 Q:I'>H S T=I
57I S I=T-B/X*10 I I>N S X=X*2 G I
58 S X=X/10,I=T-B/N
59 Q
60 ;
61 ;
62 ;
63STATS(NA) ;
64 N DIGC,DIGB,DIGPG,RUN,DIGTYPE,DIG3,I,L,%T,H,DUOUT
65 D DIGC S DIGPG=1
66 I $D(@NA@(1)) D G Q:$D(DUOUT),END
67 .F H=0:0 S H=$O(@NA@("F",H)),DIGTYPE="S" Q:'H D:$P(^(H),U,4)'["D" S DIGTYPE="N" D Q:$D(DUOUT)
68 ..S Y="",L=0 F I=0:0 S Y=$O(@NA@(1,Y)) Q:Y="" I $D(^(Y,H,DIGTYPE)) S:$L(^(DIGTYPE))>L L=$L(^(DIGTYPE)) S:$L($$E(Y,1))>I I=$L($$E(Y,1))
69 ..I 'I!'L Q
70 ..D TOP W !!?4,$P(DIGC(1),U,3),!
71 ..S Y="",%T=0
72 ..F S Y=$O(@NA@(1,Y)) Q:Y="" I $D(^(Y,H,DIGTYPE)) D Q:$D(DUOUT)
73 ...I $Y+2>IOSL D EOP Q:$D(DUOUT) D TOP
74 ...W !?4,$$E(Y,1),?I+7 S X=@NA@(1,Y,H,DIGTYPE) W $J(X,L) S %T=%T+X
75 ..W !!?4,"TOTAL",?I+7,$J(%T,L) D EOP
76 S DIGB=$NA(@NA@(2)) I $D(@DIGB)>9 D ALL2 G END
77 S DIG3="" F S DIG3=$O(@NA@(3,DIG3)) G END:DIG3=""!$D(DUOUT) S DIGB=$NA(@NA@(3,DIG3)) D ALL2
78 ;
79ALL2 F RUN=0:0 S RUN=$O(@NA@("F",RUN)) Q:'RUN F DIGTYPE="S","N" I $P(@NA@("F",RUN),U,4)'["D"!(DIGTYPE="N") D RUN(RUN,DIGTYPE)
80 Q
81 ;
82RUN(H,DIGTYPE) N %H,%Y,%D,T,C,X,Y,DX,DY,DXS,DYS,DXSC,DYSC
83 S Y="",I=0,C=0,L=0
84 F S Y=$O(@DIGB@(Y)),X="" Q:Y="" S DY=$$E(Y,2) S:$L(DY)>I I=$L(DY) D
85 .F S X=$O(@DIGB@(Y,X)) Q:X="" I $D(^(X,H,DIGTYPE)) S:'$D(X(X)) C=C+1 S DX=$$E(X,1) S:$L(DX)>L L=$L(DX) S X(X)=""
86 ;I=width of left column
87 ;L=width of data columns
88 ;C=number of data columns
89 I 'C Q
90 S Y=L+2*C+I+13
91 I Y>IOM U IO(0) W !,"MARGIN WIDTH OF ",IOM," IS TOO SMALL FOR DISPLAY",!,"USE WIDTH OF AT LEAST ",Y Q
92 S I=I+3,L=IOM-13-I\C ;make columns wide
93 D TOP,SUBTOP
94 S Y=""
95 F S Y=$O(@DIGB@(Y)) Q:Y="" D G Q:$D(DUOUT)
96 .I $Y+2>IOSL D Q:$D(DUOUT) D TOP,SUBTOP
97 ..N X D EOP
98 .N T S X="" W !!?4,$$E(Y,2),?I+6
99 .F N=0:1 S X=$O(X(X)) Q:X="" S %T=$G(@DIGB@(Y,X,H,DIGTYPE)) W $J(+%T,L) S T=$G(T)+%T,DX(X)=$G(DX(X))+%T
100 .W $J(T,7)
101 S X=" ----------------------------------------------------"
102 W !!?I+6 F N=1:1:N W $E(X,1,L)
103 W $E(X,1,IOM-$X)
104 W !!," TOTALS",?I+6 S (%T,X)="" F N=0:1 S X=$O(X(X)) Q:X="" W $J(DX(X),L) S %T=%T+DX(X)
105 W $J(%T,7)
106EOP ;
107 I $G(IOST)?1"C".E D
108 .N DIR,X,Y
109 .S DIR(0)="E" D ^DIR
110 Q
111 ;
112TOP N X,Y
113 U IO W:$Y @IOF
114 S X=@NA@("F",H)
115 W !," ",$O(^DD(+X,0,"NM",0))," FILE: "
116 W $S(DIGTYPE="N":"COUNTS",1:"SUMS")
117 I $P(X,U,2)'=.01 W " OF '",$P(X,U,3),"'"
118 S Y=DT X ^DD("DD")
119 I $G(DIGPG) S Y=Y_" Page "_DIGPG,DIGPG=DIGPG+1
120 W ?IOM-$L(Y)-1,Y Q
121 ;
122SUBTOP N Y
123 I $D(DIG3) W !!?4,$P(DIGC(3),U,3),": ",$$E(DIG3,3),!
124 S Y=$P(DIGC(2),U,3) F X=1:1:$L(Y," ") W !?4,$P(Y," ",X)
125 S Y=$P(DIGC(1),U,3) W ?(IOM-I-$L(Y)\2+I+4),Y,!!
126 W ?I+6 S X="" F S X=$O(X(X)) Q:X="" W $J($$E(X,1),L)
127 W " TOTAL"
128 W ! F Y=1:1:IOM W "-"
129 Q
130 ;
131DIGC N X,C
132 S (X,C)="" F S X=$O(@NA@("BY",X),-1) Q:'X D
133 .S C=C+1,DIGC(C)=^(X)
134 .S DIGC(C,0)=$S($D(^DD(+DIGC(C),+$P(DIGC(C),U,2),0)):$P(^(0),U,2),1:$P(DIGC(C),U,7))
135 Q
136 ;
137E(VALUE,XY) ;2=Y,1=X
138 N %DT,Y
139 I $P(DIGC(XY),U,4)["-" S VALUE=-VALUE
140 I DIGC(XY,0)["O" Q VALUE
141 I VALUE,DIGC(XY,0)["D" S Y=VALUE D DD^%DT Q Y
142 I DIGC(XY,0)["S" S Y=$P(DIGC(XY),U,2) S:'Y Y=$P($P(DIGC(XY),U,4),"+""",2) S:Y Y=$$EXTERNAL^DILFD(+DIGC(XY),Y,,VALUE,"%DT(0)") I Y]"" Q Y
143 Q VALUE
144 ;
145P S L=-1,X=0
146PP I L<X W "+" S L=L+T
147 E W "-"
148 S X=X+1 G PP:X'>DXS Q
149 ;
150 ;
151QUE ;
152 S ZTSAVE("^DOSV(0,$I,")=""
153 S ZTIO=ION_";"_IOST_";"_IOM_";"_IOSL,ZTRTN="DQ^DIG"
154 D ^%ZTLOAD K ZTSK G END
Note: See TracBrowser for help on using the repository browser.