LAMIVT6 ;SLC/DLG/DAL/FHS - VITEK MICRO DATA ENCODED NEW FORMAT UNI AMS 06.1;8/16/90 13:37 ;
;;5.2;AUTOMATED LAB INSTRUMENTS;**42**;Sep 27, 1994
;THIS WAS PREVIOUS TO V 5.2 LAMIVTK ****
;THIS ROUTINE CAN ONLY BE USED FOR UNIDIRECTIONAL OPERATIONAL UPLOADING
;CROSS LINK BY ID OR IDE
LA1 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 LROVER=1,X="TRAP^"_LANM,@^%ZOSF("TRAP")
LA2 K Y,ORG,MIC S TOUT=0,A=1 D IN G QUIT:TOUT,LA2:$E(IN,1,3)'="SSS" S Y(1)=IN
;F I=1:1:2 D IN S Y(1)=Y(1)_IN
;S IN=Y(1)
S V=$E(IN,4,9) D NUM S (IDE,ID)=+$E(V,2,6),ISOL=+$E(IN,10)+1,TRAY=$F("ABCD",$E(IN,12))-1,CUP=+$E(IN,13,14),READER=+$E(IN,11) S:READER>1 TRAY=TRAY+4 S:ISOL=0 ISOL=1
S CARD=+$O(^LAB(62.4,TSK,7,"B",$E(IN,15,16),0)),X=$E(IN,19,20) G:CARD'>0 LA2 D HEX S TIME=X/4
S BAD=0 I $D(^LAB(62.4,TSK,7,CARD,"OK")) X ^("OK") G LA2:BAD ;Return BAD=1 if card not OK
S IN=$E(IN,21,255) I $D(^LAB(62.4,TSK,7,CARD,3)) X ^(3) G LA2:BAD G LA2:'$D(ORG)
LA3 X LAGEN G LA2:'ISQN ;Can be changed by the cross-link code
S LRA=$P(^LAH(LWL,1,ISQN,0),U,3,5),LRAA=+LRA,LRAD=+$P(LRA,U,2)
I 'LRAD S LRAD=$$CADT^LA7UTIL(LRAA) ; Calculate default date based on accession transform.
G:'$D(^LRO(68,LRAA,1,LRAD,1,ID,0))#2 LA2
I +$G(^LRO(68,LRAA,1,LRAD,1,ID,5,1,0)) S LRSP=+^(0)
E S LRSP=+$O(^LAB(61,"B","UNKNOWN",0))
S ^LAH(LWL,1,ISQN,3,ISOL,0)=$S($D(^LAH(LWL,1,ISQN,3,ISOL,0))#2:^(0)_"^"_CARD,1:ORG(ISOL)_"^^"_CARD) D LA4
S ^LAH(LWL,1,ISQN,2,1)=Y(1)
S ^LAH(LWL,1,ISQN,2,2)=$S($D(^(2)):^(2)_"^"_CARD,1:"CARD^"_CARD)
I $L($G(RMK)) S JJ="" F II=1:0 S JJ=$O(^LAH(LWL,1,ISQN,3,ISOL,1,JJ)) S:JJ]"" II=JJ I JJ="" S ^LAH(LWL,1,ISQN,3,ISOL,1,II,0)=RMK Q
G LA2
Q
LA4 F J=0:0 S J=$O(MIC(ISOL,J)) Q:J<1 S K=MIC(ISOL,J)_"^" D INTRP S ^LAH(LWL,1,ISQN,3,ISOL,J)=K_S
Q
INTRP S S="" S:LRSP="" LRSP="UNKNOWN" S:LRSP="UNKNOWN" LRSP="ANY" S K1=$P(K,"^",1)
S S2=$P(^LAB(61.2,ORG(ISOL),0),U,3) G:S2="" A1 S S2=$S(S2="N":"GRAM NEG",S2="P":"GRAM POS",1:"")
A1 I $D(^LAB(62.06,"AI",J,K1,ORG(ISOL),LRSP))#2 S S=^(LRSP) G AS
I $D(^LAB(62.06,"AI",J,K1,ORG(ISOL),"ANY"))#2 S S=^("ANY") G AS
G:S2="" A2
I $D(^LAB(62.06,"AI",J,K1,S2,LRSP))#2 S S=^(LRSP) G AS
I $D(^LAB(62.06,"AI",J,K1,S2,"ANY"))#2 S S=^("ANY") G AS
A2 I $D(^LAB(62.06,"AI",J,K1))#2 S S=^(K1)
AS I $D(^LAB(62.06,"AS",J,ORG(ISOL),LRSP))#2 S S=S_"^"_^(LRSP) G AS1
I $D(^LAB(62.06,"AS",J,ORG(ISOL),"ANY"))#2 S S=S_"^"_^("ANY") G AS1
G:S2="" AS2
I $D(^LAB(62.06,"AS",J,S2,LRSP))#2 S S=S_"^"_^(LRSP) G AS1
I $D(^LAB(62.06,"AS",J,S2,"ANY"))#2 S S=S_"^"_^("ANY") G AS1
AS2 I $D(^LAB(62.06,"AS",J))#2 S S=S_"^"_^(J)
AS1 K S2,K1 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 5 G IN
S ^LA(TSK,"I",0)=CNT,IN=^(CNT),TOUT=0
S:IN["~" CTRL=$P(IN,"~",2),IN=$P(IN,"~",1)
Q
HEX S XX=X,X="" F II=1:1:$L(XX) S X=X*16+($F("0123456789ABCDEF",$E(XX,II))-2)
Q
OUT S CNT=^LA(TSK,"O")+1,^("O")=CNT,^("O",CNT)=TSK_OUT
LOCK ^LA("Q") S Q=^LA("Q")+1,^("Q")=Q,^("Q",Q)=TSK LOCK
Q
QUIT I (^LA(TSK,"I")'=^LA(TSK,"I",0)) G LA2
I $D(^LA(TSK,"O",0)),^LA(TSK,"O")'=^LA(TSK,"O",0) G LA2
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
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HLAMIVT6 3315 printed Oct 16, 2024@17:44:10 Page 2
LAMIVT6 ;SLC/DLG/DAL/FHS - VITEK MICRO DATA ENCODED NEW FORMAT UNI AMS 06.1;8/16/90 13:37 ;
+1 ;;5.2;AUTOMATED LAB INSTRUMENTS;**42**;Sep 27, 1994
+2 ;THIS WAS PREVIOUS TO V 5.2 LAMIVTK ****
+3 ;THIS ROUTINE CAN ONLY BE USED FOR UNIDIRECTIONAL OPERATIONAL UPLOADING
+4 ;CROSS LINK BY ID OR IDE
LA1 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 LROVER=1
SET X="TRAP^"_LANM
SET @^%ZOSF("TRAP")
LA2 KILL Y,ORG,MIC
SET TOUT=0
SET A=1
DO IN
if TOUT
GOTO QUIT
if $EXTRACT(IN,1,3)'="SSS"
GOTO LA2
SET Y(1)=IN
+1 ;F I=1:1:2 D IN S Y(1)=Y(1)_IN
+2 ;S IN=Y(1)
+3 SET V=$EXTRACT(IN,4,9)
DO NUM
SET (IDE,ID)=+$EXTRACT(V,2,6)
SET ISOL=+$EXTRACT(IN,10)+1
SET TRAY=$FIND("ABCD",$EXTRACT(IN,12))-1
SET CUP=+$EXTRACT(IN,13,14)
SET READER=+$EXTRACT(IN,11)
if READER>1
SET TRAY=TRAY+4
if ISOL=0
SET ISOL=1
+4 SET CARD=+$ORDER(^LAB(62.4,TSK,7,"B",$EXTRACT(IN,15,16),0))
SET X=$EXTRACT(IN,19,20)
if CARD'>0
GOTO LA2
DO HEX
SET TIME=X/4
+5 ;Return BAD=1 if card not OK
SET BAD=0
IF $DATA(^LAB(62.4,TSK,7,CARD,"OK"))
XECUTE ^("OK")
if BAD
GOTO LA2
+6 SET IN=$EXTRACT(IN,21,255)
IF $DATA(^LAB(62.4,TSK,7,CARD,3))
XECUTE ^(3)
if BAD
GOTO LA2
if '$DATA(ORG)
GOTO LA2
LA3 ;Can be changed by the cross-link code
XECUTE LAGEN
if 'ISQN
GOTO LA2
+1 SET LRA=$PIECE(^LAH(LWL,1,ISQN,0),U,3,5)
SET LRAA=+LRA
SET LRAD=+$PIECE(LRA,U,2)
+2 ; Calculate default date based on accession transform.
IF 'LRAD
SET LRAD=$$CADT^LA7UTIL(LRAA)
+3 if '$DATA(^LRO(68,LRAA,1,LRAD,1,ID,0))#2
GOTO LA2
+4 IF +$GET(^LRO(68,LRAA,1,LRAD,1,ID,5,1,0))
SET LRSP=+^(0)
+5 IF '$TEST
SET LRSP=+$ORDER(^LAB(61,"B","UNKNOWN",0))
+6 SET ^LAH(LWL,1,ISQN,3,ISOL,0)=$SELECT($DATA(^LAH(LWL,1,ISQN,3,ISOL,0))#2:^(0)_"^"_CARD,1:ORG(ISOL)_"^^"_CARD)
DO LA4
+7 SET ^LAH(LWL,1,ISQN,2,1)=Y(1)
+8 SET ^LAH(LWL,1,ISQN,2,2)=$SELECT($DATA(^(2)):^(2)_"^"_CARD,1:"CARD^"_CARD)
+9 IF $LENGTH($GET(RMK))
SET JJ=""
FOR II=1:0
SET JJ=$ORDER(^LAH(LWL,1,ISQN,3,ISOL,1,JJ))
if JJ]""
SET II=JJ
IF JJ=""
SET ^LAH(LWL,1,ISQN,3,ISOL,1,II,0)=RMK
QUIT
+10 GOTO LA2
+11 QUIT
LA4 FOR J=0:0
SET J=$ORDER(MIC(ISOL,J))
if J<1
QUIT
SET K=MIC(ISOL,J)_"^"
DO INTRP
SET ^LAH(LWL,1,ISQN,3,ISOL,J)=K_S
+1 QUIT
INTRP SET S=""
if LRSP=""
SET LRSP="UNKNOWN"
if LRSP="UNKNOWN"
SET LRSP="ANY"
SET K1=$PIECE(K,"^",1)
+1 SET S2=$PIECE(^LAB(61.2,ORG(ISOL),0),U,3)
if S2=""
GOTO A1
SET S2=$SELECT(S2="N":"GRAM NEG",S2="P":"GRAM POS",1:"")
A1 IF $DATA(^LAB(62.06,"AI",J,K1,ORG(ISOL),LRSP))#2
SET S=^(LRSP)
GOTO AS
+1 IF $DATA(^LAB(62.06,"AI",J,K1,ORG(ISOL),"ANY"))#2
SET S=^("ANY")
GOTO AS
+2 if S2=""
GOTO A2
+3 IF $DATA(^LAB(62.06,"AI",J,K1,S2,LRSP))#2
SET S=^(LRSP)
GOTO AS
+4 IF $DATA(^LAB(62.06,"AI",J,K1,S2,"ANY"))#2
SET S=^("ANY")
GOTO AS
A2 IF $DATA(^LAB(62.06,"AI",J,K1))#2
SET S=^(K1)
AS IF $DATA(^LAB(62.06,"AS",J,ORG(ISOL),LRSP))#2
SET S=S_"^"_^(LRSP)
GOTO AS1
+1 IF $DATA(^LAB(62.06,"AS",J,ORG(ISOL),"ANY"))#2
SET S=S_"^"_^("ANY")
GOTO AS1
+2 if S2=""
GOTO AS2
+3 IF $DATA(^LAB(62.06,"AS",J,S2,LRSP))#2
SET S=S_"^"_^(LRSP)
GOTO AS1
+4 IF $DATA(^LAB(62.06,"AS",J,S2,"ANY"))#2
SET S=S_"^"_^("ANY")
GOTO AS1
AS2 IF $DATA(^LAB(62.06,"AS",J))#2
SET S=S_"^"_^(J)
AS1 KILL S2,K1
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 5
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
HEX SET XX=X
SET X=""
FOR II=1:1:$LENGTH(XX)
SET X=X*16+($FIND("0123456789ABCDEF",$EXTRACT(XX,II))-2)
+1 QUIT
OUT SET CNT=^LA(TSK,"O")+1
SET ^("O")=CNT
SET ^("O",CNT)=TSK_OUT
+1 LOCK ^LA("Q")
SET Q=^LA("Q")+1
SET ^("Q")=Q
SET ^("Q",Q)=TSK
LOCK
+2 QUIT
QUIT IF (^LA(TSK,"I")'=^LA(TSK,"I",0))
GOTO LA2
+1 IF $DATA(^LA(TSK,"O",0))
IF ^LA(TSK,"O")'=^LA(TSK,"O",0)
GOTO LA2
+2 LOCK ^LA(TSK)
HANG 1
KILL ^LA(TSK),^LA("LOCK",TSK),^TMP($JOB),TMP("LA",$JOB)
+3 QUIT
TRAP ;ERROR TRAP
DO ^LABERR
SET T=TSK
DO SET^LAB
GOTO @("LA2^"_LANM)