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

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

DPatientLookup.cs: Usings Cleanup
DApptSearch: Extensive refactoring. Now uses new algorithm to find appointments. Now outputs CGAvailability
CGView: Appointments checked in now set the Checkin time on the appointment structure; changes to support DApptSearch modified output.
CGSchedLib: Extensive refactoring; only 2 methods remain: CreateAppointmentSchedule and CreateAvailabilitySchedule
CGDocument: SlotsAvailable uses a new algorithm
CGAVView: Uses CalendarGrid.TimesOverlap instead of the removed one in CGSchedLib
CGAVDocument: Uses CalendarGrid.TimesOverlap instead of the removed one in CGSchedLib; CreateAssignedSlotSchedule reassigned to CreateAvailabilitySchedule

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