Ignore:
Timestamp:
Jun 4, 2010, 10:19:48 PM (14 years ago)
Author:
Sam Habiel
Message:

Some debugging code to attach the program to the console to print messages.
Letters:

  • Cancellation letters now work.
  • Initial work on Rebook Letters.
File:
1 edited

Legend:

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

    r772 r788  
    1616                /// </summary>
    1717        private System.ComponentModel.Container components = null;
    18         private System.Drawing.Printing.PrintDocument printDocument1;
     18        private System.Drawing.Printing.PrintDocument printAppts;
     19        private System.Drawing.Printing.PrintDocument printReminderLetters;
    1920
    2021                #region Fields
    2122        DateTime _dtBegin, _dtEnd; //global fields to use in passing to printing method
     23       
     24        //stuff to track what got printed and where we are -- very ugly, I know
     25        //but I don't know if there is a better way to do it.
    2226        int _currentResourcePrinting = 0;
    2327        int _currentApptPrinting = 0;
    24         dsPatientApptDisplay2 _ds;
     28        int _pageNumber = 0;
     29       
     30        //dataset to load the results of queries into and set to print routines
     31        dsPatientApptDisplay2 _dsApptDisplay;
     32        private PrintDocument printCancelLetters;
     33        dsRebookAppts _dsRebookAppts;
    2534                #endregion Fields
    2635
    27                 public void InitializeFormClinicSchedule(CGDocumentManager docManager,
     36                /// <summary>
     37                /// Print Clinic Schedules
     38                /// </summary>
     39                /// <param name="docManager">This docManger</param>
     40                /// <param name="sClinicList">Clinics for which to print</param>
     41                /// <param name="dtBegin">Beginning Date</param>
     42                /// <param name="dtEnd">End Date</param>
     43        public void InitializeFormClinicSchedule(CGDocumentManager docManager,
    2844                        string sClinicList,
    2945                        DateTime dtBegin,
     
    4561                string sSql2 = "BSDX RESOURCE LETTERS^" + sClinicList;
    4662
    47                 _ds = new dsPatientApptDisplay2();
    48                 _ds.BSDXResource.Merge(docManager.RPMSDataTable(sSql2, "Resources"));
    49                 _ds.PatientAppts.Merge(docManager.RPMSDataTable(sSql, "PatientAppts"));
     63                _dsApptDisplay = new dsPatientApptDisplay2();
     64                _dsApptDisplay.BSDXResource.Merge(docManager.RPMSDataTable(sSql2, "Resources"));
     65                _dsApptDisplay.PatientAppts.Merge(docManager.RPMSDataTable(sSql, "PatientAppts"));
     66
     67                this.PrintPreviewControl.Document = printAppts;
    5068            }
    5169                        catch (Exception ex)
     
    5775                public void InitializeFormRebookLetters(CGDocumentManager docManager,
    5876                        string sClinicList,
    59                         DataTable dtLetters)
     77                    DateTime dtBegin,
     78            DateTime dtEnd)
    6079                {
    6180                        try
     
    6685                                }
    6786
    68                                 System.Data.DataSet ds = new System.Data.DataSet();
    69                                 ds.Tables.Add(dtLetters.Copy());
     87                string sBegin = dtBegin.ToString("M/d/yyyy@HH:mm");
     88                string sEnd = dtEnd.ToString("M/d/yyyy@HH:mm");
     89
     90                //Call RPC to get list of appt ids that have been rebooked for these clinics on these dates
     91                string sSql1 = "BSDX REBOOK CLINIC LIST^" + sClinicList + "^" + sBegin + "^" + sEnd;
     92                DataTable dtLetters = docManager.RPMSDataTable(sSql1, "PatientAppts");
    7093                               
    71                                 string sSql = "BSDX RESOURCE LETTERS^" + sClinicList;
    72                                 DataTable dt = docManager.RPMSDataTable(sSql, "Resources");                             
    73                                 ds.Tables.Add(dt.Copy());                               
    74                         }
     94                                string sSql2 = "BSDX RESOURCE LETTERS^" + sClinicList;
     95                                DataTable dt = docManager.RPMSDataTable(sSql2, "Resources");                           
     96            }
    7597                        catch (Exception ex)
    7698                        {
     
    78100                        }
    79101                }
    80 
     102        public void InitializeFormRebookLetters(CGDocumentManager docManager,
     103            string sClinicList,
     104            string sApptIDList)
     105        {
     106            try
     107            {
     108                if (sClinicList == "")
     109                {
     110                    throw new Exception("At least one clinic must be selected.");
     111                }
     112
     113                string sSql = "BSDX REBOOK LIST^" + sApptIDList;
     114                DataTable dtLetters = docManager.RPMSDataTable(sSql, "PatientAppts");
     115
     116                string sSql2 = "BSDX RESOURCE LETTERS^" + sClinicList;
     117                DataTable dt = docManager.RPMSDataTable(sSql2, "Resources");
     118
     119            }
     120            catch (Exception ex)
     121            {
     122                throw ex;
     123            }
     124        }
     125
     126        /// <summary>
     127        /// Print Cancellation letters to mail to patients
     128        /// </summary>
     129        /// <param name="docManager">This Docmanager</param>
     130        /// <param name="sClinicList">| delemited clinic list (IEN's)</param>
     131        /// <param name="dtBegin">Beginning Date</param>
     132        /// <param name="dtEnd">Ending Date</param>
    81133                public void InitializeFormCancellationLetters(CGDocumentManager docManager,
    82134                        string sClinicList,
    83                         DataTable dtLetters)
    84                 {
     135            DateTime dtBegin,
     136            DateTime dtEnd)
     137        {
    85138                        try
    86139                        {       
     
    90143                                }
    91144
    92                                 System.Data.DataSet ds = new System.Data.DataSet();
    93                                 ds.Tables.Add(dtLetters.Copy());
    94                                
    95                                 string sSql = "BSDX RESOURCE LETTERS^" + sClinicList;
    96                                 DataTable dt = docManager.RPMSDataTable(sSql, "Resources");                             
    97                                 ds.Tables.Add(dt.Copy());
    98                                
     145                string sBegin = dtBegin.ToString("M/d/yyyy@HH:mm");
     146                string sEnd = dtEnd.ToString("M/d/yyyy@HH:mm");
     147
     148                //Call RPC to get list of appt ids that have been cancelled for these clinics on these dates
     149                string sSql1 = "BSDX CANCEL CLINIC LIST^" + sClinicList + "^" + sBegin + "^" + sEnd;
     150                                string sSql2 = "BSDX RESOURCE LETTERS^" + sClinicList;
     151
     152                _dsRebookAppts = new dsRebookAppts();
     153                _dsRebookAppts.PatientAppts.Merge(docManager.RPMSDataTable(sSql1, "PatientAppts"));
     154                _dsRebookAppts.BSDXResource.Merge(docManager.RPMSDataTable(sSql2, "Resources"));
     155
     156                PrintPreviewControl.Document = printCancelLetters;
     157
    99158                        }
    100159                        catch (Exception ex)
     
    103162                        }
    104163                }
    105 
    106                 public void InitializeFormClinicLetters(CGDocumentManager docManager,
     164        /// <summary>
     165        /// Print Reminder Letters to give or mail to patients
     166        /// </summary>
     167        /// <param name="docManager">This docManger</param>
     168        /// <param name="sClinicList">Clinics for which to print</param>
     169        /// <param name="dtBegin">Beginning Date</param>
     170        /// <param name="dtEnd">End Date</param>
     171        public void InitializeFormPatientReminderLetters(CGDocumentManager docManager,
    107172                        string sClinicList,
    108173                        DateTime dtBegin,
     
    115180                                        throw new Exception("At least one clinic must be selected.");
    116181                                }
     182
     183                _dtBegin = dtBegin;
     184                _dtEnd = dtEnd;
     185                string sBegin = dtBegin.ToShortDateString();
     186                string sEnd = dtEnd.ToShortDateString();
     187                this.Text = "Clinic Schedules";
     188
     189                string sSql = "BSDX CLINIC LETTERS^" + sClinicList + "^" + sBegin + "^" + sEnd;
     190                string sSql2 = "BSDX RESOURCE LETTERS^" + sClinicList;
     191
     192                _dsApptDisplay = new dsPatientApptDisplay2();
     193                _dsApptDisplay.BSDXResource.Merge(docManager.RPMSDataTable(sSql2, "Resources"));
     194                _dsApptDisplay.PatientAppts.Merge(docManager.RPMSDataTable(sSql, "PatientAppts"));
     195
     196                this.PrintPreviewControl.Document = printReminderLetters;
    117197                               
    118                                 string sBegin = dtBegin.ToShortDateString();
    119                                 string sEnd = dtEnd.ToShortDateString();
    120 
    121                                 string sSql = "BSDX CLINIC LETTERS^" + sClinicList + "^" + sBegin + "^" + sEnd;
    122 
    123                                 System.Data.DataSet ds = new System.Data.DataSet();
    124                                 DataTable dtAppt = docManager.RPMSDataTable(sSql, "PatientAppts");                             
    125                                 ds.Tables.Add(dtAppt.Copy());
    126                                
    127                                 sSql = "BSDX RESOURCE LETTERS^" + sClinicList;
    128                                 DataTable dt = docManager.RPMSDataTable(sSql, "Resources");                             
    129                                 ds.Tables.Add(dt.Copy());
    130                                
    131198                        }
    132199                        catch (Exception ex)
     
    137204
    138205
    139                 public DPatientLetter()
     206                public DPatientLetter() : base()
    140207                {
    141208                        //
     
    171238                private void InitializeComponent()
    172239                {
    173             this.printDocument1 = new System.Drawing.Printing.PrintDocument();
     240            this.printAppts = new System.Drawing.Printing.PrintDocument();
     241            this.printReminderLetters = new System.Drawing.Printing.PrintDocument();
     242            this.printCancelLetters = new System.Drawing.Printing.PrintDocument();
    174243            this.SuspendLayout();
    175244            //
    176             // printDocument1
    177             //
    178             this.printDocument1.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.printDocument1_PrintPage);
     245            // printAppts
     246            //
     247            this.printAppts.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.printAppts_PrintPage);
     248            //
     249            // printReminderLetters
     250            //
     251            this.printReminderLetters.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.printReminderLetters_PrintPage);
     252            //
     253            // printCancelLetters
     254            //
     255            this.printCancelLetters.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.printCancelLetters_PrintPage);
    179256            //
    180257            // DPatientLetter
     
    182259            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
    183260            this.ClientSize = new System.Drawing.Size(648, 398);
    184             this.Document = this.printDocument1;
    185261            this.Name = "DPatientLetter";
    186262            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
     
    191267                #endregion
    192268
    193         private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
    194         {
     269        private void printAppts_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
     270        {
     271            //Each time we enter here, we start off with a new page number - we start off with zero
     272            _pageNumber++; //becomes one first time through
     273           
    195274            // _currentResourcePrinting starts with zero. There will be at least this one.
    196             ClinicalScheduling.Printing.PrintAppointments(_ds, e, _dtBegin, _dtEnd,
    197                     _currentResourcePrinting, ref _currentApptPrinting);
     275            ClinicalScheduling.Printing.PrintAppointments(_dsApptDisplay, e, _dtBegin, _dtEnd,
     276                    _currentResourcePrinting, ref _currentApptPrinting, _pageNumber);
    198277
    199278            //If the printing routine says it needs more pages to print the appointments,
     
    203282            // if there are more resouces to print, increment. Setting HasMorePages to true
    204283            // calls this routine again, so printing will happen with the incremented _currentResourcePrinting
    205             if (_currentResourcePrinting < _ds.BSDXResource.Rows.Count - 1)
     284            if (_currentResourcePrinting < _dsApptDisplay.BSDXResource.Rows.Count - 1)
    206285            {
    207286                _currentResourcePrinting++;
     287                //reset _currentApptPrinting
     288                _currentApptPrinting = 0;
    208289                e.HasMorePages = true;
     290            }           
     291        }
     292
     293        private void printReminderLetters_PrintPage(object sender, PrintPageEventArgs e)
     294        {
     295            // no patients
     296            if (_dsApptDisplay.PatientAppts.Count == 0)
     297            {
     298                ClinicalScheduling.Printing.PrintMessage("No Appointments found", e);
     299                return;
     300            }
     301            // if there are patients
     302            else if (_currentApptPrinting < _dsApptDisplay.PatientAppts.Count)
     303            {
     304                dsPatientApptDisplay2.BSDXResourceRow c = (dsPatientApptDisplay2.BSDXResourceRow)
     305                   _dsApptDisplay.PatientAppts[_currentApptPrinting].GetParentRow(_dsApptDisplay.Relations[0]);
     306                ClinicalScheduling.Printing.PrintReminderLetter(_dsApptDisplay.PatientAppts[_currentApptPrinting], e, c.LETTER_TEXT, "Reminder Letter");
     307                _currentApptPrinting++;
     308                if (_currentApptPrinting < _dsApptDisplay.PatientAppts.Count)
     309                    e.HasMorePages = true;
    209310            }
    210311           
     312        }
     313
     314        private void printCancelLetters_PrintPage(object sender, PrintPageEventArgs e)
     315        {
     316            // no patients
     317            if (_dsRebookAppts.PatientAppts.Count == 0)
     318            {
     319                ClinicalScheduling.Printing.PrintMessage("No Appointments found", e);
     320                return;
     321            }
     322            // if there are patients
     323            else if (_currentApptPrinting < _dsRebookAppts.PatientAppts.Count)
     324            {
     325                dsRebookAppts.BSDXResourceRow c = (dsRebookAppts.BSDXResourceRow)
     326                   _dsRebookAppts.PatientAppts[_currentApptPrinting].GetParentRow(_dsRebookAppts.Relations[0]);
     327                ClinicalScheduling.Printing.PrintCancelLetter(_dsRebookAppts.PatientAppts[_currentApptPrinting], e, c.CLINIC_CANCELLATION_LETTER, "Cancellation Letter");
     328                _currentApptPrinting++;
     329                if (_currentApptPrinting < _dsRebookAppts.PatientAppts.Count)
     330                    e.HasMorePages = true;
     331            }
     332
    211333        }
    212334        }
Note: See TracChangeset for help on using the changeset viewer.