LROR8 ;SLC/DCM - FLAG/HOLD ORDERS ;5/1/89 17:46 ;
;;5.2;LAB SERVICE;**100,128**;Sep 27, 1994
EN ;;from LROR to FLAG orders
I ORSTS'=5,ORSTS'=4 W !,"Only PENDING lab orders can be flagged." Q
S ORSTS=$S(ORSTS=4:5,ORSTS=5:4,ORSTS="":4,1:"") D:ORSTS'="" ST^ORX
Q
EN1 ;;from LROR to HOLD orders
I ORGY=0 W !!,"Lab orders cannot be put on HOLD. Do you want to CANCEL the order",$C(7) S %=2 D YN^DICN Q:%'=1
D C^LROR3 Q
Q
EN2 ;Verify unreleased lab orders
Q ;Disable verify - now done when released
EN3 ;Verify upon release
I ORSTS'=11,ORSTS'="" Q
N LRSTS
S LRSTS=ORSTS,LRSX=0,LRASK=0,LRORIFN=ORIFN,LREND=0,X=ORPK,LRTST=+X,LROST=$P(X,"^",2),LRSAMP=$P(X,"^",3),LRSPEC=$P(X,"^",4),LRZX(1)=$P(X,"^",5),LRURG=$P(X,"^",6),LRORD=$P(X,"^",7),LRI=1,LRTEST(LRI)=LRTST
I 'LRORD D GET
I 'LRTST!('LROST)!('LRSAMP)!('LRSPEC)!('$L(LRZX(1)))!('LRURG)!('$L(LRORD)) W !,"Incomplete data! This order cannot be released." D READ^ORUTL S OREND=1 D END Q
S LRTSTNM=$S($D(^LAB(60,LRTST,0)):$P(^(0),"^"),1:"")
D NOW^%DTC S LRNOW=%
N GOT,LRNSN,LRODT S GOT=0,LRODT=$P(LROST,".")
I $D(^LRO(69,"C",LRORD,LRODT)) S LRSN=0 F S LRSN=$O(^LRO(69,"C",LRORD,LRODT,LRSN)) Q:LRSN<1 D Q:GOT
. I $D(^LRO(69,LRODT,1,LRSN,0)),$P(^(0),"^",3)=LRSAMP,$D(^(4,1,0)),+^(0)=LRSPEC,$P($G(^LRO(69,LRODT,1,LRSN,3)),"^") S GOT=1
I GOT W $C(7),!!,"The specimen for test "_LRTSTNM_", has already been processed by Lab.",!,"Please create a new order, or contact lab to have this test added." S ORSTS="K" D ST^ORX W !?5,LRTSTNM_" Deleted" S OREND=1 D END,READ^ORUTL Q
I LROST["."&(LRNOW>(LROST+.0002)) D COL I LREND S OREND=1 D END Q
I LROST'[".",$P(LRNOW,".",1)>LROST D COL I LREND S OREND=1 D END Q
D DUP I LREND D END Q
S1 S LRSX=LRSX+1 I $D(^XUTL("OR",$J,"LROT",LROST,LRZX(1),LRSAMP,LRSPEC,LRSX)) G S1
S:'$G(^XUTL("OR",$J,"LROT",LROST,LRZX(1))) ^(LRZX(1))=LRORD
S ^XUTL("OR",$J,"LROT",LROST,LRZX(1),LRSAMP,LRSPEC,LRSX,1)=LRURG,^XUTL("OR",$J,"LROT",LROST,LRZX(1),LRSAMP,LRSPEC,LRSX,0)=LRORIFN,^XUTL("OR",$J,"LROT",LROST,LRZX(1),LRSAMP,LRSPEC,LRSX)=LRTST
I $D(ORCARY),'$D(^XUTL("OR",$J,"COM")) M ^XUTL("OR",$J,"COM")=ORCARY
I '$D(ORCARY),$D(^XUTL("OR",$J,"COM")) M ORCARY=^XUTL("OR",$J,"COM")
Q:LRSTS="" S LREXP="",LRZX(6)=LROST\1 D MAX^LRXO1 I LREND S ORSTS="K" D ST^ORX W " Deleted" K ^XUTL("OR",$J,"LROT",LROST,LRZX(1),LRSAMP,LRSPEC,LRSX) Q
I $D(^LAB(60,LRTST,3,+$O(^LAB(60,LRTST,3,"B",+LRSAMP,0)),0)) S LREXP=$P(^(0),"^",6) I LREXP D RCOM^LRXO9
I 'LREXP S LREXP=$P(^LAB(60,LRTST,0),"^",19) I LREXP D RCOM^LRXO9
;I $D(^LAB(60,LRTST,6,0)),$O(^(0))'<1 W !,"GENERAL WARD INSTRUCTIONS:" S N1=0 F S N1=$O(^LAB(60,LRTST,6,N1)) Q:N1<1 W !," "_^(N1,0)
N LRCSX S LRCSX=0,CNT=2,I=0,LRLWC=LRZX(1)
F S LRCSX=$O(^XUTL("OR",$J,"COM",LROST,LRZX(1),LRSAMP,LRSPEC,LRCSX)) Q:LRCSX<1 S I=0 D
. F S I=$O(^XUTL("OR",$J,"COM",LROST,LRZX(1),LRSAMP,LRSPEC,LRCSX,I)) Q:I<1 I ^(I)'["~For",$O(^(I,0))=LRTST S ORETURN("ORTX",CNT)=^XUTL("OR",$J,"COM",LROST,LRZX(1),LRSAMP,LRSPEC,LRCSX,I),CNT=CNT+1
D SET2^LROR(+LRTEST(LRI),LRSAMP,LRSPEC,LRURG,LRLWC,LRORD) S ORETURN("ORTX",1)=ORTX(1) K LRLWC
I $D(ORETURN) S ORIFN=LRORIFN D RETURN^ORX
;K ^XUTL("OR",$J,"COM",LROST,LRZX(1),LRSAMP,LRSPEC,LRSX)
Q
COL S Y=LROST D DD^%DT W !!,"The collection time of "_Y_" has expired",!,"Please enter a new collection time"
D INIT^LRXO00 I LRZX(1)["I" D Q
. D EN^LRORDIM I $G(LREND) W !,"No Collection Time Entered",!! Q
. S ORETURN("ORSTRT")=LROST D RETURN^ORX Q
N LRNOW D EN^LRXO5 I $G(LREND) W !,"A new collection time must be entered to release this order",!,"Order not released!" Q
S ORETURN("ORSTRT")=LROST D RETURN^ORX
Q
END K LRORIFN,LREND,LRTST,LROST,LRSAMP,LRSPEC,LRZX(1),LRURG,LRORD,LROT,LRZX(6),X,LRI,LRTEST
Q
DUP ;Check for duplicate in ^XUTL
N SX
S SX=0 F S SX=$O(^XUTL("OR",$J,"LROT",LROST,LRZX(1),LRSAMP,LRSPEC,SX)) Q:SX<1 I LRTST=+(^(SX)) S LREND=1 D:LRORIFN'=+$G(^(SX,0)) Q
. W !!!,"Duplicate test "_LRTSTNM_", for the same collection time will be deleted",!! D READ^ORUTL
. S ORIFN=LRORIFN,ORSTS="K" D ST^ORX
Q
GET ;Get Ord #
S LRORD=$G(^XUTL("OR",$J,"LROT",LROST,LRZX(1)))
I 'LRORD S ZTQUEUED=1 D ORDER^LROW2 K ZTQUEUED
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HLROR8 4171 printed Nov 22, 2024@17:28:52 Page 2
LROR8 ;SLC/DCM - FLAG/HOLD ORDERS ;5/1/89 17:46 ;
+1 ;;5.2;LAB SERVICE;**100,128**;Sep 27, 1994
EN ;;from LROR to FLAG orders
+1 IF ORSTS'=5
IF ORSTS'=4
WRITE !,"Only PENDING lab orders can be flagged."
QUIT
+2 SET ORSTS=$SELECT(ORSTS=4:5,ORSTS=5:4,ORSTS="":4,1:"")
if ORSTS'=""
DO ST^ORX
+3 QUIT
EN1 ;;from LROR to HOLD orders
+1 IF ORGY=0
WRITE !!,"Lab orders cannot be put on HOLD. Do you want to CANCEL the order",$CHAR(7)
SET %=2
DO YN^DICN
if %'=1
QUIT
+2 DO C^LROR3
QUIT
+3 QUIT
EN2 ;Verify unreleased lab orders
+1 ;Disable verify - now done when released
QUIT
EN3 ;Verify upon release
+1 IF ORSTS'=11
IF ORSTS'=""
QUIT
+2 NEW LRSTS
+3 SET LRSTS=ORSTS
SET LRSX=0
SET LRASK=0
SET LRORIFN=ORIFN
SET LREND=0
SET X=ORPK
SET LRTST=+X
SET LROST=$PIECE(X,"^",2)
SET LRSAMP=$PIECE(X,"^",3)
SET LRSPEC=$PIECE(X,"^",4)
SET LRZX(1)=$PIECE(X,"^",5)
SET LRURG=$PIECE(X,"^",6)
SET LRORD=$PIECE(X,"^",7)
SET LRI=1
SET LRTEST(LRI)=LRTST
+4 IF 'LRORD
DO GET
+5 IF 'LRTST!('LROST)!('LRSAMP)!('LRSPEC)!('$LENGTH(LRZX(1)))!('LRURG)!('$LENGTH(LRORD))
WRITE !,"Incomplete data! This order cannot be released."
DO READ^ORUTL
SET OREND=1
DO END
QUIT
+6 SET LRTSTNM=$SELECT($DATA(^LAB(60,LRTST,0)):$PIECE(^(0),"^"),1:"")
+7 DO NOW^%DTC
SET LRNOW=%
+8 NEW GOT,LRNSN,LRODT
SET GOT=0
SET LRODT=$PIECE(LROST,".")
+9 IF $DATA(^LRO(69,"C",LRORD,LRODT))
SET LRSN=0
FOR
SET LRSN=$ORDER(^LRO(69,"C",LRORD,LRODT,LRSN))
if LRSN<1
QUIT
Begin DoDot:1
+10 IF $DATA(^LRO(69,LRODT,1,LRSN,0))
IF $PIECE(^(0),"^",3)=LRSAMP
IF $DATA(^(4,1,0))
IF +^(0)=LRSPEC
IF $PIECE($GET(^LRO(69,LRODT,1,LRSN,3)),"^")
SET GOT=1
End DoDot:1
if GOT
QUIT
+11 IF GOT
WRITE $CHAR(7),!!,"The specimen for test "_LRTSTNM_", has already been processed by Lab.",!,"Please create a new order, or contact lab to have this test added."
SET ORSTS="K"
DO ST^ORX
WRITE !?5,LRTSTNM_" Deleted"
SET OREND=1
DO END
DO READ^ORUTL
QUIT
+12 IF LROST["."&(LRNOW>(LROST+.0002))
DO COL
IF LREND
SET OREND=1
DO END
QUIT
+13 IF LROST'["."
IF $PIECE(LRNOW,".",1)>LROST
DO COL
IF LREND
SET OREND=1
DO END
QUIT
+14 DO DUP
IF LREND
DO END
QUIT
S1 SET LRSX=LRSX+1
IF $DATA(^XUTL("OR",$JOB,"LROT",LROST,LRZX(1),LRSAMP,LRSPEC,LRSX))
GOTO S1
+1 if '$GET(^XUTL("OR",$JOB,"LROT",LROST,LRZX(1)))
SET ^(LRZX(1))=LRORD
+2 SET ^XUTL("OR",$JOB,"LROT",LROST,LRZX(1),LRSAMP,LRSPEC,LRSX,1)=LRURG
SET ^XUTL("OR",$JOB,"LROT",LROST,LRZX(1),LRSAMP,LRSPEC,LRSX,0)=LRORIFN
SET ^XUTL("OR",$JOB,"LROT",LROST,LRZX(1),LRSAMP,LRSPEC,LRSX)=LRTST
+3 IF $DATA(ORCARY)
IF '$DATA(^XUTL("OR",$JOB,"COM"))
MERGE ^XUTL("OR",$JOB,"COM")=ORCARY
+4 IF '$DATA(ORCARY)
IF $DATA(^XUTL("OR",$JOB,"COM"))
MERGE ORCARY=^XUTL("OR",$JOB,"COM")
+5 if LRSTS=""
QUIT
SET LREXP=""
SET LRZX(6)=LROST\1
DO MAX^LRXO1
IF LREND
SET ORSTS="K"
DO ST^ORX
WRITE " Deleted"
KILL ^XUTL("OR",$JOB,"LROT",LROST,LRZX(1),LRSAMP,LRSPEC,LRSX)
QUIT
+6 IF $DATA(^LAB(60,LRTST,3,+$ORDER(^LAB(60,LRTST,3,"B",+LRSAMP,0)),0))
SET LREXP=$PIECE(^(0),"^",6)
IF LREXP
DO RCOM^LRXO9
+7 IF 'LREXP
SET LREXP=$PIECE(^LAB(60,LRTST,0),"^",19)
IF LREXP
DO RCOM^LRXO9
+8 ;I $D(^LAB(60,LRTST,6,0)),$O(^(0))'<1 W !,"GENERAL WARD INSTRUCTIONS:" S N1=0 F S N1=$O(^LAB(60,LRTST,6,N1)) Q:N1<1 W !," "_^(N1,0)
+9 NEW LRCSX
SET LRCSX=0
SET CNT=2
SET I=0
SET LRLWC=LRZX(1)
+10 FOR
SET LRCSX=$ORDER(^XUTL("OR",$JOB,"COM",LROST,LRZX(1),LRSAMP,LRSPEC,LRCSX))
if LRCSX<1
QUIT
SET I=0
Begin DoDot:1
+11 FOR
SET I=$ORDER(^XUTL("OR",$JOB,"COM",LROST,LRZX(1),LRSAMP,LRSPEC,LRCSX,I))
if I<1
QUIT
IF ^(I)'["~For"
IF $ORDER(^(I,0))=LRTST
SET ORETURN("ORTX",CNT)=^XUTL("OR",$JOB,"COM",LROST,LRZX(1),LRSAMP,LRSPEC,LRCSX,I)
SET CNT=CNT+1
End DoDot:1
+12 DO SET2^LROR(+LRTEST(LRI),LRSAMP,LRSPEC,LRURG,LRLWC,LRORD)
SET ORETURN("ORTX",1)=ORTX(1)
KILL LRLWC
+13 IF $DATA(ORETURN)
SET ORIFN=LRORIFN
DO RETURN^ORX
+14 ;K ^XUTL("OR",$J,"COM",LROST,LRZX(1),LRSAMP,LRSPEC,LRSX)
+15 QUIT
COL SET Y=LROST
DO DD^%DT
WRITE !!,"The collection time of "_Y_" has expired",!,"Please enter a new collection time"
+1 DO INIT^LRXO00
IF LRZX(1)["I"
Begin DoDot:1
+2 DO EN^LRORDIM
IF $GET(LREND)
WRITE !,"No Collection Time Entered",!!
QUIT
+3 SET ORETURN("ORSTRT")=LROST
DO RETURN^ORX
QUIT
End DoDot:1
QUIT
+4 NEW LRNOW
DO EN^LRXO5
IF $GET(LREND)
WRITE !,"A new collection time must be entered to release this order",!,"Order not released!"
QUIT
+5 SET ORETURN("ORSTRT")=LROST
DO RETURN^ORX
+6 QUIT
END KILL LRORIFN,LREND,LRTST,LROST,LRSAMP,LRSPEC,LRZX(1),LRURG,LRORD,LROT,LRZX(6),X,LRI,LRTEST
+1 QUIT
DUP ;Check for duplicate in ^XUTL
+1 NEW SX
+2 SET SX=0
FOR
SET SX=$ORDER(^XUTL("OR",$JOB,"LROT",LROST,LRZX(1),LRSAMP,LRSPEC,SX))
if SX<1
QUIT
IF LRTST=+(^(SX))
SET LREND=1
if LRORIFN'=+$GET(^(SX,0))
Begin DoDot:1
+3 WRITE !!!,"Duplicate test "_LRTSTNM_", for the same collection time will be deleted",!!
DO READ^ORUTL
+4 SET ORIFN=LRORIFN
SET ORSTS="K"
DO ST^ORX
End DoDot:1
QUIT
+5 QUIT
GET ;Get Ord #
+1 SET LRORD=$GET(^XUTL("OR",$JOB,"LROT",LROST,LRZX(1)))
+2 IF 'LRORD
SET ZTQUEUED=1
DO ORDER^LROW2
KILL ZTQUEUED
+3 QUIT