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

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

CGDocumentManager: Localization now works from CurrentCulture, not just CurrentUICulture.
CGView: Nothing important. Designer moves around stuff; again.
Printing: Routing slip arabized; page starts at a lower level to allow for a watermark. Graphics.Dispose now called at the end of all prints to allow for faster gc.
strings: Updated with more translations.

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