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

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

Some debugging code to attach the program to the console to print messages.
Letters:

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