source: cprs/branches/tmg-cprs/m_files/TMGTRNRP.m@ 1727

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

Initial upload

File size: 16.7 KB
RevLine 
[796]1TMGTRNRP ;TMG/kst/TRANSCRIPTION REPRINT REPORT FUNCTIONS ;03/25/06
2 ;;1.0;TMG-LIB;**1**;09/01/05
3
4 ;" TRANSCRIPTION REPRINT REPORT FUNCTIONS
5
6 ;"=======================================================================
7 ;" API -- Public Functions.
8 ;"=======================================================================
9 ;"REPRINTSET
10 ;"PRTEMPL -- RE-PRINT TEMPLATE
11
12 ;"=======================================================================
13 ;" Private Functions.
14 ;"=======================================================================
15 ;"LoadBatches(CompArray)
16 ;"ShowBatchInfo(Info)
17 ;"ShowSummary(Summary)
18 ;"OneLineSummary(Summary,Array,Batch)
19 ;"SummarizeBatchInfo(Info,Summary)
20 ;"GetBatchInfo(Job,Info)
21 ;"GetDocInfo(DocIEN,Info)
22
23
24
25REPRINTSET
26 ;"Purpose: In our setting, we have the transcriptionists signing documents for the physicians,
27 ;" because they won't sign them for themselves. A problem arose where the notes
28 ;" were not properly printed at the time of signing. So this function allows a user
29 ;" to browse through the batches of signed documents, and reprint them.
30
31 new CompArray
32 new SelectedBatch set SelectedBatch=0
33 new done set done=0
34
35 write #,!
36 write " --------------------------------------------------",!
37 write " Re-Print Documents that were Batch-Signed.",!
38 write " --------------------------------------------------",!
39 write !,"Scanning documents... Please wait.",!
40
41 do LoadBatches(.CompArray)
42
43Loop1
44 write #,!
45 write " --------------------------------------------------",!
46 write " Re-Print Documents that were Batch-Signed.",!
47 write " --------------------------------------------------",!
48 write " How would you like to search for the correct batch?",!
49 write " 1. By Date Signed.",!
50 write " 2. By Transcriptionist.",!
51 write " 3. By Author.",!
52 write " 4. By Visit date.",!
53 write " 5. Exit",!!
54
55 new input
56 read "Enter Number of Option: ",input:$get(DTIME,3600),!
57 if (input="")!(input="^") set input="5"
58
59 if input="1" do
60 . set SelectedBatch=$$BrowseBy^TMGTREE(.CompArray,"BY-SIGNED")
61 else if input="2" do
62 . set SelectedBatch=$$BrowseBy^TMGTREE(.CompArray,"BY-TRANS")
63 else if input="3" do
64 . set SelectedBatch=$$BrowseBy^TMGTREE(.CompArray,"BY-AUTHOR")
65 else if input="4" do
66 . set SelectedBatch=$$BrowseBy^TMGTREE(.CompArray,"BY-VISITDATE")
67 else if input="5" set done=1
68
69 if SelectedBatch>0 do
70 . set done=$$PrintBatch(SelectedBatch)
71
72 if done=0 goto Loop1
73
74RPSDone
75 write !,"Goodbye.",!
76 quit
77
78
79PrintBatch(SelectedBatch)
80 ;"Purpose: To reprint a set of batch signed documents
81 ;"Input: the SelectedBatch (really a job number) to print
82 ;"Result: 1 if print OK. 0 if user cancels
83
84 new result set result=0
85
86 write !,"Great, you have selected batch: #",SelectedBatch,!
87 new Info,input
88 if $$GetBatchInfo(SelectedBatch,.Info) do
89 . do ShowBatchInfo(.Info)
90 . read !,"Reprint this batch? YES// ",input:$get(DTIME,3600),!
91 . if input="" set input="Y"
92 . if ("YesyesYES"[input)=0 quit
93 . new PrintArray
94 . merge PrintArray=^TMG("BATCH SIGNED DOCS",SelectedBatch)
95 . do PRINT^TMGTRAN1(.PrintArray)
96 . set result=1
97
98PBDone
99 quit result
100
101
102LoadBatches(CompArray)
103 ;"Purpose: to browse through the batches, and allow user to select one
104 ;"Input: compArray -- PASS BY REFERENCE -- an array to put composite into
105 ;"Results: returns a batch/job number
106
107 new cTmp set cTmp="BATCH SIGNED DOCS"
108 new Batch
109
110 set Batch=$order(^TMG(cTmp,""))
111 if Batch'="" for do quit:(Batch="")
112 . new Info,Summary
113 . if $$GetBatchInfo(Batch,.Info) do
114 . . do SummarizeBatch(.Info,.Summary)
115 . . new OneLine
116 . . set OneLine=$$OneLineSummary(.Summary,.CompArray,Batch)
117 . set Batch=$order(^TMG(cTmp,Batch))
118
119 ;"zwr CompArray(*)
120
121BBDone
122 quit
123
124
125ShowBatchInfo(Info)
126 ;"Purpose: To Display the info retrieved by GetBatchInfo
127
128 new DocIEN,i
129
130 write "Visit Date; Transcr Date; Signed Date; Transcr, Author; Patient",!
131 for i=1:1:60 write "-"
132 write !
133 set DocIEN=$order(Info(""))
134 if +DocIEN>0 for do quit:(+DocIEN=0)
135 . new tDate
136 . set tDate=$get(Info(DocIEN,"VISIT DATE"))
137 . write $$DTFormat^TMGMISC(tDate,"ww mm/dd/yy"),"; "
138 . set tDate=$get(Info(DocIEN,"TRANS DATE"))
139 . write $$DTFormat^TMGMISC(tDate,"ww mm/dd/yy"),"; "
140 . set tDate=$get(Info(DocIEN,"DATE SIGNED"))
141 . write $$DTFormat^TMGMISC(tDate,"ww mm/dd/yy"),"; "
142 . write $get(Info(DocIEN,"TRANS","INITS")),"; "
143 . write $get(Info(DocIEN,"AUTHOR","INITS")),"; "
144 . write $get(Info(DocIEN,"PATIENT","NAME")),"; "
145 . write !
146 . set DocIEN=$order(Info(DocIEN))
147
148SBIDone
149 quit
150
151
152ShowSummary(Summary)
153 ;"Purpose: to Display the Summary retrieved by SummarizeBatchInfo
154
155 new ts,tDate,tCount
156
157 set ts=$order(Summary("TRANS","INITS",""))
158 if ts'="" for do quit:(ts="")
159 . set tCount=$get(Summary("TRANS","INITS",ts))
160 . write tCount," patients transcribed by ",ts,!
161 . set ts=$order(Summary("TRANS","INITS",ts))
162
163 set ts=$order(Summary("AUTHOR","NAME",""))
164 if ts'="" for do quit:(ts="")
165 . set tCount=$get(Summary("AUTHOR","NAME",ts))
166 . write tCount," patients with author: ",ts,!
167 . set ts=$order(Summary("AUTHOR","NAME",ts))
168
169 set ts=$order(Summary("DATE SIGNED",""))
170 if ts'="" for do quit:(ts="")
171 . set tCount=$get(Summary("DATE SIGNED",ts))
172 . set tDate=$$DTFormat^TMGMISC(ts,"ww mm/dd/yy")
173 . write +tCount," patients with date signed: ",tDate,!
174 . set ts=$order(Summary("DATE SIGNED",ts))
175
176 set ts=$order(Summary("VISIT DATE",""))
177 if ts'="" for do quit:(ts="")
178 . set tCount=$get(Summary("VISIT DATE",ts))
179 . set tDate=$$DTFormat^TMGMISC(ts,"ww mm/dd/yy")
180 . write +tCount," patients with visit date: ",tDate,!
181 . set ts=$order(Summary("VISIT DATE",ts))
182
183 set ts=$order(Summary("TRANS DATE",""))
184 if ts'="" for do quit:(ts="")
185 . set tCount=$get(Summary("TRANS DATE",ts))
186 . set tDate=$$DTFormat^TMGMISC(ts,"ww mm/dd/yy")
187 . write +tCount," patients with transcription date: ",tDate,!
188 . set ts=$order(Summary("TRANS DATE",ts))
189
190 write "--------------------------------------------------",!
191 quit
192
193
194OneLineSummary(Summary,Array,Batch)
195 ;"Purpose: to Display the Summary retrieved by SummarizeBatchInfo
196 ;"Input: Summary -- the array to display info from
197 ;" Array - PASS BY REFERENCE an out parameter
198 ;" Will put results into array, if passed
199 ;" Format:
200 ;" Array(DateSigned,TransInitials,AuthorName,VisitDate)
201 ;" Batch: number of batchused to label line
202 ;"Results: a one line summary. If multiple entries, just picks larges.
203
204 new ts,tDate,date,tCount,count,S,entries
205 new DateSigned,TransInitials,AuthorName,VisitDate
206 new result set result=""
207
208 set S="",count=0,entries=0
209 set ts=$order(Summary("DATE SIGNED",""))
210 if ts'="" for do quit:(ts="")
211 . set entries=entries+1
212 . set tCount=$get(Summary("DATE SIGNED",ts))
213 . if tCount>count do
214 . . set count=tCount
215 . . set S="Signed "_$$DTFormat^TMGMISC(ts,"mm/dd/yy")
216 . set ts=$order(Summary("DATE SIGNED",ts))
217 if entries>1 set S=S_"+"
218 set DateSigned=S
219 set result=result_S
220 set result=result_"; "
221
222 set S="",count=0
223 set ts=$order(Summary("TRANS","NAME",""))
224 if ts'="" for do quit:(ts="")
225 . set entries=entries+1
226 . set tCount=$get(Summary("TRANS","NAME",ts))
227 . if tCount>count do
228 . . set count=tCount
229 . . set S=ts
230 . set ts=$order(Summary("TRANS","NAME",ts))
231 if entries>1 set S=S_"+"
232 set TransInitials=S
233 set result=result_S
234 set result=result_"; "
235
236 set S="",count=0
237 set ts=$order(Summary("AUTHOR","NAME",""))
238 if ts'="" for do quit:(ts="")
239 . set entries=entries+1
240 . set tCount=$get(Summary("AUTHOR","NAME",ts))
241 . if tCount>count do
242 . . set count=tCount
243 . . set S=ts
244 . set ts=$order(Summary("AUTHOR","NAME",ts))
245 if entries>1 set S=S_"+"
246 set AuthorName=S
247 set result=result_S
248 set result=result_"; "
249
250 set S="",count=0
251 set ts=$order(Summary("VISIT DATE",""))
252 if ts'="" for do quit:(ts="")
253 . set entries=entries+1
254 . set tCount=$get(Summary("VISIT DATE",ts))
255 . if tCount>count do
256 . . set count=tCount
257 . . set S=$$DTFormat^TMGMISC(ts,"ww mm/dd/yy")
258 . set ts=$order(Summary("VISIT DATE",ts))
259 if entries>1 set S=S_"+"
260 set VisitDate=S
261 set result=result_"Visit date: "_S
262 set result=result_"; "
263
264 set Array("BY-SIGNED",DateSigned,TransInitials,AuthorName,VisitDate)=$get(Batch)
265 set Array("BY-TRANS",TransInitials,DateSigned,AuthorName,VisitDate)=$get(Batch)
266 set Array("BY-AUTHOR",AuthorName,DateSigned,TransInitials,VisitDate)=$get(Batch)
267 set Array("BY-VISITDATE",VisitDate,DateSigned,TransInitials,AuthorName)=$get(Batch)
268
269 quit result
270
271
272SummarizeBatchInfo(Info,Summary)
273 ;"Purpose: To summarize info retrieved by GetBatchInfo
274 ;"Input: Info -- PASS BY REFERENCE -- the info array to display
275 ;" Summary -- PASS BY REFERENCE -- the array to contain summary info.
276 ;" Format as follows:
277 ;" Summary("TRANS","INITS","nlx")=count
278 ;" Summary("TRANS","NAME","Nancy L. Xavier")=count
279 ;" Summary("DATE SIGNED", FMDate)=count
280 ;" Summary("AUTHOR","NAME","Marcus M. Welby")=count
281 ;" Summary("AUTHOR","INITS","mmw")=count
282 ;" Summary("PATIENTS")=count
283 ;" Summary("VISIT DATE",FMDate)=count
284 ;" Summary("TRANS DATE",FMDate)=count
285
286 new DocIEN
287 set DocIEN=$order(Info(""))
288 if +DocIEN>0 for do quit:(+DocIEN=0)
289 . new tDate,tInits,tName
290 . set tDate=$get(Info(DocIEN,"VISIT DATE"))\1
291 . set Summary("VISIT DATE",tDate)=$get(Summary("VISIT DATE",tDate))+1
292 . set tDate=$get(Info(DocIEN,"TRANS DATE"))\1
293 . set Summary("TRANS DATE",tDate)=$get(Summary("TRANS DATE",tDate))+1
294 . set tDate=$get(Info(DocIEN,"DATE SIGNED"))\1
295 . set Summary("DATE SIGNED",tDate)=$get(Summary("DATE SIGNED",tDate))+1
296 . set tInits=$get(Info(DocIEN,"TRANS","INITS"))
297 . set Summary("TRANS","INITS",tInits)=$get(Summary("TRANS","INITS",tInits))+1
298 . set tName=$get(Info(DocIEN,"TRANS","NAME"))
299 . set Summary("TRANS","NAME",tName)=$get(Summary("TRANS","NAME",tName))+1
300 . set tInits=$get(Info(DocIEN,"AUTHOR","INITS"))
301 . set Summary("AUTHOR","INITS",tInits)=$get(Summary("AUTHOR","INITS",tInits))+1
302 . set tName=$get(Info(DocIEN,"AUTHOR","NAME"))
303 . set Summary("AUTHOR","NAME",tName)=$get(Summary("AUTHOR","NAME",tName))+1
304 . set Summary("PATIENTS")=$get(Summary("PATIENTS"))+1
305 . set DocIEN=$order(Info(DocIEN))
306
307SmBIDone
308 quit
309
310GetBatchInfo(Job,Info)
311 ;"Purpose: to return stats for a given sign batch
312 ;"Input: Job: the job number to investigate
313 ;" Info -- PASS BY REFERENCE.. an out parameter
314 ;" Format: Returns an aggregate array of all the docs
315 ;" Info(DocIEN,"TRANS","INITS")="nlx"
316 ;" Info(DocIEN,"TRANS","NAME")="Nancy L. Xavier"
317 ;" Info(DocIEN,"TRANS","IEN")=1234
318 ;" Info(DocIEN,"DATE SIGNED")=FMDate
319 ;" Info(DocIEN,"AUTHOR","NAME")="Marcus M. Welby"
320 ;" Info(DocIEN,"AUTHOR","INITS")="mmw"
321 ;" Info(DocIEN,"AUTHOR","IEN")="1234
322 ;" Info(DocIEN,"PATIENT","NAME")="Doe,John G"
323 ;" Info(DocIEN,"VISIT DATE")=FMDate
324 ;" Info(DocIEN,"TRANS DATE")=FMDate
325 ;"Result: 0 if failure, otherwise 1
326
327 new result set result=0
328 new cTmp set cTmp="BATCH SIGNED DOCS"
329 new DocInfo
330 if +$get(Job)=0 goto GBIDone
331
332 new DocIEN set DocIEN=$order(^TMG(cTmp,Job,0))
333 if +DocIEN>0 for do quit:(+DocIEN=0)
334 . set result=$$GetDocInfo(DocIEN,.Info)
335 . set DocIEN=$order(^TMG(cTmp,Job,DocIEN))
336
337GBIDone
338 quit result
339
340
341GetDocInfo(DocIEN,Info)
342 ;"Purpose: to get information on a given documen
343 ;"Input: DocIEN - the IEN number of the document to investigate
344 ;" Info -- PASS BY REFERENCE an out parameter
345 ;" Format as follows:
346 ;" Info(DocIEN,"TRANS","INITS")="nlx"
347 ;" Info(DocIEN,"TRANS","NAME")="Nancy L. Xavier"
348 ;" Info(DocIEN,"TRANS","IEN")=1234
349 ;" Info(DocIEN,"DATE SIGNED")=FMDate
350 ;" Info(DocIEN,"AUTHOR","NAME")="Marcus M. Welby"
351 ;" Info(DocIEN,"AUTHOR","INITS")="mmw"
352 ;" Info(DocIEN,"AUTHOR","IEN")="1234
353 ;" Info(DocIEN,"PATIENT","NAME")="Doe,John G"
354 ;" Info(DocIEN,"VISIT DATE")=FMDate
355 ;" Info(DocIEN,"TRANS DATE")=FMDate
356 ;"Result: 0 if failure, 1 if success
357
358 new result set result=0
359 if $get(DocIEN)=0 goto GDIDone
360 if $get(^TIU(8925,DocIEN,0))="" goto GDIDone
361
362 new AuthIEN,initials,AuthName,PatIEN,TransIEN,TransInit
363
364 set Info(DocIEN,"TRANS DATE")=$piece($get(^TIU(8925,DocIEN,12)),"^",1)
365 set Info(DocIEN,"VISIT DATE")=$piece($get(^TIU(8925,DocIEN,0)),"^",7)
366 set Info(DocIEN,"DATE SIGNED")=$piece($get(^TIU(8925,DocIEN,15)),"^",1)
367 set AuthIEN=$piece($get(^TIU(8925,DocIEN,12)),"^",2) ;"field 1202 = Author
368 if +AuthIEN'=0 do
369 . set Info(DocIEN,"AUTHOR","INITS")=$piece($get(^VA(200,AuthIEN,0)),"^",2) ;"field .02 = initials
370 . set Info(DocIEN,"AUTHOR","NAME")=$piece($get(^VA(200,AuthIEN,0)),"^",1) ;"field .01 = Name
371 else do
372 . set Info(DocIEN,"AUTHOR","INITS")="???"
373 . set Info(DocIEN,"AUTHOR","NAME")="???"
374 set PatIEN=$piece($get(^TIU(8925,DocIEN,0)),"^",2) ;"field .02 = patient IEN
375 if +PatIEN'=0 do
376 . set Info(DocIEN,"PATIENT","NAME")=$piece($get(^DPT(PatIEN,0)),"^",1) ;"field .01 is patient name
377 else do
378 . set Info(DocIEN,"PATIENT","NAME")="???"
379 set TransIEN=$piece($get(^TIU(8925,DocIEN,13)),"^",2) ;"field 1302 = Entered by IEN
380 if +TransIEN'=0 do
381 . set Info(DocIEN,"TRANS","INITS")=$piece($get(^VA(200,TransIEN,0)),"^",2) ;" field .02 = initials
382 . set Info(DocIEN,"TRANS","NAME")=$piece($get(^VA(200,TransIEN,0)),"^",1) ;"field .01 = Name
383 else do
384 . set Info(DocIEN,"TRANS","INITS")="???"
385 . set Info(DocIEN,"TRANS","NAME")="???"
386
387
388 set result=1
389
390GDIDone
391 quit result
392
393
394FindBatch(DocIEN)
395 ;"Purpose: given a DocIEN, find the batch number it was printed in
396
397 new result set result=0
398 new batch
399 set batch=$order(^TMG("BATCH SIGNED DOCS",""))
400 if batch'="" for do quit:(index="")
401 . if $data(^TMG("BATCH SIGNED DOCS",batch,DocIEN))#10=1 do
402 . . write "Printed in batch: ",batch,!
403 . . set result=batch
404 . set batch=$order(^TMG("BATCH SIGNED DOCS",batch))
405
406 quit result
407
408
409PRTEMPL ;"i.e. RE-PRINT TEMPLATE
410 ;"Purpose: To ask for a SORT TEMPLATE that contains documents to reprint.
411
412 write !,!,"This will allow printing of documents stored in a TEMPLATE.",!
413 write "This TEMPLATE should have been already created by a Fileman SEARCH.",!
414
415 new DIC,Y
416 set DIC=.401
417 set DIC(0)="MAEQ"
418 do ^DIC
419 if +Y>0 do
420 . new PrintArray
421 . if $piece($get(^DIBT(+Y,0)),"^",4)'=8925 do quit
422 . . write "That template is for another file. Sorry.",!
423 . merge PrintArray=^DIBT(+Y,1)
424 . if $data(PrintArray)=0 do quit
425 . . write "That template doesn't contain any documents to print.",!
426 . do PRINT^TMGTRAN1(.PrintArray)
427
428 quit
Note: See TracBrowser for help on using the repository browser.