Ignore:
Timestamp:
Dec 24, 2015, 10:43:43 AM (8 years ago)
Author:
Faisal Sami
Message:

ClinicalScheduling version 2.0.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Scheduling/trunk/cs/bsdx0200GUISourceCode/CGView.cs

    r1512 r1728  
    1111using System.Drawing.Printing;
    1212using System.Linq;
     13using System.Text;
     14using System.Net.Mail;
     15using System.Configuration;
     16using System.Net;
     17using System.IO;
    1318
    1419namespace IndianHealthService.ClinicalScheduling
     
    9499                private System.Windows.Forms.MenuItem sepApptMenu2;
    95100                private System.Windows.Forms.MenuItem ctxCalGridWalkin;
    96                 private System.Windows.Forms.MenuItem ctxCalGridSep1;
    97101                private System.Windows.Forms.MenuItem ctxCalGridSep2;
    98102                private System.Windows.Forms.MenuItem mnuOpenMultipleSchedules;
     
    115119        private MenuItem mnuReprintApptSlip;
    116120        private MenuItem mnuViewBrokerLog;
     121        private MenuItem ctxCalGridSep1;
     122        private MenuItem ctxCalGridCloneForward;
     123        private MenuItem ctxCalGridExportInvite;
     124        private MenuItem ctxCopyAppointment;
    117125        private IContainer components;
    118126
     
    255263            this.lblResource = new System.Windows.Forms.Label();
    256264            this.panelCenter = new System.Windows.Forms.Panel();
     265            this.calendarGrid1 = new IndianHealthService.ClinicalScheduling.CalendarGrid();
    257266            this.ctxCalendarGrid = new System.Windows.Forms.ContextMenu();
    258267            this.ctxCalGridAdd = new System.Windows.Forms.MenuItem();
     
    261270            this.ctxCalGridDelete = new System.Windows.Forms.MenuItem();
    262271            this.ctxCalGridCancelRadAppt = new System.Windows.Forms.MenuItem();
     272            this.ctxCalGridCloneForward = new System.Windows.Forms.MenuItem();
     273            this.ctxCopyAppointment = new System.Windows.Forms.MenuItem();
    263274            this.ctxCalGridCheckIn = new System.Windows.Forms.MenuItem();
    264275            this.ctxCalGridUndoCheckin = new System.Windows.Forms.MenuItem();
    265             this.ctxCalGridSep1 = new System.Windows.Forms.MenuItem();
    266276            this.ctxCalGridNoShow = new System.Windows.Forms.MenuItem();
    267277            this.ctxCalGridNoShowUndo = new System.Windows.Forms.MenuItem();
     278            this.ctxCalGridSep1 = new System.Windows.Forms.MenuItem();
     279            this.ctxCalGridExportInvite = new System.Windows.Forms.MenuItem();
    268280            this.ctxCalGridSep2 = new System.Windows.Forms.MenuItem();
    269281            this.ctxCalGridWalkin = new System.Windows.Forms.MenuItem();
     
    274286            this.splitter1 = new System.Windows.Forms.Splitter();
    275287            this.splitter2 = new System.Windows.Forms.Splitter();
    276             this.calendarGrid1 = new IndianHealthService.ClinicalScheduling.CalendarGrid();
    277288            this.panelRight.SuspendLayout();
    278289            this.panelClip.SuspendLayout();
     
    716727            this.tvSchedules.Location = new System.Drawing.Point(0, 0);
    717728            this.tvSchedules.Name = "tvSchedules";
    718             this.tvSchedules.Size = new System.Drawing.Size(128, 347);
     729            this.tvSchedules.Size = new System.Drawing.Size(128, 305);
    719730            this.tvSchedules.Sorted = true;
    720731            this.tvSchedules.TabIndex = 1;
     
    785796            this.panelRight.Location = new System.Drawing.Point(996, 0);
    786797            this.panelRight.Name = "panelRight";
    787             this.panelRight.Size = new System.Drawing.Size(128, 347);
     798            this.panelRight.Size = new System.Drawing.Size(128, 305);
    788799            this.panelRight.TabIndex = 3;
    789800            this.panelRight.Visible = false;
     
    881892            this.panelCenter.Location = new System.Drawing.Point(136, 24);
    882893            this.panelCenter.Name = "panelCenter";
    883             this.panelCenter.Size = new System.Drawing.Size(857, 299);
     894            this.panelCenter.Size = new System.Drawing.Size(857, 257);
    884895            this.panelCenter.TabIndex = 7;
    885             //
    886             // ctxCalendarGrid
    887             //
    888             this.ctxCalendarGrid.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
    889             this.ctxCalGridAdd,
    890             this.ctxCalGridMkRadAppt,
    891             this.ctxCalGridEdit,
    892             this.ctxCalGridDelete,
    893             this.ctxCalGridCancelRadAppt,
    894             this.ctxCalGridCheckIn,
    895             this.ctxCalGridUndoCheckin,
    896             this.ctxCalGridSep1,
    897             this.ctxCalGridNoShow,
    898             this.ctxCalGridNoShowUndo,
    899             this.ctxCalGridSep2,
    900             this.ctxCalGridWalkin,
    901             this.ctxCalGridSep3,
    902             this.ctxCalGridReprintApptSlip});
    903             this.ctxCalendarGrid.Popup += new System.EventHandler(this.ctxCalendarGrid_Popup);
    904             //
    905             // ctxCalGridAdd
    906             //
    907             this.ctxCalGridAdd.Index = 0;
    908             this.ctxCalGridAdd.Text = "Add Appointment";
    909             this.ctxCalGridAdd.Click += new System.EventHandler(this.ctxCalGridAdd_Click);
    910             //
    911             // ctxCalGridMkRadAppt
    912             //
    913             this.ctxCalGridMkRadAppt.Index = 1;
    914             this.ctxCalGridMkRadAppt.Text = "Make Radiology Appointment";
    915             this.ctxCalGridMkRadAppt.Click += new System.EventHandler(this.ctxCalGridMkRadAppt_Click);
    916             //
    917             // ctxCalGridEdit
    918             //
    919             this.ctxCalGridEdit.Index = 2;
    920             this.ctxCalGridEdit.Text = "Edit Appointment";
    921             this.ctxCalGridEdit.Click += new System.EventHandler(this.ctxCalGridEdit_Click);
    922             //
    923             // ctxCalGridDelete
    924             //
    925             this.ctxCalGridDelete.Index = 3;
    926             this.ctxCalGridDelete.Text = "Cancel Appointment";
    927             this.ctxCalGridDelete.Click += new System.EventHandler(this.ctxCalGridDelete_Click);
    928             //
    929             // ctxCalGridCancelRadAppt
    930             //
    931             this.ctxCalGridCancelRadAppt.Index = 4;
    932             this.ctxCalGridCancelRadAppt.Text = "Cancel Radiology Appointment";
    933             this.ctxCalGridCancelRadAppt.Click += new System.EventHandler(this.ctxCalGridCancelRadAppt_Click);
    934             //
    935             // ctxCalGridCheckIn
    936             //
    937             this.ctxCalGridCheckIn.Index = 5;
    938             this.ctxCalGridCheckIn.Text = "Check In Patient";
    939             this.ctxCalGridCheckIn.Click += new System.EventHandler(this.ctxCalGridCheckIn_Click);
    940             //
    941             // ctxCalGridUndoCheckin
    942             //
    943             this.ctxCalGridUndoCheckin.Index = 6;
    944             this.ctxCalGridUndoCheckin.Text = "&Undo Check In";
    945             this.ctxCalGridUndoCheckin.Click += new System.EventHandler(this.ctxCalGridUndoCheckin_Click);
    946             //
    947             // ctxCalGridSep1
    948             //
    949             this.ctxCalGridSep1.Index = 7;
    950             this.ctxCalGridSep1.Text = "-";
    951             //
    952             // ctxCalGridNoShow
    953             //
    954             this.ctxCalGridNoShow.Index = 8;
    955             this.ctxCalGridNoShow.Text = "Mark as No Show";
    956             this.ctxCalGridNoShow.Click += new System.EventHandler(this.ctxCalGridNoShow_Click);
    957             //
    958             // ctxCalGridNoShowUndo
    959             //
    960             this.ctxCalGridNoShowUndo.Index = 9;
    961             this.ctxCalGridNoShowUndo.Text = "Undo NoShow";
    962             this.ctxCalGridNoShowUndo.Click += new System.EventHandler(this.ctxCalGridNoShowUndo_Click);
    963             //
    964             // ctxCalGridSep2
    965             //
    966             this.ctxCalGridSep2.Index = 10;
    967             this.ctxCalGridSep2.Text = "-";
    968             //
    969             // ctxCalGridWalkin
    970             //
    971             this.ctxCalGridWalkin.Index = 11;
    972             this.ctxCalGridWalkin.Text = "Create Wal&k-In Appointment";
    973             this.ctxCalGridWalkin.Click += new System.EventHandler(this.ctxCalGridWalkin_Click);
    974             //
    975             // ctxCalGridSep3
    976             //
    977             this.ctxCalGridSep3.Index = 12;
    978             this.ctxCalGridSep3.Text = "-";
    979             //
    980             // ctxCalGridReprintApptSlip
    981             //
    982             this.ctxCalGridReprintApptSlip.Index = 13;
    983             this.ctxCalGridReprintApptSlip.Text = "&Reprint Appointment Slip";
    984             this.ctxCalGridReprintApptSlip.Click += new System.EventHandler(this.ctxCalGridReprintApptSlip_Click);
    985             //
    986             // panelBottom
    987             //
    988             this.panelBottom.Controls.Add(this.statusBar1);
    989             this.panelBottom.Dock = System.Windows.Forms.DockStyle.Bottom;
    990             this.panelBottom.Location = new System.Drawing.Point(136, 323);
    991             this.panelBottom.Name = "panelBottom";
    992             this.panelBottom.Size = new System.Drawing.Size(857, 24);
    993             this.panelBottom.TabIndex = 8;
    994             //
    995             // statusBar1
    996             //
    997             this.statusBar1.Dock = System.Windows.Forms.DockStyle.Fill;
    998             this.statusBar1.Location = new System.Drawing.Point(0, 0);
    999             this.statusBar1.Name = "statusBar1";
    1000             this.statusBar1.Size = new System.Drawing.Size(857, 24);
    1001             this.statusBar1.SizingGrip = false;
    1002             this.statusBar1.TabIndex = 0;
    1003             //
    1004             // splitter1
    1005             //
    1006             this.splitter1.Location = new System.Drawing.Point(128, 24);
    1007             this.splitter1.Name = "splitter1";
    1008             this.splitter1.Size = new System.Drawing.Size(8, 323);
    1009             this.splitter1.TabIndex = 9;
    1010             this.splitter1.TabStop = false;
    1011             //
    1012             // splitter2
    1013             //
    1014             this.splitter2.Dock = System.Windows.Forms.DockStyle.Right;
    1015             this.splitter2.Location = new System.Drawing.Point(993, 24);
    1016             this.splitter2.Name = "splitter2";
    1017             this.splitter2.Size = new System.Drawing.Size(3, 323);
    1018             this.splitter2.TabIndex = 10;
    1019             this.splitter2.TabStop = false;
    1020896            //
    1021897            // calendarGrid1
     
    1038914            this.calendarGrid1.Resources = ((System.Collections.ArrayList)(resources.GetObject("calendarGrid1.Resources")));
    1039915            this.calendarGrid1.SelectedAppointment = 0;
    1040             this.calendarGrid1.Size = new System.Drawing.Size(857, 299);
     916            this.calendarGrid1.Size = new System.Drawing.Size(857, 257);
    1041917            this.calendarGrid1.StartDate = new System.DateTime(2003, 1, 27, 0, 0, 0, 0);
    1042918            this.calendarGrid1.TabIndex = 0;
     
    1048924            this.calendarGrid1.MouseEnter += new System.EventHandler(this.calendarGrid1_MouseEnter);
    1049925            //
     926            // ctxCalendarGrid
     927            //
     928            this.ctxCalendarGrid.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
     929            this.ctxCalGridAdd,
     930            this.ctxCalGridMkRadAppt,
     931            this.ctxCalGridEdit,
     932            this.ctxCalGridDelete,
     933            this.ctxCalGridCancelRadAppt,
     934            this.ctxCalGridCloneForward,
     935            this.ctxCopyAppointment,
     936            this.ctxCalGridCheckIn,
     937            this.ctxCalGridUndoCheckin,
     938            this.ctxCalGridNoShow,
     939            this.ctxCalGridNoShowUndo,
     940            this.ctxCalGridSep1,
     941            this.ctxCalGridExportInvite,
     942            this.ctxCalGridSep2,
     943            this.ctxCalGridWalkin,
     944            this.ctxCalGridSep3,
     945            this.ctxCalGridReprintApptSlip});
     946            this.ctxCalendarGrid.Popup += new System.EventHandler(this.ctxCalendarGrid_Popup);
     947            //
     948            // ctxCalGridAdd
     949            //
     950            this.ctxCalGridAdd.Index = 0;
     951            this.ctxCalGridAdd.Text = "Add Appointment";
     952            this.ctxCalGridAdd.Click += new System.EventHandler(this.ctxCalGridAdd_Click);
     953            //
     954            // ctxCalGridMkRadAppt
     955            //
     956            this.ctxCalGridMkRadAppt.Index = 1;
     957            this.ctxCalGridMkRadAppt.Text = "Make Radiology Appointment";
     958            this.ctxCalGridMkRadAppt.Click += new System.EventHandler(this.ctxCalGridMkRadAppt_Click);
     959            //
     960            // ctxCalGridEdit
     961            //
     962            this.ctxCalGridEdit.Index = 2;
     963            this.ctxCalGridEdit.Text = "Edit Appointment";
     964            this.ctxCalGridEdit.Click += new System.EventHandler(this.ctxCalGridEdit_Click);
     965            //
     966            // ctxCalGridDelete
     967            //
     968            this.ctxCalGridDelete.Index = 3;
     969            this.ctxCalGridDelete.Text = "Cancel Appointment";
     970            this.ctxCalGridDelete.Click += new System.EventHandler(this.ctxCalGridDelete_Click);
     971            //
     972            // ctxCalGridCancelRadAppt
     973            //
     974            this.ctxCalGridCancelRadAppt.Index = 4;
     975            this.ctxCalGridCancelRadAppt.Text = "Cancel Radiology Appointment";
     976            this.ctxCalGridCancelRadAppt.Click += new System.EventHandler(this.ctxCalGridCancelRadAppt_Click);
     977            //
     978            // ctxCalGridCloneForward
     979            //
     980            this.ctxCalGridCloneForward.Index = 5;
     981            this.ctxCalGridCloneForward.Text = "Copy/Forward Appointment";
     982            this.ctxCalGridCloneForward.Click += new System.EventHandler(this.ctxCalGridCloneForward_Click);
     983            //
     984            // ctxCopyAppointment
     985            //
     986            this.ctxCopyAppointment.Index = 6;
     987            this.ctxCopyAppointment.Text = "Copy to Clipboard";
     988            this.ctxCopyAppointment.Click += new System.EventHandler(this.ctxCopyAppointment_Click);
     989            //
     990            // ctxCalGridCheckIn
     991            //
     992            this.ctxCalGridCheckIn.Index = 7;
     993            this.ctxCalGridCheckIn.Text = "Check In Patient";
     994            this.ctxCalGridCheckIn.Click += new System.EventHandler(this.ctxCalGridCheckIn_Click);
     995            //
     996            // ctxCalGridUndoCheckin
     997            //
     998            this.ctxCalGridUndoCheckin.Index = 8;
     999            this.ctxCalGridUndoCheckin.Text = "&Undo Check In";
     1000            this.ctxCalGridUndoCheckin.Click += new System.EventHandler(this.ctxCalGridUndoCheckin_Click);
     1001            //
     1002            // ctxCalGridNoShow
     1003            //
     1004            this.ctxCalGridNoShow.Index = 9;
     1005            this.ctxCalGridNoShow.Text = "Mark as No Show";
     1006            this.ctxCalGridNoShow.Click += new System.EventHandler(this.ctxCalGridNoShow_Click);
     1007            //
     1008            // ctxCalGridNoShowUndo
     1009            //
     1010            this.ctxCalGridNoShowUndo.Index = 10;
     1011            this.ctxCalGridNoShowUndo.Text = "Undo NoShow";
     1012            this.ctxCalGridNoShowUndo.Click += new System.EventHandler(this.ctxCalGridNoShowUndo_Click);
     1013            //
     1014            // ctxCalGridSep1
     1015            //
     1016            this.ctxCalGridSep1.Index = 11;
     1017            this.ctxCalGridSep1.Text = "-";
     1018            //
     1019            // ctxCalGridExportInvite
     1020            //
     1021            this.ctxCalGridExportInvite.Index = 12;
     1022            this.ctxCalGridExportInvite.Text = "Export Canendar Invite";
     1023            this.ctxCalGridExportInvite.Click += new System.EventHandler(this.ctxExportInvite_Click);
     1024            //
     1025            // ctxCalGridSep2
     1026            //
     1027            this.ctxCalGridSep2.Index = 13;
     1028            this.ctxCalGridSep2.Text = "-";
     1029            //
     1030            // ctxCalGridWalkin
     1031            //
     1032            this.ctxCalGridWalkin.Index = 14;
     1033            this.ctxCalGridWalkin.Text = "Create Wal&k-In Appointment";
     1034            this.ctxCalGridWalkin.Click += new System.EventHandler(this.ctxCalGridWalkin_Click);
     1035            //
     1036            // ctxCalGridSep3
     1037            //
     1038            this.ctxCalGridSep3.Index = 15;
     1039            this.ctxCalGridSep3.Text = "-";
     1040            //
     1041            // ctxCalGridReprintApptSlip
     1042            //
     1043            this.ctxCalGridReprintApptSlip.Index = 16;
     1044            this.ctxCalGridReprintApptSlip.Text = "&Reprint Appointment Slip";
     1045            this.ctxCalGridReprintApptSlip.Click += new System.EventHandler(this.ctxCalGridReprintApptSlip_Click);
     1046            //
     1047            // panelBottom
     1048            //
     1049            this.panelBottom.Controls.Add(this.statusBar1);
     1050            this.panelBottom.Dock = System.Windows.Forms.DockStyle.Bottom;
     1051            this.panelBottom.Location = new System.Drawing.Point(136, 281);
     1052            this.panelBottom.Name = "panelBottom";
     1053            this.panelBottom.Size = new System.Drawing.Size(857, 24);
     1054            this.panelBottom.TabIndex = 8;
     1055            //
     1056            // statusBar1
     1057            //
     1058            this.statusBar1.Dock = System.Windows.Forms.DockStyle.Fill;
     1059            this.statusBar1.Location = new System.Drawing.Point(0, 0);
     1060            this.statusBar1.Name = "statusBar1";
     1061            this.statusBar1.Size = new System.Drawing.Size(857, 24);
     1062            this.statusBar1.SizingGrip = false;
     1063            this.statusBar1.TabIndex = 0;
     1064            //
     1065            // splitter1
     1066            //
     1067            this.splitter1.Location = new System.Drawing.Point(128, 24);
     1068            this.splitter1.Name = "splitter1";
     1069            this.splitter1.Size = new System.Drawing.Size(8, 281);
     1070            this.splitter1.TabIndex = 9;
     1071            this.splitter1.TabStop = false;
     1072            //
     1073            // splitter2
     1074            //
     1075            this.splitter2.Dock = System.Windows.Forms.DockStyle.Right;
     1076            this.splitter2.Location = new System.Drawing.Point(993, 24);
     1077            this.splitter2.Name = "splitter2";
     1078            this.splitter2.Size = new System.Drawing.Size(3, 281);
     1079            this.splitter2.TabIndex = 10;
     1080            this.splitter2.TabStop = false;
     1081            //
    10501082            // CGView
    10511083            //
    10521084            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
    1053             this.ClientSize = new System.Drawing.Size(1124, 347);
     1085            this.ClientSize = new System.Drawing.Size(1124, 305);
    10541086            this.Controls.Add(this.panelCenter);
    10551087            this.Controls.Add(this.panelBottom);
     
    12121244                    lstClip.Items.Add(a);
    12131245                                }
     1246                copyAppointmentToClipBoard();
    12141247                        }
    12151248                        catch (Exception ex)
     
    13981431                }
    13991432
    1400                 #endregion ctxApptClipMenu Handlers
    1401 
    1402                 #region ctxCalGridMenu Handlers
     1433        #endregion ctxApptClipMenu Handlers
     1434
     1435        #region ctxCalGridMenu Handlers
     1436
     1437        private Configuration GetConfiguration() {
     1438            Configuration conf = null;
     1439            var fileName = Path.Combine(Environment.GetFolderPath(
     1440    Environment.SpecialFolder.ApplicationData), "ClinicalScheduling.exe.config");
     1441            if (!File.Exists(fileName))
     1442            {
     1443                try
     1444                {
     1445                    Configuration temp = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
     1446                    File.Copy(temp.FilePath, fileName);
     1447                }
     1448                catch (Exception ex)
     1449                {
     1450                    MessageBox.Show(ex.Message);
     1451                    return conf;
     1452                }
     1453            }
     1454            if (!File.Exists(fileName))
     1455            {
     1456                MessageBox.Show("Unable to locate the app.config file.");
     1457                return conf;
     1458            }
     1459            ExeConfigurationFileMap mapping = new ExeConfigurationFileMap();
     1460            mapping.ExeConfigFilename = fileName;
     1461            conf = ConfigurationManager.OpenMappedExeConfiguration(mapping, ConfigurationUserLevel.None);
     1462            return conf;
     1463        }
    14031464
    14041465                private void ctxCalendarGrid_Popup(object sender, System.EventArgs e)
     
    14111472            bool _noShowEnabled = NoShowEnabled();
    14121473            bool _undoCheckinEnabled = UndoCheckinEnabled();
     1474            bool _cloneForwardEnabled = CloneForwardEnabled();
     1475            bool _exportCalendarInviteEnabled = ExportCalendarInviteEnabled();
     1476            bool _copyAppointmentEnabled = CopyAppointmentEnabled();
    14131477            //end flags
    14141478
     
    14231487                ctxCalGridWalkin.Visible = false;
    14241488                ctxCalGridUndoCheckin.Visible = false;
     1489                ctxCalGridSep2.Visible = false;
     1490                ctxCalGridCloneForward.Visible = false;
     1491                ctxCalGridExportInvite.Visible = false;
    14251492                ctxCalGridSep1.Visible = false;
    1426                 ctxCalGridSep2.Visible = false;
     1493                ctxCopyAppointment.Visible = false;
    14271494
    14281495                ctxCalGridMkRadAppt.Visible = true;
     
    14421509                ctxCalGridWalkin.Visible = true;
    14431510                ctxCalGridUndoCheckin.Visible = true;
     1511                ctxCalGridSep2.Visible = true;
     1512                ctxCalGridCloneForward.Visible = true;
     1513                ctxCalGridExportInvite.Visible = true;
    14441514                ctxCalGridSep1.Visible = true;
    1445                 ctxCalGridSep2.Visible = true;
     1515                ctxCopyAppointment.Visible = true;
    14461516
    14471517                ctxCalGridMkRadAppt.Visible = false;
     
    14651535            ctxCalGridMkRadAppt.Enabled = _isRadAppt && _addApptsEnabled;
    14661536            ctxCalGridCancelRadAppt.Enabled = _isRadAppt && _editApptsEnabled;
     1537
     1538            ctxCalGridCloneForward.Enabled = !_isRadAppt && _cloneForwardEnabled;
     1539            ctxCalGridExportInvite.Enabled = !_isRadAppt && _exportCalendarInviteEnabled;
     1540            ctxCopyAppointment.Enabled = !_isRadAppt && _copyAppointmentEnabled;
     1541            //Configuration conf = GetConfiguration();           
     1542            //MessageBox.Show(conf.ConnectionStrings["useEmail"]);
     1543            Configuration conf = GetConfiguration();
     1544            if (conf.AppSettings.Settings["useEmail"].Value == "true")
     1545            {
     1546                ctxCalGridExportInvite.Text = "Email Canlendar Invite";
     1547            }
    14671548        }
    14681549
     
    16771758            CGAppointment appt = (CGAppointment)this.Appointments.AppointmentTable[calendarGrid1.SelectedAppointment];
    16781759            return !appt.NoShow;
     1760        }
     1761
     1762        private bool CloneForwardEnabled() {
     1763            if (calendarGrid1.SelectedAppointment < 1)
     1764                return false;
     1765            return true;
     1766        }
     1767
     1768        private bool CopyAppointmentEnabled()
     1769        {
     1770            return EditAppointmentEnabled();
     1771        }
     1772
     1773        private bool ExportCalendarInviteEnabled()
     1774        {
     1775            if (calendarGrid1.SelectedAppointment < 1)
     1776                return false;
     1777            CGAppointment appt = (CGAppointment)this.Appointments.AppointmentTable[calendarGrid1.SelectedAppointment];
     1778            if (appt.StartTime < DateTime.Now)
     1779            {
     1780                return false;
     1781            }
     1782            if (appt.Patient.Email == null)
     1783            {
     1784                try
     1785                {
     1786                    string sSql;
     1787                    sSql = "BSDX GET BASIC REG INFO^" + appt.PatientID.ToString();
     1788
     1789                    DataTable tb = m_DocManager.RPMSDataTable(sSql, "PatientRegInfo");
     1790
     1791                    Debug.Assert(tb.Rows.Count == 1);
     1792                    DataRow r = tb.Rows[0];
     1793                    appt.Patient.Email = r["EMAIL ADDRESS"].ToString();
     1794                }
     1795                catch (Exception e)
     1796                {                   
     1797                    MessageBox.Show("DAppointPage::InitializePage -- Unable to retrieve patient information from VistA.  " + e.Message);
     1798                }
     1799                if (appt.Patient.Email == "")
     1800                {
     1801                    return false;
     1802                }
     1803            }
     1804            return true;
    16791805        }
    16801806
     
    20472173                                dAppt.DocManager = this.m_DocManager;
    20482174                                dAppt.InitializePage(a);
     2175                dAppt.HideCloneForwardTab();
    20492176
    20502177                                calendarGrid1.CGToolTip.Active = false;
     
    20782205                        }
    20792206                }
     2207
     2208        private void AppointmentCloneForward(ArrayList alResources)
     2209        {
     2210            try
     2211            {
     2212                int nApptID = this.calendarGrid1.SelectedAppointment;
     2213                Debug.Assert(nApptID != 0);
     2214
     2215                CGAppointment a = (CGAppointment)this.Appointments.AppointmentTable[nApptID];
     2216
     2217                DAppointPage dAppt = new DAppointPage();
     2218                dAppt.DocManager = this.m_DocManager;
     2219                dAppt.InitializePage(a);
     2220
     2221                calendarGrid1.CGToolTip.Active = false;
     2222
     2223                dAppt.SetCloneForwardable(alResources, a);
     2224               
     2225
     2226                if (dAppt.ShowDialog(this) == DialogResult.Cancel)
     2227                {
     2228                    calendarGrid1.CGToolTip.Active = true;
     2229                    return;
     2230                }
     2231                calendarGrid1.CGToolTip.Active = true;
     2232
     2233                string sNote = dAppt.Note;
     2234
     2235                CGAppointment appt = dAppt.Appointment;
     2236
     2237                //Call Document to add a new appointment. Document adds appointment to CGAppointments array.
     2238                this.Document.CreateAppointment(appt);
     2239
     2240
     2241                if (dAppt.PrintAppointmentSlip)
     2242                {
     2243                    PrintAppointmentSlip(appt);
     2244                }
     2245
     2246                //Show the new set of appointments by calling UpdateArrays. Fetches Document's CGAppointments
     2247                this.UpdateArrays();
     2248
     2249                RaiseRPMSEvent("BSDX SCHEDULE", appt.Resource);
     2250            }
     2251            catch (Exception ex)
     2252            {
     2253                string msg;
     2254                if (M.Piece(ex.Message, "~", 1) == "-10") // -10 means that BSDXAPI reported an error.
     2255                    msg = M.Piece(ex.Message, "~", 4);
     2256                else
     2257                    msg = ex.Message;
     2258
     2259                MessageBox.Show("VISTA says: \r\n" + msg, "Unable to Make Appointment");
     2260                return;
     2261            }
     2262        }
    20802263
    20812264                /// <summary>
     
    25902773                m_nSlots = m_Document.SlotsAvailable(dStart, dEnd, sResource, this.calendarGrid1.TimeScale, out resultantAvail);
    25912774
    2592                                 if (m_nSlots < 1)
     2775                                /* Faisal Don't show overbood popup
     2776                if (m_nSlots < 1)
    25932777                                {
    25942778                                        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);
     
    25972781                                                return;
    25982782                                        }
    2599                                 }
     2783                                }*/
    26002784
    26012785                                //Display a dialog to collect Patient Name
     
    26172801                                string sNote = "";
    26182802                dAppt.InitializePage(dPat.PatientIEN, dStart, dEnd, sResource, sNote, nAccessTypeID);
     2803                dAppt.HideCloneForwardTab();
    26192804
    26202805                                if (dAppt.ShowDialog(this) == DialogResult.Cancel)
     
    32153400                                CGDocumentManager.Current.RemoteSession.EventServices.RpmsEvent -= BMXNetEventHandler;
    32163401                                this.calendarGrid1.CloseGrid();
    3217                         }
     3402                if (this.DocManager.m_SsshProcess != null)
     3403                {
     3404                    if (!this.DocManager.m_SsshProcess.HasExited)
     3405                    {
     3406                        this.DocManager.m_SsshProcess.Kill();
     3407                    }                   
     3408                }
     3409            }
    32183410                        catch (Exception ex)
    32193411                        {
     
    39664158        }
    39674159
    3968 
     4160        private void ctxCalGridCloneForward_Click(object sender, EventArgs e)
     4161        {
     4162            AppointmentCloneForward(m_alSelectedTreeResourceArray);
     4163        }
     4164
     4165        private void menuItem8_Click(object sender, EventArgs e)
     4166        {
     4167
     4168        }
     4169
     4170        private StringBuilder GetCalendarInvite(CGAppointment appt, String emailSubject, String emailBody)
     4171        {
     4172            StringBuilder sb = new StringBuilder();
     4173            Configuration conf = GetConfiguration();
     4174            sb.AppendLine("BEGIN:VCALENDAR");
     4175            sb.AppendLine(string.Format("PRODID:-//{0}//BSDX Scheduling 1.7//EN", conf.AppSettings.Settings["organization"].Value));
     4176            sb.AppendLine("VERSION:2.0");
     4177            sb.AppendLine("CALSCALE:GREGORIAN");
     4178            sb.AppendLine("METHOD:REQUEST");
     4179            sb.AppendLine("X-WR-CALDESC:");
     4180            sb.AppendLine("BEGIN:VEVENT");
     4181            sb.AppendLine(string.Format("DTSTART;VALUE=DATE-TIME:{0:yyyyMMddTHHmmssZ}", appt.StartTime.ToUniversalTime().ToString("yyyyMMdd\\THHmmss\\Z")));
     4182            sb.AppendLine(string.Format("DTEND;VALUE=DATE-TIME:{0:yyyyMMddTHHmmssZ}", appt.EndTime.ToUniversalTime().ToString("yyyyMMdd\\THHmmss\\Z")));
     4183            sb.AppendLine(string.Format("DTSTAMP:{0:yyyyMMddTHHmmssZ}", DateTime.Now.ToUniversalTime().ToString("yyyyMMdd\\THHmmss\\Z")));
     4184            sb.AppendLine(string.Format("UID:{0}", Guid.NewGuid()));
     4185            sb.AppendLine(string.Format("DESCRIPTION:{0}", emailBody));
     4186            sb.AppendLine(string.Format("X-ALT-DESC;FMTTYPE=text/html:{0}", emailBody));
     4187            sb.AppendLine(string.Format("SUMMARY:{0}", emailSubject));
     4188            sb.AppendLine(string.Format("ORGANIZER:MAILTO:{0}", conf.AppSettings.Settings["userEmail"].Value)); //
     4189            sb.AppendLine(string.Format("ATTENDEE;CN=\"{0}\";RSVP=TRUE:mailto:{1}", appt.Patient.Name, appt.Patient.Email));
     4190            sb.AppendLine("LOCATION:" + appt.Resource + ", " + conf.AppSettings.Settings["address"].Value); //appt.Resource);
     4191            sb.AppendLine("SEQUENCE:0");
     4192            sb.AppendLine("STATUS:CONFIRMED");
     4193            sb.AppendLine("TRANSP:TRANSPARENT");
     4194            sb.AppendLine("END:VEVENT");
     4195            sb.AppendLine("END:VCALENDAR");
     4196            return sb;
     4197        }
     4198
     4199        private void ExportCalendarInvite(CGAppointment appt, string emailSubject, string emailBody)
     4200        {
     4201            SaveFileDialog saveFileDialog1 = new SaveFileDialog();
     4202            saveFileDialog1.Filter = "iCalendar File|*.ics";
     4203            saveFileDialog1.Title = "Save Calendar Invite";
     4204            saveFileDialog1.ShowDialog();
     4205            if (saveFileDialog1.FileName != "")
     4206            {
     4207                StringBuilder str = GetCalendarInvite(appt, emailSubject, emailBody);
     4208                FileStream fs = new FileStream(saveFileDialog1.FileName, FileMode.Create);
     4209                StreamWriter sw = new StreamWriter(fs);
     4210                sw.Write(str.ToString());
     4211                sw.Close();
     4212                fs.Close();
     4213            }
     4214        }
     4215
     4216        private void EmailCalendarInvite(CGAppointment appt, String emailSubject, String emailBody)
     4217        {
     4218            Configuration conf = GetConfiguration();
     4219            SmtpClient sc = new SmtpClient(conf.AppSettings.Settings["smtpHost"].Value);
     4220
     4221            System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
     4222
     4223            msg.From = new MailAddress(conf.AppSettings.Settings["userEmail"].Value);
     4224            msg.To.Add(new MailAddress(appt.Patient.Email, appt.Patient.Name));
     4225            msg.Bcc.Add(new MailAddress(conf.AppSettings.Settings["userEmail"].Value));
     4226            msg.Subject = emailSubject;
     4227            msg.IsBodyHtml = true;
     4228            msg.Body = emailBody;
     4229            StringBuilder str = GetCalendarInvite(appt, emailSubject, emailBody);
     4230            System.Net.Mime.ContentType ct = new System.Net.Mime.ContentType("text/calendar");
     4231            ct.Parameters.Add("method", "REQUEST");
     4232            //ct.Parameters.Add("name", "meeting.ics");
     4233            AlternateView avCal = AlternateView.CreateAlternateViewFromString(str.ToString(), ct);
     4234            msg.AlternateViews.Add(avCal);
     4235            NetworkCredential nc = new NetworkCredential(conf.AppSettings.Settings["userEmail"].Value, conf.AppSettings.Settings["userPassword"].Value);
     4236            sc.Port = Convert.ToInt32(conf.AppSettings.Settings["smtpPort"].Value);
     4237            sc.EnableSsl = Convert.ToBoolean(conf.AppSettings.Settings["enableSSL"].Value);
     4238            sc.Credentials = nc;
     4239            try
     4240            {
     4241                sc.Send(msg);
     4242            }
     4243            catch (Exception e)
     4244            {
     4245                MessageBox.Show("Unable to send email.  " + e.Message);
     4246            }
     4247        }
     4248
     4249        private void copyAppointmentToClipBoard() {           
     4250            int apptID = this.CGrid.SelectedAppointment;
     4251            Configuration conf = GetConfiguration();
     4252            if (apptID <= 0) return;
     4253            CGAppointment a = (CGAppointment)this.Appointments.AppointmentTable[apptID];
     4254
     4255            string str = "Clinic Title: " + a.Resource + "\n" +
     4256                            "Date/Time: " + a.StartTime.ToString() + "\n" +
     4257                            "Location: " + conf.AppSettings.Settings["address"].Value + "\n" +
     4258                            "Phone: " + conf.AppSettings.Settings["phone"].Value;
     4259            Clipboard.SetText(str);
     4260        }
     4261
     4262        private void ctxExportInvite_Click(object sender, EventArgs e)
     4263        {
     4264            Configuration conf = GetConfiguration();
     4265            String emailBody = "Your Appointment is Scheduled.";
     4266            String emailSubject = conf.AppSettings.Settings["inviteSubject"].Value;
     4267            int apptID = this.CGrid.SelectedAppointment;
     4268            if (apptID <= 0) return;
     4269
     4270            CGAppointment a = (CGAppointment)this.Appointments.AppointmentTable[apptID];
     4271
     4272            if (conf.AppSettings.Settings["useEmail"].Value == "true")
     4273            {
     4274                EmailCalendarInvite(a, emailSubject, emailBody);
     4275            }
     4276            else
     4277            {
     4278                ExportCalendarInvite(a, emailSubject, emailBody);
     4279            }
     4280        }
     4281
     4282        private void ctxCopyAppointment_Click(object sender, EventArgs e)
     4283        {
     4284            copyAppointmentToClipBoard();
     4285        }
    39694286    }//End class
    39704287}
Note: See TracChangeset for help on using the changeset viewer.