PSJOE ;BIR/MLM-INPATIENT ORDER ENTRY ;29-May-2012 14:38;PLS
;;5.0; INPATIENT MEDICATIONS ;**7,26,29,33,42,50,56,72,58,85,95,80,1009,1011,110,111,133,140,151,149,1015**;16 DEC 97;Build 62
;
; Reference to ^PS(55 is supported by DBIA #2191.
; Reference to EN^VALM is supported by DBIA #10118.
; Reference to FULL^VALM1 and PAUSE^VALM1 is supported by DBIA #10116.
; Reference to ^PSSLOCK is supported by DBIA #2789
; Reference to ^DPT is supported by DBIA #10035.
; Reference to ^ORCFLAG is supported by DBIA #3620.
; Reference to ^SDAMA203 is supported by DBIA #4133.
; 12/09/2010 - Line COPY+5
; IHS/MSC/PLS - 03/28/2011 - Line EN+5
EN ; Start Inpatient LM OE
; Modified - IHS/MSC/JDS - 11/20/2010 - Line RENEW+3
N PSJLK,PSJNEWOE,PSJLMCON,PSJPROT,XQORS,VALMEVL D ENCV^PSGSETU,^PSIVXU
I $D(XQUIT) K XQUIT G DONE
K PSGVBY,PSJPR S (PSJOL,PSJACOK,PSGOP,PSGNEF,PSGOEAV,PSGPXN)="" L +^PS(53.45,PSJSYSP):1 E D LOCKERR^PSJOE G DONE^PSJOE
F S (PSJLMCON,PSGPTMP)=0 D ^PSJP,HK Q:PSGP'>0 S PSJPROT=3,DFN=PSGP D ^PSJAC D I PSJLK D UL^PSSLOCK(PSGP)
.D SETPTCX^APSPFUNC(PSGP) ;IHS/MSC/PLS - 03/28/11
.K ^TMP("PSJ",$J)
.S PSJLK=$$L^PSSLOCK(PSGP,1) I 'PSJLK W !,$C(7),$P(PSJLK,U,2) Q
.K PSJLMPRO D EN^VALM("PSJ LM BRIEF PATIENT INFO")
.N NXTPT S NXTPT=0 F Q:$G(NXTPT) D
..K PSGRDTX
..I $G(PSJLMCON)!$G(PSJNEWOE) D
...S PSJOL=$S(",S,L,"[(","_$G(PSJOL)_","):PSJOL,1:"S")
...S PSJLMPRO=1,PSJLMCON=1,PSJNEWOE=0 D EN^VALM("PSJ LM OE")
..I $G(PSJNEWOE)!($G(VALMBCK)="Q") S PSJNEWOE=0 Q
..I $G(PSJLMCON)&$G(PSJLMPRO)&'$D(^TMP("PSJ",$J)) D Q
...S PSJLMCON=0,PSJLMPRO=0 D EN^VALM("PSJ LM BRIEF PATIENT INFO")
...I $G(PSJNEWOE) S NXTPT=0 Q
...S NXTPT=1
..S NXTPT=1,PSJNEWOE=0
.S PSJOL="S"
.I $G(PSGPXN) I $P(PSJSYSW0,U,29)]""!($G(PSJCOM)) S PSGPXPT=PSGP D K PSGPXPT S PSGPXN=0
..N DFN,PSGP,PSJPXDP
..I $P(PSJSYSW0,U,29)="" S PSJPDXP=1 D
...N IO,ION,IOS D HOME^%ZIS S $P(PSJSYSW0,U,29)=+$G(IOS)
..S (PSGP,DFN)=PSGPXPT D ^PSGPER S:$G(PSJPDXP) $P(PSJSYSW0,U,29)="" K PSJPDXP
.D ENCV^PSGSETU,^PSIVXU
K PSJLMPRO,^TMP("PSJPRO",$J),^TMP("PSJ",$J),^TMP("PSJON",$J)
;
DONE ;
K AC,ACTION,D1,D2,MI,N,ON,P3,PNOW,PSIVAT,PSIVLN,PSIVSTR L -^PS(53.45,PSJSYSP)
K DA,DRG,NE,PSGCF,PSGCANFL,PSGNEDFD,PSGNEF,PSGNEFD,PSGNEPR,PSGNESD,PSJACOK,PSJOE,PSJOECNT,PSJOEPF,PSJORD,PSGOEA,PSGOEAV,PSGOL,PSGOS,PSGON,PSGOP,PSGORD,PSGS0XT,PSGS0Y,RCT,ST,WD,XREF,Z,PSJIVORF,PSJIVPCL
K PSGOEORF,PSIVREA,PSJOPC,PSJORL,PSJORPCL,PSJORTOI,RF,WSCHADM,PSJLM,PSJCT
K DIU,DRGI,FLAG,FQC,ND2,PRI,PSGOE,PSGPRI,PSGSDN,PSGOEDMR,PSGOEPR,PSGPTS,PSGTOL,PSGTOO,PSGUOW,PSJIVOF,PSJOCNT,PSJON,PSJORQF,PSJORTOU,PSJORVP
G:$G(PSGPXN) ^PSGPER1 D ENIVKV^PSGSETU
Q
;
HK ; Housekeeping (a nice COBOL term)
I PSGOP,PSGOP'=PSGP D
.N PSJACPF,PSJACNWP,PSJPWD,PSJSYSL,PSJSYSW,PSJSYSW0,DFN,VAIN,VAERR S DFN=PSGOP
.D INP^VADPT S PSJPWD=+VAIN(4) I PSJPWD S PSJACPF=10 D WP^PSJAC D:$P(PSJSYSL,"^",2)]"" ENQL^PSGLW
Q:PSGP<0
S (DFN,PSGOP)=PSGP,X=""
Q
;
SELECT ; Select order from list
N PSGLMT,PSGODDD,PSJLMQT,PSJLMFIN,PSJUDPRF,PSGRDTX K ^TMP("PSJCOM",$J),^TMP("PSJCOM2",$J)
S PSGONC=1,PSGLMT=^TMP("PSJPRO",$J,0) D ENASR^PSGON
I "^"[X S VALMQUIT=1 Q
S PSJLM=1,PSJSEL=0 F S PSJSEL=$O(PSGODDD(PSJSEL)) Q:'PSJSEL!($G(Y)<0) F PSJSEL1=1:1:$L(PSGODDD(PSJSEL),",")-1 D
.S PSJORD=$G(^TMP("PSJON",$J,+$P(PSGODDD(PSJSEL),",",PSJSEL1))) D:PSJORD=+PSJORD SELECT^PSJOEA Q:PSJORD=""!($G(Y)<0) Q:PSJORD=+PSJORD D
..Q:('$$LS^PSSLOCK(PSGP,PSJORD))
..Q:PSJORD=+PSJORD
..S PSGORD=""
..D DISACTIO(PSGP,PSJORD,"") S:PSJORD["V" PSJORD=ON
..D UNL^PSSLOCK(PSGP,PSJORD) Q:$G(Y)<0
S VALMBCK="Q"
K PSJLM
Q
;
DISACTIO(DFN,PSJORD,PSJPNV) ; Display UD order and allow actions.
; DFN - Patient IEN
; PSJORD - Order #_location Code (P:53.1,V:55.01,U:55.06)
; PSJPNV - Invoked from Pending/NV option; (gets different hidden menu)
N PSGP,PSJIVFLG,PSGSDX,PSGFDX,PSJXX1,ON55
D OLDCOM^PSJOE0(DFN,PSJORD)
S PSGP=DFN D ENIV^PSJAC I PSJORD["V" D EN^PSJLIORD(DFN,PSJORD) Q
D GETUD^PSJLMGUD(DFN,PSJORD)
S PSGOEAV=$P(PSJSYSP0,"^",9)&PSJSYSU
S:$G(PSJTUD) PSGPD=$G(PSJCOI),PSGPDN=$$OINAME^PSJLMUTL(+PSGPD)
K PSGOENG I '$D(PSGPRF) D Q:$G(PSGOENG)
. I PSJORD["U" L +^PS(55,PSGP,5,+PSJORD):1 E S PSGOENG=1
. I PSJORD["P" L +^PS(53.1,+PSJORD):1 E S PSGOENG=1
. I $G(PSGOENG) W !,"This order is being edited by another terminal.",! S PSGOENG=1 K DIR S DIR(0)="E" D ^DIR K DIR Q
S PSGACT=$$ENACTION^PSGOE1(PSGP,PSJORD)
I PSJORD["P" S PSJXX1=$G(^PS(53.1,+PSJORD,0)) I PSGP'=$P(PSJXX1,U,15)!(DFN'=$P(PSJXX1,U,15)) L -^PS(53.1,+PSJORD) Q
I PSJORD["P" D S PSJXX1=$P($G(^PS(53.1,+PSJORD,0)),U,9) I $S($G(PSJIVFLG):1,$G(Y)<0:1,"PADE"[PSJXX1:1,1:0) L -^PS(53.1,+PSJORD) Q
.I $P(PSJXX1,U,9)="N",($P(PSJXX1,U,4)'="U") D Q
.. S P("PON")=PSJORD,PSIVFLG=1
.. N ON S ON=PSJORD D VF^PSIVORC2
.I $P(PSJXX1,U,9)="P" D Q
..S:$G(PSJTUD) $P(PSJXX1,U,4)="U"
..I $P(PSJXX1,U,4)="U" D Q:$G(PSJIVFLG)
... N VAIP S CLINIC=$G(^PS(53.1,+PSJORD,"DSS")),APPT=$P(CLINIC,"^",2),CLINIC=$P(CLINIC,"^") I $$PATCH^XPDUTL("SD*5.3*285"),$$SDIMO^SDAMA203(CLINIC,DFN)>-1 Q
... Q:'PSJPDD W !!,"Cannot process an Out-patient Unit Dose order for ",$P($G(^DPT(+PSGP,0)),U) D PAUSE^VALM1 S PSJIVFLG=1
..NEW PSGRSD,PSGRSDN,PSGRFD,PSGRFDN
..D REQDT^PSJLIVMD(PSJORD)
..I $P(PSJXX1,U,4)="U",($G(PSGSCH)="") W !!,"Invalid schedule, can't finish this order" D PAUSE^VALM1 Q
..I $P(PSJXX1,U,4)="U" N PSJLM S PSJLM=1,PSGORD=PSJORD D START^PSGOEF,ENSFE^PSGOEE0(PSGP,PSGORD),@$S($G(PSJTUD):"FINISH^PSGOEF",1:"EN^VALM(""PSJ LM PENDING EDIT"")") Q
..I $P(PSJXX1,U,4)'="U",PSGP=$P(PSJXX1,U,15),DFN=$P(PSJXX1,U,15) S PSJLYN=PSJORD D EN^PSJLIFN S PSJIVFLG=1 K PSJLYN,PSJMAI
I $G(PSIVFLG) K PSIVFLG Q
S PSGACT=$$ENACTION^PSGOE1(PSGP,PSJORD),PSGOEEF=0 D GETUD^PSJLMGUD(PSGP,PSJORD),ENSFE^PSGOEE0(PSGP,PSJORD),EN^VALM("PSJ LM UD ACTION")
I PSJORD["P" L -^PS(53.1,+PSJORD)
I PSJORD["U" L -^PS(55,PSGP,5,+PSJORD)
;Send SN to CPRS if auto-verify OFF and Order Set Entry and no 21st piece
S PSGOEAV=$P(PSJSYSP0,"^",9)&PSJSYSU
I $D(PSGOES),'PSGOEAV,$D(PSGORD),PSGORD["P",$P($G(^PS(53.1,+PSGORD,0)),"^",21)']"" D ORSET^PSGOETO1
D UNL^PSSLOCK(PSGP,PSJORD)
Q
EDIT(PSGP,PSGORD,PROMPT) ;
I "DE"[$$GTSTATUS(PSGP,PSGORD) W !,"This order may not be edited." D PAUSE^VALM1 Q
I PSGACT'["E" W !,"This order may not be edited." D PAUSE^VALM1 Q
S PSGNEDFD="" D HOLDHDR,@$S('PROMPT:"ENEFA2^PSGON",1:"ENEFA^PSGON") I 'Y D ABORT^PSGOEE Q
I PSGORD["P" D ENF^PSGOEE Q
D ACT^PSGOEE
Q
RENEW(PSGP,PSGORD) ;
D HOLDHDR
I 'PSJSYSU,$P($G(^PS(55,PSGP,5,+PSGORD,4)),U,15),$P($G(^(4)),U,16) W !!,"This order is already marked for renewal!" D PAUSE^VALM1 S VALMBCK="R" Q
N OI S OI=+$G(^PS(55,PSGP,5,+PSGORD,.2)) I OI I '$$OI^APSPMULT(OI,+PSGP) W !!,"Sorry, this drug is not currently available in this facility" D PAUSE^VALM1 S VALMBCK="R" Q ;IHS/MSC/JDS - 11/20/2010
I 'PSGRRF D ^PSGOER Q
D ^PSGOERI
Q
;
GTSTATUS(DFN,ON) ;
I ON["P" Q $P($G(^PS(53.1,+ON,0)),U,9)
I ON["U" Q $P($G(^PS(55,DFN,5,+ON,0)),U,9)
Q $P($G(^PS(55,DFN,"IV",+ON,0)),U,17)
;
DC(DFN,PSJORD) ; DC IV, UD, or pending orders.
D HOLDHDR
S X=$$GTSTATUS(DFN,PSJORD) I X="D"!(X="DE")!(X="R") W !,$S(X="R":"This order has a pending renewal and cannot be DISCONTINUED.",1:"This order has already been DISCONTINUED.") D PAUSE^VALM1 Q
D ENO^PSGOEC(DFN,PSJORD) ;,GETUD^PSJLMGUD(DFN,PSJORD),INIT^PSJLMUDE(DFN,PSJORD) S VALMBCK="Q"
S VALMBCK="Q"
Q
HOLD(DFN,PSJORD) ; Change order's status from ACTIVE<->HOLD
D HOLDHDR
I PSJORD["V" D H^PSIVOPT(DFN,PSJORD,P(17),P(3))
I PSJORD'["V" D H^PSGOE1(DFN,PSJORD)
D GETUD^PSJLMGUD(DFN,PSJORD),INIT^PSJLMUDE(DFN,PSJORD) S PSGACT=$$ENACTION^PSGOE1(DFN,PSJORD),VALMBCK="R"
Q
;
COPY(PSGP,PSGORD) ; Copy an order (does not discontinue original order)
I $D(PSGCOPY) W !!,"You cannot copy the order at this time" D PAUSE^VALM1 Q
I PSGORD["P" W !!,"You cannot copy this "_$S($G(PSGSTAT)]"":PSGSTAT,1:"PENDING IV")_" order." D PAUSE^VALM1 Q
I PSGORD["V" D Q
.I $G(PSIVCOPY) W !!,"You cannot copy the order at this time" D PAUSE^VALM1 Q
.D COPY^PSIVOD(PSGP,PSGORD) Q
Q:'$$HIDDEN^PSJLMUTL("COPY")
I $T(OI^APSPMULT)]"" N OI S OI=+$G(^PS(55,PSGP,5,+PSGORD,.2)) I '$$OI^APSPMULT(OI,+$G(DFN)) W !!,"Sorry, this drug is not currently available in this facility" D PAUSE^VALM1 Q ;IHS/MSC/JDS - 12/09/10 - MDF
D ^PSJHVARS
I $P($G(^PS(55,PSGP,5,+PSGORD,.2)),U,4)="D",'$P($G(^(4)),"^",3) W !!,"Nurse verified orders with a priority of DONE may not be Copied." D PAUSE^VALM1 Q
S PSGOEAV=$P(PSJSYSP0,U,9)&PSJSYSU
S PSGCOPY=1
D FULL^VALM1,^PSGOD
S VALMBCK="R"
K PSGCOPY
S PSGACT=$$ENACTION^PSGOE1(PSGP,PSGORD) ; resets PSGACT after copy
I $G(PSGPXN) N PSGTMPXN S PSGTMPXN=PSGPXN
D RESTORE^PSJHVARS I $G(PSGTMPXN) S PSGPXN=PSGTMPXN
Q
;
UPDATE ; Refresh array, actions, & display.
D GETUD^PSJLMGUD(DFN,ON),INIT^PSJLMUDE(DFN,ON) S VALMBCK="R"
Q
FINISH ;
D FINISH^PSGOEF,PAUSE^VALM1
Q
;
LOG(DFN,PSGORD) ;
D FULL^VALM1,ENLM^PSGOEL(DFN,PSGORD),PAUSE^VALM1 S VALMBCK="R"
Q
NEWSEL ;
N PSGLMT,PSGODDD,PSJLMQT,PSJLMFIN,PSJUDPRF,PSGRDTX K ^TMP("PSJCOM",$J),^TMP("PSJCOM2",$J)
S X=$P(XQORNOD(0),"=",2)
S PSGONC=1,PSGLMT=^TMP("PSJPRO",$J,0)
D ENCHK^PSGON I '$O(PSGODDD(0)) S VALMQUIT=1 Q
S PSJLM=1,PSJSEL=0 F S PSJSEL=$O(PSGODDD(PSJSEL)) Q:'PSJSEL F PSJSEL1=1:1:$L(PSGODDD(PSJSEL),",")-1 D
.S PSJORD=$G(^TMP("PSJON",$J,+$P(PSGODDD(PSJSEL),",",PSJSEL1))) D:PSJORD=+PSJORD SELECT^PSJOEA
.Q:PSJORD=+PSJORD
.Q:PSJORD=""!($G(Y)<0) Q:('$$LS^PSSLOCK(PSGP,PSJORD)) D
..S PSGORD=""
..S ON=PSJORD
..D DISACTIO(PSGP,PSJORD,$G(PSJPNV)) S:PSJORD["V" PSJORD=ON
..D UNL^PSSLOCK(PSGP,PSJORD)
..I $G(PSJNOL) K PSJNOL I $D(ON),ON'=PSJORD D UNL^PSSLOCK(PSGP,ON)
..Q:$G(Y)<0
S VALMBCK="Q"
K PSJLM
Q
HOLDHDR ; Freeze header text while processing order actions
I $D(VALM("TM")) S IOTM=VALM("TM"),IOBM=IOSL W IOSC W @IOSTBM W IORC
Q
LOCKERR ;
W !!,$C(7),"You are entering or editing an Inpatient Medication order in another session.",!,"Only one order entry/edit session is allowed for a user at a time.",!! N DIR S DIR(0)="E" D ^DIR
Q
FLAG(DFN,PSJORD) ;Flag order through CPRS entry point.
N ORIFN,NODE0
S NODE0=$S(PSJORD["V":$G(^PS(55,DFN,"IV",+PSJORD,0)),PSJORD["U":$G(^PS(55,DFN,5,+PSJORD,0)),1:^PS(53.1,+PSJORD,0))
S ORIFN=$P(NODE0,"^",21)
D EN1^ORCFLAG(ORIFN)
D PAUSE^VALM1
Q
;
COMPLEX(DFN,ON) ;
N NDP2,COM
S NDP2=$S(ON["P":$G(^PS(53.1,+ON,.2)),ON["U":$G(^PS(55,DFN,5,+ON,.2)),ON["V":$G(^PS(55,DFN,"IV",+ON,.2)),1:"")
S COM=$P(NDP2,"^",8) I COM Q 1
Q 0
PSJOE ;BIR/MLM-INPATIENT ORDER ENTRY ;29-May-2012 14:38;PLS
+1 ;;5.0; INPATIENT MEDICATIONS ;**7,26,29,33,42,50,56,72,58,85,95,80,1009,1011,110,111,133,140,151,149,1015**;16 DEC 97;Build 62
+2 ;
+3 ; Reference to ^PS(55 is supported by DBIA #2191.
+4 ; Reference to EN^VALM is supported by DBIA #10118.
+5 ; Reference to FULL^VALM1 and PAUSE^VALM1 is supported by DBIA #10116.
+6 ; Reference to ^PSSLOCK is supported by DBIA #2789
+7 ; Reference to ^DPT is supported by DBIA #10035.
+8 ; Reference to ^ORCFLAG is supported by DBIA #3620.
+9 ; Reference to ^SDAMA203 is supported by DBIA #4133.
+10 ; 12/09/2010 - Line COPY+5
+11 ; IHS/MSC/PLS - 03/28/2011 - Line EN+5
EN ; Start Inpatient LM OE
+1 ; Modified - IHS/MSC/JDS - 11/20/2010 - Line RENEW+3
+2 NEW PSJLK,PSJNEWOE,PSJLMCON,PSJPROT,XQORS,VALMEVL
DO ENCV^PSGSETU
DO ^PSIVXU
+3 IF $DATA(XQUIT)
KILL XQUIT
GOTO DONE
+4 KILL PSGVBY,PSJPR
SET (PSJOL,PSJACOK,PSGOP,PSGNEF,PSGOEAV,PSGPXN)=""
LOCK +^PS(53.45,PSJSYSP):1
IF '$TEST
DO LOCKERR^PSJOE
GOTO DONE^PSJOE
+5 FOR
SET (PSJLMCON,PSGPTMP)=0
DO ^PSJP
DO HK
IF PSGP'>0
QUIT
SET PSJPROT=3
SET DFN=PSGP
DO ^PSJAC
Begin DoDot:1
+6 ;IHS/MSC/PLS - 03/28/11
DO SETPTCX^APSPFUNC(PSGP)
+7 KILL ^TMP("PSJ",$JOB)
+8 SET PSJLK=$$L^PSSLOCK(PSGP,1)
IF 'PSJLK
WRITE !,$CHAR(7),$PIECE(PSJLK,U,2)
QUIT
+9 KILL PSJLMPRO
DO EN^VALM("PSJ LM BRIEF PATIENT INFO")
+10 NEW NXTPT
SET NXTPT=0
FOR
IF $GET(NXTPT)
QUIT
Begin DoDot:2
+11 KILL PSGRDTX
+12 IF $GET(PSJLMCON)!$GET(PSJNEWOE)
Begin DoDot:3
+13 SET PSJOL=$SELECT(",S,L,"[(","_$GET(PSJOL)_","):PSJOL,1:"S")
+14 SET PSJLMPRO=1
SET PSJLMCON=1
SET PSJNEWOE=0
DO EN^VALM("PSJ LM OE")
End DoDot:3
+15 IF $GET(PSJNEWOE)!($GET(VALMBCK)="Q")
SET PSJNEWOE=0
QUIT
+16 IF $GET(PSJLMCON)&$GET(PSJLMPRO)&'$DATA(^TMP("PSJ",$JOB))
Begin DoDot:3
+17 SET PSJLMCON=0
SET PSJLMPRO=0
DO EN^VALM("PSJ LM BRIEF PATIENT INFO")
+18 IF $GET(PSJNEWOE)
SET NXTPT=0
QUIT
+19 SET NXTPT=1
End DoDot:3
QUIT
+20 SET NXTPT=1
SET PSJNEWOE=0
End DoDot:2
+21 SET PSJOL="S"
+22 IF $GET(PSGPXN)
IF $PIECE(PSJSYSW0,U,29)]""!($GET(PSJCOM))
SET PSGPXPT=PSGP
Begin DoDot:2
+23 NEW DFN,PSGP,PSJPXDP
+24 IF $PIECE(PSJSYSW0,U,29)=""
SET PSJPDXP=1
Begin DoDot:3
+25 NEW IO,ION,IOS
DO HOME^%ZIS
SET $PIECE(PSJSYSW0,U,29)=+$GET(IOS)
End DoDot:3
+26 SET (PSGP,DFN)=PSGPXPT
DO ^PSGPER
IF $GET(PSJPDXP)
SET $PIECE(PSJSYSW0,U,29)=""
KILL PSJPDXP
End DoDot:2
KILL PSGPXPT
SET PSGPXN=0
+27 DO ENCV^PSGSETU
DO ^PSIVXU
End DoDot:1
IF PSJLK
DO UL^PSSLOCK(PSGP)
+28 KILL PSJLMPRO,^TMP("PSJPRO",$JOB),^TMP("PSJ",$JOB),^TMP("PSJON",$JOB)
+29 ;
DONE ;
+1 KILL AC,ACTION,D1,D2,MI,N,ON,P3,PNOW,PSIVAT,PSIVLN,PSIVSTR
LOCK -^PS(53.45,PSJSYSP)
+2 KILL DA,DRG,NE,PSGCF,PSGCANFL,PSGNEDFD,PSGNEF,PSGNEFD,PSGNEPR,PSGNESD,PSJACOK,PSJOE,PSJOECNT,PSJOEPF,PSJORD,PSGOEA,PSGOEAV,PSGOL,PSGOS,PSGON,PSGOP,PSGORD,PSGS0XT,PSGS0Y,RCT,ST,WD,XREF,Z,PSJIVORF,PSJIVPCL
+3 KILL PSGOEORF,PSIVREA,PSJOPC,PSJORL,PSJORPCL,PSJORTOI,RF,WSCHADM,PSJLM,PSJCT
+4 KILL DIU,DRGI,FLAG,FQC,ND2,PRI,PSGOE,PSGPRI,PSGSDN,PSGOEDMR,PSGOEPR,PSGPTS,PSGTOL,PSGTOO,PSGUOW,PSJIVOF,PSJOCNT,PSJON,PSJORQF,PSJORTOU,PSJORVP
+5 IF $GET(PSGPXN)
GOTO ^PSGPER1
DO ENIVKV^PSGSETU
+6 QUIT
+7 ;
HK ; Housekeeping (a nice COBOL term)
+1 IF PSGOP
IF PSGOP'=PSGP
Begin DoDot:1
+2 NEW PSJACPF,PSJACNWP,PSJPWD,PSJSYSL,PSJSYSW,PSJSYSW0,DFN,VAIN,VAERR
SET DFN=PSGOP
+3 DO INP^VADPT
SET PSJPWD=+VAIN(4)
IF PSJPWD
SET PSJACPF=10
DO WP^PSJAC
IF $PIECE(PSJSYSL,"^",2)]""
DO ENQL^PSGLW
End DoDot:1
+4 IF PSGP<0
QUIT
+5 SET (DFN,PSGOP)=PSGP
SET X=""
+6 QUIT
+7 ;
SELECT ; Select order from list
+1 NEW PSGLMT,PSGODDD,PSJLMQT,PSJLMFIN,PSJUDPRF,PSGRDTX
KILL ^TMP("PSJCOM",$JOB),^TMP("PSJCOM2",$JOB)
+2 SET PSGONC=1
SET PSGLMT=^TMP("PSJPRO",$JOB,0)
DO ENASR^PSGON
+3 IF "^"[X
SET VALMQUIT=1
QUIT
+4 SET PSJLM=1
SET PSJSEL=0
FOR
SET PSJSEL=$ORDER(PSGODDD(PSJSEL))
IF 'PSJSEL!($GET(Y)<0)
QUIT
FOR PSJSEL1=1:1:$LENGTH(PSGODDD(PSJSEL),",")-1
Begin DoDot:1
+5 SET PSJORD=$GET(^TMP("PSJON",$JOB,+$PIECE(PSGODDD(PSJSEL),",",PSJSEL1)))
IF PSJORD=+PSJORD
DO SELECT^PSJOEA
IF PSJORD=""!($GET(Y)<0)
QUIT
IF PSJORD=+PSJORD
QUIT
Begin DoDot:2
+6 IF ('$$LS^PSSLOCK(PSGP,PSJORD))
QUIT
+7 IF PSJORD=+PSJORD
QUIT
+8 SET PSGORD=""
+9 DO DISACTIO(PSGP,PSJORD,"")
IF PSJORD["V"
SET PSJORD=ON
+10 DO UNL^PSSLOCK(PSGP,PSJORD)
IF $GET(Y)<0
QUIT
End DoDot:2
End DoDot:1
+11 SET VALMBCK="Q"
+12 KILL PSJLM
+13 QUIT
+14 ;
DISACTIO(DFN,PSJORD,PSJPNV) ; Display UD order and allow actions.
+1 ; DFN - Patient IEN
+2 ; PSJORD - Order #_location Code (P:53.1,V:55.01,U:55.06)
+3 ; PSJPNV - Invoked from Pending/NV option; (gets different hidden menu)
+4 NEW PSGP,PSJIVFLG,PSGSDX,PSGFDX,PSJXX1,ON55
+5 DO OLDCOM^PSJOE0(DFN,PSJORD)
+6 SET PSGP=DFN
DO ENIV^PSJAC
IF PSJORD["V"
DO EN^PSJLIORD(DFN,PSJORD)
QUIT
+7 DO GETUD^PSJLMGUD(DFN,PSJORD)
+8 SET PSGOEAV=$PIECE(PSJSYSP0,"^",9)&PSJSYSU
+9 IF $GET(PSJTUD)
SET PSGPD=$GET(PSJCOI)
SET PSGPDN=$$OINAME^PSJLMUTL(+PSGPD)
+10 KILL PSGOENG
IF '$DATA(PSGPRF)
Begin DoDot:1
+11 IF PSJORD["U"
LOCK +^PS(55,PSGP,5,+PSJORD):1
IF '$TEST
SET PSGOENG=1
+12 IF PSJORD["P"
LOCK +^PS(53.1,+PSJORD):1
IF '$TEST
SET PSGOENG=1
+13 IF $GET(PSGOENG)
WRITE !,"This order is being edited by another terminal.",!
SET PSGOENG=1
KILL DIR
SET DIR(0)="E"
DO ^DIR
KILL DIR
QUIT
End DoDot:1
IF $GET(PSGOENG)
QUIT
+14 SET PSGACT=$$ENACTION^PSGOE1(PSGP,PSJORD)
+15 IF PSJORD["P"
SET PSJXX1=$GET(^PS(53.1,+PSJORD,0))
IF PSGP'=$PIECE(PSJXX1,U,15)!(DFN'=$PIECE(PSJXX1,U,15))
LOCK -^PS(53.1,+PSJORD)
QUIT
+16 IF PSJORD["P"
Begin DoDot:1
+17 IF $PIECE(PSJXX1,U,9)="N"
IF ($PIECE(PSJXX1,U,4)'="U")
Begin DoDot:2
+18 SET P("PON")=PSJORD
SET PSIVFLG=1
+19 NEW ON
SET ON=PSJORD
DO VF^PSIVORC2
End DoDot:2
QUIT
+20 IF $PIECE(PSJXX1,U,9)="P"
Begin DoDot:2
+21 IF $GET(PSJTUD)
SET $PIECE(PSJXX1,U,4)="U"
+22 IF $PIECE(PSJXX1,U,4)="U"
Begin DoDot:3
+23 NEW VAIP
SET CLINIC=$GET(^PS(53.1,+PSJORD,"DSS"))
SET APPT=$PIECE(CLINIC,"^",2)
SET CLINIC=$PIECE(CLINIC,"^")
IF $$PATCH^XPDUTL("SD*5.3*285")
IF $$SDIMO^SDAMA203(CLINIC,DFN)>-1
QUIT
+24 IF 'PSJPDD
QUIT
WRITE !!,"Cannot process an Out-patient Unit Dose order for ",$PIECE($GET(^DPT(+PSGP,0)),U)
DO PAUSE^VALM1
SET PSJIVFLG=1
End DoDot:3
IF $GET(PSJIVFLG)
QUIT
+25 NEW PSGRSD,PSGRSDN,PSGRFD,PSGRFDN
+26 DO REQDT^PSJLIVMD(PSJORD)
+27 IF $PIECE(PSJXX1,U,4)="U"
IF ($GET(PSGSCH)="")
WRITE !!,"Invalid schedule, can't finish this order"
DO PAUSE^VALM1
QUIT
+28 IF $PIECE(PSJXX1,U,4)="U"
NEW PSJLM
SET PSJLM=1
SET PSGORD=PSJORD
DO START^PSGOEF
DO ENSFE^PSGOEE0(PSGP,PSGORD)
DO @$SELECT($GET(PSJTUD):"FINISH^PSGOEF",1:"EN^VALM(""PSJ LM PENDING EDIT"")")
QUIT
+29 IF $PIECE(PSJXX1,U,4)'="U"
IF PSGP=$PIECE(PSJXX1,U,15)
IF DFN=$PIECE(PSJXX1,U,15)
SET PSJLYN=PSJORD
DO EN^PSJLIFN
SET PSJIVFLG=1
KILL PSJLYN,PSJMAI
End DoDot:2
QUIT
End DoDot:1
SET PSJXX1=$PIECE($GET(^PS(53.1,+PSJORD,0)),U,9)
IF $SELECT($GET(PSJIVFLG):1,$GET(Y)<0:1,"PADE"[PSJXX1:1,1:0)
LOCK -^PS(53.1,+PSJORD)
QUIT
+30 IF $GET(PSIVFLG)
KILL PSIVFLG
QUIT
+31 SET PSGACT=$$ENACTION^PSGOE1(PSGP,PSJORD)
SET PSGOEEF=0
DO GETUD^PSJLMGUD(PSGP,PSJORD)
DO ENSFE^PSGOEE0(PSGP,PSJORD)
DO EN^VALM("PSJ LM UD ACTION")
+32 IF PSJORD["P"
LOCK -^PS(53.1,+PSJORD)
+33 IF PSJORD["U"
LOCK -^PS(55,PSGP,5,+PSJORD)
+34 ;Send SN to CPRS if auto-verify OFF and Order Set Entry and no 21st piece
+35 SET PSGOEAV=$PIECE(PSJSYSP0,"^",9)&PSJSYSU
+36 IF $DATA(PSGOES)
IF 'PSGOEAV
IF $DATA(PSGORD)
IF PSGORD["P"
IF $PIECE($GET(^PS(53.1,+PSGORD,0)),"^",21)']""
DO ORSET^PSGOETO1
+37 DO UNL^PSSLOCK(PSGP,PSJORD)
+38 QUIT
EDIT(PSGP,PSGORD,PROMPT) ;
+1 IF "DE"[$$GTSTATUS(PSGP,PSGORD)
WRITE !,"This order may not be edited."
DO PAUSE^VALM1
QUIT
+2 IF PSGACT'["E"
WRITE !,"This order may not be edited."
DO PAUSE^VALM1
QUIT
+3 SET PSGNEDFD=""
DO HOLDHDR
DO @$SELECT('PROMPT:"ENEFA2^PSGON",1:"ENEFA^PSGON")
IF 'Y
DO ABORT^PSGOEE
QUIT
+4 IF PSGORD["P"
DO ENF^PSGOEE
QUIT
+5 DO ACT^PSGOEE
+6 QUIT
RENEW(PSGP,PSGORD) ;
+1 DO HOLDHDR
+2 IF 'PSJSYSU
IF $PIECE($GET(^PS(55,PSGP,5,+PSGORD,4)),U,15)
IF $PIECE($GET(^(4)),U,16)
WRITE !!,"This order is already marked for renewal!"
DO PAUSE^VALM1
SET VALMBCK="R"
QUIT
+3 ;IHS/MSC/JDS - 11/20/2010
NEW OI
SET OI=+$GET(^PS(55,PSGP,5,+PSGORD,.2))
IF OI
IF '$$OI^APSPMULT(OI,+PSGP)
WRITE !!,"Sorry, this drug is not currently available in this facility"
DO PAUSE^VALM1
SET VALMBCK="R"
QUIT
+4 IF 'PSGRRF
DO ^PSGOER
QUIT
+5 DO ^PSGOERI
+6 QUIT
+7 ;
GTSTATUS(DFN,ON) ;
+1 IF ON["P"
QUIT $PIECE($GET(^PS(53.1,+ON,0)),U,9)
+2 IF ON["U"
QUIT $PIECE($GET(^PS(55,DFN,5,+ON,0)),U,9)
+3 QUIT $PIECE($GET(^PS(55,DFN,"IV",+ON,0)),U,17)
+4 ;
DC(DFN,PSJORD) ; DC IV, UD, or pending orders.
+1 DO HOLDHDR
+2 SET X=$$GTSTATUS(DFN,PSJORD)
IF X="D"!(X="DE")!(X="R")
WRITE !,$SELECT(X="R":"This order has a pending renewal and cannot be DISCONTINUED.",1:"This order has already been DISCONTINUED.")
DO PAUSE^VALM1
QUIT
+3 ;,GETUD^PSJLMGUD(DFN,PSJORD),INIT^PSJLMUDE(DFN,PSJORD) S VALMBCK="Q"
DO ENO^PSGOEC(DFN,PSJORD)
+4 SET VALMBCK="Q"
+5 QUIT
HOLD(DFN,PSJORD) ; Change order's status from ACTIVE<->HOLD
+1 DO HOLDHDR
+2 IF PSJORD["V"
DO H^PSIVOPT(DFN,PSJORD,P(17),P(3))
+3 IF PSJORD'["V"
DO H^PSGOE1(DFN,PSJORD)
+4 DO GETUD^PSJLMGUD(DFN,PSJORD)
DO INIT^PSJLMUDE(DFN,PSJORD)
SET PSGACT=$$ENACTION^PSGOE1(DFN,PSJORD)
SET VALMBCK="R"
+5 QUIT
+6 ;
COPY(PSGP,PSGORD) ; Copy an order (does not discontinue original order)
+1 IF $DATA(PSGCOPY)
WRITE !!,"You cannot copy the order at this time"
DO PAUSE^VALM1
QUIT
+2 IF PSGORD["P"
WRITE !!,"You cannot copy this "_$SELECT($GET(PSGSTAT)]"":PSGSTAT,1:"PENDING IV")_" order."
DO PAUSE^VALM1
QUIT
+3 IF PSGORD["V"
Begin DoDot:1
+4 IF $GET(PSIVCOPY)
WRITE !!,"You cannot copy the order at this time"
DO PAUSE^VALM1
QUIT
+5 DO COPY^PSIVOD(PSGP,PSGORD)
QUIT
End DoDot:1
QUIT
+6 IF '$$HIDDEN^PSJLMUTL("COPY")
QUIT
+7 ;IHS/MSC/JDS - 12/09/10 - MDF
IF $TEXT(OI^APSPMULT)]""
NEW OI
SET OI=+$GET(^PS(55,PSGP,5,+PSGORD,.2))
IF '$$OI^APSPMULT(OI,+$GET(DFN))
WRITE !!,"Sorry, this drug is not currently available in this facility"
DO PAUSE^VALM1
QUIT
+8 DO ^PSJHVARS
+9 IF $PIECE($GET(^PS(55,PSGP,5,+PSGORD,.2)),U,4)="D"
IF '$PIECE($GET(^(4)),"^",3)
WRITE !!,"Nurse verified orders with a priority of DONE may not be Copied."
DO PAUSE^VALM1
QUIT
+10 SET PSGOEAV=$PIECE(PSJSYSP0,U,9)&PSJSYSU
+11 SET PSGCOPY=1
+12 DO FULL^VALM1
DO ^PSGOD
+13 SET VALMBCK="R"
+14 KILL PSGCOPY
+15 ; resets PSGACT after copy
SET PSGACT=$$ENACTION^PSGOE1(PSGP,PSGORD)
+16 IF $GET(PSGPXN)
NEW PSGTMPXN
SET PSGTMPXN=PSGPXN
+17 DO RESTORE^PSJHVARS
IF $GET(PSGTMPXN)
SET PSGPXN=PSGTMPXN
+18 QUIT
+19 ;
UPDATE ; Refresh array, actions, & display.
+1 DO GETUD^PSJLMGUD(DFN,ON)
DO INIT^PSJLMUDE(DFN,ON)
SET VALMBCK="R"
+2 QUIT
FINISH ;
+1 DO FINISH^PSGOEF
DO PAUSE^VALM1
+2 QUIT
+3 ;
LOG(DFN,PSGORD) ;
+1 DO FULL^VALM1
DO ENLM^PSGOEL(DFN,PSGORD)
DO PAUSE^VALM1
SET VALMBCK="R"
+2 QUIT
NEWSEL ;
+1 NEW PSGLMT,PSGODDD,PSJLMQT,PSJLMFIN,PSJUDPRF,PSGRDTX
KILL ^TMP("PSJCOM",$JOB),^TMP("PSJCOM2",$JOB)
+2 SET X=$PIECE(XQORNOD(0),"=",2)
+3 SET PSGONC=1
SET PSGLMT=^TMP("PSJPRO",$JOB,0)
+4 DO ENCHK^PSGON
IF '$ORDER(PSGODDD(0))
SET VALMQUIT=1
QUIT
+5 SET PSJLM=1
SET PSJSEL=0
FOR
SET PSJSEL=$ORDER(PSGODDD(PSJSEL))
IF 'PSJSEL
QUIT
FOR PSJSEL1=1:1:$LENGTH(PSGODDD(PSJSEL),",")-1
Begin DoDot:1
+6 SET PSJORD=$GET(^TMP("PSJON",$JOB,+$PIECE(PSGODDD(PSJSEL),",",PSJSEL1)))
IF PSJORD=+PSJORD
DO SELECT^PSJOEA
+7 IF PSJORD=+PSJORD
QUIT
+8 IF PSJORD=""!($GET(Y)<0)
QUIT
IF ('$$LS^PSSLOCK(PSGP,PSJORD))
QUIT
Begin DoDot:2
+9 SET PSGORD=""
+10 SET ON=PSJORD
+11 DO DISACTIO(PSGP,PSJORD,$GET(PSJPNV))
IF PSJORD["V"
SET PSJORD=ON
+12 DO UNL^PSSLOCK(PSGP,PSJORD)
+13 IF $GET(PSJNOL)
KILL PSJNOL
IF $DATA(ON)
IF ON'=PSJORD
DO UNL^PSSLOCK(PSGP,ON)
+14 IF $GET(Y)<0
QUIT
End DoDot:2
End DoDot:1
+15 SET VALMBCK="Q"
+16 KILL PSJLM
+17 QUIT
HOLDHDR ; Freeze header text while processing order actions
+1 IF $DATA(VALM("TM"))
SET IOTM=VALM("TM")
SET IOBM=IOSL
WRITE IOSC
WRITE @IOSTBM
WRITE IORC
+2 QUIT
LOCKERR ;
+1 WRITE !!,$CHAR(7),"You are entering or editing an Inpatient Medication order in another session.",!,"Only one order entry/edit session is allowed for a user at a time.",!!
NEW DIR
SET DIR(0)="E"
DO ^DIR
+2 QUIT
FLAG(DFN,PSJORD) ;Flag order through CPRS entry point.
+1 NEW ORIFN,NODE0
+2 SET NODE0=$SELECT(PSJORD["V":$GET(^PS(55,DFN,"IV",+PSJORD,0)),PSJORD["U":$GET(^PS(55,DFN,5,+PSJORD,0)),1:^PS(53.1,+PSJORD,0))
+3 SET ORIFN=$PIECE(NODE0,"^",21)
+4 DO EN1^ORCFLAG(ORIFN)
+5 DO PAUSE^VALM1
+6 QUIT
+7 ;
COMPLEX(DFN,ON) ;
+1 NEW NDP2,COM
+2 SET NDP2=$SELECT(ON["P":$GET(^PS(53.1,+ON,.2)),ON["U":$GET(^PS(55,DFN,5,+ON,.2)),ON["V":$GET(^PS(55,DFN,"IV",+ON,.2)),1:"")
+3 SET COM=$PIECE(NDP2,"^",8)
IF COM
QUIT 1
+4 QUIT 0