source: Scheduling/trunk/cs/bsdx0200GUISourceCode/DCheckIn.cs@ 1114

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

CGAppointment: Added Provider as a Member of Class. (auto property)
CGDocument: No changes
CGDocumentManager: Added UserPreferences as a member of a Class (private and property)
CGView: Changes to support printing of Routing Slip
DAppointPage: Changes to support UserPreferences member for auto printing the routing slips
DCheckIn: Extensive changes in load code (now uses LINQ instead of ADO.net). Changes to support UserPreferences member for auto printing the routing slips.
Patient: Documentation for UserFriendlyAge.
Provider: New class to represent Provider
UserPreferences: New class to represent User preferences. Does not interact with DB right now.

File size: 20.1 KB
Line 
1using System;
2using System.Drawing;
3using System.Collections;
4using System.ComponentModel;
5using System.Windows.Forms;
6using System.Data;
7using System.Diagnostics;
8using IndianHealthService.BMXNet;
9using System.Collections.Generic;
10using System.Linq;
11
12namespace IndianHealthService.ClinicalScheduling
13{
14 /// <summary>
15 /// Summary description for DCheckIn.
16 /// </summary>
17 public class DCheckIn : System.Windows.Forms.Form
18 {
19 private IContainer components;
20
21 public DCheckIn()
22 {
23 //
24 // Required for Windows Form Designer support
25 //
26 InitializeComponent();
27 }
28
29
30 #region Fields
31 private System.Windows.Forms.Panel pnlPageBottom;
32 private System.Windows.Forms.Button cmdCancel;
33 private System.Windows.Forms.Button cmdOK;
34 private System.Windows.Forms.Panel pnlDescription;
35 private System.Windows.Forms.GroupBox grpDescriptionResourceGroup;
36 private System.Windows.Forms.Label lblDescriptionResourceGroup;
37 private System.Windows.Forms.Label label1;
38 private System.Windows.Forms.DateTimePicker dtpCheckIn;
39 private System.Windows.Forms.Label lblAlready;
40 private System.Windows.Forms.Label label3;
41 private System.Windows.Forms.Label lblPatientName;
42 private System.Windows.Forms.Label label2;
43 private System.Windows.Forms.ComboBox cboProvider;
44 private System.Windows.Forms.CheckBox chkRoutingSlip;
45
46 private string m_sPatientName;
47 private DateTime m_dCheckIn;
48 private string m_sProvider;
49 private string m_sProviderIEN;
50 private CGDocumentManager m_DocManager;
51 private DataSet m_dsGlobal;
52 private DataTable m_dtProvider;
53 private DataView m_dvCS;
54 private bool m_bProviderRequired;
55 private DataTable m_dtClinic;
56 private DataTable m_dtForm;
57 private DataView m_dvClinic;
58 private DataView m_dvForm;
59 public bool m_bPrintRouteSlip;
60 private List<Provider> _providers;
61 private ToolTip toolTip1;
62
63 #endregion Fields
64
65 #region Properties
66
67 /// <summary>
68 /// Returns Provider chosen for Check-In
69 /// </summary>
70 public Provider Provider
71 {
72 get
73 {
74 if (cboProvider.SelectedIndex < 1) return null; // because first item is empty placeholder
75 else return this._providers[cboProvider.SelectedIndex];
76 }
77 }
78
79 /// <summary>
80 /// Returns 'true' if routing slip to be printed; otherwise 'false'
81 /// </summary>
82 public bool PrintRouteSlip
83 {
84 get
85 {
86 return m_bPrintRouteSlip;
87 }
88 }
89
90 /// <summary>
91 /// Appointment checkin time
92 /// </summary>
93 public DateTime CheckInTime
94 {
95 get
96 {
97 return m_dCheckIn;
98 }
99 set
100 {
101 m_dCheckIn = value;
102 }
103 }
104
105 #endregion Properties
106
107 #region Methods
108
109 /// <summary>
110 /// Fill memeber variables before showing dialog
111 /// </summary>
112 /// <param name="a">Appointment</param>
113 /// <param name="docManager">Document Manager</param>
114 public void InitializePage(CGAppointment a)
115 {
116 m_DocManager = CGDocumentManager.Current;
117 m_dsGlobal = m_DocManager.GlobalDataSet;
118
119 Int32? nHospLoc = (from resource in m_dsGlobal.Tables["Resources"].AsEnumerable()
120 where resource.Field<string>("RESOURCE_NAME") == a.Resource
121 select resource.Field<Int32?>("HOSPITAL_LOCATION_ID"))
122 .SingleOrDefault();
123
124 //smh - following logic replaced with above...
125 /*
126 DataView rv = new DataView(this.m_DocManager.GlobalDataSet.Tables["Resources"]);
127 rv.Sort = "RESOURCE_NAME ASC";
128 int nFind = rv.Find((string)a.Resource);
129 DataRowView drv = rv[nFind];
130
131 string sHospLoc = drv["HOSPITAL_LOCATION_ID"].ToString();
132 sHospLoc = (sHospLoc == "") ? "0" : sHospLoc;
133 int nHospLoc = 0;
134 try
135 {
136 nHospLoc = Convert.ToInt32(sHospLoc);
137 }
138 catch (Exception ex)
139 {
140 Debug.Write("CGView.AppointmentCheckIn Error: " + ex.Message);
141 }
142 */
143
144 //smh new code
145 //if the resource is linked to a valid hospital location, grab this locations providers
146 //from the provider multiple and put them in the combo box.
147 if (nHospLoc != null)
148 {
149 //RPC BSDX HOSP LOC PROVIDERS returns Table w/ Columns:
150 //HOSPITAL_LOCATION_ID^BMXIEN (ie Prov IEN)^NAME^DEFALUT
151 string sCommandText = "BSDX HOSP LOC PROVIDERS^" + nHospLoc;
152 m_dtProvider = m_DocManager.RPMSDataTable(sCommandText, "ClinicProviders");
153
154 _providers = (from providerRow in m_dtProvider.AsEnumerable()
155 orderby providerRow.Field<string>("NAME")
156 select new Provider
157 {
158 IEN = providerRow.Field<int>("BMXIEN"),
159 Name = providerRow.Field<string>("NAME"),
160 Default = providerRow.Field<string>("DEFAULT") == "YES" ? true : false
161 }).ToList();
162
163
164
165 //cboProvider.DisplayMember = "NAME";
166 //cboProvider.ValueMember = "BMXIEN";
167 _providers.Insert(0, new Provider { Name = "<None>", IEN = -1 });
168 cboProvider.DataSource = _providers;
169 cboProvider.SelectedIndex = _providers.FindIndex(prov => prov.Default);
170 // if no provider is default, set default to be <none> item.
171 if (cboProvider.SelectedIndex == -1) cboProvider.SelectedIndex = 0;
172 ////Add None to the top of the list
173 //DataRow drProv = m_dtProvider.NewRow();
174 //drProv.BeginEdit();
175 //drProv["HOSPITAL_LOCATION_ID"] = 0;
176 //drProv["NAME"] = "<None>";
177 //drProv["BMXIEN"] = 0;
178 //drProv.EndEdit();
179 //m_dtProvider.Rows.InsertAt(drProv, 0);
180 ////cboProvider.SelectedIndex = 0;
181
182 //Find default provider--search for Yes in Field DEFAULT
183 //DataRow[] nRow = m_dtProvider.Select("DEFAULT='YES'", "NAME ASC");
184 //if (nRow.Length > 0) nFind = m_dtProvider.Rows.IndexOf(nRow[0]);
185
186
187 }
188 //otherwise, just use the default provider table
189 else
190 {
191
192 _providers = (from providerRow in m_dsGlobal.Tables["Provider"].AsEnumerable()
193 orderby providerRow.Field<string>("NAME")
194 select new Provider
195 {
196 IEN = providerRow.Field<int>("BMXIEN"),
197 Name = providerRow.Field<string>("NAME"),
198 Default = false
199 }).ToList();
200
201
202 /*m_dtProvider = m_dsGlobal.Tables["Provider"];
203 m_dtProvider.DefaultView.Sort = "NAME ASC";*/
204 _providers.Insert(0, new Provider { Name = "<None>", IEN = -1 });
205 cboProvider.DataSource = _providers;
206 cboProvider.SelectedIndex = 0;
207 //cboProvider.DisplayMember = "NAME";
208 //cboProvider.ValueMember = "BMXIEN";
209
210 //Add None to the top of the list
211 //DataRow drProv = m_dtProvider.NewRow();
212 //drProv.BeginEdit();
213 //drProv["NAME"] = "<None>";
214 //drProv["BMXIEN"] = 0;
215 //drProv.EndEdit();
216 //m_dtProvider.Rows.InsertAt(drProv, 0);
217 //cboProvider.SelectedIndex = 0;
218 }
219
220
221
222 m_sPatientName = a.PatientName;
223 if (a.CheckInTime.Ticks != 0)
224 {
225 m_dCheckIn = a.CheckInTime;
226 dtpCheckIn.Enabled = false;
227 this.cboProvider.Enabled = false;
228 lblAlready.Visible = true;
229 }
230 else
231 {
232 m_dCheckIn = DateTime.Now;
233 }
234
235 //Print Routing Slip based on user preferences.
236 chkRoutingSlip.Checked = CGDocumentManager.Current.UserPreferences.PrintRoutingSlipAutomatically;
237
238 UpdateDialogData(true);
239 }
240
241
242 /// <summary>
243 /// If b is true, moves member vars into control data
244 /// otherwise, moves control data into member vars
245 /// </summary>
246 /// <param name="b"></param>
247 private void UpdateDialogData(bool b)
248 {
249 if (b == true) //Move data to dialog controls from member variables
250 {
251 this.lblPatientName.Text = m_sPatientName;
252 this.dtpCheckIn.Value = m_dCheckIn;
253 }
254 else //Move data to member variables from dialog controls
255 {
256 m_dCheckIn = this.dtpCheckIn.Value;
257 m_sProviderIEN = this.cboProvider.SelectedValue.ToString();
258 m_bPrintRouteSlip = chkRoutingSlip.Checked;
259 }
260 }
261
262 /// <summary>
263 /// Clean up any resources being used.
264 /// </summary>
265 protected override void Dispose(bool disposing)
266 {
267 if (disposing)
268 {
269 if (components != null)
270 {
271 components.Dispose();
272 }
273 }
274 base.Dispose(disposing);
275 }
276 #endregion Methods
277
278 #region Windows Form Designer generated code
279 /// <summary>
280 /// Required method for Designer support - do not modify
281 /// the contents of this method with the code editor.
282 /// </summary>
283 private void InitializeComponent()
284 {
285 this.components = new System.ComponentModel.Container();
286 this.pnlPageBottom = new System.Windows.Forms.Panel();
287 this.cmdCancel = new System.Windows.Forms.Button();
288 this.cmdOK = new System.Windows.Forms.Button();
289 this.pnlDescription = new System.Windows.Forms.Panel();
290 this.grpDescriptionResourceGroup = new System.Windows.Forms.GroupBox();
291 this.lblDescriptionResourceGroup = new System.Windows.Forms.Label();
292 this.label1 = new System.Windows.Forms.Label();
293 this.dtpCheckIn = new System.Windows.Forms.DateTimePicker();
294 this.lblAlready = new System.Windows.Forms.Label();
295 this.label3 = new System.Windows.Forms.Label();
296 this.lblPatientName = new System.Windows.Forms.Label();
297 this.cboProvider = new System.Windows.Forms.ComboBox();
298 this.label2 = new System.Windows.Forms.Label();
299 this.chkRoutingSlip = new System.Windows.Forms.CheckBox();
300 this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
301 this.pnlPageBottom.SuspendLayout();
302 this.pnlDescription.SuspendLayout();
303 this.grpDescriptionResourceGroup.SuspendLayout();
304 this.SuspendLayout();
305 //
306 // pnlPageBottom
307 //
308 this.pnlPageBottom.Controls.Add(this.cmdCancel);
309 this.pnlPageBottom.Controls.Add(this.cmdOK);
310 this.pnlPageBottom.Dock = System.Windows.Forms.DockStyle.Bottom;
311 this.pnlPageBottom.Location = new System.Drawing.Point(0, 203);
312 this.pnlPageBottom.Name = "pnlPageBottom";
313 this.pnlPageBottom.Size = new System.Drawing.Size(520, 40);
314 this.pnlPageBottom.TabIndex = 5;
315 //
316 // cmdCancel
317 //
318 this.cmdCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
319 this.cmdCancel.Location = new System.Drawing.Point(440, 8);
320 this.cmdCancel.Name = "cmdCancel";
321 this.cmdCancel.Size = new System.Drawing.Size(56, 24);
322 this.cmdCancel.TabIndex = 2;
323 this.cmdCancel.Text = "Cancel";
324 //
325 // cmdOK
326 //
327 this.cmdOK.DialogResult = System.Windows.Forms.DialogResult.OK;
328 this.cmdOK.Location = new System.Drawing.Point(360, 8);
329 this.cmdOK.Name = "cmdOK";
330 this.cmdOK.Size = new System.Drawing.Size(64, 24);
331 this.cmdOK.TabIndex = 1;
332 this.cmdOK.Text = "OK";
333 this.cmdOK.Click += new System.EventHandler(this.cmdOK_Click);
334 //
335 // pnlDescription
336 //
337 this.pnlDescription.Controls.Add(this.grpDescriptionResourceGroup);
338 this.pnlDescription.Dock = System.Windows.Forms.DockStyle.Bottom;
339 this.pnlDescription.Location = new System.Drawing.Point(0, 131);
340 this.pnlDescription.Name = "pnlDescription";
341 this.pnlDescription.Size = new System.Drawing.Size(520, 72);
342 this.pnlDescription.TabIndex = 6;
343 //
344 // grpDescriptionResourceGroup
345 //
346 this.grpDescriptionResourceGroup.Controls.Add(this.lblDescriptionResourceGroup);
347 this.grpDescriptionResourceGroup.Dock = System.Windows.Forms.DockStyle.Fill;
348 this.grpDescriptionResourceGroup.Location = new System.Drawing.Point(0, 0);
349 this.grpDescriptionResourceGroup.Name = "grpDescriptionResourceGroup";
350 this.grpDescriptionResourceGroup.Size = new System.Drawing.Size(520, 72);
351 this.grpDescriptionResourceGroup.TabIndex = 1;
352 this.grpDescriptionResourceGroup.TabStop = false;
353 this.grpDescriptionResourceGroup.Text = "Description";
354 //
355 // lblDescriptionResourceGroup
356 //
357 this.lblDescriptionResourceGroup.Dock = System.Windows.Forms.DockStyle.Fill;
358 this.lblDescriptionResourceGroup.Location = new System.Drawing.Point(3, 16);
359 this.lblDescriptionResourceGroup.Name = "lblDescriptionResourceGroup";
360 this.lblDescriptionResourceGroup.Size = new System.Drawing.Size(514, 53);
361 this.lblDescriptionResourceGroup.TabIndex = 0;
362 this.lblDescriptionResourceGroup.Text = "Use this panel to check in an appointment. A patient may only be checked-in once." +
363 "";
364 //
365 // label1
366 //
367 this.label1.Location = new System.Drawing.Point(16, 16);
368 this.label1.Name = "label1";
369 this.label1.Size = new System.Drawing.Size(80, 16);
370 this.label1.TabIndex = 7;
371 this.label1.Text = "Patient Name:";
372 //
373 // dtpCheckIn
374 //
375 this.dtpCheckIn.AllowDrop = true;
376 this.dtpCheckIn.CustomFormat = "MMMM dd yyyy H:mm";
377 this.dtpCheckIn.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
378 this.dtpCheckIn.Location = new System.Drawing.Point(96, 48);
379 this.dtpCheckIn.Name = "dtpCheckIn";
380 this.dtpCheckIn.ShowUpDown = true;
381 this.dtpCheckIn.Size = new System.Drawing.Size(176, 20);
382 this.dtpCheckIn.TabIndex = 9;
383 //
384 // lblAlready
385 //
386 this.lblAlready.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
387 this.lblAlready.ForeColor = System.Drawing.Color.Green;
388 this.lblAlready.Location = new System.Drawing.Point(288, 40);
389 this.lblAlready.Name = "lblAlready";
390 this.lblAlready.Size = new System.Drawing.Size(192, 32);
391 this.lblAlready.TabIndex = 10;
392 this.lblAlready.Text = "This Patient is already checked in.";
393 this.lblAlready.Visible = false;
394 //
395 // label3
396 //
397 this.label3.Location = new System.Drawing.Point(16, 48);
398 this.label3.Name = "label3";
399 this.label3.Size = new System.Drawing.Size(80, 16);
400 this.label3.TabIndex = 7;
401 this.label3.Text = "Check-in Time:";
402 //
403 // lblPatientName
404 //
405 this.lblPatientName.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
406 this.lblPatientName.Location = new System.Drawing.Point(96, 16);
407 this.lblPatientName.Name = "lblPatientName";
408 this.lblPatientName.Size = new System.Drawing.Size(256, 16);
409 this.lblPatientName.TabIndex = 11;
410 //
411 // cboProvider
412 //
413 this.cboProvider.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
414 this.cboProvider.Location = new System.Drawing.Point(96, 88);
415 this.cboProvider.Name = "cboProvider";
416 this.cboProvider.Size = new System.Drawing.Size(240, 21);
417 this.cboProvider.TabIndex = 12;
418 //
419 // label2
420 //
421 this.label2.Location = new System.Drawing.Point(16, 88);
422 this.label2.Name = "label2";
423 this.label2.Size = new System.Drawing.Size(80, 16);
424 this.label2.TabIndex = 7;
425 this.label2.Text = "Visit Provider:";
426 //
427 // chkRoutingSlip
428 //
429 this.chkRoutingSlip.Location = new System.Drawing.Point(380, 93);
430 this.chkRoutingSlip.Name = "chkRoutingSlip";
431 this.chkRoutingSlip.Size = new System.Drawing.Size(128, 16);
432 this.chkRoutingSlip.TabIndex = 14;
433 this.chkRoutingSlip.Text = "Print Routing Slip";
434 this.toolTip1.SetToolTip(this.chkRoutingSlip, "Prints routing slip to the Windows Default Printer");
435 this.chkRoutingSlip.CheckedChanged += new System.EventHandler(this.chkRoutingSlip_CheckedChanged);
436 //
437 // DCheckIn
438 //
439 this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
440 this.ClientSize = new System.Drawing.Size(520, 243);
441 this.Controls.Add(this.chkRoutingSlip);
442 this.Controls.Add(this.cboProvider);
443 this.Controls.Add(this.lblPatientName);
444 this.Controls.Add(this.lblAlready);
445 this.Controls.Add(this.dtpCheckIn);
446 this.Controls.Add(this.label1);
447 this.Controls.Add(this.pnlDescription);
448 this.Controls.Add(this.pnlPageBottom);
449 this.Controls.Add(this.label3);
450 this.Controls.Add(this.label2);
451 this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
452 this.Name = "DCheckIn";
453 this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
454 this.Text = "Appointment Check In";
455 this.pnlPageBottom.ResumeLayout(false);
456 this.pnlDescription.ResumeLayout(false);
457 this.grpDescriptionResourceGroup.ResumeLayout(false);
458 this.ResumeLayout(false);
459
460 }
461 #endregion
462
463 #region Events
464
465 private void cmdOK_Click(object sender, System.EventArgs e)
466 {
467 this.UpdateDialogData(false);
468 }
469
470 /// <summary>
471 /// Save this in User Preferences Object.
472 /// </summary>
473 /// <param name="sender"></param>
474 /// <param name="e"></param>
475 private void chkRoutingSlip_CheckedChanged(object sender, EventArgs e)
476 {
477 CGDocumentManager.Current.UserPreferences.PrintRoutingSlipAutomatically = chkRoutingSlip.Checked;
478 }
479
480 #endregion Events
481
482 }
483}
Note: See TracBrowser for help on using the repository browser.