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

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

CGAppointment: Added Provider as a Member of Class. (auto property)
CGDocument: No changes
CGDocumentManager: Added UserPreferences as a member of a Class (private and property)
CGView: Changes to support printing of Routing Slip
DAppointPage: Changes to support UserPreferences member for auto printing the routing slips
DCheckIn: Extensive changes in load code (now uses LINQ instead of ADO.net). Changes to support UserPreferences member for auto printing the routing slips.
Patient: Documentation for UserFriendlyAge.
Provider: New class to represent Provider
UserPreferences: New class to represent User preferences. Does not interact with DB right now.

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