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

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

Updated Release exes.
CGDocument: Appointment Creation Code now reuses appt object passed in rather than creating a new one.
CGView:
ctxPrintScheduleT3 added. Print schedule in 3 days. For weekday after weekend.
Scaling of grid now restricted. You can't scale down from the original TimeScale, but you can scale up.
DCheckIn: Remove unused variables.
DResource: Remove unused variables.

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