Ignore:
Timestamp:
Nov 18, 2010, 7:47:04 AM (14 years ago)
Author:
Sam Habiel
Message:

UCPatientAppts: Fixes printing empty table bug reported by EHS.
DAccessTemplate: Various usability improvements.
CGDocumentManager: Fixed Delegate code so that it can operate asynchronously
CGAVView: Some temporary fixes (not totally usable): Added non-functional Delete Slots menu option; Added Background worker for saving acccess slots
In the future, Delete Slots will work; and will use ADO.net Updatable datatable for saving access slots.
calendarGrid: just some comments for now
AssemblyInfo: bumped version up to v1.4.2

File:
1 edited

Legend:

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

    r917 r1011  
    6868            this.mnuLoadTemplate = new System.Windows.Forms.MenuItem();
    6969            this.mnuSaveTemplate = new System.Windows.Forms.MenuItem();
     70            this.mnuDeleteAllAppointments = new System.Windows.Forms.MenuItem();
    7071            this.menuItem6 = new System.Windows.Forms.MenuItem();
    7172            this.mnuSchedulingManagment = new System.Windows.Forms.MenuItem();
     
    9091            this.mnuHelpAbout = new System.Windows.Forms.MenuItem();
    9192            this.splitter1 = new System.Windows.Forms.Splitter();
     93            this.saveAccessBlocksWorker = new System.ComponentModel.BackgroundWorker();
    9294            this.calendarGrid1 = new IndianHealthService.ClinicalScheduling.CalendarGrid();
    9395            this.panelRight.SuspendLayout();
     
    104106            this.panelRight.Location = new System.Drawing.Point(728, 0);
    105107            this.panelRight.Name = "panelRight";
    106             this.panelRight.Size = new System.Drawing.Size(120, 412);
     108            this.panelRight.Size = new System.Drawing.Size(120, 393);
    107109            this.panelRight.TabIndex = 1;
    108110            //
     
    125127            this.lstClip.Location = new System.Drawing.Point(0, 32);
    126128            this.lstClip.Name = "lstClip";
    127             this.lstClip.Size = new System.Drawing.Size(120, 407);
     129            this.lstClip.Size = new System.Drawing.Size(120, 416);
    128130            this.lstClip.TabIndex = 0;
    129131            this.lstClip.DragDrop += new System.Windows.Forms.DragEventHandler(this.lstClip_DragDrop);
     132            this.lstClip.DragEnter += new System.Windows.Forms.DragEventHandler(this.lstClip_DragEnter);
     133            this.lstClip.MouseDown += new System.Windows.Forms.MouseEventHandler(this.lstClip_MouseDown);
    130134            this.lstClip.MouseMove += new System.Windows.Forms.MouseEventHandler(this.lstClip_MouseMove);
    131             this.lstClip.MouseDown += new System.Windows.Forms.MouseEventHandler(this.lstClip_MouseDown);
    132             this.lstClip.DragEnter += new System.Windows.Forms.DragEventHandler(this.lstClip_DragEnter);
    133135            //
    134136            // ctxApptClipMenu
     
    165167            this.panelBottom.Controls.Add(this.statusBar1);
    166168            this.panelBottom.Dock = System.Windows.Forms.DockStyle.Bottom;
    167             this.panelBottom.Location = new System.Drawing.Point(8, 388);
     169            this.panelBottom.Location = new System.Drawing.Point(8, 369);
    168170            this.panelBottom.Name = "panelBottom";
    169171            this.panelBottom.Size = new System.Drawing.Size(720, 24);
     
    217219            this.panelCenter.Location = new System.Drawing.Point(8, 24);
    218220            this.panelCenter.Name = "panelCenter";
    219             this.panelCenter.Size = new System.Drawing.Size(712, 364);
     221            this.panelCenter.Size = new System.Drawing.Size(712, 345);
    220222            this.panelCenter.TabIndex = 4;
    221223            //
     
    253255            this.tvSchedules.Location = new System.Drawing.Point(0, 0);
    254256            this.tvSchedules.Name = "tvSchedules";
    255             this.tvSchedules.Size = new System.Drawing.Size(8, 412);
     257            this.tvSchedules.Size = new System.Drawing.Size(8, 393);
    256258            this.tvSchedules.Sorted = true;
    257259            this.tvSchedules.TabIndex = 5;
     
    271273            this.mnuLoadTemplate,
    272274            this.mnuSaveTemplate,
     275            this.mnuDeleteAllAppointments,
    273276            this.menuItem6,
    274277            this.mnuSchedulingManagment,
     
    291294            this.mnuSaveTemplate.Click += new System.EventHandler(this.mnuSaveTemplate_Click);
    292295            //
     296            // mnuDeleteAllAppointments
     297            //
     298            this.mnuDeleteAllAppointments.Enabled = false;
     299            this.mnuDeleteAllAppointments.Index = 2;
     300            this.mnuDeleteAllAppointments.Shortcut = System.Windows.Forms.Shortcut.CtrlD;
     301            this.mnuDeleteAllAppointments.Text = "&Delete All Appointments";
     302            this.mnuDeleteAllAppointments.Click += new System.EventHandler(this.mnuDeleteAllAppointments_Click);
     303            //
    293304            // menuItem6
    294305            //
    295             this.menuItem6.Index = 2;
     306            this.menuItem6.Index = 3;
    296307            this.menuItem6.Text = "-";
    297308            //
    298309            // mnuSchedulingManagment
    299310            //
    300             this.mnuSchedulingManagment.Index = 3;
     311            this.mnuSchedulingManagment.Index = 4;
    301312            this.mnuSchedulingManagment.Shortcut = System.Windows.Forms.Shortcut.CtrlShiftM;
    302313            this.mnuSchedulingManagment.Text = "Scheduling &Management";
     
    305316            // menuItem5
    306317            //
    307             this.menuItem5.Index = 4;
     318            this.menuItem5.Index = 5;
    308319            this.menuItem5.Text = "-";
    309320            //
    310321            // mnuClose
    311322            //
    312             this.mnuClose.Index = 5;
     323            this.mnuClose.Index = 6;
    313324            this.mnuClose.Shortcut = System.Windows.Forms.Shortcut.CtrlW;
    314325            this.mnuClose.Text = "&Close";
     
    446457            this.splitter1.Location = new System.Drawing.Point(720, 24);
    447458            this.splitter1.Name = "splitter1";
    448             this.splitter1.Size = new System.Drawing.Size(8, 364);
     459            this.splitter1.Size = new System.Drawing.Size(8, 345);
    449460            this.splitter1.TabIndex = 6;
    450461            this.splitter1.TabStop = false;
     462            //
     463            // saveAccessBlocksWorker
     464            //
     465            this.saveAccessBlocksWorker.WorkerReportsProgress = true;
     466            this.saveAccessBlocksWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(this.saveAccessBlocksWorker_DoWork);
     467            this.saveAccessBlocksWorker.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(this.saveAccessBlocksWorker_ProgressChanged);
     468            this.saveAccessBlocksWorker.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.saveAccessBlocksWorker_RunWorkerCompleted);
    451469            //
    452470            // calendarGrid1
     
    469487            this.calendarGrid1.Resources = ((System.Collections.ArrayList)(resources.GetObject("calendarGrid1.Resources")));
    470488            this.calendarGrid1.SelectedAppointment = 0;
    471             this.calendarGrid1.Size = new System.Drawing.Size(712, 364);
     489            this.calendarGrid1.Size = new System.Drawing.Size(712, 345);
    472490            this.calendarGrid1.StartDate = new System.DateTime(2003, 1, 27, 0, 0, 0, 0);
    473491            this.calendarGrid1.TabIndex = 2;
    474492            this.calendarGrid1.TimeScale = 20;
     493            this.calendarGrid1.CGAppointmentAdded += new IndianHealthService.ClinicalScheduling.CGAppointmentChangedHandler(this.calendarGrid1_CGAppointmentAdded);
     494            this.calendarGrid1.CGAppointmentChanged += new IndianHealthService.ClinicalScheduling.CGAppointmentChangedHandler(this.calendarGrid1_CGAppointmentChanged);
     495            this.calendarGrid1.CGSelectionChanged += new IndianHealthService.ClinicalScheduling.CGSelectionChangedHandler(this.calendarGrid1_CGSelectionChanged);
    475496            this.calendarGrid1.DoubleClick += new System.EventHandler(this.calendarGrid1_DoubleClick);
    476             this.calendarGrid1.CGSelectionChanged += new IndianHealthService.ClinicalScheduling.CGSelectionChangedHandler(this.calendarGrid1_CGSelectionChanged);
    477             this.calendarGrid1.CGAppointmentChanged += new IndianHealthService.ClinicalScheduling.CGAppointmentChangedHandler(this.calendarGrid1_CGAppointmentChanged);
    478             this.calendarGrid1.CGAppointmentAdded += new IndianHealthService.ClinicalScheduling.CGAppointmentChangedHandler(this.calendarGrid1_CGAppointmentAdded);
    479497            //
    480498            // CGAVView
    481499            //
    482500            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
    483             this.ClientSize = new System.Drawing.Size(848, 412);
     501            this.ClientSize = new System.Drawing.Size(848, 393);
    484502            this.Controls.Add(this.panelCenter);
    485503            this.Controls.Add(this.splitter1);
     
    492510            this.Name = "CGAVView";
    493511            this.Text = "CGAVView";
     512            this.Closing += new System.ComponentModel.CancelEventHandler(this.CGAVView_Closing);
    494513            this.Load += new System.EventHandler(this.CGAVView_Load);
    495             this.Closing += new System.ComponentModel.CancelEventHandler(this.CGAVView_Closing);
    496514            this.panelRight.ResumeLayout(false);
    497515            this.panelClip.ResumeLayout(false);
     
    556574                private System.Windows.Forms.MenuItem ctxCalGridEdit;
    557575                private System.Windows.Forms.MenuItem ctxCalGridDelete;
     576        private BackgroundWorker saveAccessBlocksWorker;
     577        private MenuItem mnuDeleteAllAppointments;
    558578                private bool                            m_bDragDropStart = false;
    559579
     
    749769                }//End AvailabilityAddNew
    750770
     771        private void MassAppointmentDelete()
     772        {
     773            DialogResult msgResult = MessageBox.Show("Delete all Access Slots?", "Delete Slots?",MessageBoxButtons.YesNo);
     774            if (msgResult != DialogResult.Yes) return;
     775
     776            CGAppointments appointments = new CGAppointments();
     777            appointments = this.Document.AVBlocks;
     778
     779            foreach (CGAppointment a in appointments.AppointmentTable.Values)
     780            {
     781                int nApptID = a.AppointmentKey;
     782                Debug.Assert(nApptID != 0);
     783                try
     784                {
     785                    Document.DeleteAvailability(nApptID);
     786                }
     787                catch (Exception ex)
     788                {
     789                    MessageBox.Show("Unable to delete access block" + ex.Message, "Clinical Scheduling");
     790                }
     791
     792            }
     793
     794            this.m_DocManager.UpdateViews((string)this.m_Document.Resources[0], "");
     795            RaiseRPMSEvent("BSDX SCHEDULE", m_Document.DocName);
     796            this.calendarGrid1.Invalidate();
     797        }
     798
    751799                private void AppointmentDelete()
    752800                {
     
    756804                                sMsg = " these access blocks?";
    757805
    758                         if (MessageBox.Show("Are you sure you want to delete" + sMsg, "Clinical Scheduling",  MessageBoxButtons.YesNo) != DialogResult.Yes)
    759                         {
    760                                 calendarGrid1.CGToolTip.Active = true;
    761                                 return;
    762                         }
    763806                        calendarGrid1.CGToolTip.Active = true;
    764807
     
    907950                        {
    908951//                              this.DocManager.EnableAutoRefresh(false);
    909 
    910                                 if (MessageBox.Show("Are you sure you want to move this access block?", "Clinical Scheduling",  MessageBoxButtons.YesNo) != DialogResult.Yes)
    911                                         return;
    912952
    913953                                m_Document.ChangeAppointmentTime(e.Appointment, e.StartTime, e.EndTime, e.Resource);
     
    10101050                        try
    10111051                        {
    1012                                 OpenFileDialog openFileDialog1 = dlg.FileDialog;
    1013                                 Stream streamFile;
    1014                                 if((streamFile = openFileDialog1.OpenFile())== null)
    1015                                 {
    1016                                         MessageBox.Show("Unable to open template file.");
    1017                                         return;
    1018                                 }
    1019 
    1020                                 BinaryFormatter formatter = new BinaryFormatter();
    1021                                 CGAppointments cgaTemp = (CGAppointments) formatter.Deserialize(streamFile);
    1022                                 streamFile.Close();
    1023 
    1024                                 DateTime dtStart = dlg.StartDate;
    1025                 DateTime newStartDate, newEndDate;
    1026                 this.Document.WeekNeedsRefresh(1,dtStart, out newStartDate, out newEndDate);
    1027                 dtStart = newStartDate;
    1028                                 int nWeeksToApply = dlg.WeeksToApply;
    1029                                 DateTime dtEnd = dtStart.AddDays(6); // or 7?
    1030 
    1031                                 string sResourceID = this.m_Document.ResourceID.ToString();
    1032                                 DataTable dt;
    1033 
    1034                                 for (int j=1; j < nWeeksToApply + 1; j++)
    1035                                 {
    1036                                         //Convert start and end to string
    1037                                         //string sStart = dtStart.ToString("M/d/yyyy");
    1038                                         //string sEnd = dtEnd.ToString("M/d/yyyy");
    1039                     //i18n
    1040                     string sStart = FMDateTime.Create(dtStart).DateOnly.FMDateString;
    1041                     string sEnd = FMDateTime.Create(dtEnd).DateOnly.FMDateString;
    1042                                         //Cancel all existing access blocks in the date range
    1043                                         string sSql = "BSDX CANCEL AV BY DATE^" + sResourceID + "^" + sStart + "^" + sEnd;
    1044                                         dt = this.m_DocManager.RPMSDataTable(sSql, "Cancelled");
    1045 
    1046                                         //for each CGAppointment in AVBlocks, call AddNew
    1047                                         string sResource = "";
    1048                                         sResource = (string) this.Document.Resources[0];
    1049                                         foreach (CGAppointment a in cgaTemp.AppointmentTable.Values)
    1050                                         {
    1051                                                 //Change the resource to the current one
    1052                                                 a.Resource = sResource;
    1053 
    1054                                                 //Change the date to correspond to the GridColumn member
    1055                                                 int col = a.GridColumn;
    1056                                                 col--;
    1057                                                 DateTime dBuildDate = dtStart.Date;
    1058                                                 dBuildDate = dBuildDate.AddDays(col);
    1059                                                 dBuildDate = dBuildDate.AddHours(a.StartTime.Hour);
    1060                                                 dBuildDate = dBuildDate.AddMinutes(a.StartTime.Minute);
    1061                                                 a.StartTime = dBuildDate;
    1062                                                 dBuildDate = dtStart.Date;
    1063                                                 dBuildDate = dBuildDate.AddDays(col);
    1064                                                 dBuildDate = dBuildDate.AddHours(a.EndTime.Hour);
    1065                                                 dBuildDate = dBuildDate.AddMinutes(a.EndTime.Minute);
    1066                                                 a.EndTime = dBuildDate;
    1067 
    1068                                                 //Call Document to add a new appointment
    1069                                                 this.Document.CreateAppointmentAuto(a);
    1070                                         }
    1071 
    1072                                         //Increment start and end
    1073                                         dtStart = dtStart.AddDays(7);
    1074                                         dtEnd = dtStart.AddDays(6);
    1075 
    1076                                 }//end for
     1052                this.saveAccessBlocksWorker.RunWorkerAsync(dlg);
     1053                //OpenFileDialog openFileDialog1 = dlg.FileDialog;
     1054                //openFileDialog1.RestoreDirectory = false; // go back to our dir
     1055                //Stream streamFile;
     1056                //if((streamFile = openFileDialog1.OpenFile())== null)
     1057                //{
     1058                //    MessageBox.Show("Unable to open template file.");
     1059                //    return;
     1060                //}
     1061
     1062                //BinaryFormatter formatter = new BinaryFormatter();
     1063                //CGAppointments cgaTemp = (CGAppointments) formatter.Deserialize(streamFile);
     1064                //streamFile.Close();
     1065
     1066                //DateTime dtStart = dlg.StartDate;
     1067                //DateTime newStartDate, newEndDate;
     1068                //this.Document.WeekNeedsRefresh(1,dtStart, out newStartDate, out newEndDate);
     1069                //dtStart = newStartDate;
     1070                //int nWeeksToApply = dlg.WeeksToApply;
     1071                //DateTime dtEnd = dtStart.AddDays(6); // or 7?
     1072
     1073                //string sResourceID = this.m_Document.ResourceID.ToString();
     1074                //DataTable dt;
     1075
     1076                //for (int j=1; j < nWeeksToApply + 1; j++)
     1077                //{
     1078                //    //Convert start and end to string
     1079                //    //string sStart = dtStart.ToString("M/d/yyyy");
     1080                //    //string sEnd = dtEnd.ToString("M/d/yyyy");
     1081                //    //i18n
     1082                //    string sStart = FMDateTime.Create(dtStart).DateOnly.FMDateString;
     1083                //    string sEnd = FMDateTime.Create(dtEnd).DateOnly.FMDateString;
     1084                //    //Cancel all existing access blocks in the date range
     1085                //    string sSql = "BSDX CANCEL AV BY DATE^" + sResourceID + "^" + sStart + "^" + sEnd;
     1086                //    dt = this.m_DocManager.RPMSDataTable(sSql, "Cancelled");
     1087
     1088                //    //for each CGAppointment in AVBlocks, call AddNew
     1089                //    string sResource = "";
     1090                //    sResource = (string) this.Document.Resources[0];
     1091                //    foreach (CGAppointment a in cgaTemp.AppointmentTable.Values)
     1092                //    {
     1093                //        //Change the resource to the current one
     1094                //        a.Resource = sResource;
     1095
     1096                //        //Change the date to correspond to the GridColumn member
     1097                //        int col = a.GridColumn;
     1098                //        col--;
     1099                //        DateTime dBuildDate = dtStart.Date;
     1100                //        dBuildDate = dBuildDate.AddDays(col);
     1101                //        dBuildDate = dBuildDate.AddHours(a.StartTime.Hour);
     1102                //        dBuildDate = dBuildDate.AddMinutes(a.StartTime.Minute);
     1103                //        a.StartTime = dBuildDate;
     1104                //        dBuildDate = dtStart.Date;
     1105                //        dBuildDate = dBuildDate.AddDays(col);
     1106                //        dBuildDate = dBuildDate.AddHours(a.EndTime.Hour);
     1107                //        dBuildDate = dBuildDate.AddMinutes(a.EndTime.Minute);
     1108                //        a.EndTime = dBuildDate;
     1109
     1110                //        //Call Document to add a new appointment
     1111                //        this.Document.CreateAppointmentAuto(a);
     1112                //    }
     1113
     1114                //    //Increment start and end
     1115                //    dtStart = dtStart.AddDays(7);
     1116                //    dtEnd = dtStart.AddDays(6);
     1117
     1118                                // }//end for
    10771119                                try
    10781120                                {
     
    14241466                        cg.Invalidate();
    14251467                }
     1468
     1469
     1470
     1471        private void saveAccessBlocksWorker_DoWork(object sender, DoWorkEventArgs e)
     1472        {
     1473            BackgroundWorker worker = (BackgroundWorker)sender;
     1474            DAccessTemplate dlg = (DAccessTemplate)e.Argument;
     1475
     1476            OpenFileDialog openFileDialog1 = dlg.FileDialog;
     1477            openFileDialog1.RestoreDirectory = false; // go back to our dir
     1478            Stream streamFile;
     1479            if ((streamFile = openFileDialog1.OpenFile()) == null)
     1480            {
     1481                MessageBox.Show("Unable to open template file.");
     1482                return;
     1483            }
     1484
     1485            BinaryFormatter formatter = new BinaryFormatter();
     1486            CGAppointments cgaTemp = (CGAppointments)formatter.Deserialize(streamFile);
     1487            streamFile.Close();
     1488
     1489            DateTime dtStart = dlg.StartDate;
     1490            DateTime newStartDate, newEndDate;
     1491            this.Document.WeekNeedsRefresh(1, dtStart, out newStartDate, out newEndDate);
     1492            dtStart = newStartDate;
     1493            int nWeeksToApply = dlg.WeeksToApply;
     1494            DateTime dtEnd = dtStart.AddDays(6); // or 7?
     1495
     1496            string sResourceID = this.m_Document.ResourceID.ToString();
     1497            DataTable dt;
     1498
     1499            for (int j = 1; j < nWeeksToApply + 1; j++)
     1500            {
     1501                float fProgressPercentage = ((float)j / (float)nWeeksToApply) * 100;
     1502                int iProgressPercentage = (int)fProgressPercentage;
     1503                worker.ReportProgress(iProgressPercentage);
     1504                //Convert start and end to string
     1505                //string sStart = dtStart.ToString("M/d/yyyy");
     1506                //string sEnd = dtEnd.ToString("M/d/yyyy");
     1507                //i18n
     1508                string sStart = FMDateTime.Create(dtStart).DateOnly.FMDateString;
     1509                string sEnd = FMDateTime.Create(dtEnd).DateOnly.FMDateString;
     1510                //Cancel all existing access blocks in the date range
     1511                string sSql = "BSDX CANCEL AV BY DATE^" + sResourceID + "^" + sStart + "^" + sEnd;
     1512                CGDocumentManager.RPMSDataTableDelegate d = new CGDocumentManager.RPMSDataTableDelegate(m_DocManager.RPMSDataTable);
     1513                //dt = this.m_DocManager.RPMSDataTable(sSql, "Cancelled");
     1514                dt = d(sSql, "Cancelled");
     1515                //for each CGAppointment in AVBlocks, call AddNew
     1516                string sResource = "";
     1517                sResource = (string)this.Document.Resources[0];
     1518                foreach (CGAppointment a in cgaTemp.AppointmentTable.Values)
     1519                {
     1520                    //Change the resource to the current one
     1521                    a.Resource = sResource;
     1522
     1523                    //Change the date to correspond to the GridColumn member
     1524                    int col = a.GridColumn;
     1525                    col--;
     1526                    DateTime dBuildDate = dtStart.Date;
     1527                    dBuildDate = dBuildDate.AddDays(col);
     1528                    dBuildDate = dBuildDate.AddHours(a.StartTime.Hour);
     1529                    dBuildDate = dBuildDate.AddMinutes(a.StartTime.Minute);
     1530                    a.StartTime = dBuildDate;
     1531                    dBuildDate = dtStart.Date;
     1532                    dBuildDate = dBuildDate.AddDays(col);
     1533                    dBuildDate = dBuildDate.AddHours(a.EndTime.Hour);
     1534                    dBuildDate = dBuildDate.AddMinutes(a.EndTime.Minute);
     1535                    a.EndTime = dBuildDate;
     1536
     1537                    //Call Document to add a new appointment
     1538                    this.Document.CreateAppointmentAuto(a);
     1539                }
     1540
     1541                //Increment start and end
     1542                dtStart = dtStart.AddDays(7);
     1543                dtEnd = dtStart.AddDays(6);
     1544
     1545            }
     1546
     1547        }
     1548
     1549        private void saveAccessBlocksWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
     1550        {
     1551            this.statusBar1.Text = "Done saving access blocks.";
     1552        }
     1553
     1554        private void saveAccessBlocksWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
     1555        {
     1556            this.statusBar1.Text = "Saving Data to VISTA. Progress: " + e.ProgressPercentage + " %";
     1557        }
     1558
     1559        private void mnuDeleteAllAppointments_Click(object sender, EventArgs e)
     1560        {
     1561            MassAppointmentDelete();
     1562        }
    14261563        }
    14271564}
Note: See TracChangeset for help on using the changeset viewer.