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

Last change on this file since 1438 was 1194, checked in by Sam Habiel, 14 years ago

All changes to support BMX4. Now works with BMX 4.
AssemblyInfo: Bumped to 1.6 (will be 1.7 pending server changes).
Removed BMXNet23.dll and added BMXNET40.dll and BMXWIN40.dll.
Actual changes to support BMX 4 in the code:
All references to DocManager.ConnectInfo.bmxNetLib substituted with CGDocumentManager.Current.RemoteSession everywhere.
All Events use RemoteSession.EventServices APIs.
All references to DUZ use RemoteSession.User APIs.
All references to BMXNetLib.Piece changed to M.Piece.
Added RPC Logging Capability courtesy of BMX4.
Extensive changes in the Main[] class CGDocumentManager:

  • Added references to IndianHealthService.BMXNet.WinForm
  • Removed references to BMXNetLib and changed to RemoteSession
  • Singleton Instance constructor now private (overdue change).
  • Use new Event Framework part of Remote Session.
  • Login code totally rewritten to use BMXWIN40.dll.
  • RPMSDataTable references changed to TableFromCommand or TableFromSQL.

DAL:

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