source: Scheduling/trunk/cs/bsdx0200GUISourceCode/DAL.cs@ 1039

Last change on this file since 1039 was 1039, checked in by Sam Habiel, 13 years ago

Release build for Scheduling v 1.42 for .net 3.5.

File size: 7.2 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Data;
5using System.Text;
6using System.Diagnostics;
7using IndianHealthService.BMXNet;
8
9namespace IndianHealthService.ClinicalScheduling
10{
11 /// <summary>
12 /// Data Access Layer
13 /// </summary>
14 public class DAL
15 {
16 private BMXNetConnectInfo _thisConnection; // set in constructor
17
18 delegate DataTable RPMSDataTableDelegate(string CommandString, string TableName); // for use in calling (Sync and Async)
19
20 /// <summary>
21 /// Constructor
22 /// </summary>
23 /// <param name="conn">The current connection to use</param>
24 public DAL(BMXNetConnectInfo conn)
25 {
26 this._thisConnection = conn;
27 }
28
29 public DataTable GetVersion(string nmsp)
30 {
31 string cmd = String.Format("BMX VERSION INFO^{0}", nmsp);
32 return RPMSDataTable(cmd, "");
33 }
34
35 public DataTable GetUserInfo(string DUZ)
36 {
37 string cmd = String.Format("BSDX SCHEDULING USER INFO^{0}", DUZ);
38 return RPMSDataTable(cmd, "");
39 }
40
41 public DataTable GetAccessTypes()
42 {
43 string sCommandText = "SELECT * FROM BSDX_ACCESS_TYPE";
44 DataTable table = RPMSDataTable(sCommandText, "");
45 DataColumn dcKey = table.Columns["BMXIEN"];
46 DataColumn[] dcKeys = new DataColumn[1];
47 dcKeys[0] = dcKey;
48 table.PrimaryKey = dcKeys;
49 return table;
50 }
51
52 /// <summary>
53 /// Get the Patients who have appointments in between dates for the clinics requested
54 /// </summary>
55 /// <param name="sClinicList">| delimited resource list (resource IENS, not names)</param>
56 /// <param name="BeginDate">Self Explanatory</param>
57 /// <param name="EndDate">Self Explanatory</param>
58 /// <returns>DataTable with the following columns:
59 /// T00030Name^D00020DOB^T00030Sex^T00030HRN^D00030ApptDate^T00030Clinic^T00030TypeStatus
60 /// I00010RESOURCEID^T00030APPT_MADE_BY^D00020DATE_APPT_MADE^T00250NOTE^T00030STREET^
61 /// T00030CITY^T00030STATE^T00030ZIP^T00030HOMEPHONE
62 ///</returns>
63 ///<remarks>Mirrors dsPatientApptDisplay2.PatientAppts Schema in this project. Can merge table into schema.</remarks>
64 public DataTable GetClinicSchedules(string sClinicList, DateTime BeginDate, DateTime EndDate)
65 {
66 string sBegin = FMDateTime.Create(BeginDate).DateOnly.FMDateString;
67 string sEnd = FMDateTime.Create(EndDate).DateOnly.FMDateString;
68 string cmd = String.Format("BSDX CLINIC LETTERS^{0}^{1}^{2}", sClinicList, sBegin, sEnd);
69 return RPMSDataTable(cmd, "");
70 }
71
72 /// <summary>
73 /// Get the letter templates associated with the requested clinics (reminder letter, cancellation letter etc)
74 /// </summary>
75 /// <param name="sClinicList">| delimited resource list (resource IENS, not names)</param>
76 /// <returns>DataTable with the following columns:
77 /// I00010RESOURCEID^T00030RESOURCE_NAME^T00030LETTER_TEXT^T00030NO_SHOW_LETTER^T00030CLINIC_CANCELLATION_LETTER
78 /// </returns>
79 /// <remarks>Mirrors dsPatientApptDisplay2.BSDXResource Schema. Can merge table into schema.</remarks>
80 public DataTable GetResourceLetters(string sClinicList)
81 {
82 string cmd = String.Format("BSDX RESOURCE LETTERS^{0}", sClinicList);
83 return RPMSDataTable(cmd, "");
84 }
85
86 /// <summary>
87 /// Get the list of Patients who have Rebooked Appointments
88 /// </summary>
89 /// <param name="sClinicList">| delimited resource list (resource IENS, not names)</param>
90 /// <param name="BeginDate">Self Explanatory</param>
91 /// <param name="EndDate">Self Explanatory</param>
92 /// <returns>T00030Name^D00020DOB^T00030Sex^T00030HRN^D00030NewApptDate^T00030Clinic^T00030TypeStatus
93 /// ^I00010RESOURCEID^T00030APPT_MADE_BY^D00020DATE_APPT_MADE^T00250NOTE^T00030STREET^T00030CITY
94 /// ^T00030STATE^T00030ZIP^T00030HOMEPHONE^D00030OldApptDate
95 ///</returns>
96 /// <remarks>Mirrors dsRebookAppts.PatientAppt Schema. Can merge table into schema.</remarks>
97 public DataTable GetRebookedAppointments(string sClinicList, DateTime BeginDate, DateTime EndDate)
98 {
99 string sBegin = FMDateTime.Create(BeginDate).DateOnly.FMDateString;
100 string sEnd = FMDateTime.Create(EndDate).DateOnly.FMDateString;
101 string cmd = String.Format("BSDX REBOOK CLINIC LIST^{0}^{1}^{2}", sClinicList, sBegin, sEnd);
102 return RPMSDataTable(cmd, "");
103 }
104
105 public DataTable GetRebookedAppointments(string sApptList)
106 {
107 string cmd = String.Format("BSDX REBOOK LIST^{0}", sApptList);
108 return RPMSDataTable(cmd, "");
109 }
110
111 public DataTable GetCancelledAppointments(string sClinicList, DateTime BeginDate, DateTime EndDate)
112 {
113 string sBegin = FMDateTime.Create(BeginDate).DateOnly.FMDateString;
114 string sEnd = FMDateTime.Create(EndDate).DateOnly.FMDateString;
115 string cmd = String.Format("BSDX CANCEL CLINIC LIST^{0}^{1}^{2}", sClinicList, sBegin, sEnd);
116 return RPMSDataTable(cmd, "");
117 }
118
119 /// <summary>
120 /// Delete All Slots for a Resource
121 /// </summary>
122 /// <param name="sResourceID"></param>
123 /// <param name="BeginDate"></param>
124 /// <param name="EndDate"></param>
125 /// <returns></returns>
126 public DataTable MassSlotDelete(string sResourceID, DateTime BeginDate, DateTime EndDate)
127 {
128 string sBegin = FMDateTime.Create(BeginDate).DateOnly.FMDateString;
129 string sEnd = FMDateTime.Create(EndDate).DateOnly.FMDateString;
130 string cmd = String.Format("BSDX CANCEL AV BY DATE^{0}^{1}^{2}", sResourceID, sBegin, sEnd);
131 return RPMSDataTable(cmd, "Cancelled");
132 }
133
134 /// <summary>
135 /// Workhorse
136 /// </summary>
137 /// <param name="sSQL"></param>
138 /// <param name="sTableName"></param>
139 /// <returns></returns>
140 private DataTable RPMSDataTable(string sSQL, string sTableName)
141 {
142 //Retrieves a recordset from RPMS
143 string sErrorMessage = "";
144 DataTable dtOut;
145
146#if TRACE
147 DateTime sendTime = DateTime.Now;
148#endif
149 try
150 {
151 RPMSDataTableDelegate rdtd = new RPMSDataTableDelegate(_thisConnection.RPMSDataTable);
152 dtOut = (DataTable)rdtd.Invoke(sSQL, sTableName);
153 }
154
155 catch (Exception ex)
156 {
157 sErrorMessage = "DAL.RPMSDataTable error: " + ex.Message;
158 throw ex;
159 }
160
161#if TRACE
162 DateTime receiveTime = DateTime.Now;
163 TimeSpan executionTime = receiveTime - sendTime;
164 Debug.Write("RPMSDataTable Execution Time: " + executionTime.Milliseconds + " ms.\n");
165#endif
166
167 return dtOut;
168
169 }
170
171
172 }
173}
174
175
Note: See TracBrowser for help on using the repository browser.