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

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

CGView:

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