PSOHLD ;BIR/SAB - hold unhold functionality ;05-Jun-2013 15:36;DU
;;7.0;OUTPATIENT PHARMACY;**1,16,21,24,27,32,55,82,114,130,166,1011,148,268,281,1015,1017**;DEC 1997;Build 40
;External reference to ^DD(52-DBIA 999, VA(200-DBIA 224, NA^ORX1-DBIA 2186,
;
;Modified - IHS/MSC/PLS - 07/21/2011 - Lines EN+5 and EN+19
; 04/16/2013 - Change /// to //// for division (PSOSITE) set
; 06/05/2013 - Line NOOR+2
; L, UL, PSOL, and PSOUL^PSSLOCK-DBIA 2789, ^%DTC-DBIA 10000, ^DIE-DBIA 10018, ^DIR-DBIA 10026,
; ^DIK-DBIA 10013, ^VALM1-DBIA 10016, ^XUSEC(-DBIA 10076
UHLD I '$D(PSOPAR) D ^PSOLSET G:'$D(PSOPAR) EX
I $G(PSOBEDT) W $C(7),$C(7) S VALMSG="Invalid Action at this time !",VALMBCK="" Q
I $G(PSONACT) W $C(7),$C(7) S VALMSG="No Pharmacy Orderable Item !",VALMBCK="" Q
S PSOPLCK=$$L^PSSLOCK(PSODFN,0) I '$G(PSOPLCK) D LOCK^PSOORCPY S VALMSG=$S($P($G(PSOPLCK),"^",2)'="":$P($G(PSOPLCK),"^",2)_" is working on this patient.",1:"Another person is entering orders for this patient.") K PSOPLCK S VALMBCK="" Q
;W !! S DIC("A")="Unhold Prescription #: ",(DIE,DIC)="^PSRX(",DIC(0)="AEMQZ",DIC("S")="I $G(^PSRX(+Y,""H""))]"""",$P(^(""STA""),""^"")'=16" D ^DIC G:"^"[$E(X) EX G:Y<0 UHLD S (DA,PPL)=+Y,DFN=$P(Y(0),"^",2)
K PSOPLCK D PSOL^PSSLOCK(DA) I '$G(PSOMSG) S VALMSG=$S($P($G(PSOMSG),"^",2)'="":$P($G(PSOMSG),"^",2),1:"Another person is editing this order."),VALMBCK="" K PSOMSG D ULP Q
S Y(0)=^PSRX(DA,0),STA=+$G(^("STA"))
I STA=16 S VALMSG="Placed on HOLD by Provider!" K Y,STA D PSOUL^PSSLOCK(DA) D ULP S VALMBCK="" Q
I STA'=3!('$D(^XUSEC("PSORPH",DUZ))) S VALMSG="Invalid Action Selection!",VALMBCK="" K Y,STA D PSOUL^PSSLOCK(DA) D ULP Q
D FULL^VALM1 K DIR,DTOUT,DUOUT,DIRUT D NOOR I $D(DIRUT) D ULP G EX
I DT>$P(^PSRX(DA,2),"^",6) D D ULP G EX
.S VALMSG="Medication Expired on "_$E($P(^PSRX(DA,2),"^",6),4,5)_"-"_$E($P(^(2),"^",6),6,7)_"-"_$E($P(^(2),"^",6),2,3) I $P(^PSRX(DA,"STA"),"^")<11 S $P(^PSRX(DA,"STA"),"^")=11
.S ^PSRX(DA,"H")="",COMM="Medication Expired on "_$E($P(^(2),"^",6),4,5)_"-"_$E($P(^(2),"^",6),6,7)_"-"_$E($P(^(2),"^",6),2,3) D EN^PSOHLSN1(DA,"SC","ZE",COMM,"") K COMM
EN S RXF=0 F I=0:0 S I=$O(^PSRX(DA,1,I)) Q:'I S RXF=I,RSDT=$P(^(0),"^")
I RXF D I $D(Y) D ULP G EX
.S (PSDA,DA(1))=DA,DA=RXF,DIE="^PSRX("_DA(1)_",1,"
.S RLDT=$P(^PSRX(DA(1),1,DA,0),"^",18)
.;IHS/MSC/PLS - Updated division
.;S DR=$S('RLDT:".01R;2;",1:"")_"3COMMENTS"
.S DR=$S('RLDT:".01R;2;",1:"")_"3COMMENTS"_";8////"_PSOSITE
.S PSOUNHLD=1 D ^DIE K PSOUNHLD
.S ZD(PSDA)=$P(^PSRX(DA(1),1,DA,0),"^")
.Q:$D(Y) S PSORX("FILL DATE")=$P(^PSRX(DA(1),1,DA,0),"^"),DA=PSDA K DA(1)
;
S ACT=1,DIE="^PSRX(",FDT=$S($P(^PSRX(DA,2),"^",2):$P(^PSRX(DA,2),"^",2),1:DT)
S RLDT=$P(^PSRX(DA,2),"^",13),DR="",RLDTP1=$P(RLDT,".",1)
I 'RXF&'RLDT S DR="22//^S X=FDT;11;Q;"
I RLDT&($P(^PSRX(DA,2),"^",2)="") S DR="22//^S X=RLDTP1;11;Q;"
S DR=DR_"100///0;101///^S X=$S(RXF:$G(ZD(PSDA)),1:$P(^PSRX(PSDA,2),""^"",2))"
;
S:'RXF DR=DR_";20////"_PSOSITE ;IHS/MSC/PLS - 07/21/2011 - Updated division
D ^DIE K FDT I $D(Y) S VALMBCK="R" D ULP G EX
S COMM="Medication Removed from Hold by Pharmacy" D EN^PSOHLSN1(DA,"OE","",COMM,PSONOOR) K COMM,PSONOOR
S PSORX("FILL DATE")=$S('RXF:$P(^PSRX(DA,2),"^",2),1:ZD(PSDA)) K ^PSRX("AH",$P(^PSRX(DA,"H"),"^"),DA) S ^PSRX(DA,"H")="" D ACT^PSOHLDA S (NEW1,NEW11)="^^"
S (RXF,RXFL(DA))=0 F JJ=0:0 S JJ=$O(^PSRX(DA,1,JJ)) Q:'JJ S (RXFL(DA),RXF)=JJ
I $G(PSXSYS) D UNHOLD^PSOCMOPA I $G(XFLAG) D ULP G EX
I $G(DA) D RELC I $G(PSOHRL) D ULP G EX
I PSORX("FILL DATE")>DT,$P(PSOPAR,"^",6) D S^PSORXL,EX,ULP Q
S PCOMH(DA)="Medication Removed from Hold by Pharmacy"
I $G(DA) S RXRH(DA)=DA
I $P($G(^PSRX(DA,2)),"^",15)'="" S $P(^PSRX(DA,2),"^",14)=1,RXRP(DA)=1,$P(RXRP(DA),"^",2)=$P($G(^PSRX(DA,0)),"^",18) ; MARK PRESCRIPTION AND LABEL AS BEING REPRINTED WHEN UNHOLDING A RETURNED TO SOTCK PRESCRIPTION
;
; - Submitting Rx to ECME
N ACTION
I $$SUBMIT^PSOBPSUT(DA,+$G(RXFL(DA))) D I ACTION="Q"!(ACTION="^") D ULP G EX
. N RX,RFL S RX=DA,RFL=+$G(RXFL(DA))
. N DA S ACTION=""
. D ECMESND^PSOBPSU1(RX,RFL,,$S(RFL:"RF",1:"OF"))
. I $$FIND^PSOREJUT(RX,RFL) D
. . S ACTION=$$HDLG^PSOREJU1(RX,RFL,"79,88","ED","IOQ","Q")
;
I $G(PSORX("PSOL",1))']"" S PSORX("PSOL",1)=DA_"," D ULP G EX
F PSOX1=0:0 S PSOX1=$O(PSORX("PSOL",PSOX1)) Q:'PSOX1 S PSOX2=PSOX1
I $L(PSORX("PSOL",PSOX2))+$L(DA)<220 S PSORX("PSOL",PSOX2)=PSORX("PSOL",PSOX2)_DA_","
E S PSORX("PSOL",PSOX2+1)=DA_","
;
D ULP
EX D PSOUL^PSSLOCK($P(PSOLST(ORN),"^",2)) D ^PSOBUILD
K PSOHRL,PSOMSG,PSOPLCK,ST,PSL,PSNP,IR,NOW,DR,NEW1,NEW11,RTN,DA,PPL,RXN,RX0,RXS,DIK,RXP,FLD,ACT,DIE,DIC,DIR,DIE,X,Y,DIRUT,DUOUT,SUSPT,C,D0,LFD,I,PSDA,RFDATE,DI,DQ,%,RFN,XFLAG
K HRX,PSHLD,PSOLIST,PSORX("FILL DATE"),STA,QTY,RFDT,PSORX0,PSRXN,RXF,JJ Q
;
HLD ;
I $G(PSOBEDT) W $C(7),$C(7) S VALMSG="Invalid Action at this time !",VALMBCK="" Q
I $G(PSONACT) W $C(7),$C(7) S VALMSG="No Pharmacy Orderable Item !",VALMBCK="" Q
I '$D(^XUSEC("PSORPH",DUZ)) S VALMSG="Invalid Action Selection!",VALMBCK="" Q
S PSOPLCK=$$L^PSSLOCK(PSODFN,0) I '$G(PSOPLCK) D LOCK^PSOORCPY S VALMSG=$S($P($G(PSOPLCK),"^",2)'="":$P($G(PSOPLCK),"^",2)_" is working on this patient.",1:"Another person is entering orders for this patient."),VALMBCK="" K PSOPLCK Q
K PSOPLCK D PSOL^PSSLOCK(DA) I '$G(PSOMSG) S VALMSG=$S($P($G(PSOMSG),"^",2)'="":$P($G(PSOMSG),"^",2),1:"Another person is editing this order."),VALMBCK="" K PSOMSG D ULP Q
S Y(0)=^PSRX(DA,0),STA=+$G(^("STA")) I DT>$P(^PSRX(DA,2),"^",6) D D ULP G D1
.S VALMSG="Medication Expired on "_$E($P(^PSRX(DA,2),"^",6),4,5)_"-"_$E($P(^(2),"^",6),6,7)_"-"_$E($P(^(2),"^",6),2,3),VALMBCK="R"
.I $P(^PSRX(DA,"STA"),"^")<11 S $P(^PSRX(DA,"STA"),"^")=11 D
..S COMM="Medication Expired on "_$E($P(^PSRX(DA,2),"^",6),4,5)_"-"_$E($P(^(2),"^",6),6,7)_"-"_$E($P(^(2),"^",6),2,3) D EN^PSOHLSN1(DA,"SC","ZE",COMM) K COMM
S ST=$P("ERROR^ACTIVE^NON-VERIFIED^REFILL^HOLD^NON-VERIFIED^SUSPENDED^^^^^DONE^EXPIRED^DISCONTINUED^DELETED^DISCONTINUED^DISCONTINUED (EDIT)^PROVIDER HOLD^","^",STA+2)
I STA,STA'>4!(STA>11) D D ULP G D1
.S VALMSG="Rx: "_$P(Y(0),"^")_" is currently in a status of "_ST,VALMBCK="R" K ST,Y Q
D FULL^VALM1 D NOOR I $D(DIRUT) D ULP G D1
D HLD^PSOCMOPA I $G(XFLAG) K XFLAG D ULP G D1
K DIR S DIR("A")=$P(^DD(52,99,0),"^"),DIR(0)="52,99" D ^DIR S FLD(99)=Y I $D(DUOUT)!($D(DIRUT)) K DIRUT,DUOUT,DIR D ULP G D1
I $G(FLD(99))=99 K DIR S DIR("A")=$P(^DD(52,99.1,0),"^"),DIR(0)="52,99.1" D ^DIR S FLD(99.1)=Y G AR
E K DIR S DIR(0)="FO^10:100",DIR("A")="HOLD COMMENTS" D ^DIR S FLD(99.1)=Y
AR I $D(DUOUT)!($D(DTOUT)) K DIRUT,DUOUT,DIR S VALMBCK="R" D ULP G D1
F PI=1:1 Q:$P(PPL,",",PI)="" S DA=$P(PPL,",",PI) D H S DA=PSDA K PSDA D:$D(PSORX("PSOL")) RMP^PSOHLDA
K PI D ^PSOBUILD
D ULP
D1 D PSOUL^PSSLOCK($P(PSOLST(ORN),"^",2)) K PSOMSG,PSOPLCK,RFN,DIR,RSDT,FLD,DA,ACT,X,Y,DIRUT,DUOUT,DTOUT,DIROUT
Q
;
H ; - Rx HOLD update
D HOLD^PSOHLDA
Q
;
FLD N DA K DIR S DIR("A")=$P(^DD(52,99,0),"^"),DIR(0)="52,99" D ^DIR Q:$D(DUOUT)!($D(DIRUT)) S FLD(99)=Y
S COMM=Y(0)
I $G(FLD(99))=99 K DIR S DIR("A")=$P(^DD(52,99.1,0),"^"),DIR(0)="52,99.1" D ^DIR Q:$D(DUOUT)!($D(DIRUT)) S (FLD(99.1),COMM)=Y Q
E S FLD(99.1)=""
Q
NOOR ;ask nature of order
K DIR,DTOUT,DTOUT,DIRUT I $T(NA^ORX1)]"" D Q
.;IHS/MSC/PLS - 06/05/2013
.;S PSONOOR=$$NA^ORX1("W",0,"B","Nature of Order",0,"WPSDIVR"_$S(+$G(^VA(200,DUZ,"PS")):"E",1:""))
.S PSONOOR=$$NA^ORX1("W",0,"B","Nature of Order",0,"WPSDIV"_$S(+$G(^VA(200,DUZ,"PS")):"E",1:""))
.I +PSONOOR S PSONOOR=$P(PSONOOR,"^",3) Q
.S DIRUT=1 K PSONOOR
S DIR("A")="Nature of Order: ",DIR("B")="WRITTEN"
S DIR(0)="SA^W:WRITTEN;V:VERBAL;P:TELEPHONE;S:SERVICE CORRECTED;D:DUPLICATE;I:POLICY;R:SERVICE REJECTED"_$S(+$G(^VA(200,DUZ,"PS")):";E:PROVIDER ENTERED",1:"")
NOORX D ^DIR K DIR,DTOUT,DTOUT Q:$D(DIRUT) S PSONOOR=Y
Q
ULP ;
D UL^PSSLOCK(+$G(PSODFN))
Q
RELC ;
S (PSOHRL,PSOHTX)=0 F PSOHT=0:0 S PSOHT=$O(^PSRX(DA,1,PSOHT)) Q:'PSOHT S:$D(^PSRX(DA,1,PSOHT,0)) PSOHTX=PSOHT
I $G(PSOHTX) S PSOHRL=$S($P($G(^PSRX(DA,1,PSOHTX,0)),"^",18):1,1:0)
I '$G(PSOHTX) S PSOHRL=$S($P($G(^PSRX(DA,2)),"^",13):1,1:0)
K PSOHTX,PSOHT
Q
PSOHLD ;BIR/SAB - hold unhold functionality ;05-Jun-2013 15:36;DU
+1 ;;7.0;OUTPATIENT PHARMACY;**1,16,21,24,27,32,55,82,114,130,166,1011,148,268,281,1015,1017**;DEC 1997;Build 40
+2 ;External reference to ^DD(52-DBIA 999, VA(200-DBIA 224, NA^ORX1-DBIA 2186,
+3 ;
+4 ;Modified - IHS/MSC/PLS - 07/21/2011 - Lines EN+5 and EN+19
+5 ; 04/16/2013 - Change /// to //// for division (PSOSITE) set
+6 ; 06/05/2013 - Line NOOR+2
+7 ; L, UL, PSOL, and PSOUL^PSSLOCK-DBIA 2789, ^%DTC-DBIA 10000, ^DIE-DBIA 10018, ^DIR-DBIA 10026,
+8 ; ^DIK-DBIA 10013, ^VALM1-DBIA 10016, ^XUSEC(-DBIA 10076
UHLD IF '$DATA(PSOPAR)
DO ^PSOLSET
IF '$DATA(PSOPAR)
GOTO EX
+1 IF $GET(PSOBEDT)
WRITE $CHAR(7),$CHAR(7)
SET VALMSG="Invalid Action at this time !"
SET VALMBCK=""
QUIT
+2 IF $GET(PSONACT)
WRITE $CHAR(7),$CHAR(7)
SET VALMSG="No Pharmacy Orderable Item !"
SET VALMBCK=""
QUIT
+3 SET PSOPLCK=$$L^PSSLOCK(PSODFN,0)
IF '$GET(PSOPLCK)
DO LOCK^PSOORCPY
SET VALMSG=$SELECT($PIECE($GET(PSOPLCK),"^",2)'="":$PIECE($GET(PSOPLCK),"^",2)_" is working on this patient.",1:"Another person is entering orders for this patient.")
KILL PSOPLCK
SET VALMBCK=""
QUIT
+4 ;W !! S DIC("A")="Unhold Prescription #: ",(DIE,DIC)="^PSRX(",DIC(0)="AEMQZ",DIC("S")="I $G(^PSRX(+Y,""H""))]"""",$P(^(""STA""),""^"")'=16" D ^DIC G:"^"[$E(X) EX G:Y<0 UHLD S (DA,PPL)=+Y,DFN=$P(Y(0),"^",2)
+5 KILL PSOPLCK
DO PSOL^PSSLOCK(DA)
IF '$GET(PSOMSG)
SET VALMSG=$SELECT($PIECE($GET(PSOMSG),"^",2)'="":$PIECE($GET(PSOMSG),"^",2),1:"Another person is editing this order.")
SET VALMBCK=""
KILL PSOMSG
DO ULP
QUIT
+6 SET Y(0)=^PSRX(DA,0)
SET STA=+$GET(^("STA"))
+7 IF STA=16
SET VALMSG="Placed on HOLD by Provider!"
KILL Y,STA
DO PSOUL^PSSLOCK(DA)
DO ULP
SET VALMBCK=""
QUIT
+8 IF STA'=3!('$DATA(^XUSEC("PSORPH",DUZ)))
SET VALMSG="Invalid Action Selection!"
SET VALMBCK=""
KILL Y,STA
DO PSOUL^PSSLOCK(DA)
DO ULP
QUIT
+9 DO FULL^VALM1
KILL DIR,DTOUT,DUOUT,DIRUT
DO NOOR
IF $DATA(DIRUT)
DO ULP
GOTO EX
+10 IF DT>$PIECE(^PSRX(DA,2),"^",6)
Begin DoDot:1
+11 SET VALMSG="Medication Expired on "_$EXTRACT($PIECE(^PSRX(DA,2),"^",6),4,5)_"-"_$EXTRACT($PIECE(^(2),"^",6),6,7)_"-"_$EXTRACT($PIECE(^(2),"^",6),2,3)
IF $PIECE(^PSRX(DA,"STA"),"^")<11
SET $PIECE(^PSRX(DA,"STA"),"^")=11
+12 SET ^PSRX(DA,"H")=""
SET COMM="Medication Expired on "_$EXTRACT($PIECE(^(2),"^",6),4,5)_"-"_$EXTRACT($PIECE(^(2),"^",6),6,7)_"-"_$EXTRACT($PIECE(^(2),"^",6),2,3)
DO EN^PSOHLSN1(DA,"SC","ZE",COMM,"")
KILL COMM
End DoDot:1
DO ULP
GOTO EX
EN SET RXF=0
FOR I=0:0
SET I=$ORDER(^PSRX(DA,1,I))
IF 'I
QUIT
SET RXF=I
SET RSDT=$PIECE(^(0),"^")
+1 IF RXF
Begin DoDot:1
+2 SET (PSDA,DA(1))=DA
SET DA=RXF
SET DIE="^PSRX("_DA(1)_",1,"
+3 SET RLDT=$PIECE(^PSRX(DA(1),1,DA,0),"^",18)
+4 ;IHS/MSC/PLS - Updated division
+5 ;S DR=$S('RLDT:".01R;2;",1:"")_"3COMMENTS"
+6 SET DR=$SELECT('RLDT:".01R;2;",1:"")_"3COMMENTS"_";8////"_PSOSITE
+7 SET PSOUNHLD=1
DO ^DIE
KILL PSOUNHLD
+8 SET ZD(PSDA)=$PIECE(^PSRX(DA(1),1,DA,0),"^")
+9 IF $DATA(Y)
QUIT
SET PSORX("FILL DATE")=$PIECE(^PSRX(DA(1),1,DA,0),"^")
SET DA=PSDA
KILL DA(1)
End DoDot:1
IF $DATA(Y)
DO ULP
GOTO EX
+10 ;
+11 SET ACT=1
SET DIE="^PSRX("
SET FDT=$SELECT($PIECE(^PSRX(DA,2),"^",2):$PIECE(^PSRX(DA,2),"^",2),1:DT)
+12 SET RLDT=$PIECE(^PSRX(DA,2),"^",13)
SET DR=""
SET RLDTP1=$PIECE(RLDT,".",1)
+13 IF 'RXF&'RLDT
SET DR="22//^S X=FDT;11;Q;"
+14 IF RLDT&($PIECE(^PSRX(DA,2),"^",2)="")
SET DR="22//^S X=RLDTP1;11;Q;"
+15 SET DR=DR_"100///0;101///^S X=$S(RXF:$G(ZD(PSDA)),1:$P(^PSRX(PSDA,2),""^"",2))"
+16 ;
+17 ;IHS/MSC/PLS - 07/21/2011 - Updated division
IF 'RXF
SET DR=DR_";20////"_PSOSITE
+18 DO ^DIE
KILL FDT
IF $DATA(Y)
SET VALMBCK="R"
DO ULP
GOTO EX
+19 SET COMM="Medication Removed from Hold by Pharmacy"
DO EN^PSOHLSN1(DA,"OE","",COMM,PSONOOR)
KILL COMM,PSONOOR
+20 SET PSORX("FILL DATE")=$SELECT('RXF:$PIECE(^PSRX(DA,2),"^",2),1:ZD(PSDA))
KILL ^PSRX("AH",$PIECE(^PSRX(DA,"H"),"^"),DA)
SET ^PSRX(DA,"H")=""
DO ACT^PSOHLDA
SET (NEW1,NEW11)="^^"
+21 SET (RXF,RXFL(DA))=0
FOR JJ=0:0
SET JJ=$ORDER(^PSRX(DA,1,JJ))
IF 'JJ
QUIT
SET (RXFL(DA),RXF)=JJ
+22 IF $GET(PSXSYS)
DO UNHOLD^PSOCMOPA
IF $GET(XFLAG)
DO ULP
GOTO EX
+23 IF $GET(DA)
DO RELC
IF $GET(PSOHRL)
DO ULP
GOTO EX
+24 IF PSORX("FILL DATE")>DT
IF $PIECE(PSOPAR,"^",6)
DO S^PSORXL
DO EX
DO ULP
QUIT
+25 SET PCOMH(DA)="Medication Removed from Hold by Pharmacy"
+26 IF $GET(DA)
SET RXRH(DA)=DA
+27 ; MARK PRESCRIPTION AND LABEL AS BEING REPRINTED WHEN UNHOLDING A RETURNED TO SOTCK PRESCRIPTION
IF $PIECE($GET(^PSRX(DA,2)),"^",15)'=""
SET $PIECE(^PSRX(DA,2),"^",14)=1
SET RXRP(DA)=1
SET $PIECE(RXRP(DA),"^",2)=$PIECE($GET(^PSRX(DA,0)),"^",18)
+28 ;
+29 ; - Submitting Rx to ECME
+30 NEW ACTION
+31 IF $$SUBMIT^PSOBPSUT(DA,+$GET(RXFL(DA)))
Begin DoDot:1
+32 NEW RX,RFL
SET RX=DA
SET RFL=+$GET(RXFL(DA))
+33 NEW DA
SET ACTION=""
+34 DO ECMESND^PSOBPSU1(RX,RFL,,$SELECT(RFL:"RF",1:"OF"))
+35 IF $$FIND^PSOREJUT(RX,RFL)
Begin DoDot:2
+36 SET ACTION=$$HDLG^PSOREJU1(RX,RFL,"79,88","ED","IOQ","Q")
End DoDot:2
End DoDot:1
IF ACTION="Q"!(ACTION="^")
DO ULP
GOTO EX
+37 ;
+38 IF $GET(PSORX("PSOL",1))']""
SET PSORX("PSOL",1)=DA_","
DO ULP
GOTO EX
+39 FOR PSOX1=0:0
SET PSOX1=$ORDER(PSORX("PSOL",PSOX1))
IF 'PSOX1
QUIT
SET PSOX2=PSOX1
+40 IF $LENGTH(PSORX("PSOL",PSOX2))+$LENGTH(DA)<220
SET PSORX("PSOL",PSOX2)=PSORX("PSOL",PSOX2)_DA_","
+41 IF '$TEST
SET PSORX("PSOL",PSOX2+1)=DA_","
+42 ;
+43 DO ULP
EX DO PSOUL^PSSLOCK($PIECE(PSOLST(ORN),"^",2))
DO ^PSOBUILD
+1 KILL PSOHRL,PSOMSG,PSOPLCK,ST,PSL,PSNP,IR,NOW,DR,NEW1,NEW11,RTN,DA,PPL,RXN,RX0,RXS,DIK,RXP,FLD,ACT,DIE,DIC,DIR,DIE,X,Y,DIRUT,DUOUT,SUSPT,C,D0,LFD,I,PSDA,RFDATE,DI,DQ,%,RFN,XFLAG
+2 KILL HRX,PSHLD,PSOLIST,PSORX("FILL DATE"),STA,QTY,RFDT,PSORX0,PSRXN,RXF,JJ
QUIT
+3 ;
HLD ;
+1 IF $GET(PSOBEDT)
WRITE $CHAR(7),$CHAR(7)
SET VALMSG="Invalid Action at this time !"
SET VALMBCK=""
QUIT
+2 IF $GET(PSONACT)
WRITE $CHAR(7),$CHAR(7)
SET VALMSG="No Pharmacy Orderable Item !"
SET VALMBCK=""
QUIT
+3 IF '$DATA(^XUSEC("PSORPH",DUZ))
SET VALMSG="Invalid Action Selection!"
SET VALMBCK=""
QUIT
+4 SET PSOPLCK=$$L^PSSLOCK(PSODFN,0)
IF '$GET(PSOPLCK)
DO LOCK^PSOORCPY
SET VALMSG=$SELECT($PIECE($GET(PSOPLCK),"^",2)'="":$PIECE($GET(PSOPLCK),"^",2)_" is working on this patient.",1:"Another person is entering orders for this patient.")
SET VALMBCK=""
KILL PSOPLCK
QUIT
+5 KILL PSOPLCK
DO PSOL^PSSLOCK(DA)
IF '$GET(PSOMSG)
SET VALMSG=$SELECT($PIECE($GET(PSOMSG),"^",2)'="":$PIECE($GET(PSOMSG),"^",2),1:"Another person is editing this order.")
SET VALMBCK=""
KILL PSOMSG
DO ULP
QUIT
+6 SET Y(0)=^PSRX(DA,0)
SET STA=+$GET(^("STA"))
IF DT>$PIECE(^PSRX(DA,2),"^",6)
Begin DoDot:1
+7 SET VALMSG="Medication Expired on "_$EXTRACT($PIECE(^PSRX(DA,2),"^",6),4,5)_"-"_$EXTRACT($PIECE(^(2),"^",6),6,7)_"-"_$EXTRACT($PIECE(^(2),"^",6),2,3)
SET VALMBCK="R"
+8 IF $PIECE(^PSRX(DA,"STA"),"^")<11
SET $PIECE(^PSRX(DA,"STA"),"^")=11
Begin DoDot:2
+9 SET COMM="Medication Expired on "_$EXTRACT($PIECE(^PSRX(DA,2),"^",6),4,5)_"-"_$EXTRACT($PIECE(^(2),"^",6),6,7)_"-"_$EXTRACT($PIECE(^(2),"^",6),2,3)
DO EN^PSOHLSN1(DA,"SC","ZE",COMM)
KILL COMM
End DoDot:2
End DoDot:1
DO ULP
GOTO D1
+10 SET ST=$PIECE("ERROR^ACTIVE^NON-VERIFIED^REFILL^HOLD^NON-VERIFIED^SUSPENDED^^^^^DONE^EXPIRED^DISCONTINUED^DELETED^DISCONTINUED^DISCONTINUED (EDIT)^PROVIDER HOLD^","^",STA+2)
+11 IF STA
IF STA'>4!(STA>11)
Begin DoDot:1
+12 SET VALMSG="Rx: "_$PIECE(Y(0),"^")_" is currently in a status of "_ST
SET VALMBCK="R"
KILL ST,Y
QUIT
End DoDot:1
DO ULP
GOTO D1
+13 DO FULL^VALM1
DO NOOR
IF $DATA(DIRUT)
DO ULP
GOTO D1
+14 DO HLD^PSOCMOPA
IF $GET(XFLAG)
KILL XFLAG
DO ULP
GOTO D1
+15 KILL DIR
SET DIR("A")=$PIECE(^DD(52,99,0),"^")
SET DIR(0)="52,99"
DO ^DIR
SET FLD(99)=Y
IF $DATA(DUOUT)!($DATA(DIRUT))
KILL DIRUT,DUOUT,DIR
DO ULP
GOTO D1
+16 IF $GET(FLD(99))=99
KILL DIR
SET DIR("A")=$PIECE(^DD(52,99.1,0),"^")
SET DIR(0)="52,99.1"
DO ^DIR
SET FLD(99.1)=Y
GOTO AR
+17 IF '$TEST
KILL DIR
SET DIR(0)="FO^10:100"
SET DIR("A")="HOLD COMMENTS"
DO ^DIR
SET FLD(99.1)=Y
AR IF $DATA(DUOUT)!($DATA(DTOUT))
KILL DIRUT,DUOUT,DIR
SET VALMBCK="R"
DO ULP
GOTO D1
+1 FOR PI=1:1
IF $PIECE(PPL,",",PI)=""
QUIT
SET DA=$PIECE(PPL,",",PI)
DO H
SET DA=PSDA
KILL PSDA
IF $DATA(PSORX("PSOL"))
DO RMP^PSOHLDA
+2 KILL PI
DO ^PSOBUILD
+3 DO ULP
D1 DO PSOUL^PSSLOCK($PIECE(PSOLST(ORN),"^",2))
KILL PSOMSG,PSOPLCK,RFN,DIR,RSDT,FLD,DA,ACT,X,Y,DIRUT,DUOUT,DTOUT,DIROUT
+1 QUIT
+2 ;
H ; - Rx HOLD update
+1 DO HOLD^PSOHLDA
+2 QUIT
+3 ;
FLD NEW DA
KILL DIR
SET DIR("A")=$PIECE(^DD(52,99,0),"^")
SET DIR(0)="52,99"
DO ^DIR
IF $DATA(DUOUT)!($DATA(DIRUT))
QUIT
SET FLD(99)=Y
+1 SET COMM=Y(0)
+2 IF $GET(FLD(99))=99
KILL DIR
SET DIR("A")=$PIECE(^DD(52,99.1,0),"^")
SET DIR(0)="52,99.1"
DO ^DIR
IF $DATA(DUOUT)!($DATA(DIRUT))
QUIT
SET (FLD(99.1),COMM)=Y
QUIT
+3 IF '$TEST
SET FLD(99.1)=""
+4 QUIT
NOOR ;ask nature of order
+1 KILL DIR,DTOUT,DTOUT,DIRUT
IF $TEXT(NA^ORX1)]""
Begin DoDot:1
+2 ;IHS/MSC/PLS - 06/05/2013
+3 ;S PSONOOR=$$NA^ORX1("W",0,"B","Nature of Order",0,"WPSDIVR"_$S(+$G(^VA(200,DUZ,"PS")):"E",1:""))
+4 SET PSONOOR=$$NA^ORX1("W",0,"B","Nature of Order",0,"WPSDIV"_$SELECT(+$GET(^VA(200,DUZ,"PS")):"E",1:""))
+5 IF +PSONOOR
SET PSONOOR=$PIECE(PSONOOR,"^",3)
QUIT
+6 SET DIRUT=1
KILL PSONOOR
End DoDot:1
QUIT
+7 SET DIR("A")="Nature of Order: "
SET DIR("B")="WRITTEN"
+8 SET DIR(0)="SA^W:WRITTEN;V:VERBAL;P:TELEPHONE;S:SERVICE CORRECTED;D:DUPLICATE;I:POLICY;R:SERVICE REJECTED"_$SELECT(+$GET(^VA(200,DUZ,"PS")):";E:PROVIDER ENTERED",1:"")
NOORX DO ^DIR
KILL DIR,DTOUT,DTOUT
IF $DATA(DIRUT)
QUIT
SET PSONOOR=Y
+1 QUIT
ULP ;
+1 DO UL^PSSLOCK(+$GET(PSODFN))
+2 QUIT
RELC ;
+1 SET (PSOHRL,PSOHTX)=0
FOR PSOHT=0:0
SET PSOHT=$ORDER(^PSRX(DA,1,PSOHT))
IF 'PSOHT
QUIT
IF $DATA(^PSRX(DA,1,PSOHT,0))
SET PSOHTX=PSOHT
+2 IF $GET(PSOHTX)
SET PSOHRL=$SELECT($PIECE($GET(^PSRX(DA,1,PSOHTX,0)),"^",18):1,1:0)
+3 IF '$GET(PSOHTX)
SET PSOHRL=$SELECT($PIECE($GET(^PSRX(DA,2)),"^",13):1,1:0)
+4 KILL PSOHTX,PSOHT
+5 QUIT