source: FOIAVistA/trunk/r/OUTPATIENT_PHARMACY-PSO-APSP-HUIP/PSOCPBAK.m@ 1540

Last change on this file since 1540 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 6.4 KB
Line 
1PSOCPBAK ;BIR/EJW-Tally unbilled NON-SERVICE CONNECTED copays ;03/28/03
2 ;;7.0;OUTPATIENT PHARMACY;**137,268**;DEC 1997;Build 9
3 ;External reference to ^XUSEC supported by DBIA 10076
4 ;External reference to IBARX supported by DBIA 125
5 S ZTDTH=""
6 I $D(ZTQUEUED) S ZTDTH=$H
7 L +^XTMP("PSOCPBAK"):$S(+$G(^DD("DILOCKTM"))>0:+^DD("DILOCKTM"),1:3) I '$T D Q
8 . I ZTDTH="" D BMES^XPDUTL("Tally job is already running. Halting...")
9 L -^XTMP("PSOCPBAK")
10 I ZTDTH="" D
11 .D BMES^XPDUTL("Tally unbilled, released NON-SERVICE CONNECTED prescription fills.")
12 .D BMES^XPDUTL("If no start date/time is entered when prompted, the background job will be ")
13 .D MES^XPDUTL("queued to run NOW.")
14 .D GETDATE
15 .D BMES^XPDUTL("Queuing background job to tally unbilled NON-SERVICE CONNECTED fills...")
16 S ZTRTN="EN^PSOCPBAK",ZTIO="",ZTDESC="Background job to tally NON-SERVICE CONNECTED unbilled copays" D ^%ZTLOAD K ZTDTH,ZTRTN,ZTIO,ZTDESC
17 W:$D(ZTSK)&('$D(ZTQUEUED)) !!,"Task Queued !",!
18 Q
19EN ;
20 L +^XTMP("PSOCPBAK"):$S(+$G(^DD("DILOCKTM"))>0:+^DD("DILOCKTM"),1:3) I '$T S:$D(ZTQUEUED) ZTREQ="@" Q
21 N PSODT,RXP,PSOTEXT,YY,PSOCNT,PSOSTART,PSOEND,PSOVETS
22 S PSOCNT=0
23 D NOW^%DTC S (Y,PSOS1)=% D DD^%DT S PSOSTART=Y
24 S PSOSTRT2=$$FMTE^XLFDT(%,"1PS")
25 I '$G(DT) S DT=$$DT^XLFDT
26 I '$D(^XTMP("PSOCPBAK")) S X1=DT,X2=+90 D C^%DTC S ^XTMP("PSOCPBAK",0)=$G(X)_"^"_DT
27 S PSODT=3020203.235959 ; START WITH DATE $7 COPAY WENT INTO EFFECT
28 F S PSODT=$O(^PSRX("AL",PSODT)) Q:'PSODT S RXP="" F S RXP=$O(^PSRX("AL",PSODT,RXP)) Q:'RXP D
29 .S PSODFN=$P($G(^PSRX(RXP,0)),"^",2) Q:PSODFN="" I '$D(^DPT(PSODFN,0)) Q
30 .I $G(^XTMP("PSOCPBAK",$J,PSODFN)) Q ; EXEMPT OR SC QUESTION APPLIES-- NOTHING TO REPROCESS FOR THIS PATIENT
31 .S BADDT=$G(^XTMP("PSOCPBAK",$J,PSODFN,RXP))
32 .I 'BADDT D CHKLOG
33 .I BADDT,BADDT'>$P(PSODT,".") D
34 ..I '$D(^XTMP("PSOCPBAK",$J,PSODFN)) D XTYPE S ^XTMP("PSOCPBAK",$J,PSODFN)=$S(PSOSCMX=1:"",1:1) I PSOSCMX'=1 Q ; QUIT IF SC QUESTION APPLIES -- NOTHING TO REPROCESS
35 ..S YY="" F S YY=$O(^PSRX("AL",PSODT,RXP,YY)) Q:YY="" D
36 ...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
37 ...I 'YY I $P($G(^PSRX(RXP,"IB")),"^",2)'="" Q ; ALREADY BILLED
38 ...I 'YY I $P($G(^PSRX(RXP,"IB")),"^",4)'="" Q ; ALREADY BILLED (POTENTIAL BILL - EXCEEDED ANNUAL CAP)
39 ...I YY,$P($G(^PSRX(RXP,1,YY,"IB")),"^",1)'="" Q ; REFILL ALREADY BILLED
40 ...I YY,$P($G(^PSRX(RXP,1,YY,"IB")),"^",2)'="" Q ; REFILL ALREADY BILLED (POTENTIAL BILL - EXCEEDED ANNUAL CAP)
41 ...S PSOXIN=$$RXST^IBARXEU(PSODFN,$P(PSOREL,".")) I $P($G(PSOXIN),"^")=1 Q ; INCOME EXEMPT ON RELEASE DATE
42 ...I '$D(^XTMP("PSOCPBAK",$J,PSODFN,RXP)) S ^XTMP("PSOCPBAK",$J,PSODFN,RXP)=BADDT
43 ...S ^XTMP("PSOCPBAK",$J,PSODFN,RXP,YY)=$P(PSOREL,".") ; SAVE TO PROCESS IN "BILL" SECTION
44 D TALLY^PSOCPBA2
45 D TOTAL
46 D MAIL
47 D MAIL2
48 L -^XTMP("PSOCPBAK")
49 S:$D(ZTQUEUED) ZTREQ="@"
50 Q
51 ;
52MAIL ;
53 D NOW^%DTC S Y=% D DD^%DT S PSOEND=Y
54 I $G(DUZ) S XMY(DUZ)=""
55 S XMDUZ="Outpatient Pharmacy",XMSUB="Outpatient Pharmacy Copay Tally"
56 F PSOCXPDA=0:0 S PSOCXPDA=$O(^XUSEC("PSO COPAY",PSOCXPDA)) Q:'PSOCXPDA S XMY(PSOCXPDA)=""
57 I $O(XMY(""))="" Q ; no recipients for mail message
58 S PSOTEXT(1)="The Rx copay tally job for the Outpatient Pharmacy patch (PSO*7*137)"
59 S PSOTEXT(2)="started "_PSOSTART_" and completed "_PSOEND_"."
60 I PSOCNT>0 S PSOTEXT(3)="Released non-service connected prescriptions have now been reprocessed."
61 I PSOCNT>0 S PSOTEXT(4)="There were "_PSOCNT_" fills successfully tallied for "_$G(PSOVETS)_" veterans." D
62 .S PSOTEXT(5)=" "
63 .S PSOTEXT(6)="Fills eligible for back-billing by year:"
64 .S PSOTEXT(7)="2002 30-DAY EQUIVALENT FILLS: "_PSOCNT("YR2002",1)
65 .S PSOTEXT(8)="2002 60-DAY EQUIVALENT FILLS: "_PSOCNT("YR2002",2)
66 .S PSOTEXT(9)="2002 90-DAY EQUIVALENT FILLS: "_PSOCNT("YR2002",3)
67 .S PSOTEXT(10)=""
68 .S PSOTEXT(11)="2003 30-DAY EQUIVALENT FILLS: "_PSOCNT("YR2003",1)
69 .S PSOTEXT(12)="2003 60-DAY EQUIVALENT FILLS: "_PSOCNT("YR2003",2)
70 .S PSOTEXT(13)="2003 90-DAY EQUIVALENT FILLS: "_PSOCNT("YR2003",3)
71 I PSOCNT=0 S PSOTEXT(3)="No released unbilled copay fills were found."
72 S XMTEXT="PSOTEXT(" N DIFROM D ^XMD K XMDUZ,XMTEXT,XMSUB
73 Q
74 ;
75MAIL2 ;
76 N I,COUNTS
77 D NOW^%DTC S PSOTIME=$$FMDIFF^XLFDT(%,PSOS1,2)
78 S PSOINST=$P($G(^DIC(4,+$P($G(^XMB(1,1,"XUS")),"^",17),99)),"^")
79 K PSOTEXT
80 S COUNTS=""
81 F J="YR2002","YR2003" F I=1:1:3 S COUNTS=COUNTS_"^"_PSOCNT(J,I)
82 K XMY(DUZ)
83 S XMY("WHITE.ELAINE@FORUM.VA.GOV")=""
84 S XMY("CARROLL.DAN@FORUM.VA.GOV")=""
85 S XMDUZ="PSO*7*137 TALLY",XMSUB=$G(PSOINST)_" - COUNTS"
86 S PSOTEXT(1)=PSOSTRT2_"^"_PSOTIME_"^"_$G(PSOVETS)_"^"_PSOCNT_COUNTS
87 S XMTEXT="PSOTEXT(" N DIFROM D ^XMD K XMDUZ,XMTEXT,XMSUB
88 Q
89 ;
90CHKLOG ;
91 S BADDT=""
92 S PSOSQ=0 F S PSOSQ=$O(^PSRX(RXP,"COPAY",PSOSQ)) Q:'PSOSQ S PSOLOG=$G(^PSRX(RXP,"COPAY",PSOSQ,0)) I PSOLOG["Service Connected" S BADDT=$P(PSOLOG,".") Q
93 Q
94 ;
95GETDATE ; GET DATE/TIME OF WHEN BACKGROUND JOB SHOULD BE RUN
96 S ZTDTH=""
97 S NOW=0
98 D NOW^%DTC S (Y,TODAY)=% D DD^%DT
99 D BMES^XPDUTL("At the following prompt, enter a starting date@time")
100 D MES^XPDUTL("or enter NOW to queue the job immediately.")
101 D BMES^XPDUTL("If this prompting is during patch installation, you will not see what you type.")
102 W ! K %DT D NOW^%DTC S %DT="RAEX",%DT(0)=%,%DT("A")="Queue copay tally Job to run Date@Time: "
103 D ^%DT K %DT I $D(DTOUT)!(Y<0) W "Task will be queued to run NOW" S ZTDTH=$H,NOW=1
104 I 'NOW,Y>0 D
105 .S SAVEY=Y
106 .D DD^%DT
107 .S X=Y
108 .S Y=SAVEY
109ASK D BMES^XPDUTL("Task will be queued to run "_$S(NOW:"NOW",1:X)_". Is that correct? :")
110 R XX:300 S:'$T XX="Y" I XX'="Y",XX'="y",XX'="N",XX'="n" W " Enter Y or N" G ASK
111 I XX'="Y",XX'="y" G GETDATE
112 I Y>0,ZTDTH="" S ZTDTH=Y
113 I ZTDTH="" S ZTDTH=$H
114 Q
115 ;
116XTYPE ;
117 N Y,I,J,X,SAVY,DFN
118 S DFN=PSODFN D DEM^VADPT I +$G(VADM(6)) S PSOSCMX="" Q ; DECEASED
119 S (X,PSOSCMX,SAVY)=""
120 S J=0 F S J=$O(^PS(59,J)) Q:'J I +$G(^(J,"IB")) S X=+^("IB") Q
121 I 'X Q
122 S X=X_"^"_PSODFN D XTYPE^IBARX
123 I $G(Y)'=1 Q
124 S J="" F S J=$O(Y(J)) Q:'J S I="" F S SAVY=I,I=$O(Y(J,I)) Q:I="" S:I>0 PSOSCMX=I
125 I PSOSCMX="",SAVY=0 Q ; INCOME EXEMPT OR SERVICE-CONNECTED
126 I PSOSCMX=2 Q ; NEED TO ASK SC QUESTION
127 Q
128 ;
129TOTAL ;
130 N COUNT,COUNTED
131 I '$D(PSOVETS) S PSOVETS=0
132 N I,J
133 F I=1:1:3 S (PSOCNT("YR2002",I),PSOCNT("YR2003",I))=0
134 S PSODFN=0 F S PSODFN=$O(^XTMP("PSOCPBAK",$J,PSODFN)) Q:'PSODFN D
135 .S COUNTED=0
136 .F J="YR2002","YR2003" F I=1:1:3 S COUNT=$G(^XTMP("PSOCPBAK",$J,PSODFN,J,I)) I COUNT>0 S:'$G(COUNTED) COUNTED=1,PSOVETS=PSOVETS+1 S PSOCNT(J,I)=PSOCNT(J,I)+COUNT
137 F I=1:1:3 S PSOCNT=PSOCNT+PSOCNT("YR2002",I)+PSOCNT("YR2003",I)
138 Q
139 ;
Note: See TracBrowser for help on using the repository browser.