BLRRLTAR ; IHS/MSC/MKK - Reference Lab Test "Add" Routine ; 22-Oct-2013 09:22 ; MKK
;;5.2;IHS LABORATORY;**1033**;NOV 1, 1997
;
; Code cloned from ADDTST^LRCE
;
; This routine will add a test to a given Accession when the incoming HL7 message from a Reference Lab
; has the OBX "ADDTEST" flag set. No output.
;
; All IHS Ref Lab tests are "CH" subscripted tests (for now).
;
; NOTE: There will be no check on the LRLABKY variable.
; It is assumed that the process running this routine MUST be able to add tests to an accession.
;
; LA76249 is the Message # from file 62.49
; BLRRLTST is the unique identifier of the test to be added (the IEN)
; BLRRLUID is the UID passed to this routine by the calling routine
;
EEP ; Ersatz EP
D EEP^BLRGMENU
Q
;
PEP ; EP
EP ; EP
ADDTST(LA76249,BLRRLTST,BLRRLUID) ; EP
NEW (BLRRLTST,BLRRLUID,DILOCKTM,DISYS,DT,DTIME,DUZ,IO,IOBS,IOF,IOM,ION,IOS,IOSL,IOST,IOT,LA76249,LRDFN,LRODT,LRSN,IOXY,U,XPARSYS,XQXFLG)
;
S X=$Q(^LRO(68,"C",BLRRLUID)),LRAA=+$QS(X,4),LRAD=+$QS(X,5),LRAN=+$QS(X,6)
S ORDERNUM=+$G(^LRO(68,LRAA,1,LRAD,1,LRAN,.1))
S LRODT=+$O(^LRO(69,"C",ORDERNUM,0)),LRSN=+$O(^LRO(69,"C",ORDERNUM,LRODT,0))
;
D ^LRPARAM ; Reset LRPARAM string
;
S LRTS=BLRRLTST
S LRURG=$$FIND1^DIC(62.05,,,"ROUTINE"),LRFLG=""
D LRTSTSET
Q
;
LRTSTSET ; EP - Code cloned from LRTSTSET
I '($D(^LRO(68,LRAA,1,LRAD,1,LRAN,0))#2) W !?10,"Sorry This accession "_LRAN_" No longer exist",!?10," Accession may have been deleted.",!,$C(7) G ADDTST^LRTSTJAM
S ^LRO(68,LRAA,1,LRAD,1,LRAN,4,LRTS,0)=LRTS_"^"_LRURG,$P(^(0),U,9)=$G(LRTSP),^LRO(68,LRAA,1,LRAD,1,LRAN,4,"B",LRTS,LRTS)="",$P(^LRO(68,LRAA,1,LRAD,1,LRAN,3),U,4)=""
S $P(^LRO(68,LRAA,1,LRAD,1,LRAN,4,0),U,3)=LRTS,$P(^(0),U,4)=$P(^(0),U,4)+1 I $P(LRPARAM,U,14),$P(^LRO(68,LRAA,0),U,16) D CAP^LRWLST12
S LRACD=$P(^LRO(68,LRAA,1,LRAD,1,LRAN,0),"^",3),LRTSAD(1,LRTS)=""
D EN^LA7ADL($P($G(^LRO(68,LRAA,1,LRAD,1,LRAN,.3),0),"^")) ;Check for automatic downloading
I LRACD,LRACD'=LRAD S ^LRO(68,LRAA,1,LRACD,1,LRAN,4,LRTS,0)=LRTS_"^"_LRURG,$P(^(0),U,9)=+LRTS D
.S ^LRO(68,LRAA,1,LRACD,1,LRAN,4,"B",LRTS,LRTS)="",$P(^LRO(68,LRAA,1,LRAD,1,LRAN,3),"^",4)="" I $P(LRPARAM,U,14),$P(^LRO(68,LRAA,0),U,16) D CAP^LRWLST12
F L +^LRO(69,LRODT,1,LRSN):1 Q:$T W !?7,"Someone else is editing this order",!,$C(7) H 20
K LRXDA,DA,DIC,DIE,DR
S DIC="^LRO(69,"_LRODT_",1,"_LRSN_",2,",DA(2)=LRODT,DA(1)=LRSN
S DIC(0)="LOX",DLAYGO=69,X=$P(^LAB(60,LRTS,0),"^") D ^DIC
69 ; EP
I Y>0 D
. S LRXDA(3)=$G(^LRO(68,LRAA,1,LRAD,1,LRAN,.3))
. S (LRXDA,DA)=+Y,DIE=DIC,DR="1///^S X=LRURG;2///^S X=LRAD;3///^S X=LRAA;4///^S X=LRAN;8///^S X=""IP"";9///^S X=""L"""
. I $L($P(LRXDA(3),U)) D
. . S DR=DR_";13///^S X=$P(LRXDA(3),U)"
. . S:$P(LRXDA(3),U,2) DR=DR_";14////^S X=$P(LRXDA(3),U,2);15////^S X=$P(LRXDA(3),U,3);16///^S X=$P(LRXDA(3),U,4);17///^S X=$P(LRXDA(3),U,5)"
. D ^DIE
. D:$G(LRTSP)
. . S LRBETN=$O(^LRO(69,LRODT,1,LRSN,2,"B",LRTSP,""))
. . I LRBETN D DADD^LRBEBA31(LRODT,LRSN,LRBETN,LRXDA,LRTS,$G(LRBERF))
. K LRBETN,LRBERF
I $G(LRXDA) D
. N X,Y
. S Y=$P($$FMTE^XLFDT($$NOW^XLFDT,"5Z"),":",1,2)
. S X=1+$S($D(^LRO(69,LRODT,1,LRSN,2,LRXDA,1,0)):$P(^(0),"^",3),1:0),^(0)="^^"_X_"^"_DT,^(X,0)=" Added by "_$G(DUZ)_" on "_Y
. S ^LRO(69,"AA",+$G(^LRO(69,LRODT,1,LRSN,.1)),LRODT_"|"_LRSN)=""
. ;
. ;
I '$D(LRFLG) K DLAYGO,DA,DIC,DIE,DR,LRXDA L -^LRO(69,LRODT,1,LRSN) Q
SETOR ;
I $G(LRXDA),$$VER^LR7OU1<3 D ;OE/RR 2.5
. 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 X=^LRO(69,LRODT,1,LRSN,0),LRLB=$P(^(.1),"^"),X1=$S($D(^(1)):^(1),1:$P(X,"^",8)),ORVP=$P(^LR(+X,0),"^",3)_";"_$P(^DIC($P(^LR(+X,0),"^",2),0,"GL"),"^",2)
. I ORNATR="C" S OREPDUZ=$P(X,"^",2),ORLOG=$P(X,"^",5),ORNATR=""
. S LRORSAMP=$P(X,"^",3),LRORTYPE=$P(X,"^",4),ORNP=$P(X,"^",6),ORL=$S($L($P(X,"^",7)):$P(X,"^",7),1:"UNKNOWN")
. S ORL=$S($O(^SC("C",ORL,0))'="":$O(^(0))_";SC(",1:""),ORSTRT=$P(X1,"^"),X=^LRO(69,LRODT,1,LRSN,2,LRXDA,0),ORIT=+X_";LAB(60,",LRORSPEC=$O(^LRO(69,LRODT,1,LRSN,4,0)),LRORSPEC=$S(LRORSPEC>0:$P(^(LRORSPEC,0),"^"),1:"")
. S X=$S($D(LRORSAMP):$S($D(^LAB(62,+LRORSAMP,0)):$P(^(0),"^"),1:""),1:""),Y=$S($D(LRORSPEC):$S($D(^LAB(61,+LRORSPEC,0)):$P(^(0),"^"),1:""),1:"")
. S ORTX(1)=$P(^LAB(60,+LRTS,0),"^")_$S(Y'[X!(X=Y):" "_X,1:"")_$S(X'[Y:" "_Y,1:"")
. S ORTX(1)=ORTX(1)_" LB #"_LRLB_" "_$S($D(LRORTYPE):LRORTYPE,1:"")_$S(LRURG=9!('LRURG):"",1:" "_$P(^LAB(62.05,LRURG,0),"^"))
. S ORPCL=$P(^LAB(69.9,1,1),"^",6),ORSTS=6,ORTO=$P(^LAB(60,+ORIT,0),"^",6) S:$P(^LAB(69.9,1,0),"^",9) ORPURG=$P(^(0),"^",9)
. S ORPCL=$P(^LAB(69.9,1,1),"^",6)_";ORD(101,",ORPK=LRODT_"^"_LRSN_"^"_DA,DA=LRXDA
. D FILE^ORX
. S:$D(ORIFN) $P(^LRO(69,LRODT,1,LRSN,2,LRXDA,0),"^",7)=ORIFN
. K LRLB,LRXDA,LRFLG,LRORSPEC,LRORSAMP,LRORTYPE
N LTS S LTS(LRTS)=""
D NEW^LR7OB1(LRODT,LRSN,"SN",$G(LRNATURE),.LTS,6)
K DLAYGO,DA,DIC,DIE,DR,LRBERF,LRBEFN,LRBEX L -^LRO(69,LRODT,1,LRSN)
Q
BLRRLTAR ; IHS/MSC/MKK - Reference Lab Test "Add" Routine ; 22-Oct-2013 09:22 ; MKK
+1 ;;5.2;IHS LABORATORY;**1033**;NOV 1, 1997
+2 ;
+3 ; Code cloned from ADDTST^LRCE
+4 ;
+5 ; This routine will add a test to a given Accession when the incoming HL7 message from a Reference Lab
+6 ; has the OBX "ADDTEST" flag set. No output.
+7 ;
+8 ; All IHS Ref Lab tests are "CH" subscripted tests (for now).
+9 ;
+10 ; NOTE: There will be no check on the LRLABKY variable.
+11 ; It is assumed that the process running this routine MUST be able to add tests to an accession.
+12 ;
+13 ; LA76249 is the Message # from file 62.49
+14 ; BLRRLTST is the unique identifier of the test to be added (the IEN)
+15 ; BLRRLUID is the UID passed to this routine by the calling routine
+16 ;
EEP ; Ersatz EP
+1 DO EEP^BLRGMENU
+2 QUIT
+3 ;
PEP ; EP
EP ; EP
ADDTST(LA76249,BLRRLTST,BLRRLUID) ; EP
+1 NEW (BLRRLTST,BLRRLUID,DILOCKTM,DISYS,DT,DTIME,DUZ,IO,IOBS,IOF,IOM,ION,IOS,IOSL,IOST,IOT,LA76249,LRDFN,LRODT,LRSN,IOXY,U,XPARSYS,XQXFLG)
+2 ;
+3 SET X=$QUERY(^LRO(68,"C",BLRRLUID))
SET LRAA=+$QSUBSCRIPT(X,4)
SET LRAD=+$QSUBSCRIPT(X,5)
SET LRAN=+$QSUBSCRIPT(X,6)
+4 SET ORDERNUM=+$GET(^LRO(68,LRAA,1,LRAD,1,LRAN,.1))
+5 SET LRODT=+$ORDER(^LRO(69,"C",ORDERNUM,0))
SET LRSN=+$ORDER(^LRO(69,"C",ORDERNUM,LRODT,0))
+6 ;
+7 ; Reset LRPARAM string
DO ^LRPARAM
+8 ;
+9 SET LRTS=BLRRLTST
+10 SET LRURG=$$FIND1^DIC(62.05,,,"ROUTINE")
SET LRFLG=""
+11 DO LRTSTSET
+12 QUIT
+13 ;
LRTSTSET ; EP - Code cloned from LRTSTSET
+1 IF '($DATA(^LRO(68,LRAA,1,LRAD,1,LRAN,0))#2)
WRITE !?10,"Sorry This accession "_LRAN_" No longer exist",!?10," Accession may have been deleted.",!,$CHAR(7)
GOTO ADDTST^LRTSTJAM
+2 SET ^LRO(68,LRAA,1,LRAD,1,LRAN,4,LRTS,0)=LRTS_"^"_LRURG
SET $PIECE(^(0),U,9)=$GET(LRTSP)
SET ^LRO(68,LRAA,1,LRAD,1,LRAN,4,"B",LRTS,LRTS)=""
SET $PIECE(^LRO(68,LRAA,1,LRAD,1,LRAN,3),U,4)=""
+3 SET $PIECE(^LRO(68,LRAA,1,LRAD,1,LRAN,4,0),U,3)=LRTS
SET $PIECE(^(0),U,4)=$PIECE(^(0),U,4)+1
IF $PIECE(LRPARAM,U,14)
IF $PIECE(^LRO(68,LRAA,0),U,16)
DO CAP^LRWLST12
+4 SET LRACD=$PIECE(^LRO(68,LRAA,1,LRAD,1,LRAN,0),"^",3)
SET LRTSAD(1,LRTS)=""
+5 ;Check for automatic downloading
DO EN^LA7ADL($PIECE($GET(^LRO(68,LRAA,1,LRAD,1,LRAN,.3),0),"^"))
+6 IF LRACD
IF LRACD'=LRAD
SET ^LRO(68,LRAA,1,LRACD,1,LRAN,4,LRTS,0)=LRTS_"^"_LRURG
SET $PIECE(^(0),U,9)=+LRTS
Begin DoDot:1
+7 SET ^LRO(68,LRAA,1,LRACD,1,LRAN,4,"B",LRTS,LRTS)=""
SET $PIECE(^LRO(68,LRAA,1,LRAD,1,LRAN,3),"^",4)=""
IF $PIECE(LRPARAM,U,14)
IF $PIECE(^LRO(68,LRAA,0),U,16)
DO CAP^LRWLST12
End DoDot:1
+8 FOR
LOCK +^LRO(69,LRODT,1,LRSN):1
IF $TEST
QUIT
WRITE !?7,"Someone else is editing this order",!,$CHAR(7)
HANG 20
+9 KILL LRXDA,DA,DIC,DIE,DR
+10 SET DIC="^LRO(69,"_LRODT_",1,"_LRSN_",2,"
SET DA(2)=LRODT
SET DA(1)=LRSN
+11 SET DIC(0)="LOX"
SET DLAYGO=69
SET X=$PIECE(^LAB(60,LRTS,0),"^")
DO ^DIC
69 ; EP
+1 IF Y>0
Begin DoDot:1
+2 SET LRXDA(3)=$GET(^LRO(68,LRAA,1,LRAD,1,LRAN,.3))
+3 SET (LRXDA,DA)=+Y
SET DIE=DIC
SET DR="1///^S X=LRURG;2///^S X=LRAD;3///^S X=LRAA;4///^S X=LRAN;8///^S X=""IP"";9///^S X=""L"""
+4 IF $LENGTH($PIECE(LRXDA(3),U))
Begin DoDot:2
+5 SET DR=DR_";13///^S X=$P(LRXDA(3),U)"
+6 IF $PIECE(LRXDA(3),U,2)
SET DR=DR_";14////^S X=$P(LRXDA(3),U,2);15////^S X=$P(LRXDA(3),U,3);16///^S X=$P(LRXDA(3),U,4);17///^S X=$P(LRXDA(3),U,5)"
End DoDot:2
+7 DO ^DIE
+8 IF $GET(LRTSP)
Begin DoDot:2
+9 SET LRBETN=$ORDER(^LRO(69,LRODT,1,LRSN,2,"B",LRTSP,""))
+10 IF LRBETN
DO DADD^LRBEBA31(LRODT,LRSN,LRBETN,LRXDA,LRTS,$GET(LRBERF))
End DoDot:2
+11 KILL LRBETN,LRBERF
End DoDot:1
+12 IF $GET(LRXDA)
Begin DoDot:1
+13 NEW X,Y
+14 SET Y=$PIECE($$FMTE^XLFDT($$NOW^XLFDT,"5Z"),":",1,2)
+15 SET X=1+$SELECT($DATA(^LRO(69,LRODT,1,LRSN,2,LRXDA,1,0)):$PIECE(^(0),"^",3),1:0)
SET ^(0)="^^"_X_"^"_DT
SET ^(X,0)=" Added by "_$GET(DUZ)_" on "_Y
+16 SET ^LRO(69,"AA",+$GET(^LRO(69,LRODT,1,LRSN,.1)),LRODT_"|"_LRSN)=""
+17 ;
+18 ;
End DoDot:1
+19 IF '$DATA(LRFLG)
KILL DLAYGO,DA,DIC,DIE,DR,LRXDA
LOCK -^LRO(69,LRODT,1,LRSN)
QUIT
SETOR ;
+1 ;OE/RR 2.5
IF $GET(LRXDA)
IF $$VER^LR7OU1<3
Begin DoDot:1
+2 IF '$DATA(ORNATR)
SET ORNATR=$SELECT($DATA(LRNATURE):LRNATURE,1:"")
IF '$DATA(LRNATURE)
IF $PIECE($GET(^ORD(100.99,1,2)),"^",2)
DO OT^LROR6
SET LRNATURE=ORNATR
+3 SET X=^LRO(69,LRODT,1,LRSN,0)
SET LRLB=$PIECE(^(.1),"^")
SET X1=$SELECT($DATA(^(1)):^(1),1:$PIECE(X,"^",8))
SET ORVP=$PIECE(^LR(+X,0),"^",3)_";"_$PIECE(^DIC($PIECE(^LR(+X,0),"^",2),0,"GL"),"^",2)
+4 IF ORNATR="C"
SET OREPDUZ=$PIECE(X,"^",2)
SET ORLOG=$PIECE(X,"^",5)
SET ORNATR=""
+5 SET LRORSAMP=$PIECE(X,"^",3)
SET LRORTYPE=$PIECE(X,"^",4)
SET ORNP=$PIECE(X,"^",6)
SET ORL=$SELECT($LENGTH($PIECE(X,"^",7)):$PIECE(X,"^",7),1:"UNKNOWN")
+6 SET ORL=$SELECT($ORDER(^SC("C",ORL,0))'="":$ORDER(^(0))_";SC(",1:"")
SET ORSTRT=$PIECE(X1,"^")
SET X=^LRO(69,LRODT,1,LRSN,2,LRXDA,0)
SET ORIT=+X_";LAB(60,"
SET LRORSPEC=$ORDER(^LRO(69,LRODT,1,LRSN,4,0))
SET LRORSPEC=$SELECT(LRORSPEC>0:$PIECE(^(LRORSPEC,0),"^"),1:"")
+7 SET X=$SELECT($DATA(LRORSAMP):$SELECT($DATA(^LAB(62,+LRORSAMP,0)):$PIECE(^(0),"^"),1:""),1:"")
SET Y=$SELECT($DATA(LRORSPEC):$SELECT($DATA(^LAB(61,+LRORSPEC,0)):$PIECE(^(0),"^"),1:""),1:"")
+8 SET ORTX(1)=$PIECE(^LAB(60,+LRTS,0),"^")_$SELECT(Y'[X!(X=Y):" "_X,1:"")_$SELECT(X'[Y:" "_Y,1:"")
+9 SET ORTX(1)=ORTX(1)_" LB #"_LRLB_" "_$SELECT($DATA(LRORTYPE):LRORTYPE,1:"")_$SELECT(LRURG=9!('LRURG):"",1:" "_$PIECE(^LAB(62.05,LRURG,0),"^"))
+10 SET ORPCL=$PIECE(^LAB(69.9,1,1),"^",6)
SET ORSTS=6
SET ORTO=$PIECE(^LAB(60,+ORIT,0),"^",6)
IF $PIECE(^LAB(69.9,1,0),"^",9)
SET ORPURG=$PIECE(^(0),"^",9)
+11 SET ORPCL=$PIECE(^LAB(69.9,1,1),"^",6)_";ORD(101,"
SET ORPK=LRODT_"^"_LRSN_"^"_DA
SET DA=LRXDA
+12 DO FILE^ORX
+13 IF $DATA(ORIFN)
SET $PIECE(^LRO(69,LRODT,1,LRSN,2,LRXDA,0),"^",7)=ORIFN
+14 KILL LRLB,LRXDA,LRFLG,LRORSPEC,LRORSAMP,LRORTYPE
End DoDot:1
+15 NEW LTS
SET LTS(LRTS)=""
+16 DO NEW^LR7OB1(LRODT,LRSN,"SN",$GET(LRNATURE),.LTS,6)
+17 KILL DLAYGO,DA,DIC,DIE,DR,LRBERF,LRBEFN,LRBEX
LOCK -^LRO(69,LRODT,1,LRSN)
+18 QUIT