source: Scheduling/trunk/cs/bsdx0200GUISourceCode/CGView.cs@ 794

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

CGView: Added various shortcuts keys for menus; removed extra overbook prompt after booking if doing an overbook. You already get one before booking.
CGDocumentManager: Mickey mouse connection check to prevent prompting for access and verify if there's no connection to VISTA.
CGDocumentManager: Test SQL statement to retrieve Hospital Locations and default providers associated with them.
Remove garbage file {85FE etc}.rpt

File size: 103.2 KB
Line 
1using System;
2using System.Drawing;
3using System.Collections;
4using System.ComponentModel;
5using System.Windows.Forms;
6using System.Diagnostics;
7using System.Data;
8using System.Net;
9using System.Net.Sockets;
10using System.Threading;
11using System.IO;
12using IndianHealthService.BMXNet;
13using System.Reflection;
14
15
16namespace IndianHealthService.ClinicalScheduling
17{
18 /// <summary>
19 /// Summary description for CGView.
20 /// </summary>
21 public class CGView : System.Windows.Forms.Form
22 {
23 private System.Windows.Forms.MainMenu mainMenu1;
24 private System.Windows.Forms.MenuItem mnuFile;
25 private System.Windows.Forms.MenuItem mnuTest;
26 private System.Windows.Forms.MenuItem mnuAppointment;
27 private System.Windows.Forms.MenuItem mnuNewAppointment;
28 private System.Windows.Forms.MenuItem mnu1Day;
29 private System.Windows.Forms.MenuItem mnu7Day;
30 private System.Windows.Forms.MenuItem menuItem4;
31 private System.Windows.Forms.MenuItem mnu5Day;
32 private System.Windows.Forms.MenuItem mnu10Minute;
33 private System.Windows.Forms.MenuItem mnu20Minute;
34 private System.Windows.Forms.MenuItem mnu30Minute;
35 private System.Windows.Forms.MenuItem mnuTimeScale;
36 private System.Windows.Forms.MenuItem mnu15Minute;
37 private System.Windows.Forms.MenuItem mnuOpenSchedule;
38 private System.Windows.Forms.MenuItem menuItem1;
39 private System.Windows.Forms.TreeView tvSchedules;
40 private System.Windows.Forms.MenuItem mnuViewScheduleTree;
41 private System.Windows.Forms.MenuItem mnuDeleteAppointment;
42 private System.Windows.Forms.MenuItem mnuTest1;
43 private System.Windows.Forms.Splitter splitter1;
44 private System.Windows.Forms.Splitter splitter2;
45 private System.Windows.Forms.StatusBar statusBar1;
46 private System.Windows.Forms.DateTimePicker dateTimePicker1;
47 private System.Windows.Forms.MenuItem mnuViewRightPanel;
48 private System.Windows.Forms.Panel panelRight;
49 private System.Windows.Forms.Panel panelTop;
50 private System.Windows.Forms.Panel panelCenter;
51 private System.Windows.Forms.Panel panelBottom;
52 private System.Windows.Forms.Label lblResource;
53 private System.Windows.Forms.ContextMenu contextMenu1;
54 private System.Windows.Forms.MenuItem ctxOpenSchedule;
55 private System.Windows.Forms.MenuItem ctxEditAvailability;
56 private System.Windows.Forms.MenuItem ctxProperties;
57 private System.Windows.Forms.MenuItem mnuSchedulingManagment;
58 private System.Windows.Forms.MenuItem ctxFindAppt;
59 private System.Windows.Forms.MenuItem mnuFindAppt;
60 internal System.Windows.Forms.MenuItem mnuRPMSServer;
61 internal System.Windows.Forms.MenuItem mnuRPMSLogin;
62 private System.Windows.Forms.MenuItem mnuCheckIn;
63 private System.Windows.Forms.MenuItem menuItem3;
64 private System.Windows.Forms.MenuItem mnuHelpAbout;
65 private System.Windows.Forms.MenuItem mnuCalendar;
66 private System.Windows.Forms.MenuItem mnuHelp;
67 private System.Windows.Forms.MenuItem mnuClose;
68 private System.Windows.Forms.MenuItem mnuViewPatientAppts;
69 private IndianHealthService.ClinicalScheduling.CalendarGrid calendarGrid1;
70 private System.Windows.Forms.MenuItem mnuCopyAppointment;
71 private System.Windows.Forms.Panel panelClip;
72 private System.Windows.Forms.ListBox lstClip;
73 private System.Windows.Forms.Label label1;
74 private System.Windows.Forms.ContextMenu ctxApptClipMenu;
75 private System.Windows.Forms.MenuItem mnuRemoveClipItem;
76 private System.Windows.Forms.MenuItem mnuClearClipItems;
77 private System.Windows.Forms.MenuItem mnuEditAppointment;
78 private System.Windows.Forms.ContextMenu ctxCalendarGrid;
79 private System.Windows.Forms.MenuItem ctxCalGridAdd;
80 private System.Windows.Forms.MenuItem ctxCalGridEdit;
81 private System.Windows.Forms.MenuItem ctxCalGridDelete;
82 private System.Windows.Forms.MenuItem ctxCalGridCheckIn;
83 private System.Windows.Forms.MenuItem menuItem6;
84 private System.Windows.Forms.MenuItem menuItem7;
85 private System.Windows.Forms.MenuItem mnuPrintReminderLetters;
86 private System.Windows.Forms.MenuItem mnuPrintPatientLetter;
87 private System.Windows.Forms.MenuItem mnuPrintClinicSchedules;
88 private System.Windows.Forms.MenuItem ctxCalGridNoShow;
89 private System.Windows.Forms.MenuItem ctxCalGridNoShowUndo;
90 private System.Windows.Forms.MenuItem mnuNoShow;
91 private System.Windows.Forms.MenuItem mnuNoShowUndo;
92 private System.Windows.Forms.MenuItem mnuPrintRebookLetters;
93 private System.Windows.Forms.MenuItem mnuPrintCancellationLetters;
94 private System.Windows.Forms.MenuItem mnuWalkIn;
95 private System.Windows.Forms.MenuItem menuItem5;
96 private System.Windows.Forms.MenuItem menuItem8;
97 private System.Windows.Forms.MenuItem ctxCalGridWalkin;
98 private System.Windows.Forms.MenuItem menuItem2;
99 private System.Windows.Forms.MenuItem menuItem9;
100 private System.Windows.Forms.MenuItem mnuOpenMultipleSchedules;
101 private System.Windows.Forms.MenuItem mnuDisplayWalkIns;
102 private System.Windows.Forms.MenuItem mnuRPMSDivision;
103 private IContainer components;
104
105 #region Initialization
106 public CGView()
107 {
108 //
109 // Required for Windows Form Designer support
110 //
111 InitializeComponent();
112
113 m_nSlots = 0;
114 m_alSelectedTreeResourceArray = new ArrayList();
115 m_ClipList = new CGAppointments();
116
117 }
118
119 public void InitializeDocView(string sText)
120 {
121 this.Text = this.DocManager.ConnectInfo.UserName;
122 if (sText != null)
123 this.Text += " - " + sText;
124 if (DocManager.ConnectInfo.DivisionName != null)
125 this.Text += " - " + DocManager.ConnectInfo.DivisionName;
126 }
127
128 public void InitializeDocView(CGDocument doc,
129 CGDocumentManager docMgr,
130 DateTime dStartDate,
131 CGAppointments cgAppts,
132 string sText)
133 {
134 System.IntPtr pHandle = this.Handle;
135 this.DocManager = docMgr;
136 this.StartDate = dStartDate;
137 this.Document = doc;
138 this.Appointments = cgAppts;
139 this.Text = this.DocManager.ConnectInfo.UserName;
140 if (sText != null)
141 this.Text += " - " + sText;
142 if (DocManager.ConnectInfo.DivisionName != null)
143 this.Text += " - " + DocManager.ConnectInfo.DivisionName;
144
145 this.m_ConnectInfo = m_DocManager.ConnectInfo;
146 m_bmxDelegate = new BMXNetConnectInfo.BMXNetEventDelegate(BMXNetEventHandler);
147 m_ConnectInfo.BMXNetEvent += m_bmxDelegate;
148 }
149
150 private BMXNetConnectInfo.BMXNetEventDelegate m_bmxDelegate;
151 delegate void OnUpdateScheduleDelegate();
152
153 private void BMXNetEventHandler(Object obj, BMXNet.BMXNetEventArgs e)
154 {
155 try
156 {
157 if (e.BMXEvent == "BMXNet AutoFire")
158 {
159 Debug.Write("CGView caught AutoFire event.\n");
160 if (this == null)
161 return;
162 OnUpdateScheduleDelegate ousd = new OnUpdateScheduleDelegate(OnUpdateSchedule);
163 this.BeginInvoke(ousd);
164 return;
165 }
166
167 if (e.BMXEvent != "BSDX SCHEDULE")
168 {
169 return;
170 }
171 string sResourceName;
172 for (int j=0; j < m_Document.m_sResourcesArray.Count; j++)
173 {
174 sResourceName = m_Document.m_sResourcesArray[j].ToString();
175 if (e.BMXParam == sResourceName)
176 {
177 OnUpdateScheduleDelegate ousd = new OnUpdateScheduleDelegate(OnUpdateSchedule);
178 if (this == null)
179 return;
180 this.BeginInvoke(ousd);
181 Debug.Write("CGView caught BSDX SCHEDULE event.\n");
182 break;
183 }
184 }
185 }
186 catch (Exception ex)
187 {
188 Debug.Write(ex.Message);
189 }
190 }
191
192 #endregion initialization
193
194 #region Windows Form Designer generated code
195 /// <summary>
196 /// Required method for Designer support - do not modify
197 /// the contents of this method with the code editor.
198 /// </summary>
199 private void InitializeComponent()
200 {
201 this.components = new System.ComponentModel.Container();
202 System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CGView));
203 this.mainMenu1 = new System.Windows.Forms.MainMenu(this.components);
204 this.mnuFile = new System.Windows.Forms.MenuItem();
205 this.mnuOpenSchedule = new System.Windows.Forms.MenuItem();
206 this.mnuOpenMultipleSchedules = new System.Windows.Forms.MenuItem();
207 this.menuItem1 = new System.Windows.Forms.MenuItem();
208 this.mnuRPMSServer = new System.Windows.Forms.MenuItem();
209 this.mnuRPMSLogin = new System.Windows.Forms.MenuItem();
210 this.mnuRPMSDivision = new System.Windows.Forms.MenuItem();
211 this.menuItem3 = new System.Windows.Forms.MenuItem();
212 this.mnuSchedulingManagment = new System.Windows.Forms.MenuItem();
213 this.menuItem6 = new System.Windows.Forms.MenuItem();
214 this.mnuPrintClinicSchedules = new System.Windows.Forms.MenuItem();
215 this.mnuPrintReminderLetters = new System.Windows.Forms.MenuItem();
216 this.mnuPrintRebookLetters = new System.Windows.Forms.MenuItem();
217 this.mnuPrintCancellationLetters = new System.Windows.Forms.MenuItem();
218 this.mnuPrintPatientLetter = new System.Windows.Forms.MenuItem();
219 this.menuItem7 = new System.Windows.Forms.MenuItem();
220 this.mnuClose = new System.Windows.Forms.MenuItem();
221 this.mnuAppointment = new System.Windows.Forms.MenuItem();
222 this.mnuNewAppointment = new System.Windows.Forms.MenuItem();
223 this.mnuEditAppointment = new System.Windows.Forms.MenuItem();
224 this.mnuDeleteAppointment = new System.Windows.Forms.MenuItem();
225 this.menuItem5 = new System.Windows.Forms.MenuItem();
226 this.mnuNoShow = new System.Windows.Forms.MenuItem();
227 this.mnuNoShowUndo = new System.Windows.Forms.MenuItem();
228 this.menuItem8 = new System.Windows.Forms.MenuItem();
229 this.mnuCopyAppointment = new System.Windows.Forms.MenuItem();
230 this.mnuWalkIn = new System.Windows.Forms.MenuItem();
231 this.mnuFindAppt = new System.Windows.Forms.MenuItem();
232 this.mnuCheckIn = new System.Windows.Forms.MenuItem();
233 this.mnuViewPatientAppts = new System.Windows.Forms.MenuItem();
234 this.mnuCalendar = new System.Windows.Forms.MenuItem();
235 this.mnuDisplayWalkIns = new System.Windows.Forms.MenuItem();
236 this.mnu1Day = new System.Windows.Forms.MenuItem();
237 this.mnu5Day = new System.Windows.Forms.MenuItem();
238 this.mnu7Day = new System.Windows.Forms.MenuItem();
239 this.menuItem4 = new System.Windows.Forms.MenuItem();
240 this.mnuTimeScale = new System.Windows.Forms.MenuItem();
241 this.mnu10Minute = new System.Windows.Forms.MenuItem();
242 this.mnu15Minute = new System.Windows.Forms.MenuItem();
243 this.mnu20Minute = new System.Windows.Forms.MenuItem();
244 this.mnu30Minute = new System.Windows.Forms.MenuItem();
245 this.mnuViewScheduleTree = new System.Windows.Forms.MenuItem();
246 this.mnuViewRightPanel = new System.Windows.Forms.MenuItem();
247 this.mnuHelp = new System.Windows.Forms.MenuItem();
248 this.mnuHelpAbout = new System.Windows.Forms.MenuItem();
249 this.mnuTest = new System.Windows.Forms.MenuItem();
250 this.mnuTest1 = new System.Windows.Forms.MenuItem();
251 this.tvSchedules = new System.Windows.Forms.TreeView();
252 this.contextMenu1 = new System.Windows.Forms.ContextMenu();
253 this.ctxOpenSchedule = new System.Windows.Forms.MenuItem();
254 this.ctxEditAvailability = new System.Windows.Forms.MenuItem();
255 this.ctxProperties = new System.Windows.Forms.MenuItem();
256 this.ctxFindAppt = new System.Windows.Forms.MenuItem();
257 this.panelRight = new System.Windows.Forms.Panel();
258 this.panelClip = new System.Windows.Forms.Panel();
259 this.lstClip = new System.Windows.Forms.ListBox();
260 this.ctxApptClipMenu = new System.Windows.Forms.ContextMenu();
261 this.mnuRemoveClipItem = new System.Windows.Forms.MenuItem();
262 this.mnuClearClipItems = new System.Windows.Forms.MenuItem();
263 this.label1 = new System.Windows.Forms.Label();
264 this.panelTop = new System.Windows.Forms.Panel();
265 this.dateTimePicker1 = new System.Windows.Forms.DateTimePicker();
266 this.lblResource = new System.Windows.Forms.Label();
267 this.panelCenter = new System.Windows.Forms.Panel();
268 this.calendarGrid1 = new IndianHealthService.ClinicalScheduling.CalendarGrid();
269 this.ctxCalendarGrid = new System.Windows.Forms.ContextMenu();
270 this.ctxCalGridAdd = new System.Windows.Forms.MenuItem();
271 this.ctxCalGridEdit = new System.Windows.Forms.MenuItem();
272 this.ctxCalGridDelete = new System.Windows.Forms.MenuItem();
273 this.ctxCalGridCheckIn = new System.Windows.Forms.MenuItem();
274 this.menuItem2 = new System.Windows.Forms.MenuItem();
275 this.ctxCalGridNoShow = new System.Windows.Forms.MenuItem();
276 this.ctxCalGridNoShowUndo = new System.Windows.Forms.MenuItem();
277 this.menuItem9 = new System.Windows.Forms.MenuItem();
278 this.ctxCalGridWalkin = new System.Windows.Forms.MenuItem();
279 this.panelBottom = new System.Windows.Forms.Panel();
280 this.statusBar1 = new System.Windows.Forms.StatusBar();
281 this.splitter1 = new System.Windows.Forms.Splitter();
282 this.splitter2 = new System.Windows.Forms.Splitter();
283 this.panelRight.SuspendLayout();
284 this.panelClip.SuspendLayout();
285 this.panelTop.SuspendLayout();
286 this.panelCenter.SuspendLayout();
287 this.panelBottom.SuspendLayout();
288 this.SuspendLayout();
289 //
290 // mainMenu1
291 //
292 this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
293 this.mnuFile,
294 this.mnuAppointment,
295 this.mnuCalendar,
296 this.mnuHelp,
297 this.mnuTest});
298 //
299 // mnuFile
300 //
301 this.mnuFile.Index = 0;
302 this.mnuFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
303 this.mnuOpenSchedule,
304 this.mnuOpenMultipleSchedules,
305 this.menuItem1,
306 this.mnuRPMSServer,
307 this.mnuRPMSLogin,
308 this.mnuRPMSDivision,
309 this.menuItem3,
310 this.mnuSchedulingManagment,
311 this.menuItem6,
312 this.mnuPrintClinicSchedules,
313 this.mnuPrintReminderLetters,
314 this.mnuPrintRebookLetters,
315 this.mnuPrintCancellationLetters,
316 this.mnuPrintPatientLetter,
317 this.menuItem7,
318 this.mnuClose});
319 this.mnuFile.Text = "&File";
320 this.mnuFile.Popup += new System.EventHandler(this.mnuFile_Popup);
321 //
322 // mnuOpenSchedule
323 //
324 this.mnuOpenSchedule.Enabled = false;
325 this.mnuOpenSchedule.Index = 0;
326 this.mnuOpenSchedule.Text = "&Open Schedule";
327 this.mnuOpenSchedule.Visible = false;
328 this.mnuOpenSchedule.Click += new System.EventHandler(this.mnuOpenSchedule_Click);
329 //
330 // mnuOpenMultipleSchedules
331 //
332 this.mnuOpenMultipleSchedules.Index = 1;
333 this.mnuOpenMultipleSchedules.Shortcut = System.Windows.Forms.Shortcut.CtrlM;
334 this.mnuOpenMultipleSchedules.Text = "Open M&ultiple Schedules";
335 this.mnuOpenMultipleSchedules.Click += new System.EventHandler(this.mnuOpenMultipleSchedules_Click);
336 //
337 // menuItem1
338 //
339 this.menuItem1.Index = 2;
340 this.menuItem1.Text = "-";
341 //
342 // mnuRPMSServer
343 //
344 this.mnuRPMSServer.Index = 3;
345 this.mnuRPMSServer.Text = "Change VistA &Server";
346 this.mnuRPMSServer.Click += new System.EventHandler(this.mnuRPMSServer_Click);
347 //
348 // mnuRPMSLogin
349 //
350 this.mnuRPMSLogin.Index = 4;
351 this.mnuRPMSLogin.Text = "Change VistA &Login";
352 this.mnuRPMSLogin.Click += new System.EventHandler(this.mnuRPMSLogin_Click);
353 //
354 // mnuRPMSDivision
355 //
356 this.mnuRPMSDivision.Index = 5;
357 this.mnuRPMSDivision.Text = "Change VistA &Division";
358 this.mnuRPMSDivision.Click += new System.EventHandler(this.mnuRPMSDivision_Click);
359 //
360 // menuItem3
361 //
362 this.menuItem3.Index = 6;
363 this.menuItem3.Text = "-";
364 //
365 // mnuSchedulingManagment
366 //
367 this.mnuSchedulingManagment.Index = 7;
368 this.mnuSchedulingManagment.Shortcut = System.Windows.Forms.Shortcut.CtrlShiftM;
369 this.mnuSchedulingManagment.Text = "Scheduling &Management";
370 this.mnuSchedulingManagment.Click += new System.EventHandler(this.mnuSchedulingManagment_Click);
371 //
372 // menuItem6
373 //
374 this.menuItem6.Index = 8;
375 this.menuItem6.Text = "-";
376 //
377 // mnuPrintClinicSchedules
378 //
379 this.mnuPrintClinicSchedules.Index = 9;
380 this.mnuPrintClinicSchedules.Shortcut = System.Windows.Forms.Shortcut.CtrlP;
381 this.mnuPrintClinicSchedules.Text = "&Print Clinic Schedules";
382 this.mnuPrintClinicSchedules.Click += new System.EventHandler(this.mnuPrintClinicSchedules_Click);
383 //
384 // mnuPrintReminderLetters
385 //
386 this.mnuPrintReminderLetters.Index = 10;
387 this.mnuPrintReminderLetters.Shortcut = System.Windows.Forms.Shortcut.CtrlR;
388 this.mnuPrintReminderLetters.Text = "Print Rem&inder Letters";
389 this.mnuPrintReminderLetters.Click += new System.EventHandler(this.mnuPrintReminderLetters_Click);
390 //
391 // mnuPrintRebookLetters
392 //
393 this.mnuPrintRebookLetters.Index = 11;
394 this.mnuPrintRebookLetters.Text = "Print &Rebook Letters";
395 this.mnuPrintRebookLetters.Click += new System.EventHandler(this.mnuPrintRebookLetters_Click);
396 //
397 // mnuPrintCancellationLetters
398 //
399 this.mnuPrintCancellationLetters.Index = 12;
400 this.mnuPrintCancellationLetters.Shortcut = System.Windows.Forms.Shortcut.CtrlShiftC;
401 this.mnuPrintCancellationLetters.Text = "Print C&ancellation Letters";
402 this.mnuPrintCancellationLetters.Click += new System.EventHandler(this.mnuPrintCancellationLetters_Click);
403 //
404 // mnuPrintPatientLetter
405 //
406 this.mnuPrintPatientLetter.Index = 13;
407 this.mnuPrintPatientLetter.Shortcut = System.Windows.Forms.Shortcut.CtrlL;
408 this.mnuPrintPatientLetter.Text = "Print Patient Le&tter";
409 this.mnuPrintPatientLetter.Click += new System.EventHandler(this.mnuPrintPatientLetter_Click);
410 //
411 // menuItem7
412 //
413 this.menuItem7.Index = 14;
414 this.menuItem7.Text = "-";
415 //
416 // mnuClose
417 //
418 this.mnuClose.Index = 15;
419 this.mnuClose.Shortcut = System.Windows.Forms.Shortcut.CtrlW;
420 this.mnuClose.Text = "&Close Schedule";
421 this.mnuClose.Click += new System.EventHandler(this.mnuClose_Click);
422 //
423 // mnuAppointment
424 //
425 this.mnuAppointment.Index = 1;
426 this.mnuAppointment.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
427 this.mnuNewAppointment,
428 this.mnuEditAppointment,
429 this.mnuDeleteAppointment,
430 this.menuItem5,
431 this.mnuNoShow,
432 this.mnuNoShowUndo,
433 this.menuItem8,
434 this.mnuCopyAppointment,
435 this.mnuWalkIn,
436 this.mnuFindAppt,
437 this.mnuCheckIn,
438 this.mnuViewPatientAppts});
439 this.mnuAppointment.Text = "&Appointment";
440 this.mnuAppointment.Popup += new System.EventHandler(this.mnuAppointment_Popup);
441 //
442 // mnuNewAppointment
443 //
444 this.mnuNewAppointment.Index = 0;
445 this.mnuNewAppointment.Text = "&New Appointment";
446 this.mnuNewAppointment.Click += new System.EventHandler(this.mnuNewAppointment_Click);
447 //
448 // mnuEditAppointment
449 //
450 this.mnuEditAppointment.Index = 1;
451 this.mnuEditAppointment.Text = "&Edit Appointment";
452 this.mnuEditAppointment.Click += new System.EventHandler(this.mnuEditAppointment_Click);
453 //
454 // mnuDeleteAppointment
455 //
456 this.mnuDeleteAppointment.Index = 2;
457 this.mnuDeleteAppointment.Text = "Cance&l Appointment";
458 this.mnuDeleteAppointment.Click += new System.EventHandler(this.mnuDeleteAppointment_Click);
459 //
460 // menuItem5
461 //
462 this.menuItem5.Index = 3;
463 this.menuItem5.Text = "-";
464 //
465 // mnuNoShow
466 //
467 this.mnuNoShow.Index = 4;
468 this.mnuNoShow.Text = "Mark as No Sho&w";
469 this.mnuNoShow.Click += new System.EventHandler(this.mnuNoShow_Click);
470 //
471 // mnuNoShowUndo
472 //
473 this.mnuNoShowUndo.Index = 5;
474 this.mnuNoShowUndo.Text = "&Undo No Show";
475 this.mnuNoShowUndo.Click += new System.EventHandler(this.mnuNoShowUndo_Click);
476 //
477 // menuItem8
478 //
479 this.menuItem8.Index = 6;
480 this.menuItem8.Text = "-";
481 //
482 // mnuCopyAppointment
483 //
484 this.mnuCopyAppointment.Index = 7;
485 this.mnuCopyAppointment.Text = "&Copy Appointment to Clipboard";
486 this.mnuCopyAppointment.Click += new System.EventHandler(this.mnuCopyAppointment_Click);
487 //
488 // mnuWalkIn
489 //
490 this.mnuWalkIn.Index = 8;
491 this.mnuWalkIn.Text = "Create Wal&k-In Appointment";
492 this.mnuWalkIn.Click += new System.EventHandler(this.mnuWalkIn_Click);
493 //
494 // mnuFindAppt
495 //
496 this.mnuFindAppt.Index = 9;
497 this.mnuFindAppt.Text = "&Find Available Appointment";
498 this.mnuFindAppt.Click += new System.EventHandler(this.mnuFindAppt_Click);
499 //
500 // mnuCheckIn
501 //
502 this.mnuCheckIn.Index = 10;
503 this.mnuCheckIn.Text = "Check &In Patient";
504 this.mnuCheckIn.Click += new System.EventHandler(this.mnuCheckIn_Click);
505 //
506 // mnuViewPatientAppts
507 //
508 this.mnuViewPatientAppts.Index = 11;
509 this.mnuViewPatientAppts.Text = "&View Patient Appointments";
510 this.mnuViewPatientAppts.Click += new System.EventHandler(this.mnuViewPatientAppts_Click);
511 //
512 // mnuCalendar
513 //
514 this.mnuCalendar.Index = 2;
515 this.mnuCalendar.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
516 this.mnuDisplayWalkIns,
517 this.mnu1Day,
518 this.mnu5Day,
519 this.mnu7Day,
520 this.menuItem4,
521 this.mnuTimeScale,
522 this.mnuViewScheduleTree,
523 this.mnuViewRightPanel});
524 this.mnuCalendar.Text = "&View";
525 //
526 // mnuDisplayWalkIns
527 //
528 this.mnuDisplayWalkIns.Checked = true;
529 this.mnuDisplayWalkIns.Index = 0;
530 this.mnuDisplayWalkIns.Text = "&Display Walk-Ins";
531 this.mnuDisplayWalkIns.Click += new System.EventHandler(this.mnuDisplayWalkIns_Click);
532 //
533 // mnu1Day
534 //
535 this.mnu1Day.Index = 1;
536 this.mnu1Day.Shortcut = System.Windows.Forms.Shortcut.Ctrl1;
537 this.mnu1Day.Text = "&1-Day View";
538 this.mnu1Day.Click += new System.EventHandler(this.mnu1Day_Click);
539 //
540 // mnu5Day
541 //
542 this.mnu5Day.Index = 2;
543 this.mnu5Day.Shortcut = System.Windows.Forms.Shortcut.Ctrl5;
544 this.mnu5Day.Text = "&5-Day View";
545 this.mnu5Day.Click += new System.EventHandler(this.mnu5Day_Click);
546 //
547 // mnu7Day
548 //
549 this.mnu7Day.Index = 3;
550 this.mnu7Day.Shortcut = System.Windows.Forms.Shortcut.Ctrl7;
551 this.mnu7Day.Text = "&7-Day View";
552 this.mnu7Day.Click += new System.EventHandler(this.mnu7Day_Click);
553 //
554 // menuItem4
555 //
556 this.menuItem4.Index = 4;
557 this.menuItem4.Text = "-";
558 //
559 // mnuTimeScale
560 //
561 this.mnuTimeScale.Index = 5;
562 this.mnuTimeScale.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
563 this.mnu10Minute,
564 this.mnu15Minute,
565 this.mnu20Minute,
566 this.mnu30Minute});
567 this.mnuTimeScale.Text = "&Time Scale";
568 //
569 // mnu10Minute
570 //
571 this.mnu10Minute.Index = 0;
572 this.mnu10Minute.Shortcut = System.Windows.Forms.Shortcut.Ctrl0;
573 this.mnu10Minute.Text = "&10-Minute";
574 this.mnu10Minute.Click += new System.EventHandler(this.mnu10Minute_Click);
575 //
576 // mnu15Minute
577 //
578 this.mnu15Minute.Index = 1;
579 this.mnu15Minute.Shortcut = System.Windows.Forms.Shortcut.Ctrl4;
580 this.mnu15Minute.Text = "1&5-Minute";
581 this.mnu15Minute.Click += new System.EventHandler(this.mnu15Minute_Click);
582 //
583 // mnu20Minute
584 //
585 this.mnu20Minute.Index = 2;
586 this.mnu20Minute.Shortcut = System.Windows.Forms.Shortcut.Ctrl3;
587 this.mnu20Minute.Text = "&20-Minute";
588 this.mnu20Minute.Click += new System.EventHandler(this.mnu20Minute_Click);
589 //
590 // mnu30Minute
591 //
592 this.mnu30Minute.Index = 3;
593 this.mnu30Minute.Shortcut = System.Windows.Forms.Shortcut.Ctrl2;
594 this.mnu30Minute.Text = "&30-Minute";
595 this.mnu30Minute.Click += new System.EventHandler(this.mnu30Minute_Click);
596 //
597 // mnuViewScheduleTree
598 //
599 this.mnuViewScheduleTree.Index = 6;
600 this.mnuViewScheduleTree.Text = "&Schedule Tree";
601 this.mnuViewScheduleTree.Click += new System.EventHandler(this.mnuViewScheduleTree_Click);
602 //
603 // mnuViewRightPanel
604 //
605 this.mnuViewRightPanel.Index = 7;
606 this.mnuViewRightPanel.Text = "&Appointment Clipboard";
607 this.mnuViewRightPanel.Click += new System.EventHandler(this.mnuViewRightPanel_Click);
608 //
609 // mnuHelp
610 //
611 this.mnuHelp.Index = 3;
612 this.mnuHelp.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
613 this.mnuHelpAbout});
614 this.mnuHelp.Text = "&Help";
615 //
616 // mnuHelpAbout
617 //
618 this.mnuHelpAbout.Index = 0;
619 this.mnuHelpAbout.Text = "&About";
620 this.mnuHelpAbout.Click += new System.EventHandler(this.mnuHelpAbout_Click);
621 //
622 // mnuTest
623 //
624 this.mnuTest.Enabled = false;
625 this.mnuTest.Index = 4;
626 this.mnuTest.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
627 this.mnuTest1});
628 this.mnuTest.Text = "&Test";
629 this.mnuTest.Visible = false;
630 //
631 // mnuTest1
632 //
633 this.mnuTest1.Index = 0;
634 this.mnuTest1.Text = "Test1";
635 this.mnuTest1.Click += new System.EventHandler(this.mnuTest1_Click);
636 //
637 // tvSchedules
638 //
639 this.tvSchedules.BackColor = System.Drawing.SystemColors.ControlLight;
640 this.tvSchedules.ContextMenu = this.contextMenu1;
641 this.tvSchedules.Dock = System.Windows.Forms.DockStyle.Left;
642 this.tvSchedules.HotTracking = true;
643 this.tvSchedules.Location = new System.Drawing.Point(0, 0);
644 this.tvSchedules.Name = "tvSchedules";
645 this.tvSchedules.Size = new System.Drawing.Size(128, 422);
646 this.tvSchedules.Sorted = true;
647 this.tvSchedules.TabIndex = 1;
648 this.tvSchedules.DoubleClick += new System.EventHandler(this.tvSchedules_DoubleClick);
649 this.tvSchedules.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.tvSchedules_AfterSelect);
650 this.tvSchedules.BeforeSelect += new System.Windows.Forms.TreeViewCancelEventHandler(this.tvSchedules_BeforeSelect);
651 this.tvSchedules.Click += new System.EventHandler(this.tvSchedules_Click);
652 //
653 // contextMenu1
654 //
655 this.contextMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
656 this.ctxOpenSchedule,
657 this.ctxEditAvailability,
658 this.ctxProperties,
659 this.ctxFindAppt});
660 this.contextMenu1.Popup += new System.EventHandler(this.contextMenu1_Popup);
661 //
662 // ctxOpenSchedule
663 //
664 this.ctxOpenSchedule.DefaultItem = true;
665 this.ctxOpenSchedule.Index = 0;
666 this.ctxOpenSchedule.Text = "&Open Schedule";
667 this.ctxOpenSchedule.Click += new System.EventHandler(this.ctxOpenSchedule_Click);
668 //
669 // ctxEditAvailability
670 //
671 this.ctxEditAvailability.Index = 1;
672 this.ctxEditAvailability.Text = "&Edit Resource Availability";
673 this.ctxEditAvailability.Click += new System.EventHandler(this.ctxEditAvailability_Click);
674 //
675 // ctxProperties
676 //
677 this.ctxProperties.Index = 2;
678 this.ctxProperties.Text = "&Properties";
679 this.ctxProperties.Click += new System.EventHandler(this.ctxProperties_Click);
680 //
681 // ctxFindAppt
682 //
683 this.ctxFindAppt.Index = 3;
684 this.ctxFindAppt.Text = "Find Available Appointment";
685 this.ctxFindAppt.Click += new System.EventHandler(this.ctxFindAppt_Click);
686 //
687 // panelRight
688 //
689 this.panelRight.Controls.Add(this.panelClip);
690 this.panelRight.Dock = System.Windows.Forms.DockStyle.Right;
691 this.panelRight.Location = new System.Drawing.Point(807, 0);
692 this.panelRight.Name = "panelRight";
693 this.panelRight.Size = new System.Drawing.Size(128, 422);
694 this.panelRight.TabIndex = 3;
695 this.panelRight.Visible = false;
696 //
697 // panelClip
698 //
699 this.panelClip.Controls.Add(this.lstClip);
700 this.panelClip.Controls.Add(this.label1);
701 this.panelClip.Dock = System.Windows.Forms.DockStyle.Top;
702 this.panelClip.Location = new System.Drawing.Point(0, 0);
703 this.panelClip.Name = "panelClip";
704 this.panelClip.Size = new System.Drawing.Size(128, 448);
705 this.panelClip.TabIndex = 0;
706 //
707 // lstClip
708 //
709 this.lstClip.AllowDrop = true;
710 this.lstClip.ContextMenu = this.ctxApptClipMenu;
711 this.lstClip.DisplayMember = "PatientName";
712 this.lstClip.Dock = System.Windows.Forms.DockStyle.Fill;
713 this.lstClip.Location = new System.Drawing.Point(0, 32);
714 this.lstClip.Name = "lstClip";
715 this.lstClip.Size = new System.Drawing.Size(128, 407);
716 this.lstClip.TabIndex = 0;
717 this.lstClip.SelectedIndexChanged += new System.EventHandler(this.lstClip_SelectedIndexChanged);
718 this.lstClip.DragDrop += new System.Windows.Forms.DragEventHandler(this.lstClip_DragDrop);
719 this.lstClip.MouseMove += new System.Windows.Forms.MouseEventHandler(this.lstClip_MouseMove);
720 this.lstClip.MouseDown += new System.Windows.Forms.MouseEventHandler(this.lstClip_MouseDown);
721 this.lstClip.DragEnter += new System.Windows.Forms.DragEventHandler(this.lstClip_DragEnter);
722 //
723 // ctxApptClipMenu
724 //
725 this.ctxApptClipMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
726 this.mnuRemoveClipItem,
727 this.mnuClearClipItems});
728 this.ctxApptClipMenu.Popup += new System.EventHandler(this.ctxApptClipMenu_Popup);
729 //
730 // mnuRemoveClipItem
731 //
732 this.mnuRemoveClipItem.Index = 0;
733 this.mnuRemoveClipItem.Text = "Remove Item";
734 this.mnuRemoveClipItem.Click += new System.EventHandler(this.mnuRemoveClipItem_Click);
735 //
736 // mnuClearClipItems
737 //
738 this.mnuClearClipItems.Index = 1;
739 this.mnuClearClipItems.Text = "Clear All";
740 this.mnuClearClipItems.Click += new System.EventHandler(this.mnuClearClipItems_Click);
741 //
742 // label1
743 //
744 this.label1.Dock = System.Windows.Forms.DockStyle.Top;
745 this.label1.Location = new System.Drawing.Point(0, 0);
746 this.label1.Name = "label1";
747 this.label1.Size = new System.Drawing.Size(128, 32);
748 this.label1.TabIndex = 1;
749 this.label1.Text = "Appointment Clipboard";
750 this.label1.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
751 //
752 // panelTop
753 //
754 this.panelTop.Controls.Add(this.dateTimePicker1);
755 this.panelTop.Controls.Add(this.lblResource);
756 this.panelTop.Dock = System.Windows.Forms.DockStyle.Top;
757 this.panelTop.Location = new System.Drawing.Point(128, 0);
758 this.panelTop.Name = "panelTop";
759 this.panelTop.Size = new System.Drawing.Size(679, 24);
760 this.panelTop.TabIndex = 6;
761 //
762 // dateTimePicker1
763 //
764 this.dateTimePicker1.Dock = System.Windows.Forms.DockStyle.Right;
765 this.dateTimePicker1.DropDownAlign = System.Windows.Forms.LeftRightAlignment.Right;
766 this.dateTimePicker1.Format = System.Windows.Forms.DateTimePickerFormat.Short;
767 this.dateTimePicker1.Location = new System.Drawing.Point(551, 0);
768 this.dateTimePicker1.Name = "dateTimePicker1";
769 this.dateTimePicker1.Size = new System.Drawing.Size(128, 20);
770 this.dateTimePicker1.TabIndex = 1;
771 this.dateTimePicker1.ValueChanged += new System.EventHandler(this.dateTimePicker1_ValueChanged);
772 //
773 // lblResource
774 //
775 this.lblResource.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
776 this.lblResource.ForeColor = System.Drawing.SystemColors.Highlight;
777 this.lblResource.Location = new System.Drawing.Point(8, 5);
778 this.lblResource.Name = "lblResource";
779 this.lblResource.Size = new System.Drawing.Size(456, 19);
780 this.lblResource.TabIndex = 2;
781 this.lblResource.Text = "lblResource";
782 //
783 // panelCenter
784 //
785 this.panelCenter.Controls.Add(this.calendarGrid1);
786 this.panelCenter.Dock = System.Windows.Forms.DockStyle.Fill;
787 this.panelCenter.Location = new System.Drawing.Point(136, 24);
788 this.panelCenter.Name = "panelCenter";
789 this.panelCenter.Size = new System.Drawing.Size(668, 374);
790 this.panelCenter.TabIndex = 7;
791 //
792 // calendarGrid1
793 //
794 this.calendarGrid1.AllowDrop = true;
795 this.calendarGrid1.Appointments = null;
796 this.calendarGrid1.ApptDragSource = null;
797 this.calendarGrid1.AutoScroll = true;
798 this.calendarGrid1.AutoScrollMinSize = new System.Drawing.Size(600, 1898);
799 this.calendarGrid1.AvailabilityArray = null;
800 this.calendarGrid1.BackColor = System.Drawing.SystemColors.Window;
801 this.calendarGrid1.Columns = 5;
802 this.calendarGrid1.ContextMenu = this.ctxCalendarGrid;
803 this.calendarGrid1.Dock = System.Windows.Forms.DockStyle.Fill;
804 this.calendarGrid1.DrawWalkIns = true;
805 this.calendarGrid1.GridBackColor = null;
806 this.calendarGrid1.GridEnter = false;
807 this.calendarGrid1.Location = new System.Drawing.Point(0, 0);
808 this.calendarGrid1.Name = "calendarGrid1";
809 this.calendarGrid1.Resources = ((System.Collections.ArrayList)(resources.GetObject("calendarGrid1.Resources")));
810 this.calendarGrid1.SelectedAppointment = 0;
811 this.calendarGrid1.Size = new System.Drawing.Size(668, 374);
812 this.calendarGrid1.StartDate = new System.DateTime(2003, 1, 27, 0, 0, 0, 0);
813 this.calendarGrid1.TabIndex = 0;
814 this.calendarGrid1.TimeScale = 20;
815 this.calendarGrid1.DoubleClick += new System.EventHandler(this.calendarGrid1_DoubleClick);
816 this.calendarGrid1.CGSelectionChanged += new IndianHealthService.ClinicalScheduling.CGSelectionChangedHandler(this.calendarGrid1_CGSelectionChanged);
817 this.calendarGrid1.CGAppointmentChanged += new IndianHealthService.ClinicalScheduling.CGAppointmentChangedHandler(this.calendarGrid1_CGAppointmentChanged);
818 this.calendarGrid1.CGAppointmentAdded += new IndianHealthService.ClinicalScheduling.CGAppointmentChangedHandler(this.calendarGrid1_CGAppointmentAdded);
819 //
820 // ctxCalendarGrid
821 //
822 this.ctxCalendarGrid.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
823 this.ctxCalGridAdd,
824 this.ctxCalGridEdit,
825 this.ctxCalGridDelete,
826 this.ctxCalGridCheckIn,
827 this.menuItem2,
828 this.ctxCalGridNoShow,
829 this.ctxCalGridNoShowUndo,
830 this.menuItem9,
831 this.ctxCalGridWalkin});
832 this.ctxCalendarGrid.Popup += new System.EventHandler(this.ctxCalendarGrid_Popup);
833 //
834 // ctxCalGridAdd
835 //
836 this.ctxCalGridAdd.Index = 0;
837 this.ctxCalGridAdd.Text = "Add Appointment";
838 this.ctxCalGridAdd.Click += new System.EventHandler(this.ctxCalGridAdd_Click);
839 //
840 // ctxCalGridEdit
841 //
842 this.ctxCalGridEdit.Index = 1;
843 this.ctxCalGridEdit.Text = "Edit Appointment";
844 this.ctxCalGridEdit.Click += new System.EventHandler(this.ctxCalGridEdit_Click);
845 //
846 // ctxCalGridDelete
847 //
848 this.ctxCalGridDelete.Index = 2;
849 this.ctxCalGridDelete.Text = "Cancel Appointment";
850 this.ctxCalGridDelete.Click += new System.EventHandler(this.ctxCalGridDelete_Click);
851 //
852 // ctxCalGridCheckIn
853 //
854 this.ctxCalGridCheckIn.Index = 3;
855 this.ctxCalGridCheckIn.Text = "Check In Patient";
856 this.ctxCalGridCheckIn.Click += new System.EventHandler(this.ctxCalGridCheckIn_Click);
857 //
858 // menuItem2
859 //
860 this.menuItem2.Index = 4;
861 this.menuItem2.Text = "-";
862 //
863 // ctxCalGridNoShow
864 //
865 this.ctxCalGridNoShow.Index = 5;
866 this.ctxCalGridNoShow.Text = "Mark as No Show";
867 this.ctxCalGridNoShow.Click += new System.EventHandler(this.ctxCalGridNoShow_Click);
868 //
869 // ctxCalGridNoShowUndo
870 //
871 this.ctxCalGridNoShowUndo.Index = 6;
872 this.ctxCalGridNoShowUndo.Text = "Undo NoShow";
873 this.ctxCalGridNoShowUndo.Click += new System.EventHandler(this.ctxCalGridNoShowUndo_Click);
874 //
875 // menuItem9
876 //
877 this.menuItem9.Index = 7;
878 this.menuItem9.Text = "-";
879 //
880 // ctxCalGridWalkin
881 //
882 this.ctxCalGridWalkin.Index = 8;
883 this.ctxCalGridWalkin.Text = "Create Wal&k-In Appointment";
884 this.ctxCalGridWalkin.Click += new System.EventHandler(this.ctxCalGridWalkin_Click);
885 //
886 // panelBottom
887 //
888 this.panelBottom.Controls.Add(this.statusBar1);
889 this.panelBottom.Dock = System.Windows.Forms.DockStyle.Bottom;
890 this.panelBottom.Location = new System.Drawing.Point(136, 398);
891 this.panelBottom.Name = "panelBottom";
892 this.panelBottom.Size = new System.Drawing.Size(668, 24);
893 this.panelBottom.TabIndex = 8;
894 //
895 // statusBar1
896 //
897 this.statusBar1.Dock = System.Windows.Forms.DockStyle.Fill;
898 this.statusBar1.Location = new System.Drawing.Point(0, 0);
899 this.statusBar1.Name = "statusBar1";
900 this.statusBar1.Size = new System.Drawing.Size(668, 24);
901 this.statusBar1.SizingGrip = false;
902 this.statusBar1.TabIndex = 0;
903 //
904 // splitter1
905 //
906 this.splitter1.Location = new System.Drawing.Point(128, 24);
907 this.splitter1.Name = "splitter1";
908 this.splitter1.Size = new System.Drawing.Size(8, 398);
909 this.splitter1.TabIndex = 9;
910 this.splitter1.TabStop = false;
911 //
912 // splitter2
913 //
914 this.splitter2.Dock = System.Windows.Forms.DockStyle.Right;
915 this.splitter2.Location = new System.Drawing.Point(804, 24);
916 this.splitter2.Name = "splitter2";
917 this.splitter2.Size = new System.Drawing.Size(3, 398);
918 this.splitter2.TabIndex = 10;
919 this.splitter2.TabStop = false;
920 //
921 // CGView
922 //
923 this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
924 this.ClientSize = new System.Drawing.Size(935, 422);
925 this.Controls.Add(this.panelCenter);
926 this.Controls.Add(this.panelBottom);
927 this.Controls.Add(this.splitter2);
928 this.Controls.Add(this.splitter1);
929 this.Controls.Add(this.panelTop);
930 this.Controls.Add(this.panelRight);
931 this.Controls.Add(this.tvSchedules);
932 this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
933 this.Menu = this.mainMenu1;
934 this.Name = "CGView";
935 this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
936 this.Text = "CGView";
937 this.CursorChanged += new System.EventHandler(this.CGView_CursorChanged);
938 this.Load += new System.EventHandler(this.CGView_Load);
939 this.Activated += new System.EventHandler(this.CGView_Activated);
940 this.Closing += new System.ComponentModel.CancelEventHandler(this.CGView_Closing);
941 this.panelRight.ResumeLayout(false);
942 this.panelClip.ResumeLayout(false);
943 this.panelTop.ResumeLayout(false);
944 this.panelCenter.ResumeLayout(false);
945 this.panelBottom.ResumeLayout(false);
946 this.ResumeLayout(false);
947
948 }
949 #endregion
950
951 #region Fields
952
953 private CGDocument m_Document;
954 private CGDocumentManager m_DocManager;
955 private int m_nSlots;
956 bool bSchedulesClicked = false;
957 private ArrayList m_alSelectedTreeResourceArray = new ArrayList();
958 private string m_sDocName;
959 private CGAppointments m_ClipList;
960 private bool m_bDragDropStart = false;
961 private Hashtable m_htOverbook;
962 private Hashtable m_htModifySchedule;
963 private Hashtable m_htChangeAppts;
964 private BMXNetConnectInfo m_ConnectInfo = null;
965 public BMXNetConnectInfo.BMXNetEventDelegate BMXNetEvent;
966
967 #endregion Fields
968
969 #region Properties
970
971 /// <summary>
972 /// Access the CalendarGrid associated with this view
973 /// </summary>
974 public CalendarGrid CGrid
975 {
976 get
977 {
978 return this.calendarGrid1;
979 }
980 }
981
982 /// <summary>
983 /// Accesses the document associated with this view
984 /// </summary>
985 public CGDocument Document
986 {
987 get
988 {
989 return this.m_Document;
990 }
991 set
992 {
993 this.m_Document = value;
994 }
995 }
996
997 public CGDocumentManager DocManager
998 {
999 get
1000 {
1001 return m_DocManager;
1002 }
1003 set
1004 {
1005 m_DocManager = value;
1006 }
1007 }
1008
1009 public DateTime StartDate
1010 {
1011 get
1012 {
1013 return this.calendarGrid1.StartDate;
1014 }
1015 set
1016 {
1017 this.calendarGrid1.StartDate = value;
1018 }
1019 }
1020
1021 public CGAppointments Appointments
1022 {
1023 get
1024 {
1025 return this.calendarGrid1.Appointments;
1026 }
1027 set
1028 {
1029 this.calendarGrid1.Appointments = value;
1030 }
1031 }
1032
1033
1034 #endregion
1035
1036 #region AppointmentMenu Handlers
1037
1038 private void mnuAppointment_Popup(object sender, System.EventArgs e)
1039 {
1040 bool bEnabled = (this.Document.Resources.Count > 0)? true : false ;
1041 this.mnuFindAppt.Enabled = bEnabled;
1042
1043 //Toggle availability of make, edit, checkin and delete appointments
1044 //based on whether a range is selected.
1045
1046 mnuNewAppointment.Enabled = AddAppointmentEnabled();
1047 this.mnuWalkIn.Enabled = mnuNewAppointment.Enabled;
1048 bool bEditAppointments = this.EditAppointmentEnabled();
1049
1050 mnuDeleteAppointment.Enabled = bEditAppointments;
1051 mnuCheckIn.Enabled = bEditAppointments;
1052 mnuEditAppointment.Enabled = bEditAppointments;
1053 mnuNoShow.Enabled = bEditAppointments;
1054 mnuNoShowUndo.Enabled = bEditAppointments;
1055 }
1056
1057 private void mnuCheckIn_Click(object sender, System.EventArgs e)
1058 {
1059 AppointmentCheckIn();
1060 }
1061
1062 private void mnuCopyAppointment_Click(object sender, System.EventArgs e)
1063 {
1064 //For each appointment in the grid's selected list,
1065 //add to the clip list
1066 //and add to m_ClipList
1067 try
1068 {
1069 foreach (CGAppointment a in this.calendarGrid1.SelectedAppointments.AppointmentTable.Values)
1070 {
1071 if (m_ClipList.AppointmentTable.Contains((int) a.AppointmentKey))
1072 {
1073 return;
1074 }
1075 m_ClipList.AddAppointment(a);
1076 lstClip.Items.Add(a.PatientName);
1077 }
1078 }
1079 catch (Exception ex)
1080 {
1081 string s = ex.Message;
1082 Debug.Write(s);
1083 return;
1084 }
1085 }
1086
1087 private void mnuDeleteAppointment_Click(object sender, System.EventArgs e)
1088 {
1089 AppointmentDelete();
1090 }
1091
1092 private void mnuEditAppointment_Click(object sender, System.EventArgs e)
1093 {
1094 AppointmentEdit();
1095 }
1096
1097 private void mnuNewAppointment_Click(object sender, System.EventArgs e)
1098 {
1099 AppointmentAddNew();
1100 }
1101
1102 private void mnuNoShow_Click(object sender, System.EventArgs e)
1103 {
1104 AppointmentNoShow(true);
1105 }
1106
1107 private void mnuNoShowUndo_Click(object sender, System.EventArgs e)
1108 {
1109 AppointmentNoShow(false);
1110 }
1111
1112 #endregion AppointmentMenu Handlers
1113
1114 #region ContextMenu1 Handlers
1115
1116 private void contextMenu1_Popup(object sender, System.EventArgs e)
1117 {
1118 //Enable/disable OpenSchedule and Find Appointment options
1119 bool bEnabled = (m_alSelectedTreeResourceArray.Count > 0)? true : false ;
1120 this.ctxOpenSchedule.Enabled = bEnabled;
1121 this.ctxFindAppt.Enabled = bEnabled;
1122
1123 //properties not supported now
1124 this.ctxProperties.Enabled = false;
1125 this.ctxProperties.Visible = false;
1126
1127 //Enable/disable Availability menu option
1128 if (m_alSelectedTreeResourceArray.Count != 1)
1129 {
1130 this.ctxEditAvailability.Enabled = false;
1131 return;
1132 }
1133
1134 if (this.DocManager.ScheduleManager == true)
1135 {
1136 ctxEditAvailability.Enabled = true;
1137 return;
1138 }
1139
1140 string sResource = (string) m_alSelectedTreeResourceArray[0];
1141 DataTable dt = this.DocManager.GlobalDataSet.Tables["ResourceUser"];
1142 DataView dv = new DataView(dt, "", "RESOURCENAME ASC", DataViewRowState.OriginalRows);
1143 string sDuz = this.DocManager.ConnectInfo.DUZ;
1144 bool bModSchedule = false;
1145 DataRowView[] drvA = dv.FindRows(sResource);
1146 if (drvA.Length == 0)
1147 {
1148 this.ctxEditAvailability.Enabled = false;
1149 }
1150 else
1151 {
1152 string sModSchedule = "NO";
1153 foreach (DataRowView drv in drvA)
1154 {
1155 if (drv["USERID"].ToString() == sDuz)
1156 {
1157 sModSchedule = drv["MODIFY_SCHEDULE"].ToString();
1158 break;
1159 }
1160 }
1161
1162 bModSchedule = (sModSchedule == "YES")?true:false;
1163 this.ctxEditAvailability.Enabled = bModSchedule;
1164 }
1165 }
1166
1167 private void ctxEditAvailability_Click(object sender, System.EventArgs e)
1168 {
1169 this.EditScheduleAvailability();
1170 }
1171
1172 private void ctxOpenSchedule_Click(object sender, System.EventArgs e)
1173 {
1174 OpenSelectedSchedule(m_alSelectedTreeResourceArray, DateTime.Today);
1175 }
1176
1177 private void ctxProperties_Click(object sender, System.EventArgs e)
1178 {
1179 //TODO: Implement Properties dialog
1180 MessageBox.Show("TODO: Implement Properties dialog");
1181 }
1182
1183 private void ctxFindAppt_Click(object sender, System.EventArgs e)
1184 {
1185 FindAvailableAppointment(m_alSelectedTreeResourceArray);
1186 }
1187
1188 #endregion ContextMenu1 Handlers
1189
1190 #region ctxApptClipMenu Handlers
1191
1192 private void mnuClearClipItems_Click(object sender, System.EventArgs e)
1193 {
1194 this.m_ClipList.ClearAllAppointments();
1195 lstClip.Items.Clear();
1196 }
1197
1198 private void mnuRemoveClipItem_Click(object sender, System.EventArgs e)
1199 {
1200 int i = lstClip.SelectedIndex;
1201 CGAppointment a = (CGAppointment) lstClip.SelectedItem;
1202 int nKey = a.AppointmentKey;
1203 if (i > -1)
1204 {
1205 m_ClipList.RemoveAppointment(nKey);
1206 lstClip.Items.RemoveAt(i);
1207 }
1208 }
1209
1210 private void ctxApptClipMenu_Popup(object sender, System.EventArgs e)
1211 {
1212 mnuClearClipItems.Enabled = (m_ClipList.AppointmentTable.Count > 0);
1213 mnuRemoveClipItem.Enabled = (lstClip.SelectedIndex > -1);
1214 }
1215
1216 #endregion ctxApptClipMenu Handlers
1217
1218 #region ctxCalGridMenu Handlers
1219
1220 private void ctxCalendarGrid_Popup(object sender, System.EventArgs e)
1221 {
1222 //Toggle availability of make, edit, checkin and delete appointments
1223 //based on whether appropriate element is selected.
1224 ctxCalGridAdd.Enabled = AddAppointmentEnabled();
1225 bool bEditAppointments = (EditAppointmentEnabled() && (calendarGrid1.SelectedAppointment > 0)) ;
1226 ctxCalGridDelete.Enabled = bEditAppointments;
1227 ctxCalGridEdit.Enabled = bEditAppointments;
1228 ctxCalGridCheckIn.Enabled = bEditAppointments;
1229 ctxCalGridNoShow.Enabled = bEditAppointments;
1230 ctxCalGridNoShowUndo.Enabled = bEditAppointments;
1231 ctxCalGridWalkin.Enabled = ctxCalGridAdd.Enabled;
1232 }
1233
1234 private void ctxCalGridAdd_Click(object sender, System.EventArgs e)
1235 {
1236 AppointmentAddNew();
1237 }
1238
1239 private void calendarGrid1_DoubleClick(object sender, System.EventArgs e)
1240 {
1241 if (calendarGrid1.SelectedAppointment > 0)
1242 AppointmentEdit();
1243 }
1244
1245 private void ctxCalGridEdit_Click(object sender, System.EventArgs e)
1246 {
1247 AppointmentEdit();
1248 }
1249
1250 private void ctxCalGridDelete_Click(object sender, System.EventArgs e)
1251 {
1252 AppointmentDelete();
1253 }
1254
1255 private void ctxCalGridCheckIn_Click(object sender, System.EventArgs e)
1256 {
1257 AppointmentCheckIn();
1258 }
1259
1260 private void ctxCalGridNoShow_Click(object sender, System.EventArgs e)
1261 {
1262 AppointmentNoShow(true);
1263 }
1264
1265 private void ctxCalGridNoShowUndo_Click(object sender, System.EventArgs e)
1266 {
1267 AppointmentNoShow(false);
1268 }
1269
1270 #endregion ctxCalGridMenu Handlers
1271
1272 #region Methods
1273
1274 private bool EditAppointmentEnabled()
1275 {
1276 try
1277 {
1278 //Call here if there is a selected appointment in the grid
1279 if (calendarGrid1.SelectedAppointment < 1)
1280 return false;
1281 CGAppointment appt = (CGAppointment)this.Appointments.AppointmentTable[calendarGrid1.SelectedAppointment];
1282 string sResource = appt.Resource;
1283 return EditAppointmentEnabled(sResource);
1284
1285 }
1286 catch (Exception ex)
1287 {
1288 string sMsg = ex.Message;
1289 return false;
1290 }
1291 }
1292
1293 private bool EditAppointmentEnabled(string sResource)
1294 {
1295
1296 bool bManager = this.DocManager.ScheduleManager;
1297 if (bManager == true)
1298 {
1299 return (true);
1300 }
1301 else
1302 {
1303 bool bModAppts;
1304 bModAppts = (bool)this.m_htChangeAppts[sResource];
1305 return bModAppts;
1306 }
1307 }
1308
1309 private bool AddAppointmentEnabled()
1310 {
1311 if (this.calendarGrid1.SelectedRange.Cells.CellCount < 1)
1312 return false;
1313
1314 bool bManager = this.DocManager.ScheduleManager;
1315 if (bManager == true)
1316 {
1317 return (true);
1318 }
1319 else
1320 {
1321 DateTime dStart = DateTime.Today;
1322 DateTime dEnd = DateTime.Today;
1323 string sResource = "";
1324 bool bRet = this.calendarGrid1.GetSelectedTime(out dStart, out dEnd, out sResource);
1325 if (bRet == false)
1326 {
1327 return false;
1328 }
1329 bool bSlotsAvailable;
1330 bool bOverbook;
1331 bool bModSchedule;
1332 bool bModAppts;
1333 bOverbook = (bool)this.m_htOverbook[sResource];
1334 bModSchedule = (bool)this.m_htModifySchedule[sResource];
1335 bModAppts = (bool)this.m_htChangeAppts[sResource];
1336 if (bModAppts == false)
1337 return false;
1338
1339 bSlotsAvailable = (this.m_nSlots > 0);
1340 return ((bSlotsAvailable) || (bModSchedule) || (bOverbook));
1341 }
1342 }
1343
1344 /// <summary>
1345 /// Clean up any resources being used.
1346 /// </summary>
1347 protected override void Dispose( bool disposing )
1348 {
1349 if( disposing )
1350 {
1351 if(components != null)
1352 {
1353 components.Dispose();
1354 }
1355 }
1356 base.Dispose( disposing );
1357 }
1358
1359 void UpdateStatusBar(DateTime dStart, DateTime dEnd, string sAccessType, string sAvailabilityMessage)
1360 {
1361 string sMsg = dStart.ToShortTimeString() + " to " + dEnd.ToShortTimeString();
1362 if (m_nSlots > 0)
1363 {
1364 sMsg = sMsg + ": " + m_nSlots.ToString() + " slot";
1365 sMsg = sMsg + ((m_nSlots > 1)?"s " : " ");
1366 sMsg = sMsg + "available";
1367 if (sAccessType != "")
1368 {
1369 sMsg = sMsg + " for " + sAccessType;
1370 }
1371 sMsg = sMsg + ".";
1372 if (sAvailabilityMessage != "")
1373 {
1374 sMsg = sMsg + " Note: " + sAvailabilityMessage;
1375 }
1376 }
1377 else
1378 {
1379 sMsg += ": No appointment slots available.";
1380 }
1381
1382 this.statusBar1.Text = sMsg;
1383 }
1384
1385 private void EditScheduleAvailability()
1386 {
1387 CGAVDocument doc = new CGAVDocument();
1388 try
1389 {
1390 //If resource already open, then navigate to its window
1391 CGAVView v =this.DocManager.GetAVViewByResource(m_alSelectedTreeResourceArray);
1392
1393 if (v != null)
1394 {
1395 v.Activate();
1396 }
1397 else
1398 {
1399 //If not already open, get a lock and open it
1400 doc.DocManager = this.DocManager;
1401 for (int j=0; j < m_alSelectedTreeResourceArray.Count; j++)
1402 {
1403 doc.AddResource((string) m_alSelectedTreeResourceArray[j]);
1404 }
1405 doc.DocName = this.m_sDocName;
1406
1407 //Get preferred time scale from resource info
1408
1409 DataTable dt = this.DocManager.GlobalDataSet.Tables["Resources"];
1410 DataView dv = new DataView(dt, "", "RESOURCE_NAME ASC", DataViewRowState.OriginalRows);
1411 int nScale = 60;
1412 int nTest=0;
1413 string sResource;
1414 int nDataRow;
1415 DataRowView drv;
1416 string sResourceID="";
1417 for (int j=0; j < m_alSelectedTreeResourceArray.Count; j++)
1418 {
1419 sResource = (string) m_alSelectedTreeResourceArray[j];
1420 nDataRow = dv.Find(sResource);
1421 Debug.Assert(nDataRow != -1);
1422 drv = dv[nDataRow];
1423 if (drv["TIMESCALE"].ToString() == "")
1424 {
1425 nTest = 15; //15 minute default
1426 }
1427 else
1428 {
1429 nTest = (int) drv["TIMESCALE"];
1430 }
1431 nScale = (nTest < nScale)?nTest : nScale ;
1432 sResourceID = drv["RESOURCEID"].ToString();
1433 }
1434
1435 doc.ResourceID = Convert.ToInt32(sResourceID);
1436
1437 bool bLock = DocManager.ConnectInfo.bmxNetLib.Lock("^BSDXRES(" + sResourceID + ")", "+");
1438 if (bLock == false)
1439 {
1440 throw new BMXNetException("Another user is currently editing availability for this resource. Try later.");
1441 }
1442
1443 doc.OnOpenDocument();
1444 v =this.DocManager.GetAVViewByResource(m_alSelectedTreeResourceArray);
1445 CalendarGrid cg = v.CGrid;
1446
1447 cg.TimeScale = nScale;
1448
1449 //Position grid to 0700
1450 PositionGrid(cg, 7);
1451 }
1452 }
1453 catch (Exception ex)
1454 {
1455 MessageBox.Show("Unable to edit availability for " + m_sDocName + " schedule. " + ex.Message, "Clinical Scheduling");
1456 this.m_DocManager.CloseAllViews(doc);
1457 return;
1458 }
1459 }
1460
1461 private void OpenSelectedSchedule(ArrayList sSelectedTreeResourceArray, DateTime dDate)
1462 {
1463 //If resource already open, then navigate to its window
1464 CGDocument doc;
1465 CGView v =this.DocManager.GetViewByResource(sSelectedTreeResourceArray);
1466 if (v != null)
1467 {
1468 v.Activate();
1469 v.dateTimePicker1.Value = dDate;
1470 }
1471 else
1472 {
1473 //If not already open, open it
1474 //If current document has a resource, then open a new window
1475 //with the selected resource.
1476 //Otherwise just use the current document.
1477 if (this.Document.m_sResourcesArray.Count > 0)
1478 {
1479 doc = new CGDocument();
1480 doc.DocManager = this.DocManager;
1481 }
1482 else
1483 {
1484 doc = this.Document;
1485 }
1486 for (int j=0; j < sSelectedTreeResourceArray.Count; j++)
1487 {
1488 doc.AddResource((string) sSelectedTreeResourceArray[j]);
1489 }
1490 doc.DocName = this.m_sDocName;
1491 try
1492 {
1493 doc.OnOpenDocument();
1494 }
1495 catch (Exception ex)
1496 {
1497 MessageBox.Show("Unable to open " + m_sDocName + " schedule. " + ex.Message, "Clinical Scheduling");
1498 this.m_DocManager.CloseAllViews(doc);
1499 return;
1500 }
1501 v =this.DocManager.GetViewByResource(sSelectedTreeResourceArray);
1502 v.dateTimePicker1.Value = dDate;
1503
1504 //Get preferred time scale from resource info
1505 //If more than one resource, get smallest time scale
1506 CalendarGrid cg = v.CGrid;
1507 DataTable dt = this.DocManager.GlobalDataSet.Tables["Resources"];
1508 DataView dv = new DataView(dt, "", "RESOURCE_NAME ASC", DataViewRowState.OriginalRows);
1509 int nScale = 60;
1510 int nTest=0;
1511 string sResource;
1512 int nDataRow;
1513 DataRowView drv;
1514 for (int j=0; j < sSelectedTreeResourceArray.Count; j++)
1515 {
1516 sResource = (string) sSelectedTreeResourceArray[j];
1517 nDataRow = dv.Find(sResource);
1518 Debug.Assert(nDataRow != -1);
1519 drv = dv[nDataRow];
1520 if (drv["TIMESCALE"].ToString() == "")
1521 {
1522 nTest = 15; //15 minute default
1523 }
1524 else
1525 {
1526 nTest = (int) drv["TIMESCALE"];
1527 }
1528 nScale = (nTest < nScale)?nTest : nScale ;
1529 }
1530
1531 cg.TimeScale = nScale;
1532
1533 PositionGrid(cg, 7);
1534
1535 //Get the OverBook and ModifySchedule permissions from ResourceUser table
1536 //and populate the hashtables
1537 string sOverbook;
1538 string sModSchedule;
1539 string sModAppts;
1540 bool bOverbook;
1541 bool bModSchedule;
1542 bool bModAppts;
1543 v.m_htOverbook = new Hashtable(sSelectedTreeResourceArray.Count);
1544 v.m_htModifySchedule = new Hashtable(sSelectedTreeResourceArray.Count);
1545 v.m_htChangeAppts = new Hashtable(sSelectedTreeResourceArray.Count);
1546 dt = this.DocManager.GlobalDataSet.Tables["ResourceUser"];
1547 dv = new DataView(dt, "", "RESOURCENAME ASC", DataViewRowState.OriginalRows);
1548 dv.RowFilter = "USERNAME = '" + this.DocManager.ConnectInfo.UserName + "'";
1549 for (int j=0; j < dv.Count; j++)
1550 {
1551 drv = dv[j];
1552 sResource = drv["RESOURCENAME"].ToString();
1553 sOverbook = drv["OVERBOOK"].ToString();
1554 bOverbook = (sOverbook == "YES")?true:false;
1555 sModSchedule = drv["MODIFY_SCHEDULE"].ToString();
1556 bModSchedule = (sModSchedule == "YES")?true:false;
1557 sModAppts = drv["MODIFY_APPOINTMENTS"].ToString();
1558 bModAppts = (sModAppts == "YES")?true:false;
1559 v.m_htOverbook[sResource] = bOverbook;
1560 v.m_htModifySchedule[sResource] = bModSchedule;
1561 v.m_htChangeAppts[sResource] = bModAppts;
1562 }
1563
1564 //For programmers and scheduling managers, set all permissions for all resources
1565 if (this.DocManager.ScheduleManager == true)
1566 {
1567 dt = this.DocManager.GlobalDataSet.Tables["Resources"];
1568 foreach (DataRow dr in dt.Rows)
1569 {
1570 sResource = dr["RESOURCE_NAME"].ToString();
1571 v.m_htOverbook[sResource] = true;
1572 v.m_htModifySchedule[sResource] = true;
1573 v.m_htChangeAppts[sResource] = true;
1574 }
1575 }
1576
1577 v.calendarGrid1.SetOverlapTable();
1578 v.calendarGrid1.Refresh();
1579 }
1580 }
1581
1582 private void PositionGrid(CalendarGrid cg, int nHour)
1583 {
1584 //Position grid to nHour
1585 int nRow = 0, nCol = 0;
1586 DateTime dStart = DateTime.Today;
1587 dStart = dStart.AddHours(nHour);
1588 cg.GetCellFromTime(dStart, ref nRow, ref nCol, false, "");
1589 int nHeight = cg.CellHeight + 10;
1590 nHeight *= nRow;
1591 cg.AutoScrollPosition = new Point(50, nHeight);
1592 cg.Invalidate();
1593 }
1594
1595 private void LoadTree()
1596 {
1597 //Navigate from ResourceGroup table to Resources table
1598 DataRow[] arrRows;
1599 DataRelation dr = DocManager.GlobalDataSet.Relations["GroupResource"];
1600 string sGroup;
1601 string sResource;
1602 int nIndex = 0;
1603 foreach (DataRow r in DocManager.GlobalDataSet.Tables["ResourceGroup"].Rows)
1604 {
1605 sGroup = r["RESOURCE_GROUP"].ToString();
1606 TreeNode deptNode = new TreeNode(sGroup);
1607 nIndex = this.tvSchedules.Nodes.Add(deptNode);
1608 tvSchedules.Nodes[nIndex].Tag = "Dept";
1609 arrRows = r.GetChildRows(dr);
1610 for (int i=0; i< arrRows.Length; i++)
1611 {
1612 sResource = arrRows[i]["RESOURCE_NAME"].ToString();
1613 TreeNode resNode = new TreeNode(sResource);
1614 int nResIndex = deptNode.Nodes.Add(resNode);
1615 deptNode.Nodes[nResIndex].Tag = "Resource";
1616 }
1617 }
1618 }
1619
1620 public void CreateNewSchedule()
1621 {
1622 //Create a new document and open it
1623 CGDocument doc = new CGDocument();
1624 doc.DocManager = this.DocManager;
1625 try
1626 {
1627 doc.OnOpenDocument();
1628 }
1629 catch (Exception ex)
1630 {
1631 MessageBox.Show("Unable to open " + m_sDocName + " schedule. " + ex.Message, "Clinical Scheduling");
1632 this.m_DocManager.CloseAllViews(doc);
1633 return;
1634 }
1635 }
1636
1637 private void AppointmentEdit()
1638 {
1639 try
1640 {
1641 int nApptID = this.calendarGrid1.SelectedAppointment;
1642 Debug.Assert(nApptID != 0);
1643
1644 CGAppointment a = (CGAppointment) this.Appointments.AppointmentTable[nApptID];
1645
1646 DAppointPage dAppt = new DAppointPage();
1647 dAppt.DocManager = this.m_DocManager;
1648 dAppt.InitializePage(a);
1649
1650 calendarGrid1.CGToolTip.Active = false;
1651
1652 if (dAppt.ShowDialog(this) == DialogResult.Cancel)
1653 {
1654 calendarGrid1.CGToolTip.Active = true;
1655 return;
1656 }
1657 calendarGrid1.CGToolTip.Active = true;
1658
1659 string sNote = dAppt.Note;
1660
1661 //Call Document to edit appointment
1662 this.Document.EditAppointment(a, sNote);
1663
1664 }
1665 catch (Exception ex)
1666 {
1667 Debug.Write("CGView.AppointmentEdit Failed: " + ex.Message);
1668 }
1669 }
1670
1671 /// <summary>
1672 /// Marks all selected appointments as No Show
1673 /// </summary>
1674 /// <param name="nApptID"></param>
1675 /// <returns></returns>
1676 private void AppointmentNoShow(bool bNoShow)
1677 {
1678
1679 //bNoShow indicates whether to mark or un-mark as noshow
1680 bool bMarked = false; //Indicates at least one attempt to mark as noshow succeeded
1681 bool bRebook = false; //Stores user's response to auto-rebook dialog question
1682 CGAppointments alRebookList = new CGAppointments();
1683 DNoShow dlg = new DNoShow();;
1684 if (bNoShow == true)
1685 {
1686 if (dlg.ShowDialog(this) == DialogResult.Cancel)
1687 {
1688 return;
1689 }
1690 }
1691
1692 bRebook = dlg.AutoRebook;
1693
1694 foreach (CGAppointment a in this.calendarGrid1.SelectedAppointments.AppointmentTable.Values)
1695 {
1696 int nApptID = a.AppointmentKey;
1697 Debug.Assert(nApptID != 0);
1698 try
1699 {
1700 if ((bNoShow == true)
1701 &&
1702 (a.StartTime.Date > DateTime.Today.Date)
1703 &&
1704 (MessageBox.Show(this, "The appointment for " + a.PatientName + " is in the future. Are you sure you want to No-Show?", "Windows Scheduling", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK))
1705 {
1706 }
1707 else
1708 {
1709 string sError = Document.AppointmentNoShow(nApptID, bNoShow);
1710 if (sError != "1")
1711 throw new Exception(sError);
1712
1713 bMarked = true;
1714 }
1715 }
1716 catch (Exception ex)
1717 {
1718 MessageBox.Show("Unable to mark appointment No Show: " + ex.Message, "Clinical Scheduling");
1719 }
1720 if (bRebook == true)
1721 {
1722 try
1723 {
1724 CGAppointment aRebook;
1725 int nMinimumdays = dlg.RebookStartDays;
1726 int nMaximumdays = dlg.RebookMaxDays;
1727 int nAccessType = dlg.RebookAccessType;
1728 //-1 means use current type
1729
1730 if (nAccessType == -1)
1731 {
1732 //Get access type from grid
1733 int nRow = 0;
1734 int nCol = 0;
1735 CGCell cgCell = new CGCell();
1736 this.calendarGrid1.GetCellFromTime(a.StartTime, ref nRow, ref nCol, true , a.Resource);
1737 cgCell.CellColumn = nCol;
1738 cgCell.CellRow = nRow;
1739 this.calendarGrid1.GetTypeFromCell(cgCell, out nAccessType);
1740 a.AccessTypeID = nAccessType;
1741 }
1742 string sResult = Document.AutoRebook(a, nAccessType, nMinimumdays, nMaximumdays, out aRebook);
1743 if (sResult == "1")
1744 {
1745 //Add appointment to list of rebooked appointments
1746 alRebookList.AddAppointment(a);
1747 }
1748 else
1749 {
1750 MessageBox.Show("Unable to rebook this patient: " + a.PatientName);
1751 }
1752
1753 }
1754 catch (Exception ex)
1755 {
1756 MessageBox.Show("Unable to rebook: " + ex.Message);
1757 }
1758 }
1759 }
1760
1761 if (bMarked == true)
1762 {
1763 //Notify other scheduling users that this schedule has changed
1764 try
1765 {
1766 this.Document.RefreshDocument();
1767 RaiseRPMSEvent("BSDX SCHEDULE" , m_Document.DocName);
1768 }
1769 catch (Exception ex)
1770 {
1771 Debug.Write(ex.Message);
1772 }
1773 this.calendarGrid1.Invalidate();
1774
1775 AutoRebookFromList(alRebookList);
1776 }
1777 }
1778
1779 private void AutoRebookFromList(CGAppointments alRebookList)
1780 {
1781 //Print AutoRebook letters.
1782 if (alRebookList.AppointmentCount > 0)
1783 {
1784 //build |-delimited list of ApptIDs to pass to BSDX REBOOK LIST
1785 string sApptIDList = "";
1786
1787 System.Collections.ArrayList a = new ArrayList();
1788
1789 foreach (CGAppointment appt in alRebookList.AppointmentTable.Values)
1790 {
1791 string sApptID = appt.AppointmentKey.ToString() + "|";
1792 sApptIDList += sApptID;
1793 if (a.Contains(appt.Resource) == false)
1794 a.Add(appt.Resource);
1795 }
1796
1797 // Print rebooks
1798 string sClinicList = "";
1799 foreach (string sRes in a)
1800 {
1801 sClinicList = sClinicList + sRes + "|";
1802 }
1803 DPatientLetter dpl = new DPatientLetter();
1804 dpl.InitializeFormRebookLetters(this.DocManager, sClinicList, sApptIDList);
1805 dpl.ShowDialog(this);
1806 }
1807 }
1808
1809 /// <summary>
1810 /// Delete appointment ApptID
1811 /// </summary>
1812 /// <param name="nApptID"></param>
1813 /// <returns></returns>
1814 private string AppointmentDeleteOne(int nApptID)
1815 {
1816 return Document.DeleteAppointment(nApptID);
1817 }
1818
1819 /// <summary>
1820 /// Delete all selected appointments
1821 /// </summary>
1822 private void AppointmentDelete()
1823 {
1824 calendarGrid1.CGToolTip.Active = false;
1825 CGAppointments alRebookList = new CGAppointments();
1826
1827 DCancelAppt dCancel = new DCancelAppt();
1828 dCancel.InitializePage(this.m_DocManager);
1829 if (dCancel.ShowDialog(this) != DialogResult.OK)
1830 {
1831 calendarGrid1.CGToolTip.Active = true;
1832 return;
1833 }
1834
1835 bool bClinic = dCancel.ClinicCancelled;
1836 int nReason = dCancel.CancelReason;
1837 string sRemarks = dCancel.CancelRemarks;
1838 bool bRebook = dCancel.AutoRebook;
1839 int nRebookStart = dCancel.RebookStartDays;
1840 int nRebookMax = dCancel.RebookMaxDays;
1841 int nRebookAccessType = dCancel.RebookAccessType;
1842
1843 calendarGrid1.CGToolTip.Active = true;
1844
1845 bool bDeleted = false;
1846 foreach (CGAppointment a in this.calendarGrid1.SelectedAppointments.AppointmentTable.Values)
1847 {
1848 int nApptID = a.AppointmentKey;
1849 Debug.Assert(nApptID != 0);
1850 try
1851 {
1852 string sError = Document.DeleteAppointment(nApptID,bClinic, nReason, sRemarks);
1853 if (sError != "")
1854 throw new Exception(sError);
1855
1856 bDeleted = true;
1857 if (bRebook == true)
1858 {
1859 try
1860 {
1861 //TODO: Parameterize or dialogize the minum and maximum rebook days
1862 CGAppointment aRebook;
1863 int nMinimumdays = nRebookStart;
1864 int nMaximumdays = nRebookMax;
1865 string sResult = Document.AutoRebook(a, nRebookAccessType, nMinimumdays, nMaximumdays, out aRebook);
1866 if (sResult == "1")
1867 {
1868 //Add appointment to list of rebooked appointments
1869 alRebookList.AddAppointment(a);
1870 }
1871
1872 }
1873 catch (Exception ex)
1874 {
1875 MessageBox.Show("Unable to rebook: " + ex.Message);
1876 }
1877 }
1878 }
1879 catch (Exception ex)
1880 {
1881 MessageBox.Show("Unable to delete appointment. " + ex.Message, "Clinical Scheduling");
1882 }
1883
1884 }
1885 if (bDeleted == true)
1886 {
1887 try
1888 {
1889 RaiseRPMSEvent("BSDX SCHEDULE" , m_Document.DocName);
1890 }
1891 catch (Exception ex)
1892 {
1893 Debug.Write(ex.Message);
1894 }
1895 this.calendarGrid1.Invalidate();
1896 if (bRebook == true)
1897 {
1898 AutoRebookFromList(alRebookList);
1899 }
1900 }
1901
1902 }
1903
1904 private void AppointmentCheckIn()
1905 {
1906 bool bDeleted = false;
1907 int nApptID = this.calendarGrid1.SelectedAppointment;
1908 Debug.Assert(nApptID != 0);
1909
1910 CGAppointment a = (CGAppointment) this.Appointments.AppointmentTable[nApptID];
1911
1912 try
1913 {
1914
1915 bool bAlreadyCheckedIn = false;
1916 if (a.CheckInTime.Ticks > 0)
1917 bAlreadyCheckedIn = true;
1918
1919 if ((bAlreadyCheckedIn == false)
1920 &&
1921 (a.StartTime.Date > DateTime.Today.Date))
1922 {
1923 MessageBox.Show(this, "It is too early to check in " + a.PatientName, "Windows Scheduling", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
1924 return;
1925 }
1926 //Find the default provider for the resource & load into combo box
1927 DataView rv = new DataView(this.m_DocManager.GlobalDataSet.Tables["Resources"]);
1928 rv.Sort="RESOURCE_NAME ASC";
1929 int nFind = rv.Find((string) a.Resource);
1930 DataRowView drv = rv[nFind];
1931
1932 string sHospLoc = drv["HOSPITAL_LOCATION_ID"].ToString();
1933 sHospLoc = (sHospLoc == "")?"0":sHospLoc;
1934 int nHospLoc = 0;
1935 try
1936 {
1937 nHospLoc = Convert.ToInt32(sHospLoc);
1938 }
1939 catch(Exception ex)
1940 {
1941 Debug.Write("CGView.AppointmentCheckIn Error: " + ex.Message);
1942 }
1943
1944
1945 string sProv = "";
1946 string sProvReqd = "NO";
1947 string sPCC = "NO";
1948 string sMultCodes = "NO";
1949 string sStopCode = "";
1950 bool bProvReqd = false;
1951 bool bPCC = false;
1952 bool bMultCodes = false;
1953 if (nHospLoc > 0)
1954 {
1955 DataRow dr = drv.Row;
1956 DataRow drHL = dr.GetParentRow(m_DocManager.GlobalDataSet.Relations["HospitalLocationResource"]);
1957 sProv = drHL["DEFAULT_PROVIDER"].ToString();
1958 sStopCode = drHL["STOP_CODE_NUMBER"].ToString();
1959
1960
1961 //TODO: Remove this. This doesn't exist in VISTA.
1962 DataRow[] draCS = drHL.GetChildRows(m_DocManager.GlobalDataSet.Relations["HospitalLocationClinic"]);
1963 if (draCS.GetLength(0) > 0)
1964 {
1965 DataRow drCS = draCS[0];
1966 sProvReqd = drCS["VISIT_PROVIDER_REQUIRED"].ToString();
1967 sPCC = drCS["GENERATE_PCCPLUS_FORMS?"].ToString();
1968 sMultCodes = drCS["MULTIPLE_CLINIC_CODES_USED?"].ToString();
1969 }
1970 bProvReqd = (sProvReqd == "YES")?true:false;
1971 bPCC = (sPCC == "YES")?true:false;
1972 bMultCodes = (sMultCodes == "YES")?true:false;
1973 }
1974
1975 DCheckIn dlgCheckin = new DCheckIn();
1976 dlgCheckin.InitializePage(a, this.m_DocManager, sProv, bProvReqd, bPCC, bMultCodes, sStopCode);
1977 calendarGrid1.CGToolTip.Active = false;
1978 if (dlgCheckin.ShowDialog(this) != DialogResult.OK)
1979 {
1980 calendarGrid1.CGToolTip.Active = true;
1981 return;
1982 }
1983 calendarGrid1.CGToolTip.Active = true;
1984
1985 if (bAlreadyCheckedIn == true)
1986 return;
1987
1988 DateTime dtCheckIn = dlgCheckin.CheckInTime;
1989
1990 /*
1991 * Need to pass Provider, ClinicStop, PrintRouteSlip,
1992 * PCC Clinic, PCC Form, Print OutGuide
1993 */
1994
1995 this.Document.CheckInAppointment(nApptID, dtCheckIn,
1996 dlgCheckin.ClinicStopIEN,
1997 dlgCheckin.ProviderIEN,
1998 dlgCheckin.PrintRouteSlip,
1999 dlgCheckin.PCCClinicIEN,
2000 dlgCheckin.PCCFormIEN,
2001 dlgCheckin.PCCOutGuide
2002 );
2003 this.calendarGrid1.Invalidate();
2004 }
2005 catch (Exception ex)
2006 {
2007 MessageBox.Show("Error checking in patient: " + ex.Message, "Clinical Scheduling");
2008 }
2009
2010 if (bDeleted == true)
2011 {
2012 try
2013 {
2014 RaiseRPMSEvent("BSDX SCHEDULE" , m_Document.DocName);
2015 }
2016 catch (Exception ex)
2017 {
2018 Debug.Write(ex.Message);
2019 }
2020 this.calendarGrid1.Invalidate();
2021 }
2022 }
2023
2024 private void AppointmentAddWalkin()
2025 {
2026 try
2027 {
2028 CGAppointment appt = new CGAppointment();
2029
2030 //Get Time and Resource from Selected Cell
2031 DateTime dStart = DateTime.Today;
2032 DateTime dEnd = DateTime.Today;
2033 string sResource = "";
2034 bool bRet = this.calendarGrid1.GetSelectedTime(out dStart, out dEnd, out sResource);
2035 if (bRet == false)
2036 return;
2037
2038 TimeSpan tsDuration = dEnd - dStart;
2039 int nDuration = (int) tsDuration.TotalMinutes;
2040 Debug.Assert(nDuration > 0);
2041
2042 /*
2043 * 8-10-05 Added check to prevent walkin from being created
2044 * on a date later than today.
2045 */
2046
2047 if (dStart.Date > DateTime.Today.Date)
2048 {
2049 MessageBox.Show(this, "You cannot create a walk-in appointment for a date in the future.\n Select today's date and try again.", "Windows Scheduling", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
2050 return;
2051 }
2052
2053 /*
2054 * 8-10-05 Added overbook prompt for walkin
2055 */
2056 this.Document.RefreshDocument();
2057 string sAccessType = "";
2058 string sAvailabilityMessage = "";
2059 m_nSlots = m_Document.SlotsAvailable(dStart, dEnd, sResource, out sAccessType, out sAvailabilityMessage);
2060
2061 if (m_nSlots < 1)
2062 {
2063 DialogResult dr = MessageBox.Show(this, "There are no slots available at the selected time. Do you want to overbook this appointment?", "Clinical Scheduling",MessageBoxButtons.YesNo);
2064 if (dr != DialogResult.Yes)
2065 {
2066 return;
2067 }
2068 }
2069
2070 //Display a dialog to collect Patient Name
2071 DPatientLookup dPat = new DPatientLookup();
2072 dPat.DocManager = m_DocManager;
2073
2074 int nAccessTypeID = 0;
2075 bRet = calendarGrid1.GetSelectedType(out nAccessTypeID);
2076
2077 if (dPat.ShowDialog(this) == DialogResult.Cancel)
2078 {
2079 return;
2080 }
2081
2082 appt.PatientID = Convert.ToInt32(dPat.PatientIEN);
2083 appt.PatientName = dPat.PatientName;
2084 appt.StartTime = dStart;
2085 appt.EndTime = dEnd;
2086 appt.Resource = sResource;
2087 appt.HealthRecordNumber = dPat.HealthRecordNumber;
2088
2089 /*
2090 * 8-10-05 Copied overbook prompt for walkin
2091 * to this position in order to check just prior
2092 * to calling CreateAppointment
2093 */
2094 this.Document.RefreshDocument();
2095 m_nSlots = m_Document.SlotsAvailable(dStart, dEnd, sResource, out sAccessType, out sAvailabilityMessage);
2096
2097 if (m_nSlots < 1)
2098 {
2099 DialogResult dr = MessageBox.Show(this, "There are no slots available at the selected time. Do you want to overbook this appointment?", "Clinical Scheduling",MessageBoxButtons.YesNo);
2100 if (dr != DialogResult.Yes)
2101 {
2102 return;
2103 }
2104 }
2105
2106 //Call Document to add a walkin appointment
2107 int nApptID = this.Document.CreateAppointment(appt, true);
2108
2109 //Now check them in.
2110 calendarGrid1.SelectedAppointment = nApptID;
2111
2112 AppointmentCheckIn();
2113
2114 try
2115 {
2116 RaiseRPMSEvent("BSDX SCHEDULE" , m_Document.DocName);
2117 }
2118 catch (Exception ex)
2119 {
2120 Debug.Write(ex.Message);
2121 }
2122
2123 }
2124 catch (Exception ex)
2125 {
2126 MessageBox.Show("Unable to add walk-in appointment " + ex.Message, "Clinical Scheduling");
2127 return;
2128
2129 }
2130 }
2131
2132 private void AppointmentAddNew()
2133 {
2134 try
2135 {
2136 CGAppointment appt = new CGAppointment();
2137
2138 //Get Time and Resource from Selected Cell
2139 DateTime dStart = DateTime.Today;
2140 DateTime dEnd = DateTime.Today;
2141 string sResource = "";
2142 bool bRet = this.calendarGrid1.GetSelectedTime(out dStart, out dEnd, out sResource);
2143 if (bRet == false)
2144 return;
2145
2146 //Test dStart for Holiday
2147 DataView dvHoliday = new DataView(this.DocManager.GlobalDataSet.Tables["HOLIDAY"]);
2148 dvHoliday.Sort="DATE ASC";
2149 int nFind = dvHoliday.Find(dStart.Date);
2150 if (nFind > -1)
2151 {
2152 string sHoliday = "";
2153 DataRowView drv = dvHoliday[nFind];
2154 sHoliday = drv["NAME"].ToString();
2155 if (MessageBox.Show(this, dStart.ToShortDateString() + " is a holiday (" + sHoliday + "). Are you sure you want to make this appointment?","Clinical Scheduling", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
2156 return;
2157 }
2158
2159 TimeSpan tsDuration = dEnd - dStart;
2160 int nDuration = (int) tsDuration.TotalMinutes;
2161 Debug.Assert(nDuration > 0);
2162
2163 this.Document.RefreshDocument();
2164 string sAccessType = "";
2165 string sAvailabilityMessage = "";
2166 m_nSlots = m_Document.SlotsAvailable(dStart, dEnd, sResource, out sAccessType, out sAvailabilityMessage);
2167
2168 if (m_nSlots < 1)
2169 {
2170 DialogResult dr = MessageBox.Show(this, "There are no slots available at the selected time. Do you want to overbook this appointment?", "Clinical Scheduling",MessageBoxButtons.YesNo);
2171 if (dr != DialogResult.Yes)
2172 {
2173 return;
2174 }
2175 }
2176
2177 //Display a dialog to collect Patient Name
2178 DPatientLookup dPat = new DPatientLookup();
2179 dPat.DocManager = m_DocManager;
2180
2181 int nAccessTypeID = 0;
2182 bRet = calendarGrid1.GetSelectedType(out nAccessTypeID);
2183
2184 if (dPat.ShowDialog(this) == DialogResult.Cancel)
2185 {
2186 return;
2187 }
2188
2189 //Call the appointment dialog to collect the appointment info
2190 Debug.Assert(dPat.PatientIEN != "");
2191 DAppointPage dAppt = new DAppointPage();
2192 dAppt.DocManager = this.m_DocManager;
2193 string sNote = "";
2194 dAppt.InitializePage(dPat.PatientIEN, dStart, nDuration, sResource, sNote);
2195
2196 if (dAppt.ShowDialog(this) == DialogResult.Cancel)
2197 {
2198 return;
2199 }
2200
2201 appt.PatientID = Convert.ToInt32(dPat.PatientIEN);
2202 appt.PatientName = dPat.PatientName;
2203 appt.StartTime = dStart;
2204 appt.EndTime = dEnd;
2205 appt.Resource = sResource;
2206 appt.Note = dAppt.Note;
2207 appt.HealthRecordNumber = dPat.HealthRecordNumber;
2208 appt.AccessTypeID = nAccessTypeID;
2209
2210 //Call Document to add a new appointment
2211 this.Document.CreateAppointment(appt);
2212 this.Document.RefreshDocument();
2213
2214 }
2215 catch (Exception ex)
2216 {
2217 MessageBox.Show("Unable to add new appointment " + ex.Message, "Clinical Scheduling");
2218 return;
2219
2220 }
2221 try
2222 {
2223 RaiseRPMSEvent("BSDX SCHEDULE" , m_Document.DocName);
2224 this.calendarGrid1.Invalidate();
2225 }
2226 catch (Exception ex)
2227 {
2228 Debug.Write(ex.Message);
2229 }
2230 }
2231
2232 public void OnUpdateSchedule()
2233 {
2234 try
2235 {
2236 this.Cursor = Cursors.WaitCursor;
2237 m_Document.RefreshDocument();
2238 }
2239 catch (Exception ex)
2240 {
2241 MessageBox.Show("Unable to refresh document " + ex.Message, "Clinical Scheduling");
2242 }
2243 finally
2244 {
2245 this.Cursor = Cursors.Default;
2246 }
2247 }
2248
2249 public void UpdateArrays()
2250 {
2251 Debug.Assert(this.InvokeRequired == false,"CGView.UpdateArrays InvokeRequired");
2252 try
2253 {
2254 this.calendarGrid1.AvailabilityArray = this.m_Document.AvailabilityArray;
2255 this.calendarGrid1.Resources = this.m_Document.Resources;
2256 this.calendarGrid1.OnUpdateArrays();
2257 this.lblResource.Text = this.m_Document.DocName;
2258 this.calendarGrid1.Invalidate();
2259 }
2260 catch (Exception ex)
2261 {
2262 MessageBox.Show("Unable to update arrays " + ex.Message, "Clinical Scheduling");
2263 }
2264 }
2265
2266 public void RaiseRPMSEvent(string sEvent, string sParams)
2267 {
2268 try
2269 {
2270 //Signal RPMS to raise an event
2271 m_ConnectInfo.RaiseEvent(sEvent, sParams, true);
2272 }
2273 catch (Exception ex)
2274 {
2275 Debug.Write(ex.Message);
2276 }
2277 }
2278
2279 private void SchedulingManagement()
2280 {
2281 try
2282 {
2283 bool bLock = DocManager.ConnectInfo.Lock("^BSDXMGR", "+", "");
2284 if (bLock == false)
2285 {
2286 throw new Exception("Another user is currently in Scheduling Management. Try later.");
2287 }
2288
2289 DManagement dMgm = new DManagement();
2290 dMgm.InitializeDialog(this.m_DocManager);
2291
2292 if (dMgm.ShowDialog(this) == DialogResult.Cancel)
2293 {
2294 }
2295
2296 m_DocManager.GlobalDataSet.Tables["ResourceUser"].Clear();
2297 m_DocManager.LoadResourceUserTable(false);
2298 bLock = DocManager.ConnectInfo.bmxNetLib.Lock("^BSDXMGR", "-");
2299 }
2300 catch (ApplicationException aex)
2301 {
2302 string sMsg = aex.Message;
2303 MessageBox.Show("Unable to acquire transmit lock. Try later.");
2304 }
2305 catch (Exception ex)
2306 {
2307 MessageBox.Show("Scheduling Management Error: " + ex.Message, "Clinical Scheduling");
2308 }
2309 }
2310
2311 public void UpdateTree()
2312 {
2313 this.tvSchedules.Nodes.Clear();
2314 this.LoadTree();
2315 }
2316
2317 public void ViewPatientAppointments()
2318 {
2319 try
2320 {
2321 //Display a dialog to collect Patient Name
2322 DPatientLookup dPat = new DPatientLookup();
2323 dPat.DocManager = m_DocManager;
2324 if (dPat.ShowDialog(this) == DialogResult.Cancel)
2325 {
2326 return;
2327 }
2328
2329 Debug.Assert(dPat.PatientIEN != "");
2330 int nPatientID = Convert.ToInt32(dPat.PatientIEN);
2331 ViewPatientAppointments(nPatientID);
2332 }
2333 catch (Exception ex)
2334 {
2335 MessageBox.Show(this, ex.Message, "Clinical Scheduling", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
2336 }
2337 }
2338
2339 public void ViewPatientAppointments(int PatientID)
2340 {
2341 DPatientApptDisplay dPa = new DPatientApptDisplay();
2342
2343 dPa.InitializeForm(this.DocManager, PatientID);
2344
2345
2346 if (dPa.ShowDialog(this) != DialogResult.Cancel)
2347 {
2348
2349 }
2350
2351 }
2352
2353 private void FindAvailableAppointment(ArrayList alResourceArray)
2354 {
2355 DApptSearch dSearch = new DApptSearch();
2356 dSearch.InitializePage(alResourceArray, this.m_DocManager);
2357 if (dSearch.ShowDialog(this) == DialogResult.Cancel)
2358 return;
2359
2360 string sResource = dSearch.SelectedResource;
2361 ArrayList alResource = new ArrayList();
2362 alResource.Add(sResource);
2363 DateTime sDate = dSearch.SelectedDate;
2364 m_sDocName = sResource;
2365 OpenSelectedSchedule(alResource, sDate);
2366
2367 }
2368
2369 #endregion Methods
2370
2371 #region Events
2372
2373 private void CGView_Load(object sender, System.EventArgs e)
2374 {
2375 Debug.Assert (this.Document != null);
2376
2377 //Register the view
2378 CGDocumentManager.Current.RegisterDocumentView(this.Document, this);
2379 this.mnu5Day.Click += new System.EventHandler(this.dateTimePicker1_ValueChanged); // MJL 1/17/2007
2380 this.mnu7Day.Click += new System.EventHandler(this.dateTimePicker1_ValueChanged);
2381
2382 //Load the Group-Resource treeview
2383 LoadTree();
2384
2385 this.SetDesktopLocation(this.DesktopLocation.X + 10, this.DesktopLocation.Y + 10);
2386 }
2387
2388 private void mnuOpenSchedule_Click(object sender, System.EventArgs e)
2389 {
2390 CreateNewSchedule();
2391 }
2392
2393 private void mnu1Day_Click(object sender, System.EventArgs e)
2394 {
2395 DateTime dtPicker = dateTimePicker1.Value;
2396 DateTime DayOnly = new DateTime(dtPicker.Year, dtPicker.Month, dtPicker.Day);
2397 this.calendarGrid1.StartDate = DayOnly;
2398 this.calendarGrid1.Columns = 1;
2399 }
2400
2401 private void mnu5Day_Click(object sender, System.EventArgs e)
2402 {
2403 if (this.calendarGrid1.Columns == 1)
2404 {
2405 this.StartDate = this.Document.StartDate;
2406 }
2407
2408 this.calendarGrid1.Columns = 5;
2409 this.Document.m_nColumnCount = 5; // MJL 1/17/2007
2410 //this.Document.UpdateAllViews();
2411 }
2412
2413 private void mnu7Day_Click(object sender, System.EventArgs e)
2414 {
2415 this.calendarGrid1.Columns = 7;
2416 this.Document.m_nColumnCount = 7; // MJL 1/17/2007
2417 }
2418
2419 private void mnu10Minute_Click(object sender, System.EventArgs e)
2420 {
2421 CalendarGrid cg = this.calendarGrid1;
2422 cg.TimeScale = 10;
2423 PositionGrid(cg, 7);
2424 }
2425
2426 private void mnu15Minute_Click(object sender, System.EventArgs e)
2427 {
2428 CalendarGrid cg = this.calendarGrid1;
2429 cg.TimeScale = 15;
2430 PositionGrid(cg, 7);
2431 }
2432
2433 private void mnu20Minute_Click(object sender, System.EventArgs e)
2434 {
2435 CalendarGrid cg = this.calendarGrid1;
2436 cg.TimeScale = 20;
2437 PositionGrid(cg, 7);
2438 }
2439
2440 private void mnu30Minute_Click(object sender, System.EventArgs e)
2441 {
2442 CalendarGrid cg = this.calendarGrid1;
2443 cg.TimeScale = 30;
2444 PositionGrid(cg, 7);
2445 }
2446
2447 private void mnuViewScheduleTree_Click(object sender, System.EventArgs e)
2448 {
2449 this.mnuViewScheduleTree.Checked = this.tvSchedules.Visible;
2450 this.tvSchedules.Visible = !(this.tvSchedules.Visible);
2451 this.mnuViewScheduleTree.Checked = !(this.mnuViewScheduleTree.Checked);
2452 }
2453
2454 private void tvSchedules_Click(object sender, System.EventArgs e)
2455 {
2456 bSchedulesClicked = true;
2457 }
2458
2459 private void tvSchedules_DoubleClick(object sender, System.EventArgs e)
2460 {
2461 if (m_alSelectedTreeResourceArray == null)
2462 return;
2463 if (m_alSelectedTreeResourceArray.Count < 1)
2464 {
2465 if (this.tvSchedules.SelectedNode.Text != "")
2466 {
2467 SetResourceArrayFromGroup(tvSchedules.SelectedNode.Text);
2468 }
2469 else
2470 {
2471 return;
2472 }
2473 }
2474 OpenSelectedSchedule(m_alSelectedTreeResourceArray, DateTime.Today);
2475 }
2476
2477 //20041109 Added
2478 private void SetResourceArrayFromGroup(string sGroup)
2479 {
2480 //Navigate from ResourceGroup table to Resources table
2481 DataRow[] arrRows;
2482 DataRelation dr = DocManager.GlobalDataSet.Relations["GroupResource"];
2483 DataRow r = DocManager.GlobalDataSet.Tables["ResourceGroup"].Rows.Find(sGroup);
2484 arrRows = r.GetChildRows(dr);
2485 for (int i=0; i< arrRows.Length; i++)
2486 {
2487 string sResource = arrRows[i]["RESOURCE_NAME"].ToString();
2488 m_alSelectedTreeResourceArray.Add(sResource);
2489 }
2490 m_sDocName = sGroup;
2491 }
2492
2493 public void SyncTree()
2494 {
2495
2496 }
2497
2498 private void tvSchedules_BeforeSelect(object sender, System.Windows.Forms.TreeViewCancelEventArgs e)
2499 {
2500
2501 }
2502
2503 private void tvSchedules_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
2504 {
2505 if (bSchedulesClicked == false)
2506 return;
2507 bSchedulesClicked = false;
2508
2509 m_alSelectedTreeResourceArray = new ArrayList();
2510 string sResource = e.Node.FullPath;
2511 string[] ss = sResource.Split((char) 92);
2512 int l = ss.GetUpperBound(0);
2513
2514 if (l == 0) //a resource group was checked, so get all underying resources
2515 {
2516 SetResourceArrayFromGroup(ss[0]);
2517 }
2518 else
2519 {
2520 sResource = ss[l];
2521 m_alSelectedTreeResourceArray.Add(ss[1]);
2522 }
2523
2524 m_sDocName = ss[l];
2525 return;
2526
2527 }
2528
2529 private void mnuTest1_Click(object sender, System.EventArgs e)
2530 {
2531 ReaderWriterLock m_rwl = this.DocManager.ConnectInfo.bmxNetLib.BMXRWL;
2532 try
2533 {
2534 m_rwl.AcquireWriterLock(50);
2535 Debug.Write("\nTest Button 1 Acquired first lock\n");
2536 m_rwl.AcquireWriterLock(50);
2537 Debug.Write("Test Button 1 Acquired second lock\n");
2538 this.DocManager.ViewRefresh();
2539 Thread.Sleep(5000);
2540 try
2541 {
2542 }
2543 catch
2544 {
2545 }
2546 finally
2547 {
2548 m_rwl.ReleaseWriterLock();
2549 Debug.Write ("Test Button 1 released first lock.\n");
2550 m_rwl.ReleaseWriterLock();
2551 Debug.Write ("Test Button 1 released second lock.\n");
2552 }
2553
2554 return;
2555 }
2556 catch (Exception ex)
2557 {
2558 Debug.Write("Test Button 1 exception: " + ex.Message + "\n");
2559 }
2560 }
2561
2562 private void CGView_Closing(object sender, System.ComponentModel.CancelEventArgs e)
2563 {
2564 try
2565 {
2566 m_ConnectInfo.BMXNetEvent -= m_bmxDelegate;
2567 this.calendarGrid1.CloseGrid();
2568 }
2569 catch (Exception ex)
2570 {
2571 Debug.Write("CGView_Closing exception: " + ex.Message + "\n");
2572 }
2573 }
2574
2575 private void mnuViewRightPanel_Click(object sender, System.EventArgs e)
2576 {
2577 this.mnuViewRightPanel.Checked = this.panelRight.Visible;
2578 this.panelRight.Visible = !(this.panelRight.Visible);
2579 this.mnuViewRightPanel.Checked = !(this.mnuViewRightPanel.Checked);
2580 }
2581
2582 private void dateTimePicker1_ValueChanged(object sender, System.EventArgs e)
2583 {
2584 DateTime dDate = dateTimePicker1.Value;
2585 dDate = dDate.Date;
2586 this.Document.SelectedDate = dDate;
2587 if (this.Document.Resources.Count == 1)
2588 {
2589 if (this.calendarGrid1.Columns > 1)
2590 {
2591 this.StartDate = this.Document.StartDate;
2592 }
2593 else
2594 {
2595 this.StartDate = this.Document.SelectedDate;
2596 }
2597 }
2598 else
2599 {
2600 this.StartDate = this.Document.SelectedDate;
2601 }
2602 this.Document.UpdateAllViews();
2603 this.calendarGrid1.Invalidate();
2604 }
2605
2606 private void calendarGrid1_CGSelectionChanged(object sender, IndianHealthService.ClinicalScheduling.CGSelectionChangedArgs e)
2607 {
2608 string sAccessType = "";
2609 string sAvailabilityMessage = "";
2610 m_nSlots = m_Document.SlotsAvailable(e.StartTime, e.EndTime, e.Resource, out sAccessType, out sAvailabilityMessage);
2611 UpdateStatusBar(e.StartTime, e.EndTime, sAccessType, sAvailabilityMessage);
2612 }
2613
2614 private void calendarGrid1_CGAppointmentChanged(object sender, IndianHealthService.ClinicalScheduling.CGAppointmentChangedArgs e)
2615 {
2616 try
2617 {
2618 if (e.Appointment.CheckInTime.Ticks > 0)
2619 {
2620 MessageBox.Show("You cannot change the appointment time because the patient has already checked in.", "Clinical Scheduling", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
2621 return;
2622 }
2623
2624 if (EditAppointmentEnabled(e.Resource) == false)
2625 return;
2626 if (EditAppointmentEnabled(e.Appointment.Resource) == false)
2627 return;
2628
2629 if (MessageBox.Show("Are you sure you want to move this appointment?", "Clinical Scheduling", MessageBoxButtons.YesNo) != DialogResult.Yes)
2630 return;
2631
2632 //20040909 Cherokee Replaced this block with following
2633 string sAccessType = "";
2634 string sAvailabilityMessage = "";
2635 // if (m_Document.SlotsAvailable(e.StartTime, e.EndTime, e.Resource, out sAccessType, out sAvailabilityMessage) < 1)
2636 // {
2637 // MessageBox.Show("There are no appointment slots available for the selected time.");
2638 // return;
2639 // }
2640 bool bOverbook =false;
2641 if (m_htOverbook.Count > 0)
2642 {
2643 bOverbook = (bool) this.m_htOverbook[e.Resource.ToString()];
2644 }
2645 bool bModSchedule =false;
2646 if (m_htModifySchedule.Count > 0)
2647 {
2648 bModSchedule = (bool) this.m_htModifySchedule[e.Resource.ToString()];
2649 }
2650 bool bSlotsAvailable = (m_Document.SlotsAvailable(e.StartTime, e.EndTime, e.Resource, out sAccessType, out sAvailabilityMessage) > 0);
2651 if (!((bSlotsAvailable) || (bModSchedule) || (bOverbook) ))
2652 {
2653 MessageBox.Show("There are no appointment slots available for the selected time.");
2654 return;
2655 }
2656
2657 /*
2658 * 7-19-05 Added overbook prompt
2659 */
2660 if (bSlotsAvailable == false)
2661 {
2662 DialogResult dr = MessageBox.Show(this, "There are no slots available at the selected time. Do you want to overbook this appointment?", "Clinical Scheduling",MessageBoxButtons.YesNo);
2663 if (dr != DialogResult.Yes)
2664 {
2665 return;
2666 }
2667 }
2668
2669 e.Appointment.StartTime = e.StartTime;
2670 e.Appointment.EndTime = e.EndTime;
2671 e.Appointment.Resource = e.Resource;
2672 e.Appointment.AccessTypeID = e.AccessTypeID;
2673 m_Document.CreateAppointment(e.Appointment);
2674
2675 string sError = AppointmentDeleteOne(e.Appointment.AppointmentKey);
2676 if (sError != "")
2677 {
2678 MessageBox.Show(sError);
2679 return;
2680 }
2681
2682 }
2683 catch (Exception ex)
2684 {
2685 MessageBox.Show("Unable to change appointment " + ex.Message, "Clinical Scheduling");
2686 this.m_DocManager.UpdateViews();
2687 return;
2688 }
2689 finally
2690 {
2691
2692 }
2693 try
2694 {
2695 RaiseRPMSEvent("BSDX SCHEDULE" , e.Resource);
2696 if (e.Resource != e.OldResource)
2697 RaiseRPMSEvent("BSDX SCHEDULE", e.OldResource);
2698 this.m_DocManager.UpdateViews(e.Resource, e.OldResource);
2699 }
2700 catch (Exception ex)
2701 {
2702 Debug.Write(ex.Message);
2703 }
2704 }
2705
2706 private void mnuSchedulingManagment_Click(object sender, System.EventArgs e)
2707 {
2708 SchedulingManagement();
2709 }
2710
2711 private void mnuFile_Popup(object sender, System.EventArgs e)
2712 {
2713 this.mnuSchedulingManagment.Enabled = DocManager.ScheduleManager;
2714 }
2715
2716 private void mnuFindAppt_Click(object sender, System.EventArgs e)
2717 {
2718 FindAvailableAppointment(this.Document.Resources);
2719 }
2720
2721 private void mnuRPMSServer_Click(object sender, System.EventArgs e)
2722 {
2723 //Handled by DocumentManager class
2724 }
2725
2726 private void mnuRPMSLogin_Click(object sender, System.EventArgs e)
2727 {
2728 //Handled by DocumentManager class
2729 }
2730
2731 private void CGView_Activated(object sender, System.EventArgs e)
2732 {
2733 calendarGrid1.GridEnter = true;
2734 }
2735
2736 private void mnuHelpAbout_Click(object sender, System.EventArgs e)
2737 {
2738 MessageBox.Show("Clinical Scheduling Version " + Application.ProductVersion, "Clinical Scheduling", MessageBoxButtons.OK, MessageBoxIcon.Information);
2739 }
2740
2741 private void ImplementMsg()
2742 {
2743 MessageBox.Show("Clinical Scheduling", "TODO: Implement this function");
2744 }
2745
2746 private void mnuClose_Click(object sender, System.EventArgs e)
2747 {
2748 DialogResult dr = MessageBox.Show("Are you sure you want to close this schedule?", Application.ProductName, MessageBoxButtons.OKCancel);
2749 if (dr != DialogResult.OK)
2750 return;
2751
2752 this.Close();
2753 }
2754
2755 private void mnuViewPatientAppts_Click(object sender, System.EventArgs e)
2756 {
2757 ViewPatientAppointments();
2758 }
2759
2760 private void lstClip_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
2761 {
2762 bool b = e.Data.GetDataPresent(typeof(CGAppointment));
2763 if (b == true)
2764 {
2765 e.Effect = DragDropEffects.Move;
2766 }
2767 else
2768 {
2769 e.Effect = DragDropEffects.None;
2770 }
2771
2772 }
2773
2774 private void lstClip_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
2775 {
2776 try
2777 {
2778 CGAppointment a = (CGAppointment) e.Data.GetData(typeof(CGAppointment));
2779 if (m_ClipList.AppointmentTable.Contains((int) a.AppointmentKey))
2780 {
2781 return;
2782 }
2783 m_ClipList.AddAppointment(a);
2784 lstClip.Items.Add(a);
2785 }
2786 catch(Exception ex)
2787 {
2788 Debug.Write(ex.Message);
2789 }
2790
2791 }
2792
2793 private void lstClip_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
2794 {
2795 m_bDragDropStart = false;
2796 }
2797
2798 private void lstClip_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
2799 {
2800 try
2801 {
2802 if ((m_bDragDropStart == false)&&(lstClip.SelectedIndex > -1))
2803 {
2804 CGAppointment a = (CGAppointment) lstClip.Items[lstClip.SelectedIndex];
2805 this.calendarGrid1.ApptDragSource = "list";
2806 DragDropEffects effect = DoDragDrop(a, DragDropEffects.Move);
2807 m_bDragDropStart = true;
2808 }
2809 }
2810 catch (Exception ex)
2811 {
2812 Debug.Write(ex.Message);
2813 }
2814 }
2815
2816 private void calendarGrid1_CGAppointmentAdded(object sender, IndianHealthService.ClinicalScheduling.CGAppointmentChangedArgs e)
2817 {
2818 try
2819 {
2820 string sAccessType = "";
2821 string sAvailabilityMessage = "";
2822 bool bSlotsAvailable;
2823 bool bOverbook;
2824 bool bModSchedule;
2825 bool bModAppts;
2826
2827 if (this.EditAppointmentEnabled(e.Appointment.Resource) == false)
2828 return;
2829
2830 bModAppts = (bool) this.m_htChangeAppts[e.Resource.ToString()];
2831 if (bModAppts == false)
2832 return;
2833
2834 bOverbook = (bool) this.m_htOverbook[e.Resource.ToString()];
2835 bModSchedule = (bool) this.m_htModifySchedule[e.Resource.ToString()];
2836 bSlotsAvailable = (m_Document.SlotsAvailable(e.StartTime, e.EndTime, e.Resource, out sAccessType, out sAvailabilityMessage) > 0);
2837
2838 if (!((bSlotsAvailable) || (bModSchedule) || (bOverbook) ))
2839 {
2840 MessageBox.Show("There are no appointment slots available for the selected time.");
2841 return;
2842 }
2843
2844 /*
2845 * 7-19-05 Added overbook prompt
2846 */
2847 if (bSlotsAvailable == false)
2848 {
2849 DialogResult dr = MessageBox.Show(this, "There are no slots available at the selected time. Do you want to overbook this appointment?", "Clinical Scheduling",MessageBoxButtons.YesNo);
2850 if (dr != DialogResult.Yes)
2851 {
2852 return;
2853 }
2854 }
2855
2856 e.Appointment.StartTime = e.StartTime;
2857 e.Appointment.EndTime = e.EndTime;
2858 e.Appointment.Resource = e.Resource;
2859 e.Appointment.AccessTypeID = e.AccessTypeID;
2860 m_Document.CreateAppointment(e.Appointment);
2861 }
2862 catch (Exception ex)
2863 {
2864 MessageBox.Show("Unable to add new appointment " + ex.Message, "Clinical Scheduling");
2865 return;
2866 }
2867 try
2868 {
2869 RaiseRPMSEvent("BSDX SCHEDULE" , e.Resource);
2870 if (e.Resource != e.OldResource)
2871 RaiseRPMSEvent("BSDX SCHEDULE", e.OldResource);
2872 this.m_DocManager.UpdateViews(e.Resource, e.OldResource);
2873 }
2874 catch (Exception ex)
2875 {
2876 Debug.Write(ex.Message);
2877 }
2878 }
2879
2880 private void lstClip_SelectedIndexChanged(object sender, System.EventArgs e)
2881 {
2882
2883 }
2884
2885 private void mnuPrintClinicSchedules_Click(object sender, System.EventArgs e)
2886 {
2887 try
2888 {
2889 DSelectLetterClinics ds = new DSelectLetterClinics();
2890 ds.InitializePage(this.m_DocManager.GlobalDataSet, "Print Clinic Schedules");
2891 ds.SetupForReports();
2892 if (ds.ShowDialog(this) != DialogResult.OK)
2893 return;
2894
2895 //get the resource names and call the letter printer
2896
2897 string sClinics = ds.SelectedClinics;
2898 DateTime dtBegin = ds.BeginDate;
2899 DateTime dtEnd = ds.EndDate;
2900
2901 DPatientLetter dpl = new DPatientLetter();
2902 dpl.InitializeFormClinicSchedule(this.DocManager, sClinics, dtBegin, dtEnd);
2903 dpl.ShowDialog(this);
2904
2905 }
2906 catch(Exception ex)
2907 {
2908 MessageBox.Show(this, ex.Message, "Clinical Scheduling", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
2909 }
2910 }
2911
2912 private void mnuPrintReminderLetters_Click(object sender, System.EventArgs e)
2913 {
2914 try
2915 {
2916 DSelectLetterClinics ds = new DSelectLetterClinics();
2917 ds.InitializePage(this.m_DocManager.GlobalDataSet, "Print Reminder Letters");
2918 if (ds.ShowDialog(this) != DialogResult.OK)
2919 return;
2920
2921 //get the resource names and call the letter printer
2922
2923 string sClinics = ds.SelectedClinics;
2924 DateTime dtBegin = ds.BeginDate;
2925 DateTime dtEnd = ds.EndDate;
2926
2927 DPatientLetter dpl = new DPatientLetter();
2928 dpl.InitializeFormPatientReminderLetters(this.DocManager, sClinics, dtBegin, dtEnd);
2929 dpl.ShowDialog(this);
2930
2931 }
2932 catch(Exception ex)
2933 {
2934 MessageBox.Show(this, ex.Message, "Clinical Scheduling", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
2935 }
2936
2937 }
2938
2939 private void mnuPrintRebookLetters_Click(object sender, System.EventArgs e)
2940 {
2941 try
2942 {
2943 DSelectLetterClinics ds = new DSelectLetterClinics();
2944 ds.InitializePage(this.m_DocManager.GlobalDataSet, "Print Clinic Rebook Letters");
2945 if (ds.ShowDialog(this) != DialogResult.OK)
2946 return;
2947
2948 //Call the letter printer
2949 DPatientLetter dpl = new DPatientLetter();
2950 dpl.InitializeFormRebookLetters(this.DocManager, ds.SelectedClinics, ds.BeginDate, ds.EndDate);
2951 dpl.ShowDialog(this);
2952
2953 }
2954 catch(Exception ex)
2955 {
2956 MessageBox.Show(this, ex.Message, "Clinical Scheduling", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
2957 }
2958 }
2959
2960 private void mnuPrintPatientLetter_Click(object sender, System.EventArgs e)
2961 {
2962 ViewPatientAppointments();
2963 }
2964
2965 private void mnuRPMSDivision_Click(object sender, System.EventArgs e)
2966 {
2967 this.DocManager.ChangeDivision(this);
2968 }
2969
2970 private void CGView_CursorChanged(object sender, System.EventArgs e)
2971 {
2972
2973 }
2974
2975 private void mnuDisplayWalkIns_Click(object sender, System.EventArgs e)
2976 {
2977 calendarGrid1.DrawWalkIns = !(calendarGrid1.DrawWalkIns);
2978 mnuDisplayWalkIns.Checked = calendarGrid1.DrawWalkIns;
2979 calendarGrid1.SetOverlapTable();
2980 calendarGrid1.Refresh();
2981 }
2982
2983 private void mnuOpenMultipleSchedules_Click(object sender, System.EventArgs e)
2984 {
2985
2986 try
2987 {
2988 DSelectSchedules ds = new DSelectSchedules();
2989 ds.InitializePage(this.m_DocManager.GlobalDataSet, "Open Multiple Schedules");
2990 if (ds.ShowDialog(this) != DialogResult.OK)
2991 return;
2992
2993 //get the resource names and open schedules
2994
2995 ArrayList sResources = ds.SelectedClinics;
2996 if (ds.SingleWindow == true)
2997 {
2998 m_sDocName = (ds.GroupWindowName == "")?"Multiple Selected Schedules":ds.GroupWindowName;
2999 OpenSelectedSchedule( sResources, DateTime.Today);
3000 }
3001 else
3002 {
3003 foreach (string sResource in sResources)
3004 {
3005 ArrayList alSingle = new ArrayList(1);
3006 alSingle.Add(sResource);
3007 m_sDocName = sResource;
3008 OpenSelectedSchedule( alSingle, DateTime.Today);
3009 }
3010 }
3011 return;
3012
3013 }
3014 catch(Exception ex)
3015 {
3016 MessageBox.Show(this, ex.Message, "Clinical Scheduling", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
3017 }
3018
3019 }
3020
3021 private void ctxCalGridWalkin_Click(object sender, System.EventArgs e)
3022 {
3023 AppointmentAddWalkin();
3024 }
3025
3026 private void mnuWalkIn_Click(object sender, System.EventArgs e)
3027 {
3028 AppointmentAddWalkin();
3029 }
3030
3031 private void mnuPrintCancellationLetters_Click(object sender, System.EventArgs e)
3032 {
3033 try
3034 {
3035 DSelectLetterClinics ds = new DSelectLetterClinics();
3036 ds.InitializePage(this.m_DocManager.GlobalDataSet, "Print Clinic Cancellation Letters");
3037 if (ds.ShowDialog(this) != DialogResult.OK)
3038 return;
3039
3040 //get the resource names and call the letter printer
3041
3042 string sClinics = ds.SelectedClinics;
3043 DateTime dtBegin = ds.BeginDate;
3044 DateTime dtEnd = ds.EndDate;
3045
3046 DPatientLetter dpl = new DPatientLetter();
3047
3048 dpl.InitializeFormCancellationLetters(this.DocManager, sClinics, dtBegin, dtEnd);
3049 dpl.ShowDialog(this);
3050 }
3051 catch(Exception ex)
3052 {
3053 MessageBox.Show(this, ex.Message, "Clinical Scheduling", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
3054 }
3055 }
3056
3057 #endregion events
3058
3059
3060
3061
3062 }//End class
3063}
Note: See TracBrowser for help on using the repository browser.