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

Last change on this file since 1482 was 1474, checked in by Sam Habiel, 12 years ago

Finally, v 1.7 to the main repo. I will delete the branch after this.

This commit merges all the BMX4 changes in the Scheduling GUI back to the main trunk.

File size: 148.4 KB
Line 
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using System.ComponentModel;
5using System.Windows.Forms;
6using System.Diagnostics;
7using System.Data;
8using System.Threading;
9using IndianHealthService.BMXNet;
10using System.Runtime.InteropServices;
11using System.Drawing.Printing;
12using System.Linq;
13
14namespace IndianHealthService.ClinicalScheduling
15{
16 /// <summary>
17 /// Main Form: Shows Tree of Clinics and Calendar Grid
18 /// </summary>
19 public class CGView : System.Windows.Forms.Form
20 {
21 private System.Windows.Forms.MainMenu mainMenu1;
22 private System.Windows.Forms.MenuItem mnuFile;
23 private System.Windows.Forms.MenuItem mnuTest;
24 private System.Windows.Forms.MenuItem mnuAppointment;
25 private System.Windows.Forms.MenuItem mnuNewAppointment;
26 private System.Windows.Forms.MenuItem mnu1Day;
27 private System.Windows.Forms.MenuItem mnu7Day;
28 private System.Windows.Forms.MenuItem menuItem4;
29 private System.Windows.Forms.MenuItem mnu5Day;
30 private System.Windows.Forms.MenuItem mnu10Minute;
31 private System.Windows.Forms.MenuItem mnu20Minute;
32 private System.Windows.Forms.MenuItem mnu30Minute;
33 private System.Windows.Forms.MenuItem mnuTimeScale;
34 private System.Windows.Forms.MenuItem mnu15Minute;
35 private System.Windows.Forms.MenuItem mnuOpenSchedule;
36 private System.Windows.Forms.MenuItem menuItem1;
37 private System.Windows.Forms.TreeView tvSchedules;
38 private System.Windows.Forms.MenuItem mnuViewScheduleTree;
39 private System.Windows.Forms.MenuItem mnuDeleteAppointment;
40 private System.Windows.Forms.MenuItem mnuTest1;
41 private System.Windows.Forms.Splitter splitter1;
42 private System.Windows.Forms.Splitter splitter2;
43 private System.Windows.Forms.StatusBar statusBar1;
44 private System.Windows.Forms.DateTimePicker dateTimePicker1;
45 private System.Windows.Forms.MenuItem mnuViewRightPanel;
46 private System.Windows.Forms.Panel panelRight;
47 private System.Windows.Forms.Panel panelTop;
48 private System.Windows.Forms.Panel panelCenter;
49 private System.Windows.Forms.Panel panelBottom;
50 private System.Windows.Forms.Label lblResource;
51 private System.Windows.Forms.ContextMenu ctxResourceTree;
52 private System.Windows.Forms.MenuItem ctxOpenSchedule;
53 private System.Windows.Forms.MenuItem ctxEditAvailability;
54 private System.Windows.Forms.MenuItem ctxProperties;
55 private System.Windows.Forms.MenuItem mnuSchedulingManagment;
56 private System.Windows.Forms.MenuItem ctxFindAppt;
57 private System.Windows.Forms.MenuItem mnuFindAppt;
58 internal System.Windows.Forms.MenuItem mnuRPMSServer;
59 internal System.Windows.Forms.MenuItem mnuRPMSLogin;
60 private System.Windows.Forms.MenuItem mnuCheckIn;
61 private System.Windows.Forms.MenuItem menuItem3;
62 private System.Windows.Forms.MenuItem mnuHelpAbout;
63 private System.Windows.Forms.MenuItem mnuCalendar;
64 private System.Windows.Forms.MenuItem mnuHelp;
65 private System.Windows.Forms.MenuItem mnuClose;
66 private System.Windows.Forms.MenuItem mnuViewPatientAppts;
67 private IndianHealthService.ClinicalScheduling.CalendarGrid calendarGrid1;
68 private System.Windows.Forms.MenuItem mnuCopyAppointment;
69 private System.Windows.Forms.Panel panelClip;
70 private System.Windows.Forms.ListBox lstClip;
71 private System.Windows.Forms.Label label1;
72 private System.Windows.Forms.ContextMenu ctxApptClipMenu;
73 private System.Windows.Forms.MenuItem mnuRemoveClipItem;
74 private System.Windows.Forms.MenuItem mnuClearClipItems;
75 private System.Windows.Forms.MenuItem mnuEditAppointment;
76 private System.Windows.Forms.ContextMenu ctxCalendarGrid;
77 private System.Windows.Forms.MenuItem ctxCalGridAdd;
78 private System.Windows.Forms.MenuItem ctxCalGridEdit;
79 private System.Windows.Forms.MenuItem ctxCalGridDelete;
80 private System.Windows.Forms.MenuItem ctxCalGridCheckIn;
81 private System.Windows.Forms.MenuItem menuItem6;
82 private System.Windows.Forms.MenuItem menuItem7;
83 private System.Windows.Forms.MenuItem mnuPrintReminderLetters;
84 private System.Windows.Forms.MenuItem mnuPrintPatientLetter;
85 private System.Windows.Forms.MenuItem mnuPrintClinicSchedules;
86 private System.Windows.Forms.MenuItem ctxCalGridNoShow;
87 private System.Windows.Forms.MenuItem ctxCalGridNoShowUndo;
88 private System.Windows.Forms.MenuItem mnuNoShow;
89 private System.Windows.Forms.MenuItem mnuNoShowUndo;
90 private System.Windows.Forms.MenuItem mnuPrintRebookLetters;
91 private System.Windows.Forms.MenuItem mnuPrintCancellationLetters;
92 private System.Windows.Forms.MenuItem mnuWalkIn;
93 private System.Windows.Forms.MenuItem sepApptMenu1;
94 private System.Windows.Forms.MenuItem sepApptMenu2;
95 private System.Windows.Forms.MenuItem ctxCalGridWalkin;
96 private System.Windows.Forms.MenuItem ctxCalGridSep1;
97 private System.Windows.Forms.MenuItem ctxCalGridSep2;
98 private System.Windows.Forms.MenuItem mnuOpenMultipleSchedules;
99 private System.Windows.Forms.MenuItem mnuDisplayWalkIns;
100 private System.Windows.Forms.MenuItem mnuRPMSDivision;
101 private MenuItem ctxCalGridSep3;
102 private MenuItem ctxCalGridReprintApptSlip;
103 private MenuItem ctxCalGridUndoCheckin;
104 private MenuItem ctxPrintScheduleT0;
105 private MenuItem ctxPrintScheduleT1;
106 private MenuItem ctxPrintScheduleT3;
107 private MenuItem menuItem12;
108 private MenuItem mnuRefresh;
109 private MenuItem ctxCalGridMkRadAppt;
110 private MenuItem ctxCalGridCancelRadAppt;
111 private MenuItem mnuMkRadAppt;
112 private MenuItem mnuCancelRadAppt;
113 private MenuItem mnuUndoCheckin;
114 private MenuItem sepApptMenu3;
115 private MenuItem mnuReprintApptSlip;
116 private MenuItem mnuViewBrokerLog;
117 private IContainer components;
118
119 #region Initialization
120 public CGView()
121 {
122 //
123 // Required for Windows Form Designer support
124 //
125 InitializeComponent();
126
127 m_nSlots = 0;
128 m_alSelectedTreeResourceArray = new ArrayList();
129 m_ClipList = new CGAppointments();
130
131 }
132
133 public void InitializeDocView(string sText)
134 {
135 this.Text = CGDocumentManager.Current.RemoteSession.User.Name;
136 if (sText != null)
137 this.Text += " - " + sText;
138 if (CGDocumentManager.Current.RemoteSession.User.Division.Name != null)
139 this.Text += " - " + CGDocumentManager.Current.RemoteSession.User.Division.Name;
140 }
141
142 public void InitializeDocView(CGDocument doc,
143 CGDocumentManager docMgr,
144 DateTime dStartDate,
145 string sText)
146 {
147 System.IntPtr pHandle = this.Handle;
148 this.DocManager = docMgr;
149 this.StartDate = dStartDate;
150 this.Document = doc;
151
152 //Rather strangely, this line is needed for God knows Why...
153 //Without it, the Grid tries to draw appointments, but can't.
154 //Making a constructor in the Calendar Grid itself didn't work. Don't know why.
155 //XXX: For later investigation.
156 this.Appointments = new CGAppointments();
157
158
159 // Set username and division up top
160 this.Text = CGDocumentManager.Current.RemoteSession.User.Name;
161 if (sText != null)
162 this.Text += " - " + sText;
163 if (CGDocumentManager.Current.RemoteSession.User.Division.Name != null)
164 this.Text += " - " + CGDocumentManager.Current.RemoteSession.User.Division.Name;
165
166 CGDocumentManager.Current.RemoteSession.EventServices.RpmsEvent += BMXNetEventHandler;
167 }
168
169
170 #endregion initialization
171
172 #region Windows Form Designer generated code
173 /// <summary>
174 /// Required method for Designer support - do not modify
175 /// the contents of this method with the code editor.
176 /// </summary>
177 private void InitializeComponent()
178 {
179 this.components = new System.ComponentModel.Container();
180 System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CGView));
181 this.mainMenu1 = new System.Windows.Forms.MainMenu(this.components);
182 this.mnuFile = new System.Windows.Forms.MenuItem();
183 this.mnuOpenSchedule = new System.Windows.Forms.MenuItem();
184 this.mnuOpenMultipleSchedules = new System.Windows.Forms.MenuItem();
185 this.menuItem1 = new System.Windows.Forms.MenuItem();
186 this.mnuRPMSServer = new System.Windows.Forms.MenuItem();
187 this.mnuRPMSLogin = new System.Windows.Forms.MenuItem();
188 this.mnuRPMSDivision = new System.Windows.Forms.MenuItem();
189 this.menuItem3 = new System.Windows.Forms.MenuItem();
190 this.mnuSchedulingManagment = new System.Windows.Forms.MenuItem();
191 this.menuItem6 = new System.Windows.Forms.MenuItem();
192 this.mnuPrintClinicSchedules = new System.Windows.Forms.MenuItem();
193 this.mnuPrintReminderLetters = new System.Windows.Forms.MenuItem();
194 this.mnuPrintRebookLetters = new System.Windows.Forms.MenuItem();
195 this.mnuPrintCancellationLetters = new System.Windows.Forms.MenuItem();
196 this.mnuPrintPatientLetter = new System.Windows.Forms.MenuItem();
197 this.menuItem7 = new System.Windows.Forms.MenuItem();
198 this.mnuClose = new System.Windows.Forms.MenuItem();
199 this.mnuAppointment = new System.Windows.Forms.MenuItem();
200 this.mnuNewAppointment = new System.Windows.Forms.MenuItem();
201 this.mnuWalkIn = new System.Windows.Forms.MenuItem();
202 this.mnuMkRadAppt = new System.Windows.Forms.MenuItem();
203 this.mnuEditAppointment = new System.Windows.Forms.MenuItem();
204 this.mnuDeleteAppointment = new System.Windows.Forms.MenuItem();
205 this.mnuCancelRadAppt = new System.Windows.Forms.MenuItem();
206 this.sepApptMenu1 = new System.Windows.Forms.MenuItem();
207 this.mnuNoShow = new System.Windows.Forms.MenuItem();
208 this.mnuNoShowUndo = new System.Windows.Forms.MenuItem();
209 this.sepApptMenu2 = new System.Windows.Forms.MenuItem();
210 this.mnuCheckIn = new System.Windows.Forms.MenuItem();
211 this.mnuUndoCheckin = new System.Windows.Forms.MenuItem();
212 this.sepApptMenu3 = new System.Windows.Forms.MenuItem();
213 this.mnuFindAppt = new System.Windows.Forms.MenuItem();
214 this.mnuCopyAppointment = new System.Windows.Forms.MenuItem();
215 this.mnuViewPatientAppts = new System.Windows.Forms.MenuItem();
216 this.mnuReprintApptSlip = new System.Windows.Forms.MenuItem();
217 this.mnuCalendar = new System.Windows.Forms.MenuItem();
218 this.mnuDisplayWalkIns = new System.Windows.Forms.MenuItem();
219 this.mnu1Day = new System.Windows.Forms.MenuItem();
220 this.mnu5Day = new System.Windows.Forms.MenuItem();
221 this.mnu7Day = new System.Windows.Forms.MenuItem();
222 this.menuItem4 = new System.Windows.Forms.MenuItem();
223 this.mnuTimeScale = new System.Windows.Forms.MenuItem();
224 this.mnu10Minute = new System.Windows.Forms.MenuItem();
225 this.mnu15Minute = new System.Windows.Forms.MenuItem();
226 this.mnu20Minute = new System.Windows.Forms.MenuItem();
227 this.mnu30Minute = new System.Windows.Forms.MenuItem();
228 this.mnuViewScheduleTree = new System.Windows.Forms.MenuItem();
229 this.mnuViewRightPanel = new System.Windows.Forms.MenuItem();
230 this.menuItem12 = new System.Windows.Forms.MenuItem();
231 this.mnuRefresh = new System.Windows.Forms.MenuItem();
232 this.mnuHelp = new System.Windows.Forms.MenuItem();
233 this.mnuHelpAbout = new System.Windows.Forms.MenuItem();
234 this.mnuViewBrokerLog = new System.Windows.Forms.MenuItem();
235 this.mnuTest = new System.Windows.Forms.MenuItem();
236 this.mnuTest1 = new System.Windows.Forms.MenuItem();
237 this.tvSchedules = new System.Windows.Forms.TreeView();
238 this.ctxResourceTree = new System.Windows.Forms.ContextMenu();
239 this.ctxOpenSchedule = new System.Windows.Forms.MenuItem();
240 this.ctxEditAvailability = new System.Windows.Forms.MenuItem();
241 this.ctxProperties = new System.Windows.Forms.MenuItem();
242 this.ctxFindAppt = new System.Windows.Forms.MenuItem();
243 this.ctxPrintScheduleT0 = new System.Windows.Forms.MenuItem();
244 this.ctxPrintScheduleT1 = new System.Windows.Forms.MenuItem();
245 this.ctxPrintScheduleT3 = new System.Windows.Forms.MenuItem();
246 this.panelRight = new System.Windows.Forms.Panel();
247 this.panelClip = new System.Windows.Forms.Panel();
248 this.lstClip = new System.Windows.Forms.ListBox();
249 this.ctxApptClipMenu = new System.Windows.Forms.ContextMenu();
250 this.mnuRemoveClipItem = new System.Windows.Forms.MenuItem();
251 this.mnuClearClipItems = new System.Windows.Forms.MenuItem();
252 this.label1 = new System.Windows.Forms.Label();
253 this.panelTop = new System.Windows.Forms.Panel();
254 this.dateTimePicker1 = new System.Windows.Forms.DateTimePicker();
255 this.lblResource = new System.Windows.Forms.Label();
256 this.panelCenter = new System.Windows.Forms.Panel();
257 this.calendarGrid1 = new IndianHealthService.ClinicalScheduling.CalendarGrid();
258 this.ctxCalendarGrid = new System.Windows.Forms.ContextMenu();
259 this.ctxCalGridAdd = new System.Windows.Forms.MenuItem();
260 this.ctxCalGridMkRadAppt = new System.Windows.Forms.MenuItem();
261 this.ctxCalGridEdit = new System.Windows.Forms.MenuItem();
262 this.ctxCalGridDelete = new System.Windows.Forms.MenuItem();
263 this.ctxCalGridCancelRadAppt = new System.Windows.Forms.MenuItem();
264 this.ctxCalGridCheckIn = new System.Windows.Forms.MenuItem();
265 this.ctxCalGridUndoCheckin = new System.Windows.Forms.MenuItem();
266 this.ctxCalGridSep1 = new System.Windows.Forms.MenuItem();
267 this.ctxCalGridNoShow = new System.Windows.Forms.MenuItem();
268 this.ctxCalGridNoShowUndo = new System.Windows.Forms.MenuItem();
269 this.ctxCalGridSep2 = new System.Windows.Forms.MenuItem();
270 this.ctxCalGridWalkin = new System.Windows.Forms.MenuItem();
271 this.ctxCalGridSep3 = new System.Windows.Forms.MenuItem();
272 this.ctxCalGridReprintApptSlip = new System.Windows.Forms.MenuItem();
273 this.panelBottom = new System.Windows.Forms.Panel();
274 this.statusBar1 = new System.Windows.Forms.StatusBar();
275 this.splitter1 = new System.Windows.Forms.Splitter();
276 this.splitter2 = new System.Windows.Forms.Splitter();
277 this.panelRight.SuspendLayout();
278 this.panelClip.SuspendLayout();
279 this.panelTop.SuspendLayout();
280 this.panelCenter.SuspendLayout();
281 this.panelBottom.SuspendLayout();
282 this.SuspendLayout();
283 //
284 // mainMenu1
285 //
286 this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
287 this.mnuFile,
288 this.mnuAppointment,
289 this.mnuCalendar,
290 this.mnuHelp,
291 this.mnuTest});
292 //
293 // mnuFile
294 //
295 this.mnuFile.Index = 0;
296 this.mnuFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
297 this.mnuOpenSchedule,
298 this.mnuOpenMultipleSchedules,
299 this.menuItem1,
300 this.mnuRPMSServer,
301 this.mnuRPMSLogin,
302 this.mnuRPMSDivision,
303 this.menuItem3,
304 this.mnuSchedulingManagment,
305 this.menuItem6,
306 this.mnuPrintClinicSchedules,
307 this.mnuPrintReminderLetters,
308 this.mnuPrintRebookLetters,
309 this.mnuPrintCancellationLetters,
310 this.mnuPrintPatientLetter,
311 this.menuItem7,
312 this.mnuClose});
313 this.mnuFile.Text = "&File";
314 this.mnuFile.Popup += new System.EventHandler(this.mnuFile_Popup);
315 //
316 // mnuOpenSchedule
317 //
318 this.mnuOpenSchedule.Enabled = false;
319 this.mnuOpenSchedule.Index = 0;
320 this.mnuOpenSchedule.Text = "&Open Schedule";
321 this.mnuOpenSchedule.Visible = false;
322 this.mnuOpenSchedule.Click += new System.EventHandler(this.mnuOpenSchedule_Click);
323 //
324 // mnuOpenMultipleSchedules
325 //
326 this.mnuOpenMultipleSchedules.Index = 1;
327 this.mnuOpenMultipleSchedules.Shortcut = System.Windows.Forms.Shortcut.CtrlM;
328 this.mnuOpenMultipleSchedules.Text = "Open M&ultiple Schedules";
329 this.mnuOpenMultipleSchedules.Click += new System.EventHandler(this.mnuOpenMultipleSchedules_Click);
330 //
331 // menuItem1
332 //
333 this.menuItem1.Index = 2;
334 this.menuItem1.Text = "-";
335 //
336 // mnuRPMSServer
337 //
338 this.mnuRPMSServer.Index = 3;
339 this.mnuRPMSServer.Shortcut = System.Windows.Forms.Shortcut.CtrlShiftS;
340 this.mnuRPMSServer.Text = "Change VistA &Server";
341 this.mnuRPMSServer.Click += new System.EventHandler(this.mnuRPMSServer_Click);
342 //
343 // mnuRPMSLogin
344 //
345 this.mnuRPMSLogin.Index = 4;
346 this.mnuRPMSLogin.Shortcut = System.Windows.Forms.Shortcut.CtrlShiftL;
347 this.mnuRPMSLogin.Text = "Change VistA &Login";
348 this.mnuRPMSLogin.Click += new System.EventHandler(this.mnuRPMSLogin_Click);
349 //
350 // mnuRPMSDivision
351 //
352 this.mnuRPMSDivision.Index = 5;
353 this.mnuRPMSDivision.Shortcut = System.Windows.Forms.Shortcut.CtrlShiftD;
354 this.mnuRPMSDivision.Text = "Change VistA &Division";
355 this.mnuRPMSDivision.Click += new System.EventHandler(this.mnuRPMSDivision_Click);
356 //
357 // menuItem3
358 //
359 this.menuItem3.Index = 6;
360 this.menuItem3.Text = "-";
361 //
362 // mnuSchedulingManagment
363 //
364 this.mnuSchedulingManagment.Index = 7;
365 this.mnuSchedulingManagment.Shortcut = System.Windows.Forms.Shortcut.CtrlShiftM;
366 this.mnuSchedulingManagment.Text = "Scheduling &Management";
367 this.mnuSchedulingManagment.Click += new System.EventHandler(this.mnuSchedulingManagment_Click);
368 //
369 // menuItem6
370 //
371 this.menuItem6.Index = 8;
372 this.menuItem6.Text = "-";
373 //
374 // mnuPrintClinicSchedules
375 //
376 this.mnuPrintClinicSchedules.Index = 9;
377 this.mnuPrintClinicSchedules.Shortcut = System.Windows.Forms.Shortcut.CtrlP;
378 this.mnuPrintClinicSchedules.Text = "&Print Clinic Schedules";
379 this.mnuPrintClinicSchedules.Click += new System.EventHandler(this.mnuPrintClinicSchedules_Click);
380 //
381 // mnuPrintReminderLetters
382 //
383 this.mnuPrintReminderLetters.Index = 10;
384 this.mnuPrintReminderLetters.Shortcut = System.Windows.Forms.Shortcut.CtrlE;
385 this.mnuPrintReminderLetters.Text = "Print Rem&inder Letters";
386 this.mnuPrintReminderLetters.Click += new System.EventHandler(this.mnuPrintReminderLetters_Click);
387 //
388 // mnuPrintRebookLetters
389 //
390 this.mnuPrintRebookLetters.Index = 11;
391 this.mnuPrintRebookLetters.Shortcut = System.Windows.Forms.Shortcut.CtrlR;
392 this.mnuPrintRebookLetters.Text = "Print &Rebook Letters";
393 this.mnuPrintRebookLetters.Click += new System.EventHandler(this.mnuPrintRebookLetters_Click);
394 //
395 // mnuPrintCancellationLetters
396 //
397 this.mnuPrintCancellationLetters.Index = 12;
398 this.mnuPrintCancellationLetters.Shortcut = System.Windows.Forms.Shortcut.CtrlShiftC;
399 this.mnuPrintCancellationLetters.Text = "Print C&ancellation Letters";
400 this.mnuPrintCancellationLetters.Click += new System.EventHandler(this.mnuPrintCancellationLetters_Click);
401 //
402 // mnuPrintPatientLetter
403 //
404 this.mnuPrintPatientLetter.Index = 13;
405 this.mnuPrintPatientLetter.Shortcut = System.Windows.Forms.Shortcut.CtrlL;
406 this.mnuPrintPatientLetter.Text = "Print Patient Le&tter";
407 this.mnuPrintPatientLetter.Click += new System.EventHandler(this.mnuPrintPatientLetter_Click);
408 //
409 // menuItem7
410 //
411 this.menuItem7.Index = 14;
412 this.menuItem7.Text = "-";
413 //
414 // mnuClose
415 //
416 this.mnuClose.Index = 15;
417 this.mnuClose.Shortcut = System.Windows.Forms.Shortcut.CtrlW;
418 this.mnuClose.Text = "&Close Schedule";
419 this.mnuClose.Click += new System.EventHandler(this.mnuClose_Click);
420 //
421 // mnuAppointment
422 //
423 this.mnuAppointment.Index = 1;
424 this.mnuAppointment.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
425 this.mnuNewAppointment,
426 this.mnuWalkIn,
427 this.mnuMkRadAppt,
428 this.mnuEditAppointment,
429 this.mnuDeleteAppointment,
430 this.mnuCancelRadAppt,
431 this.sepApptMenu1,
432 this.mnuNoShow,
433 this.mnuNoShowUndo,
434 this.sepApptMenu2,
435 this.mnuCheckIn,
436 this.mnuUndoCheckin,
437 this.sepApptMenu3,
438 this.mnuFindAppt,
439 this.mnuCopyAppointment,
440 this.mnuViewPatientAppts,
441 this.mnuReprintApptSlip});
442 this.mnuAppointment.Text = "&Appointment";
443 this.mnuAppointment.Popup += new System.EventHandler(this.mnuAppointment_Popup);
444 //
445 // mnuNewAppointment
446 //
447 this.mnuNewAppointment.Index = 0;
448 this.mnuNewAppointment.Shortcut = System.Windows.Forms.Shortcut.Ins;
449 this.mnuNewAppointment.Text = "&New Appointment";
450 this.mnuNewAppointment.Click += new System.EventHandler(this.mnuNewAppointment_Click);
451 //
452 // mnuWalkIn
453 //
454 this.mnuWalkIn.Index = 1;
455 this.mnuWalkIn.Shortcut = System.Windows.Forms.Shortcut.ShiftIns;
456 this.mnuWalkIn.Text = "Create Wal&k-In Appointment";
457 this.mnuWalkIn.Click += new System.EventHandler(this.mnuWalkIn_Click);
458 //
459 // mnuMkRadAppt
460 //
461 this.mnuMkRadAppt.Index = 2;
462 this.mnuMkRadAppt.Shortcut = System.Windows.Forms.Shortcut.CtrlIns;
463 this.mnuMkRadAppt.Text = "Make Radiology Appointment";
464 this.mnuMkRadAppt.Click += new System.EventHandler(this.mnuMkRadAppt_Click);
465 //
466 // mnuEditAppointment
467 //
468 this.mnuEditAppointment.Index = 3;
469 this.mnuEditAppointment.Shortcut = System.Windows.Forms.Shortcut.F2;
470 this.mnuEditAppointment.Text = "&Edit Appointment";
471 this.mnuEditAppointment.Click += new System.EventHandler(this.mnuEditAppointment_Click);
472 //
473 // mnuDeleteAppointment
474 //
475 this.mnuDeleteAppointment.Index = 4;
476 this.mnuDeleteAppointment.Shortcut = System.Windows.Forms.Shortcut.Del;
477 this.mnuDeleteAppointment.Text = "Cance&l Appointment";
478 this.mnuDeleteAppointment.Click += new System.EventHandler(this.mnuDeleteAppointment_Click);
479 //
480 // mnuCancelRadAppt
481 //
482 this.mnuCancelRadAppt.Index = 5;
483 this.mnuCancelRadAppt.Shortcut = System.Windows.Forms.Shortcut.CtrlDel;
484 this.mnuCancelRadAppt.Text = "Cancel Radiology Appointment";
485 this.mnuCancelRadAppt.Click += new System.EventHandler(this.mnuCancelRadAppt_Click);
486 //
487 // sepApptMenu1
488 //
489 this.sepApptMenu1.Index = 6;
490 this.sepApptMenu1.Text = "-";
491 //
492 // mnuNoShow
493 //
494 this.mnuNoShow.Index = 7;
495 this.mnuNoShow.Shortcut = System.Windows.Forms.Shortcut.CtrlN;
496 this.mnuNoShow.Text = "Mark as No Sho&w";
497 this.mnuNoShow.Click += new System.EventHandler(this.mnuNoShow_Click);
498 //
499 // mnuNoShowUndo
500 //
501 this.mnuNoShowUndo.Index = 8;
502 this.mnuNoShowUndo.Shortcut = System.Windows.Forms.Shortcut.CtrlShiftN;
503 this.mnuNoShowUndo.Text = "&Undo No Show";
504 this.mnuNoShowUndo.Click += new System.EventHandler(this.mnuNoShowUndo_Click);
505 //
506 // sepApptMenu2
507 //
508 this.sepApptMenu2.Index = 9;
509 this.sepApptMenu2.Text = "-";
510 //
511 // mnuCheckIn
512 //
513 this.mnuCheckIn.Index = 10;
514 this.mnuCheckIn.Shortcut = System.Windows.Forms.Shortcut.CtrlI;
515 this.mnuCheckIn.Text = "Check &In Patient";
516 this.mnuCheckIn.Click += new System.EventHandler(this.mnuCheckIn_Click);
517 //
518 // mnuUndoCheckin
519 //
520 this.mnuUndoCheckin.Index = 11;
521 this.mnuUndoCheckin.Shortcut = System.Windows.Forms.Shortcut.CtrlShiftI;
522 this.mnuUndoCheckin.Text = "Undo Checkin";
523 this.mnuUndoCheckin.Click += new System.EventHandler(this.mnuUndoCheckin_Click);
524 //
525 // sepApptMenu3
526 //
527 this.sepApptMenu3.Index = 12;
528 this.sepApptMenu3.Text = "-";
529 //
530 // mnuFindAppt
531 //
532 this.mnuFindAppt.Index = 13;
533 this.mnuFindAppt.Shortcut = System.Windows.Forms.Shortcut.CtrlF;
534 this.mnuFindAppt.Text = "&Find Empty Slots";
535 this.mnuFindAppt.Click += new System.EventHandler(this.mnuFindAppt_Click);
536 //
537 // mnuCopyAppointment
538 //
539 this.mnuCopyAppointment.Index = 14;
540 this.mnuCopyAppointment.Shortcut = System.Windows.Forms.Shortcut.CtrlC;
541 this.mnuCopyAppointment.Text = "&Copy Appointment to Clipboard";
542 this.mnuCopyAppointment.Click += new System.EventHandler(this.mnuCopyAppointment_Click);
543 //
544 // mnuViewPatientAppts
545 //
546 this.mnuViewPatientAppts.Index = 15;
547 this.mnuViewPatientAppts.Shortcut = System.Windows.Forms.Shortcut.CtrlShiftZ;
548 this.mnuViewPatientAppts.Text = "&View Patient Appointments";
549 this.mnuViewPatientAppts.Click += new System.EventHandler(this.mnuViewPatientAppts_Click);
550 //
551 // mnuReprintApptSlip
552 //
553 this.mnuReprintApptSlip.Index = 16;
554 this.mnuReprintApptSlip.Shortcut = System.Windows.Forms.Shortcut.CtrlShiftP;
555 this.mnuReprintApptSlip.Text = "Reprint Appointment Slip";
556 this.mnuReprintApptSlip.Click += new System.EventHandler(this.mnuReprintApptSlip_Click);
557 //
558 // mnuCalendar
559 //
560 this.mnuCalendar.Index = 2;
561 this.mnuCalendar.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
562 this.mnuDisplayWalkIns,
563 this.mnu1Day,
564 this.mnu5Day,
565 this.mnu7Day,
566 this.menuItem4,
567 this.mnuTimeScale,
568 this.mnuViewScheduleTree,
569 this.mnuViewRightPanel,
570 this.menuItem12,
571 this.mnuRefresh});
572 this.mnuCalendar.Text = "&View";
573 //
574 // mnuDisplayWalkIns
575 //
576 this.mnuDisplayWalkIns.Checked = true;
577 this.mnuDisplayWalkIns.Index = 0;
578 this.mnuDisplayWalkIns.Shortcut = System.Windows.Forms.Shortcut.F12;
579 this.mnuDisplayWalkIns.Text = "&Display Walk-Ins";
580 this.mnuDisplayWalkIns.Click += new System.EventHandler(this.mnuDisplayWalkIns_Click);
581 //
582 // mnu1Day
583 //
584 this.mnu1Day.Index = 1;
585 this.mnu1Day.Shortcut = System.Windows.Forms.Shortcut.Ctrl1;
586 this.mnu1Day.Text = "&1-Day View";
587 this.mnu1Day.Click += new System.EventHandler(this.mnu1Day_Click);
588 //
589 // mnu5Day
590 //
591 this.mnu5Day.Index = 2;
592 this.mnu5Day.Shortcut = System.Windows.Forms.Shortcut.Ctrl5;
593 this.mnu5Day.Text = "&5-Day View";
594 this.mnu5Day.Click += new System.EventHandler(this.mnu5Day_Click);
595 //
596 // mnu7Day
597 //
598 this.mnu7Day.Index = 3;
599 this.mnu7Day.Shortcut = System.Windows.Forms.Shortcut.Ctrl7;
600 this.mnu7Day.Text = "&7-Day View";
601 this.mnu7Day.Click += new System.EventHandler(this.mnu7Day_Click);
602 //
603 // menuItem4
604 //
605 this.menuItem4.Index = 4;
606 this.menuItem4.Text = "-";
607 //
608 // mnuTimeScale
609 //
610 this.mnuTimeScale.Index = 5;
611 this.mnuTimeScale.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
612 this.mnu10Minute,
613 this.mnu15Minute,
614 this.mnu20Minute,
615 this.mnu30Minute});
616 this.mnuTimeScale.Text = "&Time Scale";
617 //
618 // mnu10Minute
619 //
620 this.mnu10Minute.Enabled = false;
621 this.mnu10Minute.Index = 0;
622 this.mnu10Minute.Shortcut = System.Windows.Forms.Shortcut.Ctrl0;
623 this.mnu10Minute.Text = "&10-Minute";
624 this.mnu10Minute.Click += new System.EventHandler(this.mnu10Minute_Click);
625 //
626 // mnu15Minute
627 //
628 this.mnu15Minute.Enabled = false;
629 this.mnu15Minute.Index = 1;
630 this.mnu15Minute.Shortcut = System.Windows.Forms.Shortcut.Ctrl4;
631 this.mnu15Minute.Text = "1&5-Minute";
632 this.mnu15Minute.Click += new System.EventHandler(this.mnu15Minute_Click);
633 //
634 // mnu20Minute
635 //
636 this.mnu20Minute.Enabled = false;
637 this.mnu20Minute.Index = 2;
638 this.mnu20Minute.Shortcut = System.Windows.Forms.Shortcut.Ctrl3;
639 this.mnu20Minute.Text = "&20-Minute";
640 this.mnu20Minute.Click += new System.EventHandler(this.mnu20Minute_Click);
641 //
642 // mnu30Minute
643 //
644 this.mnu30Minute.Enabled = false;
645 this.mnu30Minute.Index = 3;
646 this.mnu30Minute.Shortcut = System.Windows.Forms.Shortcut.Ctrl2;
647 this.mnu30Minute.Text = "&30-Minute";
648 this.mnu30Minute.Click += new System.EventHandler(this.mnu30Minute_Click);
649 //
650 // mnuViewScheduleTree
651 //
652 this.mnuViewScheduleTree.Checked = true;
653 this.mnuViewScheduleTree.Index = 6;
654 this.mnuViewScheduleTree.Shortcut = System.Windows.Forms.Shortcut.F4;
655 this.mnuViewScheduleTree.Text = "&Schedule Tree";
656 this.mnuViewScheduleTree.Click += new System.EventHandler(this.mnuViewScheduleTree_Click);
657 //
658 // mnuViewRightPanel
659 //
660 this.mnuViewRightPanel.Index = 7;
661 this.mnuViewRightPanel.Text = "&Appointment Clipboard";
662 this.mnuViewRightPanel.Click += new System.EventHandler(this.mnuViewRightPanel_Click);
663 //
664 // menuItem12
665 //
666 this.menuItem12.Index = 8;
667 this.menuItem12.Text = "-";
668 //
669 // mnuRefresh
670 //
671 this.mnuRefresh.Index = 9;
672 this.mnuRefresh.Shortcut = System.Windows.Forms.Shortcut.F5;
673 this.mnuRefresh.Text = "Refresh Data";
674 this.mnuRefresh.Click += new System.EventHandler(this.mnuRefresh_Click);
675 //
676 // mnuHelp
677 //
678 this.mnuHelp.Index = 3;
679 this.mnuHelp.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
680 this.mnuHelpAbout,
681 this.mnuViewBrokerLog});
682 this.mnuHelp.Text = "&Help";
683 //
684 // mnuHelpAbout
685 //
686 this.mnuHelpAbout.Index = 0;
687 this.mnuHelpAbout.Text = "&About";
688 this.mnuHelpAbout.Click += new System.EventHandler(this.mnuHelpAbout_Click);
689 //
690 // mnuViewBrokerLog
691 //
692 this.mnuViewBrokerLog.Index = 1;
693 this.mnuViewBrokerLog.Text = "&View Broker Log";
694 this.mnuViewBrokerLog.Click += new System.EventHandler(this.mnuViewBrokerLog_Click);
695 //
696 // mnuTest
697 //
698 this.mnuTest.Enabled = false;
699 this.mnuTest.Index = 4;
700 this.mnuTest.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
701 this.mnuTest1});
702 this.mnuTest.Text = "&Test";
703 this.mnuTest.Visible = false;
704 //
705 // mnuTest1
706 //
707 this.mnuTest1.Index = 0;
708 this.mnuTest1.Text = "Test1";
709 //
710 // tvSchedules
711 //
712 this.tvSchedules.BackColor = System.Drawing.SystemColors.ControlLight;
713 this.tvSchedules.ContextMenu = this.ctxResourceTree;
714 this.tvSchedules.Dock = System.Windows.Forms.DockStyle.Left;
715 this.tvSchedules.HotTracking = true;
716 this.tvSchedules.Location = new System.Drawing.Point(0, 0);
717 this.tvSchedules.Name = "tvSchedules";
718 this.tvSchedules.Size = new System.Drawing.Size(128, 389);
719 this.tvSchedules.Sorted = true;
720 this.tvSchedules.TabIndex = 1;
721 this.tvSchedules.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.tvSchedules_AfterSelect);
722 this.tvSchedules.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.tvSchedules_NodeMouseClick);
723 this.tvSchedules.DoubleClick += new System.EventHandler(this.tvSchedules_DoubleClick);
724 this.tvSchedules.MouseEnter += new System.EventHandler(this.tvSchedules_MouseEnter);
725 //
726 // ctxResourceTree
727 //
728 this.ctxResourceTree.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
729 this.ctxOpenSchedule,
730 this.ctxEditAvailability,
731 this.ctxProperties,
732 this.ctxFindAppt,
733 this.ctxPrintScheduleT0,
734 this.ctxPrintScheduleT1,
735 this.ctxPrintScheduleT3});
736 this.ctxResourceTree.Popup += new System.EventHandler(this.contextMenu1_Popup);
737 //
738 // ctxOpenSchedule
739 //
740 this.ctxOpenSchedule.DefaultItem = true;
741 this.ctxOpenSchedule.Index = 0;
742 this.ctxOpenSchedule.Text = "&Open Schedule";
743 this.ctxOpenSchedule.Click += new System.EventHandler(this.ctxOpenSchedule_Click);
744 //
745 // ctxEditAvailability
746 //
747 this.ctxEditAvailability.Index = 1;
748 this.ctxEditAvailability.Text = "&Edit Resource Availability";
749 this.ctxEditAvailability.Click += new System.EventHandler(this.ctxEditAvailability_Click);
750 //
751 // ctxProperties
752 //
753 this.ctxProperties.Index = 2;
754 this.ctxProperties.Text = "P&roperties";
755 this.ctxProperties.Click += new System.EventHandler(this.ctxProperties_Click);
756 //
757 // ctxFindAppt
758 //
759 this.ctxFindAppt.Index = 3;
760 this.ctxFindAppt.Text = "&Find Empty Slots";
761 this.ctxFindAppt.Click += new System.EventHandler(this.ctxFindAppt_Click);
762 //
763 // ctxPrintScheduleT0
764 //
765 this.ctxPrintScheduleT0.Index = 4;
766 this.ctxPrintScheduleT0.Text = "Print Clinic Schedule(s) (T+&0)";
767 this.ctxPrintScheduleT0.Click += new System.EventHandler(this.ctxPrintScheduleT0_Click);
768 //
769 // ctxPrintScheduleT1
770 //
771 this.ctxPrintScheduleT1.Index = 5;
772 this.ctxPrintScheduleT1.Text = "Print Clinic Schedule(s) (T+&1)";
773 this.ctxPrintScheduleT1.Click += new System.EventHandler(this.ctxPrintScheduleT1_Click);
774 //
775 // ctxPrintScheduleT3
776 //
777 this.ctxPrintScheduleT3.Index = 6;
778 this.ctxPrintScheduleT3.Text = "Print Clinic Schedule(s) (T+&3)";
779 this.ctxPrintScheduleT3.Click += new System.EventHandler(this.ctxPrintScheduleT3_Click);
780 //
781 // panelRight
782 //
783 this.panelRight.Controls.Add(this.panelClip);
784 this.panelRight.Dock = System.Windows.Forms.DockStyle.Right;
785 this.panelRight.Location = new System.Drawing.Point(996, 0);
786 this.panelRight.Name = "panelRight";
787 this.panelRight.Size = new System.Drawing.Size(128, 389);
788 this.panelRight.TabIndex = 3;
789 this.panelRight.Visible = false;
790 //
791 // panelClip
792 //
793 this.panelClip.Controls.Add(this.lstClip);
794 this.panelClip.Controls.Add(this.label1);
795 this.panelClip.Dock = System.Windows.Forms.DockStyle.Top;
796 this.panelClip.Location = new System.Drawing.Point(0, 0);
797 this.panelClip.Name = "panelClip";
798 this.panelClip.Size = new System.Drawing.Size(128, 448);
799 this.panelClip.TabIndex = 0;
800 //
801 // lstClip
802 //
803 this.lstClip.AllowDrop = true;
804 this.lstClip.ContextMenu = this.ctxApptClipMenu;
805 this.lstClip.DisplayMember = "PatientName";
806 this.lstClip.Dock = System.Windows.Forms.DockStyle.Fill;
807 this.lstClip.Location = new System.Drawing.Point(0, 32);
808 this.lstClip.Name = "lstClip";
809 this.lstClip.Size = new System.Drawing.Size(128, 416);
810 this.lstClip.TabIndex = 0;
811 this.lstClip.SelectedIndexChanged += new System.EventHandler(this.lstClip_SelectedIndexChanged);
812 this.lstClip.DragDrop += new System.Windows.Forms.DragEventHandler(this.lstClip_DragDrop);
813 this.lstClip.DragEnter += new System.Windows.Forms.DragEventHandler(this.lstClip_DragEnter);
814 this.lstClip.MouseDown += new System.Windows.Forms.MouseEventHandler(this.lstClip_MouseDown);
815 this.lstClip.MouseMove += new System.Windows.Forms.MouseEventHandler(this.lstClip_MouseMove);
816 //
817 // ctxApptClipMenu
818 //
819 this.ctxApptClipMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
820 this.mnuRemoveClipItem,
821 this.mnuClearClipItems});
822 this.ctxApptClipMenu.Popup += new System.EventHandler(this.ctxApptClipMenu_Popup);
823 //
824 // mnuRemoveClipItem
825 //
826 this.mnuRemoveClipItem.Index = 0;
827 this.mnuRemoveClipItem.Text = "Remove Item";
828 this.mnuRemoveClipItem.Click += new System.EventHandler(this.mnuRemoveClipItem_Click);
829 //
830 // mnuClearClipItems
831 //
832 this.mnuClearClipItems.Index = 1;
833 this.mnuClearClipItems.Text = "Clear All";
834 this.mnuClearClipItems.Click += new System.EventHandler(this.mnuClearClipItems_Click);
835 //
836 // label1
837 //
838 this.label1.Dock = System.Windows.Forms.DockStyle.Top;
839 this.label1.Location = new System.Drawing.Point(0, 0);
840 this.label1.Name = "label1";
841 this.label1.Size = new System.Drawing.Size(128, 32);
842 this.label1.TabIndex = 1;
843 this.label1.Text = "Appointment Clipboard";
844 this.label1.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
845 //
846 // panelTop
847 //
848 this.panelTop.Controls.Add(this.dateTimePicker1);
849 this.panelTop.Controls.Add(this.lblResource);
850 this.panelTop.Dock = System.Windows.Forms.DockStyle.Top;
851 this.panelTop.Location = new System.Drawing.Point(128, 0);
852 this.panelTop.Name = "panelTop";
853 this.panelTop.Size = new System.Drawing.Size(868, 24);
854 this.panelTop.TabIndex = 6;
855 //
856 // dateTimePicker1
857 //
858 this.dateTimePicker1.Dock = System.Windows.Forms.DockStyle.Right;
859 this.dateTimePicker1.DropDownAlign = System.Windows.Forms.LeftRightAlignment.Right;
860 this.dateTimePicker1.Location = new System.Drawing.Point(662, 0);
861 this.dateTimePicker1.Name = "dateTimePicker1";
862 this.dateTimePicker1.Size = new System.Drawing.Size(206, 20);
863 this.dateTimePicker1.TabIndex = 1;
864 this.dateTimePicker1.CloseUp += new System.EventHandler(this.dateTimePicker1_CloseUp);
865 this.dateTimePicker1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.dateTimePicker1_KeyPress);
866 this.dateTimePicker1.Leave += new System.EventHandler(this.dateTimePicker1_Leave);
867 //
868 // lblResource
869 //
870 this.lblResource.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
871 this.lblResource.ForeColor = System.Drawing.SystemColors.Highlight;
872 this.lblResource.Location = new System.Drawing.Point(8, 5);
873 this.lblResource.Name = "lblResource";
874 this.lblResource.Size = new System.Drawing.Size(456, 19);
875 this.lblResource.TabIndex = 2;
876 //
877 // panelCenter
878 //
879 this.panelCenter.Controls.Add(this.calendarGrid1);
880 this.panelCenter.Dock = System.Windows.Forms.DockStyle.Fill;
881 this.panelCenter.Location = new System.Drawing.Point(136, 24);
882 this.panelCenter.Name = "panelCenter";
883 this.panelCenter.Size = new System.Drawing.Size(857, 341);
884 this.panelCenter.TabIndex = 7;
885 //
886 // ctxCalendarGrid
887 //
888 this.ctxCalendarGrid.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
889 this.ctxCalGridAdd,
890 this.ctxCalGridMkRadAppt,
891 this.ctxCalGridEdit,
892 this.ctxCalGridDelete,
893 this.ctxCalGridCancelRadAppt,
894 this.ctxCalGridCheckIn,
895 this.ctxCalGridUndoCheckin,
896 this.ctxCalGridSep1,
897 this.ctxCalGridNoShow,
898 this.ctxCalGridNoShowUndo,
899 this.ctxCalGridSep2,
900 this.ctxCalGridWalkin,
901 this.ctxCalGridSep3,
902 this.ctxCalGridReprintApptSlip});
903 this.ctxCalendarGrid.Popup += new System.EventHandler(this.ctxCalendarGrid_Popup);
904 //
905 // ctxCalGridAdd
906 //
907 this.ctxCalGridAdd.Index = 0;
908 this.ctxCalGridAdd.Text = "Add Appointment";
909 this.ctxCalGridAdd.Click += new System.EventHandler(this.ctxCalGridAdd_Click);
910 //
911 // ctxCalGridMkRadAppt
912 //
913 this.ctxCalGridMkRadAppt.Index = 1;
914 this.ctxCalGridMkRadAppt.Text = "Make Radiology Appointment";
915 this.ctxCalGridMkRadAppt.Click += new System.EventHandler(this.ctxCalGridMkRadAppt_Click);
916 //
917 // ctxCalGridEdit
918 //
919 this.ctxCalGridEdit.Index = 2;
920 this.ctxCalGridEdit.Text = "Edit Appointment";
921 this.ctxCalGridEdit.Click += new System.EventHandler(this.ctxCalGridEdit_Click);
922 //
923 // ctxCalGridDelete
924 //
925 this.ctxCalGridDelete.Index = 3;
926 this.ctxCalGridDelete.Text = "Cancel Appointment";
927 this.ctxCalGridDelete.Click += new System.EventHandler(this.ctxCalGridDelete_Click);
928 //
929 // ctxCalGridCancelRadAppt
930 //
931 this.ctxCalGridCancelRadAppt.Index = 4;
932 this.ctxCalGridCancelRadAppt.Text = "Cancel Radiology Appointment";
933 this.ctxCalGridCancelRadAppt.Click += new System.EventHandler(this.ctxCalGridCancelRadAppt_Click);
934 //
935 // ctxCalGridCheckIn
936 //
937 this.ctxCalGridCheckIn.Index = 5;
938 this.ctxCalGridCheckIn.Text = "Check In Patient";
939 this.ctxCalGridCheckIn.Click += new System.EventHandler(this.ctxCalGridCheckIn_Click);
940 //
941 // ctxCalGridUndoCheckin
942 //
943 this.ctxCalGridUndoCheckin.Index = 6;
944 this.ctxCalGridUndoCheckin.Text = "&Undo Check In";
945 this.ctxCalGridUndoCheckin.Click += new System.EventHandler(this.ctxCalGridUndoCheckin_Click);
946 //
947 // ctxCalGridSep1
948 //
949 this.ctxCalGridSep1.Index = 7;
950 this.ctxCalGridSep1.Text = "-";
951 //
952 // ctxCalGridNoShow
953 //
954 this.ctxCalGridNoShow.Index = 8;
955 this.ctxCalGridNoShow.Text = "Mark as No Show";
956 this.ctxCalGridNoShow.Click += new System.EventHandler(this.ctxCalGridNoShow_Click);
957 //
958 // ctxCalGridNoShowUndo
959 //
960 this.ctxCalGridNoShowUndo.Index = 9;
961 this.ctxCalGridNoShowUndo.Text = "Undo NoShow";
962 this.ctxCalGridNoShowUndo.Click += new System.EventHandler(this.ctxCalGridNoShowUndo_Click);
963 //
964 // ctxCalGridSep2
965 //
966 this.ctxCalGridSep2.Index = 10;
967 this.ctxCalGridSep2.Text = "-";
968 //
969 // ctxCalGridWalkin
970 //
971 this.ctxCalGridWalkin.Index = 11;
972 this.ctxCalGridWalkin.Text = "Create Wal&k-In Appointment";
973 this.ctxCalGridWalkin.Click += new System.EventHandler(this.ctxCalGridWalkin_Click);
974 //
975 // ctxCalGridSep3
976 //
977 this.ctxCalGridSep3.Index = 12;
978 this.ctxCalGridSep3.Text = "-";
979 //
980 // ctxCalGridReprintApptSlip
981 //
982 this.ctxCalGridReprintApptSlip.Index = 13;
983 this.ctxCalGridReprintApptSlip.Text = "&Reprint Appointment Slip";
984 this.ctxCalGridReprintApptSlip.Click += new System.EventHandler(this.ctxCalGridReprintApptSlip_Click);
985 //
986 // panelBottom
987 //
988 this.panelBottom.Controls.Add(this.statusBar1);
989 this.panelBottom.Dock = System.Windows.Forms.DockStyle.Bottom;
990 this.panelBottom.Location = new System.Drawing.Point(136, 365);
991 this.panelBottom.Name = "panelBottom";
992 this.panelBottom.Size = new System.Drawing.Size(857, 24);
993 this.panelBottom.TabIndex = 8;
994 //
995 // statusBar1
996 //
997 this.statusBar1.Dock = System.Windows.Forms.DockStyle.Fill;
998 this.statusBar1.Location = new System.Drawing.Point(0, 0);
999 this.statusBar1.Name = "statusBar1";
1000 this.statusBar1.Size = new System.Drawing.Size(857, 24);
1001 this.statusBar1.SizingGrip = false;
1002 this.statusBar1.TabIndex = 0;
1003 //
1004 // splitter1
1005 //
1006 this.splitter1.Location = new System.Drawing.Point(128, 24);
1007 this.splitter1.Name = "splitter1";
1008 this.splitter1.Size = new System.Drawing.Size(8, 365);
1009 this.splitter1.TabIndex = 9;
1010 this.splitter1.TabStop = false;
1011 //
1012 // splitter2
1013 //
1014 this.splitter2.Dock = System.Windows.Forms.DockStyle.Right;
1015 this.splitter2.Location = new System.Drawing.Point(993, 24);
1016 this.splitter2.Name = "splitter2";
1017 this.splitter2.Size = new System.Drawing.Size(3, 365);
1018 this.splitter2.TabIndex = 10;
1019 this.splitter2.TabStop = false;
1020 //
1021 // calendarGrid1
1022 //
1023 this.calendarGrid1.AllowDrop = true;
1024 this.calendarGrid1.Appointments = null;
1025 this.calendarGrid1.ApptDragSource = null;
1026 this.calendarGrid1.AutoScroll = true;
1027 this.calendarGrid1.AutoScrollMinSize = new System.Drawing.Size(600, 1898);
1028 this.calendarGrid1.AvailabilityArray = null;
1029 this.calendarGrid1.BackColor = System.Drawing.SystemColors.Window;
1030 this.calendarGrid1.Columns = 5;
1031 this.calendarGrid1.ContextMenu = this.ctxCalendarGrid;
1032 this.calendarGrid1.Dock = System.Windows.Forms.DockStyle.Fill;
1033 this.calendarGrid1.DrawWalkIns = true;
1034 this.calendarGrid1.GridBackColor = null;
1035 this.calendarGrid1.GridEnter = false;
1036 this.calendarGrid1.Location = new System.Drawing.Point(0, 0);
1037 this.calendarGrid1.Name = "calendarGrid1";
1038 this.calendarGrid1.Resources = ((System.Collections.ArrayList)(resources.GetObject("calendarGrid1.Resources")));
1039 this.calendarGrid1.SelectedAppointment = 0;
1040 this.calendarGrid1.Size = new System.Drawing.Size(857, 341);
1041 this.calendarGrid1.StartDate = new System.DateTime(2003, 1, 27, 0, 0, 0, 0);
1042 this.calendarGrid1.TabIndex = 0;
1043 this.calendarGrid1.TimeScale = 20;
1044 this.calendarGrid1.CGAppointmentChanged += new IndianHealthService.ClinicalScheduling.CalendarGrid.CGAppointmentChangedHandler(this.calendarGrid1_CGAppointmentChanged);
1045 this.calendarGrid1.CGAppointmentAdded += new IndianHealthService.ClinicalScheduling.CalendarGrid.CGAppointmentChangedHandler(this.calendarGrid1_CGAppointmentAdded);
1046 this.calendarGrid1.CGSelectionChanged += new IndianHealthService.ClinicalScheduling.CalendarGrid.CGSelectionChangedHandler(this.calendarGrid1_CGSelectionChanged);
1047 this.calendarGrid1.DoubleClick += new System.EventHandler(this.calendarGrid1_DoubleClick);
1048 this.calendarGrid1.MouseEnter += new System.EventHandler(this.calendarGrid1_MouseEnter);
1049 //
1050 // CGView
1051 //
1052 this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
1053 this.ClientSize = new System.Drawing.Size(1124, 389);
1054 this.Controls.Add(this.panelCenter);
1055 this.Controls.Add(this.panelBottom);
1056 this.Controls.Add(this.splitter2);
1057 this.Controls.Add(this.splitter1);
1058 this.Controls.Add(this.panelTop);
1059 this.Controls.Add(this.panelRight);
1060 this.Controls.Add(this.tvSchedules);
1061 this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
1062 this.Menu = this.mainMenu1;
1063 this.Name = "CGView";
1064 this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
1065 this.Text = "CGView";
1066 this.Activated += new System.EventHandler(this.CGView_Activated);
1067 this.Closing += new System.ComponentModel.CancelEventHandler(this.CGView_Closing);
1068 this.Load += new System.EventHandler(this.CGView_Load);
1069 this.CursorChanged += new System.EventHandler(this.CGView_CursorChanged);
1070 this.panelRight.ResumeLayout(false);
1071 this.panelClip.ResumeLayout(false);
1072 this.panelTop.ResumeLayout(false);
1073 this.panelCenter.ResumeLayout(false);
1074 this.panelBottom.ResumeLayout(false);
1075 this.ResumeLayout(false);
1076
1077 }
1078 #endregion
1079
1080 #region Fields
1081
1082 private CGDocument m_Document;
1083 private CGDocumentManager m_DocManager;
1084 private int m_nSlots;
1085 private ArrayList m_alSelectedTreeResourceArray = new ArrayList();
1086 private string m_sDocName;
1087 private CGAppointments m_ClipList;
1088 private bool m_bDragDropStart = false;
1089 private Hashtable m_htOverbook;
1090 private Hashtable m_htModifySchedule;
1091 private Hashtable m_htChangeAppts;
1092
1093 #endregion Fields
1094
1095 #region Properties
1096
1097 /// <summary>
1098 /// Access the CalendarGrid associated with this view
1099 /// </summary>
1100 public CalendarGrid CGrid
1101 {
1102 get
1103 {
1104 return this.calendarGrid1;
1105 }
1106 }
1107
1108 /// <summary>
1109 /// Accesses the document associated with this view
1110 /// </summary>
1111 public CGDocument Document
1112 {
1113 get
1114 {
1115 return this.m_Document;
1116 }
1117 set
1118 {
1119 this.m_Document = value;
1120 }
1121 }
1122
1123 public CGDocumentManager DocManager
1124 {
1125 get
1126 {
1127 return m_DocManager;
1128 }
1129 set
1130 {
1131 m_DocManager = value;
1132 }
1133 }
1134
1135 public DateTime StartDate
1136 {
1137 get
1138 {
1139 return this.calendarGrid1.StartDate;
1140 }
1141 set
1142 {
1143 this.calendarGrid1.StartDate = value;
1144 }
1145 }
1146
1147 public CGAppointments Appointments
1148 {
1149 get
1150 {
1151 return this.calendarGrid1.Appointments;
1152 }
1153 set
1154 {
1155 this.calendarGrid1.Appointments = value;
1156 }
1157 }
1158
1159
1160 #endregion
1161
1162 #region AppointmentMenu Handlers
1163
1164 private void mnuAppointment_Popup(object sender, System.EventArgs e)
1165 {
1166 // our flags
1167 bool _findApptsEnabled = (this.Document.Resources.Count > 0)? true : false ;
1168 bool _addApptsEnabled = AddAppointmentEnabled();
1169 bool _editApptsEnabled = EditAppointmentEnabled();
1170 bool _isRadAppt = IsThisARadiologyResource();
1171 bool _noShowEnabled = NoShowEnabled();
1172 bool _undoCheckinEnabled = UndoCheckinEnabled();
1173 //end flags
1174
1175 mnuNewAppointment.Enabled = _addApptsEnabled && !_isRadAppt;
1176 mnuWalkIn.Enabled = _addApptsEnabled && !_isRadAppt;
1177 mnuMkRadAppt.Enabled = _isRadAppt && _addApptsEnabled;
1178
1179 mnuEditAppointment.Enabled = _editApptsEnabled && !_isRadAppt;
1180 mnuDeleteAppointment.Enabled = _editApptsEnabled && !_isRadAppt;
1181 mnuCancelRadAppt.Enabled = _isRadAppt && _editApptsEnabled;
1182 mnuNoShow.Enabled = _noShowEnabled && _editApptsEnabled;
1183 mnuNoShowUndo.Enabled = !_noShowEnabled && _editApptsEnabled;
1184 mnuCheckIn.Enabled = _editApptsEnabled && !_isRadAppt;
1185 mnuUndoCheckin.Enabled = _undoCheckinEnabled && !_isRadAppt;
1186
1187 mnuFindAppt.Enabled = _findApptsEnabled;
1188 mnuCopyAppointment.Enabled = _editApptsEnabled && !_isRadAppt;
1189 mnuViewPatientAppts.Enabled = true;
1190 mnuReprintApptSlip.Enabled = _editApptsEnabled;
1191 }
1192
1193 private void mnuCheckIn_Click(object sender, System.EventArgs e)
1194 {
1195 AppointmentCheckIn();
1196 }
1197
1198 private void mnuCopyAppointment_Click(object sender, System.EventArgs e)
1199 {
1200 //For each appointment in the grid's selected list,
1201 //add to the clip list
1202 //and add to m_ClipList
1203 try
1204 {
1205 foreach (CGAppointment a in this.calendarGrid1.SelectedAppointments.AppointmentTable.Values)
1206 {
1207 if (m_ClipList.AppointmentTable.Contains((int)a.AppointmentKey))
1208 {
1209 return;
1210 }
1211 m_ClipList.AddAppointment(a);
1212 lstClip.Items.Add(a);
1213 }
1214 }
1215 catch (Exception ex)
1216 {
1217 string s = ex.Message;
1218 Debug.Write(s);
1219 return;
1220 }
1221 }
1222
1223 private void mnuDeleteAppointment_Click(object sender, System.EventArgs e)
1224 {
1225 AppointmentDelete();
1226 }
1227
1228 private void mnuEditAppointment_Click(object sender, System.EventArgs e)
1229 {
1230 AppointmentEdit();
1231 }
1232
1233 private void mnuNewAppointment_Click(object sender, System.EventArgs e)
1234 {
1235 AppointmentAddNew();
1236 }
1237
1238 private void mnuNoShow_Click(object sender, System.EventArgs e)
1239 {
1240 AppointmentNoShow(true);
1241 }
1242
1243 private void mnuNoShowUndo_Click(object sender, System.EventArgs e)
1244 {
1245 AppointmentNoShow(false);
1246 }
1247
1248 private void ctxCalGridUndoCheckin_Click(object sender, EventArgs e)
1249 {
1250 AppointmentUndoCheckin();
1251 }
1252
1253 private void mnuMkRadAppt_Click(object sender, EventArgs e)
1254 {
1255 AppointmentAddNewRadiology();
1256 }
1257
1258 private void mnuCancelRadAppt_Click(object sender, EventArgs e)
1259 {
1260 AppointmentDeleteOneRadiology();
1261 }
1262
1263 private void mnuUndoCheckin_Click(object sender, EventArgs e)
1264 {
1265 AppointmentUndoCheckin();
1266 }
1267
1268 private void mnuReprintApptSlip_Click(object sender, EventArgs e)
1269 {
1270 int apptID = this.CGrid.SelectedAppointment;
1271 if (apptID <= 0) return;
1272
1273 CGAppointment a = (CGAppointment)this.Appointments.AppointmentTable[apptID];
1274
1275 PrintAppointmentSlip(a);
1276 }
1277
1278 #endregion AppointmentMenu Handlers
1279
1280 #region ContextMenu1 Handlers
1281
1282 private void contextMenu1_Popup(object sender, System.EventArgs e)
1283 {
1284 //Enable/disable OpenSchedule and Find Appointment options
1285 bool bEnabled = (m_alSelectedTreeResourceArray.Count > 0)? true : false ;
1286 this.ctxOpenSchedule.Enabled = bEnabled;
1287 this.ctxFindAppt.Enabled = bEnabled;
1288 this.ctxPrintScheduleT0.Enabled = bEnabled;
1289 this.ctxPrintScheduleT1.Enabled = bEnabled;
1290 this.ctxPrintScheduleT3.Enabled = bEnabled;
1291
1292 //properties not supported now
1293 this.ctxProperties.Enabled = false;
1294 this.ctxProperties.Visible = false;
1295
1296 //Enable/disable Availability menu option
1297 if (m_alSelectedTreeResourceArray.Count != 1)
1298 {
1299 this.ctxEditAvailability.Enabled = false;
1300 return;
1301 }
1302
1303 if (this.DocManager.ScheduleManager == true)
1304 {
1305 ctxEditAvailability.Enabled = true;
1306 return;
1307 }
1308
1309 string sResource = (string) m_alSelectedTreeResourceArray[0];
1310 DataTable dt = this.DocManager.GlobalDataSet.Tables["ResourceUser"];
1311 DataView dv = new DataView(dt, "", "RESOURCENAME ASC", DataViewRowState.OriginalRows);
1312 string sDuz = CGDocumentManager.Current.RemoteSession.User.Duz;
1313 bool bModSchedule = false;
1314 DataRowView[] drvA = dv.FindRows(sResource);
1315 if (drvA.Length == 0)
1316 {
1317 this.ctxEditAvailability.Enabled = false;
1318 }
1319 else
1320 {
1321 string sModSchedule = "NO";
1322 foreach (DataRowView drv in drvA)
1323 {
1324 if (drv["USERID"].ToString() == sDuz)
1325 {
1326 sModSchedule = drv["MODIFY_SCHEDULE"].ToString();
1327 break;
1328 }
1329 }
1330
1331 bModSchedule = (sModSchedule == "YES")?true:false;
1332 this.ctxEditAvailability.Enabled = bModSchedule;
1333 }
1334 }
1335
1336 private void ctxEditAvailability_Click(object sender, System.EventArgs e)
1337 {
1338 this.EditScheduleAvailability();
1339 }
1340
1341 private void ctxOpenSchedule_Click(object sender, System.EventArgs e)
1342 {
1343 OpenSelectedSchedule(m_alSelectedTreeResourceArray, DateTime.Today);
1344 }
1345
1346 private void ctxPrintScheduleT0_Click(object sender, EventArgs e)
1347 {
1348 PrintClinicSchedule(DateTime.Today, DateTime.Today);
1349 }
1350
1351 private void ctxPrintScheduleT1_Click(object sender, EventArgs e)
1352 {
1353 PrintClinicSchedule(DateTime.Today.AddDays(1), DateTime.Today.AddDays(1));
1354 }
1355
1356 private void ctxPrintScheduleT3_Click(object sender, EventArgs e)
1357 {
1358 PrintClinicSchedule(DateTime.Today.AddDays(3), DateTime.Today.AddDays(3));
1359 }
1360
1361 private void ctxProperties_Click(object sender, System.EventArgs e)
1362 {
1363 //TODO: Implement Properties dialog
1364 MessageBox.Show("TODO: Implement Properties dialog");
1365 }
1366
1367 private void ctxFindAppt_Click(object sender, System.EventArgs e)
1368 {
1369 FindAvailableAppointment(m_alSelectedTreeResourceArray);
1370 }
1371
1372 #endregion ContextMenu1 Handlers
1373
1374 #region ctxApptClipMenu Handlers
1375
1376 private void mnuClearClipItems_Click(object sender, System.EventArgs e)
1377 {
1378 this.m_ClipList.ClearAllAppointments();
1379 lstClip.Items.Clear();
1380 }
1381
1382 private void mnuRemoveClipItem_Click(object sender, System.EventArgs e)
1383 {
1384 int i = lstClip.SelectedIndex;
1385 CGAppointment a = (CGAppointment) lstClip.SelectedItem;
1386 int nKey = a.AppointmentKey;
1387 if (i > -1)
1388 {
1389 m_ClipList.RemoveAppointment(nKey);
1390 lstClip.Items.RemoveAt(i);
1391 }
1392 }
1393
1394 private void ctxApptClipMenu_Popup(object sender, System.EventArgs e)
1395 {
1396 mnuClearClipItems.Enabled = (m_ClipList.AppointmentTable.Count > 0);
1397 mnuRemoveClipItem.Enabled = (lstClip.SelectedIndex > -1);
1398 }
1399
1400 #endregion ctxApptClipMenu Handlers
1401
1402 #region ctxCalGridMenu Handlers
1403
1404 private void ctxCalendarGrid_Popup(object sender, System.EventArgs e)
1405 {
1406 // our flags
1407 bool _findApptsEnabled = (this.Document.Resources.Count > 0) ? true : false;
1408 bool _addApptsEnabled = AddAppointmentEnabled();
1409 bool _editApptsEnabled = EditAppointmentEnabled();
1410 bool _isRadAppt = IsThisARadiologyResource();
1411 bool _noShowEnabled = NoShowEnabled();
1412 bool _undoCheckinEnabled = UndoCheckinEnabled();
1413 //end flags
1414
1415 if (_isRadAppt)//this is a radiology resource
1416 {
1417 ctxCalGridAdd.Visible = false;
1418 ctxCalGridDelete.Visible = false;
1419 ctxCalGridEdit.Visible = false;
1420 ctxCalGridCheckIn.Visible = false;
1421 ctxCalGridNoShow.Visible = false;
1422 ctxCalGridNoShowUndo.Visible = false;
1423 ctxCalGridWalkin.Visible = false;
1424 ctxCalGridUndoCheckin.Visible = false;
1425 ctxCalGridSep1.Visible = false;
1426 ctxCalGridSep2.Visible = false;
1427
1428 ctxCalGridMkRadAppt.Visible = true;
1429 ctxCalGridCancelRadAppt.Visible = true;
1430
1431
1432 }
1433
1434 else // this is a normal resource
1435 {
1436 ctxCalGridAdd.Visible = true;
1437 ctxCalGridDelete.Visible = true;
1438 ctxCalGridEdit.Visible = true;
1439 ctxCalGridCheckIn.Visible = true;
1440 ctxCalGridNoShow.Visible = true;
1441 ctxCalGridNoShowUndo.Visible = true;
1442 ctxCalGridWalkin.Visible = true;
1443 ctxCalGridUndoCheckin.Visible = true;
1444 ctxCalGridSep1.Visible = true;
1445 ctxCalGridSep2.Visible = true;
1446
1447 ctxCalGridMkRadAppt.Visible = false;
1448 ctxCalGridCancelRadAppt.Visible = false;
1449 }
1450
1451 //Toggle availability of make, edit, checkin and delete appointments etc
1452 //based on whether appropriate element is selected.
1453 ctxCalGridAdd.Enabled = _addApptsEnabled && !_isRadAppt;
1454 ctxCalGridWalkin.Enabled = _addApptsEnabled && !_isRadAppt;
1455 ctxCalGridEdit.Enabled = _editApptsEnabled && !_isRadAppt;;
1456 ctxCalGridDelete.Enabled = _editApptsEnabled && !_isRadAppt;
1457
1458 ctxCalGridCheckIn.Enabled = _editApptsEnabled && !_isRadAppt;
1459 ctxCalGridUndoCheckin.Enabled = _undoCheckinEnabled && !_isRadAppt;
1460 ctxCalGridNoShow.Enabled = _noShowEnabled && _editApptsEnabled;
1461 ctxCalGridNoShowUndo.Enabled = !_noShowEnabled && _editApptsEnabled;
1462 ctxCalGridReprintApptSlip.Enabled = _editApptsEnabled;
1463
1464 //if the rad ones are visible, then these apply
1465 ctxCalGridMkRadAppt.Enabled = _isRadAppt && _addApptsEnabled;
1466 ctxCalGridCancelRadAppt.Enabled = _isRadAppt && _editApptsEnabled;
1467 }
1468
1469 private void ctxCalGridAdd_Click(object sender, System.EventArgs e)
1470 {
1471 AppointmentAddNew();
1472 }
1473
1474 private void calendarGrid1_DoubleClick(object sender, System.EventArgs e)
1475 {
1476 if (calendarGrid1.SelectedAppointment > 0)
1477 AppointmentEdit();
1478 }
1479
1480 private void ctxCalGridEdit_Click(object sender, System.EventArgs e)
1481 {
1482 AppointmentEdit();
1483 }
1484
1485 private void ctxCalGridDelete_Click(object sender, System.EventArgs e)
1486 {
1487 AppointmentDelete();
1488 }
1489
1490 private void ctxCalGridCheckIn_Click(object sender, System.EventArgs e)
1491 {
1492 AppointmentCheckIn();
1493 }
1494
1495 private void ctxCalGridNoShow_Click(object sender, System.EventArgs e)
1496 {
1497 AppointmentNoShow(true);
1498 }
1499
1500 private void ctxCalGridNoShowUndo_Click(object sender, System.EventArgs e)
1501 {
1502 AppointmentNoShow(false);
1503 }
1504
1505 private void ctxCalGridMkRadAppt_Click(object sender, EventArgs e)
1506 {
1507 AppointmentAddNewRadiology();
1508 }
1509
1510 private void ctxCalGridCancelRadAppt_Click(object sender, EventArgs e)
1511 {
1512 AppointmentDeleteOneRadiology();
1513 }
1514
1515 private void ctxCalGridReprintApptSlip_Click(object sender, EventArgs e)
1516 {
1517 int apptID = this.CGrid.SelectedAppointment;
1518 if (apptID <= 0) return;
1519
1520 CGAppointment a = (CGAppointment) this.Appointments.AppointmentTable[apptID];
1521
1522 PrintAppointmentSlip(a);
1523 }
1524
1525 #endregion ctxCalGridMenu Handlers
1526
1527 #region Methods
1528
1529 /// <summary>
1530 /// Decides whether this is a Radiology Resource. Local Helper to decide what menu items to enable/display
1531 /// </summary>
1532 /// <returns></returns>
1533 private bool IsThisARadiologyResource()
1534 {
1535 //I don't like this logic!!! but works for now!
1536 //Note: I use banana peeling model below
1537
1538 //If no cell is selected AND no appointment is selected, then it's false
1539 if (this.calendarGrid1.SelectedRange.Cells.CellCount < 1 && this.calendarGrid1.SelectedAppointment < 1)
1540 return false;
1541
1542 //If an appointment is selected then...
1543 if (this.calendarGrid1.SelectedAppointment > 0)
1544 {
1545 CGAppointment appt = this.Appointments.AppointmentTable[this.calendarGrid1.SelectedAppointment] as CGAppointment;
1546 if (appt == null) return false; //appt doesn't exist; old appointment and grid wasn't refreshed yet
1547 if (appt.RadiologyExamIEN.HasValue && appt.RadiologyExamIEN.Value > 0) return true; //this appointment is a radiology appointment since it has that member
1548 else return false;
1549
1550 }
1551
1552 //Otherwise, we are for sure dealing with a cell.
1553 //We need to determine if the cell resource is mapped to a Radiology Hospital Location.
1554 DateTime dStart;
1555 DateTime dEnd;
1556 string sResource;
1557
1558 // Get resource
1559 bool bRet = this.calendarGrid1.GetSelectedTime(out dStart, out dEnd, out sResource);
1560
1561 // If we fail, return false (but this is not supposed to ever happen)
1562 if (bRet == false)
1563 {
1564 return false;
1565 }
1566
1567 // see if resource is mapped to a Radiology Hospital Location.
1568 return IsThisARadiologyResource(sResource);
1569 }
1570
1571 private bool IsThisARadiologyResource(string sResource)
1572 {
1573 //smh - change in v 1.7... if the resource is not linked to a PIMS clinic, this method fails.
1574 //This happens if there is just one resource that is not linked, which makes it impossible to
1575 //make any appointments, because this method gets called at any time a menu is opened.
1576 //So we change res.Field<int> to res.Field<int?>
1577
1578 // see if resource is mapped to a Radiology Hospital Location.
1579 return ( //select all Hospital Locations which are radiology locations
1580 from hl in CGDocumentManager.Current.GlobalDataSet.Tables["HospitalLocation"].AsEnumerable()
1581 where hl.Field<string>("IS_RADIOLOGY_LOCATION") == "1"
1582 //join this to the resources table using the foreign ID (plain jane relational join)
1583 join res in CGDocumentManager.Current.GlobalDataSet.Tables["Resources"].AsEnumerable()
1584 //on hl.Field<int>("HOSPITAL_LOCATION_ID") equals res.Field<int>("HOSPITAL_LOCATION_ID") //change in 1.7
1585 on hl.Field<int>("HOSPITAL_LOCATION_ID") equals res.Field<int?>("HOSPITAL_LOCATION_ID")
1586 //then filter this down to the resource that we have
1587 where res.Field<string>("RESOURCE_NAME") == sResource
1588 //if we have any row left, then it is true.
1589 select hl).Any();
1590 }
1591
1592 private bool EditAppointmentEnabled()
1593 {
1594 try
1595 {
1596 //Call here if there is a selected appointment in the grid
1597 if (calendarGrid1.SelectedAppointment < 1)
1598 return false;
1599 CGAppointment appt = (CGAppointment)this.Appointments.AppointmentTable[calendarGrid1.SelectedAppointment];
1600 string sResource = appt.Resource;
1601 return EditAppointmentEnabled(sResource);
1602
1603 }
1604 catch (Exception ex)
1605 {
1606 string sMsg = ex.Message;
1607 return false;
1608 }
1609 }
1610
1611 private bool EditAppointmentEnabled(string sResource)
1612 {
1613
1614 bool bManager = this.DocManager.ScheduleManager;
1615 if (bManager == true)
1616 {
1617 return (true);
1618 }
1619 else
1620 {
1621 bool bModAppts;
1622 bModAppts = (bool)this.m_htChangeAppts[sResource];
1623 return bModAppts;
1624 }
1625 }
1626
1627 private bool AddAppointmentEnabled()
1628 {
1629 if (this.calendarGrid1.SelectedRange.Cells.CellCount < 1)
1630 return false;
1631
1632 bool bManager = this.DocManager.ScheduleManager;
1633 if (bManager == true)
1634 {
1635 return (true);
1636 }
1637 else
1638 {
1639 DateTime dStart = DateTime.Today;
1640 DateTime dEnd = DateTime.Today;
1641 string sResource = "";
1642 bool bRet = this.calendarGrid1.GetSelectedTime(out dStart, out dEnd, out sResource);
1643 if (bRet == false)
1644 {
1645 return false;
1646 }
1647 bool bSlotsAvailable;
1648 bool bOverbook;
1649 bool bModSchedule;
1650 bool bModAppts;
1651 bOverbook = (bool)this.m_htOverbook[sResource];
1652 bModSchedule = (bool)this.m_htModifySchedule[sResource];
1653 bModAppts = (bool)this.m_htChangeAppts[sResource];
1654 if (bModAppts == false)
1655 return false;
1656
1657 CGAvailability resultantAvail;
1658 m_nSlots = m_Document.SlotsAvailable(dStart, dEnd, sResource, this.calendarGrid1.TimeScale, out resultantAvail);
1659
1660 bSlotsAvailable = (this.m_nSlots > 0);
1661 return ((bSlotsAvailable) || (bModSchedule) || (bOverbook));
1662 }
1663 }
1664
1665 private bool NoShowEnabled()
1666 {
1667 if (calendarGrid1.SelectedAppointment < 1)
1668 return false;
1669 CGAppointment appt = (CGAppointment)this.Appointments.AppointmentTable[calendarGrid1.SelectedAppointment];
1670 return !appt.NoShow;
1671 }
1672
1673 private bool UndoCheckinEnabled()
1674 {
1675 if (calendarGrid1.SelectedAppointment < 1) return false;
1676 CGAppointment appt = (CGAppointment)this.Appointments.AppointmentTable[calendarGrid1.SelectedAppointment];
1677 return appt.CheckInTime.Ticks > 0;
1678 }
1679
1680 /// <summary>
1681 /// Clean up any resources being used.
1682 /// </summary>
1683 protected override void Dispose( bool disposing )
1684 {
1685 if( disposing )
1686 {
1687 if(components != null)
1688 {
1689 components.Dispose();
1690 }
1691 }
1692 base.Dispose( disposing );
1693 }
1694
1695 void UpdateStatusBar(DateTime dStart, DateTime dEnd, CGAvailability av)
1696 {
1697 System.Text.StringBuilder sbMsg = new System.Text.StringBuilder(100);
1698 sbMsg.Append(dStart.ToShortTimeString() + " to " + dEnd.ToShortTimeString());
1699 if (av != null && m_nSlots > 0)
1700 {
1701 sbMsg.Append(String.Format(" has {0} slot(s) available for {1}. ", m_nSlots.ToString(), av.AccessTypeName));
1702 }
1703 else
1704 {
1705 sbMsg.Append(": No appointment slots available. ");
1706 }
1707
1708 if (av != null)
1709 {
1710 sbMsg.Append(String.Format("Source Block: {0} to {1} with {2} slot(s) of type {3}",
1711 av.StartTime.ToShortTimeString(),
1712 av.EndTime.ToShortTimeString(),
1713 av.Slots.ToString(),
1714 av.AccessTypeName));
1715
1716 sbMsg.Append(". ");
1717
1718 if (av.Note.Trim().Length > 0) sbMsg.Append("Note: " + av.Note + ".");
1719 }
1720
1721 this.statusBar1.Text = sbMsg.ToString();
1722 }
1723
1724 private void EditScheduleAvailability()
1725 {
1726 CGAVDocument doc = new CGAVDocument();
1727 try
1728 {
1729 //If resource already open, then navigate to its window
1730 CGAVView v =this.DocManager.GetAVViewByResource(m_alSelectedTreeResourceArray);
1731
1732 if (v != null)
1733 {
1734 v.Activate();
1735 }
1736 else
1737 {
1738 //If not already open, get a lock and open it
1739 doc.DocManager = this.DocManager;
1740 for (int j=0; j < m_alSelectedTreeResourceArray.Count; j++)
1741 {
1742 doc.AddResource((string) m_alSelectedTreeResourceArray[j]);
1743 }
1744 doc.DocName = this.m_sDocName;
1745
1746 //Get preferred time scale from resource info
1747
1748 DataTable dt = this.DocManager.GlobalDataSet.Tables["Resources"];
1749 DataView dv = new DataView(dt, "", "RESOURCE_NAME ASC", DataViewRowState.OriginalRows);
1750 int nScale = 60;
1751 int nTest=0;
1752 string sResource;
1753 int nDataRow;
1754 DataRowView drv;
1755 string sResourceID="";
1756 for (int j=0; j < m_alSelectedTreeResourceArray.Count; j++)
1757 {
1758 sResource = (string) m_alSelectedTreeResourceArray[j];
1759 nDataRow = dv.Find(sResource);
1760 Debug.Assert(nDataRow != -1);
1761 drv = dv[nDataRow];
1762 if (drv["TIMESCALE"].ToString() == "")
1763 {
1764 nTest = 15; //15 minute default
1765 }
1766 else
1767 {
1768 nTest = (int) drv["TIMESCALE"];
1769 }
1770 nScale = (nTest < nScale)?nTest : nScale ;
1771 sResourceID = drv["RESOURCEID"].ToString();
1772 }
1773
1774 doc.ResourceID = Convert.ToInt32(sResourceID);
1775
1776 bool bLock = CGDocumentManager.Current.RemoteSession.Lock("^BSDXRES(" + sResourceID + ")", "+");
1777 if (bLock == false)
1778 {
1779 throw new BMXNetException("Another user is currently editing availability for this resource. Try later.");
1780 }
1781
1782 doc.OnOpenDocument();
1783 v =this.DocManager.GetAVViewByResource(m_alSelectedTreeResourceArray);
1784 CalendarGrid cg = v.CGrid;
1785
1786 cg.TimeScale = nScale;
1787
1788 //Position grid to 0700
1789 cg.PositionGrid(7);
1790 }
1791 }
1792 catch (Exception ex)
1793 {
1794 MessageBox.Show("Unable to edit availability for " + m_sDocName + " schedule. " + ex.Message, "Clinical Scheduling");
1795 this.m_DocManager.CloseAllViews(doc);
1796 return;
1797 }
1798 }
1799
1800 /// <summary>
1801 /// Opens a view of the Schedule a user requested to open at a specific date
1802 /// </summary>
1803 /// <param name="sSelectedTreeResourceArray">A set of resources to open (?pending more investigation)</param>
1804 /// <param name="dDate">Date at which to show the Grid</param>
1805 private void OpenSelectedSchedule(ArrayList sSelectedTreeResourceArray, DateTime dDate)
1806 {
1807 //If resource already open, then navigate to its window
1808 CGView v = this.DocManager.GetViewByResource(sSelectedTreeResourceArray);
1809 if (v != null)
1810 {
1811 v.Activate();
1812 v.dateTimePicker1.Value = dDate;
1813 v.RequestRefreshGrid();
1814 return;
1815 }
1816
1817 //So if it is not a view that's already open, it means we have to grab the data for
1818 //So we tell the user to wait wait wait
1819 this.Cursor = Cursors.WaitCursor;
1820 this.LoadSplash(); //Open "Loading" splash
1821
1822
1823 //If this Document has no resources then use it (happens when the GUI has nothing open, typically after log-in)
1824 //Else, create a new document
1825 CGDocument doc;
1826 if (this.Document.m_sResourcesArray.Count == 0)
1827 {
1828 doc = this.Document;
1829 }
1830 else
1831 {
1832 doc = new CGDocument();
1833 doc.DocManager = this.DocManager;
1834 }
1835
1836 //Add resources to Document
1837 for (int j=0; j < sSelectedTreeResourceArray.Count; j++)
1838 {
1839 doc.AddResource((string) sSelectedTreeResourceArray[j]);
1840 }
1841
1842 doc.DocName = this.m_sDocName;
1843
1844 try
1845 {
1846 doc.OnOpenDocument(dDate); //this typically creates a new view
1847 }
1848
1849 catch (Exception ex)
1850 {
1851 MessageBox.Show("Unable to open " + m_sDocName + " schedule. " + ex.Message, "Clinical Scheduling");
1852 this.m_DocManager.CloseAllViews(doc);
1853 return;
1854 }
1855
1856 //We are doing this--again--to fetch the view we just opened in OnOpenDocument
1857 //XXX: Yes, I know, this totally sucks. But I don't fully grasp the whole thing yet to refactor it.
1858 v =this.DocManager.GetViewByResource(sSelectedTreeResourceArray);
1859
1860 //Position the Grid to start at a certain day.
1861 //XXX: This must be a better way to do this.
1862 v.dateTimePicker1.Value = dDate;
1863 v.StartDate = doc.StartDate;
1864
1865 //Get preferred time scale from resource info
1866 //If more than one resource, get smallest time scale
1867 CalendarGrid cg = v.CGrid;
1868 DataTable dt = this.DocManager.GlobalDataSet.Tables["Resources"];
1869 DataView dv = new DataView(dt, "", "RESOURCE_NAME ASC", DataViewRowState.OriginalRows);
1870 int nScale = 60;
1871 int nTest=0;
1872 string sResource;
1873 int nDataRow;
1874 DataRowView drv;
1875 for (int j=0; j < sSelectedTreeResourceArray.Count; j++)
1876 {
1877 sResource = (string) sSelectedTreeResourceArray[j];
1878 nDataRow = dv.Find(sResource);
1879 Debug.Assert(nDataRow != -1);
1880 drv = dv[nDataRow];
1881 if (drv["TIMESCALE"].ToString() == "")
1882 {
1883 nTest = 15; //15 minute default
1884 }
1885 else
1886 {
1887 nTest = (int) drv["TIMESCALE"];
1888 }
1889 nScale = (nTest < nScale)?nTest : nScale ;
1890 }
1891
1892 cg.TimeScale = nScale;
1893
1894 cg.PositionGrid(7);
1895
1896 //new code for v 1.5 //smh
1897 //Disable entries that would make time scale smaller b/c users should not be able to
1898 //make appointments for smaller time scales
1899 if (nScale >= 10)
1900 {
1901 v.mnu10Minute.Enabled = true;
1902 v.mnu15Minute.Enabled = true;
1903 v.mnu20Minute.Enabled = true;
1904 v.mnu30Minute.Enabled = true;
1905 }
1906 if (nScale >= 15)
1907 {
1908 v.mnu10Minute.Enabled = false;
1909 v.mnu15Minute.Enabled = true;
1910 v.mnu20Minute.Enabled = true;
1911 v.mnu30Minute.Enabled = true;
1912 }
1913 if (nScale >= 20)
1914 {
1915 v.mnu10Minute.Enabled = false;
1916 v.mnu15Minute.Enabled = false;
1917 v.mnu20Minute.Enabled = true;
1918 v.mnu30Minute.Enabled = true;
1919 }
1920 if (nScale >= 30)
1921 {
1922 v.mnu10Minute.Enabled = false;
1923 v.mnu15Minute.Enabled = false;
1924 v.mnu20Minute.Enabled = false;
1925 v.mnu30Minute.Enabled = true;
1926 }
1927 if (nScale >= 60)
1928 {
1929 v.mnu10Minute.Enabled = false;
1930 v.mnu15Minute.Enabled = false;
1931 v.mnu20Minute.Enabled = false;
1932 v.mnu30Minute.Enabled = false;
1933 }
1934 //end new code
1935
1936 //Get the OverBook and ModifySchedule permissions from ResourceUser table
1937 //and populate the hashtables
1938 string sOverbook;
1939 string sModSchedule;
1940 string sModAppts;
1941 bool bOverbook;
1942 bool bModSchedule;
1943 bool bModAppts;
1944 v.m_htOverbook = new Hashtable(sSelectedTreeResourceArray.Count);
1945 v.m_htModifySchedule = new Hashtable(sSelectedTreeResourceArray.Count);
1946 v.m_htChangeAppts = new Hashtable(sSelectedTreeResourceArray.Count);
1947 dt = this.DocManager.GlobalDataSet.Tables["ResourceUser"];
1948 dv = new DataView(dt, "", "RESOURCENAME ASC", DataViewRowState.OriginalRows);
1949 dv.RowFilter = String.Format("USERNAME = '{0}'", CGDocumentManager.Current.RemoteSession.User.Name.Replace("'", "''"));
1950
1951 for (int j=0; j < dv.Count; j++)
1952 {
1953 drv = dv[j];
1954 sResource = drv["RESOURCENAME"].ToString();
1955 sOverbook = drv["OVERBOOK"].ToString();
1956 bOverbook = (sOverbook == "YES")?true:false;
1957 sModSchedule = drv["MODIFY_SCHEDULE"].ToString();
1958 bModSchedule = (sModSchedule == "YES")?true:false;
1959 sModAppts = drv["MODIFY_APPOINTMENTS"].ToString();
1960 bModAppts = (sModAppts == "YES")?true:false;
1961 v.m_htOverbook[sResource] = bOverbook;
1962 v.m_htModifySchedule[sResource] = bModSchedule;
1963 v.m_htChangeAppts[sResource] = bModAppts;
1964 }
1965
1966 //For programmers and scheduling managers, set all permissions for all resources
1967 if (this.DocManager.ScheduleManager == true)
1968 {
1969 dt = this.DocManager.GlobalDataSet.Tables["Resources"];
1970 foreach (DataRow dr in dt.Rows)
1971 {
1972 sResource = dr["RESOURCE_NAME"].ToString();
1973 v.m_htOverbook[sResource] = true;
1974 v.m_htModifySchedule[sResource] = true;
1975 v.m_htChangeAppts[sResource] = true;
1976 }
1977 }
1978
1979 v.calendarGrid1.SetOverlapTable();
1980 v.calendarGrid1.Refresh();
1981
1982 // Set cursor back and stop splash screen
1983 this.Cursor = Cursors.Default;
1984 StopSplash();
1985 }
1986
1987 private void LoadTree()
1988 {
1989 //Navigate from ResourceGroup table to Resources table
1990 DataRow[] arrRows;
1991 DataRelation dr = DocManager.GlobalDataSet.Relations["GroupResource"];
1992 string sGroup;
1993 string sResource;
1994 int nIndex = 0;
1995 foreach (DataRow r in DocManager.GlobalDataSet.Tables["ResourceGroup"].Rows)
1996 {
1997 sGroup = r["RESOURCE_GROUP"].ToString();
1998 TreeNode deptNode = new TreeNode(sGroup);
1999 nIndex = this.tvSchedules.Nodes.Add(deptNode);
2000 tvSchedules.Nodes[nIndex].Tag = "Dept";
2001 arrRows = r.GetChildRows(dr);
2002 for (int i=0; i< arrRows.Length; i++)
2003 {
2004 sResource = arrRows[i]["RESOURCE_NAME"].ToString();
2005 TreeNode resNode = new TreeNode(sResource);
2006 int nResIndex = deptNode.Nodes.Add(resNode);
2007 deptNode.Nodes[nResIndex].Tag = "Resource";
2008 }
2009 }
2010 }
2011
2012 public void CreateNewSchedule()
2013 {
2014 //Create a new document and open it
2015 CGDocument doc = new CGDocument();
2016 doc.DocManager = this.DocManager;
2017 try
2018 {
2019 doc.OnOpenDocument(DateTime.Today);
2020 }
2021 catch (Exception ex)
2022 {
2023 MessageBox.Show("Unable to open " + m_sDocName + " schedule. " + ex.Message, "Clinical Scheduling");
2024 this.m_DocManager.CloseAllViews(doc);
2025 return;
2026 }
2027 }
2028
2029 private void AppointmentEdit()
2030 {
2031 try
2032 {
2033 int nApptID = this.calendarGrid1.SelectedAppointment;
2034 Debug.Assert(nApptID != 0);
2035
2036 CGAppointment a = (CGAppointment) this.Appointments.AppointmentTable[nApptID];
2037
2038 DAppointPage dAppt = new DAppointPage();
2039 dAppt.DocManager = this.m_DocManager;
2040 dAppt.InitializePage(a);
2041
2042 calendarGrid1.CGToolTip.Active = false;
2043
2044 if (dAppt.ShowDialog(this) == DialogResult.Cancel)
2045 {
2046 calendarGrid1.CGToolTip.Active = true;
2047 return;
2048 }
2049 calendarGrid1.CGToolTip.Active = true;
2050
2051 string sNote = dAppt.Note;
2052
2053 //Call Document to edit appointment
2054 this.Document.EditAppointment(a, sNote);
2055
2056 if (dAppt.PrintAppointmentSlip)
2057 {
2058 PrintAppointmentSlip(a);
2059 }
2060
2061 //Redraw appointments
2062 this.UpdateArrays();
2063
2064 //Then tell RPMS that we are updated
2065 RaiseRPMSEvent("BSDX SCHEDULE", a.Resource);
2066 }
2067 catch (Exception ex)
2068 {
2069 Debug.Write("CGView.AppointmentEdit Failed: " + ex.Message);
2070 }
2071 }
2072
2073 /// <summary>
2074 /// Marks all selected appointments as No Show from this.calendarGrid1.SelectedAppointments
2075 /// </summary>
2076 /// <param name="bNoShow">True - Mark as noshow; False - undo noshow</param>
2077 private void AppointmentNoShow(bool bNoShow)
2078 {
2079
2080 //bNoShow indicates whether to mark or un-mark as noshow
2081 bool bMarked = false; //Indicates at least one attempt to mark as noshow succeeded
2082 bool bRebook = false; //Stores user's response to auto-rebook dialog question
2083 CGAppointments alRebookList = new CGAppointments(); // list of appointments to rebook
2084
2085 DNoShow dlg = new DNoShow(); // no show dialog
2086
2087 if (bNoShow == true) // if noshowing, show the dialog to ask the user
2088 {
2089 if (dlg.ShowDialog(this) == DialogResult.Cancel)
2090 {
2091 return;
2092 }
2093 }
2094
2095 bRebook = dlg.AutoRebook;
2096
2097 foreach (CGAppointment a in this.calendarGrid1.SelectedAppointments.AppointmentTable.Values)
2098 {
2099 int nApptID = a.AppointmentKey;
2100 Debug.Assert(nApptID != 0);
2101 try
2102 {
2103 if ((bNoShow == true) // if no-showing
2104 &&
2105 (a.StartTime.Date > DateTime.Today.Date)
2106 &&
2107 (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))
2108 {
2109 }
2110 else // otherwise, make or undo show
2111 {
2112 string sError = Document.AppointmentNoShow(a, bNoShow);
2113 if (sError != "1")
2114 throw new Exception(sError);
2115
2116 bMarked = true;
2117 }
2118 }
2119 catch (Exception ex)
2120 {
2121 MessageBox.Show("Unable to mark appointment No Show: " + ex.Message, "Clinical Scheduling");
2122 }
2123
2124 if (bRebook == true)
2125 {
2126 try
2127 {
2128 CGAppointment aRebook;
2129 int nMinimumdays = dlg.RebookStartDays;
2130 int nMaximumdays = dlg.RebookMaxDays;
2131 int nAccessType = dlg.RebookAccessType;
2132 //-1 means use current type
2133
2134 if (nAccessType == -1)
2135 {
2136 //Get access type from grid
2137 int nRow = 0;
2138 int nCol = 0;
2139 CGCell cgCell = new CGCell();
2140 this.calendarGrid1.GetCellFromTime(a.StartTime, ref nRow, ref nCol, true , a.Resource);
2141 cgCell.CellColumn = nCol;
2142 cgCell.CellRow = nRow;
2143 this.calendarGrid1.GetTypeFromCell(cgCell, out nAccessType);
2144 a.AccessTypeID = nAccessType;
2145 }
2146 string sResult = Document.AutoRebook(a, nAccessType, nMinimumdays, nMaximumdays, out aRebook);
2147 if (sResult == "1")
2148 {
2149 //Add appointment to list of rebooked appointments
2150 alRebookList.AddAppointment(a);
2151 }
2152 else
2153 {
2154 MessageBox.Show("Unable to rebook this patient: " + a.PatientName);
2155 }
2156
2157 }
2158 catch (Exception ex)
2159 {
2160 MessageBox.Show("Unable to rebook: " + ex.Message);
2161 }
2162 }
2163
2164 if (bMarked == true)
2165 {
2166 //Notify other scheduling users that this schedule has changed
2167 try
2168 {
2169 //this.Document.RefreshDocument(); no need for this; event raised back and prompts refresh itself.
2170 RaiseRPMSEvent("BSDX SCHEDULE", a.Resource);
2171 }
2172 catch (Exception ex)
2173 {
2174 Debug.Write(ex.Message);
2175 }
2176 this.calendarGrid1.Invalidate();
2177 }
2178 }
2179 AutoRebookFromList(alRebookList);
2180 }
2181
2182 /// <summary>
2183 /// Prints Auto Rebook Letters; does nothing else to DB!!!
2184 /// </summary>
2185 /// <param name="alRebookList">List of appointments</param>
2186 private void AutoRebookFromList(CGAppointments alRebookList)
2187 {
2188 //Print AutoRebook letters.
2189 if (alRebookList.AppointmentCount > 0)
2190 {
2191 //build |-delimited list of ApptIDs to pass to BSDX REBOOK LIST
2192 string sApptIDList = "";
2193
2194 System.Collections.ArrayList a = new ArrayList();
2195
2196 foreach (CGAppointment appt in alRebookList.AppointmentTable.Values)
2197 {
2198 string sApptID = appt.AppointmentKey.ToString() + "|";
2199 sApptIDList += sApptID;
2200 if (a.Contains(appt.Resource) == false)
2201 a.Add(appt.Resource);
2202 }
2203
2204 // Print rebooks
2205 string sClinicList = "";
2206 foreach (string sRes in a)
2207 {
2208 sClinicList = sClinicList + sRes + "|";
2209 }
2210 DPatientLetter dpl = new DPatientLetter();
2211 dpl.InitializeFormRebookLetters(this.DocManager, sClinicList, sApptIDList);
2212 dpl.ShowDialog(this);
2213 }
2214 }
2215
2216 /// <summary>
2217 /// Delete one Radiology Appointment
2218 /// </summary>
2219 private void AppointmentDeleteOneRadiology()
2220 {
2221 Debug.Assert(this.calendarGrid1.SelectedAppointment > 0);
2222
2223 CGAppointment a = this.Appointments.AppointmentTable[this.calendarGrid1.SelectedAppointment] as CGAppointment;
2224
2225 Debug.Assert(a.RadiologyExamIEN.HasValue);
2226
2227 //Can we cancel the appointment?
2228 bool _canCancel = CGDocumentManager.Current.DAL.CanCancelRadExam(a.RadiologyExamIEN.Value);
2229
2230 if (!_canCancel)
2231 {
2232 MessageBox.Show(this, "This appointment cannot be cancelled.\nReason:\nThe exam associated with this appointment is active/complete/discontinued.");
2233 return;
2234 }
2235
2236 //Prior to making expensive db calls, tell the grid nothing is selected anymore so nobody would try to pick it up later
2237 this.calendarGrid1.SelectedAppointment = 0;
2238
2239 //Now, Cancel the appointment
2240 this.Document.DeleteAppointment(a.AppointmentKey);
2241
2242 //Cancel Radiology Exam
2243 CGDocumentManager.Current.DAL.CancelRadiologyExam(a.PatientID, a.RadiologyExamIEN.Value);
2244
2245 //redraw the grid to display new set of appointments after this appt was removed.
2246 this.UpdateArrays();
2247
2248 //Tell other instances that this schedule has been updated
2249 RaiseRPMSEvent("BSDX SCHEDULE", a.Resource);
2250 }
2251
2252 /// <summary>
2253 /// Delete appointment ApptID
2254 /// </summary>
2255 /// <param name="nApptID"></param>
2256 /// <returns></returns>
2257 private string AppointmentDeleteOne(int nApptID)
2258 {
2259 return Document.DeleteAppointment(nApptID);
2260 }
2261
2262 /// <summary>
2263 /// Delete all selected appointments
2264 /// </summary>
2265 private void AppointmentDelete()
2266 {
2267 calendarGrid1.CGToolTip.Active = false;
2268 CGAppointments alRebookList = new CGAppointments();
2269
2270 // check to see if any appointment is checked in first
2271 foreach (CGAppointment a in this.calendarGrid1.SelectedAppointments.AppointmentTable.Values)
2272 {
2273 if (a.CheckInTime.Ticks > 0)
2274 {
2275 MessageBox.Show("You must undo the check-in first before removing the appointment.");
2276 return;
2277 }
2278 }
2279
2280 DCancelAppt dCancel = new DCancelAppt();
2281 dCancel.InitializePage(this.m_DocManager);
2282 if (dCancel.ShowDialog(this) != DialogResult.OK)
2283 {
2284 calendarGrid1.CGToolTip.Active = true;
2285 return;
2286 }
2287
2288 //At this point, the appointment will be deleted...
2289 //Remove the Selected Appointment from the grid because we don't anybody to think there's still
2290 //an appointment selected while we are still updating the grid
2291 this.calendarGrid1.SelectedAppointment = 0;
2292
2293 bool bClinic = dCancel.ClinicCancelled;
2294 int nReason = dCancel.CancelReason;
2295 string sRemarks = dCancel.CancelRemarks;
2296 bool bRebook = dCancel.AutoRebook;
2297 int nRebookStart = dCancel.RebookStartDays;
2298 int nRebookMax = dCancel.RebookMaxDays;
2299 int nRebookAccessType = dCancel.RebookAccessType;
2300
2301 calendarGrid1.CGToolTip.Active = true;
2302
2303 foreach (CGAppointment a in this.calendarGrid1.SelectedAppointments.AppointmentTable.Values)
2304 {
2305
2306 int nApptID = a.AppointmentKey;
2307 Debug.Assert(nApptID != 0);
2308 try
2309 {
2310 string sError = Document.DeleteAppointment(nApptID, bClinic, nReason, sRemarks);
2311 if (sError != "")
2312 throw new Exception(sError);
2313
2314 this.UpdateArrays(); //Redraw this calendar grid
2315
2316 if (bRebook == true)
2317 {
2318 try
2319 {
2320 //TODO: Parameterize or dialogize the minum and maximum rebook days
2321 CGAppointment aRebook;
2322 int nMinimumdays = nRebookStart;
2323 int nMaximumdays = nRebookMax;
2324 string sResult = Document.AutoRebook(a, nRebookAccessType, nMinimumdays, nMaximumdays, out aRebook);
2325 if (sResult == "1")
2326 {
2327 //Add appointment to list of rebooked appointments
2328 alRebookList.AddAppointment(a);
2329 }
2330
2331 }
2332 catch (Exception ex)
2333 {
2334 MessageBox.Show("Unable to rebook: " + ex.Message);
2335 }
2336 }
2337
2338 RaiseRPMSEvent("BSDX SCHEDULE", a.Resource);
2339 }
2340 catch (Exception ex)
2341 {
2342 MessageBox.Show("Unable to delete appointment. " + ex.Message, "Clinical Scheduling");
2343 }
2344
2345
2346 if (alRebookList.AppointmentCount > 0)
2347 {
2348 AutoRebookFromList(alRebookList);
2349 }
2350 }
2351 }
2352
2353 private void AppointmentCheckIn()
2354 {
2355 int nApptID = this.calendarGrid1.SelectedAppointment;
2356 Debug.Assert(nApptID != 0);
2357
2358 //smh
2359 //CGAppointment a = (CGAppointment) this.Appointments.AppointmentTable[nApptID];
2360 CGAppointment a = (CGAppointment)this.Document.Appointments.AppointmentTable[nApptID];
2361 try
2362 {
2363 bool bAlreadyCheckedIn = false;
2364 if (a.CheckInTime.Ticks > 0)
2365 bAlreadyCheckedIn = true;
2366
2367 if ((bAlreadyCheckedIn == false)
2368 &&
2369 (a.StartTime.Date > DateTime.Today.Date))
2370 {
2371 MessageBox.Show(this, "It is too early to check in " + a.PatientName, "Windows Scheduling", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
2372 return;
2373 }
2374
2375 DCheckIn dlgCheckin = new DCheckIn();
2376 dlgCheckin.InitializePage(a);
2377 calendarGrid1.CGToolTip.Active = false;
2378 if (dlgCheckin.ShowDialog(this) != DialogResult.OK)
2379 {
2380 calendarGrid1.CGToolTip.Active = true;
2381 return;
2382 }
2383 calendarGrid1.CGToolTip.Active = true;
2384
2385 if (bAlreadyCheckedIn != true)
2386 {
2387 DateTime dtCheckIn = dlgCheckin.CheckInTime;
2388
2389 //Tell appointment that it is checked in, for proper coloring;
2390 //When you refresh from the DB, it will have this property.
2391 a.CheckInTime = DateTime.Now;
2392
2393 //Save to Database
2394 this.Document.CheckInAppointment(nApptID, dtCheckIn);
2395 }
2396
2397 //Get Provider (XXXXXXXX: NOT SAVED TO THE DATABASE RIGHT NOW)
2398 a.Provider = dlgCheckin.Provider;
2399
2400 // Print Routing Slip if user checks that box...
2401 if (dlgCheckin.PrintRouteSlip)
2402 this.PrintRoutingSlip(a);
2403
2404 //redraw grid
2405 this.calendarGrid1.Invalidate();
2406 }
2407 catch (Exception ex)
2408 {
2409 MessageBox.Show("Error checking in patient: " + ex.Message, "Clinical Scheduling");
2410 }
2411
2412 }
2413
2414 private void AppointmentUndoCheckin()
2415 {
2416 Debug.Assert(calendarGrid1.SelectedAppointment > 0);
2417
2418 foreach (CGAppointment a in this.calendarGrid1.SelectedAppointments.AppointmentTable.Values)
2419 {
2420
2421 string msg; //out var
2422 bool didweSucceed = Document.AppointmentUndoCheckin(a, out msg);
2423
2424 if (!didweSucceed)
2425 {
2426 MessageBox.Show("Error: " + msg);
2427 continue;
2428 }
2429
2430 RaiseRPMSEvent("BSDX SCHEDULE", a.Resource);
2431 }
2432
2433 this.UpdateArrays();
2434 }
2435
2436 private void AppointmentAddWalkin()
2437 {
2438 try
2439 {
2440
2441
2442 //Get Time and Resource from Selected Cell
2443 DateTime dStart = DateTime.Today;
2444 DateTime dEnd = DateTime.Today;
2445 string sResource = "";
2446 bool bRet = this.calendarGrid1.GetSelectedTime(out dStart, out dEnd, out sResource);
2447 if (bRet == false)
2448 return;
2449
2450 TimeSpan tsDuration = dEnd - dStart;
2451 int nDuration = (int) tsDuration.TotalMinutes;
2452 Debug.Assert(nDuration > 0);
2453
2454 /*
2455 * 8-10-05 Added check to prevent walkin from being created
2456 * on a date later than today.
2457 */
2458
2459 if (dStart.Date > DateTime.Today.Date)
2460 {
2461 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);
2462 return;
2463 }
2464
2465 // Added check for making Walk-ins in the past. 9/28/2010
2466 if (dStart.Date < DateTime.Today.Date)
2467 {
2468 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);
2469 if (result == DialogResult.No) return;
2470 }
2471
2472 /*
2473 * 8-10-05 Added overbook prompt for walkin
2474 */
2475 //SMH: Takes too long to do.
2476 //this.Document.RefreshDocument();
2477 CGAvailability resultantAvail;
2478
2479 m_nSlots = m_Document.SlotsAvailable(dStart, dEnd, sResource, this.calendarGrid1.TimeScale, out resultantAvail);
2480
2481 if (m_nSlots < 1)
2482 {
2483 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);
2484 if (dr != DialogResult.Yes)
2485 {
2486 return;
2487 }
2488 }
2489
2490 //Display a dialog to collect Patient Name
2491 DPatientLookup dPat = new DPatientLookup();
2492 dPat.DocManager = m_DocManager;
2493
2494 int nAccessTypeID = 0;
2495 bRet = calendarGrid1.GetSelectedType(out nAccessTypeID);
2496
2497 if (dPat.ShowDialog(this) == DialogResult.Cancel)
2498 {
2499 return;
2500 }
2501
2502 CGAppointment appt = new CGAppointment();
2503 appt.PatientID = Convert.ToInt32(dPat.PatientIEN);
2504 appt.PatientName = dPat.PatientName;
2505 appt.StartTime = dStart;
2506 appt.EndTime = dEnd;
2507 appt.Resource = sResource;
2508 appt.HealthRecordNumber = dPat.HealthRecordNumber;
2509
2510 appt.Patient = new Patient
2511 {
2512 DFN = Convert.ToInt32(dPat.PatientIEN),
2513 ID = dPat.PatientPID,
2514 Name = dPat.PatientName,
2515 HRN = dPat.HealthRecordNumber,
2516 DOB = dPat.PatientDOB
2517 };
2518
2519 //smh: Takes too long
2520 //this.Document.RefreshDocument();
2521
2522 //Call Document to add a walkin appointment
2523 int nApptID = this.Document.CreateAppointment(appt, true);
2524
2525 //Now check them in.
2526 calendarGrid1.SelectedAppointment = nApptID;
2527 AppointmentCheckIn();
2528
2529 //Show the new set of appointments by calling UpdateArrays.
2530 this.UpdateArrays();
2531
2532 RaiseRPMSEvent("BSDX SCHEDULE", appt.Resource);
2533 }
2534 catch (Exception ex)
2535 {
2536 string msg;
2537 if (M.Piece(ex.Message, "~", 1) == "-10") // -10 means that BSDXAPI reported an error.
2538 msg = M.Piece(ex.Message, "~", 4);
2539 else
2540 msg = ex.Message;
2541
2542 MessageBox.Show("VISTA says: \r\n" + msg, "Unable to Make Walk-in Appointment");
2543 return;
2544 }
2545 }
2546
2547 private void AppointmentAddNew()
2548 {
2549 try
2550 {
2551 //Get Time and Resource from Selected Cell
2552 DateTime dStart = DateTime.Today;
2553 DateTime dEnd = DateTime.Today;
2554 string sResource = "";
2555 bool bRet = this.calendarGrid1.GetSelectedTime(out dStart, out dEnd, out sResource);
2556 if (bRet == false)
2557 return;
2558
2559 // Added check for making Walk-ins in the past. 9/28/2010
2560 if (dStart.Date < DateTime.Today.Date)
2561 {
2562 var result = MessageBox.Show("Are you sure you want to make an appointment in the past?", "Windows Scheduling", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2);
2563 if (result == DialogResult.No) return;
2564 }
2565
2566 //Test dStart for Holiday
2567 DataView dvHoliday = new DataView(this.DocManager.GlobalDataSet.Tables["HOLIDAY"]);
2568 dvHoliday.Sort="DATE ASC";
2569 int nFind = dvHoliday.Find(dStart.Date);
2570 if (nFind > -1)
2571 {
2572 string sHoliday = "";
2573 DataRowView drv = dvHoliday[nFind];
2574 sHoliday = drv["NAME"].ToString();
2575 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)
2576 return;
2577 }
2578
2579 //Sam: takes too long. Remove this call; deal with the issue of concurrent appointments another way.
2580 //this.Document.RefreshDocument();
2581 CGAvailability resultantAvail;
2582 m_nSlots = m_Document.SlotsAvailable(dStart, dEnd, sResource, this.calendarGrid1.TimeScale, out resultantAvail);
2583
2584 if (m_nSlots < 1)
2585 {
2586 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);
2587 if (dr != DialogResult.Yes)
2588 {
2589 return;
2590 }
2591 }
2592
2593 //Display a dialog to collect Patient Name
2594 DPatientLookup dPat = new DPatientLookup();
2595 dPat.DocManager = m_DocManager;
2596
2597 int nAccessTypeID = 0;
2598 bRet = calendarGrid1.GetSelectedType(out nAccessTypeID);
2599
2600 if (dPat.ShowDialog(this) == DialogResult.Cancel)
2601 {
2602 return;
2603 }
2604
2605 //Call the appointment dialog to collect the appointment info
2606 Debug.Assert(dPat.PatientIEN != "");
2607 DAppointPage dAppt = new DAppointPage();
2608 dAppt.DocManager = this.m_DocManager;
2609 string sNote = "";
2610 dAppt.InitializePage(dPat.PatientIEN, dStart, dEnd, sResource, sNote, nAccessTypeID);
2611
2612 if (dAppt.ShowDialog(this) == DialogResult.Cancel)
2613 {
2614 return;
2615 }
2616
2617 CGAppointment appt = dAppt.Appointment;
2618
2619 // old way of making an appointment
2620 /*new CGAppointment();
2621 appt.PatientID = Convert.ToInt32(dPat.PatientIEN);
2622 appt.PatientName = dPat.PatientName;
2623 appt.StartTime = dStart;
2624 appt.EndTime = dEnd;
2625 appt.Resource = sResource;
2626 appt.Note = dAppt.Note;
2627 appt.HealthRecordNumber = dPat.HealthRecordNumber;
2628 appt.AccessTypeID = nAccessTypeID;
2629 */
2630
2631 //Call Document to add a new appointment. Document adds appointment to CGAppointments array.
2632 this.Document.CreateAppointment(appt);
2633
2634
2635 if (dAppt.PrintAppointmentSlip)
2636 {
2637 PrintAppointmentSlip(appt);
2638 }
2639
2640 //Show the new set of appointments by calling UpdateArrays. Fetches Document's CGAppointments
2641 this.UpdateArrays();
2642
2643 RaiseRPMSEvent("BSDX SCHEDULE", appt.Resource);
2644 }
2645 catch (Exception ex)
2646 {
2647 string msg;
2648 if (M.Piece(ex.Message, "~", 1) == "-10") // -10 means that BSDXAPI reported an error.
2649 msg = M.Piece(ex.Message, "~", 4);
2650 else
2651 msg = ex.Message;
2652
2653 MessageBox.Show("VISTA says: \r\n" + msg, "Unable to Make Appointment");
2654 return;
2655 }
2656 }
2657
2658 /// <summary>
2659 /// Add a new Radiology Appointment to VISTA (ÒÝÊì as my mom calls it)
2660 /// </summary>
2661 private void AppointmentAddNewRadiology()
2662 {
2663 try
2664 {
2665 DateTime dStart, dEnd; //return vales for below
2666 string sResource; //ditto
2667 int nAccessTypeID = 0; //ditto
2668
2669 this.calendarGrid1.GetSelectedTime(out dStart, out dEnd, out sResource);
2670 this.calendarGrid1.GetSelectedType(out nAccessTypeID);
2671
2672 Debug.Assert(sResource != null);
2673 Debug.Assert(dStart > DateTime.MinValue);
2674
2675 //Get Slots
2676 CGAvailability resultantAvail;
2677 m_nSlots = m_Document.SlotsAvailable(dStart, dEnd, sResource, this.calendarGrid1.TimeScale, out resultantAvail);
2678
2679 if (m_nSlots < 1)
2680 {
2681 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);
2682 if (dr != DialogResult.Yes)
2683 {
2684 return;
2685 }
2686 }
2687
2688 //Display a dialog to collect Patient Name
2689 DPatientLookup dPat = new DPatientLookup();
2690 dPat.DocManager = m_DocManager;
2691
2692 if (dPat.ShowDialog(this) == DialogResult.Cancel)
2693 {
2694 return;
2695 }
2696
2697 int DFN = Int32.Parse(dPat.PatientIEN);
2698 // Hospital Location IEN
2699 int hlIEN = (from resource in CGDocumentManager.Current.GlobalDataSet.Tables["Resources"].AsEnumerable()
2700 where resource.Field<string>("RESOURCE_NAME") == sResource
2701 select resource.Field<int>("HOSPITAL_LOCATION_ID")).FirstOrDefault();
2702
2703 //Get Radiology Exams from the DB
2704 List<RadiologyExam> _radExams = CGDocumentManager.Current.DAL.GetRadiologyExamsForPatientinHL(DFN, hlIEN);
2705
2706 //If none found...
2707 if (!_radExams.Any())
2708 {
2709 MessageBox.Show("Patient does not have any radiology exams to register.");
2710 return;
2711 }
2712
2713 //Display a form for the user to select radiology exams.
2714 DRadExamsSelect _radform = new DRadExamsSelect(_radExams);
2715
2716 if (_radform.ShowDialog() == DialogResult.Cancel) return;
2717
2718 //Get some return values
2719 int _examien = _radform.ExamIEN;
2720 string _procedurename = _radform.ProcedureName;
2721
2722 //Now create and save the appointment
2723 CGAppointment appt = new CGAppointment();
2724 string _sNote = "Radiology Exam (" + _examien + "): " + _procedurename;
2725 appt.CreateAppointment(dStart, dEnd, _sNote, 0, sResource);
2726 appt.PatientID = Int32.Parse(dPat.PatientIEN);
2727 appt.PatientName = dPat.PatientName;
2728 appt.AccessTypeID = nAccessTypeID;
2729 appt.RadiologyExamIEN = _examien;
2730 appt.Patient = new Patient
2731 {
2732 DFN = Convert.ToInt32(dPat.PatientIEN),
2733 ID = dPat.PatientPID,
2734 Name = dPat.PatientName,
2735 HRN = dPat.HealthRecordNumber,
2736 DOB = dPat.PatientDOB
2737 };
2738
2739 this.Document.CreateAppointment(appt);
2740
2741 //Save Radiology Exam Schedule Info to Radiology Package
2742 CGDocumentManager.Current.DAL.ScheduleRadiologyExam(DFN, _examien, dStart);
2743
2744 //Print Appointment Slip if requested
2745 if (_radform.PrintAppointmentSlip) this.PrintAppointmentSlip(appt);
2746
2747 //Now redraw the grid to display the new appointments
2748 this.UpdateArrays();
2749
2750 //Raise event to other clients
2751 RaiseRPMSEvent("BSDX SCHEDULE", appt.Resource);
2752 }
2753 catch (Exception ex)
2754 {
2755 string msg;
2756 if (M.Piece(ex.Message, "~", 1) == "-10") // -10 means that BSDXAPI reported an error.
2757 msg = M.Piece(ex.Message, "~", 4);
2758 else
2759 msg = ex.Message;
2760
2761 MessageBox.Show("VISTA says: \r\n" + msg, "Unable to Make Appointment");
2762 return;
2763 }
2764 }
2765
2766
2767 #region BMX Event Processing and Callbacks
2768 /// <summary>
2769 /// Loosely typed delegate used several times below.
2770 /// </summary>
2771 delegate void OnUpdateScheduleDelegate();
2772
2773 /// <summary>
2774 /// Subscription point for each CGView to process BMX events polled from the server
2775 /// </summary>
2776 /// <param name="obj">Not used</param>
2777 /// <param name="e">BMXEvent Args:
2778 /// e.BMXEvent is free text for Event Type; e.BMXParam is free text for Event Arguments</param>
2779 private void BMXNetEventHandler(Object obj, RemoteEventArgs e)
2780 {
2781 try
2782 {
2783 // if this class is undefined (e.g. if the user just closed the form, do nothing
2784 if (this == null) return;
2785
2786 // if event is Autofire event
2787 if (e.EventType == "BMXNet AutoFire")
2788 {
2789 Debug.Write("CGView caught AutoFire event.\n");
2790
2791 //Create a delegate to OnUpdateSchedule and call Async
2792 //Once Async Call is done, go to OnUpdateScheduleCallback
2793 OnUpdateScheduleDelegate ousd = new OnUpdateScheduleDelegate(OnUpdateSchedule);
2794 ousd.BeginInvoke(OnUpdateScheduleCallback, null);
2795
2796 return;
2797 }
2798
2799 // if event is BSDX SCHEDULE
2800 else if (e.EventType == "BSDX SCHEDULE")
2801 {
2802 //See if any of the resources in the event argument matches BSDX Schedule.
2803 //If yes, fire off the delegate
2804 string sResourceName;
2805 for (int j = 0; j < m_Document.m_sResourcesArray.Count; j++)
2806 {
2807 sResourceName = m_Document.m_sResourcesArray[j].ToString();
2808 if (e.Details == sResourceName)
2809 {
2810 Debug.Write("CGView caught BSDX SCHEDULE event.\n");
2811
2812 //Create a delegate to OnUpdateSchedule and call Async
2813 //Once Async Call is done, go to OnUpdateScheduleCallb
2814 OnUpdateScheduleDelegate ousd = new OnUpdateScheduleDelegate(OnUpdateSchedule);
2815 ousd.BeginInvoke(OnUpdateScheduleCallback, null);
2816
2817 break;
2818 }
2819 }
2820 }
2821 }
2822 catch (Exception ex)
2823 {
2824 Debug.Write(ex.Message);
2825 }
2826 }
2827
2828 /// <summary>
2829 /// Update Appointments and Availabilites using Document.RefreshDocumentAsync on a different thread
2830 /// </summary>
2831 /// <remarks>
2832 /// This method is expected to be called asynchornously.
2833 /// </remarks>
2834 public void OnUpdateSchedule()
2835 {
2836 try
2837 {
2838 m_Document.RefreshDocumentAsync(); //new
2839 }
2840 catch (Exception ex)
2841 {
2842 MessageBox.Show("Unable to refresh document " + ex.Message, "Clinical Scheduling");
2843 }
2844 }
2845
2846 /// <summary>
2847 /// Callback for when OnUpdateSchedule is done. Triggers the Grid to redraw itself by calling UpdateArrays.
2848 /// </summary>
2849 /// <param name="itfAR">not used</param>
2850 /// <remarks>Calls UpdateArrays via this.Invoke to make sure that the grid is redrawn on the UI thread</remarks>
2851 private void OnUpdateScheduleCallback(IAsyncResult itfAR)
2852 {
2853 OnUpdateScheduleDelegate d = new OnUpdateScheduleDelegate(UpdateArrays);
2854
2855 //try catch just in case that the view closed in the meantime.
2856 try
2857 {
2858 this.Invoke(d);
2859 }
2860 catch (InvalidOperationException)
2861 {
2862 return;
2863 }
2864 }
2865
2866 /// <summary>
2867 /// Create a new event in RPMS. Wrapper around BMXConnectInfo.RaiseEvent
2868 /// </summary>
2869 /// <param name="sEvent">Name of Event to Raise</param>
2870 /// <param name="sParams">Parameter of Event to Raise</param>
2871 public void RaiseRPMSEvent(string sEvent, string sParams)
2872 {
2873 try
2874 {
2875 //Signal RPMS to raise an event
2876 CGDocumentManager.Current.RemoteSession.EventServices.TriggerEvent(sEvent, sParams, false);
2877 }
2878 catch (Exception ex)
2879 {
2880 Debug.Write(ex.Message);
2881 }
2882 }
2883
2884 #endregion
2885
2886 /// <summary>
2887 /// This is how you set how the grid will look
2888 /// </summary>
2889 public void UpdateArrays()
2890 {
2891 // Make sure that we are called synchronously
2892 Debug.Assert(this.InvokeRequired == false,"CGView.UpdateArrays InvokeRequired");
2893 // This is where you set how the grid will look
2894
2895 //Create Deep copy of Availability Array
2896 ArrayList availArrayCopy = new ArrayList();
2897 foreach (CGAvailability av in this.m_Document.AvailabilityArray)
2898 availArrayCopy.Add(av);
2899
2900 try
2901 {
2902 //Tell the grid about Avails, Appts, and Resources.
2903 this.calendarGrid1.AvailabilityArray = availArrayCopy;
2904 //Appts are cloned b/c if we tie into the class directly, we shoot off errors when we manipulate it.
2905 this.calendarGrid1.Appointments = (CGAppointments)this.m_Document.Appointments.Clone();
2906 this.calendarGrid1.Resources = this.m_Document.Resources;
2907 //Redraw the calendar grid
2908 this.calendarGrid1.OnUpdateArrays(); // this draws the Calendar
2909 this.lblResource.Text = this.m_Document.DocName;
2910 this.calendarGrid1.Invalidate();
2911 }
2912 catch (Exception ex)
2913 {
2914 MessageBox.Show("Unable to update arrays " + ex.Message, "Clinical Scheduling");
2915 }
2916 }
2917
2918 private void SchedulingManagement()
2919 {
2920 try
2921 {
2922 bool bLock = CGDocumentManager.Current.RemoteSession.Lock("^BSDXMGR", "+");
2923 if (bLock == false)
2924 {
2925 throw new Exception("Another user is currently in Scheduling Management. Try later.");
2926 }
2927
2928 DManagement dMgm = new DManagement();
2929 dMgm.InitializeDialog(this.m_DocManager);
2930
2931 if (dMgm.ShowDialog(this) == DialogResult.Cancel)
2932 {
2933 }
2934
2935 m_DocManager.GlobalDataSet.Tables["ResourceUser"].Clear();
2936 m_DocManager.LoadResourceUserTable(false);
2937 bLock = CGDocumentManager.Current.RemoteSession.Lock("^BSDXMGR", "-");
2938 }
2939 catch (ApplicationException aex)
2940 {
2941 string sMsg = aex.Message;
2942 MessageBox.Show("Unable to acquire transmit lock. Try later.");
2943 }
2944 catch (Exception ex)
2945 {
2946 MessageBox.Show("Scheduling Management Error: " + ex.Message, "Clinical Scheduling");
2947 }
2948 }
2949
2950 public void UpdateTree()
2951 {
2952 this.tvSchedules.Nodes.Clear();
2953 this.LoadTree();
2954 }
2955
2956 public void ViewPatientAppointments()
2957 {
2958 try
2959 {
2960 //Display a dialog to collect Patient Name
2961 DPatientLookup dPat = new DPatientLookup();
2962 dPat.DocManager = m_DocManager;
2963 if (dPat.ShowDialog(this) == DialogResult.Cancel)
2964 {
2965 return;
2966 }
2967
2968 Debug.Assert(dPat.PatientIEN != "");
2969 int nPatientID = Convert.ToInt32(dPat.PatientIEN);
2970 ViewPatientAppointments(nPatientID);
2971 }
2972 catch (Exception ex)
2973 {
2974 MessageBox.Show(this, ex.Message, "Clinical Scheduling", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
2975 }
2976 }
2977
2978 public void ViewPatientAppointments(int PatientID)
2979 {
2980 DPatientApptDisplay dPa = new DPatientApptDisplay();
2981
2982 dPa.InitializeForm(this.DocManager, PatientID);
2983
2984
2985 if (dPa.ShowDialog(this) != DialogResult.Cancel)
2986 {
2987
2988 }
2989
2990 }
2991
2992 private void FindAvailableAppointment(ArrayList alResourceArray)
2993 {
2994 DApptSearch dSearch = new DApptSearch();
2995 dSearch.InitializePage(alResourceArray, this.m_DocManager);
2996 if (dSearch.ShowDialog(this) == DialogResult.Cancel)
2997 return;
2998
2999 CGAvailability av = dSearch.SelectedAvailability;
3000
3001 ArrayList alResource = new ArrayList();
3002 alResource.Add(av.ResourceList);
3003 DateTime sDate = av.StartTime;
3004 m_sDocName = av.ResourceList;
3005 OpenSelectedSchedule(alResource, sDate);
3006
3007 }
3008
3009 #endregion Methods
3010
3011 #region Events
3012
3013 /// <summary>
3014 /// Special import to get the GetActiveWindow method from Win32
3015 /// </summary>
3016 /// <returns>Windows Handle number for Foregreound Active Window</returns>
3017 [DllImport("user32.dll")]
3018 static extern IntPtr GetActiveWindow();
3019
3020 /// <summary>
3021 /// If a mouse enters the grid, check if the grid is on the active form first before stealing the focus
3022 /// </summary>
3023 /// <param name="sender"></param>
3024 /// <param name="e"></param>
3025 private void calendarGrid1_MouseEnter(object sender, EventArgs e)
3026 {
3027 if (GetActiveWindow() == this.Handle)
3028 calendarGrid1.Focus();
3029 }
3030
3031 /// <summary>
3032 /// If mouse enters the Tree Section, check if the grid is on the active form first before stealing the focus
3033 /// </summary>
3034 /// <param name="sender"></param>
3035 /// <param name="e"></param>
3036 private void tvSchedules_MouseEnter(object sender, EventArgs e)
3037 {
3038 if (GetActiveWindow() == this.Handle)
3039 tvSchedules.Focus();
3040 }
3041
3042 private void CGView_Load(object sender, System.EventArgs e)
3043 {
3044 Debug.Assert (this.Document != null);
3045
3046 //Register the view
3047 CGDocumentManager.Current.RegisterDocumentView(this.Document, this);
3048
3049 //Load the Group-Resource treeview
3050 LoadTree();
3051
3052 this.SetDesktopLocation(this.DesktopLocation.X + 10, this.DesktopLocation.Y + 10);
3053
3054 //Show the Form
3055 this.Activate();
3056
3057 //Set focus on the calendar grid
3058 this.calendarGrid1.Focus();
3059 }
3060
3061 private void mnuOpenSchedule_Click(object sender, System.EventArgs e)
3062 {
3063 CreateNewSchedule();
3064 }
3065
3066 private void mnu1Day_Click(object sender, System.EventArgs e)
3067 {
3068 DateTime dtPicker = dateTimePicker1.Value;
3069 DateTime DayOnly = new DateTime(dtPicker.Year, dtPicker.Month, dtPicker.Day);
3070 this.calendarGrid1.StartDate = DayOnly;
3071 this.calendarGrid1.Columns = 1;
3072 }
3073
3074 private void mnu5Day_Click(object sender, System.EventArgs e)
3075 {
3076 if (this.calendarGrid1.Columns == 1)
3077 {
3078 this.StartDate = this.Document.StartDate;
3079 }
3080
3081 this.calendarGrid1.Columns = 5;
3082 this.Document.m_nColumnCount = 5; // MJL 1/17/2007
3083 RequestRefreshGrid();
3084 }
3085
3086 private void mnu7Day_Click(object sender, System.EventArgs e)
3087 {
3088 this.calendarGrid1.Columns = 7;
3089 this.Document.m_nColumnCount = 7; // MJL 1/17/2007
3090 RequestRefreshGrid();
3091 }
3092
3093 private void mnu10Minute_Click(object sender, System.EventArgs e)
3094 {
3095 CalendarGrid cg = this.calendarGrid1;
3096 cg.TimeScale = 10;
3097 cg.PositionGrid(7);
3098 }
3099
3100 private void mnu15Minute_Click(object sender, System.EventArgs e)
3101 {
3102 CalendarGrid cg = this.calendarGrid1;
3103 cg.TimeScale = 15;
3104 cg.PositionGrid(7);
3105 }
3106
3107 private void mnu20Minute_Click(object sender, System.EventArgs e)
3108 {
3109 CalendarGrid cg = this.calendarGrid1;
3110 cg.TimeScale = 20;
3111 cg.PositionGrid(7);
3112 }
3113
3114 private void mnu30Minute_Click(object sender, System.EventArgs e)
3115 {
3116 CalendarGrid cg = this.calendarGrid1;
3117 cg.TimeScale = 30;
3118 cg.PositionGrid(7);
3119 }
3120
3121 private void mnuViewScheduleTree_Click(object sender, System.EventArgs e)
3122 {
3123 this.mnuViewScheduleTree.Checked = this.tvSchedules.Visible;
3124 this.tvSchedules.Visible = !(this.tvSchedules.Visible);
3125 this.mnuViewScheduleTree.Checked = !(this.mnuViewScheduleTree.Checked);
3126 }
3127
3128
3129
3130 private void tvSchedules_DoubleClick(object sender, System.EventArgs e)
3131 {
3132 if (m_alSelectedTreeResourceArray == null)
3133 return;
3134 if (m_alSelectedTreeResourceArray.Count < 1)
3135 {
3136 if (this.tvSchedules.SelectedNode.Text != "")
3137 {
3138 SetResourceArrayFromGroup(tvSchedules.SelectedNode.Text);
3139 }
3140 else
3141 {
3142 return;
3143 }
3144 }
3145 OpenSelectedSchedule(m_alSelectedTreeResourceArray, DateTime.Today);
3146 }
3147
3148 //20041109 Added
3149 private void SetResourceArrayFromGroup(string sGroup)
3150 {
3151 //Navigate from ResourceGroup table to Resources table
3152 DataRow[] arrRows;
3153 DataRelation dr = DocManager.GlobalDataSet.Relations["GroupResource"];
3154 DataRow r = DocManager.GlobalDataSet.Tables["ResourceGroup"].Rows.Find(sGroup);
3155 arrRows = r.GetChildRows(dr);
3156 for (int i=0; i< arrRows.Length; i++)
3157 {
3158 string sResource = arrRows[i]["RESOURCE_NAME"].ToString();
3159 m_alSelectedTreeResourceArray.Add(sResource);
3160 }
3161 m_sDocName = sGroup;
3162 }
3163
3164 public void SyncTree()
3165 {
3166
3167 }
3168
3169
3170 private void tvSchedules_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
3171 {
3172 m_alSelectedTreeResourceArray = new ArrayList();
3173 string sResource = e.Node.FullPath;
3174 string[] ss = sResource.Split((char) 92);
3175 int l = ss.GetUpperBound(0);
3176
3177 if (l == 0) //a resource group was checked, so get all underying resources
3178 {
3179 SetResourceArrayFromGroup(ss[0]);
3180 }
3181 else
3182 {
3183 sResource = ss[l];
3184 m_alSelectedTreeResourceArray.Add(ss[1]);
3185 }
3186
3187 m_sDocName = ss[l];
3188 return;
3189
3190 }
3191
3192 /// <summary>
3193 /// Makes sure that the node gets selected no matter where we click.
3194 /// Incidentally, Invokes AfterSelect event.
3195 /// </summary>
3196 /// <param name="sender"></param>
3197 /// <param name="e"></param>
3198 private void tvSchedules_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
3199 {
3200 e.Node.TreeView.SelectedNode = e.Node;
3201 }
3202
3203 private void CGView_Closing(object sender, System.ComponentModel.CancelEventArgs e)
3204 {
3205 try
3206 {
3207 CGDocumentManager.Current.RemoteSession.EventServices.RpmsEvent -= BMXNetEventHandler;
3208 this.calendarGrid1.CloseGrid();
3209 }
3210 catch (Exception ex)
3211 {
3212 Debug.Write("CGView_Closing exception: " + ex.Message + "\n");
3213 }
3214 }
3215
3216 private void mnuViewRightPanel_Click(object sender, System.EventArgs e)
3217 {
3218 this.mnuViewRightPanel.Checked = this.panelRight.Visible;
3219 this.panelRight.Visible = !(this.panelRight.Visible);
3220 this.mnuViewRightPanel.Checked = !(this.mnuViewRightPanel.Checked);
3221 }
3222
3223
3224 private void calendarGrid1_CGSelectionChanged(object sender, IndianHealthService.ClinicalScheduling.CGSelectionChangedArgs e)
3225 {
3226 CGAvailability resultantAvail;
3227 m_nSlots = m_Document.SlotsAvailable(e.StartTime, e.EndTime, e.Resource, this.calendarGrid1.TimeScale, out resultantAvail);
3228 UpdateStatusBar(e.StartTime, e.EndTime, resultantAvail);
3229 }
3230
3231 /// <summary>
3232 /// Fired during drag and drop, on the drop action.
3233 /// </summary>
3234 /// <param name="sender"></param>
3235 /// <param name="e"></param>
3236 private void calendarGrid1_CGAppointmentChanged(object sender, IndianHealthService.ClinicalScheduling.CGAppointmentChangedArgs e)
3237 {
3238 try
3239 {
3240 // added April 13 2011
3241 // Can't edit radiology appointments (Why? b/c it's intimately tied to Radiology Entry of the Hosp Loc)
3242 if (e.Appointment.RadiologyExamIEN.HasValue && e.Appointment.RadiologyExamIEN.Value > 0)
3243 {
3244 MessageBox.Show("You cannot move a radiology appointment.", "Clinical Scheduling");
3245 return;
3246 }
3247
3248 // added May 5 2011
3249 // Can't move an appointment to a radiology resource
3250 if (IsThisARadiologyResource(e.Resource))
3251 {
3252 MessageBox.Show("You cannot move an appointment to a radiology location.", "Clinical Scheduling");
3253 return;
3254 }
3255
3256 if (e.Appointment.CheckInTime.Ticks > 0)
3257 {
3258 MessageBox.Show("You cannot change the appointment time because the patient has already checked in.", "Clinical Scheduling");
3259 return;
3260 }
3261
3262 // Added check for making Walk-ins/appts in the past. 9/28/2010 //smh
3263 if (e.StartTime < DateTime.Today.Date)
3264 {
3265 var result = MessageBox.Show("Are you sure you want to make an appointment in the past?", "Windows Scheduling", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2);
3266 if (result == DialogResult.No) return;
3267 }
3268
3269 //Can user edit destination resource?
3270 if (EditAppointmentEnabled(e.Resource) == false)
3271 return;
3272
3273 //Can user edit original schedule?
3274 if (EditAppointmentEnabled(e.Appointment.Resource) == false)
3275 return;
3276
3277 if (MessageBox.Show("Are you sure you want to move this appointment?", "Clinical Scheduling", MessageBoxButtons.YesNo) != DialogResult.Yes)
3278 return;
3279
3280 //20040909 Cherokee Replaced this block with following
3281 // if (m_Document.SlotsAvailable(e.StartTime, e.EndTime, e.Resource, out sAccessType, out sAvailabilityMessage) < 1)
3282 // {
3283 // MessageBox.Show("There are no appointment slots available for the selected time.");
3284 // return;
3285 // }
3286 bool bOverbook =false;
3287 if (m_htOverbook.Count > 0)
3288 {
3289 bOverbook = (bool) this.m_htOverbook[e.Resource.ToString()];
3290 }
3291 bool bModSchedule =false;
3292 if (m_htModifySchedule.Count > 0)
3293 {
3294 bModSchedule = (bool) this.m_htModifySchedule[e.Resource.ToString()];
3295 }
3296 CGAvailability resultantAvail;
3297 bool bSlotsAvailable = (m_Document.SlotsAvailable(e.StartTime, e.EndTime, e.Resource, this.calendarGrid1.TimeScale, out resultantAvail) > 0);
3298 if (!((bSlotsAvailable) || (bModSchedule) || (bOverbook) ))
3299 {
3300 MessageBox.Show("There are no appointment slots available for the selected time.");
3301 return;
3302 }
3303
3304 /*
3305 * 7-19-05 Added overbook prompt
3306 */
3307 if (bSlotsAvailable == false)
3308 {
3309 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);
3310 if (dr != DialogResult.Yes)
3311 {
3312 return;
3313 }
3314 }
3315
3316 //Create a new appointment using old data for patient demographics and note and new data
3317 //for StartTime, EndTime, Resource, AccessTypeID
3318 CGAppointment appt = new CGAppointment();
3319 appt.PatientID = e.Appointment.PatientID;
3320 appt.PatientName = e.Appointment.PatientName;
3321 appt.StartTime = e.StartTime;
3322 appt.EndTime = e.EndTime;
3323 appt.Resource = e.Resource;
3324 appt.Note = e.Appointment.Note;
3325 appt.HealthRecordNumber = e.Appointment.HealthRecordNumber;
3326 appt.AccessTypeID = e.AccessTypeID;
3327 appt.Patient = e.Appointment.Patient;
3328
3329 this.Document.CreateAppointment(appt);
3330
3331 //CGAppointment a = new CGAppointment();
3332 //a.StartTime = e.StartTime;
3333 ////e.Appointment.StartTime = e.StartTime
3334 //a.EndTime = e.EndTime;
3335 ////e.Appointment.EndTime = e.EndTime;
3336 //a.Resource = e.Resource;
3337 ////e.Appointment.Resource = e.Resource;
3338 //a.AccessTypeID = e.AccessTypeID;
3339 ////e.Appointment.AccessTypeID = e.AccessTypeID;
3340 //m_Document.CreateAppointment(a);
3341
3342
3343 string sError = AppointmentDeleteOne(e.Appointment.AppointmentKey);
3344 if (sError != "")
3345 {
3346 MessageBox.Show(sError);
3347 return;
3348 }
3349
3350 }
3351 catch (Exception ex)
3352 {
3353 MessageBox.Show("Unable to change appointment " + ex.Message, "Clinical Scheduling");
3354 //this.m_DocManager.UpdateViews();
3355 return;
3356 }
3357 finally
3358 {
3359 this.UpdateArrays();
3360 }
3361 try
3362 {
3363 RaiseRPMSEvent("BSDX SCHEDULE" , e.Resource);
3364 if (e.Resource != e.OldResource)
3365 RaiseRPMSEvent("BSDX SCHEDULE", e.OldResource);
3366
3367 //That will take too long. Don't do it. Try and see what happens when you come
3368 //this.m_DocManager.UpdateViews(e.Resource, e.OldResource);
3369 }
3370 catch (Exception ex)
3371 {
3372 Debug.Write(ex.Message);
3373 }
3374 }
3375
3376 private void mnuSchedulingManagment_Click(object sender, System.EventArgs e)
3377 {
3378 SchedulingManagement();
3379 }
3380
3381 private void mnuFile_Popup(object sender, System.EventArgs e)
3382 {
3383 this.mnuSchedulingManagment.Enabled = DocManager.ScheduleManager;
3384 }
3385
3386 private void mnuFindAppt_Click(object sender, System.EventArgs e)
3387 {
3388 FindAvailableAppointment(this.Document.Resources);
3389 }
3390
3391 private void mnuRPMSServer_Click(object sender, System.EventArgs e)
3392 {
3393 //Handled by DocumentManager class
3394 }
3395
3396 private void mnuRPMSLogin_Click(object sender, System.EventArgs e)
3397 {
3398 //Handled by DocumentManager class
3399 }
3400
3401 private void CGView_Activated(object sender, System.EventArgs e)
3402 {
3403 calendarGrid1.GridEnter = true;
3404 }
3405
3406 private void mnuHelpAbout_Click(object sender, System.EventArgs e)
3407 {
3408 MessageBox.Show("Clinical Scheduling Version " + Application.ProductVersion, "Clinical Scheduling", MessageBoxButtons.OK, MessageBoxIcon.Information);
3409 }
3410
3411 private void ImplementMsg()
3412 {
3413 MessageBox.Show("Clinical Scheduling", "TODO: Implement this function");
3414 }
3415
3416 private void mnuClose_Click(object sender, System.EventArgs e)
3417 {
3418 DialogResult dr = MessageBox.Show("Are you sure you want to close this schedule?", Application.ProductName, MessageBoxButtons.OKCancel);
3419 if (dr != DialogResult.OK)
3420 return;
3421
3422 this.Close();
3423 }
3424
3425 private void mnuViewPatientAppts_Click(object sender, System.EventArgs e)
3426 {
3427 ViewPatientAppointments();
3428 }
3429
3430 private void lstClip_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
3431 {
3432 bool b = e.Data.GetDataPresent(typeof(CGAppointment));
3433 if (b == true)
3434 {
3435 e.Effect = DragDropEffects.Move;
3436 }
3437 else
3438 {
3439 e.Effect = DragDropEffects.None;
3440 }
3441
3442 }
3443
3444 private void lstClip_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
3445 {
3446 try
3447 {
3448 CGAppointment a = (CGAppointment) e.Data.GetData(typeof(CGAppointment));
3449 if (m_ClipList.AppointmentTable.Contains((int) a.AppointmentKey))
3450 {
3451 return;
3452 }
3453
3454 if (a.RadiologyExamIEN.HasValue)
3455 {
3456 MessageBox.Show("Cannot move a radiology appointment to the clipboard");
3457 return;
3458 }
3459
3460 m_ClipList.AddAppointment(a);
3461 lstClip.Items.Add(a);
3462 }
3463 catch(Exception ex)
3464 {
3465 Debug.Write(ex.Message);
3466 }
3467
3468 }
3469
3470 private void lstClip_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
3471 {
3472 m_bDragDropStart = false;
3473 }
3474
3475 private void lstClip_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
3476 {
3477 try
3478 {
3479 if ((m_bDragDropStart == false)&&(lstClip.SelectedIndex > -1))
3480 {
3481 CGAppointment a = (CGAppointment) lstClip.Items[lstClip.SelectedIndex];
3482 this.calendarGrid1.ApptDragSource = "list";
3483 DragDropEffects effect = DoDragDrop(a, DragDropEffects.Move);
3484 m_bDragDropStart = true;
3485 }
3486 }
3487 catch (Exception ex)
3488 {
3489 Debug.Write(ex.Message);
3490 }
3491 }
3492
3493 private void calendarGrid1_CGAppointmentAdded(object sender, IndianHealthService.ClinicalScheduling.CGAppointmentChangedArgs e)
3494 {
3495 try
3496 {
3497 bool bSlotsAvailable;
3498 bool bOverbook;
3499 bool bModSchedule;
3500 bool bModAppts;
3501
3502 if (this.EditAppointmentEnabled(e.Appointment.Resource) == false)
3503 return;
3504
3505 bModAppts = (bool) this.m_htChangeAppts[e.Resource.ToString()];
3506 if (bModAppts == false)
3507 return;
3508
3509 // Added check for making Walk-ins/appts in the past. 9/28/2010 //smh
3510 if (e.StartTime < DateTime.Today.Date)
3511 {
3512 var result = MessageBox.Show("Are you sure you want to make an appointment in the past?", "Windows Scheduling", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2);
3513 if (result == DialogResult.No) return;
3514 }
3515
3516
3517 bOverbook = (bool) this.m_htOverbook[e.Resource.ToString()];
3518 bModSchedule = (bool) this.m_htModifySchedule[e.Resource.ToString()];
3519 CGAvailability resultantAvail;
3520
3521 bSlotsAvailable = (m_Document.SlotsAvailable(e.StartTime, e.EndTime, e.Resource, this.calendarGrid1.TimeScale, out resultantAvail) > 0);
3522
3523 if (!((bSlotsAvailable) || (bModSchedule) || (bOverbook) ))
3524 {
3525 MessageBox.Show("There are no appointment slots available for the selected time.");
3526 return;
3527 }
3528
3529 /*
3530 * 7-19-05 Added overbook prompt
3531 */
3532 if (bSlotsAvailable == false)
3533 {
3534 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);
3535 if (dr != DialogResult.Yes)
3536 {
3537 return;
3538 }
3539 }
3540
3541 e.Appointment.StartTime = e.StartTime;
3542 e.Appointment.EndTime = e.EndTime;
3543 e.Appointment.Resource = e.Resource;
3544 e.Appointment.AccessTypeID = e.AccessTypeID;
3545 m_Document.CreateAppointment(e.Appointment);
3546 }
3547 catch (Exception ex)
3548 {
3549 MessageBox.Show("Unable to add new appointment " + ex.Message, "Clinical Scheduling");
3550 return;
3551 }
3552 try
3553 {
3554 RaiseRPMSEvent("BSDX SCHEDULE" , e.Resource);
3555 if (e.Resource != e.OldResource)
3556 RaiseRPMSEvent("BSDX SCHEDULE", e.OldResource);
3557 this.m_DocManager.UpdateViews(e.Resource, e.OldResource);
3558 }
3559 catch (Exception ex)
3560 {
3561 Debug.Write(ex.Message);
3562 }
3563 }
3564
3565 private void lstClip_SelectedIndexChanged(object sender, System.EventArgs e)
3566 {
3567
3568 }
3569
3570 private void mnuPrintClinicSchedules_Click(object sender, System.EventArgs e)
3571 {
3572 try
3573 {
3574 DSelectLetterClinics ds = new DSelectLetterClinics();
3575 ds.InitializePage(this.m_DocManager.GlobalDataSet, "Print Clinic Schedules");
3576 ds.SetupForReports();
3577 if (ds.ShowDialog(this) != DialogResult.OK)
3578 return;
3579
3580 //get the resource names and call the letter printer
3581
3582 string sClinics = ds.SelectedClinics;
3583 DateTime dtBegin = ds.BeginDate;
3584 DateTime dtEnd = ds.EndDate;
3585
3586 DPatientLetter dpl = new DPatientLetter();
3587 dpl.InitializeFormClinicSchedule(this.DocManager, sClinics, dtBegin, dtEnd);
3588 dpl.ShowDialog(this);
3589
3590 }
3591 catch(Exception ex)
3592 {
3593 MessageBox.Show(this, ex.Message, "Clinical Scheduling", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
3594 }
3595 }
3596
3597 private void mnuPrintReminderLetters_Click(object sender, System.EventArgs e)
3598 {
3599 try
3600 {
3601 DSelectLetterClinics ds = new DSelectLetterClinics();
3602 ds.InitializePage(this.m_DocManager.GlobalDataSet, "Print Reminder Letters");
3603 if (ds.ShowDialog(this) != DialogResult.OK)
3604 return;
3605
3606 //get the resource names and call the letter printer
3607
3608 string sClinics = ds.SelectedClinics;
3609 DateTime dtBegin = ds.BeginDate;
3610 DateTime dtEnd = ds.EndDate;
3611
3612 DPatientLetter dpl = new DPatientLetter();
3613 dpl.InitializeFormPatientReminderLetters(this.DocManager, sClinics, dtBegin, dtEnd);
3614 dpl.ShowDialog(this);
3615
3616 }
3617 catch(Exception ex)
3618 {
3619 MessageBox.Show(this, ex.Message, "Clinical Scheduling", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
3620 }
3621
3622 }
3623
3624 private void mnuPrintRebookLetters_Click(object sender, System.EventArgs e)
3625 {
3626 try
3627 {
3628 DSelectLetterClinics ds = new DSelectLetterClinics();
3629 ds.InitializePage(this.m_DocManager.GlobalDataSet, "Print Clinic Rebook Letters");
3630 if (ds.ShowDialog(this) != DialogResult.OK)
3631 return;
3632
3633 //Call the letter printer
3634 DPatientLetter dpl = new DPatientLetter();
3635 dpl.InitializeFormRebookLetters(this.DocManager, ds.SelectedClinics, ds.BeginDate, ds.EndDate);
3636 dpl.ShowDialog(this);
3637
3638 }
3639 catch(Exception ex)
3640 {
3641 MessageBox.Show(this, ex.Message, "Clinical Scheduling", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
3642 }
3643 }
3644
3645 private void mnuPrintPatientLetter_Click(object sender, System.EventArgs e)
3646 {
3647 ViewPatientAppointments();
3648 }
3649
3650 private void mnuRPMSDivision_Click(object sender, System.EventArgs e)
3651 {
3652 this.DocManager.ChangeDivision(this);
3653 }
3654
3655 private void CGView_CursorChanged(object sender, System.EventArgs e)
3656 {
3657
3658 }
3659
3660 private void mnuDisplayWalkIns_Click(object sender, System.EventArgs e)
3661 {
3662 calendarGrid1.DrawWalkIns = !(calendarGrid1.DrawWalkIns);
3663 mnuDisplayWalkIns.Checked = calendarGrid1.DrawWalkIns;
3664 calendarGrid1.SetOverlapTable();
3665 calendarGrid1.Refresh();
3666 }
3667
3668 private void mnuOpenMultipleSchedules_Click(object sender, System.EventArgs e)
3669 {
3670
3671 try
3672 {
3673 DSelectSchedules ds = new DSelectSchedules();
3674 ds.InitializePage(this.m_DocManager.GlobalDataSet, "Open Multiple Schedules");
3675 if (ds.ShowDialog(this) != DialogResult.OK)
3676 return;
3677
3678 //get the resource names and open schedules
3679
3680 ArrayList sResources = ds.SelectedClinics;
3681 if (ds.SingleWindow == true)
3682 {
3683 m_sDocName = (ds.GroupWindowName == "")?"Multiple Selected Schedules":ds.GroupWindowName;
3684 OpenSelectedSchedule( sResources, DateTime.Today);
3685 }
3686 else
3687 {
3688 foreach (string sResource in sResources)
3689 {
3690 ArrayList alSingle = new ArrayList(1);
3691 alSingle.Add(sResource);
3692 m_sDocName = sResource;
3693 OpenSelectedSchedule( alSingle, DateTime.Today);
3694 }
3695 }
3696 return;
3697
3698 }
3699 catch(Exception ex)
3700 {
3701 MessageBox.Show(this, ex.Message, "Clinical Scheduling", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
3702 }
3703
3704 }
3705
3706 private void ctxCalGridWalkin_Click(object sender, System.EventArgs e)
3707 {
3708 AppointmentAddWalkin();
3709 }
3710
3711 private void mnuWalkIn_Click(object sender, System.EventArgs e)
3712 {
3713 AppointmentAddWalkin();
3714 }
3715
3716 private void mnuPrintCancellationLetters_Click(object sender, System.EventArgs e)
3717 {
3718 try
3719 {
3720 DSelectLetterClinics ds = new DSelectLetterClinics();
3721 ds.InitializePage(this.m_DocManager.GlobalDataSet, "Print Clinic Cancellation Letters");
3722 if (ds.ShowDialog(this) != DialogResult.OK)
3723 return;
3724
3725 //get the resource names and call the letter printer
3726
3727 string sClinics = ds.SelectedClinics;
3728 DateTime dtBegin = ds.BeginDate;
3729 DateTime dtEnd = ds.EndDate;
3730
3731 DPatientLetter dpl = new DPatientLetter();
3732
3733 dpl.InitializeFormCancellationLetters(this.DocManager, sClinics, dtBegin, dtEnd);
3734 dpl.ShowDialog(this);
3735 }
3736 catch(Exception ex)
3737 {
3738 MessageBox.Show(this, ex.Message, "Clinical Scheduling", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
3739 }
3740 }
3741
3742 private void PrintRoutingSlip(CGAppointment appt)
3743 {
3744 //get this appointment's order
3745 //Today's appointments
3746 var todaysAppts = (from lkappts in this.Document.Appointments.AppointmentTable.Values.Cast<CGAppointment>()
3747 where lkappts.StartTime > appt.StartTime.Date && lkappts.StartTime < appt.StartTime.AddDays(1).Date && lkappts.Resource == appt.Resource
3748 orderby lkappts.StartTime
3749 select lkappts).ToList();
3750
3751 //Find the order of the appointment
3752 int apptOrder = todaysAppts.FindIndex(eachappt => eachappt.StartTime == appt.StartTime && eachappt.PatientID == appt.PatientID);
3753
3754 //Index is zero based, so add 1
3755 apptOrder++;
3756
3757 //Send that to the routing slip as a parameter
3758 PrintDocument pd = new PrintDocument() { DocumentName = "Routing Slip for Appt " + appt.AppointmentKey };
3759 pd.PrintPage += (object s, System.Drawing.Printing.PrintPageEventArgs e) => CGDocumentManager.Current.PrintingObject.PrintRoutingSlip(appt, apptOrder, e);
3760 pd.Print();
3761 }
3762
3763 private void PrintAppointmentSlip(CGAppointment appt)
3764 {
3765 PrintDocument pd = new PrintDocument() { DocumentName = "Appointment Slip for Appt " + appt.AppointmentKey }; //Autoinit for DocName
3766 pd.PrintPage += (object s, System.Drawing.Printing.PrintPageEventArgs e) => CGDocumentManager.Current.PrintingObject.PrintAppointmentSlip(appt, e);
3767 pd.Print();
3768 }
3769
3770
3771 /// <summary>
3772 /// Update Selection of date if user does not pick a date/time
3773 /// </summary>
3774 /// <param name="sender"></param>
3775 /// <param name="e"></param>
3776 private void dateTimePicker1_Leave(object sender, EventArgs e)
3777 {
3778 if (this.Document.SelectedDate != dateTimePicker1.Value.Date)
3779 RequestRefreshGrid();
3780 }
3781
3782 /// <summary>
3783 /// Handle Selection of Date via mouse from datetimepicker dropdown
3784 /// </summary>
3785 /// <param name="sender"></param>
3786 /// <param name="e"></param>
3787 private void dateTimePicker1_CloseUp(object sender, EventArgs e)
3788 {
3789 if (this.Document.SelectedDate != dateTimePicker1.Value.Date)
3790 RequestRefreshGrid();
3791 }
3792
3793 /// <summary>
3794 /// Handle Enter and Escape key on dateTimePicker
3795 /// </summary>
3796 /// <param name="sender"></param>
3797 /// <param name="e"></param>
3798 private void dateTimePicker1_KeyPress(object sender, KeyPressEventArgs e)
3799 {
3800 //if enter key is pressed:
3801 // Tell windows that we are handling this
3802 // Request a Refresh Grid if the date is different
3803 // Set-Focus to Calendar Grid
3804 if (e.KeyChar == (char)Keys.Enter)
3805 {
3806 e.Handled = true;
3807
3808 if (this.Document.SelectedDate != dateTimePicker1.Value.Date)
3809 RequestRefreshGrid();
3810
3811 this.CGrid.Focus();
3812 }
3813
3814 //if escape key is pressed:
3815 // Tell windows that we are handling this
3816 // Set-Focus to Calendar Grid
3817 if (e.KeyChar == (char)Keys.Escape)
3818 {
3819 e.Handled = true;
3820 this.CGrid.Focus();
3821 }
3822 }
3823
3824 private void mnuRefresh_Click(object sender, EventArgs e)
3825 {
3826 ForceRefreshGrid();
3827 }
3828
3829 #endregion events
3830
3831 /// <summary>
3832 /// Refresh grid if needed.
3833 /// </summary>
3834 void RequestRefreshGrid()
3835 {
3836 DateTime dDate = dateTimePicker1.Value.Date;
3837 // Change Date on Document
3838 this.Document.SelectedDate = dDate;
3839
3840 // Do we need to update?
3841 bool isRefreshNeeded = this.Document.IsRefreshNeeded();
3842
3843 //Splash when loading and change Cursor
3844 if (isRefreshNeeded)
3845 {
3846 this.Cursor = Cursors.WaitCursor;
3847 LoadSplash();
3848 this.Document.RefreshDocument();
3849 StopSplash();
3850 this.Cursor = Cursors.Default;
3851 }
3852
3853
3854 if (this.Document.Resources.Count == 1)
3855 {
3856 if (this.calendarGrid1.Columns > 1)
3857 {
3858 this.StartDate = this.Document.StartDate;
3859 }
3860 else
3861 {
3862 this.StartDate = this.Document.SelectedDate;
3863 }
3864 }
3865 else
3866 {
3867 this.StartDate = this.Document.SelectedDate;
3868 }
3869
3870 //Is this needed? -- Yes it is. There is a bug in the drawing code for the calendar
3871 //First time it draws, it draws appointments, but not availability slots
3872 //Second time it draws, it both appointments and availabilites
3873 //XXX: Need to investigate
3874 this.Document.UpdateAllViews();
3875 }
3876
3877 /// <summary>
3878 /// This forces a grid refresh.
3879 /// </summary>
3880 void ForceRefreshGrid()
3881 {
3882 if (this.Document.m_sResourcesArray.Count == 0) return;
3883 this.Cursor = Cursors.WaitCursor;
3884 LoadSplash();
3885 this.Document.RefreshSchedule();
3886 this.UpdateArrays();
3887 StopSplash();
3888 this.Cursor = Cursors.Default;
3889 }
3890
3891 //private delegate DialogResult dLoadingSplash(IWin32Window owner);
3892 string _tempStatusBartext;
3893
3894 /// <summary>
3895 /// Loads a splash that says "Loading" -- removed it april 13 2010
3896 /// </summary>
3897 private void LoadSplash()
3898 {
3899 _tempStatusBartext = this.statusBar1.Text;
3900 this.statusBar1.Text = "Refreshing Schedule...";
3901 //_loadingSplash = new LoadingSplash();
3902 //_loadingSplash.StartPosition = FormStartPosition.CenterScreen; //XXX: Don't like this, but will do for now.
3903 //_loadingSplash.UseWaitCursor = true; // tell user we are working
3904 //_loadingSplash.Show(this);
3905 //Thread threadSplash = new Thread(tstart);
3906 //threadSplash.IsBackground = true;
3907 //threadSplash.Name = "Loading Thread";
3908 //threadSplash.Start(this);
3909
3910 //Thread threadSplash = new Thread(new ThreadStart(() => _loadingSplash.ShowDialog())); // lambda
3911 //threadSplash.IsBackground = true; //expendable thread -- exit even if still running.
3912 //threadSplash.Name = "Loading Thread";
3913 //threadSplash.Start();
3914 }
3915
3916 private void StopSplash()
3917 {
3918 this.statusBar1.Text = _tempStatusBartext;
3919 }
3920
3921
3922 private void PrintClinicSchedule(DateTime dStart, DateTime dEnd)
3923 {
3924 DPatientLetter dpl = new DPatientLetter();
3925
3926 int[] resourceIENs = (from resource in CGDocumentManager.Current.GlobalDataSet.Tables["Resources"].AsEnumerable()
3927 join resource_name in m_alSelectedTreeResourceArray.Cast<string>() on resource.Field<string>("RESOURCE_NAME") equals resource_name
3928 select resource.Field<int>("RESOURCEID")
3929 ).ToArray<int>();
3930
3931 // + | is an oddity in the Mumps code which I haven't investigated yet.
3932 dpl.InitializeFormClinicSchedule(this.DocManager, string.Join("|", resourceIENs) + "|", dStart, dEnd);
3933 dpl.ShowDialog(this);
3934 }
3935
3936 private void mnuViewBrokerLog_Click(object sender, EventArgs e)
3937 {
3938 var view = new RPCLoggerView();
3939 view.Show();
3940 }
3941
3942
3943 }//End class
3944}
Note: See TracBrowser for help on using the repository browser.