source: cprs/branches/tmg-cprs/m_files/TMGSEQL3.m@ 1117

Last change on this file since 1117 was 796, checked in by Kevin Toppenberg, 14 years ago

Initial upload

File size: 15.3 KB
Line 
1TMGSEQL3 ;TMG/kst/Code to interface with SequelSystems PMS ;03/25/06
2 ;;1.0;TMG-LIB;**1**;09/01/05
3
4 ;"TMG SEQUEL IMPORT UTILITY FUNCTIONS
5 ;"Kevin Toppenberg MD
6 ;"GNU General Public License (GPL) applies
7 ;"1-9-2006
8
9
10 ;"=======================================================================
11 ;" API -- Public Functions.
12 ;"=======================================================================
13 ;"RPTSSNCF ;"i.e. Report SSN Conflict
14 ;"RPTDOBER ;"i.e. Report DOB Errors
15 ;"CLEARALL
16
17
18 ;"FIXERRORS --OLD
19 ;"FixOneError(OneLine,OneErr,OneChLog) -- OLD
20 ;"tempMakeAlerts
21
22 ;"=======================================================================
23 ;"PRIVATE API FUNCTIONS
24 ;"=======================================================================
25 ;"ShowOneConflict(IEN,ErrMsg)
26 ;"$$QuietClear(DUZ)
27
28
29 ;"=======================================================================
30 ;"DEPENDENCIES
31 ;"TMGSEQL1
32 ;"TMGSEQL2
33 ;"TMGSTUTL
34 ;"TMGGDFN
35 ;"TMGDEBUG
36 ;"=======================================================================
37 ;"=======================================================================
38
39
40
41tempMakeAlerts
42 ;"Purpose: To creat alerts for all entries in file 22706
43 ;"Input: none
44 ;"Output: This will generate Alerts, sent to the current user (DUZ)
45 ;"Result: none
46
47 new i,OneLine
48
49 set i=$order(^TMG(22706,0))
50 if +i>0 for do quit:(+i'>0)
51 . new ref,IEN
52 . set IEN=i
53 . set i=$order(^TMG(22706,i))
54 . set ref="^TMG(22706,"_IEN_",2)"
55 . set OneLine=$$WPToStr^TMGSTUTL(ref)
56 . set Msg="Problem with upload of Sequel data"
57 . do MakeErrAlert^TMGSEQL2(IEN,DUZ,Msg)
58
59 quit
60
61
62FIXERRORS ;"NOTE-- this is an OLD function, not being used
63 ;"Purpose: To handles errors encountered during the ASKIMPORT function
64 ;"Input: none
65 ;"Output: the database is modified
66 ;"Results: none
67
68 new index
69 new Abort set Abort=0
70 new NewArray,newI
71 new NewErrArray,NewChgLog
72 new MaxCount
73 new TMGRemSex
74 set TMGRemSex=$$GET1^DIQ(22711,"1,",6,"I") ;"6=PICK GENDER FROM NAME?
75
76 new Ref set Ref=$name(^TMP("TMG","SEQUELIMPORT","ERRORS"))
77 set MaxCount=$order(@Ref@(""),-1)
78
79 set index=$order(@Ref@(""))
80 if index'="" for do quit:(+index'>0)!(Abort)
81 . new result
82 . new OneErrArray,OneChLog
83 . merge OneErrArray=@Ref@(index)
84 . new OneLine set OneLine=$get(@Ref@(index))
85 . write "(",index,"/",MaxCount,") "
86 . set result=$$FixOneError^TMGSEQL2(OneLine,.OneErrArray,.OneChLog)
87 . if result=-1 set Abort=1 quit
88 . if result>0 do
89 . . ;"merge NewChgLog(index)=OneChLog
90 . . merge ^TMP("TMG","SEQUELIMPORT","CHANGES",$H,index)=OneChLog
91 . else do
92 . . kill @Ref@(index)
93 . . merge @Ref@(index)=OneErrArray(1)
94 . set index=$order(@Ref@(index))
95
96 if 1=0 do
97 . set newI=$get(newI)+1
98 . set NewArray(newI)=OneLine
99 . if $$ProcessPt^TMGSEQL1(OneLine,.NewErrArray,.NewChgLog) do
100 . . MERGE ^TMP("TMG","SEQUELIMPORT","CHANGES",$H)=NewChgLog
101 . . if $data(NewErrArray) do
102 . . . MERGE ^TMP("TMG","SEQUELIMPORT","ERRORS")=NewErrArray
103 . . . write "Here is the info about adding that patient:",!
104 . . . zwr NewErrArray(*)
105 . . . write !!
106 . . . kill NewErrArray
107 . . ;"write "killing: ",Ref,"(",Idx,")",!
108 . . kill @Ref@(Idx)
109
110
111 write !,"Goodbye.",!
112FEDone
113 quit
114
115
116FixOneError(OneLine,OneErr,OneChLog) ;"NOTE-- this is an OLD function, not being used
117 ;"Purpose: to Fix one filing error
118 ;"Input: OneLine -- the original data line in CVS format.
119 ;" OneErr -- PASS BY REFERENCE
120 ;" coming in, it will pass the original error.
121 ;" passed back out, it will contain any new errors.
122 ;" OneChLog -- PASS BY REFERENCE
123 ;" This will contain messages about changes made.
124 ;" Note: uses var with global scipe: TMGRemSex
125 ;"Result: 1 = error fixed
126 ;" 0 = error NOT fixed
127 ;" -1 = aborted
128
129 new Abort set Abort=0
130 new NewArray,newI
131 new NewErrArray,NewChgLog
132 new result set result=0
133
134 new Len set Len=$length(OneLine)
135 if $extract(OneLine,Len)=$char(13) set OneLine=$extract(OneLine,1,Len-1)
136
137 new Info merge Info=OneErr("INFO")
138 new DIERR merge DIERR=OneErr("INFO","DIERR")
139 if OneLine="" goto FOEDone
140
141 new LName,FName,DOB,SID
142 set LName=$piece(OneLine,",",3)
143 set FName=$piece(OneLine,",",4)
144 set DOB=$piece($piece(OneLine,",",17)," ",1)
145 set SID=$piece(OneLine,",",5)
146 write FName," ",LName," ("_DOB_"); #",SID,"): "
147 new Prov set Prov=$piece(OneLine,",",14)
148 new skip set skip=0
149 new temp set temp=""
150
151 if $$InvalPtName^TMGSEQL1(FName,LName) do goto FOEDone
152 . write !,"Skipping and deleting, because name is: ",FName," ",LName,!
153 . set result=0
154
155 if $$InvalidProvider^TMGSEQL1(Prov) do goto FOEDone
156 . write !,"Skipping and deleting, because provider is: ",Prov,!
157 . set result=0
158
159 if ($get(DIERR(1))=311)&($get(Info(0))="PATIENT NOT IN DATABASE")&($get(DIERR(1,"PARAM","FIELD"))=.02) do
160 . set temp=""
161 . for do quit:(temp'="")!(Abort=1)
162 . . set skip=0
163 . . if TMGRemSex=1 set temp=$$GetSex^TMGSEQL2(FName)
164 . . if temp="" read "MALE/FEMALE? ?// ",temp:$get(DTIME,3600)
165 . . if temp="" set temp="?"
166 . . set temp=$$UP^XLFSTR(temp)
167 . . if temp="?" do quit
168 . . . write "Options:",!
169 . . . write "-----------------",!
170 . . . write "M Name is MALE (and remember in future).",!
171 . . . write "F Name is FEMALE (and remember in future).",!
172 . . . write "D Show the data line from the other computer (Sequel)",!
173 . . . ;"write "S Turn automatic selecting SEX based on first name: "
174 . . . ;"write $select(TMGRemSex=1:"OFF",TMGRemSex=0:"ON"),!
175 . . . write "x Skip this patient.",!
176 . . . write "Q Query the database to see existing entries.",!
177 . . . write "^ Abort.",!
178 . . . set temp=""
179 . . if temp="Q" do quit
180 . . . new DIC set DIC=2
181 . . . set DIC(0)="AEQM"
182 . . . do ^DIC
183 . . . set temp=""
184 . . if temp="S" do quit
185 . . . ;"set TMGRemSex='TMGRemSex
186 . . if temp="D" do quit
187 . . . write !,OneLine,!
188 . . . set temp=""
189 . . if ("MALE"[temp)&(temp'="FEMALE") do quit
190 . . . write "MALE",!
191 . . . set OneLine=OneLine_"^MALE"
192 . . . if TMGRemSex=1 do
193 . . . . new temp
194 . . . . set temp=$$SetSex^TMGSEQL2(FName,"MALE")
195 . . else if "FEMALE"[temp do quit
196 . . . write "FEMALE",!
197 . . . set OneLine=OneLine_"^FEMALE"
198 . . . if TMGRemSex=1 do
199 . . . . new temp
200 . . . . set temp=$$SetSex^TMGSEQL2(FName,"FEMALE")
201 . . else if temp="^" do quit
202 . . . write "aborting..",!
203 . . . set Abort=1
204 . . else do quit
205 . . . write "skip...",!
206 . . . set skip=1,temp="x"
207 else do
208 . write "??",!
209 . write "Here is info array. I don't know how to fix this:",!
210 . zwr Info(*)
211 . set temp="?"
212 . for do quit:(temp'="")!(Abort=1)
213 . . set skip=0
214 . . if temp="?" do quit
215 . . . write "Options:",!
216 . . . write "-----------------",!
217 . . . write "D Show the data line from the other computer (Sequel)",!
218 . . . write "E Edit data line.",!
219 . . . write "x Skip this patient.",!
220 . . . write "Q Query the database to see existing entries.",!
221 . . . write "^ Abort.",!
222 . . . set temp=""
223 . . else if temp="Q" do quit
224 . . . new DIC set DIC=2
225 . . . set DIC(0)="AEQM"
226 . . . do ^DIC
227 . . . set temp=""
228 . . else if temp="S" do
229 . . . set TMGRemSex='TMGRemSex
230 . . else if temp="D" do quit
231 . . . write !,OneLine,!
232 . . . set temp=""
233 . . else if temp="E" do
234 . . . new r,NewLine
235 . . . set r=$$EditOneLine^TMGSEQL2(OneLine,NewLine)
236 . . . if r=1 set OneLine=NewLine ;"NOTE: later I will save old line to keep from having to process each update cycle
237 . . else if temp="^" do quit
238 . . . write "aborting..",!
239 . . . set Abort=1
240 . . else do quit
241 . . . write "skip...",!
242 . . . set skip=1
243 . . read !,"Enter Option: ?//",temp:$get(DTIME,3600),!
244 . . if temp="" set temp="?"
245 . . set temp=$$UP^XLFSTR(temp)
246
247 if skip=0 do
248 . kill OneErr
249 . if $$ProcessPt^TMGSEQL1(OneLine,.OneErr,.OneChLog) do
250 . . if $data(OneErr) do
251 . . . write "Here is the info about adding that patient:",!
252 . . . zwr OneErr(*)
253 . . . write !!
254 . . else set result=1
255
256FOEDone
257 if Abort set result=-1
258 quit result
259
260
261
262RPTSSNCF ;"i.e. Report SSN Conflict
263 ;"Purpose: to output a report of all instances of conflicted SSNum's
264
265 do RptMsg("CONFLICTING SS-NUMBERS")
266 quit
267
268
269RPTDOBER ;"i.e. Report DOB Errors
270 ;"Purpose: to output a report of all instances of conflicted SSNum's
271
272 do RptMsg("DOB")
273 quit
274
275
276RptMsg(MatchMsg) ;"i.e. Alerts with matching message
277 ;"Purpose: to output a report of all instances of errors with matching message
278 ;"input: MatchMsg -- A message of error to match for.
279 ;" e.g. CONFLICTING SS-NUMBERS
280
281 set %ZIS("A")="Enter output printer or device (^ to abort): "
282 do ^%ZIS
283 if POP do goto RpmDone
284 . write !,"Error selecting output printer or device. Aborting report.",!
285 use IO
286
287 new IEN,count
288 set count=0
289 set IEN=$order(^TMG(22706,0))
290 if +IEN'=0 for do quit:(+IEN'>0)
291 . new Node0 set Node0=$get(^TMG(22706,IEN,0))
292 . new SQLNum set SQLNum=$piece(Node0,"^",1)
293 . new Msg set Msg=$piece(Node0,"^",2)
294 . if Msg[MatchMsg do
295 . . do ShowOneConflict(IEN,Msg)
296 . . set count=count+1
297 . set IEN=$order(^TMG(22706,IEN))
298
299 write count," conflicts found."
300
301 use IO(0)
302 do ^%ZISC
303
304RpmDone
305 write !,"Goodbye.",!
306 quit
307
308
309
310
311ShowOneConflict(IEN,ErrMsg)
312 ;"Purpose: to output one conflict
313 ;"Input: IEN, the IEN from file 22706
314
315 new OneLine,TMGWP,TMGMSG,PtInfo
316 new sqSSNum,vSSNum
317
318 new x set x=$$GET1^DIQ(22706,IEN_",",2,"","TMGWP","TMGMSG")
319 if $data(TMGMSG("DIERR"))'=0 do goto SOCDone
320 . new PriorErrorFound
321 . do ShowDIERR^TMGDEBUG(.TMGMSG,.PriorErrorFound)
322 set OneLine=$$WPToStr^TMGSTUTL("TMGWP","")
323 if $$ParseLine^TMGSEQL1(OneLine,.PtInfo)=0 do goto SOCDone
324 . write "Error parsing Alert data into patient data.",!
325
326 if $get(ErrMsg)="" goto SOCDone
327
328 set sqSSN=$piece(ErrMsg,"Sequel#=",2)
329 set sqSSN=$piece(sqSSN," ",1)
330 set vSSN=$piece(ErrMsg,"VistA#=",2)
331 set vSSN=$piece(vSSN," ",1)
332
333 new vFullName
334 do ;"get actual full name & DOB for VistA SSN
335 . new vName,vDOB
336 . new tempDFN set tempDFN=$$SSNumLookup^TMGGDFN(vSSN)
337 . new TMGMSG,TMGERR,IENS
338 . set IENS=+tempDFN_","
339 . do GETS^DIQ(2,IENS,".01;.03","E","TMGMSG","TMGERR")
340 . if $data(TMGERR("DIERR")) do
341 . . new PriorErrorFound
342 . . do ShowDIERR^TMGDEBUG(.TMGMSG,.PriorErrorFound)
343 . set vName=$get(TMGMSG(2,IENS,.01,"E"))
344 . set vDOB=$get(TMGMSG(2,IENS,.03,"E"))
345 . set vFullName=vName_" ("_vDOB_")"
346
347 write sqSSN," is Sequel SSN for: ",$get(PtInfo("FULL NAME2"))," phone: ",$get(PtInfo("PHONE NUM")),!
348 write vSSN," is VistA SSN for: ",$get(vFullName),!
349 write !
350
351SOCDone
352 quit
353
354
355
356CLEARALL
357 ;"Purpose: Wrapper for QuietClear (which clears all entries in file 22706 and all alerts.)
358 ;"Input: none, DUZ (in global scope) is used
359 ;"Output: All entries in the file and all associated Alerts are deleted
360 ;"Results: none
361
362 new TMGLIST
363 new i,count
364 set count=0
365
366 write !,"-==Error Deleater==-",!
367 write "This will delete all error alerts related to",!
368 write "importing demographics from Sequel system",!!
369
370 set count=$$QuietClear(DUZ)
371
372 write count," data import errors "
373 if count>0 write "deleted.",!
374 else write "to delete.",!
375
376 write !,"Goodbye.",!
377
378 quit
379
380
381QuietClear(DUZ)
382 ;"Purpose: To clear all entries in file 22706 and all alerts.
383 ;"Input: DUZ, the user to delete alerts for.
384 ;"Output: All entries in the file and all associated Alerts are deleted
385 ;"Results: count of errors deleted.
386
387 new TMGLIST
388 new i,count
389 set count=0
390
391 do USER^XQALERT("TMGLIST",DUZ)
392
393 set i=$order(TMGLIST(""))
394 if i'="" for do quit:(+i'>0)
395 . new alertID,IEN,TMGDATA,line
396 . set line=$get(TMGLIST(i))
397 . set i=$order(TMGLIST(i))
398 . set alertID=$piece(line,"^",2)
399 . if $piece(alertID,";",1)'="TMGSQLIMPORT" quit
400 . new XQAID
401 . do GETACT^XQALERT(alertID) ;"loads XQADATA, XQAID
402 . if +XQADATA>0 do
403 . . new TMGERR,result
404 . . set count=count+1
405 . . ;"write "Deleting from file 22706, IEN=",XQADATA,!
406 . . set result=$$DelIEN^TMGDBAPI(22706,XQADATA,.TMGERR)
407 . . if result=0 do ShowDIERR^TMGDEBUG(.TMGERR)
408 . . else do
409 . . . ;"write $piece(line,"^",1),!!
410 . . . do DELETE^XQALERT
411 . ;"else write "?? XQADATA ??",!
412
413 quit count
414
415
416
417Schedule(Time,Routine,Descr)
418 ;"Purpose: to schedule a task at the given time, to run the specified routine
419 ;"Input: Time: The time to run the task, in FileMan or $HOROLOG format
420 ;" Routine: the routine to run. E.g. "TEST^TMGSEQL3"
421 ;" Descr: Task description (don't include package name)
422 ;"Output: Will shedule the task with TaskMan
423 ;"Result: returns the task number
424
425 new result
426 set result=""
427
428 ;"New all vars used by taskman scheduler, to ensure to use of unexpected values
429 new ZTRTN,ZTDESC,ZTDTH,ZTIO,ZTUCI,ZTCPU
430 new ZTPRI,ZTSAVE,ZTKIL,ZTSYNC
431
432 set ZTRTN=$get(Routine)
433 set ZTDESC="TMG SEQUELIMPORTER "_$get(Descr)
434 set ZTDTH=$get(Time)
435 set ZTIO=""
436
437 do ^%ZTLOAD
438
439 set result=$get(ZTSK)
440
441SchDone
442 quit result
443
444
445SHOWTIME
446 ;"Purpose: to show the last time that the import task was run
447 ;"Input: none
448 ;"Output: will write to screen
449 ;"Result: none
450
451 new time
452
453 write !!,"SEQUEL BILLING SYSTEM DEMOGRAPHICS IMPORT",!
454 write "Last demographics import date/time was: "
455 set time=$$GET1^DIQ(22711,"1,","LAST IMPORT DATE","I")
456 write $$FMTE^XLFDT(time,"P"),!
457
458 new task
459 set task=$$GET1^DIQ(22711,"1,","TASK FOR NEXT RUN","I")
460 if +task>0 do
461 . write "Next demographics import date/time is: "
462 . set time=$$GET1^DIQ(14.4,task_",","Scheduled Run Time ($H)")
463 . write $$HTE^XLFDT(time,"P"),!
464
465 quit
466
Note: See TracBrowser for help on using the repository browser.