XTERSUM4 ;ISF/RWF - Find error frequece ;05/27/10 14:25
;;8.0;KERNEL;**431**;;Build 35
;Per VHA Directive 2004-038, this routine should not be modified.
Q
;
SHOW ;Show the top error
N DIR,XTERMAX,DIRUT,DTOUT,DUOUT,ZTSAVE
S DIR(0)="N^1:999",DIR("A")="Number of Errors to show",DIR("B")=5
D ^DIR Q:$D(DIRUT)
S XTERMAX=Y,ZTSAVE("XTERMAX")=""
D EN^XUTMDEVQ("DQ^XTERSUM4","Top Errors",.ZTSAVE)
Q
;
DQ N X,D0,TOP,MAX,I
S D0=0,U="^",MAX=$G(XTERMAX,5)
F S D0=$O(^%ZTER(3.077,D0)) Q:'D0 D CHECK(D0,.TOP)
S I="A",C=1
W "Top ",MAX," Most Common Errors",?45,$$HTE^XLFDT($H),!
F S I=$O(TOP(I),-1),J="" Q:('I)!(C>MAX) F S J=$O(TOP(I,J),-1) Q:('J)!(C>MAX) S C=C+1,D0=J D SHOW1(D0)
Q
;
CHECK(D0,TOP) ;
N I,X,AR
S X=$$SUMALL(D0,.AR),TOP(X,D0)=0
Q
;
SHOW1(D0) ;Show 1 error
N X,AR,I,J
I $Y+10>IOSL D WAIT Q:$D(DIRUT) W @IOF
S X=^%ZTER(3.077,D0,0)
W !!,"Error: ",$P(X,U,1),?45,"Total Count: ",$$SUMALL(D0,.AR)
W !,"First Seen: ",$$FMTE^XLFDT($P(X,U,2)),?45,"Last Seen: ",$$FMTE^XLFDT($P(X,U,3))
Q:$D(AR)<10
W !,"Distribution over ",+AR," days"
S RANGE=""
F J=3:-1:0 W !,?5,$S(J:J*10,1:">0")," " F I=1:1:24 W $S('AR(I):" ",AR(I)'<(J*10):"x",1:" ")
W !," Time: 1--4---8--12--16--20--24"
Q
;
SUMALL(IEN,RET) ;Check one error
N H,TOTAL,CNT,T,I,X
S H=0,TOTAL=0,CNT=0
F S H=$O(^%ZTER(3.077,IEN,4,H)) Q:'H S TOTAL=TOTAL+$$SUM1(.RET,IEN,H),CNT=CNT+1
S RET=CNT
Q TOTAL
;
SUM1(RET,IEN,H) ;Sum over one day, return array
;New at caller
S X=$G(^%ZTER(3.077,IEN,4,H,0)),T=0
I $L(X) F I=1:1:24 S RET(I)=$G(RET(I))+$P(X,"~",I),T=T+$P(X,"~",I)
Q T
;
WAIT ;Wait at end of page
Q:$E(IOST,1)="P"
N DIR
S DIR(0)="E" D ^DIR
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HXTERSUM4 1704 printed Dec 13, 2024@02:40:52 Page 2
XTERSUM4 ;ISF/RWF - Find error frequece ;05/27/10 14:25
+1 ;;8.0;KERNEL;**431**;;Build 35
+2 ;Per VHA Directive 2004-038, this routine should not be modified.
+3 QUIT
+4 ;
SHOW ;Show the top error
+1 NEW DIR,XTERMAX,DIRUT,DTOUT,DUOUT,ZTSAVE
+2 SET DIR(0)="N^1:999"
SET DIR("A")="Number of Errors to show"
SET DIR("B")=5
+3 DO ^DIR
if $DATA(DIRUT)
QUIT
+4 SET XTERMAX=Y
SET ZTSAVE("XTERMAX")=""
+5 DO EN^XUTMDEVQ("DQ^XTERSUM4","Top Errors",.ZTSAVE)
+6 QUIT
+7 ;
DQ NEW X,D0,TOP,MAX,I
+1 SET D0=0
SET U="^"
SET MAX=$GET(XTERMAX,5)
+2 FOR
SET D0=$ORDER(^%ZTER(3.077,D0))
if 'D0
QUIT
DO CHECK(D0,.TOP)
+3 SET I="A"
SET C=1
+4 WRITE "Top ",MAX," Most Common Errors",?45,$$HTE^XLFDT($HOROLOG),!
+5 FOR
SET I=$ORDER(TOP(I),-1)
SET J=""
if ('I)!(C>MAX)
QUIT
FOR
SET J=$ORDER(TOP(I,J),-1)
if ('J)!(C>MAX)
QUIT
SET C=C+1
SET D0=J
DO SHOW1(D0)
+6 QUIT
+7 ;
CHECK(D0,TOP) ;
+1 NEW I,X,AR
+2 SET X=$$SUMALL(D0,.AR)
SET TOP(X,D0)=0
+3 QUIT
+4 ;
SHOW1(D0) ;Show 1 error
+1 NEW X,AR,I,J
+2 IF $Y+10>IOSL
DO WAIT
if $DATA(DIRUT)
QUIT
WRITE @IOF
+3 SET X=^%ZTER(3.077,D0,0)
+4 WRITE !!,"Error: ",$PIECE(X,U,1),?45,"Total Count: ",$$SUMALL(D0,.AR)
+5 WRITE !,"First Seen: ",$$FMTE^XLFDT($PIECE(X,U,2)),?45,"Last Seen: ",$$FMTE^XLFDT($PIECE(X,U,3))
+6 if $DATA(AR)<10
QUIT
+7 WRITE !,"Distribution over ",+AR," days"
+8 SET RANGE=""
+9 FOR J=3:-1:0
WRITE !,?5,$SELECT(J:J*10,1:">0")," "
FOR I=1:1:24
WRITE $SELECT('AR(I):" ",AR(I)'<(J*10):"x",1:" ")
+10 WRITE !," Time: 1--4---8--12--16--20--24"
+11 QUIT
+12 ;
SUMALL(IEN,RET) ;Check one error
+1 NEW H,TOTAL,CNT,T,I,X
+2 SET H=0
SET TOTAL=0
SET CNT=0
+3 FOR
SET H=$ORDER(^%ZTER(3.077,IEN,4,H))
if 'H
QUIT
SET TOTAL=TOTAL+$$SUM1(.RET,IEN,H)
SET CNT=CNT+1
+4 SET RET=CNT
+5 QUIT TOTAL
+6 ;
SUM1(RET,IEN,H) ;Sum over one day, return array
+1 ;New at caller
+2 SET X=$GET(^%ZTER(3.077,IEN,4,H,0))
SET T=0
+3 IF $LENGTH(X)
FOR I=1:1:24
SET RET(I)=$GET(RET(I))+$PIECE(X,"~",I)
SET T=T+$PIECE(X,"~",I)
+4 QUIT T
+5 ;
WAIT ;Wait at end of page
+1 if $EXTRACT(IOST,1)="P"
QUIT
+2 NEW DIR
+3 SET DIR(0)="E"
DO ^DIR
+4 QUIT