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

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

V 1.6 Beta Release

AssemblyInfo.cs: version bumped up to 1.6
CGView:

  1. Changed Popup calendar menu enable/disable code for specific menu items (simplification)
  2. Bug fixed in AddAppointmentEnabled(): Checks to see if there are any slots using the new algorithm introduced in v 1.5
  3. Resequence order of Saving/Canceling Radiology Package Call with Saving/Cancelling Appointment. Saving Cancelling appointment comes first because it may fail and thus cancel the whole transaction.
  4. BMX Events will now be raised after making/cancelling a radiology appointment.
  5. Better exception handling for making Radiology Appointments in AppointmentAddNewRadiology().

strings.ar.resx:
Fixed a mispelling.

Printing:
Improved the display of dates for Appointment Slips.

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