source: BMXNET_RPMS_dotNET_UTILITIES-BMX/branch/BMX41000/IHS BMX Framework/IndianHealthService.BMXNet/RemoteSession.cs@ 1416

Last change on this file since 1416 was 1180, checked in by Sam Habiel, 14 years ago

RemoteSession.cs Interface: Added:

  • Lock method to lock glvns on M db.
  • Encoding ConnectionEncoding to set the connection encoding on the DB

BMXNetSessionConnection: Added:

  • Abstract ConnectionEncoding property
  • Clarified error message that gets called. It now says that you don't have TransmitRPC writer lock??? When the error could be any BMXNetException.

BMXNetSessionSocketConnection:

  • Added ConnectionEncoding property
  • ReceiveString completely refactored: now we get much better performance
  • Timers and Debug Writes are all over the place now.

BMXNetRemoteSession:

  • Implemented the 2 new 'stuff' in Interface RemoteSesssion: -- Lock glvn -- Encoding Property
  • TableFromSQL with Dataset has an honest to god bug in it: The passed dataset and table name are not used even though they are passed.

BMXNetSessionConnectionOverAnotherSessionConnection:

  • Implemented the Encoding Property in Interface RemoteSession to have the project compile.

Updated dlls. Have fun.

File size: 38.6 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.Data;
5using IndianHealthService.BMXNet.Ado;
6using IndianHealthService.BMXNet.Services;
7using IndianHealthService.BMXNet.Model;
8
9namespace IndianHealthService.BMXNet
10{
11 /// <summary>
12 /// All server-side RPMS RPC calls are performed through this interface. Each instance of RemoteSession corresponds to a single job (e.g. Cache process) on RPMS. There is always one primary RemoteSession and potentially more when using RemoteSessionPool. When the primary RemoteSession is closed all secondary pooled sessions are also closed and the server broker connection is terminated.
13 /// </summary>
14 public interface RemoteSession
15 {
16 #region General Properties
17 /// <summary>
18 /// BMX Broker's host address name or IP Address
19 /// </summary>
20 String HostAddress { get; }
21
22 /// <summary>
23 /// Authenticated user associated with this remote session
24 /// </summary>
25 /// <example>
26 /// this.StatusLabel.Text="Logged in: "+ aRemoteSession.User.Name;
27 /// </example>
28 /// /// <remarks>
29 /// If there is a remoteSession user, it will be the same as the localSession User object
30 /// </remarks>
31 User User { get; }
32
33 /// <summary>
34 /// The active AppContext (OPTION) of this remote session.
35 /// </summary>
36 /// <remarks>
37 /// Normally the AppContext is set once, after logging into the BMX, with a
38 /// single AppContext for the current applications. The AppContext can also be set in every RPC call. If the AppContext
39 /// is the same as the currently set AppContext, the AppContext will not be re-set.
40 /// </remarks>
41 /// <example>
42 /// The VEN namespace is for PCC+ and the example below would be used at the beginning
43 /// of a PCC+ application.
44 /// <code>
45 /// aRemoteSession.AppContext = "VEN RPC";
46 /// </code>
47 /// </example>
48 String AppContext { get; set; }
49
50 Encoding ConnectionEncoding { get; set; }
51
52 #endregion
53
54 #region Remote Procedure Call Services
55
56 /// <summary>
57 /// Calls a remote procedure on the RPMS server and returns the result as a String.
58 /// </summary>
59 /// <remarks>
60 /// Presumes that the AppContext was set prior to the call.
61 /// </remarks>
62 /// <example>
63 /// <code>
64 /// ...
65 /// this.RemoteSession.AppContext="VEN RPC";
66 /// ...
67 /// String asqThreadholds= this.RemoteSession.TransmitRPC("VEN ASQ GET DATA", this.Context.Patient.Ien);
68 /// </code>
69 /// </example>
70 /// <param name="rpcCommand">The remote procedure call name </param>
71 /// <param name="rpcParameter">A carrot ^ delimited string of input parameters</param>
72 /// <returns>The result of the RPC call</returns>
73 String TransmitRPC(String rpcCommand, String rpcParameter);
74
75 /// <summary>
76 /// Calls a remote procedure on the RPMS server and returns the result as a String.
77 /// </summary>
78 /// <remarks>
79 /// Use this for usage patterns where the AppContext is changed often and should be explicity set
80 /// for each call and not implicitly through a prior invocation of this.RemoteSession.AppContext
81 /// </remarks>
82 /// <example>
83 /// <code>
84 /// ...
85 /// this.RemoteSession.AppContext=;
86 /// ...
87 /// String asqThreadholds= this.RemoteSession.TransmitRPC("VEN ASQ GET DATA", this.Context.Patient.Ien,"VEN RPC");
88 // </code>
89 /// </example>
90 /// <param name="rpcCommand">The remote procedure call name </param>
91 /// <param name="rpcParameter">A carrot ^ delimited string of input parameters</param>
92 /// <param name="aContext">The AppContext (OPTION) to be set prior to the call(</param>
93 /// <returns>The result of the RPC call</returns>
94 String TransmitRPC(String rpcCommand, String rpcParameter, String aContext);
95
96
97 /// <summary>
98 /// Calls a remote procedure on the RPMS server and returns the result as a String. If there are any exceptions a
99 /// colon delimited string in the format Exception:Message is returned.
100 /// </summary>
101 /// <remarks>
102 /// Presumes that the AppContext was set prior to the call.
103 /// </remarks>
104 /// <example>
105 /// <code>
106 /// ...
107 /// this.RemoteSession.AppContext="VEN RPC";
108 /// ...
109 /// String asqThreadholds= this.RemoteSession.SafelyTransmitRPC("VEN ASQ GET DATA", this.Context.Patient.Ien);
110 /// </code>
111 /// </example>
112 /// <param name="rpcCommand">The remote procedure call name </param>
113 /// <param name="rpcParameter">A carrot ^ delimited string of input parameters</param>
114 /// <returns>The result of the RPC call. If there are any exceptions a colon delimited string in the format Exception:Message is returned.</returns>
115 String SafelyTransmitRPC(String rpcCommand, String rpcParameter);
116
117
118 /// <summary>
119 /// Calls a remote procedure on the RPMS server and returns the result as a String. If there are any exceptions a
120 /// colon delimited string in the format Exception:Message is returned.
121 /// </summary>
122 /// <remarks>
123 /// Presumes that the AppContext was set prior to the call.
124 /// </remarks>
125 /// <example>
126 /// <code>
127 /// ...
128 /// this.RemoteSession.AppContext="VEN RPC";
129 /// ...
130 /// String asqThreadholds= this.RemoteSession.SafelyTransmitRPC("VEN ASQ GET DATA", this.Context.Patient.Ien);
131 /// </code>
132 /// </example>
133 /// <param name="rpcCommand">The remote procedure call name </param>
134 /// <param name="rpcParameter">A carrot ^ delimited string of input parameters</param>
135 /// <param name="aContext">The AppContext (OPTION) to be set prior to the call(</param>
136 /// <returns>The result of the RPC call. If there are any exceptions a colon delimited string in the format Exception:Message is returned.</returns>
137 String SafelyTransmitRPC(String rpcCommand, String rpcParameter, String context);
138
139 #endregion
140 // ADO Services
141
142 #region ADO.NET Table Services
143
144 /// <summary>
145 ///
146 /// <example>
147 ///
148 /// <code>
149 ///
150 /// this.Context.Visit.Create();
151 /// if (this.Context.Visit.IsStub)
152 /// {
153 /// if (!this.Context.Visit.Create())
154 /// {
155 /// return false;
156 /// }
157 /// }
158 /// this.RemoteSession.SaveChanges(this.ScoreTable);
159 /// </code>
160 /// </example>
161 /// </summary>
162 /// <param name="aDataTable"></param>
163 /// <returns></returns>
164 bool SaveChanges(DataTable aDataTable);
165
166
167 /// <summary>
168 /// Calling a Custom Remote Procedure call (RPC) registered in VA FileMan’s REMOTE PROCEDURE file that results in a DataTable. You must design your remote procedure’s M routine to build its result its data in the specific format described later in this document.
169 /// </summary>
170 /// <param name="aCommand">The co /// </param>
171 /// <remarks>
172 /// Normally the AppContext is set once, after logging into the BMX, with a
173 /// single AppContext for the current applications or specified in every RPC call.
174 /// </remarks>
175 /// <example>
176 /// The VEN namespace is for PCC+ and the example below would be used at the beginning
177 /// of a PCC+ application.
178 /// <code>
179 /// aRemoteSession.AppContext = "VEN RPC";
180 /// </code>
181 /// The M code for a simple remote procedure call (BMX PATIENT DEMO) with two parameters to return a list of patients. See the following example. Note the inclusion of an error trap in the routine; BMXNet RPC routines must contain a functional error trap.
182 /// <code>
183 /// Figure 5 2 shows the M code for a simple remote procedure call (BMX PATIENT DEMO) with two parameters to return a list of patients. See the following example. Note the inclusion of an error trap in the routine; BMXNet RPC routines must contain a functional error trap.
184 /// PDEMO(BMXY,BMXPAT,BMXCOUNT) ;EP
185 /// ;This simple RPC demonstrates how to format data
186 /// ;for the BMXNet ADO.NET data provider
187 /// ;
188 /// ;Returns a maximum of BMXCOUNT records from the
189 /// ;VA PATIENT file whose names begin with BMXPAT
190 /// ;
191 /// N BMXI,BMXD,BMXC,BMXNODE,BMXDOB
192 /// ;
193 /// ; BMXY is passed in by reference. Set it to
194 /// ;the value of the variable in which we will return our data:
195 /// S BMXY="^TMP(BMX,"_$J_")"
196 /// ;
197 /// ;The first subnode of the data global contains the column header information
198 /// ;in the form "txxxxxCOLUMN1NAME^txxxxxCOLUMN2NAME"_$C(30)
199 /// ;where t is the column data type:
200 /// ; T for text
201 /// ; I for integer
202 /// ; N for floating point number
203 /// ; D for date/time.
204 /// ;xxxxx is the length of the column in characters.
205 /// ;
206 /// S BMXI=0,BMXC=0
207 /// S ^ TMP(BMX,$J,BMXI)="T00030NAME^T00010SEX^D00020DOB"_$C(30)
208 /// ;
209 /// ;You MUST set an error trap:
210 /// S X="PDERR^BMXRPC6",@^%ZOSF("TRAP")
211 /// ;
212 /// ;Strip CR, LF, TAB from BMXCOUNT parameter
213 /// S BMXCOUNT=$TR(BMXCOUNT,$C(13),"")
214 /// S BMXCOUNT=$TR(BMXCOUNT,$C(10),"")
215 /// S BMXCOUNT=$TR(BMXCOUNT,$C(9),"")
216 /// ;
217 /// ;Iterate through the global and set the data nodes:
218 /// S:BMXPAT="" BMXPAT="A"
219 /// S BMXPAT=$O(^DPT("B",BMXPAT),-1)
220 /// S BMXD=0
221 /// F S BMXPAT=$O(^DPT("B",BMXPAT)) Q:BMXPAT="" S BMXD=$O(^DPT("B",BMXPAT,0)) I +BMXD S BMXC=BMXC+1 Q:(BMXCOUNT)BMXC BMXCOUNT) D
222 /// . Q:'$D(^DPT(BMXD,0))
223 /// . S BMXI=BMXI+1
224 /// . S BMXNODE=^DPT(BMXD,0)
225 /// . ;Convert the DOB from FM date to external form
226 /// . S Y=$P(BMXNODE,U,3)
227 /// . I +Y X ^DD("DD")
228 /// . S BMXDOB=Y
229 /// . ;The data node fields are in the same order as the column header, i.e. NAME^SEX^DOB
230 /// . ;and terminated with a $C(30)
231 /// . S ^ TMP(BMX,$J,BMXI)=$P(BMXNODE,U)_U_$P(BMXNODE,U,2)_U_BMXDOB_$C(30)
232 /// ;
233 /// ;After all the data nodes have been set, set the final node to $C(31) to indicate
234 /// ;the end of the recordset
235 /// S BMXI=BMXI+1
236 /// S ^ TMP(BMX,$J,BMXI)=$C(31)
237 /// Q
238 /// ;
239 /// PDERR ;Error trap for PDEMO
240 /// ;
241 /// S ^ TMP(BMX,$J,BMXI+1)=$C(31)
242 /// Q
243 /// </code>
244 /// Register as an RPC
245 /// <para>
246 /// NAME: BMX DEMO TAG: PDEMO
247 /// ROUTINE: BMXRPC6 RETURN VALUE TYPE: GLOBAL ARRAY
248 /// </para>
249 /// Call using a RemoteSession
250 /// <code>
251 /// DataTable demoTable=aRemoteSession.TableFromCommand("BMX DEMO^S^10");
252 /// </code>
253 /// </example>
254 /// <param name="aCommand">The name of the RPC </param>
255 /// <returns>The resulting DataTable</returns>
256 DataTable TableFromCommand(String aCommand);
257
258
259 /// <summary>
260 /// Calling a Custom Remote Procedure call (RPC) registered in VA FileMan’s REMOTE PROCEDURE file that results in a DataTable. You must design your remote procedure’s M routine to build its result its data in the specific format described later in this document.
261 /// </summary>
262 /// <param name="aCommand">The co /// </param>
263 /// <remarks>
264 /// Normally the AppContext is set once, after logging into the BMX, with a
265 /// single AppContext for the current applications or specified in every RPC call.
266 /// </remarks>
267 /// <example>
268 /// The VEN namespace is for PCC+ and the example below would be used at the beginning
269 /// of a PCC+ application.
270 /// <code>
271 /// aRemoteSession.AppContext = "VEN RPC";
272 /// </code>
273 /// The M code for a simple remote procedure call (BMX PATIENT DEMO) with two parameters to return a list of patients. See the following example. Note the inclusion of an error trap in the routine; BMXNet RPC routines must contain a functional error trap.
274 /// <code>
275 /// Figure 5 2 shows the M code for a simple remote procedure call (BMX PATIENT DEMO) with two parameters to return a list of patients. See the following example. Note the inclusion of an error trap in the routine; BMXNet RPC routines must contain a functional error trap.
276 /// PDEMO(BMXY,BMXPAT,BMXCOUNT) ;EP
277 /// ;This simple RPC demonstrates how to format data
278 /// ;for the BMXNet ADO.NET data provider
279 /// ;
280 /// ;Returns a maximum of BMXCOUNT records from the
281 /// ;VA PATIENT file whose names begin with BMXPAT
282 /// ;
283 /// N BMXI,BMXD,BMXC,BMXNODE,BMXDOB
284 /// ;
285 /// ; BMXY is passed in by reference. Set it to
286 /// ;the value of the variable in which we will return our data:
287 /// S BMXY="^TMP(BMX,"_$J_")"
288 /// ;
289 /// ;The first subnode of the data global contains the column header information
290 /// ;in the form "txxxxxCOLUMN1NAME^txxxxxCOLUMN2NAME"_$C(30)
291 /// ;where t is the column data type:
292 /// ; T for text
293 /// ; I for integer
294 /// ; N for floating point number
295 /// ; D for date/time.
296 /// ;xxxxx is the length of the column in characters.
297 /// ;
298 /// S BMXI=0,BMXC=0
299 /// S ^ TMP(BMX,$J,BMXI)="T00030NAME^T00010SEX^D00020DOB"_$C(30)
300 /// ;
301 /// ;You MUST set an error trap:
302 /// S X="PDERR^BMXRPC6",@^%ZOSF("TRAP")
303 /// ;
304 /// ;Strip CR, LF, TAB from BMXCOUNT parameter
305 /// S BMXCOUNT=$TR(BMXCOUNT,$C(13),"")
306 /// S BMXCOUNT=$TR(BMXCOUNT,$C(10),"")
307 /// S BMXCOUNT=$TR(BMXCOUNT,$C(9),"")
308 /// ;
309 /// ;Iterate through the global and set the data nodes:
310 /// S:BMXPAT="" BMXPAT="A"
311 /// S BMXPAT=$O(^DPT("B",BMXPAT),-1)
312 /// S BMXD=0
313 /// F S BMXPAT=$O(^DPT("B",BMXPAT)) Q:BMXPAT="" S BMXD=$O(^DPT("B",BMXPAT,0)) I +BMXD S BMXC=BMXC+1 Q:(BMXCOUNT)BMXC BMXCOUNT) D
314 /// . Q:'$D(^DPT(BMXD,0))
315 /// . S BMXI=BMXI+1
316 /// . S BMXNODE=^DPT(BMXD,0)
317 /// . ;Convert the DOB from FM date to external form
318 /// . S Y=$P(BMXNODE,U,3)
319 /// . I +Y X ^DD("DD")
320 /// . S BMXDOB=Y
321 /// . ;The data node fields are in the same order as the column header, i.e. NAME^SEX^DOB
322 /// . ;and terminated with a $C(30)
323 /// . S ^ TMP(BMX,$J,BMXI)=$P(BMXNODE,U)_U_$P(BMXNODE,U,2)_U_BMXDOB_$C(30)
324 /// ;
325 /// ;After all the data nodes have been set, set the final node to $C(31) to indicate
326 /// ;the end of the recordset
327 /// S BMXI=BMXI+1
328 /// S ^ TMP(BMX,$J,BMXI)=$C(31)
329 /// Q
330 /// ;
331 /// PDERR ;Error trap for PDEMO
332 /// ;
333 /// S ^ TMP(BMX,$J,BMXI+1)=$C(31)
334 /// Q
335 /// </code>
336 /// Register as an RPC
337 /// <para>
338 /// NAME: BMX DEMO TAG: PDEMO
339 /// ROUTINE: BMXRPC6 RETURN VALUE TYPE: GLOBAL ARRAY
340 /// </para>
341 /// Call using a RemoteSession
342 /// <code>
343 /// DataTable demoTable=aRemoteSession.TableFromCommand("BMX DEMO^S^10");
344 /// </code>
345 /// </example>
346 /// <param name="aCommand">The name of the RPC </param>
347 /// <param name="aContext">The AppContext to set prior to the call</param>
348 /// <returns>The resulting DataTable</returns>
349 DataTable TableFromCommand(String aCommand, String aContext);
350
351
352 /// <summary>
353 /// Calling a Custom Remote Procedure call (RPC) registered in VA FileMan’s REMOTE PROCEDURE file that results in a DataTable. You must design your remote procedure’s M routine to build its result its data in the specific format described later in this document.
354 /// </summary>
355 /// <param name="aCommand">The co /// </param>
356 /// <remarks>
357 /// Normally the AppContext is set once, after logging into the BMX, with a
358 /// single AppContext for the current applications or specified in every RPC call.
359 /// </remarks>
360 /// <example>
361 /// The VEN namespace is for PCC+ and the example below would be used at the beginning
362 /// of a PCC+ application.
363 /// <code>
364 /// aRemoteSession.AppContext = "VEN RPC";
365 /// </code>
366 /// The M code for a simple remote procedure call (BMX PATIENT DEMO) with two parameters to return a list of patients. See the following example. Note the inclusion of an error trap in the routine; BMXNet RPC routines must contain a functional error trap.
367 /// <code>
368 /// Figure 5 2 shows the M code for a simple remote procedure call (BMX PATIENT DEMO) with two parameters to return a list of patients. See the following example. Note the inclusion of an error trap in the routine; BMXNet RPC routines must contain a functional error trap.
369 /// PDEMO(BMXY,BMXPAT,BMXCOUNT) ;EP
370 /// ;This simple RPC demonstrates how to format data
371 /// ;for the BMXNet ADO.NET data provider
372 /// ;
373 /// ;Returns a maximum of BMXCOUNT records from the
374 /// ;VA PATIENT file whose names begin with BMXPAT
375 /// ;
376 /// N BMXI,BMXD,BMXC,BMXNODE,BMXDOB
377 /// ;
378 /// ; BMXY is passed in by reference. Set it to
379 /// ;the value of the variable in which we will return our data:
380 /// S BMXY="^TMP(BMX,"_$J_")"
381 /// ;
382 /// ;The first subnode of the data global contains the column header information
383 /// ;in the form "txxxxxCOLUMN1NAME^txxxxxCOLUMN2NAME"_$C(30)
384 /// ;where t is the column data type:
385 /// ; T for text
386 /// ; I for integer
387 /// ; N for floating point number
388 /// ; D for date/time.
389 /// ;xxxxx is the length of the column in characters.
390 /// ;
391 /// S BMXI=0,BMXC=0
392 /// S ^ TMP(BMX,$J,BMXI)="T00030NAME^T00010SEX^D00020DOB"_$C(30)
393 /// ;
394 /// ;You MUST set an error trap:
395 /// S X="PDERR^BMXRPC6",@^%ZOSF("TRAP")
396 /// ;
397 /// ;Strip CR, LF, TAB from BMXCOUNT parameter
398 /// S BMXCOUNT=$TR(BMXCOUNT,$C(13),"")
399 /// S BMXCOUNT=$TR(BMXCOUNT,$C(10),"")
400 /// S BMXCOUNT=$TR(BMXCOUNT,$C(9),"")
401 /// ;
402 /// ;Iterate through the global and set the data nodes:
403 /// S:BMXPAT="" BMXPAT="A"
404 /// S BMXPAT=$O(^DPT("B",BMXPAT),-1)
405 /// S BMXD=0
406 /// F S BMXPAT=$O(^DPT("B",BMXPAT)) Q:BMXPAT="" S BMXD=$O(^DPT("B",BMXPAT,0)) I +BMXD S BMXC=BMXC+1 Q:(BMXCOUNT)BMXC BMXCOUNT) D
407 /// . Q:'$D(^DPT(BMXD,0))
408 /// . S BMXI=BMXI+1
409 /// . S BMXNODE=^DPT(BMXD,0)
410 /// . ;Convert the DOB from FM date to external form
411 /// . S Y=$P(BMXNODE,U,3)
412 /// . I +Y X ^DD("DD")
413 /// . S BMXDOB=Y
414 /// . ;The data node fields are in the same order as the column header, i.e. NAME^SEX^DOB
415 /// . ;and terminated with a $C(30)
416 /// . S ^ TMP(BMX,$J,BMXI)=$P(BMXNODE,U)_U_$P(BMXNODE,U,2)_U_BMXDOB_$C(30)
417 /// ;
418 /// ;After all the data nodes have been set, set the final node to $C(31) to indicate
419 /// ;the end of the recordset
420 /// S BMXI=BMXI+1
421 /// S ^ TMP(BMX,$J,BMXI)=$C(31)
422 /// Q
423 /// ;
424 /// PDERR ;Error trap for PDEMO
425 /// ;
426 /// S ^ TMP(BMX,$J,BMXI+1)=$C(31)
427 /// Q
428 /// </code>
429 /// Register as an RPC
430 /// <para>
431 /// NAME: BMX DEMO TAG: PDEMO
432 /// ROUTINE: BMXRPC6 RETURN VALUE TYPE: GLOBAL ARRAY
433 /// </para>
434 /// Call using a RemoteSession
435 /// <code>
436 /// DataTable demoTable=aRemoteSession.TableFromCommand("BMX DEMO^S^10");
437 /// </code>
438 /// </example>
439 /// <param name="aCommand">The name of the RPC </param>
440 /// <param name="aDataSet">The DataSet to be populated with a resulting DataTable named aTableNAme</param>
441 /// <param name="aTableName">The name of the DataTable in the DataSet to populate or to create</param>
442 /// <returns>The resulting DataTable</returns>
443 DataTable TableFromCommand(String aCommand, DataSet aDataSet, String aTableName);
444
445
446 /// <summary>
447 /// Calling a Custom Remote Procedure call (RPC) registered in VA FileMan’s REMOTE PROCEDURE file that results in a DataTable. You must design your remote procedure’s M routine to build its result its data in the specific format described later in this document.
448 /// </summary>
449 /// <param name="aCommand">The co /// </param>
450 /// <remarks>
451 /// Normally the AppContext is set once, after logging into the BMX, with a
452 /// single AppContext for the current applications or specified in every RPC call.
453 /// </remarks>
454 /// <example>
455 /// The VEN namespace is for PCC+ and the example below would be used at the beginning
456 /// of a PCC+ application.
457 /// <code>
458 /// aRemoteSession.AppContext = "VEN RPC";
459 /// </code>
460 /// The M code for a simple remote procedure call (BMX PATIENT DEMO) with two parameters to return a list of patients. See the following example. Note the inclusion of an error trap in the routine; BMXNet RPC routines must contain a functional error trap.
461 /// <code>
462 /// Figure 5 2 shows the M code for a simple remote procedure call (BMX PATIENT DEMO) with two parameters to return a list of patients. See the following example. Note the inclusion of an error trap in the routine; BMXNet RPC routines must contain a functional error trap.
463 /// PDEMO(BMXY,BMXPAT,BMXCOUNT) ;EP
464 /// ;This simple RPC demonstrates how to format data
465 /// ;for the BMXNet ADO.NET data provider
466 /// ;
467 /// ;Returns a maximum of BMXCOUNT records from the
468 /// ;VA PATIENT file whose names begin with BMXPAT
469 /// ;
470 /// N BMXI,BMXD,BMXC,BMXNODE,BMXDOB
471 /// ;
472 /// ; BMXY is passed in by reference. Set it to
473 /// ;the value of the variable in which we will return our data:
474 /// S BMXY="^TMP(BMX,"_$J_")"
475 /// ;
476 /// ;The first subnode of the data global contains the column header information
477 /// ;in the form "txxxxxCOLUMN1NAME^txxxxxCOLUMN2NAME"_$C(30)
478 /// ;where t is the column data type:
479 /// ; T for text
480 /// ; I for integer
481 /// ; N for floating point number
482 /// ; D for date/time.
483 /// ;xxxxx is the length of the column in characters.
484 /// ;
485 /// S BMXI=0,BMXC=0
486 /// S ^ TMP(BMX,$J,BMXI)="T00030NAME^T00010SEX^D00020DOB"_$C(30)
487 /// ;
488 /// ;You MUST set an error trap:
489 /// S X="PDERR^BMXRPC6",@^%ZOSF("TRAP")
490 /// ;
491 /// ;Strip CR, LF, TAB from BMXCOUNT parameter
492 /// S BMXCOUNT=$TR(BMXCOUNT,$C(13),"")
493 /// S BMXCOUNT=$TR(BMXCOUNT,$C(10),"")
494 /// S BMXCOUNT=$TR(BMXCOUNT,$C(9),"")
495 /// ;
496 /// ;Iterate through the global and set the data nodes:
497 /// S:BMXPAT="" BMXPAT="A"
498 /// S BMXPAT=$O(^DPT("B",BMXPAT),-1)
499 /// S BMXD=0
500 /// F S BMXPAT=$O(^DPT("B",BMXPAT)) Q:BMXPAT="" S BMXD=$O(^DPT("B",BMXPAT,0)) I +BMXD S BMXC=BMXC+1 Q:(BMXCOUNT)BMXC BMXCOUNT) D
501 /// . Q:'$D(^DPT(BMXD,0))
502 /// . S BMXI=BMXI+1
503 /// . S BMXNODE=^DPT(BMXD,0)
504 /// . ;Convert the DOB from FM date to external form
505 /// . S Y=$P(BMXNODE,U,3)
506 /// . I +Y X ^DD("DD")
507 /// . S BMXDOB=Y
508 /// . ;The data node fields are in the same order as the column header, i.e. NAME^SEX^DOB
509 /// . ;and terminated with a $C(30)
510 /// . S ^ TMP(BMX,$J,BMXI)=$P(BMXNODE,U)_U_$P(BMXNODE,U,2)_U_BMXDOB_$C(30)
511 /// ;
512 /// ;After all the data nodes have been set, set the final node to $C(31) to indicate
513 /// ;the end of the recordset
514 /// S BMXI=BMXI+1
515 /// S ^ TMP(BMX,$J,BMXI)=$C(31)
516 /// Q
517 /// ;
518 /// PDERR ;Error trap for PDEMO
519 /// ;
520 /// S ^ TMP(BMX,$J,BMXI+1)=$C(31)
521 /// Q
522 /// </code>
523 /// Register as an RPC
524 /// <para>
525 /// NAME: BMX DEMO TAG: PDEMO
526 /// ROUTINE: BMXRPC6 RETURN VALUE TYPE: GLOBAL ARRAY
527 /// </para>
528 /// Call using a RemoteSession
529 /// <code>
530 /// DataTable demoTable=aRemoteSession.TableFromCommand("BMX DEMO^S^10");
531 /// </code>
532 /// </example>
533 /// <param name="aCommand">The name of the RPC </param>
534 /// <param name="aDataSet">The DataSet to be populated with a resulting DataTable named aTableNAme</param>
535 /// <param name="aTableName">The name of the DataTable in the DataSet to populate or to create</param>
536 /// <param name="aContext">The AppContext to set prior to the call</param>
537 /// <returns>The resulting DataTable</returns>
538 DataTable TableFromCommand(String aCommand, DataSet aDataSet, String aTableName, String aContext);
539
540
541
542 DataTable TableFromSQL(String anSqlStatement);
543 DataTable TableFromSQL(String anSqlStatement, String aContext);
544 DataTable TableFromSQL(String anSqlStatement, DataSet aDataSet, String aTableName);
545
546 /// <summary>
547 /// SELECT VA_PATIENT.NAME, VA_PATIENT.SSN, PATIENT.CURRENT_COMMUNITY FROM VA_PATIENT, PATIENT WHERE VA_PATIENT.BMXIEN =* INTERNAL[PATIENT.NAME] AND VA_PATIENT.NAME LIKE 'DEMO%' AND VA_PATIENT.AGE BETWEEN 15 AND 24 SHOWPLAN
548 /// </summary>
549 /// <param name="anSqlStatement"></param>
550 /// <param name="aDataSet"></param>
551 /// <param name="aTableName"></param>
552 /// <param name="aContext"></param>
553 /// <returns></returns>
554 DataTable TableFromSQL(String anSqlStatement, DataSet aDataSet, String aTableName, String aContext);
555
556 /// <summary>
557 /// TabletFromRpc is a double-dispatch method that is used by some developers. Developers create an RPC
558 /// call the returns a properly format BMX command (custom or BMX SS ADO) that is then transmitted back to RPMS to retrieve the Data Table.
559 /// </summary>
560 /// <param name="rpcCommand">The remote procedure call name </param>
561 /// <param name="rpcParameter">A carrot ^ delimited string of input parameters</param>
562 /// <returns>The resulting DataTable</returns>
563 DataTable TableFromRPC(String rpcCommand, String rpcParameter);
564
565 /// <summary>
566 /// TabletFromRpc is a double-dispatch method that is used by some developers. Developers create an RPC
567 /// call the returns a properly format BMX command (custom or BMX SS ADO) that is then transmitted back to RPMS to retrieve the Data Table.
568 /// </summary>
569 /// <param name="rpcCommand">The remote procedure call name </param>
570 /// <param name="rpcParameter">A carrot ^ delimited string of input parameters</param>
571 /// <param name="aContext">The AppContext to set prior to the call</param>
572 /// <returns>The resulting DataTable</returns>
573 DataTable TableFromRPC(String rpcCommand, String rpcParameter, String aContext);
574
575 /// <summary>
576 /// TabletFromRpc is a double-dispatch method that is used by some developers. Developers create an RPC
577 /// call the returns a properly format BMX command (custom or BMX SS ADO) that is then transmitted back to RPMS to retrieve the Data Table.
578 /// </summary>
579 /// <param name="rpcCommand">The remote procedure call name </param>
580 /// <param name="rpcParameter">A carrot ^ delimited string of input parameters</param>
581 /// <param name="aDataSet">The DataSet to be populated with a resulting DataTable named aTableNAme</param>
582 /// <param name="aTableName">The name of the DataTable in the DataSet to populate or to create</param>
583 /// <returns>The resulting DataTable</returns>
584 DataTable TableFromRPC(String rpcCommand, String rpcParameter, DataSet aDataSet, String aTableName);
585
586 /// <summary>
587 /// TabletFromRpc is a double-dispatch method that is used by some developers. Developers create an RPC
588 /// call the returns a properly format BMX command (custom or BMX SS ADO) that is then transmitted back to RPMS to retrieve the Data Table.
589 /// </summary>
590 /// <param name="rpcCommand">The remote procedure call name </param>
591 /// <param name="rpcParameter">A carrot ^ delimited string of input parameters</param>
592 /// <param name="aDataSet">The DataSet to be populated with a resulting DataTable named aTableNAme</param>
593 /// <param name="aTableName">The name of the DataTable in the DataSet to populate or to create</param>
594 /// <param name="aContext">The AppContext to set prior to the call</param>
595 /// <returns>The resulting DataTable</returns>
596 DataTable TableFromRPC(String rpcCommand, String rpcParameter, DataSet aDataSet, String aTableName, String context);
597
598
599 /// <summary>
600 /// Same as the corresponding TableFromCommand call except a DataTableFuture is returned. See <see cref="DataTableFuture "/> on how to use a 'Future
601 /// </summary>
602 /// <param name="aCommand">The name of the RPC </param>
603 /// <returns>A DataTableFuture</returns>
604 DataTableFuture AsyncTableFromCommand(String aCommand);
605
606 /// <summary>
607 /// Same as the corresponding TableFromCommand call except a DataTableFuture is returned. See <see cref="DataTableFuture "/> on how to use a 'Future
608 /// </summary>
609 /// <param name="aCommand">The name of the RPC </param>
610 /// <param name="aContext">The AppContext to set prior to the call</param>
611 /// <returns>A DataTableFuture</returns>
612 DataTableFuture AsyncTableFromCommand(String aCommand, String aContext);
613
614 /// <summary>
615 /// Same as the corresponding TableFromCommand call except a DataTableFuture is returned. See <see cref="DataTableFuture "/> on how to use a 'Future
616 /// </summary>
617 /// <param name="aCommand">The name of the RPC </param>
618 /// <param name="aDataSet">The DataSet to be populated with a resulting DataTable named aTableNAme</param>
619 /// <param name="aTableName">The name of the DataTable in the DataSet to populate or to create</param>
620 /// <returns>A DataTableFuture</returns>
621 DataTableFuture AsyncTableFromCommand(String aCommand, DataSet aDataSet, String aTableName);
622
623 /// <summary>
624 /// Same as the corresponding TableFromCommand call except a DataTableFuture is returned. See <see cref="DataTableFuture "/> on how to use a 'Future
625 /// </summary>
626 /// <param name="aCommand">The name of the RPC </param>
627 /// <param name="aDataSet">The DataSet to be populated with a resulting DataTable named aTableNAme</param>
628 /// <param name="aTableName">The name of the DataTable in the DataSet to populate or to create</param>
629 /// <param name="aContext">The AppContext to set prior to the call</param>
630 /// <returns>A DataTableFuture</returns>
631 DataTableFuture AsyncTableFromCommand(String aCommand, DataSet aDataSet, String aTableName, String aContext);
632
633 DataTableFuture AsyncTableFromSQL(String sql);
634 DataTableFuture AsyncTableFromSQL(String sql, String aContext);
635 DataTableFuture AsyncTableFromSQL(String sql, DataSet aDataSet, String aTableName);
636 DataTableFuture AsyncTableFromSQL(String sql, DataSet aDataSet, String aTableName, String aContext);
637
638 /// <summary>
639 /// Same as the corresponding TableFromRPC call except a DataTableFuture is returned. See <see cref="DataTableFuture "/> on how to use a 'Future
640 /// </summary>
641 /// <param name="rpcCommand">The remote procedure call name </param>
642 /// <param name="rpcParameter">A carrot ^ delimited string of input parameters</param>
643 /// <returns>A DataTableFuture</returns>
644 DataTableFuture AsyncTableFromRPC(String rpcCommand, String rpcParameter);
645
646 /// <summary>
647 /// Same as the corresponding TableFromRPC call except a DataTableFuture is returned. See <see cref="DataTableFuture "/> on how to use a 'Future
648 /// </summary>
649 /// <param name="rpcCommand"></param>
650 /// <param name="rpcParameter"></param>
651 /// <param name="aContext"></param>
652 /// <returns>A DataTableFuture</returns>
653 DataTableFuture AsyncTableFromRPC(String rpcCommand, String rpcParameter, String context);
654
655 /// <summary>
656 /// Same as the corresponding TableFromRPC call except a DataTableFuture is returned. See <see cref="DataTableFuture "/> on how to use a 'Future
657 /// </summary>
658 /// <param name="rpcCommand">The remote procedure call name </param>
659 /// <param name="rpcParameter">A carrot ^ delimited string of input parameters</param>
660 /// <param name="aDataSet">The DataSet to be populated with a resulting DataTable named aTableNAme</param>
661 /// <param name="aTableName">The name of the DataTable in the DataSet to populate or to create</param>
662 /// <returns>A DataTableFuture</returns>
663 DataTableFuture AsyncTableFromRPC(String rpcCommand, String rpcParameter, DataSet aDataSet, String aTableName);
664
665 /// <summary>
666 /// Same as the corresponding TableFromRPC call except a DataTableFuture is returned. See <see cref="DataTableFuture "/> on how to use a 'Future
667 /// </summary>
668 /// <param name="rpcCommand">The remote procedure call name </param>
669 /// <param name="rpcParameter">A carrot ^ delimited string of input parameters</param>
670 /// <param name="aDataSet">The DataSet to be populated with a resulting DataTable named aTableNAme</param>
671 /// <param name="aTableName">The name of the DataTable in the DataSet to populate or to create</param>
672 /// <param name="aContext">The AppContext to set prior to the call</param>
673 /// <returns>A DataTableFuture</returns>
674 DataTableFuture AsyncTableFromRPC(String rpcCommand, String rpcParameter, DataSet aDataSet, String aTableName, String aContext);
675
676 /// <summary>
677 /// Answer True if aString is a standard BMX ADO SS command that uses the BMX ADO SCHEMA files
678 /// </summary>
679 /// <remarks>
680 /// This is mostly used by the framework but exposed for potential use.
681 /// </remarks>
682 /// <param name="aString">The command to be examined</param>
683 /// <returns>True if it complied, otherwise false</returns>
684 bool IsBmxAdoCommand(String aString);
685
686 /// <summary>
687 /// Locks a Name on the Mumps Database
688 /// </summary>
689 /// <param name="g/lvnToLock">Global or Local Name to Lock</param>
690 /// <param name="addOrSubstract">+ or - to increment or decrement the lock</param>
691 /// <returns>true for success; false for failure</returns>
692 bool Lock(string lvnToLock, string addOrSubstract);
693
694 #endregion
695
696
697 #region Event Services
698
699 /// <summary>
700 /// Access the session's RemoteEventServices service provider to configure receiving
701 /// remote events and to source new events.
702 /// </summary>
703 RemoteEventService EventServices { get; }
704
705 #endregion
706
707
708 #region Debugging
709 /// <summary>
710 /// Job number of server-side Cache/MDB process. Very useful for debugging.
711 /// </summary>
712 String Job { get; }
713
714 /// <summary>
715 /// String describing RPC call and input parameters of last non-DataTable RPC call
716 /// </summary>
717 String DebugLastRpcSignature { get; }
718
719 /// <summary>
720 /// String value of last successful non-DataTable RPC call
721 /// </summary>
722 String RpcResult { get; }
723
724 /// <summary>
725 /// String value of last successful non-DataTable RPC call
726 /// </summary>
727 String DebugLastRpcResult { get; }
728
729 /// <summary>
730 /// Last DataTable retrieved by non-async calls
731 /// </summary>
732 DataTable DebugLastTableResult { get; }
733
734 Log Log { get; }
735
736 #endregion
737
738 #region Lifecycle
739
740 /// <summary>
741 /// The networking data receive timeout (in milliseconds). This value can be changed if the developer finds it neccessary
742 /// to extend the time after login.
743 /// </summary>
744 /// <remarks>
745 /// Only applicable for the WinFramework
746 /// </remarks>
747 int ReceiveTimeout { get; set; }
748
749 /// <summary>
750 /// The networking data send timeout (in milliseconds). This value can be changed if the developer finds it neccessary
751 /// to extend the time after login but normally the send timeout should be kept short unless network conditions are poor.
752 /// </summary>
753 /// <remarks>
754 /// Only applicable for the WinFramework
755 /// </remarks>
756 int SendTimeout { get; set; }
757
758 /// <summary>
759 /// The primary session has the unique in that it holds the authenication privileges for all sessions. If you close the primary session, then all will close.
760 /// </summary>
761 bool IsPrimary { get; }
762
763 /// <summary>
764 /// When done with session it should be closed. Once closed it is unusable.
765 /// </summary>
766 /// <remarks>Internally the session is a lightweight object and when using multiple sessions internal RPMS connections are pooled . Close sessions when finished</remarks>
767 /// <remarks>Closing the primary session closes all sessions and shuts down the RPMS connection</remarks>
768 void Close();
769 #endregion
770 }
771
772}
Note: See TracBrowser for help on using the repository browser.