VistA-WorldVistAEHR/r/LAB_SERVICE-LR-LS/LROR.m

79 lines
4.9 KiB
Mathematica

LROR ;SLC/CJS - LAB MODULE FOR OR ;3/29/90 16:39 ;
;;5.2;LAB SERVICE;**5,18,100,121**;Sep 27, 1994
I $D(ORACTION),ORACTION G EN^LROR6:ORACTION=1,EN^LROR7:ORACTION=2,EN^LROR8:ORACTION=3,EN1^LROR8:ORACTION=4,C^LROR3:ORACTION=6,P^LROR3:ORACTION=7,STAT^LROR1:ORACTION=8,EN2^LROR8:ORGY=10 Q
G EN^LROR5
V ;;from LRVER3A
S LRY=Y,ORIFN="" I '$D(LRNOW),$D(LX1) Q:LX1<1 S %DT="T",X="N" D ^%DT S LRNOWM=+Y
N DA,DH,DIER,DU,DV,I1,LRIFN
I $D(^LRO(69,LRODT,1,LRSN,2,"B",I)) S A=$O(^(I,0)) Q:'A I $D(^LRO(69,LRODT,1,LRSN,2,A,0)) S X=^(0) I $P(X,"^",4)=LRAA,$P(X,"^",5)=LRAN S LRTNUM=$P(X,"^",1) S LRIFN=$P(X,"^",7) I LRIFN D
. I $L($P(X,"^",14)) S X=$P(X,"^",14) I $P($G(^LRO(69,+X,1,+$P(X,";",2),2,+$P(X,";",3),0)),"^",7) S ORIFN=$P(^(0),"^",7),ORSTS=2 D ST^ORX
. N I I $D(LRNOW)!$D(LRNOWM) S ORETURN("ORSTOP")=$S($D(LRNOW):LRNOW,1:LRNOWM)
. S ORIFN=LRIFN,ORETURN("ORSTS")=2 D RETURN^ORX S ORIFN=LRIFN
S Y=LRY K LRY,LRNOWM,A,B,C Q
SET ;from LROW2,LRWLST
N X,ORPK,ORL,ORNP,ORVP,ORPCL,ORPURG,ORSTRT,ORSTS,ORTX,ORIT,LRURG,Y
S:'$D(DFN) DFN=$S($D(^LR(LRDFN,0)):$P(^(0),U,3),1:"") S:'$D(LRDPF) LRDPF=$S($D(^LR(LRDFN,0)):$P(^(0),U,2),1:"")
Q:+LRDPF'=2&(+LRDPF'=65.5)&(+LRDPF'=67)
I '$D(ORNATR) S ORNATR=$S($D(LRNATURE):LRNATURE,1:"") I '$D(LRNATURE) D:$P($G(^ORD(100.99,1,2)),"^",2) OT^LROR6 S LRNATURE=ORNATR
S ORPK=LRODT_"^"_LRSN_"^"_LRTN,ORIT=+LRTEST(LRI)_";LAB(60,",LRURG=$P(LRTEST(LRI),"^",2),X=$G(^LRO(69,+LRODT,1,+LRSN,0)),X1=$G(^(1))
I ORNATR="C" S:$P(X,"^",2) OREPDUZ=$P(X,"^",2) S:$P(X,"^",5) ORLOG=$P(X,"^",5) S ORNATR=""
S:'$L(LRLLOC)!(LRLLOC["^") LRLLOC="UNKNOWN" S ORL=$S(LROLLOC:LROLLOC_";SC(",1:""),ORNP=$S($G(LRPRAC):LRPRAC,1:$P(X,"^",6)),ORVP=DFN_";"_$P(^DIC(+LRDPF,0,"GL"),"^",2)
SET1 S:'$D(ORPCL) ORPCL=$P(^LAB(69.9,1,1),U,6)_";ORD(101,"
S ORPURG=$P(LRPARAM,"^",9),ORSTRT=$S($P(X,"^",8):$P(X,"^",8),$P(X,"^",5):$P(X,"^",5),1:LRODT),ORSTS=$S(X1:6,1:5) D NOW^%DTC S NOW=%,LRODTSV=LRODT,LRSNSV=LRSN,LRTNSV=LRTN
D SET2(+LRTEST(LRI),LRSAMP,LRSPEC,LRURG,$G(LRLWC),LRORD)
D FILE^ORX S LRORIFN=$S($D(ORIFN):ORIFN,1:""),LRODT=LRODTSV,LRSN=LRSNSV,LRTN=LRTNSV
Q
SET2(TST,SAMP,SPEC,URG,TYPE,ORD) ;
S X=$S($D(SAMP):$S($D(^LAB(62,+SAMP,0)):$P(^(0),"^"),1:""),1:""),Y=$S($D(SPEC):$S($D(^LAB(61,+SPEC,0)):$P(^(0),"^"),1:""),1:"")
S ORTX(1)=$P(^LAB(60,TST,0),"^")_$S(Y'[X!(X=Y):" "_X,1:"")_$S(X'[Y:" "_Y,1:"")
I $G(ORD)!($D(TYPE))!($D(URG)) S ORTX(1)=ORTX(1)_$S($G(ORD):" LB #"_ORD,1:"")_" "_$S($D(TYPE):TYPE,1:"")_$S(URG=9!('URG):"",1:" "_$P(^LAB(62.05,URG,0),"^"))
Q
FLAG ;
Q:$G(LRORFLG)
S LRORFLG=1
NOTIF1 ;
K XQAKILL S ORVP=$P(XQA1,",",2)_";DPT(",ORRACT("D")="Results Display",ORPRES="10^NOTIFICATIONS",DFN=$P(ORVP,";",1)
S NOTE=$P(XQA1,",",3) S ORNSCRN="I ORNOTE=" S ORNSCRN=$S(NOTE=24:ORNSCRN_24,NOTE=3:ORNSCRN_3,NOTE=14:ORNSCRN_14,NOTE=50:ORNSCRN_50,1:"")
D REVN^ORF4
K ORVP,ORPRES,DFN,ORNSCRN Q
EN(AREA,DATE,ACC) ;
;AREA=Accession area
;ACC=#
Q:'$D(^LRO(68,+$G(AREA),1,+$G(DATE),1,+$G(ACC)))
N MSG,TST,LRN,TST1,II,ORBPMSG,ORNOTE,ORVP,LRNOTI,ORIFN,X,ORBATCH,FLAG
S TST=0
F S TST=$O(^LRO(68,AREA,1,DATE,1,ACC,4,TST)) Q:TST<1 D
. S LRN=$P($G(^LAB(60,TST,0)),"^",5)
. I $L(LRN) D CHK(LRN,TST)
. I $O(^LAB(60,TST,2,0)) S II=0 F S II=$O(^LAB(60,TST,2,II)) Q:II<1 S TST1=^(II,0) S LRN=$P($G(^LAB(60,TST1,0)),"^",5) I $L(LRN) D
.. D CHK(LRN,TST1)
. I $O(LRNOTI(0)),'$D(LRNOTI(TST)) S LRNOTI(TST)=""
I $O(FLAG(0)) D MSG S ORBPMSG=MSG,ORNOTE(50)=1,ORVP=$S(LRDPF=2:DFN,1:"") Q:'ORVP S ORVP=ORVP_";DPT(",II=0 D
. F S II=$O(LRNOTI(II)) Q:II<1 D
.. Q:'$D(^LRO(69,LRODT,1,LRSN,2,"B",II)) S A=$O(^(II,0)) Q:'A
.. I $D(^LRO(69,LRODT,1,LRSN,2,A,0)) S X=^(0) I $P(X,"^",4)=AREA,$P(X,"^",5)=ACC S TST=$P(X,"^"),ORIFN=$P(X,"^",7) I ORIFN S ORBATCH(ORIFN)="",ORBXDATA=LRODT_"^"_LRSN_"^"_A_"^"_ORIFN
. I $O(ORBATCH(0)) D NOTE^ORX3
Q
CHK(TEST,TST) ;
;TEST=Data Name
N LRNOTE Q:'$L(TEST) S TEST=$P(TEST,";",2) Q:'TEST Q:'$D(LRSB(TEST))
S A=$S($D(LRSA(TEST)):$S("<>"[$E(LRSA(TEST)):$E(LRSA(TEST),2,99),1:LRSA(TEST)),1:""),B=$S("<>"[$E(LRSB(TEST)):$E(LRSB(TEST),2,99),1:LRSB(TEST))
I +A'=+B D
. I $P(B,"^",2)["*" S FLAG(24,TST)="",LRNOTI(TST)="",ORFLAG(24)=""
. I '$D(LRNOTE),$D(^ORD(100.9,14,3)),$P(^(3),"^")'="D",$L($P(B,"^",2)) S:'$D(FLAG(24,TST)) FLAG(14,TST)="" S LRNOTI(TST)="",ORFLAG(14)=""
. I '$D(LRNOTE),$D(^ORD(100.9,3,3)),$P(^(3),"^")'="D" S:'$D(FLAG(24,TST))&'$D(FLAG(14,TST)) FLAG(3,TST)="" S LRNOTI(TST)="",ORFLAG(3)=""
Q
MSG ;
N I,TS,STOP
S MSG="LAB",STOP=0
I $D(FLAG(24)) S MSG=MSG_" Critical ",TS=0 F S TS=$O(FLAG(24,TS)) Q:'TS S MSG=MSG_$$NAME(TS)_":" I $L(MSG)>40 S:$O(FLAG(24,TS)) STOP=1 Q
I STOP!($L(MSG)>33&($D(FLAG(14))!$D(FLAG(3)))) S MSG=MSG_"..." Q
I $D(FLAG(14)) S MSG=MSG_" Abnormal ",TS=0 F S TS=$O(FLAG(14,TS)) Q:'TS S MSG=MSG_$$NAME(TS)_":" I $L(MSG)>40 S:$O(FLAG(14,TS)) STOP=1 Q
I STOP!($L(MSG)>37&$D(FLAG(3))) S MSG=MSG_"..." Q
I $D(FLAG(3)) S MSG=MSG_" New ",TS=0 F S TS=$O(FLAG(3,TS)) Q:'TS S MSG=MSG_$$NAME(TS)_":" I $L(MSG)>40 S:$O(FLAG(3,TS)) STOP=1 Q
I STOP S MSG=MSG_"..." Q
Q
NAME(TEST) ;
S NAME=$S($L($G(^LAB(60,TEST,.1))):$P(^(.1),"^"),1:$E($P(^(0),"^"),1,7))
Q NAME