source: Scheduling/branches/Radiology-Support/cs/bsdx0200GUISourceCode/CGView.cs@ 1168

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

Lots of Documentation updates.
Absorption of all updates from trunk.
CGView: Changes in Appointment Menu; Handlers for these; Radiology Support
DRadExamSelect: Change in form design; auto print appointment slip implemented.

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