Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: PSJOE

PSJOE.m

Go to the documentation of this file.
PSJOE ;BIR/MLM - INPATIENT ORDER ENTRY ;Jan 14, 2021@10:49:31
 ;;5.0;INPATIENT MEDICATIONS;**7,26,29,33,42,50,56,72,58,85,95,80,110,111,133,140,151,149,181,252,281,315,256,344,327,319,411,364**;16 DEC 97;Build 47
 ;Per VHA Directive 2004-038, this routine should not be modified.
 ; Reference to ^PS(55 via DBIA 2191
 ; Reference to EN^VALM via DBIA 10118
 ; Reference to FULL^VALM1 via DBIA 10116
 ; Reference to PAUSE^VALM1 via DBIA 10116
 ; Reference to ^PSSLOCK via DBIA 2789
 ; Reference to ^DPT( via DBIA 10035
 ; Reference to ^ORCFLAG via DBIA #3620
 ; Reference to ^SDAMA203 via DBIA #4133
 ; Reference to ^TMP("PSODAOC" via DBIA 6071
 ;
 ;*364 - add Hazardous Handle & Dispose flags alert message.
 ;
EN ; Start Inpatient LM OE
 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)
 .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)
 ...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 ;
 ; -- RTC 198753 - correct typo - r PSJALGSV w PSJAGYSV
 K PSJAGYSV,PSJEXCPT,PSJOCER,^TMP($J,"PSJPRE"),^TMP("PSODAOC",$J),^TMP("PSJDAOC",$J)
 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
 K PSIVENO,PSGRMV,PSGRMVT,PSGDUR,PSGRF,ND2P1 ;*315
 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
 ;Variable PSJOCDSC is used in Complex order dosing checks
 N PSGLMT,PSGODDD,PSJLMQT,PSJLMFIN,PSJUDPRF,PSGRDTX,PSJOCDSC,PSJAGYSV K ^TMP("PSJCOM",$J),^TMP("PSJCOM2",$J),PSJSTARI,^TMP("PSODAOC",$J),^TMP("PSJDAOC",$J)
 K PSGDUR,PSGRMVT,PSGRMV,PSGRF,ND2P1 ;*315
 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
 .K PSJOCDSC
 .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,PSJOCDSC
 Q
DISACTIO(DFN,PSJORD,PSJPNV)       ; Display UD order and allow actions.
 ; PSJORD - Order #_location Code (P:53.1,V:55.01,U:55.06)
 ; PSJPNV - Invoked from Pending/NV option; (gets different hidden menu)
 ; PSJDSVFY - Flag if non-vf order was edited
 ; PSJENHOC=1 if DI,DT were display. This will be used by dosing OC to check if error messages should display or not
 ; PSJAGYSV=1 If UD was edited
 ;N PSGP,PSJIVFLG,PSGSDX,PSGFDX,PSJXX1,ON55,PSJDSVFY,PSJENHOC,PSJAGYSV
 N PSGP,PSJIVFLG,PSGSDX,PSGFDX,PSJXX1,ON55,PSJDSVFY,PSJENHOC,PSIVENO,PSJBACK
 K PSGDUR,PSGRMVT,PSGRMV,PSGRF,ND2P1 ;*315
 K PSJEXCPT("PROSPECTIVE") ;*256
 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
 .K:$P($G(PSJXX1),U,4)="U" PSIVFLG ;p344
 .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") S PSJBACK=$$SDIMO^SDAMA203(CLINIC,DFN) I PSJBACK'<-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,PSJOCFG S PSJLM=1,PSGORD=PSJORD,PSJOCFG="FN UD" D START^PSGOEF,ENSFE^PSGOEE0(PSGP,PSGORD) S:$G(PSJTUD) PSJOCFG="FN UD" D @$S($G(PSJTUD):"FINISH^PSGOEF",1:"EN^VALM(""PSJ LM PENDING EDIT"")") K PSJOCFG Q
 ..I $P(PSJXX1,U,4)'="U",PSGP=$P(PSJXX1,U,15),DFN=$P(PSJXX1,U,15) S PSJLYN=PSJORD,PSJOCFG="FN IV" D EN^PSJLIFN S PSJIVFLG=1 K PSJLYN,PSJMAI,PSJOCFG
 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
 I $G(PSGOEAV),($G(PSGOES)=1) D SETOC ;Store allergy for order set /w auto vf
 I '$G(PSGOEAV),($G(PSJORD)["P"),$S($G(PSJAGYSV):1,($G(PSJOCFG)="NEW UD"):1,1:0) D SETOC
 ; -- RTC 236646
 K ^TMP("PSODAOC",$J,"ALLERGY")
 D UNL^PSSLOCK(PSGP,PSJORD)
 Q
SETOC ;
 ;RTC 178789
 S ^TMP("PSODAOC",$J,"IP IEN")=PSJORD
 D SETOC^PSJNEWOC(PSJORD)
 K ^TMP("PSODAOC",$J),^TMP("PSJDAOC",$J),PSJAGYSV,PSJOCFG
 Q
EDIT(PSGP,PSGORD,PROMPT) ;
 N PSJOP,ANQX,PSGEDT
 S (ANQX,PSJOP)=0,PSGEDT=1
 S PSJOP=+Y(1)
 S PSJOP=$S(PSJOP=9:0,PSJOP=11:0,1:1)
 ;/RBN Begin modification for NCC moved code to ACT^PSGOEE
 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
 N PSJEDITO S PSJEDITO=1
 S PSJAGYSV=1 ;Flag to store allergy data in 100.05.
 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) ;
 ;PSJOCFG - If defined, it's for new order, renew or copy. ^PSJOCDSD using this flag to not display drug error.
 ;/RJS Begin modifications for PSJ*5.0*327
 I $$ISCLOZ^PSJCLOZ(,,PSGP,+PSGORD) D  Q
 .W !,"Clozapine orders cannot be renewed."
 .W !,"No order entered!"
 .D PAUSE^VALM1
 ;/RJS End modifications for PSJ*5.0*327
 NEW PSJOCFG
 S PSJOCFG="RENEW UD"
 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
 I 'PSGRRF D ^PSGOER K PSJOCFG Q
 D ^PSGOERI
 K PSJOCFG
 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)
 N PSJOCFG
 ; PSJ*5*327 - disallow copy for clozapine
 I $D(^PS(55,PSGP,5,+PSGORD,"SAND")) W !!,"You cannot copy a clozapine order." D PAUSE^VALM1 Q
 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
 .S PSJOCFG="COPY IV"
 .D COPY^PSIVOD(PSGP,PSGORD) K PSJOCFG Q
 Q:'$$HIDDEN^PSJLMUTL("COPY")
 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 PSJOCFG="COPY UD"
 S PSGOEAV=$P(PSJSYSP0,U,9)&PSJSYSU
 S PSGCOPY=1,ANQX=0
 D FULL^VALM1,^PSGOD
 ;/RBN Begin modifications PSJ*5.0*327
 I $G(ANQX) K PSGCOPY Q
 ;/RBN End modifications PSJ*5.0*327
 S VALMBCK="R"
 K PSGCOPY,PSJOCFG
 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,PSJOCDSC,PSJAGYSV K ^TMP("PSJCOM",$J),^TMP("PSJCOM2",$J),^TMP("PSODAOC",$J),^TMP("PSJDAOC",$J)
 K PSGRMVT,PSGRMV,PSGDUR,PSGRF,ND2P1,PSGOROE1
 K PSGDRG,PSGDRGN  ;*364
 ;; START NCC REMEDIATION >> 327*RJS  ; Freeze header text while processing order actions
 S IOTM=VALM("TM"),IOBM=IOSL W IOSC W @IOSTBM W IORC
 ;; END NCC REMEDIATION << 327*RJS
 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
 .K PSJOCDSC,PSGDRG
 .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
 I '$G(PSGOEAV),($G(PSJORD)["P"),$G(PSJAGYSV) D
 .;RTC 178789
 .S ^TMP("PSODAOC",$J,"IP IEN")=PSJORD
 .D SETOC^PSJNEWOC(PSJORD)
 .K ^TMP("PSODAOC",$J),^TMP("PSJDAOC",$J),PSJAGYSV
 S VALMBCK="Q"
 K PSJLM,PSJOCDSC
 ;*P319
 K PSJCLAPP,P("APPT"),P("CLIN"),PSJCMO,PSJCM01,P("PON")
 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
CLOZSND ; SEND CLOZAPINE OVERRIDE MESSAGE AND ORDER TO HINES DB
 ; START NCC REMEDIATION >> 327*RJS
 D PSJFILE^PSJCLOZ(DFN),INPSND^YSCLTST5
 ; END NCC REMEDIATION << 327*RJS
 Q