source: FOIAVistA/tag/r/ONCOLOGY-ONC/ONCSAPIE.m@ 1416

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

initial load of FOIAVistA 6/30/08 version

File size: 7.8 KB
Line 
1ONCSAPIE ;Hines OIFO/SG - COLLABORATIVE STAGING (ERRORS) ; 10/27/06 8:59am
2 ;;2.11;ONCOLOGY;**40,47**;Mar 07, 1995;Build 19
3 ;;
4 ;
5 Q
6 ;
7 ;***** INITIALIZES THE ERROR STACK
8 ;
9 ; [ENABLE] Enable error stack (0/1)
10 ;
11CLEAR(ENABLE) ;
12 S:'$D(ENABLE) ENABLE=$D(ONCSAPI("MSG"))#10
13 K ONCSAPI("MSG") S:ENABLE ONCSAPI("MSG")=""
14 D CLEAN^DILF
15 Q
16 ;
17 ;***** CHECKS THE ERRORS AFTER A FILEMAN DBS CALL
18 ;
19 ; ONC8MSG Closed reference of the error messages array
20 ; (from DBS calls)
21 ; [ERRCODE] Error code to assign
22 ; [FILE] File number used in the DBS call
23 ; [IENS] IENS used in the DBS call
24 ;
25 ; The $$DBS^ONCSAPIE function checks the DIERR and @ONC8MSG
26 ; variables for errors after a FileMan DBS call.
27 ;
28 ; Return Values:
29 ;
30 ; If there are no errors found, it returns an empty string.
31 ; In case of errors, the result depends on value of the ERRCODE
32 ; parameter:
33 ;
34 ; If ERRCODE is omitted or equals 0, the function returns a string
35 ; containing the list of error codes separated by comma.
36 ;
37 ; If ERRCODE is not zero, the $$ERROR^ONCSAPIE function is called
38 ; and its return value is returned.
39 ;
40 ; NOTE: This entry point can also be called as a procedure:
41 ; D DBS^ONCSAPIE(...) if you do not need its return value.
42 ;
43DBS(ONC8MSG,ERRCODE,FILE,IENS) ;
44 I '$G(DIERR) Q:$QUIT "" Q
45 N ERRLST,ERRNODE,I,MSGTEXT
46 S ERRNODE=$S($G(ONC8MSG)'="":$NA(@ONC8MSG@("DIERR")),1:$NA(^TMP("DIERR",$J)))
47 I $D(@ERRNODE)<10 Q:$QUIT "" Q
48 ;--- Return a list of errors
49 I '$G(ERRCODE) D Q:$QUIT $P(ERRLST,",",2,99) Q
50 . S ERRLST="",I=0
51 . F S I=$O(@ERRNODE@("E",I)) Q:'I S ERRLST=ERRLST_","_I
52 . D CLEAN^DILF
53 ;--- Record the error message
54 D MSG^DIALOG("AE",.MSGTEXT,,,$G(ONC8MSG)),CLEAN^DILF
55 S I=$S($G(FILE):"; File #"_FILE,1:"")
56 S:$G(IENS)'="" I=I_"; IENS: """_IENS_""""
57 S I=$$ERROR(ERRCODE,.MSGTEXT,I)
58 Q:$QUIT I Q
59 ;
60 ;***** GENERATES THE ERROR MESSAGE
61 ;
62 ; ERRCODE Error code.
63 ; If the 'S' suffix is appended to the code, the error
64 ; descriptor will not be stored into the error stack.
65 ;
66 ; [[.]ONCINFO] Optional additional information (either a string or
67 ; a reference to a local array that contains strings
68 ; prepared for storing in a word processing field)
69 ;
70 ; [ARG1-ARG5] Optional parameters as for $$MSG^ONCSAPIE
71 ;
72 ; Return Values:
73 ; <0 Error code^Message Text^Label+Offset^Routine
74 ; 0 Ok (if ERRCOCE'<0)
75 ;
76 ; NOTE: This entry point can also be called as a procedure:
77 ; D ERROR^ONCSAPIE(...) if you do not need its return value.
78 ;
79ERROR(ERRCODE,ONCINFO,ARG1,ARG2,ARG3,ARG4,ARG5) ;
80 I ERRCODE'<0 Q:$QUIT 0 Q
81 N IEN,MSG,PLACE,SL,TMP
82 ;--- Get the error location
83 S SL=$STACK(-1)-1
84 F Q:SL'>0 D Q:'(PLACE["^ONCSAPIE") S SL=SL-1
85 . S PLACE=$P($STACK(SL,"PLACE")," ")
86 S:$G(PLACE)'[U PLACE=U
87 ;--- Prepare the additional information
88 I $D(ONCINFO)=1 S TMP=ONCINFO K ONCINFO S ONCINFO(1)=TMP
89 ;--- Prepare and store the message descriptor
90 S MSG=$$MSG(ERRCODE,,.ARG1,.ARG2,.ARG3,.ARG4,.ARG5)
91 S MSG=(+ERRCODE)_U_MSG_U_PLACE
92 D:ERRCODE'["S" STORE(MSG,"ONCINFO")
93 ;---
94 Q:$QUIT MSG Q
95 ;
96 ;***** RETURNS THE TEXT AND TYPE OF THE MESSAGE
97 ;
98 ; ERRCODE Error code
99 ;
100 ; [.TYPE] Type of the error
101 ;
102 ; [ARG1-ARG5] Optional parameters that substitute the |n| "windows"
103 ; in the text of the message (for example, the |2| will
104 ; be substituted by the value of the ARG2).
105 ;
106 ; NOTE: The "^" is replaced with the "~" in the resulting message.
107 ;
108MSG(ERRCODE,TYPE,ARG1,ARG2,ARG3,ARG4,ARG5) ;
109 S TYPE=6 Q:ERRCODE'<0 ""
110 N ARG,I1,I2,MSG
111 ;--- Get a descriptor of the message
112 S I1=-ERRCODE,MSG=$P($T(MSGLIST+I1),";;",2)
113 S I1=+$TR($P(MSG,U,2)," "),MSG=$P(MSG,U,3,999)
114 S:I1>0 TYPE=I1
115 Q:MSG?." " "Unknown error ("_ERRCODE_")"
116 ;--- Substitute parameters
117 S I1=2
118 F S I1=$F(MSG,"|",I1-1) Q:'I1 D
119 . S I2=$F(MSG,"|",I1) Q:'I2
120 . X "S ARG=$G(ARG"_+$TR($E(MSG,I1,I2-2)," ")_")"
121 . S $E(MSG,I1-1,I2-1)=ARG
122 Q $TR($$TRIM^XLFSTR(MSG),U,"~")
123 ;
124 ;***** DISPLAYS THE ERROR STACK OR A SINGLE ERROR MESSAGE
125 ;
126 ; [ERROR] Descriptor of a single error to be displayed
127 ;
128PRTERRS(ERROR) ;
129 Q:'$G(ERROR)&($D(ONCSAPI("MSG"))<10)
130 N EXIT,IMSG,INFONODE,ONCMNL
131 S ONCMNL=$S($G(IOSL)>3:IOSL-3,1:20),$Y=0
132 ;--- Print table header
133 D EN^DDIOL("Code",,"!"),EN^DDIOL("Description",,"?6")
134 D EN^DDIOL("Additional Information",,"!?6")
135 D EN^DDIOL("Type",,"!?6"),EN^DDIOL("Location",,"?22")
136 D EN^DDIOL("----",,"!"),EN^DDIOL($$REPEAT^XLFSTR("-",IOM-7),,"?6")
137 ;--- Print a single error message
138 I $G(ERROR) S EXIT=$$PRT1ERR(ERROR) Q
139 ;--- Print the error stack (most recent messages first)
140 S IMSG=" ",EXIT=0
141 F S IMSG=$O(ONCSAPI("MSG",IMSG),-1) Q:IMSG'>0 D Q:EXIT
142 . S INFONODE=$NA(ONCSAPI("MSG",IMSG,1))
143 . S EXIT=$$PRT1ERR(ONCSAPI("MSG",IMSG,0),INFONODE)
144 Q
145 ;
146PRT1ERR(ERR,ONC8INFO) ;
147 N EXIT,I,LOC,TYPE
148 S LOC=$S($P(ERR,U,4)'="":$P(ERR,U,3,4),1:$P(ERR,U,3))
149 S I=$$TYPE(+ERR,.TYPE)
150 ;---
151 S EXIT=0 D
152 . D EN^DDIOL($J(+ERR,4),,"!"),EN^DDIOL($E($P(ERR,U,2),1,IOM-7),,"?6")
153 . I $Y'<ONCMNL S EXIT=$$PAGE^ONCSAPIU() Q:EXIT
154 . ;---
155 . I $G(ONC8INFO)'="",$D(@ONC8INFO)>1 S I="" D
156 . . F S I=$O(@ONC8INFO@(I)) Q:I="" D Q:EXIT
157 . . . D EN^DDIOL($E(@ONC8INFO@(I),1,IOM-7),,"!?6")
158 . . . S:$Y'<ONCMNL EXIT=$$PAGE^ONCSAPIU()
159 . Q:EXIT
160 . ;---
161 . D EN^DDIOL(TYPE,,"!?6"),EN^DDIOL(LOC,,"?22"):LOC'?.1"^"
162 . I $Y'<ONCMNL S EXIT=$$PAGE^ONCSAPIU() Q:EXIT
163 ;---
164 D EN^DDIOL(" ")
165 Q EXIT
166 ;
167 ;***** STORES THE MESSAGE INTO THE ERROR STACK
168 ;
169 ; ERROR Error descriptor (see ^ONCSAPI)
170 ;
171 ; [ONC8INFO] Closed root of the variable that contains
172 ; additional information related to the error
173 ;
174STORE(ERROR,ONC8INFO) ;
175 Q:'$D(ONCSAPI("MSG"))!($G(ERROR)'<0)
176 N IEN
177 S IEN=$O(ONCSAPI("MSG"," "),-1)+1
178 S ONCSAPI("MSG",IEN,0)=ERROR
179 M:$G(ONC8INFO)'="" ONCSAPI("MSG",IEN,1)=@ONC8INFO
180 S ONCSAPI("MSG","E",+ERROR,IEN)=""
181 Q
182 ;
183 ;***** RETURNS TYPE OF THE MESSAGE
184 ;
185 ; ERRCODE Error code
186 ;
187 ; [.DESCR] Reference to a local variable where the type
188 ; description is returned to
189 ;
190TYPE(ERRCODE,DESCR) ;
191 I ERRCODE'<0 S DESCR="" Q 0
192 N I,TYPE S I=-ERRCODE
193 S I=$P($T(MSGLIST+I),";;",2),TYPE=+$TR($P(I,U,2)," ")
194 S:TYPE'>0 TYPE=6
195 S DESCR=$P("Debug^Information^Data Quality^Warning^Database Error^Error",U,TYPE)
196 Q TYPE
197 ;
198 ;***** LIST OF THE MESSAGES (THERE SHOULD BE NOTHING AFTER THE LIST!)
199 ;
200 ; The error codes are provided in the table only for clarity.
201 ; Text of the messages are extracted using the $TEXT function and
202 ; absolute values of the ERRCODE parameter.
203 ;
204 ; Message Type:
205 ; 1 Debug 4 Warning
206 ; 2 Information 5 Database Error
207 ; 3 Data Quality 6 Error
208 ;
209MSGLIST ; Code Type Message Text
210 ;; -1 ^ 6 ^ Missing input parameters
211 ;; -2 ^ 6 ^ Errors returned by the Oncology web-service
212 ;; -3 ^ 4 ^ XML parsing warning
213 ;; -4 ^ 6 ^ XML parsing error
214 ;; -5 ^ 6 ^ Error(s) during parsing of the result XML
215 ;; -6 ^ 6 ^ Parameter '|1|' has an invalid value: '|2|'
216 ;; -7 ^ 2 ^ Oncology web-service temporary moved to '|1|'
217 ;; -8 ^ 2 ^ Oncology web-service permanently moved to '|1|'
218 ;; -9 ^ 6 ^ FileMan DBS call error(s)|2|
219 ;; -10 ^ 6 ^ HTTP client error(s)
220 ;; -11 ^ 6 ^ Invalid URL of the Oncology web-service
221 ;; -12 ^ 6 ^ Too many redirections (|1|)
222 ;; -13 ^ 6 ^ Cannot get the CS version number
223 ;; -14 ^ 6 ^ Cannot get the schema number and name
224 ;; -15 ^ 6 ^ Cannot lock the |1|
225 ;; -16 ^ 6 ^ Invalid combination of input parameters: |1|
226 ;; -17 ^ 6 ^ Cannot update the Oncology web-service URL in file #160.1
227 ;; -18 ^ 6 ^ Missing redirection URL
228 ;; -19 ^ 2 ^ Unfortunately, the extended help is unavailable now.
229 ;; -20 ^ 2 ^ Unfortunately, input value cannot be validated.
230 ;; -21 ^ 2 ^ Unfortunately, the code description is unavailable now.
231 ;; -22 ^ 6 ^ Cannot get the URL of the Oncology web-service
232 ;; -23 ^ 6 ^ Cannot get the EDITS metafile version number
Note: See TracBrowser for help on using the repository browser.