source: WorldVistAEHR/trunk/r/HEALTH_LEVEL_SEVEN-HL/HLDIEDB1.m@ 1724

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

initial load of WorldVistAEHR

File size: 8.7 KB
RevLine 
[613]1HLDIEDB1 ;CIOFO-O/LJA - DEBUG Menu ;1/8/04 @ 01:28
2 ;;1.6;HEALTH LEVEL SEVEN;**109**;Oct 13,1995
3 ;
4INIT ;
5 N A7UMENU,A7UOK,A7UOPT,NOMENU,I,T,X,Y
6 ;
7CTRL ;
8 D HEADER
9 D M
10 D ASK I 'A7UOK QUIT ;->
11 D XEC
12 D BT QUIT:'A7UOK ;->
13 G CTRL ;->
14 ;
15BT ;
16 N DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y
17 W !
18 S A7UOK=0
19 N DIR
20 S DIR(0)="EA",DIR("A")="Press RETURN to continue, or '^' to exit... "
21 D ^DIR
22 QUIT:+Y'=1 ;->
23 S A7UOK=1
24 QUIT
25 ;
26HEADER ;
27 N DEBUG,IOINHI,IOINORM,X
28 W @IOF,$$CJ^XLFSTR("HLDIE Debug Utility",IOM)
29 S DEBUG=$G(^XTMP("HLDIE-DEBUG","STATUS"))
30 I DEBUG]"" D ; Show debug string...
31 . S X="IOINORM;IOINHI" D ENDR^%ZISS
32 . S DEBUG="Pre-call: "_$$CD($P(DEBUG,U))_" Post-call: "_$$CD($P(DEBUG,U,2))_" Screen: "_$$CD($P(DEBUG,U,3))
33 . W !,?17,DEBUG
34 W !,$$REPEAT^XLFSTR("=",80)
35 QUIT
36 ;
37CD(TXT) ; debug information
38 ; IOINORM,IOINHI -- req
39 QUIT:TXT']"" "OFF" ;->
40 QUIT IOINHI_"ON["_TXT_"]"_IOINORM ;->
41 ;
42M KILL A7UMENU N I,T F I=1:1 S T=$T(M+I) QUIT:T'[";;" S T=$P(T,";;",2,99),A7UMENU(I)=$P(T,"~",2,99) W !,$J(I,2),". ",$P(T,"~") S NOMENU=I
43 ;;Display debug documentation~D DOC
44 ;;Display debug data - API~D API^HLDIEDB0
45 ;;Display debug data - FILE,IEN~D FILEIEN^HLDIEDB0
46 ;;Display debug data - SEARCH~D SEARCH^HLDIEDB0
47 ;;Display debug data - REALTIME~D REALTIME^HLDIEDB1
48 ;;Display debug data - JOB~D JOB^HLDIEDB3
49 ;;Set debug control string (Turn debugging on/off)~D SETDEBUG^HLDIEDBG
50 ;;Kill debug data~D KILLALL^HLDIEDBG
51 QUIT
52 ;
53ASK ;
54 ; NOMENU -- req
55 N DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y
56 W !
57 S A7UOK=0
58 N DIR
59 S DIR(0)="NO^1:"_NOMENU,DIR("A")="Select option"
60 D ^DIR
61 QUIT:'$D(A7UMENU(+Y)) ;->
62 S A7UOPT=+Y
63 S A7UOK=1
64 QUIT
65 ;
66XEC ;
67 S X=A7UMENU(+A7UOPT) X X
68 QUIT
69 ;
70REALTIME ; real-time monitoring...
71 N C2,C3,C4,C5,C6,C7,C8,CT,GBL,LAST,STOP,X
72 ;
73 S GBL="^XTMP(""HLDIE-DEBUGN"",""N"")",LAST=$G(@GBL)
74 S C2=7,C3=18,C4=30,C5=40,C6=52,C7=70,C8=75
75 ;
76 S CT=0
77 ;
78 D REALHDR
79 ;
80 F D Q:STOP
81 . S STOP=1,CT=CT+1
82 . D REALSHOW
83 . R X:60 QUIT:X]"" ;->
84 . S STOP=0
85 ;
86 Q
87 ;
88REALHDR ; Header for real-time display...
89 ; Cn -- req
90 W !!,"#",?C2,"NOW",?C3,"File [#IEN]",?C4,"DataTM",?C5,"$J"
91 W ?C6,"Rtn",?C7,"LOC",?C8,"Edtor"
92 W !,$$REPEAT^XLFSTR("=",IOM)
93 Q
94 ;
95REALSHOW ; Show information...
96 ;C2,C3,GBL,LAST -- req --> LAST
97 N DNO,NOW,NUM
98 ;
99 S NUM=$G(@GBL),NOW=$$TIME($$NOW^XLFDT)
100 ;
101 I CT=1 D QUIT ;->
102 . W !,?C2,NOW,?C3,"Collecting data..."
103 ;
104 I NUM=LAST D QUIT ;->
105 . W:$X>0 !
106 . W ?C2,NOW,?C3,"[No change]"
107 ;
108 F DNO=(LAST+1):1:NUM D REALONE(DNO)
109 ;
110 S LAST=NUM
111 ;
112 Q
113 ;
114REALONE(DNO) ; Show one entry...
115 ; Cn -- req
116 N DATA,DATE,EDITOR,FILE,IEN,JOB,LOC,RTN,SNO,TIME
117 ;
118 S DATA=$G(@GBL@(DNO))
119 S FILE=$P(DATA,U),IEN=$P(DATA,U,2),TIME=$P(DATA,U,3),JOB=$P(DATA,U,4)
120 S RTN=$P(DATA,U,5),SNO=$P(DATA,U,6),EDITOR=$P(DATA,U,7)
121 ;
122 S TIME=$$TIME(TIME)
123 ;
124 W !,$J(DNO,5),?C2,NOW,?C3,FILE," [#",IEN,"]",?C4,TIME,?C5,JOB
125 W ?C6,RTN,?C7,SNO,?C8,$S(EDITOR["HLDIE":"HL",1:"FM")
126 ;
127 Q
128 ;
129TIME(FMTIME) ; Return HH:MM:SS
130 S FMTIME=$P(FMTIME_"000000",".",2)
131 QUIT $E(FMTIME,1,2)_":"_$E(FMTIME,3,4)_":"_$E(FMTIME,5,6)
132 ;
133 ;
134 ;
135DOC N C,I,IOINHI,IOINORM,T,X
136 S X="IOINHI;IOINORM" D ENDR^%ZISS
137 F I=4:1 S T=$T(DOC+I) QUIT:T'[";;"!($G(X)[U) D
138 . S T=$P(T,";;",2,99) S:$E(T,1,2)="[[" T=IOINHI_$TR(T,"[]","")_IOINORM W !,T
139 ;;[[OVERVIEW]]
140 ;; HLDIE debug data can be captured for evaluation by setting a "debug string."
141 ;; The debug string is stored on the ^XTMP("HLDIE-DEBUG","STATUS") node.
142 ;; This debug string should be set using the 'Set debug control string (Turn
143 ;; debugging on/off)' menu choice.
144 ;;
145 ;;
146 ;;[[DEBUG STRING DETAILS]]
147 ;; The "debug string" had three(3) pieces:
148 ;;
149 ;; * Piece 1 controls data capture prior to FILE^DIE or FILE^HLDIE call.
150 ;; - If set to 1, "select" data (see below) is captures.
151 ;; - If set to 2, all local variables are captures.
152 ;; - If set to "", no data is collected.
153 ;;
154 ;; * Piece 2 controls data capture after FILE^DIE or FILE^HLDIE call.
155 ;; - See piece 1 above for setting details.
156 ;;
157 ;; * Piece 3 activates data capture screening.
158 ;; - Piece 3 can be set to 1 to activate the data screen held in
159 ;; $$STORESCR^HLDIEDB2. This API holds no M code, but is a placeholder
160 ;; for M code that can evaluate the environment and on-the-fly turn on
161 ;; or off data storage. (It can also control whethere "select" or all
162 ;; data is captured.)
163 ;;
164 ;;
165 ;;[[PIECE 3 DATA SCREEN DETAILS]]
166 ;; If piece 3 of the debug control string equals 1, the following
167 ;; occurs:
168 ;;
169 ;; * $$STORESCR^HLDIEDB2 is called by debugging process in FILE^HLDIE.
170 ;; * The local variable STORE holds the value null, 1 or 2 (see above),
171 ;; specifying whether data should be captured, and if so, whether "select"
172 ;; or all local variables should be stored.
173 ;; * If M code has been added to $$STORESCR^HLDIEDB2, it may evaluate the
174 ;; environment and optionally reset STORE to null, 1 or 2.
175 ;; * The value of STORE after M code execution is returned to the debugging
176 ;; process. (And, if set to null, no data is captured.)
177 ;;
178 ;; The following variables are defined for use by the M code added to
179 ;; $$STORESCR^HLDIEDB2:
180 ;;
181 ;; * CT - The number occurences already stored for TODAY/JOB#/API.
182 ;; (When a job calls STATUS^HLTF0, a call is made to FILE^HLDIE which
183 ;; can result in the creation of a debug data capture entry. Every
184 ;; such call by the job to STATUS^HLTF0 results in the creation of
185 ;; another data capture. Twenty such calls can be made, after which
186 ;; the oldest capture is removed by the FIFO method. The value of CT
187 ;; holds the total number of data capture occurences.)
188 ;; * DEBUGNO - The sequential number to be used during data storage.
189 ;; * DEBUGNOW - The date/time that will be used during data storage.
190 ;; * HLFILE - The file being edited.
191 ;; * HLIEN - The file's IEN being edited.
192 ;; * LOC - 1 (before call) or 2 (after call).
193 ;; * RTN - RTN~SUBRTN (from the 4th & 5th FILE^HLDIE parameters.)
194 ;; * STORE - "" (don't store), 1 (store "select"), or 2 (store all.)
195 ;;
196 ;;
197 ;;[[DEBUGGING - ALL VARIABLE STORAGE]]
198 ;; Unrelated to the above debugging instructions, the
199 ;; LOG^HLDIEDBG(SUBSV,KEEP,STOP) API can be used by VistA HL7 developers to
200 ;; store all variables. (The DOLRO^%ZOSV API is used.) Data created by this
201 ;; call is stored in:
202 ;;
203 ;; ^XTMP("HLDIE-"_DT,SUBSV,#,VAR)=VALUE
204 ;;
205 ;; Entries in this global are sequential at the '#' subscript level. When a
206 ;; call is made to this API, all local variables are stored at the VAR
207 ;; subscript level.
208 ;;
209 ;; The LOG API has the following parameters:
210 ;;
211 ;; * SUBSV - The subscript to be used when storing data. (The value of this
212 ;; parameter is usually RTN~SUBRTN.)
213 ;; * KEEP - The number of entries to store. (The entry of this parameter is
214 ;; optional, defaulting to 20.)
215 ;; * STOP - If set to 1, after KEEP number of entries are stored, no more
216 ;; data is captured, (and no data is deleted.) If not set to 1,
217 ;; KEEP number of entries are stored, the first entry stored is
218 ;; deleted in FIFO manner, to ensure that no more than KEEP entries
219 ;; exist.
220 Q
221 ;
222ERR ; If error occurs during screening...
223 ; The SENDUZ(DUZ)="" array *MUST* already be defined...
224 N C,DATA,ERRTXT,LP,NO,ST,STORERR,TEXT,TIME,X,XMDUZ,XMSUB,XMTEXT,XMZ
225 ;
226 ; Before continuing, specify that NOTHING should be stored...
227 ; This email message is ALL that will be stored or sent.
228 S STORE="" ; This variable is returned to FILE^HLDIE execution
229 ;
230 ; Also, turn off STORE capture!
231 S ^XTMP("HLDIE-DEBUG","STATUS")=""
232 ;
233 ; Record an error in logger...
234 S ERRTXT=$$EC^%ZOSV
235 S X=$$LOG^HLEVAPI2("FILE-HLDIE","ERRTXT")
236 ;
237 ; setup things...
238 S XMDUZ=.5,XMSUB="HLDIE $$STORESCR Error"
239 S XMTEXT="^TMP("_$J_",""HLMSG"","
240 KILL ^TMP($J,"HLMSG"),^TMP($J,"HLVAR")
241 S NO=0
242 ;
243 ; Add text...
244 D MAILADD("An error occurred in $$STORESCR^HLDIEDB2 that must be checked. The")
245 D MAILADD("variables that existed at the time of the error are listed below.")
246 D MAILADD("")
247 D MAILADD("The error was '"_$$EC^%ZOSV_"'.")
248 D MAILADD("")
249 D MAILADD("IMPORTANT!! All debugging was turned off. Please review the problem,")
250 D MAILADD(" then turn debugging back on.")
251 D MAILADD("")
252 D MAILADD("Local Variable List"),MAILADD("--------------------")
253 ;
254 S X="^TMP("_$J_",""HLVAR""," D DOLRO^%ZOSV
255 S LP="^TMP("_$J_",""HLVAR""",ST=LP_",",LP=LP_")",C=","
256 F S LP=$Q(@LP) Q:LP'[ST D
257 . S DATA=$TR($P($P(LP,ST,2),")"),"""","")
258 . I DATA[C S DATA=$P(DATA,C)_"("_$P(DATA,C,2,99)_")"
259 . D MAILADD(DATA_"="_@LP)
260 ;
261 MERGE XMY=SENDUZ
262 I $O(XMY(0))'>0 S XMY(+$G(DUZ))=""
263 ;
264 D ^XMD
265 ;
266 KILL ^TMP($J,"HLMSG"),^TMP($J,"HLVAR")
267 ;
268 D UNWIND^%ZTER
269 ;
270 Q
271 ;
272MAILADD(T) S NO=$G(NO)+1,^TMP($J,"HLMSG",NO)=T
273 QUIT
274 ;
275EOR ;HLDIEDB1 - DEBUG Menu ;1/8/04 @ 01:28
Note: See TracBrowser for help on using the repository browser.