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

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

CGDocument: On Delete Appointment, no update done by Document method. View responsible for this request.
CGView:

  1. Drag and Dropped code made to be the same as the rest. Call Document for updating appointments, but not redraw the grid. Drag Drop does not request a refresh directly; but rather, it shoots RPMS events which when they are raised back update the grid.
  2. Fixed bug in Drag and Drop where the source appointment resource is changed before passing it to Document.CreateAppointment() which saves it to the database. This causes the appointments maintained by Document to be temporarily corrupted if CreateAppointment fails during drag and drop.
  3. View calls refershdocumentasync now after Document.DeleteAppointment call.

Last but not least: new version of ClinicalScheduling.exe and BMXNet23.dll (release).

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