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

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

CGView: Appointment Object now has Patient subobject created for routing slip information.
DPatientLookup: Now returns DOB as well.
Routing Slip doesn't print Sex anymore.
Updated Release Exes.

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