PSOBBC ;IHS/DSD/JCM-BATCH BARCODE DRIVER ;26-Aug-2013 15:36;PLS
;;7.0;OUTPATIENT PHARMACY;**11,22,27,34,46,130,146,1004,1005,185,242,264,300,1015,1016**;DEC 1997;Build 74
;External reference to ^IBE(350.1,"ANEW" supported by DBIA 592
;External references CHPUS^IBACUS and TRI^IBACUS supported by DBIA 2030
;External references LK^ORX2 and ULK^ORX2 supported by DBIA 867
;External references ^PS(55 supported by DBIA 2228
;External references U, UL, PSOL, and PSOUL^PSSLOCK supported by DBIA 2789
;PSO*242 change default to from Q to S
;-------------------------------------------------------------------
; Modified - IHS/CIA/PLS - 01/16/04 - Line PROCESSX
; 06/24/05 - Line PROCESSX+5
; Line REFILL+2, REFILL+3
; New IHSFLDS API
; IHS/MSC/PLS 05/27/06 - Line PT+3 - AudioCare Support
; 08/01/13 - Line PROCESSX+8
; 08/26/13 - Line SUSP+4
START ;
N PSODFN,PSOBBCNO
D INIT I '$D(PSOPAR) D ^PSOLSET G:'$D(PSOPAR) EOJ
I $G(PSOSITE) S PSOBARID=$G(^PS(59,PSOSITE,"IB")) I '$D(^IBE(350.1,"ANEW",+PSOBARID,1,1)) D S PSORX("QFLG")=1 K PSOBARID G END
.W $C(7),!!,"WARNING: Pharmacy Copay not working,",!,?10,"Check IB SERVICE/SECTION in Pharmacy Site File.",!!!,"You will not be able to enter any new prescriptions until this is corrected!"
S PSOBBC("QFLG")=0,PSORX("BAR CODE")=1
D FROM I PSOBBC("QFLG") S PSORX("QFLG")=1 G END
D ASK I PSOBBC("QFLG") S PSORX("QFLG")=1 G END
D PROCESS
END D EOJ
Q
;--------------------------------------------------------------------
INIT ;
S PSOBBC("QFLG")=0,PSORX("BAR CODE")=1 K PPL
I '$G(PSOINST) D
.K DIC,DR,DIQ S DA=$P($$SITE^VASITE(),"^") I DA D
..K PSOINST S DIC=4,DIQ(0)="I",DR=99,DIQ="PSOINST" D EN^DIQ1
..S PSOINST=PSOINST(4,DA,99,"I") K DIC,DA,DIQ,PSOINST(4)
Q
FROM ;
S DIR(0)="S^1:REFILLS;2:RENEWS;"
S DIR("A")="Batch Barcode for",DIR("B")="REFILLS"
D DIR G:'Y FROMX
S PSOBBC1("FROM")=$S(Y=1:"REFILL",1:"NEW")
FROMX K X,Y,DIR
Q
;
ASK ;
K BINGCRT,BINGRTE,BBRX
W !,"Please answer the following for this session of prescriptions",!
D EN^PSOREF2(.PSOBBC) I PSOBBC("DFLG") S PSOBBC("QFLG")=1 G ASKX
D SUSP
D INPT,CNH
D:'$P($G(PSOPAR),"^",6) EARLY
D SET
D:PSOBBC1("FROM")="NEW" NOORE^PSONEW(.PSOBBC) S:$G(PSOBBC("NOO"))'="" PSOBBCNO=$G(PSOBBC("NOO")) S:$G(PSOBBC("DFLG")) PSOBBC("QFLG")=1
ASKX Q
;
SUSP ;
S DIR(0)="SAB^Q:QUEUED;S:SUSPENDED"
S DIR("A")="Will these refills be Queued or Suspended ? "
;S DIR("B")="S" ;PSO*242
S DIR("B")="Q" ;IHS/MSC/PLS - 08/26/13
D DIR G:PSOBBC("QFLG") SUSPX
S (PSOBBC1("QS"),PSOBBC("QS"))=Y S:PSOBBC1("QS")="S" BINGCRT=0
SUSPX K X,Y,DIR
Q
;
INPT ;
S DIR(0)="YA"
S DIR("A")="Allow refills for inpatient ? "
S DIR("B")="N"
D DIR G:PSOBBC("QFLG") INPTX
S (PSOBBC1("INOK"),PSOBBC("INOK"))=Y
INPTX K X,Y,DIR
Q
CNH ;
S DIR(0)="YA"
S DIR("A")="Allow refills for CNH ? "
S DIR("B")="N"
D DIR G:PSOBBC("QFLG") CNHX
S (PSOBBC1("CNHOK"),PSOBBC("CNHOK"))=Y
CNHX K X,Y,DIR
Q
;
EARLY ;
S DIR(0)="YA"
S DIR("A")="Allow early refills ? "
S DIR("B")="N"
D DIR G:PSOBBC("QFLG") EARLYX
S (PSOBBC1("EAOK"),PSOBBC("EAOK"))=Y
EARLYX K X,Y,DIR
Q
;
SET ;
S PSOBBC1("MAIL/WINDOW")=PSOBBC("MAIL/WINDOW") S:PSOBBC1("MAIL/WINDOW")="W" BINGRTE="W"
S PSOBBC1("FILL DATE")=PSOBBC("FILL DATE")
S:$G(PSOBBC("CLERK CODE")) PSOBBC1("CLERK CODE")=PSOBBC("CLERK CODE")
S:$G(PSOBBC("EXPIRATION DATE")) PSOBBC1("EXPIRATION DATE")=PSOBBC("EXPIRATION DATE")
Q
DIR ;
D ^DIR
S:$D(DIRUT) PSOBBC("QFLG")=1,PSORX("QFLG")=1
K DIRUT,DUOUT,DTOUT,DIROUT
Q
;
PROCESS ;
S PSOBBC("DFLG")=0 D NOW^%DTC S TM=$E(%,1,12),TM1=$P(TM,".",2)
S RXN=$O(^TMP("PSORXN",$J,0)) I RXN D
.S RXN1=^TMP("PSORXN",$J,RXN) D EN^PSOHLSN1(RXN,$P(RXN1,"^"),$P(RXN1,"^",2),"",$P(RXN1,"^",3))
.I $P(^PSRX(RXN,"STA"),"^")=5 D EN^PSOHLSN1(RXN,"SC","ZS","")
K RXN,RXN1,^TMP("PSORXN",$J) D CLEAN^PSOVER1 K ^TMP("PSORXDC",$J)
D GETRXM D:PSOBBC("QFLG") ULK,ULP,ULRX G:PSOBBC("QFLG") PROCESSX
I $G(PSODFN)'=$P(^PSRX(PSOBBC("IRXN"),0),"^",2) D G:PSOBBC("DFLG") PROCESS
.I $G(PSODFN) D ULK,ULP
.D PT Q:PSOBBC("DFLG")
.D PROFILE^PSORX1
E D PTC G:PSOBBC("DFLG") PROCESS
D:'$G(PSOSD) ^PSOBUILD
S PSOBBC("DONE")=PSOBBC("IRXN")_","
D @PSOBBC1("FROM") S:$G(PPL)&$D(BINGRTE) BBRX(1)=$S($D(PSOBBC("DONE")):PSOBBC("DONE"),1:BBRX) D:$D(BINGCRT)&($D(BINGRTE)&($D(DISGROUP))) ^PSOBING1 K BBRX D ULRX G PROCESS
PROCESSX ;I $G(PPL) D SETX,TRI,Q^PSORXL K PPL,RXFL ; IHS/CIA/PLS - 01/16/04
; IHS/CIA/PLS - 01/16/04 - Previous line commented out
; Next five lines added.
I $G(PPL) D
.D SETX,TRI
.;IHS/CIA/PLS - 06/24/05 - Changed reference from VEX to BEX in next two lines
.;I '$G(VEXRX) D Q^PSORXL
.;E D OPT^APSPNE4 K VEXPPL
.;IHS/MSC/PLS - 08/01/13 - Added argumentless D command
.I '$G(BEXRX) D
..D Q^PSORXL
.E D
..D OPT^APSPNE4 K BEXPPL
.K PPL
Q
GETRXM ;
K DIR,PSOBBC("IRXN"),PSOREFXM
S DIR(0)="FO^5:245^K:X'?3N1""-""1.N X"
S DIR("A")="WAND BARCODE"
S DIR("?",1)="Wand the barcoded number of the prescription to be processed."
S DIR("?",2)="The number should be of the form NNN-NNNNNN"
S DIR("?",3)="where the number before the dash is your station number."
S DIR("?")="Enter ""^"", or a RETURN to quit."
D DIR G:PSOBBC("QFLG") GETRXMX
I $P(X,"-")'=PSOINST W !?7,$C(7),$C(7),$C(7),"Not From this Institution" G GETRXM
S (PSOBBC("IRXN"),PSOBBC("OIRXN"),BBRX)=$P(X,"-",2)
I $G(^PSRX(PSOBBC("IRXN"),0))']"" W !,$C(7),"Rx data is not on file !",! G GETRXM
S PSOXDFN=+$P($G(^PSRX(PSOBBC("IRXN"),0)),"^",2) I PSOXDFN S PSOLOUD=1 D:$P($G(^PS(55,PSOXDFN,0)),"^",6)'=2 EN^PSOHLUP(PSOXDFN) K PSOLOUD
K PSOXDFN I $P($G(^PSRX(PSOBBC("IRXN"),"STA")),"^")=13 W !,$C(7),"Rx has already been deleted." G GETRXM
I $G(PSOBBC("DONE"))[PSOBBC("IRXN")_"," W !,$C(7),"Rx has already been entered" G GETRXM
I $G(PSOBBC1("FROM"))="REFILL" S PSOREFXM=$G(PSOBBC("IRXN")) I PSOREFXM D PSOL^PSSLOCK(PSOREFXM) I '$G(PSOMSG) D K PSOMSG G GETRXM
.I $P($G(PSOMSG),"^",2)'="" W $C(7),!!?5,$P(PSOMSG,"^",2),! Q
.W $C(7),!!?5,"Another person is editing Rx "_$P($G(^PSRX(+$G(PSOBBC("IRXN")),0)),"^"),!
I '$D(PSODFNX(+$P(^PSRX(PSOBBC("IRXN"),0),"^",2))),$G(PSOBBC1("FROM"))="NEW" K PSONOERR D G:'$G(PSOPLCK)!($G(PSONOERR)) GETRXM
.S PSOPLCK=$$L^PSSLOCK(+$P(^PSRX(PSOBBC("IRXN"),0),"^",2),0) I '$G(PSOPLCK) D LOCK^PSOORCPY Q
.S X=+$P(^PSRX(PSOBBC("IRXN"),0),"^",2)_";DPT(" D LK^ORX2 I 'Y S PSONOERR=1 D UL^PSSLOCK(+$P(^PSRX(PSOBBC("IRXN"),0),"^",2)) Q
.S PSODFNX(+$P(^PSRX(PSOBBC("IRXN"),0),"^",2))=""
GETRXMX K X,Y,DIR,PSOOPT
Q
;
PT ;
S PSOBBC("DFLG")=0
W !,$C(7),"New Patient, please pause"
;IHS/MSC/PLS - 05/27/06 - Next two lines modified to support AudioCare
;I $G(PPL) D SETX,TRI,Q^PSORXL K PPL
D PROCESSX ; New line
K RXFL
S (DFN,PSODFN)=$P(^PSRX(PSOBBC("IRXN"),0),"^",2),PSORX("NAME")=$P(^DPT(PSODFN,0),"^")
D ICN^PSODPT(DFN)
;CHECK FOR BAD ADDRESS/SAB
S PSOLOUD=1 D:$P($G(^PS(55,PSODFN,0)),"^",6)'=2 EN^PSOHLUP(PSODFN) K PSOLOUD
D ^PSOBUILD
S PSOX=$G(^PS(55,PSODFN,"PS")) I PSOX]"" S PSORX("PATIENT STATUS")=$P($G(^PS(53,PSOX,0)),"^")
K PSOX
PTC S (DFN,PSODFN)=$P(^PSRX(PSOBBC("IRXN"),0),"^",2)
S PSOLOUD=1 D:$P($G(^PS(55,PSODFN,0)),"^",6)'=2 EN^PSOHLUP(PSODFN) K PSOLOUD
S PSOBBC("DFLG")=0 D GET^PSOPTPST
I $G(PSOPTPST(2,PSODFN,.351))]"" S PSOBBC("DFLG")=1 D DEAD^PSOPTPST G PTX
N PSOTPEXT I $G(PSOBBC1("FROM"))="NEW",$D(^PS(52.91,PSODFN,0)) I '$P(^PS(52.91,PSODFN,0),"^",3)!($P(^(0),"^",3)>DT) D PDIR^PSOTPCAN(PSODFN) I $G(PSOTPEXT) K PSOTPEXT S PSOBBC("DFLG")=1 G PTX
K PSOTPEXT
I $G(PSOPTPST(2,PSODFN,.1))]"" D:'PSOBBC("INOK") PID W !,$C(7),?10,"PATIENT IS AN INPATIENT ON WARD ",PSOPTPST(2,PSODFN,.1)," !!" I 'PSOBBC("INOK") S PSOBBC("DFLG")=1 G PTX
K PSORX("CNH")
I $G(PSOPTPST(2,PSODFN,148))="YES" D:'PSOBBC("CNHOK") PID W !,$C(7),?10,"PATIENT IS IN A CONTRACT NURSING HOME !!" S:PSOBBC("CNHOK") PSORX("CNH")=1 I 'PSOBBC("CNHOK") S PSOBBC("DFLG")=1 G PTX
D:PSOBBC1("FROM")="NEW" COPAY^PSOPTPST
PTX K PSOPTPST W:PSOBBC("DFLG") !!,$C(7),"Rx not filled"
Q
;
REFILL ;
N PSOFROM S PSOFROM="REFILL",XFROM="BATCH"
D IHSFLDS(.PSOBBC) ;IHS/CIA/PLS - 06/24/05
D EN^PSOREF0(.PSOBBC)
Q
REFILLX ;
Q
;
IHSFLDS(PSOREF) ;EP - IHS/CIA/PLS - 06/24/05 - Call to setup IHS specific fields
N PSODRUG
D IHSSET^PSOREF1
Q
NEW ;
N PSOFROM S (PSOFROM,XFROM)="BATCH"
S PSOBBC("OIRXN")=PSOBBC("IRXN")
S PSORNW("FILL DATE")=PSOBBC1("FILL DATE"),PSOOPT=3
S PSORX("DFLG")=0,PSOBBC("NOO")=$G(PSOBBCNO) D EN^PSORENW0(.PSOBBC)
S PSOBBC("MAIL/WINDOW")=PSOBBC1("MAIL/WINDOW")
S PSOBBC("EAOK")=$G(PSOBBC1("EAOK"))
S PSOBBC("QS")=PSOBBC1("QS")
S PSOBBC("INOK")=PSOBBC1("INOK")
S PSOBBC("CNHOK")=PSOBBC1("CNHOK")
S:$G(PSOBBC1("CLERK CODE")) PSOBBC("CLERK CODE")=PSOBBC1("CLERK CODE")
S:$G(PSOBBC1("EXPIRATION DATE")) PSOBBC("EXPIRATION DATE")=PSOBBC1("EXPIRATION DATE")
K PSORNW,PSOOPT
Q
;
EOJ ;
K PSOMSG,PSOREFXM,PSONOERR,PSOPLCK,PSOSD,PSOBBC,PSOBBC1,PSOBARID,Y,X,XFROM,PSOCOUU,PSOCOU,ACNT,ADFN,CLS,CMOP,CNT,FDR,HDR,PSCAN,JJ,POERR,PSOBCK,PSONEW3,PSORENW3,RXFL,PSOOPT
K PSORX,RFDT,RX1,RXS,SDA,PSONOOR,VALMBCK,VALMSG,SIG,SIGOK,STA,TM,TM1,VA,VADM,VAEL,VAPA
D CLEAN^PSOVER1 K ^TMP("PSORXDC",$J)
Q
TRI ;Check for Tricare Rx's
S X="IBACUS" X ^%ZOSF("TEST") I '$T Q
I '$$TRI^IBACUS Q
Q:'$G(PPL)
;PREV LINE, IN V 7 D ZOSF FIRST
N DA,NEWPPL,WWFLAG,PSOWRX,PSOWW,WWNEXT,WXRX,WPAT,WSITE,WDUZ,WFILL,WLOOP,WBILL,WPPLFLG,WWW
D DEV^PSOCPTRI
S NEWPPL=PPL S PPL=""
S (WWFLAG,WPPLFLG)=0 F PSOWW=1:1 S PSOWRX=$P(NEWPPL,",",PSOWW) D Q:$G(WWFLAG)
.S WWNEXT=$P(NEWPPL,",",(PSOWW+1)) I WWNEXT=""!(WWNEXT=",") S WWFLAG=1
.I '$G(DT) S DT=$$DT^XLFDT
.S WPAT=$P($G(^PSRX(+PSOWRX,0)),"^",2),WSITE=+$G(PSOSITE),WDUZ=+$G(DUZ)
.S WFILL=0 F WLOOP=0:0 S WLOOP=$O(^PSRX(+PSOWRX,1,WLOOP)) Q:'WLOOP S WFILL=WLOOP
.S WBILL=$$CHPUS^IBACUS(WPAT,DT,PSOWRX,WFILL,PSOLAP,WSITE,WDUZ)
.I '$G(WBILL) S WXRX(PSOWW,PSOWRX)="" Q
.S WPPLFLG=1
.S FLD(99)="99",FLD(99.1)="Awaiting CHAMPUS billing approval"
.N RSDT,ACT,PSUS,RXF,I,PSDA,NOW,IR,FDA,RFN S DA=PSOWRX D H^PSOCPTRH Q
I '$G(WPPLFLG) S PPL=NEWPPL Q
S WWW="" F S WWW=$O(WXRX(WWW)) Q:WWW="" D
.I $G(PPL)="" S PPL=$O(WXRX(WWW,0))_"," Q
.S PPL=PPL_$O(WXRX(WWW,0))_","
Q
ULK ;
Q:$G(PSOBBC1("FROM"))'="NEW"
I '$G(PSODFN) Q
S X=PSODFN_";DPT(" D ULK^ORX2 K PSODFNX(PSODFN) Q
ULP Q:$G(PSOBBC1("FROM"))'="NEW"
Q:'$G(PSODFN)
D UL^PSSLOCK(PSODFN)
Q
ULRX ;
Q:$G(PSOBBC1("FROM"))'="REFILL"
Q:'$G(PSOREFXM)
D PSOUL^PSSLOCK(PSOREFXM)
K PSOREFXM
Q
;
SETX ;
S:$G(PSOBBC1("FROM"))="REFILL" XFROM="BATCH"
S:$G(PSOBBC1("FROM"))="NEW" XFROM="BATCH"
Q
PID ;
I '$G(DFN) S DFN=+$G(PSODFN)
Q:'$G(DFN)
K VAPTYP D PID^VADPT
W !!,?9,$G(PSORX("NAME"))_" ",$G(VA("BID"))
K VA("BID"),VA("PID")
Q
PSOBBC ;IHS/DSD/JCM-BATCH BARCODE DRIVER ;26-Aug-2013 15:36;PLS
+1 ;;7.0;OUTPATIENT PHARMACY;**11,22,27,34,46,130,146,1004,1005,185,242,264,300,1015,1016**;DEC 1997;Build 74
+2 ;External reference to ^IBE(350.1,"ANEW" supported by DBIA 592
+3 ;External references CHPUS^IBACUS and TRI^IBACUS supported by DBIA 2030
+4 ;External references LK^ORX2 and ULK^ORX2 supported by DBIA 867
+5 ;External references ^PS(55 supported by DBIA 2228
+6 ;External references U, UL, PSOL, and PSOUL^PSSLOCK supported by DBIA 2789
+7 ;PSO*242 change default to from Q to S
+8 ;-------------------------------------------------------------------
+9 ; Modified - IHS/CIA/PLS - 01/16/04 - Line PROCESSX
+10 ; 06/24/05 - Line PROCESSX+5
+11 ; Line REFILL+2, REFILL+3
+12 ; New IHSFLDS API
+13 ; IHS/MSC/PLS 05/27/06 - Line PT+3 - AudioCare Support
+14 ; 08/01/13 - Line PROCESSX+8
+15 ; 08/26/13 - Line SUSP+4
START ;
+1 NEW PSODFN,PSOBBCNO
+2 DO INIT
IF '$DATA(PSOPAR)
DO ^PSOLSET
IF '$DATA(PSOPAR)
GOTO EOJ
+3 IF $GET(PSOSITE)
SET PSOBARID=$GET(^PS(59,PSOSITE,"IB"))
IF '$DATA(^IBE(350.1,"ANEW",+PSOBARID,1,1))
Begin DoDot:1
+4 WRITE $CHAR(7),!!,"WARNING: Pharmacy Copay not working,",!,?10,"Check IB SERVICE/SECTION in Pharmacy Site File.",!!!,"You will not be able to enter any new prescriptions until this is corrected!"
End DoDot:1
SET PSORX("QFLG")=1
KILL PSOBARID
GOTO END
+5 SET PSOBBC("QFLG")=0
SET PSORX("BAR CODE")=1
+6 DO FROM
IF PSOBBC("QFLG")
SET PSORX("QFLG")=1
GOTO END
+7 DO ASK
IF PSOBBC("QFLG")
SET PSORX("QFLG")=1
GOTO END
+8 DO PROCESS
END DO EOJ
+1 QUIT
+2 ;--------------------------------------------------------------------
INIT ;
+1 SET PSOBBC("QFLG")=0
SET PSORX("BAR CODE")=1
KILL PPL
+2 IF '$GET(PSOINST)
Begin DoDot:1
+3 KILL DIC,DR,DIQ
SET DA=$PIECE($$SITE^VASITE(),"^")
IF DA
Begin DoDot:2
+4 KILL PSOINST
SET DIC=4
SET DIQ(0)="I"
SET DR=99
SET DIQ="PSOINST"
DO EN^DIQ1
+5 SET PSOINST=PSOINST(4,DA,99,"I")
KILL DIC,DA,DIQ,PSOINST(4)
End DoDot:2
End DoDot:1
+6 QUIT
FROM ;
+1 SET DIR(0)="S^1:REFILLS;2:RENEWS;"
+2 SET DIR("A")="Batch Barcode for"
SET DIR("B")="REFILLS"
+3 DO DIR
IF 'Y
GOTO FROMX
+4 SET PSOBBC1("FROM")=$SELECT(Y=1:"REFILL",1:"NEW")
FROMX KILL X,Y,DIR
+1 QUIT
+2 ;
ASK ;
+1 KILL BINGCRT,BINGRTE,BBRX
+2 WRITE !,"Please answer the following for this session of prescriptions",!
+3 DO EN^PSOREF2(.PSOBBC)
IF PSOBBC("DFLG")
SET PSOBBC("QFLG")=1
GOTO ASKX
+4 DO SUSP
+5 DO INPT
DO CNH
+6 IF '$PIECE($GET(PSOPAR),"^",6)
DO EARLY
+7 DO SET
+8 IF PSOBBC1("FROM")="NEW"
DO NOORE^PSONEW(.PSOBBC)
IF $GET(PSOBBC("NOO"))'=""
SET PSOBBCNO=$GET(PSOBBC("NOO"))
IF $GET(PSOBBC("DFLG"))
SET PSOBBC("QFLG")=1
ASKX QUIT
+1 ;
SUSP ;
+1 SET DIR(0)="SAB^Q:QUEUED;S:SUSPENDED"
+2 SET DIR("A")="Will these refills be Queued or Suspended ? "
+3 ;S DIR("B")="S" ;PSO*242
+4 ;IHS/MSC/PLS - 08/26/13
SET DIR("B")="Q"
+5 DO DIR
IF PSOBBC("QFLG")
GOTO SUSPX
+6 SET (PSOBBC1("QS"),PSOBBC("QS"))=Y
IF PSOBBC1("QS")="S"
SET BINGCRT=0
SUSPX KILL X,Y,DIR
+1 QUIT
+2 ;
INPT ;
+1 SET DIR(0)="YA"
+2 SET DIR("A")="Allow refills for inpatient ? "
+3 SET DIR("B")="N"
+4 DO DIR
IF PSOBBC("QFLG")
GOTO INPTX
+5 SET (PSOBBC1("INOK"),PSOBBC("INOK"))=Y
INPTX KILL X,Y,DIR
+1 QUIT
CNH ;
+1 SET DIR(0)="YA"
+2 SET DIR("A")="Allow refills for CNH ? "
+3 SET DIR("B")="N"
+4 DO DIR
IF PSOBBC("QFLG")
GOTO CNHX
+5 SET (PSOBBC1("CNHOK"),PSOBBC("CNHOK"))=Y
CNHX KILL X,Y,DIR
+1 QUIT
+2 ;
EARLY ;
+1 SET DIR(0)="YA"
+2 SET DIR("A")="Allow early refills ? "
+3 SET DIR("B")="N"
+4 DO DIR
IF PSOBBC("QFLG")
GOTO EARLYX
+5 SET (PSOBBC1("EAOK"),PSOBBC("EAOK"))=Y
EARLYX KILL X,Y,DIR
+1 QUIT
+2 ;
SET ;
+1 SET PSOBBC1("MAIL/WINDOW")=PSOBBC("MAIL/WINDOW")
IF PSOBBC1("MAIL/WINDOW")="W"
SET BINGRTE="W"
+2 SET PSOBBC1("FILL DATE")=PSOBBC("FILL DATE")
+3 IF $GET(PSOBBC("CLERK CODE"))
SET PSOBBC1("CLERK CODE")=PSOBBC("CLERK CODE")
+4 IF $GET(PSOBBC("EXPIRATION DATE"))
SET PSOBBC1("EXPIRATION DATE")=PSOBBC("EXPIRATION DATE")
+5 QUIT
DIR ;
+1 DO ^DIR
+2 IF $DATA(DIRUT)
SET PSOBBC("QFLG")=1
SET PSORX("QFLG")=1
+3 KILL DIRUT,DUOUT,DTOUT,DIROUT
+4 QUIT
+5 ;
PROCESS ;
+1 SET PSOBBC("DFLG")=0
DO NOW^%DTC
SET TM=$EXTRACT(%,1,12)
SET TM1=$PIECE(TM,".",2)
+2 SET RXN=$ORDER(^TMP("PSORXN",$JOB,0))
IF RXN
Begin DoDot:1
+3 SET RXN1=^TMP("PSORXN",$JOB,RXN)
DO EN^PSOHLSN1(RXN,$PIECE(RXN1,"^"),$PIECE(RXN1,"^",2),"",$PIECE(RXN1,"^",3))
+4 IF $PIECE(^PSRX(RXN,"STA"),"^")=5
DO EN^PSOHLSN1(RXN,"SC","ZS","")
End DoDot:1
+5 KILL RXN,RXN1,^TMP("PSORXN",$JOB)
DO CLEAN^PSOVER1
KILL ^TMP("PSORXDC",$JOB)
+6 DO GETRXM
IF PSOBBC("QFLG")
DO ULK
DO ULP
DO ULRX
IF PSOBBC("QFLG")
GOTO PROCESSX
+7 IF $GET(PSODFN)'=$PIECE(^PSRX(PSOBBC("IRXN"),0),"^",2)
Begin DoDot:1
+8 IF $GET(PSODFN)
DO ULK
DO ULP
+9 DO PT
IF PSOBBC("DFLG")
QUIT
+10 DO PROFILE^PSORX1
End DoDot:1
IF PSOBBC("DFLG")
GOTO PROCESS
+11 IF '$TEST
DO PTC
IF PSOBBC("DFLG")
GOTO PROCESS
+12 IF '$GET(PSOSD)
DO ^PSOBUILD
+13 SET PSOBBC("DONE")=PSOBBC("IRXN")_","
+14 DO @PSOBBC1("FROM")
IF $GET(PPL)&$DATA(BINGRTE)
SET BBRX(1)=$SELECT($DATA(PSOBBC("DONE")):PSOBBC("DONE"),1:BBRX)
IF $DATA(BINGCRT)&($DATA(BINGRTE)&($DATA(DISGROUP)))
DO ^PSOBING1
KILL BBRX
DO ULRX
GOTO PROCESS
PROCESSX ;I $G(PPL) D SETX,TRI,Q^PSORXL K PPL,RXFL ; IHS/CIA/PLS - 01/16/04
+1 ; IHS/CIA/PLS - 01/16/04 - Previous line commented out
+2 ; Next five lines added.
+3 IF $GET(PPL)
Begin DoDot:1
+4 DO SETX
DO TRI
+5 ;IHS/CIA/PLS - 06/24/05 - Changed reference from VEX to BEX in next two lines
+6 ;I '$G(VEXRX) D Q^PSORXL
+7 ;E D OPT^APSPNE4 K VEXPPL
+8 ;IHS/MSC/PLS - 08/01/13 - Added argumentless D command
+9 IF '$GET(BEXRX)
Begin DoDot:2
+10 DO Q^PSORXL
End DoDot:2
+11 IF '$TEST
Begin DoDot:2
+12 DO OPT^APSPNE4
KILL BEXPPL
End DoDot:2
+13 KILL PPL
End DoDot:1
+14 QUIT
GETRXM ;
+1 KILL DIR,PSOBBC("IRXN"),PSOREFXM
+2 SET DIR(0)="FO^5:245^K:X'?3N1""-""1.N X"
+3 SET DIR("A")="WAND BARCODE"
+4 SET DIR("?",1)="Wand the barcoded number of the prescription to be processed."
+5 SET DIR("?",2)="The number should be of the form NNN-NNNNNN"
+6 SET DIR("?",3)="where the number before the dash is your station number."
+7 SET DIR("?")="Enter ""^"", or a RETURN to quit."
+8 DO DIR
IF PSOBBC("QFLG")
GOTO GETRXMX
+9 IF $PIECE(X,"-")'=PSOINST
WRITE !?7,$CHAR(7),$CHAR(7),$CHAR(7),"Not From this Institution"
GOTO GETRXM
+10 SET (PSOBBC("IRXN"),PSOBBC("OIRXN"),BBRX)=$PIECE(X,"-",2)
+11 IF $GET(^PSRX(PSOBBC("IRXN"),0))']""
WRITE !,$CHAR(7),"Rx data is not on file !",!
GOTO GETRXM
+12 SET PSOXDFN=+$PIECE($GET(^PSRX(PSOBBC("IRXN"),0)),"^",2)
IF PSOXDFN
SET PSOLOUD=1
IF $PIECE($GET(^PS(55,PSOXDFN,0)),"^",6)'=2
DO EN^PSOHLUP(PSOXDFN)
KILL PSOLOUD
+13 KILL PSOXDFN
IF $PIECE($GET(^PSRX(PSOBBC("IRXN"),"STA")),"^")=13
WRITE !,$CHAR(7),"Rx has already been deleted."
GOTO GETRXM
+14 IF $GET(PSOBBC("DONE"))[PSOBBC("IRXN")_","
WRITE !,$CHAR(7),"Rx has already been entered"
GOTO GETRXM
+15 IF $GET(PSOBBC1("FROM"))="REFILL"
SET PSOREFXM=$GET(PSOBBC("IRXN"))
IF PSOREFXM
DO PSOL^PSSLOCK(PSOREFXM)
IF '$GET(PSOMSG)
Begin DoDot:1
+16 IF $PIECE($GET(PSOMSG),"^",2)'=""
WRITE $CHAR(7),!!?5,$PIECE(PSOMSG,"^",2),!
QUIT
+17 WRITE $CHAR(7),!!?5,"Another person is editing Rx "_$PIECE($GET(^PSRX(+$GET(PSOBBC("IRXN")),0)),"^"),!
End DoDot:1
KILL PSOMSG
GOTO GETRXM
+18 IF '$DATA(PSODFNX(+$PIECE(^PSRX(PSOBBC("IRXN"),0),"^",2)))
IF $GET(PSOBBC1("FROM"))="NEW"
KILL PSONOERR
Begin DoDot:1
+19 SET PSOPLCK=$$L^PSSLOCK(+$PIECE(^PSRX(PSOBBC("IRXN"),0),"^",2),0)
IF '$GET(PSOPLCK)
DO LOCK^PSOORCPY
QUIT
+20 SET X=+$PIECE(^PSRX(PSOBBC("IRXN"),0),"^",2)_";DPT("
DO LK^ORX2
IF 'Y
SET PSONOERR=1
DO UL^PSSLOCK(+$PIECE(^PSRX(PSOBBC("IRXN"),0),"^",2))
QUIT
+21 SET PSODFNX(+$PIECE(^PSRX(PSOBBC("IRXN"),0),"^",2))=""
End DoDot:1
IF '$GET(PSOPLCK)!($GET(PSONOERR))
GOTO GETRXM
GETRXMX KILL X,Y,DIR,PSOOPT
+1 QUIT
+2 ;
PT ;
+1 SET PSOBBC("DFLG")=0
+2 WRITE !,$CHAR(7),"New Patient, please pause"
+3 ;IHS/MSC/PLS - 05/27/06 - Next two lines modified to support AudioCare
+4 ;I $G(PPL) D SETX,TRI,Q^PSORXL K PPL
+5 ; New line
DO PROCESSX
+6 KILL RXFL
+7 SET (DFN,PSODFN)=$PIECE(^PSRX(PSOBBC("IRXN"),0),"^",2)
SET PSORX("NAME")=$PIECE(^DPT(PSODFN,0),"^")
+8 DO ICN^PSODPT(DFN)
+9 ;CHECK FOR BAD ADDRESS/SAB
+10 SET PSOLOUD=1
IF $PIECE($GET(^PS(55,PSODFN,0)),"^",6)'=2
DO EN^PSOHLUP(PSODFN)
KILL PSOLOUD
+11 DO ^PSOBUILD
+12 SET PSOX=$GET(^PS(55,PSODFN,"PS"))
IF PSOX]""
SET PSORX("PATIENT STATUS")=$PIECE($GET(^PS(53,PSOX,0)),"^")
+13 KILL PSOX
PTC SET (DFN,PSODFN)=$PIECE(^PSRX(PSOBBC("IRXN"),0),"^",2)
+1 SET PSOLOUD=1
IF $PIECE($GET(^PS(55,PSODFN,0)),"^",6)'=2
DO EN^PSOHLUP(PSODFN)
KILL PSOLOUD
+2 SET PSOBBC("DFLG")=0
DO GET^PSOPTPST
+3 IF $GET(PSOPTPST(2,PSODFN,.351))]""
SET PSOBBC("DFLG")=1
DO DEAD^PSOPTPST
GOTO PTX
+4 NEW PSOTPEXT
IF $GET(PSOBBC1("FROM"))="NEW"
IF $DATA(^PS(52.91,PSODFN,0))
IF '$PIECE(^PS(52.91,PSODFN,0),"^",3)!($PIECE(^(0),"^",3)>DT)
DO PDIR^PSOTPCAN(PSODFN)
IF $GET(PSOTPEXT)
KILL PSOTPEXT
SET PSOBBC("DFLG")=1
GOTO PTX
+5 KILL PSOTPEXT
+6 IF $GET(PSOPTPST(2,PSODFN,.1))]""
IF 'PSOBBC("INOK")
DO PID
WRITE !,$CHAR(7),?10,"PATIENT IS AN INPATIENT ON WARD ",PSOPTPST(2,PSODFN,.1)," !!"
IF 'PSOBBC("INOK")
SET PSOBBC("DFLG")=1
GOTO PTX
+7 KILL PSORX("CNH")
+8 IF $GET(PSOPTPST(2,PSODFN,148))="YES"
IF 'PSOBBC("CNHOK")
DO PID
WRITE !,$CHAR(7),?10,"PATIENT IS IN A CONTRACT NURSING HOME !!"
IF PSOBBC("CNHOK")
SET PSORX("CNH")=1
IF 'PSOBBC("CNHOK")
SET PSOBBC("DFLG")=1
GOTO PTX
+9 IF PSOBBC1("FROM")="NEW"
DO COPAY^PSOPTPST
PTX KILL PSOPTPST
IF PSOBBC("DFLG")
WRITE !!,$CHAR(7),"Rx not filled"
+1 QUIT
+2 ;
REFILL ;
+1 NEW PSOFROM
SET PSOFROM="REFILL"
SET XFROM="BATCH"
+2 ;IHS/CIA/PLS - 06/24/05
DO IHSFLDS(.PSOBBC)
+3 DO EN^PSOREF0(.PSOBBC)
+4 QUIT
REFILLX ;
+1 QUIT
+2 ;
IHSFLDS(PSOREF) ;EP - IHS/CIA/PLS - 06/24/05 - Call to setup IHS specific fields
+1 NEW PSODRUG
+2 DO IHSSET^PSOREF1
+3 QUIT
NEW ;
+1 NEW PSOFROM
SET (PSOFROM,XFROM)="BATCH"
+2 SET PSOBBC("OIRXN")=PSOBBC("IRXN")
+3 SET PSORNW("FILL DATE")=PSOBBC1("FILL DATE")
SET PSOOPT=3
+4 SET PSORX("DFLG")=0
SET PSOBBC("NOO")=$GET(PSOBBCNO)
DO EN^PSORENW0(.PSOBBC)
+5 SET PSOBBC("MAIL/WINDOW")=PSOBBC1("MAIL/WINDOW")
+6 SET PSOBBC("EAOK")=$GET(PSOBBC1("EAOK"))
+7 SET PSOBBC("QS")=PSOBBC1("QS")
+8 SET PSOBBC("INOK")=PSOBBC1("INOK")
+9 SET PSOBBC("CNHOK")=PSOBBC1("CNHOK")
+10 IF $GET(PSOBBC1("CLERK CODE"))
SET PSOBBC("CLERK CODE")=PSOBBC1("CLERK CODE")
+11 IF $GET(PSOBBC1("EXPIRATION DATE"))
SET PSOBBC("EXPIRATION DATE")=PSOBBC1("EXPIRATION DATE")
+12 KILL PSORNW,PSOOPT
+13 QUIT
+14 ;
EOJ ;
+1 KILL PSOMSG,PSOREFXM,PSONOERR,PSOPLCK,PSOSD,PSOBBC,PSOBBC1,PSOBARID,Y,X,XFROM,PSOCOUU,PSOCOU,ACNT,ADFN,CLS,CMOP,CNT,FDR,HDR,PSCAN,JJ,POERR,PSOBCK,PSONEW3,PSORENW3,RXFL,PSOOPT
+2 KILL PSORX,RFDT,RX1,RXS,SDA,PSONOOR,VALMBCK,VALMSG,SIG,SIGOK,STA,TM,TM1,VA,VADM,VAEL,VAPA
+3 DO CLEAN^PSOVER1
KILL ^TMP("PSORXDC",$JOB)
+4 QUIT
TRI ;Check for Tricare Rx's
+1 SET X="IBACUS"
XECUTE ^%ZOSF("TEST")
IF '$TEST
QUIT
+2 IF '$$TRI^IBACUS
QUIT
+3 IF '$GET(PPL)
QUIT
+4 ;PREV LINE, IN V 7 D ZOSF FIRST
+5 NEW DA,NEWPPL,WWFLAG,PSOWRX,PSOWW,WWNEXT,WXRX,WPAT,WSITE,WDUZ,WFILL,WLOOP,WBILL,WPPLFLG,WWW
+6 DO DEV^PSOCPTRI
+7 SET NEWPPL=PPL
SET PPL=""
+8 SET (WWFLAG,WPPLFLG)=0
FOR PSOWW=1:1
SET PSOWRX=$PIECE(NEWPPL,",",PSOWW)
Begin DoDot:1
+9 SET WWNEXT=$PIECE(NEWPPL,",",(PSOWW+1))
IF WWNEXT=""!(WWNEXT=",")
SET WWFLAG=1
+10 IF '$GET(DT)
SET DT=$$DT^XLFDT
+11 SET WPAT=$PIECE($GET(^PSRX(+PSOWRX,0)),"^",2)
SET WSITE=+$GET(PSOSITE)
SET WDUZ=+$GET(DUZ)
+12 SET WFILL=0
FOR WLOOP=0:0
SET WLOOP=$ORDER(^PSRX(+PSOWRX,1,WLOOP))
IF 'WLOOP
QUIT
SET WFILL=WLOOP
+13 SET WBILL=$$CHPUS^IBACUS(WPAT,DT,PSOWRX,WFILL,PSOLAP,WSITE,WDUZ)
+14 IF '$GET(WBILL)
SET WXRX(PSOWW,PSOWRX)=""
QUIT
+15 SET WPPLFLG=1
+16 SET FLD(99)="99"
SET FLD(99.1)="Awaiting CHAMPUS billing approval"
+17 NEW RSDT,ACT,PSUS,RXF,I,PSDA,NOW,IR,FDA,RFN
SET DA=PSOWRX
DO H^PSOCPTRH
QUIT
End DoDot:1
IF $GET(WWFLAG)
QUIT
+18 IF '$GET(WPPLFLG)
SET PPL=NEWPPL
QUIT
+19 SET WWW=""
FOR
SET WWW=$ORDER(WXRX(WWW))
IF WWW=""
QUIT
Begin DoDot:1
+20 IF $GET(PPL)=""
SET PPL=$ORDER(WXRX(WWW,0))_","
QUIT
+21 SET PPL=PPL_$ORDER(WXRX(WWW,0))_","
End DoDot:1
+22 QUIT
ULK ;
+1 IF $GET(PSOBBC1("FROM"))'="NEW"
QUIT
+2 IF '$GET(PSODFN)
QUIT
+3 SET X=PSODFN_";DPT("
DO ULK^ORX2
KILL PSODFNX(PSODFN)
QUIT
ULP IF $GET(PSOBBC1("FROM"))'="NEW"
QUIT
+1 IF '$GET(PSODFN)
QUIT
+2 DO UL^PSSLOCK(PSODFN)
+3 QUIT
ULRX ;
+1 IF $GET(PSOBBC1("FROM"))'="REFILL"
QUIT
+2 IF '$GET(PSOREFXM)
QUIT
+3 DO PSOUL^PSSLOCK(PSOREFXM)
+4 KILL PSOREFXM
+5 QUIT
+6 ;
SETX ;
+1 IF $GET(PSOBBC1("FROM"))="REFILL"
SET XFROM="BATCH"
+2 IF $GET(PSOBBC1("FROM"))="NEW"
SET XFROM="BATCH"
+3 QUIT
PID ;
+1 IF '$GET(DFN)
SET DFN=+$GET(PSODFN)
+2 IF '$GET(DFN)
QUIT
+3 KILL VAPTYP
DO PID^VADPT
+4 WRITE !!,?9,$GET(PSORX("NAME"))_" ",$GET(VA("BID"))
+5 KILL VA("BID"),VA("PID")
+6 QUIT