PSOSULBL ;BHAM ISC/RTR,SAB-Print Suspended labels ;05-Sep-2013 14:45;PLS
;;7.0;OUTPATIENT PHARMACY;**139,173,1008,174,148,200,260,264,287,289,1015,1016**;DEC 1997;Build 74
;External reference ^PS(55 supported by DBIA 2228
;Reference to SAVNDC^PSSNDCUT supported by IA 4707
;Reference ^PSDRUG( supported by DBIA 221
;Modified - IHS/MSC/PLS - 02/12/09 - Calls to DQ^PSOLBL changed to DQ^APSPLBL
; 08/31/09 - Added setting of PSOPULL flag so that Dispense and Fill dates are updated
K PDUZ,REPRINT G ^PSOSULB1
BEG ;
K PSORUNIN,PSORETRY N BPSCNT
S PSORUNIN="PSOSUSP"_($G(PSOSITE))
L +@PSORUNIN:10 I '$T D
. F PSORETRY=1:1:120 L +@PSORUNIN:60 I $T Q ;wait Max of 2 hrs before continue
. Q
K ^UTILITY($J,"PSOPRO"),^TMP("PSOSBAI",$J) S PSOSEQ=1 F DFN=0:0 S DFN=$O(^PS(52.5,"AC",DFN)) Q:'DFN D D:'PSRT PID^VADPT6 D CHKDEAD D:'DEAD&($G(PSOSFLAG)) PRT
.S PSOSFLAG=0 F ZZ=0:0 S ZZ=$O(^PS(52.5,"AC",DFN,ZZ)) Q:'ZZ!$G(PSOSFLAG) I ZZ'>PRTDT S PSOSFLAG=1
D PPL
D:$D(^UTILITY($J,"PSOPRO"))&($P(PSOPAR,"^",8)) PROF
G EXIT
PRT F SDT=0:0 S SDT=$O(^PS(52.5,"AC",DFN,SDT)) D:SDT CHK Q:'SDT
Q
EXIT ;
I $D(^TMP("PSOSBAI",$J)) D CHKMAIL
K ^TMP($J),^TMP("PSOSBAI",$J)
I $D(PSORUNIN) L -@PSORUNIN
D ^%ZISC
K %,%ZIS,CNT,COM,DA,DEAD,DFN,DIRUT,DTTM,G,HDPPL,JJ,JJJ,JJJJ,PDUZ,IOP,ORD,PFIOQ,PSLION,PSRT,POP,PRF,PRTDT,PSLIO,PSNP,PSODBQ,PSOSEQ,PSOSFLAG,PSOSU,PSOTIME,PSOOUT,PSOPRFLG,PSOSEQ,PSOSUSPR,PSSPND,PST,PTL,PPLHLD,PSFNIEN,ZTSK
K PSOBADDR,PSORUNIN,PSORETRY,PSRTONE,PSSRT,PSUSDEA,RF,RFCNT,RX,RXDFN,SDT,SFN,SREC,STOP,SUSPT,VADM,VAPA,X,X1,X2,XAK,XDATE,Y,Z,ZZ,WWW,PSDDDATE,SINRX,RXPR,RXPR1,GGGG,XXX,ZII,ZTDESC,ZTRTN,ZTSAVE,RRRR,RXRP,RXRP1,RXFL,SPR S:$D(ZTQUEUED) ZTREQ="@" Q
CHK I SDT'>XDATE D TMP Q
Q
TMP F SFN=0:0 S SFN=$O(^PS(52.5,"AC",DFN,SDT,SFN)) Q:'SFN D
. I '$D(^PS(52.5,SFN,0))!'$D(^DPT(+DFN,0)) Q
. N RXSITE,PRINTED,PSDFN,RXSTS,RXIEN,RXFILL,PARTIAL,RXEXPDT,RESP,DSHLD
. S RXIEN=+$$GET1^DIQ(52.5,SFN,.01,"I"),RXDFN=$$GET1^DIQ(52,RXIEN,2,"I")
. S RXSTS=$$GET1^DIQ(52,RXIEN,100,"I"),RXSITE=+$$GET1^DIQ(52.5,SFN,.06,"I"),PRINTED=+$$GET1^DIQ(52.5,SFN,2,"I")
. S PARTIAL=+$$GET1^DIQ(52.5,SFN,.05,"I"),RXEXPDT=$$GET1^DIQ(52,RXIEN,26,"I")
. S RXFILL=$$GET1^DIQ(52.5,SFN,9,"I") I RXFILL="" S RXFILL=$$LSTRFL^PSOBPSU1(RXIEN)
. I RXSITE=$G(PSOSITE),'PRINTED,RXDFN=DFN,RXSTS<9 D
. . I PARTIAL,'$D(^PSRX(RXIEN,"P",PARTIAL)) Q
. . I RXEXPDT<DT,RXSTS<11 D Q
. . . N RXREC S RXREC=RXIEN D EX^PSOSUTL
. . . K DIE,DA S DIE=52,DA=RXIEN,DR="100///11" D ^DIE K DIE,DA
. . . K DIK,DA S DA=SFN,DIK="^PS(52.5," D ^DIK K DIK,DA
. . S PSOBADDR=0 D CHKBAI I PSOBADDR Q
. . I PSRT="D" D
. . . S PSSRT=$S($G(PSRTONE)="I":VA("PID"),1:$P(^DPT(DFN,0),"^")_$P(^(0),"^",9))
. . . S PSUSDEA=$P($G(^PS(52.5,SFN,0)),"^",10)
. . . S SRT=$S(PSUSDEA["A"!(PSUSDEA["C"):"A-"_PSSRT,PSUSDEA["S":"S-"_PSSRT,1:"Z-"_PSSRT)
. . I PSRT'="D" D
. . . S SRT=$S(PSRT:$P(^DPT(DFN,0),"^")_$P(^(0),"^",9),1:VA("PID"))
. . ; - If not partial fill, sending Rx to ECME for 3rd Party billing
. . I 'PARTIAL,$$RETRX^PSOBPSUT(RXIEN,RXFILL),SDT>DT Q
. . I 'PARTIAL,$$FIND^PSOREJUT(RXIEN,RXFILL),'$$DUR^PSOBPSU2(RXIEN,RXFILL) Q ;epharmacy-host errors
. . I 'PARTIAL,$$STATUS^PSOBPSUT(RXIEN,RXFILL-1)'="" S DSHLD=$$DSH^PSOSULB1(SFN) Q:'DSHLD ;epharmacy-3/4 days supply
. . I 'PARTIAL D Q:$$FIND^PSOREJUT(RXIEN,RXFILL,,"79,88") Q:$$TRISTA^PSOREJU3(RXIEN,RXFILL,.RESP,"PL")
. . . I $$FIND^PSOREJUT(RXIEN,RXFILL,,"79,88") Q
. . . I '$$RETRX^PSOBPSUT(RXIEN,RXFILL),'$$ECMESTAT^PSXRPPL2(RXIEN,RXFILL) Q
. . . D ECMESND^PSOBPSU1(RXIEN,RXFILL,,"PL",,,,,,.RESP) I $D(RESP),'RESP S BPSCNT=$G(BPSCNT)+1
. . S ^TMP($J,SRT,SFN)=RXIEN
Q
PPL ; Wait some time before printing so response from 3rd party payers can be received
I $G(BPSCNT)>0 H 60+$S((BPSCNT*15)>7200:7200,1:(BPSCNT*15))
K PPL,PPL1 S ORD="" F S ORD=$O(^TMP($J,ORD)) Q:ORD="" D PPL1
Q
PPL1 ; Printing Labels
N PARTIAL,REPRINT,REFILL,Z,QUIT
N PSOPULL ;IHS/MSC/PLS - 08/31/09
S (PSOPRFLG,SUSPT)=1 S:$D(PSOPROP) PFIO=PSOPROP
S:'$D(PDUZ) PDUZ=DUZ K RXPR,RXPR1,PPL
F SFN=0:0 S SFN=$O(^TMP($J,ORD,SFN)) Q:'SFN D
.I '$D(^PS(52.5,SFN,0)) Q
.S Z=$G(^PS(52.5,SFN,0)),SINRX=+$P(Z,"^"),REFILL=+$P(Z,"^",13)
.S PARTIAL=$P(Z,"^",5),REPRINT=$P(Z,"^",12)
.; - Screening out OPEN/UNRESOLVED Rejects (3rd Party Payer)
.S QUIT=0
.I 'PARTIAL,'REPRINT D I QUIT Q
..I $$FIND^PSOREJUT(SINRX,REFILL,,"79,88") S QUIT=1 Q
..I $$STATUS^PSOBPSUT(SINRX,REFILL)="IN PROGRESS" S QUIT=1 Q
..I $$STATUS^PSOBPSUT(SINRX,REFILL)="E PAYABLE" D
...D SAVNDC^PSSNDCUT(+$$GET1^DIQ(52,SINRX,6,"I"),$$RXSITE^PSOBPSUT(SINRX,REFILL),$$GETNDC^PSONDCUT(SINRX,REFILL))
.;
.I $L($G(PPL))<240 D
..S PPL=$P(^TMP($J,ORD,SFN),"^")_","_$G(PPL),RXPR(SINRX)=$P(^PS(52.5,SFN,0),"^",5)
..S:$P(^PS(52.5,SFN,0),"^",12) RXRP(SINRX)=1
.E D
..S PPL1=$P(^TMP($J,ORD,SFN),"^")_","_$G(PPL1),RXPR1(SINRX)=$P(^PS(52.5,SFN,0),"^",5)
..S:$P(^PS(52.5,SFN,0),"^",12) RXRP1(SINRX)=1
.S DFN=$P(^PS(52.5,SFN,0),"^",3)
.I $P(PSOPAR,"^",8),'$D(^PSRX($P(^PS(52.5,SFN,0),"^"),1)),'$G(RXPR(SINRX)),'$G(RXPR1(SINRX)) S PSOPRFLG=0
S PSNP=$S($P(PSOPAR,"^",8):1,1:0)
I $G(PPL) D
.S PPLHLD=$G(PPL1),HDPPL=PPL K PPL1 S (PSODBQ,PSOSUSPR)=1
.F GGGG=0:0 S GGGG=$O(RXPR(GGGG)) Q:'GGGG K:'$G(RXPR(GGGG)) RXPR(GGGG)
;IHS/MSC/PLS - 02/12/09 - Changed to call IHS label routine
;I $G(PPL) D DQ^PSOLBL,SEQ D:'$G(PSOPRFLG)
S PSOPULL=1
I $G(PPL) D DQ^APSPLBL,SEQ D:'$G(PSOPRFLG)
.I $G(PSOPROP)'=$G(PSLION) S ^UTILITY($J,"PSOPRO",DFN)="" Q
.D DQ^PSOPRFSS
I $G(PPLHLD) K RXPR S (PPL,HDPPL)=PPLHLD,(PSODBQ,PSOSUSPR)=1,PSNP=0 S:'$D(PDUZ) PDUZ=DUZ F XXX=0:0 S XXX=$O(RXPR1(XXX)) Q:'XXX S:$G(RXPR1(XXX)) RXPR(XXX)=RXPR1(XXX)
I $G(PPLHLD) F RRRR=0:0 S RRRR=$O(RXRP1(RRRR)) Q:'RRRR S:$D(RXRP1(RRRR)) RXRP(RRRR)=1
;IHS/MSC/PLS - 02/12/09 - Changed to call IHS label routine
;I $G(PPLHLD) D DQ^PSOLBL,SEQ D:'$G(PSOPRFLG)
I $G(PPLHLD) D DQ^APSPLBL,SEQ D:'$G(PSOPRFLG)
.I $G(PSOPROP)'=$G(PSLION) S ^UTILITY($J,"PSOPRO",DFN)="" Q
.D DQ^PSOPRFSS
K PPL,PPL1,PPLHLD,RXPR,RXPR1,RXFL Q
SEQ ;
S SQCOUNT=0 F JJJ=1:1:$L(HDPPL) S:$E(HDPPL,JJJ)="," SQCOUNT=SQCOUNT+1
F JJJJ=1:1:SQCOUNT S PSFNIEN=$P(HDPPL,",",JJJJ) D:PSFNIEN
.S PSFNIEN=$O(^PS(52.5,"B",PSFNIEN,0)) I PSFNIEN D
..S $P(^PS(52.5,PSFNIEN,0),"^",11)=PSOSEQ,PSOSEQ=PSOSEQ+1 S:$P(^PS(52.5,PSFNIEN,0),"^",8)&($P(^(0),"^",9))&($P(^(0),"^",6)) ^PS(52.5,"AS",$P(^PS(52.5,PSFNIEN,0),"^",8),$P(^(0),"^",9),$P(^(0),"^",6),$P(^(0),"^",11),PSFNIEN)=""
Q
CHKDEAD D DEM^VADPT I VADM(1)="" S DEAD=0 Q
I VADM(6)="" S DEAD=0 Q
S PSDDDATE=$P(VADM(6),"^",2) F WWW=0:0 S WWW=$O(^PS(55,DFN,"P",WWW)) Q:'WWW I $D(^PS(55,DFN,"P",WWW,0)),$P($G(^(0)),"^") S (DA,RXREC)=$P(^(0),"^") S SFN=$O(^PS(52.5,"B",RXREC,0)) I SFN,$D(^PS(52.5,SFN,0)) S RX=$P(^(0),"^") D DEAD
Q
DEAD S $P(^PSRX(RX,"STA"),"^")=12,COM="Died ("_$G(PSDDDATE)_")",DA(1)=RX
S DEAD=1 D ARECD^PSOSUTL S DIK="^PS(52.5,",DA=SFN D ^DIK K DIK
Q
PROF ;
S ZTRTN="PRPROF^PSOSULBL",ZTDESC="PRINT PROFILES FROM SUSPENSE",ZTDTH=$H,ZTIO=PSOPROP
S ZTSAVE("^UTILITY($J,""PSOPRO"",")="",ZTSAVE("PSOPAR")="",ZTSAVE("PSODTCUT")="",ZTSAVE("PSOSITE")="",ZTSAVE("PSOPRPAS")="" D ^%ZTLOAD Q
PRPROF ;
F LLL=0:0 S LLL=$O(^UTILITY($J,"PSOPRO",LLL)) Q:'LLL I $D(^DPT(LLL,0)) S DFN=LLL D DQ^PSOPRFSS
K PSOPAR,PSODTCUT,PSOSITE,PSOPRPAS,LLL,DFN,^UTILITY($J,"PSOPRO") D ^%ZISC S:$D(ZTQUEUED) ZTREQ="@"
Q
;
CHKBAI ; IF BAD ADDRESS INDICATOR, NO ACTIVE TEMPORARY ADDRESS AND ROUTING OF MAIL, DO NOT SEND TO OPAI AND/OR DO NOT PRINT LABEL
N PSOBADR,ACTSEQ,XX,PSOFIRST,ACTTYPE
I '$G(RXFILL),$P(^PSRX(RXIEN,0),"^",11)="W" Q
I $P($G(^PSRX(RXIEN,1,RXFILL,0)),"^",2)="W" Q
S ACTTYPE="BAD ADDRESS INDICATOR"
S PSOBADR=$$CHKRX^PSOBAI(RXIEN)
; GOOD PERMANENT OR TEMPORARY ADDRESS - CHECK FOR DO NOT MAIL
I PSOBADR,'$P(PSOBADR,"^",2) D SETTMP(ACTTYPE) Q
S NOMAIL=0 D NOMAIL I NOMAIL Q
D FOREIGN
Q
;
SETTMP(ACTTYPE) ;
N ACTSEQ,XX,PSOFIRST,ZZ
S PSOFIRST=1
S PSOBADDR=1
S ACTSEQ=0 F S ACTSEQ=$O(^PSRX(RXIEN,"A",ACTSEQ)) Q:ACTSEQ="" D
.S XX=$G(^PSRX(RXIEN,"A",ACTSEQ,0)) I $P(XX,"^",2)="S" S ZZ=$P(XX,"^",4),ZZ=$S(ZZ<6:ZZ,1:ZZ-1) I ZZ=RXFILL,$P(XX,"^",5)["due to "_ACTTYPE S PSOFIRST=0 Q
I PSOFIRST D
.S ^TMP("PSOSBAI",$J,RXIEN,+RXFILL)=ACTTYPE
.D ACT(ACTTYPE)
Q
;
NOMAIL ; SEE IF FILE 55 STATUS IS DO NOT MAIL
N ACTTYPE,DFN,MAILST,MAILEXP
S ACTTYPE="DO NOT MAIL"
S DFN=+$P($G(^PSRX(RXIEN,0)),"^",2),MAILST=$P($G(^PS(55,DFN,0)),"^",3) I MAILST'=2 Q
S MAILEXP=$P(^PS(55,DFN,0),"^",5)
I MAILEXP=""!(MAILEXP>DT) D SETTMP(ACTTYPE)
Q
;
FOREIGN ;
N DFN,PSOFORGN
S DFN=+$P($G(^PSRX(RXIEN,0)),"^",2)
D ADD^VADPT
S PSOFORGN=$P($G(VAPA(25)),"^",2) I PSOFORGN'="",PSOFORGN'["UNITED STATES" S PSOFORGN=1
I PSOFORGN D SETTMP("FOREIGN ADDRESS")
Q
;
CHKMAIL ; SEE IF MAILMAN MESSAGE SHOULD BE SENT FOR BAI/MAIL ROUTING
N RXIEN,RXFILL,ACTSEQ,XX,DFN,SSN,NAME,ACTTYPE,ZZ
K ^TMP("PSOSM",$J)
S RXIEN=0 F S RXIEN=$O(^TMP("PSOSBAI",$J,RXIEN)) Q:'RXIEN D
.S RXFILL="" F S RXFILL=$O(^TMP("PSOSBAI",$J,RXIEN,RXFILL)) Q:RXFILL="" D
..S ACTTYPE=^TMP("PSOSBAI",$J,RXIEN,RXFILL)
..S ACTSEQ=0 F S ACTSEQ=$O(^PSRX(RXIEN,"A",ACTSEQ)) Q:ACTSEQ="" D
...S XX=$G(^PSRX(RXIEN,"A",ACTSEQ,0)) I $P(XX,"^",2)="S" S ZZ=$P(XX,"^",4),ZZ=$S(ZZ<6:ZZ,1:ZZ-1) I ZZ=RXFILL,$P(XX,"^",5)["due to "_ACTTYPE Q
...S DFN=$P(^PSRX(RXIEN,0),"^",2),NAME=$P(^DPT(DFN,0),"^"),SSN=$P(^(0),"^",9) I SSN="" S SSN=0
...S ^TMP("PSOSM",$J,NAME,SSN,RXIEN,RXFILL)=ACTTYPE
I $D(^TMP("PSOSM",$J)) D BAIMAIL^PSOSULB1
K ^TMP("PSOSM",$J)
Q
;
ACT(ACTTYPE) ;adds activity info for rx not printed from suspense/not sent to OPAI
N NOW,IR,FDA
D NOW^%DTC S NOW=%
S IR=0 F FDA=0:0 S FDA=$O(^PSRX(RXIEN,"A",FDA)) Q:'FDA S IR=FDA
S IR=IR+1,^PSRX(RXIEN,"A",0)="^52.3DA^"_IR_"^"_IR
S ^PSRX(RXIEN,"A",IR,0)=NOW_"^"_"S"_"^"_DUZ_"^"_$S(+RXFILL>5:RXFILL+1,1:+RXFILL)_"^"_"RX not printed from suspense due to "_ACTTYPE
K PSUS,RXF,I,FDA,DIC,DIE,DR,Y,X,%,%I,%H,RSDT
Q
;
PSOSULBL ;BHAM ISC/RTR,SAB-Print Suspended labels ;05-Sep-2013 14:45;PLS
+1 ;;7.0;OUTPATIENT PHARMACY;**139,173,1008,174,148,200,260,264,287,289,1015,1016**;DEC 1997;Build 74
+2 ;External reference ^PS(55 supported by DBIA 2228
+3 ;Reference to SAVNDC^PSSNDCUT supported by IA 4707
+4 ;Reference ^PSDRUG( supported by DBIA 221
+5 ;Modified - IHS/MSC/PLS - 02/12/09 - Calls to DQ^PSOLBL changed to DQ^APSPLBL
+6 ; 08/31/09 - Added setting of PSOPULL flag so that Dispense and Fill dates are updated
+7 KILL PDUZ,REPRINT
GOTO ^PSOSULB1
BEG ;
+1 KILL PSORUNIN,PSORETRY
NEW BPSCNT
+2 SET PSORUNIN="PSOSUSP"_($GET(PSOSITE))
+3 LOCK +@PSORUNIN:10
IF '$TEST
Begin DoDot:1
+4 ;wait Max of 2 hrs before continue
FOR PSORETRY=1:1:120
LOCK +@PSORUNIN:60
IF $TEST
QUIT
+5 QUIT
End DoDot:1
+6 KILL ^UTILITY($JOB,"PSOPRO"),^TMP("PSOSBAI",$JOB)
SET PSOSEQ=1
FOR DFN=0:0
SET DFN=$ORDER(^PS(52.5,"AC",DFN))
IF 'DFN
QUIT
Begin DoDot:1
+7 SET PSOSFLAG=0
FOR ZZ=0:0
SET ZZ=$ORDER(^PS(52.5,"AC",DFN,ZZ))
IF 'ZZ!$GET(PSOSFLAG)
QUIT
IF ZZ'>PRTDT
SET PSOSFLAG=1
End DoDot:1
IF 'PSRT
DO PID^VADPT6
DO CHKDEAD
IF 'DEAD&($GET(PSOSFLAG))
DO PRT
+8 DO PPL
+9 IF $DATA(^UTILITY($JOB,"PSOPRO"))&($PIECE(PSOPAR,"^",8))
DO PROF
+10 GOTO EXIT
PRT FOR SDT=0:0
SET SDT=$ORDER(^PS(52.5,"AC",DFN,SDT))
IF SDT
DO CHK
IF 'SDT
QUIT
+1 QUIT
EXIT ;
+1 IF $DATA(^TMP("PSOSBAI",$JOB))
DO CHKMAIL
+2 KILL ^TMP($JOB),^TMP("PSOSBAI",$JOB)
+3 IF $DATA(PSORUNIN)
LOCK -@PSORUNIN
+4 DO ^%ZISC
+5 KILL %,%ZIS,CNT,COM,DA,DEAD,DFN,DIRUT,DTTM,G,HDPPL,JJ,JJJ,JJJJ,PDUZ,IOP,ORD,PFIOQ,PSLION,PSRT,POP,PRF,PRTDT,PSLIO,PSNP,PSODBQ,PSOSEQ,PSOSFLAG,PSOSU,PSOTIME,PSOOUT,PSOPRFLG,PSOSEQ,PSOSUSPR,PSSPND,PST,PTL,PPLHLD,PSFNIEN,ZTSK
+6 KILL PSOBADDR,PSORUNIN,PSORETRY,PSRTONE,PSSRT,PSUSDEA,RF,RFCNT,RX,RXDFN,SDT,SFN,SREC,STOP,SUSPT,VADM,VAPA,X,X1,X2,XAK,XDATE,Y,Z,ZZ,WWW,PSDDDATE,SINRX,RXPR,RXPR1,GGGG,XXX,ZII,ZTDESC,ZTRTN,ZTSAVE,RRRR,RXRP,RXRP1,RXFL,SPR
IF $DATA(ZTQUEUED)
SET ZTREQ="@"
QUIT
CHK IF SDT'>XDATE
DO TMP
QUIT
+1 QUIT
TMP FOR SFN=0:0
SET SFN=$ORDER(^PS(52.5,"AC",DFN,SDT,SFN))
IF 'SFN
QUIT
Begin DoDot:1
+1 IF '$DATA(^PS(52.5,SFN,0))!'$DATA(^DPT(+DFN,0))
QUIT
+2 NEW RXSITE,PRINTED,PSDFN,RXSTS,RXIEN,RXFILL,PARTIAL,RXEXPDT,RESP,DSHLD
+3 SET RXIEN=+$$GET1^DIQ(52.5,SFN,.01,"I")
SET RXDFN=$$GET1^DIQ(52,RXIEN,2,"I")
+4 SET RXSTS=$$GET1^DIQ(52,RXIEN,100,"I")
SET RXSITE=+$$GET1^DIQ(52.5,SFN,.06,"I")
SET PRINTED=+$$GET1^DIQ(52.5,SFN,2,"I")
+5 SET PARTIAL=+$$GET1^DIQ(52.5,SFN,.05,"I")
SET RXEXPDT=$$GET1^DIQ(52,RXIEN,26,"I")
+6 SET RXFILL=$$GET1^DIQ(52.5,SFN,9,"I")
IF RXFILL=""
SET RXFILL=$$LSTRFL^PSOBPSU1(RXIEN)
+7 IF RXSITE=$GET(PSOSITE)
IF 'PRINTED
IF RXDFN=DFN
IF RXSTS<9
Begin DoDot:2
+8 IF PARTIAL
IF '$DATA(^PSRX(RXIEN,"P",PARTIAL))
QUIT
+9 IF RXEXPDT<DT
IF RXSTS<11
Begin DoDot:3
+10 NEW RXREC
SET RXREC=RXIEN
DO EX^PSOSUTL
+11 KILL DIE,DA
SET DIE=52
SET DA=RXIEN
SET DR="100///11"
DO ^DIE
KILL DIE,DA
+12 KILL DIK,DA
SET DA=SFN
SET DIK="^PS(52.5,"
DO ^DIK
KILL DIK,DA
End DoDot:3
QUIT
+13 SET PSOBADDR=0
DO CHKBAI
IF PSOBADDR
QUIT
+14 IF PSRT="D"
Begin DoDot:3
+15 SET PSSRT=$SELECT($GET(PSRTONE)="I":VA("PID"),1:$PIECE(^DPT(DFN,0),"^")_$PIECE(^(0),"^",9))
+16 SET PSUSDEA=$PIECE($GET(^PS(52.5,SFN,0)),"^",10)
+17 SET SRT=$SELECT(PSUSDEA["A"!(PSUSDEA["C"):"A-"_PSSRT,PSUSDEA["S":"S-"_PSSRT,1:"Z-"_PSSRT)
End DoDot:3
+18 IF PSRT'="D"
Begin DoDot:3
+19 SET SRT=$SELECT(PSRT:$PIECE(^DPT(DFN,0),"^")_$PIECE(^(0),"^",9),1:VA("PID"))
End DoDot:3
+20 ; - If not partial fill, sending Rx to ECME for 3rd Party billing
+21 IF 'PARTIAL
IF $$RETRX^PSOBPSUT(RXIEN,RXFILL)
IF SDT>DT
QUIT
+22 ;epharmacy-host errors
IF 'PARTIAL
IF $$FIND^PSOREJUT(RXIEN,RXFILL)
IF '$$DUR^PSOBPSU2(RXIEN,RXFILL)
QUIT
+23 ;epharmacy-3/4 days supply
IF 'PARTIAL
IF $$STATUS^PSOBPSUT(RXIEN,RXFILL-1)'=""
SET DSHLD=$$DSH^PSOSULB1(SFN)
IF 'DSHLD
QUIT
+24 IF 'PARTIAL
Begin DoDot:3
+25 IF $$FIND^PSOREJUT(RXIEN,RXFILL,,"79,88")
QUIT
+26 IF '$$RETRX^PSOBPSUT(RXIEN,RXFILL)
IF '$$ECMESTAT^PSXRPPL2(RXIEN,RXFILL)
QUIT
+27 DO ECMESND^PSOBPSU1(RXIEN,RXFILL,,"PL",,,,,,.RESP)
IF $DATA(RESP)
IF 'RESP
SET BPSCNT=$GET(BPSCNT)+1
End DoDot:3
IF $$FIND^PSOREJUT(RXIEN,RXFILL,,"79,88")
QUIT
IF $$TRISTA^PSOREJU3(RXIEN,RXFILL,.RESP,"PL")
QUIT
+28 SET ^TMP($JOB,SRT,SFN)=RXIEN
End DoDot:2
End DoDot:1
+29 QUIT
PPL ; Wait some time before printing so response from 3rd party payers can be received
+1 IF $GET(BPSCNT)>0
HANG 60+$SELECT((BPSCNT*15)>7200:7200,1:(BPSCNT*15))
+2 KILL PPL,PPL1
SET ORD=""
FOR
SET ORD=$ORDER(^TMP($JOB,ORD))
IF ORD=""
QUIT
DO PPL1
+3 QUIT
PPL1 ; Printing Labels
+1 NEW PARTIAL,REPRINT,REFILL,Z,QUIT
+2 ;IHS/MSC/PLS - 08/31/09
NEW PSOPULL
+3 SET (PSOPRFLG,SUSPT)=1
IF $DATA(PSOPROP)
SET PFIO=PSOPROP
+4 IF '$DATA(PDUZ)
SET PDUZ=DUZ
KILL RXPR,RXPR1,PPL
+5 FOR SFN=0:0
SET SFN=$ORDER(^TMP($JOB,ORD,SFN))
IF 'SFN
QUIT
Begin DoDot:1
+6 IF '$DATA(^PS(52.5,SFN,0))
QUIT
+7 SET Z=$GET(^PS(52.5,SFN,0))
SET SINRX=+$PIECE(Z,"^")
SET REFILL=+$PIECE(Z,"^",13)
+8 SET PARTIAL=$PIECE(Z,"^",5)
SET REPRINT=$PIECE(Z,"^",12)
+9 ; - Screening out OPEN/UNRESOLVED Rejects (3rd Party Payer)
+10 SET QUIT=0
+11 IF 'PARTIAL
IF 'REPRINT
Begin DoDot:2
+12 IF $$FIND^PSOREJUT(SINRX,REFILL,,"79,88")
SET QUIT=1
QUIT
+13 IF $$STATUS^PSOBPSUT(SINRX,REFILL)="IN PROGRESS"
SET QUIT=1
QUIT
+14 IF $$STATUS^PSOBPSUT(SINRX,REFILL)="E PAYABLE"
Begin DoDot:3
+15 DO SAVNDC^PSSNDCUT(+$$GET1^DIQ(52,SINRX,6,"I"),$$RXSITE^PSOBPSUT(SINRX,REFILL),$$GETNDC^PSONDCUT(SINRX,REFILL))
End DoDot:3
End DoDot:2
IF QUIT
QUIT
+16 ;
+17 IF $LENGTH($GET(PPL))<240
Begin DoDot:2
+18 SET PPL=$PIECE(^TMP($JOB,ORD,SFN),"^")_","_$GET(PPL)
SET RXPR(SINRX)=$PIECE(^PS(52.5,SFN,0),"^",5)
+19 IF $PIECE(^PS(52.5,SFN,0),"^",12)
SET RXRP(SINRX)=1
End DoDot:2
+20 IF '$TEST
Begin DoDot:2
+21 SET PPL1=$PIECE(^TMP($JOB,ORD,SFN),"^")_","_$GET(PPL1)
SET RXPR1(SINRX)=$PIECE(^PS(52.5,SFN,0),"^",5)
+22 IF $PIECE(^PS(52.5,SFN,0),"^",12)
SET RXRP1(SINRX)=1
End DoDot:2
+23 SET DFN=$PIECE(^PS(52.5,SFN,0),"^",3)
+24 IF $PIECE(PSOPAR,"^",8)
IF '$DATA(^PSRX($PIECE(^PS(52.5,SFN,0),"^"),1))
IF '$GET(RXPR(SINRX))
IF '$GET(RXPR1(SINRX))
SET PSOPRFLG=0
End DoDot:1
+25 SET PSNP=$SELECT($PIECE(PSOPAR,"^",8):1,1:0)
+26 IF $GET(PPL)
Begin DoDot:1
+27 SET PPLHLD=$GET(PPL1)
SET HDPPL=PPL
KILL PPL1
SET (PSODBQ,PSOSUSPR)=1
+28 FOR GGGG=0:0
SET GGGG=$ORDER(RXPR(GGGG))
IF 'GGGG
QUIT
IF '$GET(RXPR(GGGG))
KILL RXPR(GGGG)
End DoDot:1
+29 ;IHS/MSC/PLS - 02/12/09 - Changed to call IHS label routine
+30 ;I $G(PPL) D DQ^PSOLBL,SEQ D:'$G(PSOPRFLG)
+31 SET PSOPULL=1
+32 IF $GET(PPL)
DO DQ^APSPLBL
DO SEQ
IF '$GET(PSOPRFLG)
Begin DoDot:1
+33 IF $GET(PSOPROP)'=$GET(PSLION)
SET ^UTILITY($JOB,"PSOPRO",DFN)=""
QUIT
+34 DO DQ^PSOPRFSS
End DoDot:1
+35 IF $GET(PPLHLD)
KILL RXPR
SET (PPL,HDPPL)=PPLHLD
SET (PSODBQ,PSOSUSPR)=1
SET PSNP=0
IF '$DATA(PDUZ)
SET PDUZ=DUZ
FOR XXX=0:0
SET XXX=$ORDER(RXPR1(XXX))
IF 'XXX
QUIT
IF $GET(RXPR1(XXX))
SET RXPR(XXX)=RXPR1(XXX)
+36 IF $GET(PPLHLD)
FOR RRRR=0:0
SET RRRR=$ORDER(RXRP1(RRRR))
IF 'RRRR
QUIT
IF $DATA(RXRP1(RRRR))
SET RXRP(RRRR)=1
+37 ;IHS/MSC/PLS - 02/12/09 - Changed to call IHS label routine
+38 ;I $G(PPLHLD) D DQ^PSOLBL,SEQ D:'$G(PSOPRFLG)
+39 IF $GET(PPLHLD)
DO DQ^APSPLBL
DO SEQ
IF '$GET(PSOPRFLG)
Begin DoDot:1
+40 IF $GET(PSOPROP)'=$GET(PSLION)
SET ^UTILITY($JOB,"PSOPRO",DFN)=""
QUIT
+41 DO DQ^PSOPRFSS
End DoDot:1
+42 KILL PPL,PPL1,PPLHLD,RXPR,RXPR1,RXFL
QUIT
SEQ ;
+1 SET SQCOUNT=0
FOR JJJ=1:1:$LENGTH(HDPPL)
IF $EXTRACT(HDPPL,JJJ)=","
SET SQCOUNT=SQCOUNT+1
+2 FOR JJJJ=1:1:SQCOUNT
SET PSFNIEN=$PIECE(HDPPL,",",JJJJ)
IF PSFNIEN
Begin DoDot:1
+3 SET PSFNIEN=$ORDER(^PS(52.5,"B",PSFNIEN,0))
IF PSFNIEN
Begin DoDot:2
+4 SET $PIECE(^PS(52.5,PSFNIEN,0),"^",11)=PSOSEQ
SET PSOSEQ=PSOSEQ+1
IF $PIECE(^PS(52.5,PSFNIEN,0),"^",8)&($PIECE(^(0),"^",9))&($PIECE(^(0),"^",6))
SET ^PS(52.5,"AS",$PIECE(^PS(52.5,PSFNIEN,0),"^",8),$PIECE(^(0),"^",9),$PIECE(^(0),"^",6),$PIECE(^(0),"^",11),PSFNIEN)=""
End DoDot:2
End DoDot:1
+5 QUIT
CHKDEAD DO DEM^VADPT
IF VADM(1)=""
SET DEAD=0
QUIT
+1 IF VADM(6)=""
SET DEAD=0
QUIT
+2 SET PSDDDATE=$PIECE(VADM(6),"^",2)
FOR WWW=0:0
SET WWW=$ORDER(^PS(55,DFN,"P",WWW))
IF 'WWW
QUIT
IF $DATA(^PS(55,DFN,"P",WWW,0))
IF $PIECE($GET(^(0)),"^")
SET (DA,RXREC)=$PIECE(^(0),"^")
SET SFN=$ORDER(^PS(52.5,"B",RXREC,0))
IF SFN
IF $DATA(^PS(52.5,SFN,0))
SET RX=$PIECE(^(0),"^")
DO DEAD
+3 QUIT
DEAD SET $PIECE(^PSRX(RX,"STA"),"^")=12
SET COM="Died ("_$GET(PSDDDATE)_")"
SET DA(1)=RX
+1 SET DEAD=1
DO ARECD^PSOSUTL
SET DIK="^PS(52.5,"
SET DA=SFN
DO ^DIK
KILL DIK
+2 QUIT
PROF ;
+1 SET ZTRTN="PRPROF^PSOSULBL"
SET ZTDESC="PRINT PROFILES FROM SUSPENSE"
SET ZTDTH=$HOROLOG
SET ZTIO=PSOPROP
+2 SET ZTSAVE("^UTILITY($J,""PSOPRO"",")=""
SET ZTSAVE("PSOPAR")=""
SET ZTSAVE("PSODTCUT")=""
SET ZTSAVE("PSOSITE")=""
SET ZTSAVE("PSOPRPAS")=""
DO ^%ZTLOAD
QUIT
PRPROF ;
+1 FOR LLL=0:0
SET LLL=$ORDER(^UTILITY($JOB,"PSOPRO",LLL))
IF 'LLL
QUIT
IF $DATA(^DPT(LLL,0))
SET DFN=LLL
DO DQ^PSOPRFSS
+2 KILL PSOPAR,PSODTCUT,PSOSITE,PSOPRPAS,LLL,DFN,^UTILITY($JOB,"PSOPRO")
DO ^%ZISC
IF $DATA(ZTQUEUED)
SET ZTREQ="@"
+3 QUIT
+4 ;
CHKBAI ; IF BAD ADDRESS INDICATOR, NO ACTIVE TEMPORARY ADDRESS AND ROUTING OF MAIL, DO NOT SEND TO OPAI AND/OR DO NOT PRINT LABEL
+1 NEW PSOBADR,ACTSEQ,XX,PSOFIRST,ACTTYPE
+2 IF '$GET(RXFILL)
IF $PIECE(^PSRX(RXIEN,0),"^",11)="W"
QUIT
+3 IF $PIECE($GET(^PSRX(RXIEN,1,RXFILL,0)),"^",2)="W"
QUIT
+4 SET ACTTYPE="BAD ADDRESS INDICATOR"
+5 SET PSOBADR=$$CHKRX^PSOBAI(RXIEN)
+6 ; GOOD PERMANENT OR TEMPORARY ADDRESS - CHECK FOR DO NOT MAIL
+7 IF PSOBADR
IF '$PIECE(PSOBADR,"^",2)
DO SETTMP(ACTTYPE)
QUIT
+8 SET NOMAIL=0
DO NOMAIL
IF NOMAIL
QUIT
+9 DO FOREIGN
+10 QUIT
+11 ;
SETTMP(ACTTYPE) ;
+1 NEW ACTSEQ,XX,PSOFIRST,ZZ
+2 SET PSOFIRST=1
+3 SET PSOBADDR=1
+4 SET ACTSEQ=0
FOR
SET ACTSEQ=$ORDER(^PSRX(RXIEN,"A",ACTSEQ))
IF ACTSEQ=""
QUIT
Begin DoDot:1
+5 SET XX=$GET(^PSRX(RXIEN,"A",ACTSEQ,0))
IF $PIECE(XX,"^",2)="S"
SET ZZ=$PIECE(XX,"^",4)
SET ZZ=$SELECT(ZZ<6:ZZ,1:ZZ-1)
IF ZZ=RXFILL
IF $PIECE(XX,"^",5)["due to "_ACTTYPE
SET PSOFIRST=0
QUIT
End DoDot:1
+6 IF PSOFIRST
Begin DoDot:1
+7 SET ^TMP("PSOSBAI",$JOB,RXIEN,+RXFILL)=ACTTYPE
+8 DO ACT(ACTTYPE)
End DoDot:1
+9 QUIT
+10 ;
NOMAIL ; SEE IF FILE 55 STATUS IS DO NOT MAIL
+1 NEW ACTTYPE,DFN,MAILST,MAILEXP
+2 SET ACTTYPE="DO NOT MAIL"
+3 SET DFN=+$PIECE($GET(^PSRX(RXIEN,0)),"^",2)
SET MAILST=$PIECE($GET(^PS(55,DFN,0)),"^",3)
IF MAILST'=2
QUIT
+4 SET MAILEXP=$PIECE(^PS(55,DFN,0),"^",5)
+5 IF MAILEXP=""!(MAILEXP>DT)
DO SETTMP(ACTTYPE)
+6 QUIT
+7 ;
FOREIGN ;
+1 NEW DFN,PSOFORGN
+2 SET DFN=+$PIECE($GET(^PSRX(RXIEN,0)),"^",2)
+3 DO ADD^VADPT
+4 SET PSOFORGN=$PIECE($GET(VAPA(25)),"^",2)
IF PSOFORGN'=""
IF PSOFORGN'["UNITED STATES"
SET PSOFORGN=1
+5 IF PSOFORGN
DO SETTMP("FOREIGN ADDRESS")
+6 QUIT
+7 ;
CHKMAIL ; SEE IF MAILMAN MESSAGE SHOULD BE SENT FOR BAI/MAIL ROUTING
+1 NEW RXIEN,RXFILL,ACTSEQ,XX,DFN,SSN,NAME,ACTTYPE,ZZ
+2 KILL ^TMP("PSOSM",$JOB)
+3 SET RXIEN=0
FOR
SET RXIEN=$ORDER(^TMP("PSOSBAI",$JOB,RXIEN))
IF 'RXIEN
QUIT
Begin DoDot:1
+4 SET RXFILL=""
FOR
SET RXFILL=$ORDER(^TMP("PSOSBAI",$JOB,RXIEN,RXFILL))
IF RXFILL=""
QUIT
Begin DoDot:2
+5 SET ACTTYPE=^TMP("PSOSBAI",$JOB,RXIEN,RXFILL)
+6 SET ACTSEQ=0
FOR
SET ACTSEQ=$ORDER(^PSRX(RXIEN,"A",ACTSEQ))
IF ACTSEQ=""
QUIT
Begin DoDot:3
+7 SET XX=$GET(^PSRX(RXIEN,"A",ACTSEQ,0))
IF $PIECE(XX,"^",2)="S"
SET ZZ=$PIECE(XX,"^",4)
SET ZZ=$SELECT(ZZ<6:ZZ,1:ZZ-1)
IF ZZ=RXFILL
IF $PIECE(XX,"^",5)["due to "_ACTTYPE
QUIT
+8 SET DFN=$PIECE(^PSRX(RXIEN,0),"^",2)
SET NAME=$PIECE(^DPT(DFN,0),"^")
SET SSN=$PIECE(^(0),"^",9)
IF SSN=""
SET SSN=0
+9 SET ^TMP("PSOSM",$JOB,NAME,SSN,RXIEN,RXFILL)=ACTTYPE
End DoDot:3
End DoDot:2
End DoDot:1
+10 IF $DATA(^TMP("PSOSM",$JOB))
DO BAIMAIL^PSOSULB1
+11 KILL ^TMP("PSOSM",$JOB)
+12 QUIT
+13 ;
ACT(ACTTYPE) ;adds activity info for rx not printed from suspense/not sent to OPAI
+1 NEW NOW,IR,FDA
+2 DO NOW^%DTC
SET NOW=%
+3 SET IR=0
FOR FDA=0:0
SET FDA=$ORDER(^PSRX(RXIEN,"A",FDA))
IF 'FDA
QUIT
SET IR=FDA
+4 SET IR=IR+1
SET ^PSRX(RXIEN,"A",0)="^52.3DA^"_IR_"^"_IR
+5 SET ^PSRX(RXIEN,"A",IR,0)=NOW_"^"_"S"_"^"_DUZ_"^"_$SELECT(+RXFILL>5:RXFILL+1,1:+RXFILL)_"^"_"RX not printed from suspense due to "_ACTTYPE
+6 KILL PSUS,RXF,I,FDA,DIC,DIE,DR,Y,X,%,%I,%H,RSDT
+7 QUIT
+8 ;