LABERR ; IHS/DIR/AAB - ERROR TRAP FOR LABORATORY AUTO INSTRUMENTS 09:45 ; [ 11/20/90 ]
;;5.2;LA;**1003**;SEP 01, 1998
;
;;5.2;AUTOMATED LAB INSTRUMENTS;**42**;Sep 27, 1994
EN ;
;^LA("ERR")=Last # used^Time last error^instrument/routine^Total errors todate
;^LA("ERR",#,0)=Time^IO^$J^DUZ^Tsk/instrument/routine^ZA^ZB^UCI^ZTSK
;^LA("ERR",#,"ER")=Error Description
;^LA("ERR",#,"ZR")=0
;^LA("ERR",#,"ZTSK")=ZTSK
;All local variables are stored in ^%ZTSK(ZTSK
; The data is cleared on the third day (midnight) This is the default setting
;Field 606 of ^LAB(69.9 allows this time to be site determined (3-30 days)
;The Y(x) variable are saved in LABZY(x) and X variable is saved in LABZX
;%ZTLOAD PROGRAM KILLS Y(x) VARIABLES.
EN1 ;
S (LABZA,LABZB,LABZR)=0,LABZE=$$EC^%ZOSV
S:$D(X)#2 LABZX=X S:$D(Y)#2 LABZY=Y S:$D(%DT)#2 LABZD=%DT S:$D(X1)#2 LABZX1=X1 S:$D(LABZX2)#2 LABZX2=X2 S:$D(X3)#2 LABZX3=X3 S:$D(DT)#2 LABZDT=DT
S XS="" F Y=0:0 S XS=$O(Y(XS)) Q:XS="" S LABZY(XS)=Y(XS)
K XS N I,X,X1,Y,X2,DT,%DT,ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE,ZTSK
S DT=$$DT^XLFDT,SY=$$NOW^XLFDT
L ^LA("ERR")
S:'$D(^LA("ERR"))#2 ^LA("ERR")=0 S ERR=+^LA("ERR")
S:'$D(^LA("ERR","DT",DT)) ^(DT)=0 G:^(DT)>100 FUL S $P(^LA("ERR"),"^",2)=SY
A S ERR=ERR+1 G:$D(^LA("ERR",ERR)) A S $P(^LA("ERR"),U)=ERR,$P(^("ERR"),U,4)=1+$P(^("ERR"),U,4),^LA("ERR","DT",DT)=1+^LA("ERR","DT",DT)
X ^%ZOSF("UCI") S LABUCI=Y
S ^LA("ERR",ERR,0)=SY_U_$S($D(IO)#2:IO,$D(ION):ION,$D(IO(0)):IO(0),1:"")_U_$J_U_$S($D(DUZ):DUZ,1:.5)_U_$S($D(LANM):LANM,$D(LRINST):LRINST,$D(TSK):TSK,$D(T):T,1:"???")_U_LABZA_U_LABZB_U_Y
S ^("ZR")=LABZR,^("ZE")=LABZE
S $P(^LA("ERR"),U,3)=$P(^LA("ERR",ERR,0),U,5)
S ^LA("ERR","B",$P(^LA("ERR",ERR,0),U,5),ERR)=""
L
S X2=3 I $D(^LAB(69.9,1,"ER"))#2,+^("ER")>0 S X2=^("ER")
S X1=DT D C^%DTC S ZTDTH=X_".2359",ZTSAVE("*")="",ZTRTN="DQ^LABERR",ZTDESC="CLEAN UP LAB ERROR TRAP",ZTIO=""
LOAD ;
S:$D(LABZX)#2 X=LABZX S:$D(LABZY)#2 Y=LABZY S:$D(LABZD)#2 %DT=LABZD S:$D(LABZX1)#2 X1=LABZX1 S:$D(LABZX2)#2 X2=LABZX2 S:$D(LABZX3)#2 X3=LABZX3 S:$D(LABZDT)#2 DT=LABZDT
K ZTSK D ^%ZTLOAD S ZTSK=$S($D(ZTSK):ZTSK,1:"???") S $P(^LA("ERR",ERR,0),U,9)=ZTSK
S ^LA("ERR",ERR,"ZTSK")=ZTSK
S ^LA("ERR","C",$P(^(0),U,5),ZTSK)=""
FUL ;
L K ERR,X1,X2,ZTSK,ZTDTH,ZTRTN,ZTDESC,ZTIO,%DT,LABZX,LABUCI,LABZY,LABZA,LABZD,LABZX1,LABZX2,LABZX3,LABZB,LABZDT,LABZE,LABZR,SY Q
Q
;
DQ ;Dequeue errors
S:$D(ZTQUEUED) ZTREQ="@"
I $D(ERR),$D(^LA("ERR",ERR,0)) S TSK=$S($L($P(^(0),U,5)):$P(^(0),U,5),1:0),T=+$P(^(0),".") K ^LA("ERR",ERR),^LA("ERR","B",TSK,ERR) I $P(^LA("ERR"),U,4)>0 S $P(^("ERR"),U,4)=$P(^("ERR"),U,4)-1
I $D(TSK),$D(ZTSK) K ^LA("ERR","C",TSK,ZTSK)
I $D(T),$D(^LA("ERR","DT",T))#2 S:^(T)>0 ^(T)=^(T)-1 I ^(T)=0 K ^(T)
Q
LABERR ; IHS/DIR/AAB - ERROR TRAP FOR LABORATORY AUTO INSTRUMENTS 09:45 ; [ 11/20/90 ]
+1 ;;5.2;LA;**1003**;SEP 01, 1998
+2 ;
+3 ;;5.2;AUTOMATED LAB INSTRUMENTS;**42**;Sep 27, 1994
EN ;
+1 ;^LA("ERR")=Last # used^Time last error^instrument/routine^Total errors todate
+2 ;^LA("ERR",#,0)=Time^IO^$J^DUZ^Tsk/instrument/routine^ZA^ZB^UCI^ZTSK
+3 ;^LA("ERR",#,"ER")=Error Description
+4 ;^LA("ERR",#,"ZR")=0
+5 ;^LA("ERR",#,"ZTSK")=ZTSK
+6 ;All local variables are stored in ^%ZTSK(ZTSK
+7 ; The data is cleared on the third day (midnight) This is the default setting
+8 ;Field 606 of ^LAB(69.9 allows this time to be site determined (3-30 days)
+9 ;The Y(x) variable are saved in LABZY(x) and X variable is saved in LABZX
+10 ;%ZTLOAD PROGRAM KILLS Y(x) VARIABLES.
EN1 ;
+1 SET (LABZA,LABZB,LABZR)=0
SET LABZE=$$EC^%ZOSV
+2 IF $DATA(X)#2
SET LABZX=X
IF $DATA(Y)#2
SET LABZY=Y
IF $DATA(%DT)#2
SET LABZD=%DT
IF $DATA(X1)#2
SET LABZX1=X1
IF $DATA(LABZX2)#2
SET LABZX2=X2
IF $DATA(X3)#2
SET LABZX3=X3
IF $DATA(DT)#2
SET LABZDT=DT
+3 SET XS=""
FOR Y=0:0
SET XS=$ORDER(Y(XS))
IF XS=""
QUIT
SET LABZY(XS)=Y(XS)
+4 KILL XS
NEW I,X,X1,Y,X2,DT,%DT,ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE,ZTSK
+5 SET DT=$$DT^XLFDT
SET SY=$$NOW^XLFDT
+6 LOCK ^LA("ERR")
+7 IF '$DATA(^LA("ERR"))#2
SET ^LA("ERR")=0
SET ERR=+^LA("ERR")
+8 IF '$DATA(^LA("ERR","DT",DT))
SET ^(DT)=0
IF ^(DT)>100
GOTO FUL
SET $PIECE(^LA("ERR"),"^",2)=SY
A SET ERR=ERR+1
IF $DATA(^LA("ERR",ERR))
GOTO A
SET $PIECE(^LA("ERR"),U)=ERR
SET $PIECE(^("ERR"),U,4)=1+$PIECE(^("ERR"),U,4)
SET ^LA("ERR","DT",DT)=1+^LA("ERR","DT",DT)
+1 XECUTE ^%ZOSF("UCI")
SET LABUCI=Y
+2 SET ^LA("ERR",ERR,0)=SY_U_$SELECT($DATA(IO)#2:IO,$DATA(ION):ION,$DATA(IO(0)):IO(0),1:"")_U_$JOB_U_$SELECT($DATA(DUZ):DUZ,1:.5)_U_$SELECT($DATA(LANM):LANM,$DATA(LRINST):LRINST,$DATA(TSK):TSK,$DATA(T):T,1:"???")_U_LABZA_U_LABZB_U_Y
+3 SET ^("ZR")=LABZR
SET ^("ZE")=LABZE
+4 SET $PIECE(^LA("ERR"),U,3)=$PIECE(^LA("ERR",ERR,0),U,5)
+5 SET ^LA("ERR","B",$PIECE(^LA("ERR",ERR,0),U,5),ERR)=""
+6 LOCK
+7 SET X2=3
IF $DATA(^LAB(69.9,1,"ER"))#2
IF +^("ER")>0
SET X2=^("ER")
+8 SET X1=DT
DO C^%DTC
SET ZTDTH=X_".2359"
SET ZTSAVE("*")=""
SET ZTRTN="DQ^LABERR"
SET ZTDESC="CLEAN UP LAB ERROR TRAP"
SET ZTIO=""
LOAD ;
+1 IF $DATA(LABZX)#2
SET X=LABZX
IF $DATA(LABZY)#2
SET Y=LABZY
IF $DATA(LABZD)#2
SET %DT=LABZD
IF $DATA(LABZX1)#2
SET X1=LABZX1
IF $DATA(LABZX2)#2
SET X2=LABZX2
IF $DATA(LABZX3)#2
SET X3=LABZX3
IF $DATA(LABZDT)#2
SET DT=LABZDT
+2 KILL ZTSK
DO ^%ZTLOAD
SET ZTSK=$SELECT($DATA(ZTSK):ZTSK,1:"???")
SET $PIECE(^LA("ERR",ERR,0),U,9)=ZTSK
+3 SET ^LA("ERR",ERR,"ZTSK")=ZTSK
+4 SET ^LA("ERR","C",$PIECE(^(0),U,5),ZTSK)=""
FUL ;
+1 LOCK
KILL ERR,X1,X2,ZTSK,ZTDTH,ZTRTN,ZTDESC,ZTIO,%DT,LABZX,LABUCI,LABZY,LABZA,LABZD,LABZX1,LABZX2,LABZX3,LABZB,LABZDT,LABZE,LABZR,SY
QUIT
+2 QUIT
+3 ;
DQ ;Dequeue errors
+1 IF $DATA(ZTQUEUED)
SET ZTREQ="@"
+2 IF $DATA(ERR)
IF $DATA(^LA("ERR",ERR,0))
SET TSK=$SELECT($LENGTH($PIECE(^(0),U,5)):$PIECE(^(0),U,5),1:0)
SET T=+$PIECE(^(0),".")
KILL ^LA("ERR",ERR),^LA("ERR","B",TSK,ERR)
IF $PIECE(^LA("ERR"),U,4)>0
SET $PIECE(^("ERR"),U,4)=$PIECE(^("ERR"),U,4)-1
+3 IF $DATA(TSK)
IF $DATA(ZTSK)
KILL ^LA("ERR","C",TSK,ZTSK)
+4 IF $DATA(T)
IF $DATA(^LA("ERR","DT",T))#2
IF ^(T)>0
SET ^(T)=^(T)-1
IF ^(T)=0
KILL ^(T)
+5 QUIT