- Timestamp:
- Jun 4, 2010, 10:19:48 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Scheduling/trunk/cs/bsdx0200GUISourceCode/DPatientLetter.cs
r772 r788 16 16 /// </summary> 17 17 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; 19 20 20 21 #region Fields 21 22 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. 22 26 int _currentResourcePrinting = 0; 23 27 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; 25 34 #endregion Fields 26 35 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, 28 44 string sClinicList, 29 45 DateTime dtBegin, … … 45 61 string sSql2 = "BSDX RESOURCE LETTERS^" + sClinicList; 46 62 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; 50 68 } 51 69 catch (Exception ex) … … 57 75 public void InitializeFormRebookLetters(CGDocumentManager docManager, 58 76 string sClinicList, 59 DataTable dtLetters) 77 DateTime dtBegin, 78 DateTime dtEnd) 60 79 { 61 80 try … … 66 85 } 67 86 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"); 70 93 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 } 75 97 catch (Exception ex) 76 98 { … … 78 100 } 79 101 } 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> 81 133 public void InitializeFormCancellationLetters(CGDocumentManager docManager, 82 134 string sClinicList, 83 DataTable dtLetters) 84 { 135 DateTime dtBegin, 136 DateTime dtEnd) 137 { 85 138 try 86 139 { … … 90 143 } 91 144 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 99 158 } 100 159 catch (Exception ex) … … 103 162 } 104 163 } 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, 107 172 string sClinicList, 108 173 DateTime dtBegin, … … 115 180 throw new Exception("At least one clinic must be selected."); 116 181 } 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; 117 197 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 131 198 } 132 199 catch (Exception ex) … … 137 204 138 205 139 public DPatientLetter() 206 public DPatientLetter() : base() 140 207 { 141 208 // … … 171 238 private void InitializeComponent() 172 239 { 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(); 174 243 this.SuspendLayout(); 175 244 // 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); 179 256 // 180 257 // DPatientLetter … … 182 259 this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); 183 260 this.ClientSize = new System.Drawing.Size(648, 398); 184 this.Document = this.printDocument1;185 261 this.Name = "DPatientLetter"; 186 262 this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; … … 191 267 #endregion 192 268 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 195 274 // _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); 198 277 199 278 //If the printing routine says it needs more pages to print the appointments, … … 203 282 // if there are more resouces to print, increment. Setting HasMorePages to true 204 283 // 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) 206 285 { 207 286 _currentResourcePrinting++; 287 //reset _currentApptPrinting 288 _currentApptPrinting = 0; 208 289 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; 209 310 } 210 311 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 211 333 } 212 334 }
Note:
See TracChangeset
for help on using the changeset viewer.