201 lines
9.2 KiB
Mathematica
201 lines
9.2 KiB
Mathematica
PSOCPIB3 ;BIR/EJW-Clean up to bill unbilled NON-SERVICE CONNECTED copays ;12/12/02
|
|
;;7.0;OUTPATIENT PHARMACY;**123**;DEC 1997
|
|
;External reference to ^XUSEC supported by DBIA 10076
|
|
;External reference to ^IBAM(354.7 supported by DBIA 3877
|
|
S ZTDTH=""
|
|
I $D(ZTQUEUED) S ZTDTH=$H
|
|
L +^XTMP("PSOCPIB3"):0 I '$T D Q
|
|
. I ZTDTH="" D BMES^XPDUTL("Clean up job is already running. Halting...")
|
|
L -^XTMP("PSOCPIB3")
|
|
I ZTDTH="" D
|
|
.D BMES^XPDUTL("Clean up for unbilled, released NON-SERVICE CONNECTED prescription fills.")
|
|
.D BMES^XPDUTL("If no start date/time is entered when prompted, the background job will be ")
|
|
.D MES^XPDUTL("queued to run NOW.")
|
|
.D GETDATE
|
|
.D BMES^XPDUTL("Queuing background job to reprocess unbilled NON-SERVICE CONNECTED fills...")
|
|
S ZTRTN="EN^PSOCPIB3",ZTIO="",ZTDESC="Background job to reprocess NON-SERVICE CONNECTED unbilled copays" D ^%ZTLOAD K ZTDTH,ZTRTN,ZTIO,ZTDESC
|
|
W:$D(ZTSK)&('$D(ZTQUEUED)) !!,"Task Queued !",!
|
|
Q
|
|
EN ;
|
|
L +^XTMP("PSOCPIB3"):0 I '$T S:$D(ZTQUEUED) ZTREQ="@" Q
|
|
N PSODT,RXP,PSOTEXT,YY,PSOCNT,PSOSTART,PSOEND
|
|
S PSOCNT=0
|
|
D NOW^%DTC S Y=% D DD^%DT S PSOSTART=Y
|
|
I '$G(DT) S DT=$$DT^XLFDT
|
|
I '$D(^XTMP("PSOCPIB3")) S X1=DT,X2=+90 D C^%DTC S ^XTMP("PSOCPIB3",0)=$G(X)_"^"_DT
|
|
I $D(^XTMP("PSOCPBAK")) G PROCESS ; POTENTIALLY BILLABLE FILLS ALREADY IDENTIFIED
|
|
S PSODT=3020203.235959 ; START WITH DATE $7 COPAY WENT INTO EFFECT
|
|
F S PSODT=$O(^PSRX("AL",PSODT)) Q:'PSODT S RXP="" F S RXP=$O(^PSRX("AL",PSODT,RXP)) Q:'RXP D
|
|
.S PSODFN=$P($G(^PSRX(RXP,0)),"^",2) Q:PSODFN="" I '$D(^DPT(PSODFN,0)) Q
|
|
.I $G(^XTMP("PSOCPBAK",$J,PSODFN)) Q ; EXEMPT OR SC QUESTION APPLIES-- NOTHING TO REPROCESS FOR THIS PATIENT
|
|
.S BADDT=$G(^XTMP("PSOCPBAK",$J,PSODFN,RXP))
|
|
.I 'BADDT D CHKLOG^PSOCPBAK
|
|
.I BADDT,BADDT'>$P(PSODT,".") D
|
|
..I '$D(^XTMP("PSOCPBAK",$J,PSODFN)) D XTYPE^PSOCPBAK S ^XTMP("PSOCPBAK",$J,PSODFN)=$S(PSOSCMX=1:"",1:1) I PSOSCMX'=1 Q ; QUIT IF SC QUESTION APPLIES -- NOTHING TO REPROCESS
|
|
..S YY="" F S YY=$O(^PSRX("AL",PSODT,RXP,YY)) Q:YY="" D
|
|
...S PSOREL=$S(YY=0:$P(^PSRX(RXP,2),"^",13),1:$P($G(^PSRX(RXP,1,YY,0)),"^",18)) I 'PSOREL Q ; RELEASED DATE WON'T BE PRESENT IF RETURNED TO STOCK
|
|
...I 'YY I $P($G(^PSRX(RXP,"IB")),"^",2)'="" Q ; ALREADY BILLED
|
|
...I 'YY I $P($G(^PSRX(RXP,"IB")),"^",4)'="" Q ; ALREADY BILLED (POTENTIAL BILL - EXCEEDED ANNUAL CAP)
|
|
...I YY,$P($G(^PSRX(RXP,1,YY,"IB")),"^",1)'="" Q ; REFILL ALREADY BILLED
|
|
...I YY,$P($G(^PSRX(RXP,1,YY,"IB")),"^",2)'="" Q ; REFILL ALREADY BILLED (POTENTIAL BILL - EXCEEDED ANNUAL CAP)
|
|
...S PSOXIN=$$RXST^IBARXEU(PSODFN,$P(PSOREL,".")) I $P($G(PSOXIN),"^")=1 Q ; INCOME EXEMPT ON RELEASE DATE
|
|
...I '$D(^XTMP("PSOCPBAK",$J,PSODFN,RXP)) S ^XTMP("PSOCPBAK",$J,PSODFN,RXP)=BADDT
|
|
...S ^XTMP("PSOCPBAK",$J,PSODFN,RXP,YY)=$P(PSOREL,".") ; SAVE TO PROCESS IN "BILL" SECTION
|
|
PROCESS ;
|
|
S PSOJ=0 F S PSOJ=$O(^XTMP("PSOCPBAK",PSOJ)) Q:'PSOJ D BILL
|
|
D MAIL
|
|
D MAIL2
|
|
L -^XTMP("PSOCPIB3")
|
|
S:$D(ZTQUEUED) ZTREQ="@"
|
|
Q
|
|
;
|
|
MAIL ;
|
|
D NOW^%DTC S Y=% D DD^%DT S PSOEND=Y
|
|
I $G(DUZ) S XMY(DUZ)=""
|
|
S XMDUZ="Outpatient Pharmacy",XMSUB="Outpatient Pharmacy Copay Clean-up"
|
|
F PSOCXPDA=0:0 S PSOCXPDA=$O(^XUSEC("PSO COPAY",PSOCXPDA)) Q:'PSOCXPDA S XMY(PSOCXPDA)=""
|
|
I $O(XMY(""))="" Q ; no recipients for mail message
|
|
S PSOTEXT(1)="The Rx copay clean up job for the Outpatient Pharmacy patch (PSO*7*123)"
|
|
S PSOTEXT(2)="started "_PSOSTART_" and completed "_PSOEND_"."
|
|
I PSOCNT>0 S PSOTEXT(3)="Released non-service connected prescriptions have now been reprocessed."
|
|
I PSOCNT>0 S PSOTEXT(4)="There were "_PSOCNT_" fills successfully billed." D
|
|
.S PSOTEXT(5)=" "
|
|
.S PSOTEXT(6)="To get a report of patient names/prescriptions that were billed as part of this"
|
|
.S PSOTEXT(7)="clean-up, enter D RPT^PSOCPIB3 at the programmer's prompt."
|
|
I PSOCNT=0 S PSOTEXT(3)="No released unbilled copay fills were found to reprocess."
|
|
S XMTEXT="PSOTEXT(" N DIFROM D ^XMD K XMDUZ,XMTEXT,XMSUB
|
|
Q
|
|
;
|
|
MAIL2 ; SEND NAME INFO FOR USE BY AAC
|
|
K XMY,PSOTEXT
|
|
S PSOCNT=0
|
|
S PSOINST=$P($G(^DIC(4,+$P($G(^XMB(1,1,"XUS")),"^",17),99)),"^")
|
|
S XMY(DUZ)=""
|
|
S XMY("WHITE.ELAINE@FORUM.VA.GOV")=""
|
|
S XMY("CARROLL.DAN@FORUM.VA.GOV")=""
|
|
S XMDUZ="PSO*7*123",XMSUB=$G(PSOINST)_" - AAC DATA"
|
|
S PSONAM="" F S PSONAM=$O(^XTMP("PSOCPIB3",$J,"BILLED",PSONAM)) Q:PSONAM="" S PSODFN="" F S PSODFN=$O(^XTMP("PSOCPIB3",$J,"BILLED",PSONAM,PSODFN)) Q:PSODFN="" D
|
|
.S DFN=PSODFN D DEM^VADPT
|
|
.S PSOCNT=PSOCNT+1,PSOTEXT(PSOCNT)=PSOINST_"^"_$G(VA("BID"))_$E($P(PSONAM,","),1,5)
|
|
I '$D(PSOTEXT) S PSOTEXT(1)="NO BILLED FILLS FOR INSTITUTION: "_PSOINST
|
|
S XMTEXT="PSOTEXT(" N DIFROM D ^XMD K XMDUZ,XMTEXT,XMSUB
|
|
Q
|
|
;
|
|
BILL ;
|
|
; IF NO IB NUMBER FOR THIS FILL, SET UP VARIABLES AND CALL CP^PSOCP. IF THERE IS AN IB NUMBER AFTER THIS CALL, COUNT IT FOR SUMMARY MAIL MSG
|
|
S PSODFN="" F S PSODFN=$O(^XTMP("PSOCPBAK",PSOJ,PSODFN)) Q:'PSODFN D
|
|
.I $G(^XTMP("PSOCPBAK",PSOJ,PSODFN)) Q ; EXEMPT OR SC QUESTION APPLIES
|
|
.S PSOCAP(302)=0
|
|
.S PSOCAP(303)=0
|
|
.S RXP="" F S RXP=$O(^XTMP("PSOCPBAK",PSOJ,PSODFN,RXP)) Q:'RXP S YY="" F S YY=$O(^XTMP("PSOCPBAK",PSOJ,PSODFN,RXP,YY)) Q:YY="" D
|
|
..S PSOREL=$G(^XTMP("PSOCPBAK",PSOJ,PSODFN,RXP,YY))
|
|
..S PSOCPUN=$P(($P(^PSRX(RXP,0),"^",8)+29)/30,".",1) ; NUMBER OF 30-DAY UNITS ELIGIBLE TO BILL
|
|
..S PSOSVUN=PSOCPUN
|
|
..D CHKTOT
|
|
..I PSOCAP($E(PSOREL,1,3)) Q ; ANNUAL CAP MET
|
|
..I 'YY D Q
|
|
...I $P($G(^PSRX(RXP,"IB")),"^",2)'="" Q ; ALREADY BILLED
|
|
...D SITE^PSOCPBA2
|
|
...D CP^PSOCP
|
|
...S PSOBILL=$P($G(^PSRX(RXP,"IB")),"^",2) I PSOBILL'="" D
|
|
....S PSONAM=$P($G(^DPT(PSODFN,0)),"^") I PSONAM="" S PSONAM="UNKNOWN"
|
|
....S PSORXP=$P($G(^PSRX(RXP,0)),"^") I PSORXP="" Q
|
|
....S PSOCNT=PSOCNT+1
|
|
....S ^XTMP("PSOCPIB3",$J,"BILLED",PSONAM,PSODFN,PSORXP,YY)=$P(PSOREL,".")
|
|
....D ACCUM
|
|
..I $P($G(^PSRX(RXP,1,YY,"IB")),"^",1)="" D ; REFILL LEVEL
|
|
...D SITE^PSOCPBA2
|
|
...D CP^PSOCP
|
|
...S PSOBILL=$P($G(^PSRX(RXP,1,YY,"IB")),"^",1) I PSOBILL'="" D
|
|
....S PSONAM=$P($G(^DPT(PSODFN,0)),"^") I PSONAM="" S PSONAM="UNKNOWN"
|
|
....S PSORXP=$P($G(^PSRX(RXP,0)),"^") I PSORXP="" Q
|
|
....S PSOCNT=PSOCNT+1
|
|
....S ^XTMP("PSOCPIB3",$J,"BILLED",PSONAM,PSODFN,PSORXP,YY)=$P(PSOREL,".")
|
|
....D ACCUM
|
|
Q
|
|
;
|
|
GETDATE ; GET DATE/TIME OF WHEN BACKGROUND JOB SHOULD BE RUN
|
|
S PSOQUES="Queue copay clean-up Job to run Date@Time: "
|
|
D GETDATE^PSOCPIB4
|
|
Q
|
|
;
|
|
RPT ;
|
|
L +^XTMP("PSOCPIB3"):0 I '$T D Q
|
|
. W !,"Clean up job for PSO*7*123 is still running. Halting..."
|
|
L -^XTMP("PSOCPIB3")
|
|
W !!,"This report shows the patient name and prescription information for fills"
|
|
W !,"that were billed as part of patch PSO*7*123 clean-up."
|
|
W !!,"You may queue the report to print, if you wish.",!
|
|
;
|
|
DVC K %ZIS,POP,IOP S %ZIS="QM" D ^%ZIS I $G(POP) W !!,"Nothing queued to print.",! G DONE
|
|
QUEUE I $D(IO("Q")) S ZTRTN="START^PSOCPIB3",ZTDESC="Billed copay report" D ^%ZTLOAD K %ZSI W !,"Report queued to print.",! G DONE
|
|
START ;
|
|
U IO
|
|
S PSOOUT=0,PSODV=$S($E(IOST)="C":"C",1:"P")
|
|
S PSOPGCT=0,PSOPGLN=IOSL-7,PSOPGCT=1
|
|
D TITLE
|
|
S PSOJ=0
|
|
F S PSOJ=$O(^XTMP("PSOCPIB3",PSOJ)) Q:PSOJ="" S PSONAM="" F S PSONAM=$O(^XTMP("PSOCPIB3",PSOJ,"BILLED",PSONAM)) Q:PSONAM="" S PSODFN="" F S PSODFN=$O(^XTMP("PSOCPIB3",PSOJ,"BILLED",PSONAM,PSODFN)) Q:PSODFN="" D
|
|
.W !
|
|
.S RXP="" F S RXP=$O(^XTMP("PSOCPIB3",PSOJ,"BILLED",PSONAM,PSODFN,RXP)) Q:RXP="" S PSOFILL="" F S PSOFILL=$O(^XTMP("PSOCPIB3",PSOJ,"BILLED",PSONAM,PSODFN,RXP,PSOFILL)) Q:PSOFILL="" D
|
|
..N XX
|
|
..S XX=$G(^XTMP("PSOCPIB3",PSOJ,"BILLED",PSONAM,PSODFN,RXP,PSOFILL)) D
|
|
...D FULL Q:$G(PSOOUT) W !,PSONAM D PRTSSN
|
|
...W ?39," ",RXP," (",PSOFILL,")" D
|
|
....S Y=XX I Y>0 X ^DD("DD")
|
|
....W ?65," ",Y
|
|
G END
|
|
;
|
|
FULL ;
|
|
I ($Y+7)>IOSL&('$G(PSOOUT)) D TITLE
|
|
Q
|
|
;
|
|
TITLE ;
|
|
I $G(PSODV)="C",$G(PSOPGCT)'=1 W ! K DIR S DIR(0)="E" D ^DIR K DIR I 'Y S PSOOUT=1 Q
|
|
;
|
|
W @IOF D
|
|
. W !,"Patch PSO*7*123 -COPAY PRESCRIPTION FILLS BILLED"
|
|
S Y=DT X ^DD("DD") W !,"Date printed: ",Y,?70,"Page: ",PSOPGCT,!
|
|
F MJT=1:1:79 W "="
|
|
W !,"PATIENT NAME (SSN) DIV",?40,"RX# (FILL)",?66,"RELEASE DATE"
|
|
W !,"------------------------",?40,"----------",?66,"------------"
|
|
S PSOPGCT=PSOPGCT+1
|
|
Q
|
|
END ;
|
|
I '$G(PSOOUT),$G(PSODV)="C" W !!,"** End of Report **" K DIR S DIR(0)="E",DIR("A")="Press Return to continue" D ^DIR K DIR
|
|
I $G(PSODV)="C" W !
|
|
E W @IOF
|
|
DONE ;
|
|
K MJT,PSOPGCT,PSOPGLN,Y,DIR,X,IOP,POP,IO("Q"),DIRUT,DUOUT,DTOUT
|
|
D ^%ZISC S:$D(ZTQUEUED) ZTREQ="@"
|
|
Q
|
|
;
|
|
PRTSSN ;
|
|
N DFN
|
|
S DFN=PSODFN D PID^VADPT
|
|
S PSORXP=$O(^PSRX("B",RXP,"")) I PSORXP="" Q
|
|
S PSODIV=$P($G(^PSRX(PSORXP,2)),"^",9) S:PSODIV'="" PSODIV=$P($G(^PS(59,PSODIV,0)),"^",1)
|
|
W " ("_$G(VA("BID"))_")"_" "_PSODIV
|
|
Q
|
|
;
|
|
ACCUM ; ACCUMULATE TOTALS AND SEE IF PATIENT MET ANNUAL CAP
|
|
S PSOYR=$E(PSOREL,1,3)
|
|
S PSOCPUN=PSOSVUN
|
|
I PSOYR'=302,PSOYR'=303 Q
|
|
S PSOTOT=$G(^XTMP("PSOCPIB3",$J,PSODFN,PSOYR))
|
|
S ^XTMP("PSOCPIB3",$J,PSODFN,PSOYR)=PSOTOT+(PSOCPUN*7)
|
|
Q
|
|
;
|
|
CHKTOT ; SEE IF BILLING THIS FILL WOULD GO OVER CAP
|
|
S PSOYR=$E(PSOREL,1,3)
|
|
I PSOYR'=302,PSOYR'=303 Q
|
|
S PSOTOT=$G(^XTMP("PSOCPIB3",$J,PSODFN,PSOYR))
|
|
I 'PSOTOT D S ^XTMP("PSOCPIB3",$J,PSODFN,PSOYR)=PSOTOT
|
|
.S PSOSQ=0 F S PSOSQ=$O(^IBAM(354.7,PSODFN,1,PSOSQ)) Q:'PSOSQ S PSOLOG=$G(^IBAM(354.7,PSODFN,1,PSOSQ,0)) I $E(PSOLOG,1,3)=PSOYR D
|
|
..I $E(PSOLOG,1,5)="30201" Q ; DON'T LOOK AT JANUARY 2002 TOTALS
|
|
..S PSOTOT=PSOTOT+$P(PSOLOG,"^",2)
|
|
I PSOYR=302,PSOTOT+(7*PSOCPUN)>770 S PSOCAP(PSOYR)=1 Q ; BILLING FOR THIS WOULD EXCEED ANNUAL CAP
|
|
I PSOYR=303,PSOTOT+(7*PSOCPUN)>840 S PSOCAP(PSOYR)=1 Q ; BILLING FOR THIS WOULD EXCEED ANNUAL CAP
|
|
Q
|
|
;
|