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

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

DRadExamsSelect: New form to let user select exam.
RadiologyExam: Class for a Radiology Exam
DAL: new DB communication methods: GetRadiologyExamsForPatientinHL and ScheduleRadiologyExam
CGView:

  1. New context menus for Radiology; context menu popup has logic for which menus to display;
  2. Helper method IsThisARadiologyResource used by ctxCalendarGrid_Popup to decide which menus to display
  3. Handler ctxCalGridMkRadAppt_Click to make the Radiology Appointment.

CGDocument:

  1. CreateAppointment now saves RadiologyExamIEN to the DB
  2. RefreshAppointments now gets RadiologyExamIEN from the DB

CGAppointment:

  1. Class completely refactored to use auto props rather than old style properties
  2. Added property RadiologyExamIEN

CalendarGrid: Class was wrongly using supposed private members of CGAppointment. Refactored to fix that as private members don't exist anymore.

Last but not least, new exe,dll

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