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

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

CGAVDocument: Don't Update Grid. Leave that to CGAVView.
CGAVView: When updating grid, make a copy of appointments, and use the copy, so there won't be clashes when updating appointments in the background.
CGDocument: Minor Changes in AppointmentNoShow; New method AppointmentUndoCheckIn
CGDocumentManager: Resequenced load order b/c UserPreferences now talks to DB.
DAL: New Methods to save autoprint preferences; new delegate to enable some async stuff
DCheckIn & DAppointPage: _myCodeIsFiringIstheCheckBoxChangedEvent added to protect against firing event when setting checkbox in the code.
DPatientLetter: No changes.
UserPreferences: Now gets and saves user preferences from DB.

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