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

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

Provided framework for Rebook letters; but they don't work.
Added the appointment dates to the printed letters.
Made more shortcuts on the main menu.
Changed version to 1.1, to be more congruous with the state of the software.

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