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

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

CGDocument: Minor Change: Add appointment ID to Appointment
CGDocumentManager: added parameter /culture to set Thread.CurrentThread.CurrentUICulture
CGView: Minor changes in CheckInAppointment: Printing of Routing Slip now always happens.

Routing slip now get parameter for patient order.

Patient: i18n of UserFriendlyAge
Printing: Extensive changes. Support for i18n; new routing slip and appt slip. i18n support only for appt slip.

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