1 | TMGTICKL ;TMG/kst-Tickler Text objects for use in CPRS ;08/27/08
|
---|
2 | ;;1.0;TMG-LIB;**1**;08/27/08
|
---|
3 |
|
---|
4 | ;"TMG Tickler text object and surrounding support code.
|
---|
5 | ;"
|
---|
6 | ;"These are bits of code that return text to be included in progress notes etc.
|
---|
7 | ;"They are called when the user puts text like this in a note:
|
---|
8 | ;" ... Mrs. Jone's vitals today are |VITALS|, measured in the office...
|
---|
9 | ;" 'VITALS' would be a TIU TEXT OBJECT, managed through menu option TIUFJ CREATE OBJECTS MGR
|
---|
10 |
|
---|
11 | ;"---------------------------------------------------------------------------
|
---|
12 | ;"PUBLIC FUNCTIONS
|
---|
13 | ;"---------------------------------------------------------------------------
|
---|
14 | ;"$$TICKLER^TMGTICKL(DFN,.TIU) -- Entry point for TIU Text object caller
|
---|
15 | ;"HANDLE^TMGTICKL -- entry point for Task to handle tickler messages, called at scheduled intervals
|
---|
16 | ;"ERRSHOW^TMGTICKL -- Handle Alerts, showing details about error.
|
---|
17 |
|
---|
18 | ;"---------------------------------------------------------------------------
|
---|
19 | ;"PRIVATE FUNCTIONS
|
---|
20 | ;"---------------------------------------------------------------------------
|
---|
21 | ;"$$HasTickler(DocIEN,DateStr) -- return if TIU DOCUMENT contains the signals for a TICKLER message.
|
---|
22 | ;"SendAddendum(DocIEN,AuthorIEN,TklIEN,TMGWP) -- place an addendum to the specified note with message
|
---|
23 | ;"SendErrAddendum(DocIEN,TklIEN,TMGMSG) -- send an addendum to note showing database error.
|
---|
24 | ;"SendAlert(UserIEN,TklIEN,Msg,TMGMSG) -- send a message alert to the user (for error reporting)
|
---|
25 | ;"RecheduleTask -- reschedule task for handling the next cycle of tickler messages.
|
---|
26 | ;"PressToCont -- provide a 'press key to continue' action
|
---|
27 | ;"GetErrStr(ErrArray) -- convert a standard DIERR array into a string for output
|
---|
28 |
|
---|
29 | ;"---------------------------------------------------------------------------
|
---|
30 | ;"---------------------------------------------------------------------------
|
---|
31 |
|
---|
32 | TICKLER(DFN)
|
---|
33 | ;"Purpose: A call point for TIU objects, to launch a tickler for the given note.
|
---|
34 | ;"Input: DFN -- the patient's unique ID (record#)
|
---|
35 | ;"Result: returns text that will be put into the note in CPRS
|
---|
36 |
|
---|
37 | new result
|
---|
38 |
|
---|
39 | set DFN=+$get(DFN)
|
---|
40 | if DFN=0 do goto TKDone
|
---|
41 | . set result="ERROR: DFN not defined. Contact IT support (Source: TMGTICKL.m)"
|
---|
42 |
|
---|
43 | set result=""
|
---|
44 | set result=result_" ======= [TICKLER MESSGE] ======="_$CHAR(13)_$CHAR(10)
|
---|
45 | set result=result_" #DUE#: Put-DUE-DATE-here "_$CHAR(13)_$CHAR(10)
|
---|
46 | set result=result_" ================================"_$CHAR(13)_$CHAR(10)
|
---|
47 | set result=result_" Message: ... "_$CHAR(13)_$CHAR(10)
|
---|
48 | set result=result_" "_$CHAR(13)_$CHAR(10)
|
---|
49 | set result=result_" ================================"_$CHAR(13)_$CHAR(10)
|
---|
50 | set result=result_$CHAR(13)_$CHAR(10)
|
---|
51 |
|
---|
52 | ;"Create an entry in TMG TICKLER file, for later processing.
|
---|
53 | ;"Processing will need to wait until after document is signed, so that due date is fixed.
|
---|
54 | new TMGFDA,TMGMSG,TMGIEN
|
---|
55 | set TMGFDA(22705.5,"+1,",.01)=DFN ;"IEN in PATIENT file
|
---|
56 | set TMGFDA(22705.5,"+1,",2)="U" ;"U=Unsigned
|
---|
57 | set TMGFDA(22705.5,"+1,",3)=DUZ ;"Current user
|
---|
58 |
|
---|
59 | do UPDATE^DIE("","TMGFDA","TMGIEN","TMGMSG")
|
---|
60 | if $data(TMGMSG("DIERR")) do goto TKDone
|
---|
61 | . set result="ERROR: Fileman error creating Tickler Message. Contact IT support (Source: TMGTICKL.m)"
|
---|
62 | . set result=result_$$GetErrStr(.TMGMSG)
|
---|
63 |
|
---|
64 | TKDone quit result
|
---|
65 |
|
---|
66 |
|
---|
67 | HANDLE
|
---|
68 | ;"Purpose: An entry point for Taskman Task to handle tickler messages
|
---|
69 | ;" This will be called at scheduled intervals
|
---|
70 |
|
---|
71 | do RecheduleTask
|
---|
72 |
|
---|
73 | new X,%,TMGFDA,TMGMSG
|
---|
74 | do NOW^%DTC ;"get current time into %
|
---|
75 | set TMGFDA(22705.4,"1,",3)=%
|
---|
76 | do FILE^DIE("","TMGFDA","TMGMSG") ;"set time of last scan in 22705.4
|
---|
77 |
|
---|
78 | new DIC,Y
|
---|
79 | set DIC=8925.6 ;"TIU STATUS file
|
---|
80 | set X="COMPLETED"
|
---|
81 | DO ^DIC
|
---|
82 | new StatusIEN set StatusIEN=+Y
|
---|
83 | if StatusIEN'>0 do goto HandlDone
|
---|
84 | . do SendAlert(DUZ,0,"Tickler Error: Can't find IEN for 'COMPLETED' status")
|
---|
85 |
|
---|
86 | ;"For each TMG TICKLER entry that is UNSIGNED, and missing a DOCUMENT
|
---|
87 | ;"pointer, a scan of all a patient's documents is carried out, looking
|
---|
88 | ;"for one with a Tickler Message that has not already been noted. When
|
---|
89 | ;"found, the DOCUMENT pointer is stored. Search is by date, in
|
---|
90 | ;"reverse chronological order (most recent first).
|
---|
91 | new TklIEN set TklIEN=0
|
---|
92 | for set TklIEN=$order(^TMG(22705.5,"S","U",TklIEN)) quit:(+TklIEN'>0) do
|
---|
93 | . new found set found=0
|
---|
94 | . new DocIEN set DocIEN=+$piece($get(^TMG(22705.5,TklIEN,0)),"^",4)
|
---|
95 | . if DocIEN>0 quit ;"Document for this Tickler already found, so don't search again. SHOULDN'T EVER HAPPEN
|
---|
96 | . new PtIEN set PtIEN=+$piece($get(^TMG(22705.5,TklIEN,0)),"^",1)
|
---|
97 | . new UserIEN set UserIEN=+$piece($get(^TMG(22705.5,TklIEN,0)),"^",5)
|
---|
98 | . new DateStr set DateStr=""
|
---|
99 | . new DocClIEN set DocClIEN=0
|
---|
100 | . ;"Note: ADCPT xref --> Patient,Doc CLASS,Status,InverseRefDate,DocIEN
|
---|
101 | . for set DocClIEN=$order(^TIU(8925,"ADCPT",PtIEN,DocClIEN)) quit:(+DocClIEN'>0)!found do
|
---|
102 | . . new RefDate set RefDate=""
|
---|
103 | . . for set RefDate=$order(^TIU(8925,"ADCPT",PtIEN,DocClIEN,StatusIEN,RefDate)) quit:(RefDate="")!found do
|
---|
104 | . . . set DocIEN=""
|
---|
105 | . . . for set DocIEN=$order(^TIU(8925,"ADCPT",PtIEN,DocClIEN,StatusIEN,RefDate,DocIEN)) quit:(+DocIEN'>0)!found do
|
---|
106 | . . . . ;"DocIEN should be a COMPLETED document for patient
|
---|
107 | . . . . if $data(^TMG(22705.5,"C",DocIEN)) quit ;"document already linked by another tickler
|
---|
108 | . . . . if $$HasTickler(DocIEN,.DateStr)=0 quit
|
---|
109 | . . . . set found=1
|
---|
110 | . . . . new TMGFDA,TMGMSG
|
---|
111 | . . . . set TMGFDA(22705.5,TklIEN_",",.05)="`"_DocIEN
|
---|
112 | . . . . set TMGFDA(22705.5,TklIEN_",",2)="S" ;"S=SIGNED
|
---|
113 | . . . . set TMGFDA(22705.5,TklIEN_",",1)=DateStr
|
---|
114 | . . . . do FILE^DIE("E","TMGFDA","TMGMSG")
|
---|
115 | . . . . if $data(TMGMSG("DIERR"))=0 quit ;"no errors, so we are done here...
|
---|
116 | . . . . do SendErrAddendum(DocIEN,TklIEN,.TMGMSG)
|
---|
117 | . if found=0 do ;"no match COMPLETED document found for TICKLER entry
|
---|
118 | . . ;"Check if patient has any non-COMPLETED documents, if so, wait longer
|
---|
119 | . . set DocIEN=""
|
---|
120 | . . for set DocIEN=$order(^TIU(8925,"C",PtIEN,DocIEN)) quit:(+DocIEN'>0)!found do
|
---|
121 | . . . set found=(+$piece($get(^TIU(8925,DocIEN,0)),"^",5)=StatusIEN)
|
---|
122 | . . if found=0 do ;"TICKLER entry doesn't refer to any real message (must have been deleted in CPRS)
|
---|
123 | . . . new TMGFDA,TMGMSG
|
---|
124 | . . . set TMGFDA(22705.5,TklIEN_",",2)="O" ;"O=ORPHANED
|
---|
125 | . . . do FILE^DIE("E","TMGFDA","TMGMSG")
|
---|
126 | . . . if $data(TMGMSG("DIERR"))=0 quit ;"no errors, so we are done here...
|
---|
127 | . . . do SendErrAddendum(DocIEN,TklIEN,.TMGMSG)
|
---|
128 |
|
---|
129 | ;"Scan all TMG TICKLER entries that have a status of SIGNED,
|
---|
130 | ;"and if the due date has arrived,then process. Change status to COMPLETED, and
|
---|
131 | ;"create an new document that is an ADDENDUM to the document.
|
---|
132 | ;"Send message 'Your message is now due' etc...
|
---|
133 | ;"ADDENDUM: I changed the external text of status (S)/SIGNED to be 'PENDING' for user clarity
|
---|
134 | set TklIEN=0
|
---|
135 | for set TklIEN=$order(^TMG(22705.5,"S","S",TklIEN)) quit:(+TklIEN'>0) do
|
---|
136 | . new DocIEN set DocIEN=+$piece($get(^TMG(22705.5,TklIEN,0)),"^",4)
|
---|
137 | . new AuthorIEN set AuthorIEN=+$piece($get(^TMG(22705.5,TklIEN,0)),"^",5) ;"0;5 = USER
|
---|
138 | . new X,X1,X2,%,%Y,DueDateT,NowDateT
|
---|
139 | . set (X1,DueDateT)=$piece(^TMG(22705.5,TklIEN,0),"^",2) ;" 0;2 = DUE DATE, Field 1
|
---|
140 | . do NOW^%DTC set (X2,NowDateT)=%
|
---|
141 | . do ^%DTC ;"returns X=X1-X2 (ie X=DUE-NOW); If %Y=, dates were imprecise and unworkable.
|
---|
142 | . if %Y=0 do quit
|
---|
143 | . . if DocIEN'>0 set X=0 quit ;"Bigger problem exists, will be reported below.
|
---|
144 | . . set s(1)="**Error Processing Dates for Tickler Message**"
|
---|
145 | . . set s(2)="(This note may be edited or deleted--until signed.)"
|
---|
146 | . . set s(3)="Date found was imprecise and unworkable, or '#DUE#:' text was not found."
|
---|
147 | . . set s(4)="TO FIX: Please create an addendum to the original note and add a NEW TICKLER message."
|
---|
148 | . . do SendAddendum(DocIEN,AuthorIEN,TklIEN,.s)
|
---|
149 | . . ;"If we don't specified the tickler to be Completed, the error will be sent repeatedly
|
---|
150 | . . new TMGFDA,TMGMSG
|
---|
151 | . . set TMGFDA(22705.5,TklIEN_",",2)="C" ;"C=COMPLETED
|
---|
152 | . . do FILE^DIE("","TMGFDA","TMGMSG")
|
---|
153 | . . if $data(TMGMSG("DIERR"))=0 quit ;"no errors, so we are done here...
|
---|
154 | . . do SendErrAddendum(DocIEN,TklIEN,.TMGMSG)
|
---|
155 | . if X'<1 quit ;"Tickler not yet due, so wait longer.
|
---|
156 | . new waitMore set waitMore=0
|
---|
157 | . if X=0 do quit:waitMore=1
|
---|
158 | . . new dueTime set dueTime=$$LJ^XLFSTR($piece(DueDateT,".",2),6,"0")
|
---|
159 | . . new nowTime set nowTime=$$LJ^XLFSTR($piece(NowDateT,".",2),6,"0")
|
---|
160 | . . if dueTime>nowTime set waitMore=1
|
---|
161 | . ;"Success! Tickler is due. Send addendum
|
---|
162 | . if DocIEN=0 do quit
|
---|
163 | . . do SendAlert(AuthorIEN,TklIEN,"Can't find Document for Tickler record. (Shouldn't happen). Check TMGTICKL.m")
|
---|
164 | . new s
|
---|
165 | . set s(1)=" "
|
---|
166 | . set s(2)=" * * Tickler message due date has arrived * * "
|
---|
167 | . set s(3)="================================================"
|
---|
168 | . set s(4)=" This note may be edited if needed until signed"
|
---|
169 | . set s(5)=" "
|
---|
170 | . set s(6)=" Please note original tickler message."
|
---|
171 | . set s(7)=" "
|
---|
172 | . do SendAddendum(DocIEN,AuthorIEN,TklIEN,.s)
|
---|
173 | . new TMGFDA,TMGMSG
|
---|
174 | . set TMGFDA(22705.5,TklIEN_",",2)="C" ;"C=COMPLETED
|
---|
175 | . do FILE^DIE("","TMGFDA","TMGMSG")
|
---|
176 | . if $data(TMGMSG("DIERR"))=0 quit ;"no errors, so we are done here...
|
---|
177 | . do SendErrAddendum(DocIEN,TklIEN,.TMGMSG)
|
---|
178 |
|
---|
179 | HandlDone
|
---|
180 | quit
|
---|
181 |
|
---|
182 |
|
---|
183 | HasTickler(DocIEN,DateStr)
|
---|
184 | ;"Purpose: To determine if the REPORT TEXT for the TIU DOCUMENT (DocIEN) WP field
|
---|
185 | ;" contains the string that signals a TICKLER message.
|
---|
186 | ;" Notice: The string matched here *same* string as is found in TICKLER()
|
---|
187 | ;"Input: DocIEN -- IEN in 8925
|
---|
188 | ;" DateStr -- PASS BY REFERENCE, an OUT PARAMETER
|
---|
189 | ;" Returns Due Date *String* from '#DUE#: <Place-Due-Date-Here>
|
---|
190 | ;" on line AFTER [TICKLER MESSAGE]
|
---|
191 | ;"Result: 1 if found, 0 if not.
|
---|
192 |
|
---|
193 | set DateStr=""
|
---|
194 | new found,line set (found,line)=0
|
---|
195 | for set line=$order(^TIU(8925,DocIEN,"TEXT",line)) quit:(+line'>0)!found do
|
---|
196 | . set found=($get(^TIU(8925,DocIEN,"TEXT",line,0))["[TICKLER MESSGE]")
|
---|
197 | . new done set done=0
|
---|
198 | . if found for set line=$order(^TIU(8925,DocIEN,"TEXT",line)) quit:(+line'>0)!done do
|
---|
199 | . . if $get(^TIU(8925,DocIEN,"TEXT",line,0))'["#DUE#:" quit
|
---|
200 | . . set done=1
|
---|
201 | . . set DateStr=$piece(^TIU(8925,DocIEN,"TEXT",line,0),"#DUE#:",2)
|
---|
202 | . . new ch for set ch=$extract(DateStr,1) quit:(ch'=" ") do ;"trim off leading spaces
|
---|
203 | . . . set DateStr=$extract(DateStr,2,200)
|
---|
204 | . . for quit:(DateStr'["@ ") do ;"handle 'mm/dd/yy @ time' format (i.e. spaces after @)
|
---|
205 | . . . new spec set spec("@ ")="@"
|
---|
206 | . . . set DateStr=$$REPLACE^XLFSTR(DateStr,.spec)
|
---|
207 |
|
---|
208 | quit found
|
---|
209 |
|
---|
210 |
|
---|
211 | SendAddendum(DocIEN,AuthorIEN,TklIEN,TMGWP)
|
---|
212 | ;"Purpose: To place an addendum to the specified note (or the note's parent if
|
---|
213 | ;" the note is itself already an addendum.
|
---|
214 | ;"Input: DocIEN -- IEN in 8925
|
---|
215 | ;" AuthorIEN -- IEN in 200 of author
|
---|
216 | ;" TklIEN -- Tickler IEN 22705.5
|
---|
217 | ;" TMGWP --PASS BY REFERENCE. message to put in addendum.
|
---|
218 | ;" e.g. TMGWP(1)="First line of text."
|
---|
219 | ;" TMGWP(2)="Second line of text."
|
---|
220 | ;"Result: 1 if successful, 0 if error. <--- NO. No result returned.
|
---|
221 |
|
---|
222 | new result set result=1 ;"default to success.
|
---|
223 |
|
---|
224 | new parentIEN set parentIEN=+$piece($get(^TIU(8925,DocIEN,0)),"^",6) ;"0;6= FIELD .06, PARENT
|
---|
225 | if parentIEN>0 set DocIEN=parentIEN
|
---|
226 | new PtIEN set PtIEN=+$piece($get(^TMG(22705.5,TklIEN,0)),"^",1)
|
---|
227 | new visitIEN set visitIEN=+$piece($get(^TIU(8925,DocIEN,0)),"^",3)
|
---|
228 | new locIEN set locIEN=+$piece($get(^TIU(8925,DocIEN,12)),"^",11)
|
---|
229 | new HlocIEN set HlocIEN=+$piece($get(^TIU(8925,DocIEN,12)),"^",5)
|
---|
230 | new divIEN set divIEN=+$piece($get(^TIU(8925,DocIEN,12)),"^",12)
|
---|
231 | new serviceIEN set serviceIEN=+$piece($get(^TIU(8925,DocIEN,14)),"^",4)
|
---|
232 |
|
---|
233 | new DIC,X,Y
|
---|
234 | set DIC=8925.1
|
---|
235 | set DIC("S")="I $P(^(0),U,4)=""DOC""" ;"screen for Type=Title
|
---|
236 | set X="ADDENDUM"
|
---|
237 | do ^DIC
|
---|
238 | if +Y'>0 do goto SendADone
|
---|
239 | . set result=0
|
---|
240 | . do SendAlert(AuthorIEN,TklIEN,"Unable to find ADDENDUM Title for Tickler Note")
|
---|
241 | new docTypeIEN set docTypeIEN=+Y
|
---|
242 |
|
---|
243 | set DIC("S")="I $P(^(0),U,4)=""DC""" ;"screen for Type=Class
|
---|
244 | set X="ADDENDUM"
|
---|
245 | do ^DIC
|
---|
246 | if +Y'>0 do goto SendADone
|
---|
247 | . set result=0
|
---|
248 | . do SendAlert(AuthorIEN,TklIEN,"Unable to find ADDENDUM class for Tickler Note")
|
---|
249 | new DocClassIEN set DocClassIEN=+Y
|
---|
250 |
|
---|
251 | new TMGFDA,TMGMSG,TMGIEN
|
---|
252 | set TMGFDA(8925,"+1,",.01)="`"_docTypeIEN ;".01 = DOCUMENT TYPE
|
---|
253 | set TMGFDA(8925,"+1,",.02)="`"_PtIEN ;".02 = PATIENT
|
---|
254 | set TMGFDA(8925,"+1,",.03)="`"_visitIEN ;".03 = VISIT
|
---|
255 | set TMGFDA(8925,"+1,",.04)="`"_DocClassIEN;".04 = PARENT DOCUMENT TYPE
|
---|
256 | set TMGFDA(8925,"+1,",.05)="UNSIGNED" ;".05 = STATUS
|
---|
257 | set TMGFDA(8925,"+1,",.06)="`"_DocIEN ;".06 = PARENT
|
---|
258 | set TMGFDA(8925,"+1,",.07)="NOW" ;".07 = EPISODE BEGIN DATE/TIME
|
---|
259 | set TMGFDA(8925,"+1,",.13)="A" ;".13 = VISIT TYPE
|
---|
260 | set TMGFDA(8925,"+1,",1201)="NOW" ;"1201 = ENTRY DATE/TIME
|
---|
261 | set TMGFDA(8925,"+1,",1202)="`"_AuthorIEN ;"1202 = AUTHOR/DICTATOR
|
---|
262 | set TMGFDA(8925,"+1,",1204)="`"_AuthorIEN ;"1204 = EXPECTED SIGNER
|
---|
263 | set TMGFDA(8925,"+1,",1205)="`"_HlocIEN ;"1205 = HOSPITAL LOCATION
|
---|
264 | set TMGFDA(8925,"+1,",1211)="`"_locIEN ;"1211 = VISIT LOCATION
|
---|
265 | set TMGFDA(8925,"+1,",1212)="`"_divIEN ;"1212 = DIVISION
|
---|
266 | set TMGFDA(8925,"+1,",1301)="NOW" ;"1301 = REFERENCE DATE
|
---|
267 | set TMGFDA(8925,"+1,",1302)="`"_AuthorIEN ;"1302 = ENTERED BY
|
---|
268 | set TMGFDA(8925,"+1,",1303)="direct" ;"1303 = CAPTURE METHOD
|
---|
269 | set TMGFDA(8925,"+1,",1404)="`"_serviceIEN;"1404 = SERVICE
|
---|
270 | set TMGFDA(8925,"+1,",1506)="NO" ;"1506 = COSIGNATURE NEEDED
|
---|
271 |
|
---|
272 | do UPDATE^DIE("E","TMGFDA","TMGIEN","TMGMSG")
|
---|
273 |
|
---|
274 | if $data(TMGMSG("DIERR")) do goto SendADone
|
---|
275 | . set result=0
|
---|
276 | . do SendAlert(AuthorIEN,TklIEN,"Error creating Tickler addendum.",.TMGMSG)
|
---|
277 |
|
---|
278 | new newDocIEN set newDocIEN=TMGIEN(1)
|
---|
279 | Do SEND^TIUALRT(newDocIEN) ;"create alert regarding note needing to be signed.
|
---|
280 |
|
---|
281 | kill TMGMSG
|
---|
282 | do WP^DIE(8925,newDocIEN_",",2,"","TMGWP","TMGMSG")
|
---|
283 |
|
---|
284 | if $data(TMGMSG("DIERR")) do goto SendADone
|
---|
285 | . set result=0
|
---|
286 | . do SendAlert(AuthorIEN,TklIEN,"Error filing message into Tickler addendum.",.TMGMSG)
|
---|
287 |
|
---|
288 | SendADone
|
---|
289 | ;"quit result
|
---|
290 | quit
|
---|
291 |
|
---|
292 |
|
---|
293 | SendErrAddendum(DocIEN,TklIEN,TMGMSG)
|
---|
294 | ;"Purpose: to send an addendum to note showing database error.
|
---|
295 | ;"Input: DocIEN: the document that should have the addendum added.
|
---|
296 | ;" TklIEN: the IEN of the tickler record
|
---|
297 | ;" TMGMSG: PASS BY REFERENCE. The error array, as returned by fileman.
|
---|
298 | ;"result: none.
|
---|
299 |
|
---|
300 | new ErrStr
|
---|
301 | set ErrStr(1)="Database error encountered handling tickler message."
|
---|
302 | set ErrStr(2)="Note: This may be deleted..."
|
---|
303 | set ErrStr(3)=$$GetErrStr(.TMGMSG)
|
---|
304 | new AuthorIEN set AuthorIEN=$piece($get(^TMG(22705.5,TklIEN,0)),"^",5)
|
---|
305 | do SendAddendum(DocIEN,AuthorIEN,TklIEN,.ErrStr)
|
---|
306 | quit
|
---|
307 |
|
---|
308 |
|
---|
309 | SendAlert(UserIEN,TklIEN,Msg,TMGMSG)
|
---|
310 | ;"Purpose: to send a message alert to the user (for error reporting)
|
---|
311 | ;"Input: UserIEN -- IEN in 200, the target of the message
|
---|
312 | ;" TklIEN -- the IEN of the tickler message
|
---|
313 | ;" Msg -- the message to send. **ONLY UP TO 80 characters**
|
---|
314 | ;" No ^ allowed in the message!
|
---|
315 | ;" TMGMSG -- OPTIONAL, PASS BY REFERENCE.
|
---|
316 | ;" An error array as created by Fileman.
|
---|
317 | ;"results: none
|
---|
318 |
|
---|
319 | ;"initialize vars for alert code
|
---|
320 | new XQA,XQAARCH,XQADATA,XQAFLG,XQAGUID,XQAID,XQAMSG
|
---|
321 | new XQAOPT,XQAROU,XQASUPV,XQASURO,XQATEXT
|
---|
322 |
|
---|
323 | set XQADATA=TklIEN_"^"_Msg
|
---|
324 | if $data(TMGMSG) set XQADATA=XQADATA_"^"_$$GetErrStr(.TMGMSG)
|
---|
325 | set XQA(UserIEN)=""
|
---|
326 | set XQAMSG=Msg
|
---|
327 | set XQAROU="ERRSHOW^TMGTICKL"
|
---|
328 |
|
---|
329 | do SETUP^XQALERT ;"send the alert
|
---|
330 |
|
---|
331 | quit
|
---|
332 |
|
---|
333 | ERRSHOW
|
---|
334 | ;"Purpose: To show details about error.
|
---|
335 | ;"Input: Global-scoped variable XQADATA will hold TklIEN^Msg^FMErrStr
|
---|
336 | ;" Note: TklIEN could be 0
|
---|
337 | ;"Results: none
|
---|
338 |
|
---|
339 | write !,!
|
---|
340 | write "Notice: There was an error processing a tickler message.",!
|
---|
341 | write "This notice is to provide as much detail as is possible,",!
|
---|
342 | write "so that the tickler message does not get lost.",!,!
|
---|
343 |
|
---|
344 | new TklIEN,Msg,FMErrStr
|
---|
345 |
|
---|
346 | if $data(XQADATA)=0 do goto ErShDone
|
---|
347 | . write "But XQADATA doesn't hold info(??). Aborting.",!
|
---|
348 | . do PressToCont
|
---|
349 |
|
---|
350 | set TklIEN=+$piece(XQADATA,"^",1)
|
---|
351 | set Msg=$piece(XQADATA,"^",2)
|
---|
352 | set FMErrStr=$piece(XQADATA,"^",3)
|
---|
353 |
|
---|
354 | write "The error message was:",!
|
---|
355 | write Msg,!
|
---|
356 | do PressToCont
|
---|
357 |
|
---|
358 | if TklIEN>0 do
|
---|
359 | . write !
|
---|
360 | . write "PATIENT:",$$GET1^DIQ(22705.5,TklIEN,.01),!
|
---|
361 | . write "DOCUMENT:",$$GET1^DIQ(22705.5,TklIEN,.05)," (#",$$GET1^DIQ(22705.5,TklIEN,.05,"I"),")",!
|
---|
362 | . write "DUE DATE:",$$GET1^DIQ(22705.5,TklIEN,1),!
|
---|
363 | . write "AUTHOR:",$$GET1^DIQ(22705.5,TklIEN,3),!
|
---|
364 | . write "AUTHOR:",$$GET1^DIQ(22705.5,TklIEN,3),!
|
---|
365 | . write "TICKLER STATUS:",$$GET1^DIQ(22705.5,TklIEN,2),!
|
---|
366 | . write "1st LINE OF MESSAGE:",$$GET1^DIQ(22705.5,TklIEN,5),!
|
---|
367 | . do PressToCont
|
---|
368 |
|
---|
369 | if FMErrStr'="" do
|
---|
370 | . write !,"The Fileman (database) error message was:",!
|
---|
371 | . write FMErrStr,!
|
---|
372 | . do PressToCont
|
---|
373 |
|
---|
374 | write !,!
|
---|
375 | write "Hopefully this will be enough information for you",!
|
---|
376 | write "to fix the tickler message.",!
|
---|
377 | write "Please follow up on this NOW....",!
|
---|
378 | write "This will be the *only* reminder!",!!
|
---|
379 | do PressToCont
|
---|
380 |
|
---|
381 | ErShDone
|
---|
382 | quit
|
---|
383 |
|
---|
384 |
|
---|
385 | RecheduleTask
|
---|
386 | ;"Purpose: to set up task to periodically handle tickler messages.
|
---|
387 | ;"Result: None
|
---|
388 |
|
---|
389 | new temp set temp=1
|
---|
390 | if temp=0 quit ;"a debugging measure so that launching a duplicate task can be avoided
|
---|
391 |
|
---|
392 | new ZTRTN,ZTDESC,ZTDTH,ZTIO,ZTUCI,ZTCPU
|
---|
393 | new ZTPRI,ZTSAVE,ZTKIL,ZTSYNC,ZTSK
|
---|
394 |
|
---|
395 | set ZTRTN="HANDLE^TMGTICKL"
|
---|
396 | set ZTDESC="TMG TICKLER MESSAGES HANDLER"
|
---|
397 | set ZTIO=""
|
---|
398 |
|
---|
399 | new hrInterval set hrInterval=+$piece($get(^TMG(22705.4,1,0)),"^",2) ;"0;2=Interval
|
---|
400 | if hrInterval<1 do goto SchTDone
|
---|
401 | . do SendAlert(DUZ,0,"Tickler Error: Interval (field #1) in file 22705.4 < 1 hr")
|
---|
402 | . set ZTSK=0
|
---|
403 |
|
---|
404 | new X,Y,%,%DT
|
---|
405 | set %DT="XR" set X="NOW+"_hrInterval_"H" do ^%DT
|
---|
406 | set ZTDTH=Y ;"schedule time.
|
---|
407 |
|
---|
408 | do ^%ZTLOAD
|
---|
409 | SchTDone
|
---|
410 | set $piece(^TMG(22705.4,1,0),"^",3)=ZTSK ;"there are no XRefs on this field, and I own it...
|
---|
411 | quit
|
---|
412 |
|
---|
413 |
|
---|
414 | ;"===========================================================================
|
---|
415 | ;"Below are copies of functions from TMG Libarary, put here to avoid dependancies
|
---|
416 | ;"===========================================================================
|
---|
417 |
|
---|
418 | PressToCont
|
---|
419 | ;"Purpose: to provide a 'press key to continue' action
|
---|
420 |
|
---|
421 | write "----- Press Key To Continue -----"
|
---|
422 | new ch read ch:$get(DTIME,3600)
|
---|
423 | write !
|
---|
424 | quit
|
---|
425 |
|
---|
426 |
|
---|
427 | GetErrStr(ErrArray)
|
---|
428 | ;"Purpose: convert a standard DIERR array into a string for output
|
---|
429 | ;"Input: ErrArray -- PASS BY REFERENCE. example:
|
---|
430 | ;" array("DIERR")="1^1"
|
---|
431 | ;" array("DIERR",1)=311
|
---|
432 | ;" array("DIERR",1,"PARAM",0)=3
|
---|
433 | ;" array("DIERR",1,"PARAM","FIELD")=.02
|
---|
434 | ;" array("DIERR",1,"PARAM","FILE")=2
|
---|
435 | ;" array("DIERR",1,"PARAM","IENS")="+1,"
|
---|
436 | ;" array("DIERR",1,"TEXT",1)="The new record '+1,' lacks some required identifiers."
|
---|
437 | ;" array("DIERR","E",311,1)=""
|
---|
438 | ;"Results: returns one long equivalent string from above array.
|
---|
439 | ;"Note: This is a copy of the function GetErrStr^TMGDEBUG
|
---|
440 | ;" I copied it here so that this file has no TMG* dependencies.
|
---|
441 |
|
---|
442 | new ErrStr
|
---|
443 | new TMGIDX
|
---|
444 | new ErrNum
|
---|
445 |
|
---|
446 | set ErrStr=""
|
---|
447 | for ErrNum=1:1:+$get(ErrArray("DIERR")) do
|
---|
448 | . set ErrStr=ErrStr_"Fileman says: '"
|
---|
449 | . if ErrNum'=1 set ErrStr=ErrStr_"(Error# "_ErrNum_") "
|
---|
450 | . set TMGIDX=$order(ErrArray("DIERR",ErrNum,"TEXT",""))
|
---|
451 | . if TMGIDX'="" for do quit:(TMGIDX="")
|
---|
452 | . . set ErrStr=ErrStr_$get(ErrArray("DIERR",ErrNum,"TEXT",TMGIDX))_" "
|
---|
453 | . . set TMGIDX=$order(ErrArray("DIERR",ErrNum,"TEXT",TMGIDX))
|
---|
454 | . if $get(ErrArray("DIERR",ErrNum,"PARAM",0))>0 do
|
---|
455 | . . set TMGIDX=$order(ErrArray("DIERR",ErrNum,"PARAM",0))
|
---|
456 | . . set ErrStr=ErrStr_"Details: "
|
---|
457 | . . for do quit:(TMGIDX="")
|
---|
458 | . . . if TMGIDX="" quit
|
---|
459 | . . . set ErrStr=ErrStr_"["_TMGIDX_"]="_$get(ErrArray("DIERR",1,"PARAM",TMGIDX))_" "
|
---|
460 | . . . set TMGIDX=$order(ErrArray("DIERR",ErrNum,"PARAM",TMGIDX))
|
---|
461 |
|
---|
462 | quit ErrStr
|
---|