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

Last change on this file since 1408 was 1233, checked in by Tariq Hamkari, 13 years ago

fixing bug "crash when user name has a single quote"

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