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

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

CGDocument:

CGDocumentManager:

CGView: (Changes to support printing of Appointment Slip)

  • Changed name and text of context menu to say "print appointment slip"
  • Logic to Print Appointment Slip

CustomPrinting.cs renamed to Printing.cs; old Printing.Cs removed.
DAppointPage:

  • New checkbox to request printing of Appointment Slip
  • Sex of patient now pulled and included in form.

DPatientLetter:

  • Redirected to use new Printing framework.

Patient:

Printing:

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