source: WorldVistAEHR/trunk/r/PROSTHETICS-RMPR-RMPO-RMPS/RMPR9DO.m@ 1351

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

revised back to 6/30/08 version

File size: 9.2 KB
Line 
1RMPR9DO ;HOIFO/HNC - ORDER CONROL PROCESSING-REMOTE PROCEDURE ;9/8/03 07:12
2 ;;3.0;PROSTHETICS;**59,77,90,60**;Feb 09, 1996;Build 18
3 ;
4 ;8/5/03 Make sure no dups, HNC patch 77
5 ;
6A1(START,STOP,SITE,SORT,DATE,WHAT) ;entry point for rollup
7 ;activated from (option name)
8 I WHAT="S" D
9 .S STN1=0
10 .F S STN1=$O(^RMPR(669.9,STN1)) Q:STN1'>0 D
11 . .S SITE=STN1
12 . .D A2
13 I WHAT="ALL" G A2
14 Q
15EN(RESULT,DUZ,START,STOP,SITE,SORT,DATE,RMPRPRSN) ; -- Broker callback to get list to display
16 ;entry to send to PCM, WHAT=ALL or S for Summary Only
17 ;RMPRPRSN=P for Purchasing D for Delayed Order Report
18 S (WHO,RMPRSC)=""
19 I RMPRPRSN="P" S RMPRSC=$O(^RMPR(669.9,"PA",DUZ,RMPRSC)) Q:(RMPRSC="")!(WHO'="") D
20 . I '$D(^RMPR(669.9,RMPRSC,0)) Q
21 . I '$D(^RMPR(669.9,RMPRSC,5,"B",DUZ)) Q
22 . S WHO=$O(^RMPR(669.9,RMPRSC,5,"B",DUZ,""))
23 . I START="" S START=$P(^RMPR(669.9,RMPRSC,5,WHO,0),U,2)
24 . I STOP="" S STOP=$P(^RMPR(669.9,RMPRSC,5,WHO,0),U,3)
25A2 N STRING,CLREND,COLUMN,ON,OFF
26 Q:SORT=""
27 Q:DATE=""
28 Q:START=""
29 Q:STOP=""
30 Q:SITE=""
31 I SITE'="ALL" S SITE=$P(^RMPR(669.9,SITE,0),U,2)
32 K ^TMP($J)
33 N RMPRA,CDATE,X
34 K ADATE,PDAY,RMPRCD
35 S VALMCNT=0,RRX=""
36 ;if sort for open or pending include all regardless of date
37 ;if sort for cancelled or closed include from date passed forward
38 ;
39 ;PPD# status=pending before date, total days create to 1st action
40 ;MHD# manual totals days create to 1st action
41 ;CHD# consult totals days create to 1st action
42 ;PPDD# status=pending before date, total days in pending state, 1st
43 ; action to current date
44 ;
45 S (LINE,MHD1,MHD2,MHD3,MHD4,MHD5,CHD1,CHD2,CHD3,CHD4,CHD5,CLNK,MLNK)=0
46 S (PPDAY,PPD,PPD1,PPD2,PPD3,PPD4,PPD5)=0
47 S (PPDDAY,PPDD1,PPDD2,PPDD3,PPDD4,PPDD5)=0
48 I SORT["O"!(SORT["P") D ALL
49 I SORT["C"!(SORT["X") D DTFWD
50 ;S LINE=LINE+1
51 S ^TMP($J,"A1")="^^^^^^^^"_MHD1_U_MHD2_U_MHD3_U_MHD4_U_MHD5_"^^^^"_MLNK_U_0
52 I $G(WHAT)="S" S RMPRXM(1)=MHD1_U_MHD2_U_MHD3_U_MHD4_U_MHD5_U_MLNK_U_0
53 ;S LINE=LINE+1
54 S ^TMP($J,"A2")="^^^^^^^^"_CHD1_U_CHD2_U_CHD3_U_CHD4_U_CHD5_"^^^^"_CLNK_U_1
55 I $G(WHAT)="S" S RMPRXM(2)=CHD1_U_CHD2_U_CHD3_U_CHD4_U_CHD5_U_CLNK_U_1
56 ;S LINE=LINE+1
57 I $G(WHAT)="S" S RMPRXM(3)=PPD1_U_PPD2_U_PPD3_U_PPD4_U_PPD5_U_U_2
58 S ^TMP($J,"A3")="^^^^^^^^"_PPDD1_U_PPDD2_U_PPDD3_U_PPDD4_U_PPDD5_"^^^^^"_2
59 ;S LINE=LINE+1
60 S ^TMP($J,"A4")="^^^^^^^^"_PPD1_U_PPD2_U_PPD3_U_PPD4_U_PPD5_"^^^^^"_3
61 ;quarter rollup with full data
62 I $G(WHAT)="Q" D MAIL
63 ;summary only
64 I $G(WHAT)="S" D MAILG
65 I $G(WHAT)="ALL" D MAILG,MAIL
66 I '$G(WHAT) G EXIT
67 Q
68ALL ;all open pending records regardless of date passed
69 S RMPRI1=0
70 F RMPRI1=START:1:STOP D
71 .I $L(RMPRI1)=1 S RMPRI=0_RMPRI1
72 .E S RMPRI=RMPRI1
73 .S RMPRST=""
74 .F S RMPRST=$O(^RMPR(668,"L1",RMPRI,RMPRST)) Q:RMPRST="" D
75 . .Q:RMPRST="X"
76 . .Q:RMPRST="C"
77 . .I SORT'["P"&(RMPRST="P") Q
78 . .S RMPRA=0
79 . .F S RMPRA=$O(^RMPR(668,"L1",RMPRI,RMPRST,RMPRA)) Q:RMPRA'>0 D
80 . . .S STN=$P(^RMPR(668,RMPRA,0),U,7)
81 . . .I SITE'="ALL"&(SITE'=STN) Q
82 . . .S STNX=$$STATN^RMPRUTIL(STN)
83 . . .I $G(WHAT)="S" S VISNX=$P($G(^RMPR(669.9,STN1,"INV")),U,2)
84 . . .S STS=$P(^RMPR(668,RMPRA,0),U,10)
85 . . .Q:STS["X"
86 . . .Q:STS["C"
87 . . .I SORT'["O"&(STS="O") Q
88 . . .I SORT'["P"&(STS="P") Q
89 . . .D REC
90 Q
91DTFWD ;from date passed forward
92 S RMPRI1=0
93 F RMPRI1=START:1:STOP D
94 .I $L(RMPRI1)=1 S RMPRI=0_RMPRI1
95 .E S RMPRI=RMPRI1
96 .S RMPRDTM=""
97 .F S RMPRDTM=$O(^RMPR(668,"L",RMPRI,RMPRDTM)) Q:RMPRDTM="" D
98 ..Q:RMPRDTM=""
99 ..Q:RMPRDTM<DATE
100 ..S RMPRST=""
101 ..F S RMPRST=$O(^RMPR(668,"L",RMPRI,RMPRDTM,RMPRST)) Q:RMPRST="" D
102 .. .Q:RMPRST="O"
103 .. .Q:RMPRST="P"
104 .. .I SORT'["X"&(RMPRST="X") Q
105 .. .I SORT'["C"&(RMPRST="C") Q
106 .. .S RMPRA=0
107 .. .F S RMPRA=$O(^RMPR(668,"L",RMPRI,RMPRDTM,RMPRST,RMPRA)) Q:RMPRA'>0 D
108 .. . .Q:RMPRA=""
109 .. . .S STN=$P(^RMPR(668,RMPRA,0),U,7)
110 .. . .I SITE'="ALL"&(SITE'=STN) Q
111 .. . .S STNX=$$STATN^RMPRUTIL(STN)
112 .. . .I $G(WHAT)'="" S VISNX=$P($G(^RMPR(669.9,SITE,"INV")),U,2)
113 .. . .S STS=$P(^RMPR(668,RMPRA,0),U,10)
114 .. . .Q:STS["O"
115 .. . .Q:STS["P"
116 .. . .I SORT'["C"&(STS="C") Q
117 .. . .I SORT'["X"&(STS="X") Q
118 .. . .D REC
119 S RMPRDTC=$P(DATE,".",1)
120 F S RMPRDTC=$O(^RMPR(668,"CD",RMPRDTC)) Q:RMPRDTC="" D
121 .Q:RMPRDTC<DATE
122 .S RMPRDYS=0
123 .F S RMPRDYS=$O(^RMPR(668,"CD",RMPRDTC,RMPRDYS)) Q:RMPRDYS="" D
124 . .Q:RMPRDYS'>5
125 . .S RMPRA=0
126 . .F S RMPRA=$O(^RMPR(668,"CD",RMPRDTC,RMPRDYS,RMPRA)) Q:RMPRA'>0 D
127 . . .;check site
128 . . .S STN=$P(^RMPR(668,RMPRA,0),U,7)
129 . . .I SITE'="ALL"&(SITE'=STN) Q
130 . . .S STNX=$$STATN^RMPRUTIL(STN)
131 . . .;check status
132 . . .S STS=$P(^RMPR(668,RMPRA,0),U,10)
133 . . .I SORT'["O"&(STS="O") Q
134 . . .I SORT'["P"&(STS="P") Q
135 . . .I SORT'["C"&(STS="C") Q
136 . . .I SORT'["X"&(STS="X") Q
137 . . .;ssn range filter
138 . . .S DFN=$P(^RMPR(668,RMPRA,0),U,2)
139 . . .D DEM^VADPT
140 . . .S SSNEN=$E($P(VADM(2),"^",2),10,11)
141 . . .I SSNEN>STOP Q
142 . . .I SSNEN<START Q
143 . . .K SSNEN,VADM
144 . . .D REC
145 Q
146REC ;records to grid
147 ;stop date, init action date
148 ;check ien, patch 77
149 ;
150 Q:$D(^TMP($J,RMPRA))
151 ;
152 N DIC,DIQ,DR,STOPDT
153 S DA=RMPRA
154 S DIC=668,DIQ="RE",DR=10,DIQ(0)="EN" D EN^DIQ1
155 S STOPDT=$P($G(^RMPR(668,RMPRA,0)),U,9),STOPDT=$$DAT2^RMPRUTL1(STOPDT)
156 S LINE=LINE+1
157 S CDATE=$P(^RMPR(668,RMPRA,0),U,1),CDATE=$$DAT2^RMPRUTL1(CDATE)
158 S DFN=$P(^RMPR(668,RMPRA,0),U,2) Q:DFN=""
159 N VA,VADM
160 D DEM^VADPT
161 S WHO=VADM(1)
162 S SSN=VADM(2)
163 D SVC^VADPT
164 S RMPROEOI=$S(VASV(11)>0:"<!>",VASV(12)>0:"<!>",VASV(13)>0:"<!>",1:0)
165 D KVAR^VADPT
166 ;type
167 S TYPE=$$TYPE^RMPREOU(RMPRA,8)
168 ;display description if manual
169 S DES=$$DES^RMPREOU(RMPRA,22)
170 S DES=$TR(DES,"^","*")
171 S DES=$TR(DES,"""","'")
172 ;init action date
173 S ADATE="",PDAY="",WRKDAY=""
174 S ADATE=$P(^RMPR(668,RMPRA,0),U,9)
175 ;PPD=1 for previous pending
176 I ADATE'="" S (PDAY,WRKDAY)=$$WRKDAY^RMPREOU(RMPRA)
177 I ADATE="" S (PDAY,WRKDAY)=$$CWRKDAY^RMPREOU(RMPRA)
178 I ADATE'="" S CDAY=$$PDAY^RMPREOU(RMPRA)
179 S STATUS=$$STATUS^RMPREOU(RMPRA)
180 I STATUS["PENDING" D
181 .I ADATE'=""&(ADATE<DATE) S PPD=1
182 .S PPDAY=$$PWRKDAY^RMPREOU(RMPRA)
183 S LINKED=$P($G(^RMPR(668,RMPRA,10,0)),U,4)
184 I LINKED="" S LINKED=0
185 ;
186 I RMPROEOI="<!>" S WHO=RMPROEOI_WHO
187 S ^TMP($J,RMPRA)=CDATE_U_WHO_U_SSN_U_TYPE_U_DES_U
188 ;look at pday and parse
189 S (HD1,HD2,HD3,HD4,HD5,DH6)=""
190 ;SD Working Days in Pending Status
191 S (SD1,SD2,SD3,SD4,SD5)=0
192 I (PDAY>0)&(PDAY<6)!(PDAY=0) S HD1=PDAY,DH6="NO"
193 I (PPDAY>0)&(PPDAY<6)!(PPDAY=0) S SD1=PPDAY
194 I (PDAY>0)&(PDAY<6)&(TYPE["MANUAL")!(PDAY=0)&(TYPE["MANUAL") S MHD1=MHD1+1
195 I (PDAY>0)&(PDAY<6)&(TYPE'["MANUAL")!(PDAY=0)&(TYPE'["MANUAL") S CHD1=CHD1+1
196 I (PPDAY>0)&(PPDAY<6)&(STATUS["PENDING") S PPDD1=PPDD1+1
197 I (PDAY>0)&(PDAY<6)&(PPD=1) S PPD1=PPD1+1
198 I HD1="" S HD1=0
199 I (PDAY>5)&(PDAY<10) S HD2=PDAY,DH6="YES"
200 I (PPDAY>5)&(PPDAY<10) S SD2=PPDAY
201 I (PDAY>5)&(PDAY<10)&(TYPE["MANUAL") S MHD2=MHD2+1
202 I (PDAY>5)&(PDAY<10)&(TYPE'["MANUAL") S CHD2=CHD2+1
203 I (PPDAY>5)&(PPDAY<10)&(STATUS["PENDING") S PPDD2=PPDD2+1
204 I (PDAY>5)&(PDAY<10)&(PPD=1) S PPD2=PPD2+1
205 I HD2="" S HD2=0
206 I (PDAY>9)&(PDAY<30) S HD3=PDAY,DH6="YES"
207 I (PPDAY>9)&(PPDAY<30) S SD3=PPDAY
208 I (PDAY>9)&(PDAY<30)&(TYPE["MANUAL") S MHD3=MHD3+1
209 I (PDAY>9)&(PDAY<30)&(TYPE'["MANUAL") S CHD3=CHD3+1
210 I (PPDAY>9)&(PPDAY<30)&(STATUS["PENDING") S PPDD3=PPDD3+1
211 I (PDAY>9)&(PDAY<30)&(PPD=1) S PPD3=PPD3+1
212 I HD3="" S HD3=0
213 I (PDAY>29)&(PDAY<90) S HD4=PDAY,DH6="YES"
214 I (PPDAY>29)&(PPDAY<90) S SD4=PPDAY
215 I (PDAY>29)&(PDAY<90)&(TYPE["MANUAL") S MHD4=MHD4+1
216 I (PDAY>29)&(PDAY<90)&(TYPE'["MANUAL") S CHD4=CHD4+1
217 I (PPDAY>29)&(PPDAY<90)&(STATUS["PENDING") S PPDD4=PPDD4+1
218 I (PDAY>29)&(PDAY<90)&(PPD=1) S PPD4=PPD4+1
219 I HD4="" S HD4=0
220 I PDAY>89 S HD5=PDAY,DH6="YES"
221 I PPDAY>89 S SD5=PPDAY
222 I (PDAY>89)&(TYPE["MANUAL") S MHD5=MHD5+1
223 I (PDAY>89)&(TYPE'["MANUAL") S CHD5=CHD5+1
224 I (PPDAY>89)&(STATUS["PENDING") S PPDD5=PPDD5+1
225 I (PDAY>89)&(PPD=1) S PPD5=PPD5+1
226 I HD5="" S HD5=0
227 S (PPD,PPDAY)=0
228 I LINKED'=0&(TYPE["MANUAL") S MLNK=MLNK+1
229 I LINKED'=0&(TYPE'["MANUAL") S CLNK=CLNK+1
230 S ^TMP($J,RMPRA)=^TMP($J,RMPRA)_STOPDT_U_DH6_U_HD1_U_HD2_U_HD3_U_HD4_U_HD5
231 S ^TMP($J,RMPRA)=^TMP($J,RMPRA)_U_STATUS_U_RMPRA_U_STNX_U_LINKED
232 S ^TMP($J,RMPRA)=^TMP($J,RMPRA)_U_U_SD1_U_SD2_U_SD3_U_SD4_U_SD5
233 K CDATE,WHO,SSN,TYPE,DES,PDAY,STATUS,ADATE
234 ;PUT RESULTS IN GLOBAL!!
235 Q
236EXIT ;common exit point
237 S RESULT=$NA(^TMP($J))
238 Q
239MAIL ;send to PCM full dataset
240 S XMY("G.RMPR SERVER")=""
241 S XMY("G.PROSTHETICS@PSAS.MED.VA.GOV")=""
242 S XMDUZ=.5
243 S XMSUB="Full DOR From Station: "_STNX
244 N LASTIEN
245 S LASTIEN="A1",LASTIEN=$O(^TMP($J,LASTIEN),-1)
246 S ^TMP($J,LASTIEN+1)=^TMP($J,"A1")
247 S ^TMP($J,LASTIEN+2)=^TMP($J,"A2")
248 S ^TMP($J,LASTIEN+3)=^TMP($J,"A3")
249 S ^TMP($J,LASTIEN+4)=^TMP($J,"A4")
250 K ^TMP($J,"A1")
251 K ^TMP($J,"A2")
252 K ^TMP($J,"A3")
253 K ^TMP($J,"A4")
254 S XMTEXT="^TMP($J,"
255 D ^XMD
256 Q
257MAILG ;Mail message to local staff
258 S XMDUZ=.5
259 S XMY("G.RMPR SERVER")=""
260 S XMY("VHACOPSASPIPReport@MED.VA.GOV")=""
261 S XMSUB="DOR From Station: "_STNX
262 S RMPRMSG(1)="The Automated Delayed Order Report has transmitted to Prosthetics HQ."
263 S RMPRMSG(2)="This was activated by "_$P(XMFROM,"@",1)
264 S RMPRMSG(3)=""
265 S RMPRMSG(4)="Summary Data Transmitted, includes the following:"
266 S RMPRMSG(5)="Totals for site "_STNX_" listed in the order of 0-5, 6-9, 10-29, 30-89, 90+"
267 S RMPRMSG(6)="Seperated by ;"
268 S RMPRMSG(7)="***Number of MANUALS ;;"_STNX_";"_MHD1_";"_MHD2_";"_MHD3_";"_MHD4_";"_MHD5
269 S RMPRMSG(8)="***Number of CONSULTS ;;"_STNX_";"_CHD1_";"_CHD2_";"_CHD3_";"_CHD4_";"_CHD5
270 S RMPRMSG(9)="***Minus Previous Pending ;;"_STNX_";"_PPD1_";"_PPD2_";"_PPD3_";"_PPD4_";"_PPD5
271 S RMPRMSG(10)=""
272 S XMTEXT="RMPRMSG("
273 D ^XMD
274 Q
Note: See TracBrowser for help on using the repository browser.