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

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

CalendarGrid: Many changes:

  1. Dragover handler to handle auto scrolling when dragging. Also highlights destination cell in dragging.
  2. Solution for the click-right click problem by better handling of right click issues.
  3. New method OnRButtonDown()
  4. Extra comments everywhere.
  5. Fix for single column being enabled when there are multiple resources. Columns property now calls this.SetColumnInfo() to rectify that problem.

CGDocument:

  1. EditAppoitment Used to send request a refresh from the DB and update the view itself, rather than letting the view handle that. That's now changed.

CGDocumentManager:

  1. MessageBox displayed during login splash now are shown BY the splash form.

CGView:

  1. Shortcuts and some display text updated.
  2. Splash screen when updating now removed.
  3. If print appointment slip checkbox is checked when EditAppointment is chosen, now it will print the routing slip.
  4. Tiny change in appointment structure generated during drag and drop (added Patient member, as it was causing a crash)

DApptSearch:

  1. Change of name of Appointment to Slot, for better user understanding.

DSplash:

  1. RemoteMessage box methods and associated delegates for mickey mousing the form from another thread.

Updated release exes and dlls

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