LACOAGX2 ; IHS/DIR/FJE - ROUTINE FOR COAGAMATE X2 7/20/90 07:51 ;
;;5.2;LA;;NOV 01, 1997
;;5.2;AUTOMATED LAB INSTRUMENTS;;Sep 27, 1994
;RUN BY TRAY CUP
LA1 S:$D(ZTQUEUED) ZTREQ="@" S LANM=$T(+0),TSK=$O(^LAB(62.4,"C",LANM,0)) Q:TSK<1
Q:'$D(^LA(TSK,"I",0))
K LATOP D ^LASET Q:'TSK S X="TRAP^"_LANM,@^%ZOSF("TRAP"),SKIP=0 I $P(^LRO(68.2,LWL,0),U,2),$P(^LAB(62.07,$P(^LRO(68.2,LWL,0),U,2),0),U)="SKIP" S SKIP=1
LA2 K TV S TOUT=0 D IN G QUIT:TOUT,LA2:$E(IN,1,5)'="DATE:" F A=1:1:2 S TOUT=0 D IN G QUIT:TOUT
G LA2:IN'["END TEST" S LASTCUP=$E(IN,26,27) S TOUT=0 D IN G QUIT:TOUT
F A=0:0 D LA2A Q:CUP=LASTCUP S TOUT=0 D IN G QUIT:TOUT
G LA2
LA2A S TOUT=0 D IN G QUIT:TOUT S (ID,IDE,CUP)=+$E(IN,3,4),V=$E(IN,6,8) D NUM S TEST(1)=V,V(1)=+$E(IN,10,14),V=$E(IN,20,22) D NUM S TEST(2)=V,V(2)=+$E(IN,24,28)
I SKIP,CUP#2 S V(11)=V(1),V(22)=V(2) S TOUT=0 D IN G QUIT:TOUT G LA2A
I SKIP,'(CUP#2) S V(111)=V(1)-V(11),V(1)=V(1)+V(11)/2,V(1)=$J(V(1),0,1),V(222)=V(2)-V(22),V(2)=V(2)+V(22)/2,V(2)=$J(V(2),0,1) S:V(111)<0 V(111)=-V(111) S:V(222)<0 V(222)=-V(222)
F I=0:0 S I=$O(TC(I)) Q:I<1 F II=1:1:2 I TC(I,4)=TEST(II) S:'SKIP!('$L(TC(I,3))) @TC(I,1)=V(II) I SKIP,$L(TC(I,3)) S LIMIT=TC(I,3)/100,DELTA=$S(II=1:V(111),1:V(222)),@TC(I,1)=$S(V(II)=0:0,DELTA/V(II)>LIMIT:"",1:V(II))
LA3 S:SKIP CUP=CUP-1 X LAGEN Q:'ISQN ;Can be changed by the cross-link code
S:SKIP CUP=CUP+1 F I=0:0 S I=$O(TV(I)) Q:I<1 S:TV(I,1)]"" ^LAH(LWL,1,ISQN,I)=TV(I,1)
Q
NUM S X="" F JJ=1:1:$L(V) S:$A(V,JJ)>32 X=X_$E(V,JJ)
S V=X Q
IN S CNT=^LA(TSK,"I",0)+1 IF '$D(^(CNT)) S TOUT=TOUT+1 Q:TOUT>9 H 20 G IN
S ^LA(TSK,"I",0)=CNT,IN=^(CNT),TOUT=0
S:IN["~" CTRL=$P(IN,"~",2),IN=$P(IN,"~",1)
Q
QUIT LOCK ^LA(TSK) H 1 K ^LA(TSK),^LA("LOCK",TSK),^TMP($J),^TMP("LA",$J)
Q
TRAP D ^LABERR S T=TSK D SET^LAB G @("LA2^"_LANM) ;ERROR TRAP
LACOAGX2 ; IHS/DIR/FJE - ROUTINE FOR COAGAMATE X2 7/20/90 07:51 ;
+1 ;;5.2;LA;;NOV 01, 1997
+2 ;;5.2;AUTOMATED LAB INSTRUMENTS;;Sep 27, 1994
+3 ;RUN BY TRAY CUP
LA1 IF $DATA(ZTQUEUED)
SET ZTREQ="@"
SET LANM=$TEXT(+0)
SET TSK=$ORDER(^LAB(62.4,"C",LANM,0))
IF TSK<1
QUIT
+1 IF '$DATA(^LA(TSK,"I",0))
QUIT
+2 KILL LATOP
DO ^LASET
IF 'TSK
QUIT
SET X="TRAP^"_LANM
SET @^%ZOSF("TRAP")
SET SKIP=0
IF $PIECE(^LRO(68.2,LWL,0),U,2)
IF $PIECE(^LAB(62.07,$PIECE(^LRO(68.2,LWL,0),U,2),0),U)="SKIP"
SET SKIP=1
LA2 KILL TV
SET TOUT=0
DO IN
IF TOUT
GOTO QUIT
IF $EXTRACT(IN,1,5)'="DATE:"
GOTO LA2
FOR A=1:1:2
SET TOUT=0
DO IN
IF TOUT
GOTO QUIT
+1 IF IN'["END TEST"
GOTO LA2
SET LASTCUP=$EXTRACT(IN,26,27)
SET TOUT=0
DO IN
IF TOUT
GOTO QUIT
+2 FOR A=0:0
DO LA2A
IF CUP=LASTCUP
QUIT
SET TOUT=0
DO IN
IF TOUT
GOTO QUIT
+3 GOTO LA2
LA2A SET TOUT=0
DO IN
IF TOUT
GOTO QUIT
SET (ID,IDE,CUP)=+$EXTRACT(IN,3,4)
SET V=$EXTRACT(IN,6,8)
DO NUM
SET TEST(1)=V
SET V(1)=+$EXTRACT(IN,10,14)
SET V=$EXTRACT(IN,20,22)
DO NUM
SET TEST(2)=V
SET V(2)=+$EXTRACT(IN,24,28)
+1 IF SKIP
IF CUP#2
SET V(11)=V(1)
SET V(22)=V(2)
SET TOUT=0
DO IN
IF TOUT
GOTO QUIT
GOTO LA2A
+2 IF SKIP
IF '(CUP#2)
SET V(111)=V(1)-V(11)
SET V(1)=V(1)+V(11)/2
SET V(1)=$JUSTIFY(V(1),0,1)
SET V(222)=V(2)-V(22)
SET V(2)=V(2)+V(22)/2
SET V(2)=$JUSTIFY(V(2),0,1)
IF V(111)<0
SET V(111)=-V(111)
IF V(222)<0
SET V(222)=-V(222)
+3 FOR I=0:0
SET I=$ORDER(TC(I))
IF I<1
QUIT
FOR II=1:1:2
IF TC(I,4)=TEST(II)
IF 'SKIP!('$LENGTH(TC(I,3)))
SET @TC(I,1)=V(II)
IF SKIP
IF $LENGTH(TC(I,3))
SET LIMIT=TC(I,3)/100
SET DELTA=$SELECT(II=1:V(111),1:V(222))
SET @TC(I,1)=$SELECT(V(II)=0:0,DELTA/V(II)>LIMIT:"",1:V(II))
LA3 ;Can be changed by the cross-link code
IF SKIP
SET CUP=CUP-1
XECUTE LAGEN
IF 'ISQN
QUIT
+1 IF SKIP
SET CUP=CUP+1
FOR I=0:0
SET I=$ORDER(TV(I))
IF I<1
QUIT
IF TV(I,1)]""
SET ^LAH(LWL,1,ISQN,I)=TV(I,1)
+2 QUIT
NUM SET X=""
FOR JJ=1:1:$LENGTH(V)
IF $ASCII(V,JJ)>32
SET X=X_$EXTRACT(V,JJ)
+1 SET V=X
QUIT
IN SET CNT=^LA(TSK,"I",0)+1
IF '$DATA(^(CNT))
SET TOUT=TOUT+1
IF TOUT>9
QUIT
HANG 20
GOTO IN
+1 SET ^LA(TSK,"I",0)=CNT
SET IN=^(CNT)
SET TOUT=0
+2 IF IN["~"
SET CTRL=$PIECE(IN,"~",2)
SET IN=$PIECE(IN,"~",1)
+3 QUIT
QUIT LOCK ^LA(TSK)
HANG 1
KILL ^LA(TSK),^LA("LOCK",TSK),^TMP($JOB),^TMP("LA",$JOB)
+1 QUIT
TRAP ;ERROR TRAP
DO ^LABERR
SET T=TSK
DO SET^LAB
GOTO @("LA2^"_LANM)