source: WorldVistAEHR/trunk/r/REGISTRATION-DGQE-DG-DPT-GRPX-VAD-VAF-VAS-VAT-VAU--VA-VIC--DGBT--DGJ--DGYA--VALM/DG53735P.m@ 1789

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

initial load of WorldVistAEHR

File size: 8.1 KB
Line 
1DG53735P ;EG,TMK - Re-transmit OEF-OIF Data to HEC ; 10/24/2006
2 ;;5.3;Registration;**735**;Aug 13,1993;Build 11
3 ; LOGIC USED:
4 ; - Find all veterans with OEF/OIF data using the 'ALOEIF;' cross
5 ; reference by latest OEF/OIF TO DATE and patient
6 ; - Check the PATIENT file (#2) record for a valid CV end date.
7 ; - If the CV end date is not valid, or
8 ; If the CV End Date is valid, but the last Z07 message transmission
9 ; for the veteran was dated before the OEF/OIF data was added,
10 ; Flag the record so it will be sent to HEC via an HL7 Z07 message
11 ; and if the CV End date was not valid, update it to be the
12 ; calculated value.
13 ;
14EP ; Queue the conversion
15 N %
16 S %=$$NEWCP^XPDUTL("IEN12","POST^DG53735P")
17 S %=$$NEWCP^XPDUTL("END","END^DG53735P") ; Leave as last update
18 Q
19 ;
20POST N ZTSK
21 D BMES^XPDUTL("Queue-ing Transmit OEF/OIF data to HEC ...")
22 D QUE
23 D BMES^XPDUTL("This request queued as Task # "_$G(ZTSK))
24 D BMES^XPDUTL("=====================================================")
25 D BMES^XPDUTL("")
26 Q
27 ;
28END ; Post-install done
29 D BMES^XPDUTL("Post install complete.")
30 Q
31 ;
32QUE N ZTRTN,ZTDESC,ZTSAVE,ZTIO,ZTDTH
33 S ZTRTN="RUN^DG53735P",ZTDESC="Re-transmit of OEF/OIF Data"
34 S ZTIO="",ZTDTH=$$NOW^XLFDT()
35 D ^%ZTLOAD
36 Q
37 ;
38RUN ;entry point from taskman
39 N NAMSPC
40 S NAMSPC=$$NAMSPC
41 I '$$CHKSTAT(1,NAMSPC) D Q
42 . D BMES^XPDUTL("Conversion routine already running, process aborted")
43 N TESTING
44 S TESTING="N" K ^XTMP(NAMSPC) D DEQUE(NAMSPC)
45 Q
46 ;
47TEST ; test entry point
48 N TESTING,X,STARTDT,ENDDT,NAMSPC
49 S NAMSPC=$$NAMSPC
50 S TESTING="Y"
51 S X=$$CHKSTAT(0,NAMSPC)
52 K ^XTMP(NAMSPC,"TEST RANGE"),^XTMP(NAMSPC,"TEST")
53 S STARTDT=$$TESTID("Starting ")
54 Q:'STARTDT
55 S ENDDT=$$TESTID("Ending ")
56 Q:'ENDDT
57 I ENDDT<STARTDT W !,?10,"Ending To Date can't be less than starting To Date" Q
58 S ^XTMP(NAMSPC,"TEST RANGE")=STARTDT_U_ENDDT
59 D DEQUE(NAMSPC)
60 Q
61 ;
62TESTID(MESS) ;
63 N DGX,DIR,DTOUT,DUOUT,X,Y
64 S DIR(0)="DA",DIR("A")=MESS_" To Date for OEF/OIF xref: "
65 W !! D ^DIR K DIR
66 S DGX=Y
67 I $D(DUOUT)!$D(DTOUT) S DGX=""
68 Q DGX
69 ;
70DEQUE(NAMSPC) ;
71 N X
72 I '$D(TESTING) N TESTING S TESTING="N"
73 D SETUPX(90,NAMSPC)
74 S X=$G(^XTMP(NAMSPC,0,0))
75 S $P(X,U,6)="RUNNING"
76 S $P(X,U,7)=$$NOW^XLFDT()
77 S ^XTMP(NAMSPC,0,0)=X
78 ;
79 S ZTSTOP=$$LOOP(NAMSPC,TESTING)
80 S X=$G(^XTMP(NAMSPC,0,0))
81 S $P(X,U,6)=$S(ZTSTOP:"STOPPED",1:"COMPLETED")
82 S $P(X,U,8)=$$NOW^XLFDT()
83 S ^XTMP(NAMSPC,0,0)=X
84 ;
85 D MAIL(NAMSPC,TESTING,DUZ)
86 K TESTING
87 L -^XTMP(NAMSPC)
88 Q
89 ;
90SETUPX(EXPDAYS,NAMSPC) ;
91 ; requires EXPDAYS - # of days to keep XTMP
92 N BEGTIME,PURGDT
93 S BEGTIME=$$NOW^XLFDT()
94 S PURGDT=$$FMADD^XLFDT(BEGTIME,EXPDAYS)
95 S ^XTMP(NAMSPC,0)=PURGDT_U_BEGTIME
96 S $P(^XTMP(NAMSPC,0),U,3)="Transmit unsent OEF/OIF data to HEC"
97 Q
98 ;
99LOOP(NAMSPC,TESTING) ;
100 ;returns stop flag
101 N X,XREC,LASTREC,TOTREC,TOTPAT
102 S LASTREC="0;0;;0;0",ZTSTOP=0
103 S TOTREC=0
104 I $D(^XTMP(NAMSPC,0,0)) D
105 . S XREC=$G(^XTMP(NAMSPC,0,0))
106 . ;last TODT processed
107 . S LASTREC=$P(XREC,U,1)
108 . ;total records read
109 . S TOTREC=+$P(XREC,U,2)
110 . S TOTPAT=+$P(XREC,U,10)
111 . Q
112 D ALOEIF(NAMSPC,TESTING,.ZTSTOP)
113 Q ZTSTOP
114 ;
115ALOEIF(NAMSPC,TESTING,ZTSTOP) ;
116 N CONF,DFN,END,FIRST,FRDT,IEN,TODT,X
117 S ZTSTOP=0
118 S TODT=$P(LASTREC,";"),END=9999999
119 I $G(TESTING)="Y" D
120 . S X=$G(^XTMP(NAMSPC,"TEST RANGE"))
121 . I $L(X) S TODT=$P(X,U,1)-1,END=$P(X,U,2)
122 S FIRST("FRDT")=$P(LASTREC,";",2),FIRST("CONF")=$P(LASTREC,";",3),FIRST("DFN")=$P(LASTREC,";",4),FIRST("IEN")=$P(LASTREC,";",5)
123 F S TODT=$O(^DPT("ALOEIF",TODT)) Q:'TODT!ZTSTOP S:TODT>END ZTSTOP=2 Q:ZTSTOP S FRDT=FIRST("FRDT"),FIRST("FRDT")=0 F S FRDT=$O(^DPT("ALOEIF",TODT,FRDT)) Q:'FRDT!ZTSTOP S CONF=FIRST("CONF"),FIRST("CONF")="" D
124 . F S CONF=$O(^DPT("ALOEIF",TODT,FRDT,CONF)) Q:CONF=""!ZTSTOP S DFN=FIRST("DFN"),FIRST("DFN")=0 F S DFN=$O(^DPT("ALOEIF",TODT,FRDT,CONF,DFN)) Q:'DFN!ZTSTOP S IEN=FIRST("IEN"),FIRST("IEN")=0 D
125 .. F S IEN=$O(^DPT("ALOEIF",TODT,FRDT,CONF,DFN,IEN)) Q:'IEN!ZTSTOP D CHKR(DFN,IEN)
126 Q
127 ;
128CHKR(DFN,IEN) ;
129 N X,CEN,CALC
130 ; Assume TODT,FRDT,CONF,TOTREC,LASTREC,TOTPAT,NAMSPC are defined
131 S TOTREC=TOTREC+1
132 ;
133 ; Chk for correct CV End Date
134 I '$$CHPAT(DFN,.CEN,.CALC) D
135 . D TRANSMIT(DFN)
136 ;
137 E D ; If CV End Date OK, must be transmitted after OEF/OIF filed
138 . N LD,LTR,LOEIF
139 . S LD=$$YEAR^IVMPLOG(DFN),LTR=$P($G(^IVM(301.5,+$O(^IVM(301.5,"APT",DFN,+LD,0)),0)),U,5)
140 . S LOEIF=$P($G(^DPT(DFN,.3215,IEN,0)),U,5)
141 . I $S('LD!'LTR:1,LOEIF>LTR:1,1:0) D
142 .. D SET(DFN,CEN,CALC,"OEF/OIF DATA NOT TX")
143 .. D TRANSMIT(DFN)
144 ;
145 S LASTREC=TODT_";"_FRDT_";"_CONF_";"_DFN_";"_IEN
146 D UPDATEX(NAMSPC,TOTREC,LASTREC,TOTPAT)
147 ;
148 I (TOTREC#100)=0 S ZTSTOP=$$STOP(NAMSPC)
149 Q
150 ;
151TRANSMIT(DFN) ;
152 S TOTPAT=TOTPAT+1
153 Q:TESTING="Y" ; No update
154 D EVENT^IVMPLOG(DFN)
155 Q
156 ;
157CHPAT(DFN,CEN,CALC) ; Function returns:
158 ; 0 if no CV End date or CV End date not correct
159 ; 1 if CV End Date correct
160 ; Also returns CEN=CV END DATE ON FILE CALC=CALCULATED CV END DATE
161 ;
162 N DGARRY,DGOK,X
163 S (CEN,CALC)=""
164 S CEN=$P($G(^DPT(DFN,.52)),U,15)
165 S CALC=$$CVDATE^DGCVRPT(DFN,.DGARRY)
166 ;
167 I 'CEN D:CALC UPDCVED(NAMSPC,DFN,CEN,CALC) D SET(DFN,CEN,CALC,"CV END DATE MISSING") S DGOK=0
168 ;
169 I CEN D
170 . I $G(DGARRY("OEF/OIF")) D
171 .. N LSSD
172 .. S LSSD=$G(DGARRY(2,DFN_",",.327,"I"))
173 .. I DGARRY("OEF/OIF")>LSSD S ^XTMP(NAMSPC,"DATA",DFN,"MSE DATA MISSING")=CEN_U_CALC
174 .. ; Correct CV End Date if value on file is not the calculated value
175 .. Q:CEN=CALC
176 .. D UPDCVED(NAMSPC,DFN,CEN,CALC)
177 . I CEN=CALC S DGOK=1 Q
178 . D SET(DFN,CEN,CALC,"CV END DATE INCORRECT")
179 . S DGOK=0
180 Q DGOK
181 ;
182UPDCVED(NAMSPC,DFN,CEN,CALC) ; Update CV end date
183 N DA,DIE,DR,X,Y
184 S DA=DFN,DIE="^DPT(",DR=".5295////"_CALC
185 D ^DIE
186 S ^XTMP(NAMSPC,"DATA",DFN,"CV END DATE UPDATED TO "_CALC)=CEN
187 Q
188 ;
189SET(DFN,CEN,CALC,REASON) ;
190 S ^XTMP(NAMSPC,"DATA",DFN)=CEN_U_CALC_U_REASON
191 Q
192 ;
193UPDATEX(NAMSPC,TOTREC,LASTREC,TOTPAT) ;
194 N X
195 S X=$G(^XTMP(NAMSPC,0,0))
196 S $P(X,U,1)=$G(LASTREC),$P(X,U,2)=$G(TOTREC)
197 S $P(X,U,10)=$G(TOTPAT)
198 S ^XTMP(NAMSPC,0,0)=X
199 Q
200 ;
201STATUS ; current run status
202 N X,NAMSPC
203 S NAMSPC=$$NAMSPC
204 S X=$G(^XTMP(NAMSPC,0,0))
205 I X="" U 0 W !!,"Task not started!!!" Q
206 W !!," Current status: ",$P(X,U,6)
207 W !," Starting time: ",$$FMTE^XLFDT($P(X,U,7))
208 I $P(X,U,8) D
209 . W !," Ending time: ",$$FMTE^XLFDT($P(X,U,8))
210 W !!," Total patient records read: ",$P(X,U,2)
211 W !," Last ALOEIF xref processed: ",$P(X,U,1)
212 W !," Total patient records set for re-transmit: ",$P(X,U,10)
213 Q
214 ;
215STOP(NAMSPC) ; returns stop flag
216 N X
217 S ZTSTOP=0
218 I $$S^%ZTLOAD S ZTSTOP=1
219 I $D(^XTMP(NAMSPC,"STOP")) S ZTSTOP=1 K ^XTMP(NAMSPC,"STOP")
220 I ZTSTOP D
221 . S X=$G(^XTMP(NAMSPC,0,0))
222 . S $P(X,U,6)="STOPPED",$P(X,U,7)=$$NOW^XLFDT()
223 . S ^XTMP(NAMSPC,0,0)=X
224 . Q
225 Q ZTSTOP
226 ;
227MAIL(NAMSPC,TESTING,DUZ) ; stats
228 N ETIME,STAT,STIME,TOTPAT,TOTREC,X
229 S X=$G(^XTMP(NAMSPC,0,0))
230 S TOTREC=$P(X,U,2)
231 S STAT=$P(X,U,6),STIME=$P(X,U,7)
232 S ETIME=$P(X,U,8)
233 S TOTPAT=$P(X,U,10)
234 ;
235 D HDNG(NAMSPC,.LIN,STAT,STIME,ETIME,TESTING)
236 D SUMRY(.LIN,TOTREC,TOTPAT,NAMSPC)
237 D MAILIT("SUMMARY STATS - TRANSMIT UNSENT OEF/OIF DATA TO HEC",DUZ,NAMSPC)
238 K ^TMP(NAMSPC,$J,"MSG")
239 Q
240 ;
241HDNG(NAMSPC,LIN,STAT,STIME,ETIME,TESTING) ; hdr lines
242 N HTEXT,TEXT,X
243 K ^TMP(NAMSPC,$J,"MSG")
244 S LIN=0
245 S HTEXT="Transmit unsent OEF/OIF data to HEC "_STAT_" on "
246 D BLDLINE(NAMSPC,HTEXT,.LIN)
247 S HTEXT=$$FMTE^XLFDT(ETIME)
248 D BLDLINE(NAMSPC,HTEXT,.LIN)
249 D BLDLINE(NAMSPC,"",.LIN)
250 I TESTING="Y" D
251 . S TEXT="** TESTING - NO CHANGES MADE TO DATABASE **"
252 . D BLDLINE(NAMSPC,TEXT,.LIN)
253 D BLDLINE(NAMSPC,"",.LIN)
254 Q
255 ;
256SUMRY(LIN,TOTREC,TOTPAT,NAMSPC) ; summary lines
257 N TEXT,X
258 S TEXT=" Total Patient Records Read: "_$J($FN(TOTREC,","),11)
259 D BLDLINE(NAMSPC,TEXT,.LIN)
260 S TEXT=" Total Patient Records Set for Re-transmit: "_$J($FN(TOTPAT,","),11)
261 D BLDLINE(NAMSPC,TEXT,.LIN)
262 Q
263 ;
264BLDLINE(NAMSPC,TEXT,LIN) ;bld line in TMP
265 S LIN=LIN+1
266 S ^TMP(NAMSPC,$J,"MSG",LIN)=TEXT
267 Q
268 ;
269MAILIT(HTEXT,DUZ,NAMSPC) ; send mail msg
270 N XMY,XMDUZ,XMSUB,XMTEXT
271 S XMY(DUZ)="",XMDUZ=.5
272 S XMY("G.DGEN ELIGIBILITY ALERT")=""
273 S XMSUB=HTEXT
274 S XMTEXT="^TMP(NAMSPC,$J,""MSG"","
275 D ^XMD
276 Q
277 ;
278CHKSTAT(POST,NAMSPC) ;check if job is running, stopped, or complete
279 L +^XTMP(NAMSPC):1
280 I '$T Q 0
281 D KILIT(POST,NAMSPC)
282 Q 1
283 ;
284KILIT(POST,NAMSPC) ;
285 I 'POST K ^XTMP(NAMSPC)
286 Q
287 ;
288NAMSPC() ;
289 Q $T(+0)
290 ;
Note: See TracBrowser for help on using the repository browser.