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

Last change on this file since 1768 was 1731, checked in by Faisal Sami, 9 years ago

BSDX Scheduling changes for version 2.0.1.

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