source: WorldVistAEHR/trunk/r/OUTPATIENT_PHARMACY-PSO-APSP-HUIP/PSOCPBK3.m@ 1270

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

initial load of WorldVistAEHR

File size: 6.3 KB
RevLine 
[613]1PSOCPBK3 ;BIR/GN-Copay Back Bill for Automated-release refills ;10/6/05 4:57pm
2 ;;7.0;OUTPATIENT PHARMACY;**217**;DEC 1997
3 ;External reference to ^XUSEC supported by DBIA 10076
4 ;External reference to IBARX supported by DBIA 125
5 ;External reference to $$PROD^XUPROD(1) supported by DBIA 4440
6 ;
7 N NAMSP,DTOUT,DUOUT,ZTSK,ZTRTN,ZTIO,ZTDTH,ZTDESC,QUIT,RUNOPT,JOBN,Y
8 S NAMSP=$$NAMSP
9 S JOBN="Back Bill"
10 ;
11 L +^XTMP(NAMSP):0 I '$T D Q
12 . D BMES^XPDUTL(JOBN_" job is already running. Halting...")
13 . D MES^XPDUTL("")
14 . D QUIT
15 ;
16 I '$D(^XTMP(NAMSP)) D INITXTMP(NAMSP,"BACK BILLING of unbilled copays for refills via OPAI, PSO*7*217",90) ;90 day life
17 S QUIT=0
18 ;
19 ;ques 1, if running from mumps prompt
20 I '$D(XPDQUES("POS1")) D I QUIT D QUIT Q
21 . ;selected cancel run at last install, dont allow to run manually
22 . I $G(^XTMP(NAMSP,0,"LAST"))["CANCEL" D Q
23 . . S QUIT=1
24 . . W !!,*7,"The last install of this patch you selected to NOT Run Back-Billing"
25 . . W !,"If you have changed your mind, you must re-install the patch to run",!!
26 . K DIR
27 . S DIR("A",1)="****************** SELECT RUN OPTION ******************"
28 . S DIR("A")="Do you want to run the Back-Billing process? "
29 . S DIR(0)="YA^^"
30 . D ^DIR I $D(DTOUT)!($D(DUOUT)) W !,"Halting..." S QUIT=1 Q
31 . S RUNOPT=Y
32 . S:'RUNOPT QUIT=1
33 ;
34 ;ques 1, if running from kids install
35 I $D(XPDQUES("POS1")) D I 'RUNOPT D QUIT Q
36 . S RUNOPT=XPDQUES("POS1")
37 . S:'RUNOPT ^XTMP(NAMSP,0,"LAST")="CANCEL RUN^"_$$NOW^XLFDT_"^^^"
38 . D BMES^XPDUTL("***** SELECTED "_$S('RUNOPT:"NOT ",1:"")_"TO RUN BACK-BILLING *****")
39 ;
40 I $G(^XTMP(NAMSP,0,"LAST"))["COMPLETED" D Q
41 . W !!,*7,"This job has been run before to completion on "
42 . W $$FMTE^XLFDT($P($G(^XTMP(NAMSP,0,"LAST")),"^",2)),!!
43 . D QUIT
44 ;
45 ;ques 2, if running from mumps prompt
46 I '$D(XPDQUES("POS2")) D I 'ZTDTH D QUIT Q
47 . K DIR
48 . S DIR("A")="Enter when to Queue the "_JOBN_" job to run in date@time format "
49 . S DIR("B")="NOW"
50 . S DIR(0)="D^::%DT"
51 . S DIR("?")="Enter when to start the job. The default is Now. You can enter a date and time in the format like this: 081505@3:30p"
52 . D ^DIR I $D(DTOUT)!($D(DUOUT)) W !,"Halting..." S ZTDTH="" Q
53 . S ZTDTH=$$FMTH^XLFDT(Y)
54 ;
55 ;ques 2, if running from kids install
56 I $D(XPDQUES("POS2")) S ZTDTH=$$FMTH^XLFDT(XPDQUES("POS2"))
57 ;
58 D BMES^XPDUTL("===================================================")
59 D MES^XPDUTL("Queuing background job to "_JOBN_" unbilled refills...")
60 D MES^XPDUTL("Start time: "_$$HTE^XLFDT(ZTDTH))
61 D MES^XPDUTL("===================================================")
62 I ZTDTH="" D BMES^XPDUTL(JOBN_" NOT QUEUED") D QUIT Q
63 ;
64 I $P($G(^XTMP(NAMSP,0,"LAST")),"^")="STOP" D
65 . S $P(^XTMP(NAMSP,0,"LAST"),"^",1,2)="RUN^"_$$NOW^XLFDT
66 E D
67 . S ^XTMP(NAMSP,0,"LAST")="RUN^"_$$NOW^XLFDT_"^^^"
68 ;
69 S ZTRTN="EN^PSOCPBK3",ZTIO=""
70 S ZTDESC="Background job to "_JOBN_" unbilled copays for refills via OPAI"
71 S ZTSAVE("JOBN")=""
72 L -^XTMP(NAMSP)
73 D ^%ZTLOAD
74 D:$D(ZTSK)
75 . D MES^XPDUTL("*** Task #"_ZTSK_" Queued! ***")
76 . D BMES^XPDUTL("")
77 D BMES^XPDUTL("")
78 K XPDQUES
79 Q
80QUIT ;
81 L -^XTMP(NAMSP)
82 Q
83EN ;
84 N NAMSP S NAMSP=$$NAMSP
85 ;if can't get Lock, then already running.
86 L +^XTMP(NAMSP):3 I '$T D Q
87 . S:$D(ZTQUEUED) ZTREQ="@"
88 . S $P(^XTMP(NAMSP,0,"LAST"),"^",1,2)="LOCKED^"_$$NOW^XLFDT
89 ;
90 N PSODT,RXP,PSOTEXT,XX,YY,PSOCNT,PSOSTART,PSOEND,PSOVETS,PSOTRX,XIEN
91 N PSOSCMX,PSODFN,PSOREL,PSOAMT,FOUND,V24,PSOTRF,PSOEND2,PSOSTRT2,CC
92 N PSOTIME,PSOSTNM,PSOS1,PSOINST,I,PSOTC,PSOCNTS,LIN,%,X1,XMY,STO
93 D NOW^%DTC S (Y,PSOS1)=% D DD^%DT S PSOSTART=Y
94 S PSOSTRT2=$$FMTE^XLFDT(%,"1PS")
95 I '$G(DT) S DT=$$DT^XLFDT
96 S PSODT=+$P($G(^XTMP(NAMSP,0,"LAST")),"^",3)
97 S RXP=+$P($G(^XTMP(NAMSP,0,"LAST")),"^",4)
98 ;
99 ;get 1st occurence of install date of patch PSO*7*156 (OPAI)
100 S XIEN=+$O(^XPD(9.7,"B","PSO*7.0*156",0))
101 S:'PSODT PSODT=+$P($G(^XPD(9.7,XIEN,1)),"^",3)
102 I 'PSODT D Q
103 . S ^XTMP(NAMSP,0,.1)="OPAI PATCH PSO*7*156 IS NOT INSTALLED"
104 . S $P(^XTMP(NAMSP,0,"LAST"),"^",1,2)="COMPLETED^"_$$NOW^XLFDT
105 . D MAIL3^PSOCPBK5(^XTMP(NAMSP,0,.1))
106 ;
107 ;check if any division is on v2.4 (OPAI interface)
108 S V24=0
109 F XX=0:0 S XX=$O(^PS(59,XX)) Q:'XX D Q:V24
110 . S:+$G(^PS(59,XX,"DISP"))=2.4 V24=1
111 I 'V24 D Q
112 . S ^XTMP(NAMSP,0,.2)="OPAI IS INSTALLED BUT IS NOT TURNED ON"
113 . S $P(^XTMP(NAMSP,0,"LAST"),"^",1,2)="COMPLETED^"_$$NOW^XLFDT
114 . D MAIL3^PSOCPBK5(^XTMP(NAMSP,0,.2))
115 ;
116 S (PSOTRX,PSOTRF)=1
117 N STOP K ^XTMP(NAMSP,0,"STOP") S STOP=0 ;init stop flag to 0
118 F CC=1:1 S PSODT=$O(^PSRX("AL",PSODT)) Q:'PSODT D Q:STOP
119 . I CC#100=0,$D(^XTMP(NAMSP,0,"STOP")) D Q
120 . . S $P(^XTMP(NAMSP,0,"LAST"),"^",1,2)="STOP^"_$$NOW^XLFDT,STOP=1
121 . F PSOTRX=PSOTRX+1:1 S RXP=$O(^PSRX("AL",PSODT,RXP)) Q:'RXP D
122 .. ;save last date & fill info
123 .. S $P(^XTMP(NAMSP,0,"LAST"),"^",3,5)=PSODT_"^"_RXP_"^"_PSOTRX
124 .. S PSODFN=$P($G(^PSRX(RXP,0)),"^",2)
125 .. Q:('PSODFN)!('$D(^DPT(PSODFN,0))) ;quit, no valid DFN info
126 .. D XTYPE^PSOCPBK4
127 .. Q:+PSOSCMX=0 ;quit, Exempt or deceased
128 .. ;search refills only, ignore 0=orig fill
129 .. F YY=0:0 S YY=$O(^PSRX("AL",PSODT,RXP,YY)) Q:'YY D ADDBILL^PSOCPBK4
130 Q:STOP
131 ;
132 S PSOCNT=0
133 D BILLIT^PSOCPBK4 Q:STOP
134 D TOTAL^PSOCPBK4
135 S $P(^XTMP(NAMSP,0,"LAST"),"^",1,2)="COMPLETED^"_$$NOW^XLFDT
136 D MAIL^PSOCPBK5
137 D MAIL2^PSOCPBK5
138 D MAILAAC^PSOCPBK5
139 L -^XTMP(NAMSP)
140 S:$D(ZTQUEUED) ZTREQ="@"
141 K JOBN
142 Q
143 ;
144STATUS ;show status of job running
145 I $$ST D
146 . W !,"Currently processing:"
147 . I ^XTMP($$NAMSP,0,"LAST")["COMPLETED" D
148 . . W !,"COMPLETED ON ",$$FMTE^XLFDT($P($G(^XTMP($$NAMSP,0,"LAST")),"^",2)),!
149 . W !?5,"Released Date > ",$P(^XTMP($$NAMSP,0,"LAST"),"^",3)
150 . W !?5," RX # > ",$P(^XTMP($$NAMSP,0,"LAST"),"^",4)
151 . W !?5," TOTAL RX's > ",$P(^XTMP($$NAMSP,0,"LAST"),"^",5),!
152 . E D
153 . I ^XTMP($$NAMSP,0,"LAST")["COMPLETED" D
154 . . W !,"COMPLETED ON ",$$FMTE^XLFDT($P($G(^XTMP($$NAMSP,0,"LAST")),"^",2)),!
155 Q
156 ;
157STOP ;stop job command
158 I $$ST S ^XTMP($$NAMSP,0,"STOP")="" D
159 . W !,"Outpatient RX Copay Tally Job - set to STOP Soon"
160 . W !!,"Check Status to be sure it has stopped and is not running..."
161 . W !," (D STATUS^PSOCPBK3)"
162 Q
163ST() ;status
164 L +^XTMP($$NAMSP):3 I $T D Q 0
165 . L -^XTMP($$NAMSP)
166 . W !,"*** NOT CURRENTLY RUNNING! ***",!
167 Q 1
168INITXTMP(NAMSP,TITLE,LIFE) ;create ^Xtmp according to SAC std
169 N BEGDT,PURGDT
170 S BEGDT=$$NOW^XLFDT()
171 S PURGDT=$$FMADD^XLFDT(BEGDT,LIFE)
172 S ^XTMP(NAMSP,0)=PURGDT_"^"_BEGDT_"^"_TITLE
173 Q
174NAMSP() ;
175 Q $T(+0)
Note: See TracBrowser for help on using the repository browser.