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

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

New exe and dll
calendarGrid: Minor documentation updates.
CGAppointments: Object now supports Deep cloning
CGDocument:

  1. Major changes on how m_pAvArrays is handled. Now it is locked whenever it is updated or queried. Some refactoring to make sure there are no db calls during the locks so that the locks won't be expensive.
  2. Removed ClearResources, an unused method.
  3. Appointment aCopy walkin property is set to true if the appointment is a walkin. This makes sure that the grid draws it correctly between it is added to the appointment array and we fetch new data from the server.
  4. Create appointment is not responsible anymore for requesting updates from the server. All requests to update data must be done through CGView, as it is the only party interested in displaying accurate data on the grid. Just send the create appt event to the server.
  5. CheckInAppointment: Same thing. Now responsible for requesting updates from the server. Just send the checkin event to the server.

CGDocumentManager: Removed tracing. Done in BMX Library only now.
CGView:

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