source: Scheduling/branches/Radiology-Support/cs/bsdx0200GUISourceCode/CGView.cs@ 1166

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

Various Radiology-related Modifications:
DAL: ScheduleRadiologyExam and CancelRadiologyExam methods to DB
CGSchedLib: Organize usings
CGView:

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