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

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

lstClip_DragDrop is modified to create a copy of the appointment to put in the clipboard rather than having the original appointment reference there. What happened was that when the appointment was dropped into the grid, it changed the original appointment object (it's the same CLR object!), when the original appointment object should not have been modified in the first place. I.e., we really just wanted a copy of the original appointment all along in the clipboard, not the original appointment itself.
Fixes bug EHS#0000255.

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