LRUPA1 ; IHS/DIR/FJE - LAB ACCESSION LIST COND'T 3/3/94 10:07 ;
;;5.2;LR;;NOV 01, 1997
;
;;5.2;LAB SERVICE;;Sep 27, 1994
S X=$S($D(^LRO(68,LRAA,1,LRAD,1,N,5,1,0)):^(0),1:""),C(3)=+X S:'C(3) C(3)=LRU S C(2)=$P(X,"^",2) S:'C(2) C(2)=LRU(1) I $D(C(1)),C(1)'=C(2) Q
Q:'$D(^LRO(68,LRAA,1,LRAD,1,N,0)) S X=^(0),LRDFN=+X,A(3)=$P(X,"^",3),A(7)=$P(X,"^",7) Q:'$D(^(3)) S X=^(3),LRI=$P(X,"^",5),A(3)=$S($P(X,"^",3):$P(X,"^",3),1:A(3))
S N(6)=$S($D(^LRO(68,LRAA,1,LRAD,1,N,6)):^(6),1:"") I '$D(^LR(LRDFN,0)) D:$Y>(IOSL-8) H^LRUPA Q:LR("Q") W !,$J(N,7),?11,"Entry not in lab results file" Q
S:LRSS="CY" Q(2)=Q(2)+N(6),Q(1)=Q(1)+$P(N(6),"^",2) D V Q:LR("Q") W:$L(LRC(5)) !,LRC(5),! Q
V D:$Y>(IOSL-8) H^LRUPA Q:LR("Q") W ! I A(3)<LRAD W $E(A(3),4,5),"/",$E(A(3),6,7)
;W ?5,$J(N,5) S (X,Z)=^LR(LRDFN,0),Y=$P(X,"^",3),(LRDPF,X)=$P(X,"^",2),P(0)=$P(^DIC(X,0),"^"),X=^DIC(X,0,"GL")
W ?5,$J(N,5) S (X,Z)=^LR(LRDFN,0),(DFN,Y)=$P(X,"^",3),(LRDPF,X)=$P(X,"^",2),P(0)=$P(^DIC(X,0),"^"),X=^DIC(X,0,"GL") ;IHS/ANMC/CLS 08/18/96
S X=@(X_Y_",0)"),SSN=$P(X,"^",9),LRP=$P(X,"^") D SSN^LRU
;W ?12 W:P(0)'="PATIENT" "#" W $E(LRP,1,15),?28,SSN(1),?34,$E(A(7),1,5) I LRSS="BB" D:$Y>(IOSL-8) H^LRUPA Q:LR("Q") W !?7,SSN," ",$P(Z,"^",5)," ",$P(Z,"^",6)
W ?12 W:P(0)'="VA PATIENT" "#" W $E(LRP,1,14),?27,HRCN,?34,$E(A(7),1,5) I LRSS="BB" D:$Y>(IOSL-8) H^LRUPA Q:LR("Q") W !?7,HRCN," ",$P(Z,"^",5)," ",$P(Z,"^",6) ;IHS/ANMC/CLS 08/18/96
I LRSS="AU" Q:'$D(^LR(LRDFN,"AU")) S X=^("AU") W ?40,$S('$P(X,"^",3):"%",1:"") S Y=+X D:Y D^LRU W ?42,Y Q
I '$D(^LR(LRDFN,LRSS,LRI,0)) W ?40,"Not in lab results file" Q
I "CYEMSP"[LRSS S X=^LR(LRDFN,LRSS,LRI,0),C(6)=$S($P(X,"^",12):"*",1:"") W:'$P(X,"^",3) ?40,"%" I "CYEMSP"[LRSS D O Q:LR("Q") Q:"EMSP"[LRSS
I LRSS="CY" W ?72,$J(+N(6),5) W:$P(N(6),"^",2) "b" W ?79,C(6) Q
I LRSS="BB" S Y=+^LR(LRDFN,LRSS,LRI,0) D DT^LRU W ?40,Y S LRA=Y
E W ?41,$S(C(2)>0&(P(0)="STERILIZER"!(P(0)="ENVIRONMENTAL")):$E($P(^LAB(62,C(2),0),"^"),1,14),$D(^LAB(61,C(3),0)):$E($P(^(0),"^"),1,13),1:"")
W S Z(2)=$S($P(^LR(LRDFN,LRSS,LRI,0),"^",3):"","CHBBMI"[LRSS:"",1:"%"),Z=0 F A=0:1 S Z=$O(^LRO(68,LRAA,1,LRAD,1,N,4,Z)) Q:'Z!(LR("Q")) S Z(3)=^(Z,0) D:+Z(3) L
Q
L Q:LR("Q")!($P($G(^LAB(60,Z,0)),"^",4)="WK")
D:$Y>(IOSL-8) H Q:LR("Q") W:A>0 ! I LRSS="CH",$P(Z(3),"^",2)=1 W ?54,"*"
W:A=0 ?55,Z(2) W ?55 W $S(LRSS="BB"&($P(Z(3),"^",4)=""):"%",1:"") W ?56,$E($P(^LAB(60,Z,0),"^"),1,19),?76 S X=$P(Z(3),"^",4) W $S('X:X,1:$P($G(^VA(200,X,0)),"^",2)) Q
;
O S C(4)=0 F B=0:1 S C(4)=$O(^LR(LRDFN,LRSS,LRI,2,C(4))) Q:'C(4)!(LR("Q")) S C(3)=+^(C(4),0) D:$Y>(IOSL-8) H^LRUPA Q:LR("Q") W:B>0 ! W ?46,$S($D(^LAB(61,C(3),0)):$E($P(^(0),"^"),1,23),1:"")
Q:LR("Q") W:B=0 ?46,"No SNOMED code" Q
;
H D H^LRUPA Q:LR("Q") W ! I A(3)<LRAD W $E(A(3),4,5),"/",$E(A(3),6,7)
;W ?5,$J(N,5),?12 W:P(0)'="PATIENT" "#" W $E(LRP,1,20),?28,SSN(1),?34,$E(A(7),1,5) W:LRSS="BB" ?40,LRA Q
W ?5,$J(N,5),?12 W:P(0)'="VA PATIENT" "#" W $E(LRP,1,14),?27,HRCN,?34,$E(A(7),1,5) W:LRSS="BB" ?40,LRA Q ;IHS/ANMC/CLS 08/18/96
LRUPA1 ; IHS/DIR/FJE - LAB ACCESSION LIST COND'T 3/3/94 10:07 ;
+1 ;;5.2;LR;;NOV 01, 1997
+2 ;
+3 ;;5.2;LAB SERVICE;;Sep 27, 1994
+4 SET X=$SELECT($DATA(^LRO(68,LRAA,1,LRAD,1,N,5,1,0)):^(0),1:"")
SET C(3)=+X
IF 'C(3)
SET C(3)=LRU
SET C(2)=$PIECE(X,"^",2)
IF 'C(2)
SET C(2)=LRU(1)
IF $DATA(C(1))
IF C(1)'=C(2)
QUIT
+5 IF '$DATA(^LRO(68,LRAA,1,LRAD,1,N,0))
QUIT
SET X=^(0)
SET LRDFN=+X
SET A(3)=$PIECE(X,"^",3)
SET A(7)=$PIECE(X,"^",7)
IF '$DATA(^(3))
QUIT
SET X=^(3)
SET LRI=$PIECE(X,"^",5)
SET A(3)=$SELECT($PIECE(X,"^",3):$PIECE(X,"^",3),1:A(3))
+6 SET N(6)=$SELECT($DATA(^LRO(68,LRAA,1,LRAD,1,N,6)):^(6),1:"")
IF '$DATA(^LR(LRDFN,0))
IF $Y>(IOSL-8)
DO H^LRUPA
IF LR("Q")
QUIT
WRITE !,$JUSTIFY(N,7),?11,"Entry not in lab results file"
QUIT
+7 IF LRSS="CY"
SET Q(2)=Q(2)+N(6)
SET Q(1)=Q(1)+$PIECE(N(6),"^",2)
DO V
IF LR("Q")
QUIT
IF $LENGTH(LRC(5))
WRITE !,LRC(5),!
QUIT
V IF $Y>(IOSL-8)
DO H^LRUPA
IF LR("Q")
QUIT
WRITE !
IF A(3)<LRAD
WRITE $EXTRACT(A(3),4,5),"/",$EXTRACT(A(3),6,7)
+1 ;W ?5,$J(N,5) S (X,Z)=^LR(LRDFN,0),Y=$P(X,"^",3),(LRDPF,X)=$P(X,"^",2),P(0)=$P(^DIC(X,0),"^"),X=^DIC(X,0,"GL")
+2 ;IHS/ANMC/CLS 08/18/96
WRITE ?5,$JUSTIFY(N,5)
SET (X,Z)=^LR(LRDFN,0)
SET (DFN,Y)=$PIECE(X,"^",3)
SET (LRDPF,X)=$PIECE(X,"^",2)
SET P(0)=$PIECE(^DIC(X,0),"^")
SET X=^DIC(X,0,"GL")
+3 SET X=@(X_Y_",0)")
SET SSN=$PIECE(X,"^",9)
SET LRP=$PIECE(X,"^")
DO SSN^LRU
+4 ;W ?12 W:P(0)'="PATIENT" "#" W $E(LRP,1,15),?28,SSN(1),?34,$E(A(7),1,5) I LRSS="BB" D:$Y>(IOSL-8) H^LRUPA Q:LR("Q") W !?7,SSN," ",$P(Z,"^",5)," ",$P(Z,"^",6)
+5 ;IHS/ANMC/CLS 08/18/96
WRITE ?12
IF P(0)'="VA PATIENT"
WRITE "#"
WRITE $EXTRACT(LRP,1,14),?27,HRCN,?34,$EXTRACT(A(7),1,5)
IF LRSS="BB"
IF $Y>(IOSL-8)
DO H^LRUPA
IF LR("Q")
QUIT
WRITE !?7,HRCN," ",$PIECE(Z,"^",5)," ",$PIECE(Z,"^",6)
+6 IF LRSS="AU"
IF '$DATA(^LR(LRDFN,"AU"))
QUIT
SET X=^("AU")
WRITE ?40,$SELECT('$PIECE(X,"^",3):"%",1:"")
SET Y=+X
IF Y
DO D^LRU
WRITE ?42,Y
QUIT
+7 IF '$DATA(^LR(LRDFN,LRSS,LRI,0))
WRITE ?40,"Not in lab results file"
QUIT
+8 IF "CYEMSP"[LRSS
SET X=^LR(LRDFN,LRSS,LRI,0)
SET C(6)=$SELECT($PIECE(X,"^",12):"*",1:"")
IF '$PIECE(X,"^",3)
WRITE ?40,"%"
IF "CYEMSP"[LRSS
DO O
IF LR("Q")
QUIT
IF "EMSP"[LRSS
QUIT
+9 IF LRSS="CY"
WRITE ?72,$JUSTIFY(+N(6),5)
IF $PIECE(N(6),"^",2)
WRITE "b"
WRITE ?79,C(6)
QUIT
+10 IF LRSS="BB"
SET Y=+^LR(LRDFN,LRSS,LRI,0)
DO DT^LRU
WRITE ?40,Y
SET LRA=Y
+11 IF '$TEST
WRITE ?41,$SELECT(C(2)>0&(P(0)="STERILIZER"!(P(0)="ENVIRONMENTAL")):$EXTRACT($PIECE(^LAB(62,C(2),0),"^"),1,14),$DATA(^LAB(61,C(3),0)):$EXTRACT($PIECE(^(0),"^"),1,13),1:"")
W SET Z(2)=$SELECT($PIECE(^LR(LRDFN,LRSS,LRI,0),"^",3):"","CHBBMI"[LRSS:"",1:"%")
SET Z=0
FOR A=0:1
SET Z=$ORDER(^LRO(68,LRAA,1,LRAD,1,N,4,Z))
IF 'Z!(LR("Q"))
QUIT
SET Z(3)=^(Z,0)
IF +Z(3)
DO L
+1 QUIT
L IF LR("Q")!($PIECE($GET(^LAB(60,Z,0)),"^",4)="WK")
QUIT
+1 IF $Y>(IOSL-8)
DO H
IF LR("Q")
QUIT
IF A>0
WRITE !
IF LRSS="CH"
IF $PIECE(Z(3),"^",2)=1
WRITE ?54,"*"
+2 IF A=0
WRITE ?55,Z(2)
WRITE ?55
WRITE $SELECT(LRSS="BB"&($PIECE(Z(3),"^",4)=""):"%",1:"")
WRITE ?56,$EXTRACT($PIECE(^LAB(60,Z,0),"^"),1,19),?76
SET X=$PIECE(Z(3),"^",4)
WRITE $SELECT('X:X,1:$PIECE($GET(^VA(200,X,0)),"^",2))
QUIT
+3 ;
O SET C(4)=0
FOR B=0:1
SET C(4)=$ORDER(^LR(LRDFN,LRSS,LRI,2,C(4)))
IF 'C(4)!(LR("Q"))
QUIT
SET C(3)=+^(C(4),0)
IF $Y>(IOSL-8)
DO H^LRUPA
IF LR("Q")
QUIT
IF B>0
WRITE !
WRITE ?46,$SELECT($DATA(^LAB(61,C(3),0)):$EXTRACT($PIECE(^(0),"^"),1,23),1:"")
+1 IF LR("Q")
QUIT
IF B=0
WRITE ?46,"No SNOMED code"
QUIT
+2 ;
H DO H^LRUPA
IF LR("Q")
QUIT
WRITE !
IF A(3)<LRAD
WRITE $EXTRACT(A(3),4,5),"/",$EXTRACT(A(3),6,7)
+1 ;W ?5,$J(N,5),?12 W:P(0)'="PATIENT" "#" W $E(LRP,1,20),?28,SSN(1),?34,$E(A(7),1,5) W:LRSS="BB" ?40,LRA Q
+2 ;IHS/ANMC/CLS 08/18/96
WRITE ?5,$JUSTIFY(N,5),?12
IF P(0)'="VA PATIENT"
WRITE "#"
WRITE $EXTRACT(LRP,1,14),?27,HRCN,?34,$EXTRACT(A(7),1,5)
IF LRSS="BB"
WRITE ?40,LRA
QUIT