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

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

grr...

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