source: BMXNET_RPMS_dotNET_UTILITIES-BMX/trunk/cs/bmxTesterForVista_0200.cs@ 818

Last change on this file since 818 was 645, checked in by Sam Habiel, 15 years ago

Initial Import of BMX.net code

File size: 4.3 KB
Line 
1using System;
2using IndianHealthService.BMXNet;
3
4namespace SamsStuff.IHS.BMX
5{
6 class MyFirstApp
7 {
8 static void Main()
9 {
10 BMXNetLib ConnectionManager = new BMXNetLib();
11 Console.Write("Enter IP Address of Server: ");
12 string ip = Console.ReadLine();
13 Console.Write("Enter the listener port: ");
14 string port = Console.ReadLine();
15 int portno = int.Parse(port);
16 Console.Write("Enter your Access Code: ");
17 string accessCode = Console.ReadLine();
18 Console.Write("Enter your Verify Code: ");
19 string verifyCode = Console.ReadLine();
20 ConnectionManager.MServerPort = portno;
21 bool success = ConnectionManager.OpenConnection(ip, accessCode, verifyCode);
22 Console.WriteLine("Connected: " + success.ToString() + " DUZ: " + ConnectionManager.DUZ);
23 ConnectionManager.AppContext = "BMXRPC";
24 string result = ConnectionManager.TransmitRPC("BMX USER", ConnectionManager.DUZ);
25 Console.WriteLine("Simple RPC: User Name: " + result);
26 ConnectionManager.AppContext = "OR CPRS GUI CHART";
27 result = ConnectionManager.TransmitRPC("ORWU NEWPERS","A^1");
28 Console.WriteLine("CPRS RPC with Parameters: ");
29 Console.WriteLine(result);
30 Console.WriteLine();
31 Console.WriteLine("SQL Statement");
32 string cmd = "SELECT NAME,SEX,DATE_OF_BIRTH FROM PATIENT";
33 RPMSDb dbTables = new RPMSDb(ConnectionManager);
34 RPMSDb.RPMSDbResultSet rs = new RPMSDb.RPMSDbResultSet();
35 dbTables.Execute(cmd, out rs);
36 for (int i = 0; i < rs.data.GetLength(0); i++ )
37 for (int j = 0; j < rs.data.GetLength(1); j++)
38 {
39 Console.WriteLine(rs.data[i, j].ToString());
40 }
41 Console.WriteLine();
42 Console.WriteLine("BMX Schema RPC");
43 ConnectionManager.AppContext = "BMXRPC";
44 BMXNetConnection conn = new BMXNetConnection(ConnectionManager);
45 BMXNetCommand cmd2 = (BMXNetCommand) conn.CreateCommand();
46 cmd2.CommandText = "BMX DEMO^S^10";
47 BMXNetDataAdapter da = new BMXNetDataAdapter();
48 da.SelectCommand = cmd2;
49 System.Data.DataSet ds = new System.Data.DataSet();
50 da.Fill(ds,"BMXNetTable1");
51 System.Data.DataTable dt = new System.Data.DataTable();
52 dt = ds.Tables["BMXNetTable1"];
53 System.Text.StringBuilder sb = new System.Text.StringBuilder();
54 for (int i = 0; i < dt.Rows.Count; i++)
55 {
56 for (int j = 0; j < dt.Columns.Count; j++)
57 {
58 sb.Append(dt.Rows[i][j]);
59 sb.Append("\t");
60 }
61 sb.Append("\n");
62 }
63 Console.WriteLine();
64 Console.Write(sb);
65 Console.WriteLine();
66 Console.WriteLine("More complicated SQL\n");
67 BMXNetCommand cmd3 = (BMXNetCommand)conn.CreateCommand();
68 cmd3.CommandText = @"SELECT PATIENT.NAME 'NAME', PATIENT.STATE 'STATE',
69 STATE.ABBREVIATION 'ABBR', PATIENT.AGE 'AGE' FROM PATIENT, STATE
70 WHERE INTERNAL[PATIENT.STATE] = STATE.BMXIEN MAXRECORDS:5";
71 da.SelectCommand = cmd3;
72 da.Fill(ds, "BMXNetTable2");
73 System.Data.DataTable dt2 = new System.Data.DataTable();
74 dt2 = ds.Tables["BMXNetTable2"];
75 System.Text.StringBuilder sb2 = new System.Text.StringBuilder();
76 for (int i = 0; i < dt2.Columns.Count; i++)
77 {
78 sb2.Append(dt2.Columns[i].ColumnName);
79 sb2.Append("\t");
80 }
81 sb2.Append("\n");
82 for (int i = 0; i < dt2.Rows.Count; i++)
83 {
84 for (int j = 0; j < dt2.Columns.Count; j++)
85 {
86 sb2.Append(dt2.Rows[i][j]);
87 sb2.Append("\t");
88 }
89 sb2.Append("\n");
90 }
91 Console.Write(sb2);
92 Console.ReadKey();
93 ConnectionManager.CloseConnection();
94 }
95 }
96}
Note: See TracBrowser for help on using the repository browser.