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

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

CalendarGrid: Handling for mouse scroll wheel added.
CGAppointments: Now supports Deep Cloning with Clone().
Updated Exes

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