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

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

CalendarGrid:

  • Support for Autoscrolling corrected.
  • A little optimization: Grid is only drawn once now when starting, not twice (don't know why original code did that).

CGAppointment:

  • Added member Patient (new Class)

CGDocument:

  • OnOpenDocument now accepts input of DateTime to decide where to open document.
  • SlotsAvailable algorithm now includes code for scaling according to timescale and code to merge Blocks if they are adjacent.

CGDocumentManager:

  • Fix bug having to do with canceling log-in after first retry. BMX lib threw an exception which was not caught.

CGView: Many changes:

  • SlotsAvailable signature changed in CGDocument. All references to it had to be changed.
  • Opening a node in the tvSchedules by clicking on the plus sign did not select it. Code changes to make it select it.
  • UpdateStatusBar now uses a string builder; and shows a more comprehensive message on the availability in the Status Bar.
  • Focus issues on various controls.
  • Support for printing a slip after an appointment is made automatically has been added.

CustomPrinting:

  • now includes a method to print a single appointment slip

DAppointPage:

  • Checkbox to decide whether to print appt slip added.
  • New readonly property to get the appointment that has been made (of type CGAppointment).

DApptSearch:

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