source: Scheduling/branches/BMX4Support/CGView.cs@ 1454

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

CGView.cs: modified IsThisARadiologyResource to handle the possibility of Unlinked Resources (not linked to PIMS).

File size: 145.5 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.ctxCalendarGrid = new System.Windows.Forms.ContextMenu();
258 this.ctxCalGridAdd = new System.Windows.Forms.MenuItem();
259 this.ctxCalGridMkRadAppt = new System.Windows.Forms.MenuItem();
260 this.ctxCalGridEdit = new System.Windows.Forms.MenuItem();
261 this.ctxCalGridDelete = new System.Windows.Forms.MenuItem();
262 this.ctxCalGridCancelRadAppt = new System.Windows.Forms.MenuItem();
263 this.ctxCalGridCheckIn = new System.Windows.Forms.MenuItem();
264 this.ctxCalGridUndoCheckin = new System.Windows.Forms.MenuItem();
265 this.ctxCalGridSep1 = new System.Windows.Forms.MenuItem();
266 this.ctxCalGridNoShow = new System.Windows.Forms.MenuItem();
267 this.ctxCalGridNoShowUndo = new System.Windows.Forms.MenuItem();
268 this.ctxCalGridSep2 = new System.Windows.Forms.MenuItem();
269 this.ctxCalGridWalkin = new System.Windows.Forms.MenuItem();
270 this.ctxCalGridSep3 = new System.Windows.Forms.MenuItem();
271 this.ctxCalGridReprintApptSlip = new System.Windows.Forms.MenuItem();
272 this.panelBottom = new System.Windows.Forms.Panel();
273 this.statusBar1 = new System.Windows.Forms.StatusBar();
274 this.splitter1 = new System.Windows.Forms.Splitter();
275 this.splitter2 = new System.Windows.Forms.Splitter();
276 this.calendarGrid1 = new IndianHealthService.ClinicalScheduling.CalendarGrid();
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 bool bEditAppointments = (EditAppointmentEnabled() && (calendarGrid1.SelectedAppointment > 0)) ;
1407
1408 if (IsThisARadiologyResource())//this is a radiology resource
1409 {
1410 ctxCalGridAdd.Visible = false;
1411 ctxCalGridDelete.Visible = false;
1412 ctxCalGridEdit.Visible = false;
1413 ctxCalGridCheckIn.Visible = false;
1414 ctxCalGridNoShow.Visible = false;
1415 ctxCalGridNoShowUndo.Visible = false;
1416 ctxCalGridWalkin.Visible = false;
1417 ctxCalGridUndoCheckin.Visible = false;
1418 ctxCalGridSep1.Visible = false;
1419 ctxCalGridSep2.Visible = false;
1420
1421 ctxCalGridMkRadAppt.Visible = true;
1422 ctxCalGridCancelRadAppt.Visible = true;
1423
1424
1425 }
1426
1427 else // this is a normal resource
1428 {
1429 ctxCalGridAdd.Visible = true;
1430 ctxCalGridDelete.Visible = true;
1431 ctxCalGridEdit.Visible = true;
1432 ctxCalGridCheckIn.Visible = true;
1433 ctxCalGridNoShow.Visible = true;
1434 ctxCalGridNoShowUndo.Visible = true;
1435 ctxCalGridWalkin.Visible = true;
1436 ctxCalGridUndoCheckin.Visible = true;
1437 ctxCalGridSep1.Visible = true;
1438 ctxCalGridSep2.Visible = true;
1439
1440 ctxCalGridMkRadAppt.Visible = false;
1441 ctxCalGridCancelRadAppt.Visible = false;
1442 }
1443
1444 //Toggle availability of make, edit, checkin and delete appointments
1445 //based on whether appropriate element is selected.
1446 ctxCalGridAdd.Enabled = AddAppointmentEnabled();
1447
1448 ctxCalGridDelete.Enabled = bEditAppointments;
1449 ctxCalGridEdit.Enabled = bEditAppointments;
1450 ctxCalGridCheckIn.Enabled = bEditAppointments;
1451 ctxCalGridNoShow.Enabled = NoShowEnabled();
1452 ctxCalGridNoShowUndo.Enabled = !NoShowEnabled() && calendarGrid1.SelectedAppointment > 0;
1453 ctxCalGridWalkin.Enabled = ctxCalGridAdd.Enabled;
1454 ctxCalGridReprintApptSlip.Enabled = bEditAppointments;
1455 ctxCalGridUndoCheckin.Enabled = UndoCheckinEnabled();
1456
1457 //if the rad ones are visible, then these apply
1458 ctxCalGridMkRadAppt.Enabled = !bEditAppointments;
1459 ctxCalGridCancelRadAppt.Enabled = bEditAppointments;
1460 }
1461
1462 private void ctxCalGridAdd_Click(object sender, System.EventArgs e)
1463 {
1464 AppointmentAddNew();
1465 }
1466
1467 private void calendarGrid1_DoubleClick(object sender, System.EventArgs e)
1468 {
1469 if (calendarGrid1.SelectedAppointment > 0)
1470 AppointmentEdit();
1471 }
1472
1473 private void ctxCalGridEdit_Click(object sender, System.EventArgs e)
1474 {
1475 AppointmentEdit();
1476 }
1477
1478 private void ctxCalGridDelete_Click(object sender, System.EventArgs e)
1479 {
1480 AppointmentDelete();
1481 }
1482
1483 private void ctxCalGridCheckIn_Click(object sender, System.EventArgs e)
1484 {
1485 AppointmentCheckIn();
1486 }
1487
1488 private void ctxCalGridNoShow_Click(object sender, System.EventArgs e)
1489 {
1490 AppointmentNoShow(true);
1491 }
1492
1493 private void ctxCalGridNoShowUndo_Click(object sender, System.EventArgs e)
1494 {
1495 AppointmentNoShow(false);
1496 }
1497
1498 private void ctxCalGridMkRadAppt_Click(object sender, EventArgs e)
1499 {
1500 AppointmentAddNewRadiology();
1501 }
1502
1503 private void ctxCalGridCancelRadAppt_Click(object sender, EventArgs e)
1504 {
1505 AppointmentDeleteOneRadiology();
1506 }
1507
1508 private void ctxCalGridReprintApptSlip_Click(object sender, EventArgs e)
1509 {
1510 int apptID = this.CGrid.SelectedAppointment;
1511 if (apptID <= 0) return;
1512
1513 CGAppointment a = (CGAppointment) this.Appointments.AppointmentTable[apptID];
1514
1515 PrintAppointmentSlip(a);
1516 }
1517
1518 #endregion ctxCalGridMenu Handlers
1519
1520 #region Methods
1521
1522 /// <summary>
1523 /// Decides whether this is a Radiology Resource. Local Helper to decide what menu items to enable/display
1524 /// </summary>
1525 /// <returns></returns>
1526 private bool IsThisARadiologyResource()
1527 {
1528 //I don't like this logic!!! but works for now!
1529 //Note: I use banana peeling model below
1530
1531 //If no cell is selected AND no appointment is selected, then it's false
1532 if (this.calendarGrid1.SelectedRange.Cells.CellCount < 1 && this.calendarGrid1.SelectedAppointment < 1)
1533 return false;
1534
1535 //If an appointment is selected then...
1536 if (this.calendarGrid1.SelectedAppointment > 0)
1537 {
1538 CGAppointment appt = this.Appointments.AppointmentTable[this.calendarGrid1.SelectedAppointment] as CGAppointment;
1539 if (appt == null) return false; //appt doesn't exist; old appointment and grid wasn't refreshed yet
1540 if (appt.RadiologyExamIEN.HasValue && appt.RadiologyExamIEN.Value > 0) return true; //this appointment is a radiology appointment since it has that member
1541 else return false;
1542
1543 }
1544
1545 //Otherwise, we are for sure dealing with a cell.
1546 //We need to determine if the cell resource is mapped to a Radiology Hospital Location.
1547 DateTime dStart;
1548 DateTime dEnd;
1549 string sResource;
1550
1551 // Get resource
1552 bool bRet = this.calendarGrid1.GetSelectedTime(out dStart, out dEnd, out sResource);
1553
1554 // If we fail, return false (but this is not supposed to ever happen)
1555 if (bRet == false)
1556 {
1557 return false;
1558 }
1559
1560 // see if resource is mapped to a Radiology Hospital Location.
1561 return IsThisARadiologyResource(sResource);
1562 }
1563
1564 private bool IsThisARadiologyResource(string sResource)
1565 {
1566 //smh - change in v 1.7... if the resource is not linked to a PIMS clinic, this method fails.
1567 //This happens if there is just one resource that is not linked, which makes it impossible to
1568 //make any appointments, because this method gets called at any time a menu is opened.
1569 //So we change res.Field<int> to res.Field<int?>
1570
1571 // see if resource is mapped to a Radiology Hospital Location.
1572 return ( //select all Hospital Locations which are radiology locations
1573 from hl in CGDocumentManager.Current.GlobalDataSet.Tables["HospitalLocation"].AsEnumerable()
1574 where hl.Field<string>("IS_RADIOLOGY_LOCATION") == "1"
1575 //join this to the resources table using the foreign ID (plain jane relational join)
1576 join res in CGDocumentManager.Current.GlobalDataSet.Tables["Resources"].AsEnumerable()
1577 //on hl.Field<int>("HOSPITAL_LOCATION_ID") equals res.Field<int>("HOSPITAL_LOCATION_ID") //change in 1.7
1578 on hl.Field<int>("HOSPITAL_LOCATION_ID") equals res.Field<int?>("HOSPITAL_LOCATION_ID")
1579 //then filter this down to the resource that we have
1580 where res.Field<string>("RESOURCE_NAME") == sResource
1581 //if we have any row left, then it is true.
1582 select hl).Any();
1583 }
1584
1585 private bool EditAppointmentEnabled()
1586 {
1587 try
1588 {
1589 //Call here if there is a selected appointment in the grid
1590 if (calendarGrid1.SelectedAppointment < 1)
1591 return false;
1592 CGAppointment appt = (CGAppointment)this.Appointments.AppointmentTable[calendarGrid1.SelectedAppointment];
1593 string sResource = appt.Resource;
1594 return EditAppointmentEnabled(sResource);
1595
1596 }
1597 catch (Exception ex)
1598 {
1599 string sMsg = ex.Message;
1600 return false;
1601 }
1602 }
1603
1604 private bool EditAppointmentEnabled(string sResource)
1605 {
1606
1607 bool bManager = this.DocManager.ScheduleManager;
1608 if (bManager == true)
1609 {
1610 return (true);
1611 }
1612 else
1613 {
1614 bool bModAppts;
1615 bModAppts = (bool)this.m_htChangeAppts[sResource];
1616 return bModAppts;
1617 }
1618 }
1619
1620 private bool AddAppointmentEnabled()
1621 {
1622 if (this.calendarGrid1.SelectedRange.Cells.CellCount < 1)
1623 return false;
1624
1625 bool bManager = this.DocManager.ScheduleManager;
1626 if (bManager == true)
1627 {
1628 return (true);
1629 }
1630 else
1631 {
1632 DateTime dStart = DateTime.Today;
1633 DateTime dEnd = DateTime.Today;
1634 string sResource = "";
1635 bool bRet = this.calendarGrid1.GetSelectedTime(out dStart, out dEnd, out sResource);
1636 if (bRet == false)
1637 {
1638 return false;
1639 }
1640 bool bSlotsAvailable;
1641 bool bOverbook;
1642 bool bModSchedule;
1643 bool bModAppts;
1644 bOverbook = (bool)this.m_htOverbook[sResource];
1645 bModSchedule = (bool)this.m_htModifySchedule[sResource];
1646 bModAppts = (bool)this.m_htChangeAppts[sResource];
1647 if (bModAppts == false)
1648 return false;
1649
1650 bSlotsAvailable = (this.m_nSlots > 0);
1651 return ((bSlotsAvailable) || (bModSchedule) || (bOverbook));
1652 }
1653 }
1654
1655 private bool NoShowEnabled()
1656 {
1657 if (calendarGrid1.SelectedAppointment < 1)
1658 return false;
1659 CGAppointment appt = (CGAppointment)this.Appointments.AppointmentTable[calendarGrid1.SelectedAppointment];
1660 return !appt.NoShow;
1661 }
1662
1663 private bool UndoCheckinEnabled()
1664 {
1665 if (calendarGrid1.SelectedAppointment < 1) return false;
1666 CGAppointment appt = (CGAppointment)this.Appointments.AppointmentTable[calendarGrid1.SelectedAppointment];
1667 return appt.CheckInTime.Ticks > 0;
1668 }
1669
1670 /// <summary>
1671 /// Clean up any resources being used.
1672 /// </summary>
1673 protected override void Dispose( bool disposing )
1674 {
1675 if( disposing )
1676 {
1677 if(components != null)
1678 {
1679 components.Dispose();
1680 }
1681 }
1682 base.Dispose( disposing );
1683 }
1684
1685 void UpdateStatusBar(DateTime dStart, DateTime dEnd, CGAvailability av)
1686 {
1687 System.Text.StringBuilder sbMsg = new System.Text.StringBuilder(100);
1688 sbMsg.Append(dStart.ToShortTimeString() + " to " + dEnd.ToShortTimeString());
1689 if (av != null && m_nSlots > 0)
1690 {
1691 sbMsg.Append(String.Format(" has {0} slot(s) available for {1}. ", m_nSlots.ToString(), av.AccessTypeName));
1692 }
1693 else
1694 {
1695 sbMsg.Append(": No appointment slots available. ");
1696 }
1697
1698 if (av != null)
1699 {
1700 sbMsg.Append(String.Format("Source Block: {0} to {1} with {2} slot(s) of type {3}",
1701 av.StartTime.ToShortTimeString(),
1702 av.EndTime.ToShortTimeString(),
1703 av.Slots.ToString(),
1704 av.AccessTypeName));
1705
1706 sbMsg.Append(". ");
1707
1708 if (av.Note.Trim().Length > 0) sbMsg.Append("Note: " + av.Note + ".");
1709 }
1710
1711 this.statusBar1.Text = sbMsg.ToString();
1712 }
1713
1714 private void EditScheduleAvailability()
1715 {
1716 CGAVDocument doc = new CGAVDocument();
1717 try
1718 {
1719 //If resource already open, then navigate to its window
1720 CGAVView v =this.DocManager.GetAVViewByResource(m_alSelectedTreeResourceArray);
1721
1722 if (v != null)
1723 {
1724 v.Activate();
1725 }
1726 else
1727 {
1728 //If not already open, get a lock and open it
1729 doc.DocManager = this.DocManager;
1730 for (int j=0; j < m_alSelectedTreeResourceArray.Count; j++)
1731 {
1732 doc.AddResource((string) m_alSelectedTreeResourceArray[j]);
1733 }
1734 doc.DocName = this.m_sDocName;
1735
1736 //Get preferred time scale from resource info
1737
1738 DataTable dt = this.DocManager.GlobalDataSet.Tables["Resources"];
1739 DataView dv = new DataView(dt, "", "RESOURCE_NAME ASC", DataViewRowState.OriginalRows);
1740 int nScale = 60;
1741 int nTest=0;
1742 string sResource;
1743 int nDataRow;
1744 DataRowView drv;
1745 string sResourceID="";
1746 for (int j=0; j < m_alSelectedTreeResourceArray.Count; j++)
1747 {
1748 sResource = (string) m_alSelectedTreeResourceArray[j];
1749 nDataRow = dv.Find(sResource);
1750 Debug.Assert(nDataRow != -1);
1751 drv = dv[nDataRow];
1752 if (drv["TIMESCALE"].ToString() == "")
1753 {
1754 nTest = 15; //15 minute default
1755 }
1756 else
1757 {
1758 nTest = (int) drv["TIMESCALE"];
1759 }
1760 nScale = (nTest < nScale)?nTest : nScale ;
1761 sResourceID = drv["RESOURCEID"].ToString();
1762 }
1763
1764 doc.ResourceID = Convert.ToInt32(sResourceID);
1765
1766 bool bLock = CGDocumentManager.Current.RemoteSession.Lock("^BSDXRES(" + sResourceID + ")", "+");
1767 if (bLock == false)
1768 {
1769 throw new BMXNetException("Another user is currently editing availability for this resource. Try later.");
1770 }
1771
1772 doc.OnOpenDocument();
1773 v =this.DocManager.GetAVViewByResource(m_alSelectedTreeResourceArray);
1774 CalendarGrid cg = v.CGrid;
1775
1776 cg.TimeScale = nScale;
1777
1778 //Position grid to 0700
1779 cg.PositionGrid(7);
1780 }
1781 }
1782 catch (Exception ex)
1783 {
1784 MessageBox.Show("Unable to edit availability for " + m_sDocName + " schedule. " + ex.Message, "Clinical Scheduling");
1785 this.m_DocManager.CloseAllViews(doc);
1786 return;
1787 }
1788 }
1789
1790 /// <summary>
1791 /// Opens a view of the Schedule a user requested to open at a specific date
1792 /// </summary>
1793 /// <param name="sSelectedTreeResourceArray">A set of resources to open (?pending more investigation)</param>
1794 /// <param name="dDate">Date at which to show the Grid</param>
1795 private void OpenSelectedSchedule(ArrayList sSelectedTreeResourceArray, DateTime dDate)
1796 {
1797 //If resource already open, then navigate to its window
1798 CGView v = this.DocManager.GetViewByResource(sSelectedTreeResourceArray);
1799 if (v != null)
1800 {
1801 v.Activate();
1802 v.dateTimePicker1.Value = dDate;
1803 v.RequestRefreshGrid();
1804 return;
1805 }
1806
1807 //So if it is not a view that's already open, it means we have to grab the data for
1808 //So we tell the user to wait wait wait
1809 this.Cursor = Cursors.WaitCursor;
1810 this.LoadSplash(); //Open "Loading" splash
1811
1812
1813 //If this Document has no resources then use it (happens when the GUI has nothing open, typically after log-in)
1814 //Else, create a new document
1815 CGDocument doc;
1816 if (this.Document.m_sResourcesArray.Count == 0)
1817 {
1818 doc = this.Document;
1819 }
1820 else
1821 {
1822 doc = new CGDocument();
1823 doc.DocManager = this.DocManager;
1824 }
1825
1826 //Add resources to Document
1827 for (int j=0; j < sSelectedTreeResourceArray.Count; j++)
1828 {
1829 doc.AddResource((string) sSelectedTreeResourceArray[j]);
1830 }
1831
1832 doc.DocName = this.m_sDocName;
1833
1834 try
1835 {
1836 doc.OnOpenDocument(dDate); //this typically creates a new view
1837 }
1838
1839 catch (Exception ex)
1840 {
1841 MessageBox.Show("Unable to open " + m_sDocName + " schedule. " + ex.Message, "Clinical Scheduling");
1842 this.m_DocManager.CloseAllViews(doc);
1843 return;
1844 }
1845
1846 //We are doing this--again--to fetch the view we just opened in OnOpenDocument
1847 //XXX: Yes, I know, this totally sucks. But I don't fully grasp the whole thing yet to refactor it.
1848 v =this.DocManager.GetViewByResource(sSelectedTreeResourceArray);
1849
1850 //Position the Grid to start at a certain day.
1851 //XXX: This must be a better way to do this.
1852 v.dateTimePicker1.Value = dDate;
1853 v.StartDate = doc.StartDate;
1854
1855 //Get preferred time scale from resource info
1856 //If more than one resource, get smallest time scale
1857 CalendarGrid cg = v.CGrid;
1858 DataTable dt = this.DocManager.GlobalDataSet.Tables["Resources"];
1859 DataView dv = new DataView(dt, "", "RESOURCE_NAME ASC", DataViewRowState.OriginalRows);
1860 int nScale = 60;
1861 int nTest=0;
1862 string sResource;
1863 int nDataRow;
1864 DataRowView drv;
1865 for (int j=0; j < sSelectedTreeResourceArray.Count; j++)
1866 {
1867 sResource = (string) sSelectedTreeResourceArray[j];
1868 nDataRow = dv.Find(sResource);
1869 Debug.Assert(nDataRow != -1);
1870 drv = dv[nDataRow];
1871 if (drv["TIMESCALE"].ToString() == "")
1872 {
1873 nTest = 15; //15 minute default
1874 }
1875 else
1876 {
1877 nTest = (int) drv["TIMESCALE"];
1878 }
1879 nScale = (nTest < nScale)?nTest : nScale ;
1880 }
1881
1882 cg.TimeScale = nScale;
1883
1884 cg.PositionGrid(7);
1885
1886 //new code for v 1.5 //smh
1887 //Disable entries that would make time scale smaller b/c users should not be able to
1888 //make appointments for smaller time scales
1889 if (nScale >= 10)
1890 {
1891 v.mnu10Minute.Enabled = true;
1892 v.mnu15Minute.Enabled = true;
1893 v.mnu20Minute.Enabled = true;
1894 v.mnu30Minute.Enabled = true;
1895 }
1896 if (nScale >= 15)
1897 {
1898 v.mnu10Minute.Enabled = false;
1899 v.mnu15Minute.Enabled = true;
1900 v.mnu20Minute.Enabled = true;
1901 v.mnu30Minute.Enabled = true;
1902 }
1903 if (nScale >= 20)
1904 {
1905 v.mnu10Minute.Enabled = false;
1906 v.mnu15Minute.Enabled = false;
1907 v.mnu20Minute.Enabled = true;
1908 v.mnu30Minute.Enabled = true;
1909 }
1910 if (nScale >= 30)
1911 {
1912 v.mnu10Minute.Enabled = false;
1913 v.mnu15Minute.Enabled = false;
1914 v.mnu20Minute.Enabled = false;
1915 v.mnu30Minute.Enabled = true;
1916 }
1917 if (nScale >= 60)
1918 {
1919 v.mnu10Minute.Enabled = false;
1920 v.mnu15Minute.Enabled = false;
1921 v.mnu20Minute.Enabled = false;
1922 v.mnu30Minute.Enabled = false;
1923 }
1924 //end new code
1925
1926 //Get the OverBook and ModifySchedule permissions from ResourceUser table
1927 //and populate the hashtables
1928 string sOverbook;
1929 string sModSchedule;
1930 string sModAppts;
1931 bool bOverbook;
1932 bool bModSchedule;
1933 bool bModAppts;
1934 v.m_htOverbook = new Hashtable(sSelectedTreeResourceArray.Count);
1935 v.m_htModifySchedule = new Hashtable(sSelectedTreeResourceArray.Count);
1936 v.m_htChangeAppts = new Hashtable(sSelectedTreeResourceArray.Count);
1937 dt = this.DocManager.GlobalDataSet.Tables["ResourceUser"];
1938 dv = new DataView(dt, "", "RESOURCENAME ASC", DataViewRowState.OriginalRows);
1939 dv.RowFilter = "USERNAME = '" + CGDocumentManager.Current.RemoteSession.User.Name + "'";
1940 for (int j=0; j < dv.Count; j++)
1941 {
1942 drv = dv[j];
1943 sResource = drv["RESOURCENAME"].ToString();
1944 sOverbook = drv["OVERBOOK"].ToString();
1945 bOverbook = (sOverbook == "YES")?true:false;
1946 sModSchedule = drv["MODIFY_SCHEDULE"].ToString();
1947 bModSchedule = (sModSchedule == "YES")?true:false;
1948 sModAppts = drv["MODIFY_APPOINTMENTS"].ToString();
1949 bModAppts = (sModAppts == "YES")?true:false;
1950 v.m_htOverbook[sResource] = bOverbook;
1951 v.m_htModifySchedule[sResource] = bModSchedule;
1952 v.m_htChangeAppts[sResource] = bModAppts;
1953 }
1954
1955 //For programmers and scheduling managers, set all permissions for all resources
1956 if (this.DocManager.ScheduleManager == true)
1957 {
1958 dt = this.DocManager.GlobalDataSet.Tables["Resources"];
1959 foreach (DataRow dr in dt.Rows)
1960 {
1961 sResource = dr["RESOURCE_NAME"].ToString();
1962 v.m_htOverbook[sResource] = true;
1963 v.m_htModifySchedule[sResource] = true;
1964 v.m_htChangeAppts[sResource] = true;
1965 }
1966 }
1967
1968 v.calendarGrid1.SetOverlapTable();
1969 v.calendarGrid1.Refresh();
1970
1971 // Set cursor back and stop splash screen
1972 this.Cursor = Cursors.Default;
1973 StopSplash();
1974 }
1975
1976 private void LoadTree()
1977 {
1978 //Navigate from ResourceGroup table to Resources table
1979 DataRow[] arrRows;
1980 DataRelation dr = DocManager.GlobalDataSet.Relations["GroupResource"];
1981 string sGroup;
1982 string sResource;
1983 int nIndex = 0;
1984 foreach (DataRow r in DocManager.GlobalDataSet.Tables["ResourceGroup"].Rows)
1985 {
1986 sGroup = r["RESOURCE_GROUP"].ToString();
1987 TreeNode deptNode = new TreeNode(sGroup);
1988 nIndex = this.tvSchedules.Nodes.Add(deptNode);
1989 tvSchedules.Nodes[nIndex].Tag = "Dept";
1990 arrRows = r.GetChildRows(dr);
1991 for (int i=0; i< arrRows.Length; i++)
1992 {
1993 sResource = arrRows[i]["RESOURCE_NAME"].ToString();
1994 TreeNode resNode = new TreeNode(sResource);
1995 int nResIndex = deptNode.Nodes.Add(resNode);
1996 deptNode.Nodes[nResIndex].Tag = "Resource";
1997 }
1998 }
1999 }
2000
2001 public void CreateNewSchedule()
2002 {
2003 //Create a new document and open it
2004 CGDocument doc = new CGDocument();
2005 doc.DocManager = this.DocManager;
2006 try
2007 {
2008 doc.OnOpenDocument(DateTime.Today);
2009 }
2010 catch (Exception ex)
2011 {
2012 MessageBox.Show("Unable to open " + m_sDocName + " schedule. " + ex.Message, "Clinical Scheduling");
2013 this.m_DocManager.CloseAllViews(doc);
2014 return;
2015 }
2016 }
2017
2018 private void AppointmentEdit()
2019 {
2020 try
2021 {
2022 int nApptID = this.calendarGrid1.SelectedAppointment;
2023 Debug.Assert(nApptID != 0);
2024
2025 CGAppointment a = (CGAppointment) this.Appointments.AppointmentTable[nApptID];
2026
2027 DAppointPage dAppt = new DAppointPage();
2028 dAppt.DocManager = this.m_DocManager;
2029 dAppt.InitializePage(a);
2030
2031 calendarGrid1.CGToolTip.Active = false;
2032
2033 if (dAppt.ShowDialog(this) == DialogResult.Cancel)
2034 {
2035 calendarGrid1.CGToolTip.Active = true;
2036 return;
2037 }
2038 calendarGrid1.CGToolTip.Active = true;
2039
2040 string sNote = dAppt.Note;
2041
2042 //Call Document to edit appointment
2043 this.Document.EditAppointment(a, sNote);
2044
2045 if (dAppt.PrintAppointmentSlip)
2046 {
2047 PrintAppointmentSlip(a);
2048 }
2049
2050 //Redraw appointments
2051 this.UpdateArrays();
2052
2053 //Then tell RPMS that we are updated
2054 RaiseRPMSEvent("BSDX SCHEDULE", a.Resource);
2055 }
2056 catch (Exception ex)
2057 {
2058 Debug.Write("CGView.AppointmentEdit Failed: " + ex.Message);
2059 }
2060 }
2061
2062 /// <summary>
2063 /// Marks all selected appointments as No Show from this.calendarGrid1.SelectedAppointments
2064 /// </summary>
2065 /// <param name="bNoShow">True - Mark as noshow; False - undo noshow</param>
2066 private void AppointmentNoShow(bool bNoShow)
2067 {
2068
2069 //bNoShow indicates whether to mark or un-mark as noshow
2070 bool bMarked = false; //Indicates at least one attempt to mark as noshow succeeded
2071 bool bRebook = false; //Stores user's response to auto-rebook dialog question
2072 CGAppointments alRebookList = new CGAppointments(); // list of appointments to rebook
2073
2074 DNoShow dlg = new DNoShow(); // no show dialog
2075
2076 if (bNoShow == true) // if noshowing, show the dialog to ask the user
2077 {
2078 if (dlg.ShowDialog(this) == DialogResult.Cancel)
2079 {
2080 return;
2081 }
2082 }
2083
2084 bRebook = dlg.AutoRebook;
2085
2086 foreach (CGAppointment a in this.calendarGrid1.SelectedAppointments.AppointmentTable.Values)
2087 {
2088 int nApptID = a.AppointmentKey;
2089 Debug.Assert(nApptID != 0);
2090 try
2091 {
2092 if ((bNoShow == true) // if no-showing
2093 &&
2094 (a.StartTime.Date > DateTime.Today.Date)
2095 &&
2096 (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))
2097 {
2098 }
2099 else // otherwise, make or undo show
2100 {
2101 string sError = Document.AppointmentNoShow(a, bNoShow);
2102 if (sError != "1")
2103 throw new Exception(sError);
2104
2105 bMarked = true;
2106 }
2107 }
2108 catch (Exception ex)
2109 {
2110 MessageBox.Show("Unable to mark appointment No Show: " + ex.Message, "Clinical Scheduling");
2111 }
2112
2113 if (bRebook == true)
2114 {
2115 try
2116 {
2117 CGAppointment aRebook;
2118 int nMinimumdays = dlg.RebookStartDays;
2119 int nMaximumdays = dlg.RebookMaxDays;
2120 int nAccessType = dlg.RebookAccessType;
2121 //-1 means use current type
2122
2123 if (nAccessType == -1)
2124 {
2125 //Get access type from grid
2126 int nRow = 0;
2127 int nCol = 0;
2128 CGCell cgCell = new CGCell();
2129 this.calendarGrid1.GetCellFromTime(a.StartTime, ref nRow, ref nCol, true , a.Resource);
2130 cgCell.CellColumn = nCol;
2131 cgCell.CellRow = nRow;
2132 this.calendarGrid1.GetTypeFromCell(cgCell, out nAccessType);
2133 a.AccessTypeID = nAccessType;
2134 }
2135 string sResult = Document.AutoRebook(a, nAccessType, nMinimumdays, nMaximumdays, out aRebook);
2136 if (sResult == "1")
2137 {
2138 //Add appointment to list of rebooked appointments
2139 alRebookList.AddAppointment(a);
2140 }
2141 else
2142 {
2143 MessageBox.Show("Unable to rebook this patient: " + a.PatientName);
2144 }
2145
2146 }
2147 catch (Exception ex)
2148 {
2149 MessageBox.Show("Unable to rebook: " + ex.Message);
2150 }
2151 }
2152
2153 if (bMarked == true)
2154 {
2155 //Notify other scheduling users that this schedule has changed
2156 try
2157 {
2158 //this.Document.RefreshDocument(); no need for this; event raised back and prompts refresh itself.
2159 RaiseRPMSEvent("BSDX SCHEDULE", a.Resource);
2160 }
2161 catch (Exception ex)
2162 {
2163 Debug.Write(ex.Message);
2164 }
2165 this.calendarGrid1.Invalidate();
2166 }
2167 }
2168 AutoRebookFromList(alRebookList);
2169 }
2170
2171 /// <summary>
2172 /// Prints Auto Rebook Letters; does nothing else to DB!!!
2173 /// </summary>
2174 /// <param name="alRebookList">List of appointments</param>
2175 private void AutoRebookFromList(CGAppointments alRebookList)
2176 {
2177 //Print AutoRebook letters.
2178 if (alRebookList.AppointmentCount > 0)
2179 {
2180 //build |-delimited list of ApptIDs to pass to BSDX REBOOK LIST
2181 string sApptIDList = "";
2182
2183 System.Collections.ArrayList a = new ArrayList();
2184
2185 foreach (CGAppointment appt in alRebookList.AppointmentTable.Values)
2186 {
2187 string sApptID = appt.AppointmentKey.ToString() + "|";
2188 sApptIDList += sApptID;
2189 if (a.Contains(appt.Resource) == false)
2190 a.Add(appt.Resource);
2191 }
2192
2193 // Print rebooks
2194 string sClinicList = "";
2195 foreach (string sRes in a)
2196 {
2197 sClinicList = sClinicList + sRes + "|";
2198 }
2199 DPatientLetter dpl = new DPatientLetter();
2200 dpl.InitializeFormRebookLetters(this.DocManager, sClinicList, sApptIDList);
2201 dpl.ShowDialog(this);
2202 }
2203 }
2204
2205 /// <summary>
2206 /// Delete one Radiology Appointment
2207 /// </summary>
2208 private void AppointmentDeleteOneRadiology()
2209 {
2210 Debug.Assert(this.calendarGrid1.SelectedAppointment > 0);
2211
2212 CGAppointment a = this.Appointments.AppointmentTable[this.calendarGrid1.SelectedAppointment] as CGAppointment;
2213
2214 Debug.Assert(a.RadiologyExamIEN.HasValue);
2215
2216 //Prior to making expensive db calls, tell the grid nothing is selected anymore so nobody would try to pick it up
2217 this.calendarGrid1.SelectedAppointment = 0;
2218
2219 //Cancel Radiology Exam
2220 CGDocumentManager.Current.DAL.CancelRadiologyExam(a.PatientID, a.RadiologyExamIEN.Value);
2221
2222 //Now, Cancel the appointment
2223 this.Document.DeleteAppointment(a.AppointmentKey);
2224
2225 //redraw the grid to display new set of appointments after this appt was removed.
2226 this.UpdateArrays();
2227 }
2228
2229 /// <summary>
2230 /// Delete appointment ApptID
2231 /// </summary>
2232 /// <param name="nApptID"></param>
2233 /// <returns></returns>
2234 private string AppointmentDeleteOne(int nApptID)
2235 {
2236 return Document.DeleteAppointment(nApptID);
2237 }
2238
2239 /// <summary>
2240 /// Delete all selected appointments
2241 /// </summary>
2242 private void AppointmentDelete()
2243 {
2244 calendarGrid1.CGToolTip.Active = false;
2245 CGAppointments alRebookList = new CGAppointments();
2246
2247 // check to see if any appointment is checked in first
2248 foreach (CGAppointment a in this.calendarGrid1.SelectedAppointments.AppointmentTable.Values)
2249 {
2250 if (a.CheckInTime.Ticks > 0)
2251 {
2252 MessageBox.Show("You must undo the check-in first before removing the appointment.");
2253 return;
2254 }
2255 }
2256
2257 DCancelAppt dCancel = new DCancelAppt();
2258 dCancel.InitializePage(this.m_DocManager);
2259 if (dCancel.ShowDialog(this) != DialogResult.OK)
2260 {
2261 calendarGrid1.CGToolTip.Active = true;
2262 return;
2263 }
2264
2265 //At this point, the appointment will be deleted...
2266 //Remove the Selected Appointment from the grid because we don't anybody to think there's still
2267 //an appointment selected while we are still updating the grid
2268 this.calendarGrid1.SelectedAppointment = 0;
2269
2270 bool bClinic = dCancel.ClinicCancelled;
2271 int nReason = dCancel.CancelReason;
2272 string sRemarks = dCancel.CancelRemarks;
2273 bool bRebook = dCancel.AutoRebook;
2274 int nRebookStart = dCancel.RebookStartDays;
2275 int nRebookMax = dCancel.RebookMaxDays;
2276 int nRebookAccessType = dCancel.RebookAccessType;
2277
2278 calendarGrid1.CGToolTip.Active = true;
2279
2280 foreach (CGAppointment a in this.calendarGrid1.SelectedAppointments.AppointmentTable.Values)
2281 {
2282
2283 int nApptID = a.AppointmentKey;
2284 Debug.Assert(nApptID != 0);
2285 try
2286 {
2287 string sError = Document.DeleteAppointment(nApptID, bClinic, nReason, sRemarks);
2288 if (sError != "")
2289 throw new Exception(sError);
2290
2291 this.UpdateArrays(); //Redraw this calendar grid
2292
2293 if (bRebook == true)
2294 {
2295 try
2296 {
2297 //TODO: Parameterize or dialogize the minum and maximum rebook days
2298 CGAppointment aRebook;
2299 int nMinimumdays = nRebookStart;
2300 int nMaximumdays = nRebookMax;
2301 string sResult = Document.AutoRebook(a, nRebookAccessType, nMinimumdays, nMaximumdays, out aRebook);
2302 if (sResult == "1")
2303 {
2304 //Add appointment to list of rebooked appointments
2305 alRebookList.AddAppointment(a);
2306 }
2307
2308 }
2309 catch (Exception ex)
2310 {
2311 MessageBox.Show("Unable to rebook: " + ex.Message);
2312 }
2313 }
2314
2315 RaiseRPMSEvent("BSDX SCHEDULE", a.Resource);
2316 }
2317 catch (Exception ex)
2318 {
2319 MessageBox.Show("Unable to delete appointment. " + ex.Message, "Clinical Scheduling");
2320 }
2321
2322
2323 if (alRebookList.AppointmentCount > 0)
2324 {
2325 AutoRebookFromList(alRebookList);
2326 }
2327 }
2328 }
2329
2330 private void AppointmentCheckIn()
2331 {
2332 int nApptID = this.calendarGrid1.SelectedAppointment;
2333 Debug.Assert(nApptID != 0);
2334
2335 //smh
2336 //CGAppointment a = (CGAppointment) this.Appointments.AppointmentTable[nApptID];
2337 CGAppointment a = (CGAppointment)this.Document.Appointments.AppointmentTable[nApptID];
2338 try
2339 {
2340 bool bAlreadyCheckedIn = false;
2341 if (a.CheckInTime.Ticks > 0)
2342 bAlreadyCheckedIn = true;
2343
2344 if ((bAlreadyCheckedIn == false)
2345 &&
2346 (a.StartTime.Date > DateTime.Today.Date))
2347 {
2348 MessageBox.Show(this, "It is too early to check in " + a.PatientName, "Windows Scheduling", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
2349 return;
2350 }
2351
2352 DCheckIn dlgCheckin = new DCheckIn();
2353 dlgCheckin.InitializePage(a);
2354 calendarGrid1.CGToolTip.Active = false;
2355 if (dlgCheckin.ShowDialog(this) != DialogResult.OK)
2356 {
2357 calendarGrid1.CGToolTip.Active = true;
2358 return;
2359 }
2360 calendarGrid1.CGToolTip.Active = true;
2361
2362 if (bAlreadyCheckedIn != true)
2363 {
2364 DateTime dtCheckIn = dlgCheckin.CheckInTime;
2365
2366 //Tell appointment that it is checked in, for proper coloring;
2367 //When you refresh from the DB, it will have this property.
2368 a.CheckInTime = DateTime.Now;
2369
2370 //Save to Database
2371 this.Document.CheckInAppointment(nApptID, dtCheckIn);
2372 }
2373
2374 //Get Provider (XXXXXXXX: NOT SAVED TO THE DATABASE RIGHT NOW)
2375 a.Provider = dlgCheckin.Provider;
2376
2377 // Print Routing Slip if user checks that box...
2378 if (dlgCheckin.PrintRouteSlip)
2379 this.PrintRoutingSlip(a);
2380
2381 //redraw grid
2382 this.calendarGrid1.Invalidate();
2383 }
2384 catch (Exception ex)
2385 {
2386 MessageBox.Show("Error checking in patient: " + ex.Message, "Clinical Scheduling");
2387 }
2388
2389 }
2390
2391 private void AppointmentUndoCheckin()
2392 {
2393 Debug.Assert(calendarGrid1.SelectedAppointment > 0);
2394
2395 foreach (CGAppointment a in this.calendarGrid1.SelectedAppointments.AppointmentTable.Values)
2396 {
2397
2398 string msg; //out var
2399 bool didweSucceed = Document.AppointmentUndoCheckin(a, out msg);
2400
2401 if (!didweSucceed)
2402 {
2403 MessageBox.Show("Error: " + msg);
2404 continue;
2405 }
2406
2407 RaiseRPMSEvent("BSDX SCHEDULE", a.Resource);
2408 }
2409
2410 this.UpdateArrays();
2411 }
2412
2413 private void AppointmentAddWalkin()
2414 {
2415 try
2416 {
2417
2418
2419 //Get Time and Resource from Selected Cell
2420 DateTime dStart = DateTime.Today;
2421 DateTime dEnd = DateTime.Today;
2422 string sResource = "";
2423 bool bRet = this.calendarGrid1.GetSelectedTime(out dStart, out dEnd, out sResource);
2424 if (bRet == false)
2425 return;
2426
2427 TimeSpan tsDuration = dEnd - dStart;
2428 int nDuration = (int) tsDuration.TotalMinutes;
2429 Debug.Assert(nDuration > 0);
2430
2431 /*
2432 * 8-10-05 Added check to prevent walkin from being created
2433 * on a date later than today.
2434 */
2435
2436 if (dStart.Date > DateTime.Today.Date)
2437 {
2438 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);
2439 return;
2440 }
2441
2442 // Added check for making Walk-ins in the past. 9/28/2010
2443 if (dStart.Date < DateTime.Today.Date)
2444 {
2445 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);
2446 if (result == DialogResult.No) return;
2447 }
2448
2449 /*
2450 * 8-10-05 Added overbook prompt for walkin
2451 */
2452 //SMH: Takes too long to do.
2453 //this.Document.RefreshDocument();
2454 CGAvailability resultantAvail;
2455
2456 m_nSlots = m_Document.SlotsAvailable(dStart, dEnd, sResource, this.calendarGrid1.TimeScale, out resultantAvail);
2457
2458 if (m_nSlots < 1)
2459 {
2460 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);
2461 if (dr != DialogResult.Yes)
2462 {
2463 return;
2464 }
2465 }
2466
2467 //Display a dialog to collect Patient Name
2468 DPatientLookup dPat = new DPatientLookup();
2469 dPat.DocManager = m_DocManager;
2470
2471 int nAccessTypeID = 0;
2472 bRet = calendarGrid1.GetSelectedType(out nAccessTypeID);
2473
2474 if (dPat.ShowDialog(this) == DialogResult.Cancel)
2475 {
2476 return;
2477 }
2478
2479 CGAppointment appt = new CGAppointment();
2480 appt.PatientID = Convert.ToInt32(dPat.PatientIEN);
2481 appt.PatientName = dPat.PatientName;
2482 appt.StartTime = dStart;
2483 appt.EndTime = dEnd;
2484 appt.Resource = sResource;
2485 appt.HealthRecordNumber = dPat.HealthRecordNumber;
2486
2487 appt.Patient = new Patient
2488 {
2489 DFN = Convert.ToInt32(dPat.PatientIEN),
2490 ID = dPat.PatientPID,
2491 Name = dPat.PatientName,
2492 HRN = dPat.HealthRecordNumber,
2493 DOB = dPat.PatientDOB
2494 };
2495
2496 //smh: Takes too long
2497 //this.Document.RefreshDocument();
2498
2499 //Call Document to add a walkin appointment
2500 int nApptID = this.Document.CreateAppointment(appt, true);
2501
2502 //Now check them in.
2503 calendarGrid1.SelectedAppointment = nApptID;
2504 AppointmentCheckIn();
2505
2506 //Show the new set of appointments by calling UpdateArrays.
2507 this.UpdateArrays();
2508
2509 RaiseRPMSEvent("BSDX SCHEDULE", appt.Resource);
2510 }
2511 catch (Exception ex)
2512 {
2513 string msg;
2514 if (M.Piece(ex.Message, "~", 1) == "-10") // -10 means that BSDXAPI reported an error.
2515 msg = M.Piece(ex.Message, "~", 4);
2516 else
2517 msg = ex.Message;
2518
2519 MessageBox.Show("VISTA says: \r\n" + msg, "Unable to Make Walk-in Appointment");
2520 return;
2521 }
2522 }
2523
2524 private void AppointmentAddNew()
2525 {
2526 try
2527 {
2528 //Get Time and Resource from Selected Cell
2529 DateTime dStart = DateTime.Today;
2530 DateTime dEnd = DateTime.Today;
2531 string sResource = "";
2532 bool bRet = this.calendarGrid1.GetSelectedTime(out dStart, out dEnd, out sResource);
2533 if (bRet == false)
2534 return;
2535
2536 // Added check for making Walk-ins in the past. 9/28/2010
2537 if (dStart.Date < DateTime.Today.Date)
2538 {
2539 var result = MessageBox.Show("Are you sure you want to make an appointment in the past?", "Windows Scheduling", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2);
2540 if (result == DialogResult.No) return;
2541 }
2542
2543 //Test dStart for Holiday
2544 DataView dvHoliday = new DataView(this.DocManager.GlobalDataSet.Tables["HOLIDAY"]);
2545 dvHoliday.Sort="DATE ASC";
2546 int nFind = dvHoliday.Find(dStart.Date);
2547 if (nFind > -1)
2548 {
2549 string sHoliday = "";
2550 DataRowView drv = dvHoliday[nFind];
2551 sHoliday = drv["NAME"].ToString();
2552 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)
2553 return;
2554 }
2555
2556 //Sam: takes too long. Remove this call; deal with the issue of concurrent appointments another way.
2557 //this.Document.RefreshDocument();
2558 CGAvailability resultantAvail;
2559 m_nSlots = m_Document.SlotsAvailable(dStart, dEnd, sResource, this.calendarGrid1.TimeScale, out resultantAvail);
2560
2561 if (m_nSlots < 1)
2562 {
2563 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);
2564 if (dr != DialogResult.Yes)
2565 {
2566 return;
2567 }
2568 }
2569
2570 //Display a dialog to collect Patient Name
2571 DPatientLookup dPat = new DPatientLookup();
2572 dPat.DocManager = m_DocManager;
2573
2574 int nAccessTypeID = 0;
2575 bRet = calendarGrid1.GetSelectedType(out nAccessTypeID);
2576
2577 if (dPat.ShowDialog(this) == DialogResult.Cancel)
2578 {
2579 return;
2580 }
2581
2582 //Call the appointment dialog to collect the appointment info
2583 Debug.Assert(dPat.PatientIEN != "");
2584 DAppointPage dAppt = new DAppointPage();
2585 dAppt.DocManager = this.m_DocManager;
2586 string sNote = "";
2587 dAppt.InitializePage(dPat.PatientIEN, dStart, dEnd, sResource, sNote, nAccessTypeID);
2588
2589 if (dAppt.ShowDialog(this) == DialogResult.Cancel)
2590 {
2591 return;
2592 }
2593
2594 CGAppointment appt = dAppt.Appointment;
2595
2596 // old way of making an appointment
2597 /*new CGAppointment();
2598 appt.PatientID = Convert.ToInt32(dPat.PatientIEN);
2599 appt.PatientName = dPat.PatientName;
2600 appt.StartTime = dStart;
2601 appt.EndTime = dEnd;
2602 appt.Resource = sResource;
2603 appt.Note = dAppt.Note;
2604 appt.HealthRecordNumber = dPat.HealthRecordNumber;
2605 appt.AccessTypeID = nAccessTypeID;
2606 */
2607
2608 //Call Document to add a new appointment. Document adds appointment to CGAppointments array.
2609 this.Document.CreateAppointment(appt);
2610
2611
2612 if (dAppt.PrintAppointmentSlip)
2613 {
2614 PrintAppointmentSlip(appt);
2615 }
2616
2617 //Show the new set of appointments by calling UpdateArrays. Fetches Document's CGAppointments
2618 this.UpdateArrays();
2619
2620 RaiseRPMSEvent("BSDX SCHEDULE", appt.Resource);
2621 }
2622 catch (Exception ex)
2623 {
2624 string msg;
2625 if (M.Piece(ex.Message, "~", 1) == "-10") // -10 means that BSDXAPI reported an error.
2626 msg = M.Piece(ex.Message, "~", 4);
2627 else
2628 msg = ex.Message;
2629
2630 MessageBox.Show("VISTA says: \r\n" + msg, "Unable to Make Appointment");
2631 return;
2632 }
2633 }
2634
2635 /// <summary>
2636 /// Add a new Radiology Appointment to VISTA (ÒÝÊì as my mom calls it)
2637 /// </summary>
2638 private void AppointmentAddNewRadiology()
2639 {
2640 DateTime dStart, dEnd; //return vales for below
2641 string sResource; //ditto
2642 int nAccessTypeID = 0; //ditto
2643
2644 this.calendarGrid1.GetSelectedTime(out dStart, out dEnd, out sResource);
2645 this.calendarGrid1.GetSelectedType(out nAccessTypeID);
2646
2647 Debug.Assert(sResource != null);
2648 Debug.Assert(dStart > DateTime.MinValue);
2649
2650 //Display a dialog to collect Patient Name
2651 DPatientLookup dPat = new DPatientLookup();
2652 dPat.DocManager = m_DocManager;
2653
2654 if (dPat.ShowDialog(this) == DialogResult.Cancel)
2655 {
2656 return;
2657 }
2658
2659 int DFN = Int32.Parse(dPat.PatientIEN);
2660 // Hospital Location IEN
2661 int hlIEN = (from resource in CGDocumentManager.Current.GlobalDataSet.Tables["Resources"].AsEnumerable()
2662 where resource.Field<string>("RESOURCE_NAME") == sResource
2663 select resource.Field<int>("HOSPITAL_LOCATION_ID")).FirstOrDefault();
2664
2665 //Get Radiology Exams from the DB
2666 List<RadiologyExam> _radExams = CGDocumentManager.Current.DAL.GetRadiologyExamsForPatientinHL(DFN, hlIEN);
2667
2668 //If none found...
2669 if (!_radExams.Any())
2670 {
2671 MessageBox.Show("Patient does not have any radiology exams to register.");
2672 return;
2673 }
2674
2675 //Display a form for the user to select radiology exams.
2676 DRadExamsSelect _radform = new DRadExamsSelect(_radExams);
2677
2678 if (_radform.ShowDialog() == DialogResult.Cancel) return;
2679
2680 //Get some return values
2681 int _examien = _radform.ExamIEN;
2682 string _procedurename = _radform.ProcedureName;
2683
2684 //Save Radiology Exam Schedule Info to Radiology Package
2685 CGDocumentManager.Current.DAL.ScheduleRadiologyExam(DFN, _examien, dStart);
2686
2687 //Now create and save the appointment
2688 CGAppointment appt = new CGAppointment();
2689 string _sNote = "Radiology Exam (" + _examien + "): " + _procedurename;
2690 appt.CreateAppointment(dStart, dEnd, _sNote, 0, sResource);
2691 appt.PatientID = Int32.Parse(dPat.PatientIEN);
2692 appt.PatientName = dPat.PatientName;
2693 appt.AccessTypeID = nAccessTypeID;
2694 appt.RadiologyExamIEN = _examien;
2695 appt.Patient = new Patient
2696 {
2697 DFN = Convert.ToInt32(dPat.PatientIEN),
2698 ID = dPat.PatientPID,
2699 Name = dPat.PatientName,
2700 HRN = dPat.HealthRecordNumber,
2701 DOB = dPat.PatientDOB
2702 };
2703
2704 this.Document.CreateAppointment(appt);
2705
2706 //Print Appointment Slip if requested
2707 if (_radform.PrintAppointmentSlip) this.PrintAppointmentSlip(appt);
2708
2709 //Now redraw the grid to display the new appointments
2710 this.UpdateArrays();
2711 }
2712
2713
2714 #region BMX Event Processing and Callbacks
2715 /// <summary>
2716 /// Loosely typed delegate used several times below.
2717 /// </summary>
2718 delegate void OnUpdateScheduleDelegate();
2719
2720 /// <summary>
2721 /// Subscription point for each CGView to process BMX events polled from the server
2722 /// </summary>
2723 /// <param name="obj">Not used</param>
2724 /// <param name="e">BMXEvent Args:
2725 /// e.BMXEvent is free text for Event Type; e.BMXParam is free text for Event Arguments</param>
2726 private void BMXNetEventHandler(Object obj, RemoteEventArgs e)
2727 {
2728 try
2729 {
2730 // if this class is undefined (e.g. if the user just closed the form, do nothing
2731 if (this == null) return;
2732
2733 // if event is Autofire event
2734 if (e.EventType == "BMXNet AutoFire")
2735 {
2736 Debug.Write("CGView caught AutoFire event.\n");
2737
2738 //Create a delegate to OnUpdateSchedule and call Async
2739 //Once Async Call is done, go to OnUpdateScheduleCallback
2740 OnUpdateScheduleDelegate ousd = new OnUpdateScheduleDelegate(OnUpdateSchedule);
2741 ousd.BeginInvoke(OnUpdateScheduleCallback, null);
2742
2743 return;
2744 }
2745
2746 // if event is BSDX SCHEDULE
2747 else if (e.EventType == "BSDX SCHEDULE")
2748 {
2749 //See if any of the resources in the event argument matches BSDX Schedule.
2750 //If yes, fire off the delegate
2751 string sResourceName;
2752 for (int j = 0; j < m_Document.m_sResourcesArray.Count; j++)
2753 {
2754 sResourceName = m_Document.m_sResourcesArray[j].ToString();
2755 if (e.Details == sResourceName)
2756 {
2757 Debug.Write("CGView caught BSDX SCHEDULE event.\n");
2758
2759 //Create a delegate to OnUpdateSchedule and call Async
2760 //Once Async Call is done, go to OnUpdateScheduleCallb
2761 OnUpdateScheduleDelegate ousd = new OnUpdateScheduleDelegate(OnUpdateSchedule);
2762 ousd.BeginInvoke(OnUpdateScheduleCallback, null);
2763
2764 break;
2765 }
2766 }
2767 }
2768 }
2769 catch (Exception ex)
2770 {
2771 Debug.Write(ex.Message);
2772 }
2773 }
2774
2775 /// <summary>
2776 /// Update Appointments and Availabilites using Document.RefreshDocumentAsync on a different thread
2777 /// </summary>
2778 /// <remarks>
2779 /// This method is expected to be called asynchornously.
2780 /// </remarks>
2781 public void OnUpdateSchedule()
2782 {
2783 try
2784 {
2785 m_Document.RefreshDocumentAsync(); //new
2786 }
2787 catch (Exception ex)
2788 {
2789 MessageBox.Show("Unable to refresh document " + ex.Message, "Clinical Scheduling");
2790 }
2791 }
2792
2793 /// <summary>
2794 /// Callback for when OnUpdateSchedule is done. Triggers the Grid to redraw itself by calling UpdateArrays.
2795 /// </summary>
2796 /// <param name="itfAR">not used</param>
2797 /// <remarks>Calls UpdateArrays via this.Invoke to make sure that the grid is redrawn on the UI thread</remarks>
2798 private void OnUpdateScheduleCallback(IAsyncResult itfAR)
2799 {
2800 OnUpdateScheduleDelegate d = new OnUpdateScheduleDelegate(UpdateArrays);
2801
2802 //try catch just in case that the view closed in the meantime.
2803 try
2804 {
2805 this.Invoke(d);
2806 }
2807 catch (InvalidOperationException)
2808 {
2809 return;
2810 }
2811 }
2812
2813 /// <summary>
2814 /// Create a new event in RPMS. Wrapper around BMXConnectInfo.RaiseEvent
2815 /// </summary>
2816 /// <param name="sEvent">Name of Event to Raise</param>
2817 /// <param name="sParams">Parameter of Event to Raise</param>
2818 public void RaiseRPMSEvent(string sEvent, string sParams)
2819 {
2820 try
2821 {
2822 //Signal RPMS to raise an event
2823 CGDocumentManager.Current.RemoteSession.EventServices.TriggerEvent(sEvent, sParams, false);
2824 }
2825 catch (Exception ex)
2826 {
2827 Debug.Write(ex.Message);
2828 }
2829 }
2830
2831 #endregion
2832
2833 /// <summary>
2834 /// This is how you set how the grid will look
2835 /// </summary>
2836 public void UpdateArrays()
2837 {
2838 // Make sure that we are called synchronously
2839 Debug.Assert(this.InvokeRequired == false,"CGView.UpdateArrays InvokeRequired");
2840 // This is where you set how the grid will look
2841
2842 //Create Deep copy of Availability Array
2843 ArrayList availArrayCopy = new ArrayList();
2844 foreach (CGAvailability av in this.m_Document.AvailabilityArray)
2845 availArrayCopy.Add(av);
2846
2847 try
2848 {
2849 //Tell the grid about Avails, Appts, and Resources.
2850 this.calendarGrid1.AvailabilityArray = availArrayCopy;
2851 //Appts are cloned b/c if we tie into the class directly, we shoot off errors when we manipulate it.
2852 this.calendarGrid1.Appointments = (CGAppointments)this.m_Document.Appointments.Clone();
2853 this.calendarGrid1.Resources = this.m_Document.Resources;
2854 //Redraw the calendar grid
2855 this.calendarGrid1.OnUpdateArrays(); // this draws the Calendar
2856 this.lblResource.Text = this.m_Document.DocName;
2857 this.calendarGrid1.Invalidate();
2858 }
2859 catch (Exception ex)
2860 {
2861 MessageBox.Show("Unable to update arrays " + ex.Message, "Clinical Scheduling");
2862 }
2863 }
2864
2865 private void SchedulingManagement()
2866 {
2867 try
2868 {
2869 bool bLock = CGDocumentManager.Current.RemoteSession.Lock("^BSDXMGR", "+");
2870 if (bLock == false)
2871 {
2872 throw new Exception("Another user is currently in Scheduling Management. Try later.");
2873 }
2874
2875 DManagement dMgm = new DManagement();
2876 dMgm.InitializeDialog(this.m_DocManager);
2877
2878 if (dMgm.ShowDialog(this) == DialogResult.Cancel)
2879 {
2880 }
2881
2882 m_DocManager.GlobalDataSet.Tables["ResourceUser"].Clear();
2883 m_DocManager.LoadResourceUserTable(false);
2884 bLock = CGDocumentManager.Current.RemoteSession.Lock("^BSDXMGR", "-");
2885 }
2886 catch (ApplicationException aex)
2887 {
2888 string sMsg = aex.Message;
2889 MessageBox.Show("Unable to acquire transmit lock. Try later.");
2890 }
2891 catch (Exception ex)
2892 {
2893 MessageBox.Show("Scheduling Management Error: " + ex.Message, "Clinical Scheduling");
2894 }
2895 }
2896
2897 public void UpdateTree()
2898 {
2899 this.tvSchedules.Nodes.Clear();
2900 this.LoadTree();
2901 }
2902
2903 public void ViewPatientAppointments()
2904 {
2905 try
2906 {
2907 //Display a dialog to collect Patient Name
2908 DPatientLookup dPat = new DPatientLookup();
2909 dPat.DocManager = m_DocManager;
2910 if (dPat.ShowDialog(this) == DialogResult.Cancel)
2911 {
2912 return;
2913 }
2914
2915 Debug.Assert(dPat.PatientIEN != "");
2916 int nPatientID = Convert.ToInt32(dPat.PatientIEN);
2917 ViewPatientAppointments(nPatientID);
2918 }
2919 catch (Exception ex)
2920 {
2921 MessageBox.Show(this, ex.Message, "Clinical Scheduling", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
2922 }
2923 }
2924
2925 public void ViewPatientAppointments(int PatientID)
2926 {
2927 DPatientApptDisplay dPa = new DPatientApptDisplay();
2928
2929 dPa.InitializeForm(this.DocManager, PatientID);
2930
2931
2932 if (dPa.ShowDialog(this) != DialogResult.Cancel)
2933 {
2934
2935 }
2936
2937 }
2938
2939 private void FindAvailableAppointment(ArrayList alResourceArray)
2940 {
2941 DApptSearch dSearch = new DApptSearch();
2942 dSearch.InitializePage(alResourceArray, this.m_DocManager);
2943 if (dSearch.ShowDialog(this) == DialogResult.Cancel)
2944 return;
2945
2946 CGAvailability av = dSearch.SelectedAvailability;
2947
2948 ArrayList alResource = new ArrayList();
2949 alResource.Add(av.ResourceList);
2950 DateTime sDate = av.StartTime;
2951 m_sDocName = av.ResourceList;
2952 OpenSelectedSchedule(alResource, sDate);
2953
2954 }
2955
2956 #endregion Methods
2957
2958 #region Events
2959
2960 /// <summary>
2961 /// Special import to get the GetActiveWindow method from Win32
2962 /// </summary>
2963 /// <returns>Windows Handle number for Foregreound Active Window</returns>
2964 [DllImport("user32.dll")]
2965 static extern IntPtr GetActiveWindow();
2966
2967 /// <summary>
2968 /// If a mouse enters the grid, check if the grid is on the active form first before stealing the focus
2969 /// </summary>
2970 /// <param name="sender"></param>
2971 /// <param name="e"></param>
2972 private void calendarGrid1_MouseEnter(object sender, EventArgs e)
2973 {
2974 if (GetActiveWindow() == this.Handle)
2975 calendarGrid1.Focus();
2976 }
2977
2978 /// <summary>
2979 /// If mouse enters the Tree Section, check if the grid is on the active form first before stealing the focus
2980 /// </summary>
2981 /// <param name="sender"></param>
2982 /// <param name="e"></param>
2983 private void tvSchedules_MouseEnter(object sender, EventArgs e)
2984 {
2985 if (GetActiveWindow() == this.Handle)
2986 tvSchedules.Focus();
2987 }
2988
2989 private void CGView_Load(object sender, System.EventArgs e)
2990 {
2991 Debug.Assert (this.Document != null);
2992
2993 //Register the view
2994 CGDocumentManager.Current.RegisterDocumentView(this.Document, this);
2995
2996 //Load the Group-Resource treeview
2997 LoadTree();
2998
2999 this.SetDesktopLocation(this.DesktopLocation.X + 10, this.DesktopLocation.Y + 10);
3000
3001 //Show the Form
3002 this.Activate();
3003
3004 //Set focus on the calendar grid
3005 this.calendarGrid1.Focus();
3006 }
3007
3008 private void mnuOpenSchedule_Click(object sender, System.EventArgs e)
3009 {
3010 CreateNewSchedule();
3011 }
3012
3013 private void mnu1Day_Click(object sender, System.EventArgs e)
3014 {
3015 DateTime dtPicker = dateTimePicker1.Value;
3016 DateTime DayOnly = new DateTime(dtPicker.Year, dtPicker.Month, dtPicker.Day);
3017 this.calendarGrid1.StartDate = DayOnly;
3018 this.calendarGrid1.Columns = 1;
3019 }
3020
3021 private void mnu5Day_Click(object sender, System.EventArgs e)
3022 {
3023 if (this.calendarGrid1.Columns == 1)
3024 {
3025 this.StartDate = this.Document.StartDate;
3026 }
3027
3028 this.calendarGrid1.Columns = 5;
3029 this.Document.m_nColumnCount = 5; // MJL 1/17/2007
3030 RequestRefreshGrid();
3031 }
3032
3033 private void mnu7Day_Click(object sender, System.EventArgs e)
3034 {
3035 this.calendarGrid1.Columns = 7;
3036 this.Document.m_nColumnCount = 7; // MJL 1/17/2007
3037 RequestRefreshGrid();
3038 }
3039
3040 private void mnu10Minute_Click(object sender, System.EventArgs e)
3041 {
3042 CalendarGrid cg = this.calendarGrid1;
3043 cg.TimeScale = 10;
3044 cg.PositionGrid(7);
3045 }
3046
3047 private void mnu15Minute_Click(object sender, System.EventArgs e)
3048 {
3049 CalendarGrid cg = this.calendarGrid1;
3050 cg.TimeScale = 15;
3051 cg.PositionGrid(7);
3052 }
3053
3054 private void mnu20Minute_Click(object sender, System.EventArgs e)
3055 {
3056 CalendarGrid cg = this.calendarGrid1;
3057 cg.TimeScale = 20;
3058 cg.PositionGrid(7);
3059 }
3060
3061 private void mnu30Minute_Click(object sender, System.EventArgs e)
3062 {
3063 CalendarGrid cg = this.calendarGrid1;
3064 cg.TimeScale = 30;
3065 cg.PositionGrid(7);
3066 }
3067
3068 private void mnuViewScheduleTree_Click(object sender, System.EventArgs e)
3069 {
3070 this.mnuViewScheduleTree.Checked = this.tvSchedules.Visible;
3071 this.tvSchedules.Visible = !(this.tvSchedules.Visible);
3072 this.mnuViewScheduleTree.Checked = !(this.mnuViewScheduleTree.Checked);
3073 }
3074
3075
3076
3077 private void tvSchedules_DoubleClick(object sender, System.EventArgs e)
3078 {
3079 if (m_alSelectedTreeResourceArray == null)
3080 return;
3081 if (m_alSelectedTreeResourceArray.Count < 1)
3082 {
3083 if (this.tvSchedules.SelectedNode.Text != "")
3084 {
3085 SetResourceArrayFromGroup(tvSchedules.SelectedNode.Text);
3086 }
3087 else
3088 {
3089 return;
3090 }
3091 }
3092 OpenSelectedSchedule(m_alSelectedTreeResourceArray, DateTime.Today);
3093 }
3094
3095 //20041109 Added
3096 private void SetResourceArrayFromGroup(string sGroup)
3097 {
3098 //Navigate from ResourceGroup table to Resources table
3099 DataRow[] arrRows;
3100 DataRelation dr = DocManager.GlobalDataSet.Relations["GroupResource"];
3101 DataRow r = DocManager.GlobalDataSet.Tables["ResourceGroup"].Rows.Find(sGroup);
3102 arrRows = r.GetChildRows(dr);
3103 for (int i=0; i< arrRows.Length; i++)
3104 {
3105 string sResource = arrRows[i]["RESOURCE_NAME"].ToString();
3106 m_alSelectedTreeResourceArray.Add(sResource);
3107 }
3108 m_sDocName = sGroup;
3109 }
3110
3111 public void SyncTree()
3112 {
3113
3114 }
3115
3116
3117 private void tvSchedules_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
3118 {
3119 m_alSelectedTreeResourceArray = new ArrayList();
3120 string sResource = e.Node.FullPath;
3121 string[] ss = sResource.Split((char) 92);
3122 int l = ss.GetUpperBound(0);
3123
3124 if (l == 0) //a resource group was checked, so get all underying resources
3125 {
3126 SetResourceArrayFromGroup(ss[0]);
3127 }
3128 else
3129 {
3130 sResource = ss[l];
3131 m_alSelectedTreeResourceArray.Add(ss[1]);
3132 }
3133
3134 m_sDocName = ss[l];
3135 return;
3136
3137 }
3138
3139 /// <summary>
3140 /// Makes sure that the node gets selected no matter where we click.
3141 /// Incidentally, Invokes AfterSelect event.
3142 /// </summary>
3143 /// <param name="sender"></param>
3144 /// <param name="e"></param>
3145 private void tvSchedules_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
3146 {
3147 e.Node.TreeView.SelectedNode = e.Node;
3148 }
3149
3150 private void CGView_Closing(object sender, System.ComponentModel.CancelEventArgs e)
3151 {
3152 try
3153 {
3154 CGDocumentManager.Current.RemoteSession.EventServices.RpmsEvent -= BMXNetEventHandler;
3155 this.calendarGrid1.CloseGrid();
3156 }
3157 catch (Exception ex)
3158 {
3159 Debug.Write("CGView_Closing exception: " + ex.Message + "\n");
3160 }
3161 }
3162
3163 private void mnuViewRightPanel_Click(object sender, System.EventArgs e)
3164 {
3165 this.mnuViewRightPanel.Checked = this.panelRight.Visible;
3166 this.panelRight.Visible = !(this.panelRight.Visible);
3167 this.mnuViewRightPanel.Checked = !(this.mnuViewRightPanel.Checked);
3168 }
3169
3170
3171 private void calendarGrid1_CGSelectionChanged(object sender, IndianHealthService.ClinicalScheduling.CGSelectionChangedArgs e)
3172 {
3173 CGAvailability resultantAvail;
3174 m_nSlots = m_Document.SlotsAvailable(e.StartTime, e.EndTime, e.Resource, this.calendarGrid1.TimeScale, out resultantAvail);
3175 UpdateStatusBar(e.StartTime, e.EndTime, resultantAvail);
3176 }
3177
3178 /// <summary>
3179 /// Fired during drag and drop, on the drop action.
3180 /// </summary>
3181 /// <param name="sender"></param>
3182 /// <param name="e"></param>
3183 private void calendarGrid1_CGAppointmentChanged(object sender, IndianHealthService.ClinicalScheduling.CGAppointmentChangedArgs e)
3184 {
3185 try
3186 {
3187 // added April 13 2011
3188 // Can't edit radiology appointments (Why? b/c it's intimately tied to Radiology Entry of the Hosp Loc)
3189 if (e.Appointment.RadiologyExamIEN.HasValue && e.Appointment.RadiologyExamIEN.Value > 0)
3190 {
3191 MessageBox.Show("You cannot move a radiology appointment.", "Clinical Scheduling");
3192 return;
3193 }
3194
3195 // added May 5 2011
3196 // Can't move an appointment to a radiology resource
3197 if (IsThisARadiologyResource(e.Resource))
3198 {
3199 MessageBox.Show("You cannot move an appointment to a radiology location.", "Clinical Scheduling");
3200 return;
3201 }
3202
3203 if (e.Appointment.CheckInTime.Ticks > 0)
3204 {
3205 MessageBox.Show("You cannot change the appointment time because the patient has already checked in.", "Clinical Scheduling");
3206 return;
3207 }
3208
3209 // Added check for making Walk-ins/appts in the past. 9/28/2010 //smh
3210 if (e.StartTime < DateTime.Today.Date)
3211 {
3212 var result = MessageBox.Show("Are you sure you want to make an appointment in the past?", "Windows Scheduling", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2);
3213 if (result == DialogResult.No) return;
3214 }
3215
3216 //Can user edit destination resource?
3217 if (EditAppointmentEnabled(e.Resource) == false)
3218 return;
3219
3220 //Can user edit original schedule?
3221 if (EditAppointmentEnabled(e.Appointment.Resource) == false)
3222 return;
3223
3224 if (MessageBox.Show("Are you sure you want to move this appointment?", "Clinical Scheduling", MessageBoxButtons.YesNo) != DialogResult.Yes)
3225 return;
3226
3227 //20040909 Cherokee Replaced this block with following
3228 // if (m_Document.SlotsAvailable(e.StartTime, e.EndTime, e.Resource, out sAccessType, out sAvailabilityMessage) < 1)
3229 // {
3230 // MessageBox.Show("There are no appointment slots available for the selected time.");
3231 // return;
3232 // }
3233 bool bOverbook =false;
3234 if (m_htOverbook.Count > 0)
3235 {
3236 bOverbook = (bool) this.m_htOverbook[e.Resource.ToString()];
3237 }
3238 bool bModSchedule =false;
3239 if (m_htModifySchedule.Count > 0)
3240 {
3241 bModSchedule = (bool) this.m_htModifySchedule[e.Resource.ToString()];
3242 }
3243 CGAvailability resultantAvail;
3244 bool bSlotsAvailable = (m_Document.SlotsAvailable(e.StartTime, e.EndTime, e.Resource, this.calendarGrid1.TimeScale, out resultantAvail) > 0);
3245 if (!((bSlotsAvailable) || (bModSchedule) || (bOverbook) ))
3246 {
3247 MessageBox.Show("There are no appointment slots available for the selected time.");
3248 return;
3249 }
3250
3251 /*
3252 * 7-19-05 Added overbook prompt
3253 */
3254 if (bSlotsAvailable == false)
3255 {
3256 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);
3257 if (dr != DialogResult.Yes)
3258 {
3259 return;
3260 }
3261 }
3262
3263 //Create a new appointment using old data for patient demographics and note and new data
3264 //for StartTime, EndTime, Resource, AccessTypeID
3265 CGAppointment appt = new CGAppointment();
3266 appt.PatientID = e.Appointment.PatientID;
3267 appt.PatientName = e.Appointment.PatientName;
3268 appt.StartTime = e.StartTime;
3269 appt.EndTime = e.EndTime;
3270 appt.Resource = e.Resource;
3271 appt.Note = e.Appointment.Note;
3272 appt.HealthRecordNumber = e.Appointment.HealthRecordNumber;
3273 appt.AccessTypeID = e.AccessTypeID;
3274 appt.Patient = e.Appointment.Patient;
3275
3276 this.Document.CreateAppointment(appt);
3277
3278 //CGAppointment a = new CGAppointment();
3279 //a.StartTime = e.StartTime;
3280 ////e.Appointment.StartTime = e.StartTime
3281 //a.EndTime = e.EndTime;
3282 ////e.Appointment.EndTime = e.EndTime;
3283 //a.Resource = e.Resource;
3284 ////e.Appointment.Resource = e.Resource;
3285 //a.AccessTypeID = e.AccessTypeID;
3286 ////e.Appointment.AccessTypeID = e.AccessTypeID;
3287 //m_Document.CreateAppointment(a);
3288
3289
3290 string sError = AppointmentDeleteOne(e.Appointment.AppointmentKey);
3291 if (sError != "")
3292 {
3293 MessageBox.Show(sError);
3294 return;
3295 }
3296
3297 }
3298 catch (Exception ex)
3299 {
3300 MessageBox.Show("Unable to change appointment " + ex.Message, "Clinical Scheduling");
3301 //this.m_DocManager.UpdateViews();
3302 return;
3303 }
3304 finally
3305 {
3306 this.UpdateArrays();
3307 }
3308 try
3309 {
3310 RaiseRPMSEvent("BSDX SCHEDULE" , e.Resource);
3311 if (e.Resource != e.OldResource)
3312 RaiseRPMSEvent("BSDX SCHEDULE", e.OldResource);
3313
3314 //That will take too long. Don't do it. Try and see what happens when you come
3315 //this.m_DocManager.UpdateViews(e.Resource, e.OldResource);
3316 }
3317 catch (Exception ex)
3318 {
3319 Debug.Write(ex.Message);
3320 }
3321 }
3322
3323 private void mnuSchedulingManagment_Click(object sender, System.EventArgs e)
3324 {
3325 SchedulingManagement();
3326 }
3327
3328 private void mnuFile_Popup(object sender, System.EventArgs e)
3329 {
3330 this.mnuSchedulingManagment.Enabled = DocManager.ScheduleManager;
3331 }
3332
3333 private void mnuFindAppt_Click(object sender, System.EventArgs e)
3334 {
3335 FindAvailableAppointment(this.Document.Resources);
3336 }
3337
3338 private void mnuRPMSServer_Click(object sender, System.EventArgs e)
3339 {
3340 //Handled by DocumentManager class
3341 }
3342
3343 private void mnuRPMSLogin_Click(object sender, System.EventArgs e)
3344 {
3345 //Handled by DocumentManager class
3346 }
3347
3348 private void CGView_Activated(object sender, System.EventArgs e)
3349 {
3350 calendarGrid1.GridEnter = true;
3351 }
3352
3353 private void mnuHelpAbout_Click(object sender, System.EventArgs e)
3354 {
3355 MessageBox.Show("Clinical Scheduling Version " + Application.ProductVersion, "Clinical Scheduling", MessageBoxButtons.OK, MessageBoxIcon.Information);
3356 }
3357
3358 private void ImplementMsg()
3359 {
3360 MessageBox.Show("Clinical Scheduling", "TODO: Implement this function");
3361 }
3362
3363 private void mnuClose_Click(object sender, System.EventArgs e)
3364 {
3365 DialogResult dr = MessageBox.Show("Are you sure you want to close this schedule?", Application.ProductName, MessageBoxButtons.OKCancel);
3366 if (dr != DialogResult.OK)
3367 return;
3368
3369 this.Close();
3370 }
3371
3372 private void mnuViewPatientAppts_Click(object sender, System.EventArgs e)
3373 {
3374 ViewPatientAppointments();
3375 }
3376
3377 private void lstClip_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
3378 {
3379 bool b = e.Data.GetDataPresent(typeof(CGAppointment));
3380 if (b == true)
3381 {
3382 e.Effect = DragDropEffects.Move;
3383 }
3384 else
3385 {
3386 e.Effect = DragDropEffects.None;
3387 }
3388
3389 }
3390
3391 private void lstClip_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
3392 {
3393 try
3394 {
3395 CGAppointment a = (CGAppointment) e.Data.GetData(typeof(CGAppointment));
3396 if (m_ClipList.AppointmentTable.Contains((int) a.AppointmentKey))
3397 {
3398 return;
3399 }
3400 m_ClipList.AddAppointment(a);
3401 lstClip.Items.Add(a);
3402 }
3403 catch(Exception ex)
3404 {
3405 Debug.Write(ex.Message);
3406 }
3407
3408 }
3409
3410 private void lstClip_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
3411 {
3412 m_bDragDropStart = false;
3413 }
3414
3415 private void lstClip_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
3416 {
3417 try
3418 {
3419 if ((m_bDragDropStart == false)&&(lstClip.SelectedIndex > -1))
3420 {
3421 CGAppointment a = (CGAppointment) lstClip.Items[lstClip.SelectedIndex];
3422 this.calendarGrid1.ApptDragSource = "list";
3423 DragDropEffects effect = DoDragDrop(a, DragDropEffects.Move);
3424 m_bDragDropStart = true;
3425 }
3426 }
3427 catch (Exception ex)
3428 {
3429 Debug.Write(ex.Message);
3430 }
3431 }
3432
3433 private void calendarGrid1_CGAppointmentAdded(object sender, IndianHealthService.ClinicalScheduling.CGAppointmentChangedArgs e)
3434 {
3435 try
3436 {
3437 bool bSlotsAvailable;
3438 bool bOverbook;
3439 bool bModSchedule;
3440 bool bModAppts;
3441
3442 if (this.EditAppointmentEnabled(e.Appointment.Resource) == false)
3443 return;
3444
3445 bModAppts = (bool) this.m_htChangeAppts[e.Resource.ToString()];
3446 if (bModAppts == false)
3447 return;
3448
3449 // Added check for making Walk-ins/appts in the past. 9/28/2010 //smh
3450 if (e.StartTime < DateTime.Today.Date)
3451 {
3452 var result = MessageBox.Show("Are you sure you want to make an appointment in the past?", "Windows Scheduling", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2);
3453 if (result == DialogResult.No) return;
3454 }
3455
3456
3457 bOverbook = (bool) this.m_htOverbook[e.Resource.ToString()];
3458 bModSchedule = (bool) this.m_htModifySchedule[e.Resource.ToString()];
3459 CGAvailability resultantAvail;
3460
3461 bSlotsAvailable = (m_Document.SlotsAvailable(e.StartTime, e.EndTime, e.Resource, this.calendarGrid1.TimeScale, out resultantAvail) > 0);
3462
3463 if (!((bSlotsAvailable) || (bModSchedule) || (bOverbook) ))
3464 {
3465 MessageBox.Show("There are no appointment slots available for the selected time.");
3466 return;
3467 }
3468
3469 /*
3470 * 7-19-05 Added overbook prompt
3471 */
3472 if (bSlotsAvailable == false)
3473 {
3474 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);
3475 if (dr != DialogResult.Yes)
3476 {
3477 return;
3478 }
3479 }
3480
3481 e.Appointment.StartTime = e.StartTime;
3482 e.Appointment.EndTime = e.EndTime;
3483 e.Appointment.Resource = e.Resource;
3484 e.Appointment.AccessTypeID = e.AccessTypeID;
3485 m_Document.CreateAppointment(e.Appointment);
3486 }
3487 catch (Exception ex)
3488 {
3489 MessageBox.Show("Unable to add new appointment " + ex.Message, "Clinical Scheduling");
3490 return;
3491 }
3492 try
3493 {
3494 RaiseRPMSEvent("BSDX SCHEDULE" , e.Resource);
3495 if (e.Resource != e.OldResource)
3496 RaiseRPMSEvent("BSDX SCHEDULE", e.OldResource);
3497 this.m_DocManager.UpdateViews(e.Resource, e.OldResource);
3498 }
3499 catch (Exception ex)
3500 {
3501 Debug.Write(ex.Message);
3502 }
3503 }
3504
3505 private void lstClip_SelectedIndexChanged(object sender, System.EventArgs e)
3506 {
3507
3508 }
3509
3510 private void mnuPrintClinicSchedules_Click(object sender, System.EventArgs e)
3511 {
3512 try
3513 {
3514 DSelectLetterClinics ds = new DSelectLetterClinics();
3515 ds.InitializePage(this.m_DocManager.GlobalDataSet, "Print Clinic Schedules");
3516 ds.SetupForReports();
3517 if (ds.ShowDialog(this) != DialogResult.OK)
3518 return;
3519
3520 //get the resource names and call the letter printer
3521
3522 string sClinics = ds.SelectedClinics;
3523 DateTime dtBegin = ds.BeginDate;
3524 DateTime dtEnd = ds.EndDate;
3525
3526 DPatientLetter dpl = new DPatientLetter();
3527 dpl.InitializeFormClinicSchedule(this.DocManager, sClinics, dtBegin, dtEnd);
3528 dpl.ShowDialog(this);
3529
3530 }
3531 catch(Exception ex)
3532 {
3533 MessageBox.Show(this, ex.Message, "Clinical Scheduling", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
3534 }
3535 }
3536
3537 private void mnuPrintReminderLetters_Click(object sender, System.EventArgs e)
3538 {
3539 try
3540 {
3541 DSelectLetterClinics ds = new DSelectLetterClinics();
3542 ds.InitializePage(this.m_DocManager.GlobalDataSet, "Print Reminder Letters");
3543 if (ds.ShowDialog(this) != DialogResult.OK)
3544 return;
3545
3546 //get the resource names and call the letter printer
3547
3548 string sClinics = ds.SelectedClinics;
3549 DateTime dtBegin = ds.BeginDate;
3550 DateTime dtEnd = ds.EndDate;
3551
3552 DPatientLetter dpl = new DPatientLetter();
3553 dpl.InitializeFormPatientReminderLetters(this.DocManager, sClinics, dtBegin, dtEnd);
3554 dpl.ShowDialog(this);
3555
3556 }
3557 catch(Exception ex)
3558 {
3559 MessageBox.Show(this, ex.Message, "Clinical Scheduling", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
3560 }
3561
3562 }
3563
3564 private void mnuPrintRebookLetters_Click(object sender, System.EventArgs e)
3565 {
3566 try
3567 {
3568 DSelectLetterClinics ds = new DSelectLetterClinics();
3569 ds.InitializePage(this.m_DocManager.GlobalDataSet, "Print Clinic Rebook Letters");
3570 if (ds.ShowDialog(this) != DialogResult.OK)
3571 return;
3572
3573 //Call the letter printer
3574 DPatientLetter dpl = new DPatientLetter();
3575 dpl.InitializeFormRebookLetters(this.DocManager, ds.SelectedClinics, ds.BeginDate, ds.EndDate);
3576 dpl.ShowDialog(this);
3577
3578 }
3579 catch(Exception ex)
3580 {
3581 MessageBox.Show(this, ex.Message, "Clinical Scheduling", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
3582 }
3583 }
3584
3585 private void mnuPrintPatientLetter_Click(object sender, System.EventArgs e)
3586 {
3587 ViewPatientAppointments();
3588 }
3589
3590 private void mnuRPMSDivision_Click(object sender, System.EventArgs e)
3591 {
3592 this.DocManager.ChangeDivision(this);
3593 }
3594
3595 private void CGView_CursorChanged(object sender, System.EventArgs e)
3596 {
3597
3598 }
3599
3600 private void mnuDisplayWalkIns_Click(object sender, System.EventArgs e)
3601 {
3602 calendarGrid1.DrawWalkIns = !(calendarGrid1.DrawWalkIns);
3603 mnuDisplayWalkIns.Checked = calendarGrid1.DrawWalkIns;
3604 calendarGrid1.SetOverlapTable();
3605 calendarGrid1.Refresh();
3606 }
3607
3608 private void mnuOpenMultipleSchedules_Click(object sender, System.EventArgs e)
3609 {
3610
3611 try
3612 {
3613 DSelectSchedules ds = new DSelectSchedules();
3614 ds.InitializePage(this.m_DocManager.GlobalDataSet, "Open Multiple Schedules");
3615 if (ds.ShowDialog(this) != DialogResult.OK)
3616 return;
3617
3618 //get the resource names and open schedules
3619
3620 ArrayList sResources = ds.SelectedClinics;
3621 if (ds.SingleWindow == true)
3622 {
3623 m_sDocName = (ds.GroupWindowName == "")?"Multiple Selected Schedules":ds.GroupWindowName;
3624 OpenSelectedSchedule( sResources, DateTime.Today);
3625 }
3626 else
3627 {
3628 foreach (string sResource in sResources)
3629 {
3630 ArrayList alSingle = new ArrayList(1);
3631 alSingle.Add(sResource);
3632 m_sDocName = sResource;
3633 OpenSelectedSchedule( alSingle, DateTime.Today);
3634 }
3635 }
3636 return;
3637
3638 }
3639 catch(Exception ex)
3640 {
3641 MessageBox.Show(this, ex.Message, "Clinical Scheduling", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
3642 }
3643
3644 }
3645
3646 private void ctxCalGridWalkin_Click(object sender, System.EventArgs e)
3647 {
3648 AppointmentAddWalkin();
3649 }
3650
3651 private void mnuWalkIn_Click(object sender, System.EventArgs e)
3652 {
3653 AppointmentAddWalkin();
3654 }
3655
3656 private void mnuPrintCancellationLetters_Click(object sender, System.EventArgs e)
3657 {
3658 try
3659 {
3660 DSelectLetterClinics ds = new DSelectLetterClinics();
3661 ds.InitializePage(this.m_DocManager.GlobalDataSet, "Print Clinic Cancellation Letters");
3662 if (ds.ShowDialog(this) != DialogResult.OK)
3663 return;
3664
3665 //get the resource names and call the letter printer
3666
3667 string sClinics = ds.SelectedClinics;
3668 DateTime dtBegin = ds.BeginDate;
3669 DateTime dtEnd = ds.EndDate;
3670
3671 DPatientLetter dpl = new DPatientLetter();
3672
3673 dpl.InitializeFormCancellationLetters(this.DocManager, sClinics, dtBegin, dtEnd);
3674 dpl.ShowDialog(this);
3675 }
3676 catch(Exception ex)
3677 {
3678 MessageBox.Show(this, ex.Message, "Clinical Scheduling", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
3679 }
3680 }
3681
3682 private void PrintRoutingSlip(CGAppointment appt)
3683 {
3684 //get this appointment's order
3685 //Today's appointments
3686 var todaysAppts = (from lkappts in this.Document.Appointments.AppointmentTable.Values.Cast<CGAppointment>()
3687 where lkappts.StartTime > appt.StartTime.Date && lkappts.StartTime < appt.StartTime.AddDays(1).Date && lkappts.Resource == appt.Resource
3688 orderby lkappts.StartTime
3689 select lkappts).ToList();
3690
3691 //Find the order of the appointment
3692 int apptOrder = todaysAppts.FindIndex(eachappt => eachappt.StartTime == appt.StartTime && eachappt.PatientID == appt.PatientID);
3693
3694 //Index is zero based, so add 1
3695 apptOrder++;
3696
3697 //Send that to the routing slip as a parameter
3698 PrintDocument pd = new PrintDocument() { DocumentName = "Routing Slip for Appt " + appt.AppointmentKey };
3699 pd.PrintPage += (object s, System.Drawing.Printing.PrintPageEventArgs e) => CGDocumentManager.Current.PrintingObject.PrintRoutingSlip(appt, apptOrder, e);
3700 pd.Print();
3701 }
3702
3703 private void PrintAppointmentSlip(CGAppointment appt)
3704 {
3705 PrintDocument pd = new PrintDocument() { DocumentName = "Appointment Slip for Appt " + appt.AppointmentKey }; //Autoinit for DocName
3706 pd.PrintPage += (object s, System.Drawing.Printing.PrintPageEventArgs e) => CGDocumentManager.Current.PrintingObject.PrintAppointmentSlip(appt, e);
3707 pd.Print();
3708 }
3709
3710
3711 /// <summary>
3712 /// Update Selection of date if user does not pick a date/time
3713 /// </summary>
3714 /// <param name="sender"></param>
3715 /// <param name="e"></param>
3716 private void dateTimePicker1_Leave(object sender, EventArgs e)
3717 {
3718 if (this.Document.SelectedDate != dateTimePicker1.Value.Date)
3719 RequestRefreshGrid();
3720 }
3721
3722 /// <summary>
3723 /// Handle Selection of Date via mouse from datetimepicker dropdown
3724 /// </summary>
3725 /// <param name="sender"></param>
3726 /// <param name="e"></param>
3727 private void dateTimePicker1_CloseUp(object sender, EventArgs e)
3728 {
3729 if (this.Document.SelectedDate != dateTimePicker1.Value.Date)
3730 RequestRefreshGrid();
3731 }
3732
3733 /// <summary>
3734 /// Handle Enter and Escape key on dateTimePicker
3735 /// </summary>
3736 /// <param name="sender"></param>
3737 /// <param name="e"></param>
3738 private void dateTimePicker1_KeyPress(object sender, KeyPressEventArgs e)
3739 {
3740 //if enter key is pressed:
3741 // Tell windows that we are handling this
3742 // Request a Refresh Grid if the date is different
3743 // Set-Focus to Calendar Grid
3744 if (e.KeyChar == (char)Keys.Enter)
3745 {
3746 e.Handled = true;
3747
3748 if (this.Document.SelectedDate != dateTimePicker1.Value.Date)
3749 RequestRefreshGrid();
3750
3751 this.CGrid.Focus();
3752 }
3753
3754 //if escape key is pressed:
3755 // Tell windows that we are handling this
3756 // Set-Focus to Calendar Grid
3757 if (e.KeyChar == (char)Keys.Escape)
3758 {
3759 e.Handled = true;
3760 this.CGrid.Focus();
3761 }
3762 }
3763
3764 private void mnuRefresh_Click(object sender, EventArgs e)
3765 {
3766 ForceRefreshGrid();
3767 }
3768
3769 #endregion events
3770
3771 /// <summary>
3772 /// Refresh grid if needed.
3773 /// </summary>
3774 void RequestRefreshGrid()
3775 {
3776 DateTime dDate = dateTimePicker1.Value.Date;
3777 // Change Date on Document
3778 this.Document.SelectedDate = dDate;
3779
3780 // Do we need to update?
3781 bool isRefreshNeeded = this.Document.IsRefreshNeeded();
3782
3783 //Splash when loading and change Cursor
3784 if (isRefreshNeeded)
3785 {
3786 this.Cursor = Cursors.WaitCursor;
3787 LoadSplash();
3788 this.Document.RefreshDocument();
3789 StopSplash();
3790 this.Cursor = Cursors.Default;
3791 }
3792
3793
3794 if (this.Document.Resources.Count == 1)
3795 {
3796 if (this.calendarGrid1.Columns > 1)
3797 {
3798 this.StartDate = this.Document.StartDate;
3799 }
3800 else
3801 {
3802 this.StartDate = this.Document.SelectedDate;
3803 }
3804 }
3805 else
3806 {
3807 this.StartDate = this.Document.SelectedDate;
3808 }
3809
3810 //Is this needed? -- Yes it is. There is a bug in the drawing code for the calendar
3811 //First time it draws, it draws appointments, but not availability slots
3812 //Second time it draws, it both appointments and availabilites
3813 //XXX: Need to investigate
3814 this.Document.UpdateAllViews();
3815 }
3816
3817 /// <summary>
3818 /// This forces a grid refresh.
3819 /// </summary>
3820 void ForceRefreshGrid()
3821 {
3822 if (this.Document.m_sResourcesArray.Count == 0) return;
3823 this.Cursor = Cursors.WaitCursor;
3824 LoadSplash();
3825 this.Document.RefreshSchedule();
3826 this.UpdateArrays();
3827 StopSplash();
3828 this.Cursor = Cursors.Default;
3829 }
3830
3831 //private delegate DialogResult dLoadingSplash(IWin32Window owner);
3832 string _tempStatusBartext;
3833
3834 /// <summary>
3835 /// Loads a splash that says "Loading" -- removed it april 13 2010
3836 /// </summary>
3837 private void LoadSplash()
3838 {
3839 _tempStatusBartext = this.statusBar1.Text;
3840 this.statusBar1.Text = "Refreshing Schedule...";
3841 //_loadingSplash = new LoadingSplash();
3842 //_loadingSplash.StartPosition = FormStartPosition.CenterScreen; //XXX: Don't like this, but will do for now.
3843 //_loadingSplash.UseWaitCursor = true; // tell user we are working
3844 //_loadingSplash.Show(this);
3845 //Thread threadSplash = new Thread(tstart);
3846 //threadSplash.IsBackground = true;
3847 //threadSplash.Name = "Loading Thread";
3848 //threadSplash.Start(this);
3849
3850 //Thread threadSplash = new Thread(new ThreadStart(() => _loadingSplash.ShowDialog())); // lambda
3851 //threadSplash.IsBackground = true; //expendable thread -- exit even if still running.
3852 //threadSplash.Name = "Loading Thread";
3853 //threadSplash.Start();
3854 }
3855
3856 private void StopSplash()
3857 {
3858 this.statusBar1.Text = _tempStatusBartext;
3859 }
3860
3861
3862 private void PrintClinicSchedule(DateTime dStart, DateTime dEnd)
3863 {
3864 DPatientLetter dpl = new DPatientLetter();
3865
3866 int[] resourceIENs = (from resource in CGDocumentManager.Current.GlobalDataSet.Tables["Resources"].AsEnumerable()
3867 join resource_name in m_alSelectedTreeResourceArray.Cast<string>() on resource.Field<string>("RESOURCE_NAME") equals resource_name
3868 select resource.Field<int>("RESOURCEID")
3869 ).ToArray<int>();
3870
3871 // + | is an oddity in the Mumps code which I haven't investigated yet.
3872 dpl.InitializeFormClinicSchedule(this.DocManager, string.Join("|", resourceIENs) + "|", dStart, dEnd);
3873 dpl.ShowDialog(this);
3874 }
3875
3876 private void mnuViewBrokerLog_Click(object sender, EventArgs e)
3877 {
3878 var view = new RPCLoggerView();
3879 view.Show();
3880 }
3881
3882
3883 }//End class
3884}
Note: See TracBrowser for help on using the repository browser.