[843] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Linq;
|
---|
| 4 | using System.Data;
|
---|
| 5 | using System.Text;
|
---|
| 6 | using System.Diagnostics;
|
---|
| 7 | using IndianHealthService.BMXNet;
|
---|
| 8 |
|
---|
| 9 | namespace IndianHealthService.ClinicalScheduling
|
---|
| 10 | {
|
---|
| 11 | /// <summary>
|
---|
| 12 | /// Data Access Layer
|
---|
| 13 | /// </summary>
|
---|
| 14 | public class DAL
|
---|
| 15 | {
|
---|
| 16 | private BMXNetConnectInfo _thisConnection; // set in constructor
|
---|
| 17 | delegate DataTable RPMSDataTableDelegate(string CommandString, string TableName); // for use in calling (Sync and Async)
|
---|
| 18 |
|
---|
| 19 | /// <summary>
|
---|
| 20 | /// Constructor
|
---|
| 21 | /// </summary>
|
---|
| 22 | /// <param name="conn">The current connection to use</param>
|
---|
| 23 | public DAL(BMXNetConnectInfo conn)
|
---|
| 24 | {
|
---|
| 25 | this._thisConnection = conn;
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | public DataTable GetVersion(string nmsp)
|
---|
| 29 | {
|
---|
| 30 | string cmd = String.Format("BMX VERSION INFO^{0}", nmsp);
|
---|
| 31 | return RPMSDataTable(cmd, "");
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | public DataTable GetUserInfo(string DUZ)
|
---|
| 35 | {
|
---|
| 36 | string cmd = String.Format("BSDX SCHEDULING USER INFO^{0}", DUZ);
|
---|
| 37 | return RPMSDataTable(cmd, "");
|
---|
| 38 | }
|
---|
| 39 |
|
---|
| 40 | public DataTable GetAccessTypes()
|
---|
| 41 | {
|
---|
| 42 | string sCommandText = "SELECT * FROM BSDX_ACCESS_TYPE";
|
---|
| 43 | DataTable table = RPMSDataTable(sCommandText, "");
|
---|
| 44 | DataColumn dcKey = table.Columns["BMXIEN"];
|
---|
| 45 | DataColumn[] dcKeys = new DataColumn[1];
|
---|
| 46 | dcKeys[0] = dcKey;
|
---|
| 47 | table.PrimaryKey = dcKeys;
|
---|
| 48 | return table;
|
---|
| 49 | }
|
---|
| 50 |
|
---|
| 51 |
|
---|
| 52 |
|
---|
| 53 | /// <summary>
|
---|
| 54 | /// Workhorse
|
---|
| 55 | /// </summary>
|
---|
| 56 | /// <param name="sSQL"></param>
|
---|
| 57 | /// <param name="sTableName"></param>
|
---|
| 58 | /// <param name="ds"></param>
|
---|
| 59 | /// <returns></returns>
|
---|
| 60 | private DataTable RPMSDataTable(string sSQL, string sTableName)
|
---|
| 61 | {
|
---|
| 62 | //Retrieves a recordset from RPMS
|
---|
| 63 | string sErrorMessage = "";
|
---|
| 64 | DataTable dtOut;
|
---|
| 65 |
|
---|
| 66 | #if TRACE
|
---|
| 67 | DateTime sendTime = DateTime.Now;
|
---|
| 68 | #endif
|
---|
| 69 | try
|
---|
| 70 | {
|
---|
| 71 | RPMSDataTableDelegate rdtd = new RPMSDataTableDelegate(_thisConnection.RPMSDataTable);
|
---|
| 72 | dtOut = (DataTable)rdtd.Invoke(sSQL, sTableName);
|
---|
| 73 | }
|
---|
| 74 |
|
---|
| 75 | catch (Exception ex)
|
---|
| 76 | {
|
---|
| 77 | sErrorMessage = "CGDocumentManager.RPMSDataTable error: " + ex.Message;
|
---|
| 78 | throw ex;
|
---|
| 79 | }
|
---|
| 80 |
|
---|
| 81 | #if TRACE
|
---|
| 82 | DateTime receiveTime = DateTime.Now;
|
---|
| 83 | TimeSpan executionTime = receiveTime - sendTime;
|
---|
| 84 | Debug.Write("RPMSDataTable Execution Time: " + executionTime.Milliseconds + " ms.\n");
|
---|
| 85 | #endif
|
---|
| 86 |
|
---|
| 87 | return dtOut;
|
---|
| 88 |
|
---|
| 89 | }
|
---|
| 90 |
|
---|
| 91 |
|
---|
| 92 | }
|
---|
| 93 | }
|
---|
| 94 |
|
---|
| 95 |
|
---|