LAMLA1KC ;SLC/DLG/FHS - ELECTRA 900/900C/1000C ;03/25/93 15:41 ;
;;5.2;AUTOMATED LAB INSTRUMENTS;;Sep 27, 1994
;CROSS LINK BY CUP, ENTER ACCESSION NUMBER INTO PATIENT ID FIELD
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")
LA2 K Y,TEST,TV S TOUT=0 D IN G QUIT:TOUT,LA2:$E(IN,1)'="R" S BAD=0 D QC G LA2:BAD
F I=0:0 S I=$O(TC(I)) Q:I<1 I $D(TC(I,4)),TC(I,4)=TEST S V=Y(TEST) D NUM S @TC(I,1)=V
F I=0:0 S I=$O(TC(I)) Q:I<1 I $D(TC(I,2)),TC(I,2)'="" X TC(I,2) S:V>0 @TC(I,1)=V
S (CUP,ID,IDE)=+$P(IN,"|",3),TRAY=1
LA3 X LAGEN G LA2:'ISQN
F I=0:0 S I=$O(TV(I)) Q:I<1 S:TV(I,1)]"" ^LAH(LWL,1,ISQN,I)=TV(I,1)
G LA2
QC ;QC TESTING HERE; S BAD=1 IF DONT STORE
;CR=curve results, all tests other than PT,PTT,INR found here
S TEST=+$P(IN,"|",4),ST=$P(IN,"|",5),CR=$P(IN,"|",12),Y(TEST)=$S(CR>0:$P(IN,"|",14),ST<3:$P(IN,"|",7),1:$P(IN,"|",11)),Y(2)=+$P(IN,"|",17) I ST<3,($P(IN,"|",6)=0!($P(IN,"|",6)>1)) S BAD=1 Q
I ST>2,($P(IN,"|",8)=0)!($P(IN,"|",8)>1) S BAD=1 Q
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 10 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) D
.K ^TMP("LA",$J),BAD,CNT,CR,CTRL,CUP,I,ID,IDE,IN,ISQN,JJ,LAGEN
.K LANM,LATOP,LWL,ST,T,TC,TEST,TOUT,TRAY,TSK,TV,V
Q
TRAP D ^LABERR S T=TSK D SET^LAB G @("LA2^"_LANM) ;ERROR TRAP
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HLAMLA1KC 1580 printed Dec 13, 2024@01:43:39 Page 2
LAMLA1KC ;SLC/DLG/FHS - ELECTRA 900/900C/1000C ;03/25/93 15:41 ;
+1 ;;5.2;AUTOMATED LAB INSTRUMENTS;;Sep 27, 1994
+2 ;CROSS LINK BY CUP, ENTER ACCESSION NUMBER INTO PATIENT ID FIELD
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")
LA2 KILL Y,TEST,TV
SET TOUT=0
DO IN
if TOUT
GOTO QUIT
if $EXTRACT(IN,1)'="R"
GOTO LA2
SET BAD=0
DO QC
if BAD
GOTO LA2
+1 FOR I=0:0
SET I=$ORDER(TC(I))
if I<1
QUIT
IF $DATA(TC(I,4))
IF TC(I,4)=TEST
SET V=Y(TEST)
DO NUM
SET @TC(I,1)=V
+2 FOR I=0:0
SET I=$ORDER(TC(I))
if I<1
QUIT
IF $DATA(TC(I,2))
IF TC(I,2)'=""
XECUTE TC(I,2)
if V>0
SET @TC(I,1)=V
+3 SET (CUP,ID,IDE)=+$PIECE(IN,"|",3)
SET TRAY=1
LA3 XECUTE LAGEN
if 'ISQN
GOTO LA2
+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 GOTO LA2
QC ;QC TESTING HERE; S BAD=1 IF DONT STORE
+1 ;CR=curve results, all tests other than PT,PTT,INR found here
+2 SET TEST=+$PIECE(IN,"|",4)
SET ST=$PIECE(IN,"|",5)
SET CR=$PIECE(IN,"|",12)
SET Y(TEST)=$SELECT(CR>0:$PIECE(IN,"|",14),ST<3:$PIECE(IN,"|",7),1:$PIECE(IN,"|",11))
SET Y(2)=+$PIECE(IN,"|",17)
IF ST<3
IF ($PIECE(IN,"|",6)=0!($PIECE(IN,"|",6)>1))
SET BAD=1
QUIT
+3 IF ST>2
IF ($PIECE(IN,"|",8)=0)!($PIECE(IN,"|",8)>1)
SET BAD=1
QUIT
+4 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 10
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)
Begin DoDot:1
+1 KILL ^TMP("LA",$JOB),BAD,CNT,CR,CTRL,CUP,I,ID,IDE,IN,ISQN,JJ,LAGEN
+2 KILL LANM,LATOP,LWL,ST,T,TC,TEST,TOUT,TRAY,TSK,TV,V
End DoDot:1
+3 QUIT
TRAP ;ERROR TRAP
DO ^LABERR
SET T=TSK
DO SET^LAB
GOTO @("LA2^"_LANM)