[772] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Linq;
|
---|
| 4 | using System.Text;
|
---|
| 5 | using System.Drawing.Printing;
|
---|
| 6 | using System.Drawing;
|
---|
| 7 | using System.Data;
|
---|
| 8 | using System.Drawing.Drawing2D;
|
---|
| 9 |
|
---|
| 10 | namespace IndianHealthService.ClinicalScheduling
|
---|
| 11 | {
|
---|
| 12 | /// <summary>
|
---|
| 13 | /// Class that encapsulates printing functions in Clinical Scheduling
|
---|
| 14 | /// </summary>
|
---|
| 15 | public static class Printing
|
---|
| 16 | {
|
---|
| 17 | /// <summary>
|
---|
| 18 | /// Print Appointments
|
---|
| 19 | /// </summary>
|
---|
| 20 | /// <param name="ds">Strongly Typed DataSet contains Resources and Appointments</param>
|
---|
| 21 | /// <param name="e">PrintPageEventArgs from PrintDocument Print handler</param>
|
---|
| 22 | /// <param name="beg">Begin Datetime to print appointments</param>
|
---|
[788] | 23 | /// <param name="end">End Datetime to print appointments</param
|
---|
| 24 | /// <param name="resourceToPrint">The resouce to print</param>
|
---|
| 25 | /// <param name="apptPrinting">Current Appointment printing</param>
|
---|
| 26 | /// <param name="pageNumber">Current page number</param>
|
---|
[772] | 27 | /// <remarks>beg and end have no effect on operation--they are there for documentation for user only</remarks>
|
---|
| 28 | public static void PrintAppointments(dsPatientApptDisplay2 ds, PrintPageEventArgs e, DateTime beg, DateTime end,
|
---|
[788] | 29 | int resourceToPrint, ref int apptPrinting, int pageNumber)
|
---|
[772] | 30 | {
|
---|
| 31 | Graphics g = e.Graphics;
|
---|
| 32 | //g.PageUnit = GraphicsUnit.Millimeter;
|
---|
| 33 | //SizeF szVCB = g.VisibleClipBounds.Size;
|
---|
| 34 | //PointF[] ptszVCB = {new PointF(szVCB.Width,szVCB.Height)};
|
---|
| 35 | //g.TransformPoints(CoordinateSpace.Page, CoordinateSpace.Device, ptszVCB);
|
---|
| 36 | //Create Fonts
|
---|
| 37 | Font f8 = new Font(FontFamily.GenericSerif, 8);
|
---|
| 38 | Font f10 = new Font(FontFamily.GenericSerif, 10);
|
---|
| 39 | Font f14bold = new Font(FontFamily.GenericSerif, 14, FontStyle.Bold);
|
---|
| 40 |
|
---|
| 41 | //Center Alignment for some stuff
|
---|
| 42 | StringFormat sf = new StringFormat();
|
---|
| 43 | sf.Alignment = StringAlignment.Center;
|
---|
| 44 |
|
---|
[788] | 45 | //Header
|
---|
[772] | 46 | g.DrawString("Confidential Patient Information", f8, Brushes.Black, e.PageBounds, sf);
|
---|
| 47 |
|
---|
[788] | 48 | //Footer
|
---|
| 49 | sf.Alignment = StringAlignment.Center;
|
---|
| 50 | sf.LineAlignment = StringAlignment.Far;
|
---|
| 51 | g.DrawString("Page " + pageNumber, f8, Brushes.Black, e.PageBounds, sf);
|
---|
| 52 |
|
---|
[772] | 53 | //Typical manipulable print area
|
---|
| 54 | Rectangle printArea = e.MarginBounds;
|
---|
| 55 |
|
---|
[788] | 56 | //resource we want to print
|
---|
[772] | 57 | dsPatientApptDisplay2.BSDXResourceRow r = ds.BSDXResource[resourceToPrint];
|
---|
| 58 |
|
---|
[788] | 59 | //header
|
---|
[772] | 60 | string toprint;
|
---|
| 61 | if (beg == end) toprint = "Appointments for " + r.RESOURCE_NAME + " on " + beg.ToLongDateString();
|
---|
| 62 | else toprint = "Appointments for " + r.RESOURCE_NAME + " from " + beg.ToShortDateString() + " to "
|
---|
| 63 | + end.ToShortDateString();
|
---|
| 64 | g.DrawString(toprint, f14bold, Brushes.Black, printArea);
|
---|
| 65 |
|
---|
[788] | 66 | //Move print area down
|
---|
| 67 | printArea.Height -= (int)f14bold.GetHeight();
|
---|
[772] | 68 | printArea.Y += (int)f14bold.GetHeight();
|
---|
[788] | 69 |
|
---|
| 70 | //Draw Line
|
---|
[772] | 71 | g.DrawLine(new Pen(Brushes.Black, 0), printArea.X, printArea.Y, printArea.X + printArea.Width, printArea.Y);
|
---|
| 72 |
|
---|
[788] | 73 | //Move print area down
|
---|
| 74 | printArea.Y += 5;
|
---|
| 75 | printArea.Height -= 5;
|
---|
| 76 |
|
---|
| 77 | System.Data.DataRow[] appts = r.GetChildRows(ds.Relations[0]); //ds has only one relation
|
---|
[772] | 78 |
|
---|
[788] | 79 | StringFormat sf2 = new StringFormat(); //sf to hold tab stops
|
---|
| 80 | sf2.SetTabStops(50, new float[] { 100, 250, 25 });
|
---|
[772] | 81 |
|
---|
[788] | 82 | //appt printed starts at zero
|
---|
| 83 | while (apptPrinting < appts.Length)
|
---|
[772] | 84 | {
|
---|
[788] | 85 | dsPatientApptDisplay2.PatientApptsRow a = (dsPatientApptDisplay2.PatientApptsRow)appts[apptPrinting];
|
---|
| 86 |
|
---|
| 87 | StringBuilder apptPrintStr = new StringBuilder(200);
|
---|
| 88 | apptPrintStr.AppendLine(a.ApptDate.ToString() + "\t" + a.Name + "(" + a.Sex + ")" + "\t" + "DOB: " + a.DOB.ToString("dd-MMM-yyyy") + "\t" + "ID: " + a.HRN);
|
---|
| 89 | apptPrintStr.AppendLine("P: " + a.HOMEPHONE + "\t" + "Address: " + a.STREET + ", " + a.CITY + ", " + a.STATE + " " + a.ZIP);
|
---|
| 90 | apptPrintStr.AppendLine("Note: " + a.NOTE);
|
---|
| 91 | apptPrintStr.AppendLine("Appointment made by " + a.APPT_MADE_BY + " on " + a.DATE_APPT_MADE);
|
---|
| 92 |
|
---|
| 93 | int printedApptHeight = (int)g.MeasureString(apptPrintStr.ToString(), f10, printArea.Width).Height;
|
---|
| 94 | if (printedApptHeight > printArea.Height) // too much to print -- move to next page
|
---|
| 95 | // but don't increment the appointment to print since we haven't printed it yet.
|
---|
| 96 | // i.e. apptPrinting stays the same.
|
---|
| 97 | {
|
---|
| 98 | e.HasMorePages = true;
|
---|
| 99 | break;
|
---|
| 100 | }
|
---|
| 101 |
|
---|
| 102 | //otherwise print it
|
---|
| 103 | g.DrawString(apptPrintStr.ToString(), f10, Brushes.Black, printArea, sf2);
|
---|
| 104 |
|
---|
| 105 | //Move print area down
|
---|
| 106 | printArea.Y += printedApptHeight + 3;
|
---|
| 107 | printArea.Height -= printedApptHeight + 3;
|
---|
| 108 |
|
---|
| 109 | //Draw a divider line
|
---|
| 110 | Point pt1 = new Point((int)(printArea.X + printArea.Width * 0.25), printArea.Y);
|
---|
| 111 | Point pt2 = new Point((int)(printArea.X + printArea.Width * 0.75), printArea.Y);
|
---|
| 112 | g.DrawLine(Pens.Gray, pt1, pt2);
|
---|
| 113 |
|
---|
| 114 | //move down, again
|
---|
| 115 | printArea.Y += 3;
|
---|
| 116 | printArea.Height -= 3;
|
---|
| 117 |
|
---|
| 118 | //go to the next appointment
|
---|
| 119 | apptPrinting++;
|
---|
[772] | 120 | }
|
---|
| 121 | }
|
---|
[788] | 122 |
|
---|
| 123 | /// <summary>
|
---|
| 124 | /// Print Letter to be given or mailed to the patient
|
---|
| 125 | /// </summary>
|
---|
| 126 | /// <param name="ptrow">Strongly typed PatientApptsRow to pass (just one ApptRow)</param>
|
---|
| 127 | /// <param name="e">You know what that is</param>
|
---|
| 128 | /// <param name="letter">Contains letter string</param>
|
---|
| 129 | /// <param name="title">Title of the letter</param>
|
---|
| 130 | public static void PrintReminderLetter(dsPatientApptDisplay2.PatientApptsRow ptRow, PrintPageEventArgs e, string letter, string title)
|
---|
| 131 | {
|
---|
| 132 |
|
---|
| 133 | Rectangle printArea = e.MarginBounds;
|
---|
| 134 | Graphics g = e.Graphics;
|
---|
| 135 | StringFormat sf = new StringFormat();
|
---|
| 136 | sf.Alignment = StringAlignment.Center; //for title
|
---|
| 137 | Font fTitle = new Font(FontFamily.GenericSerif, 24, FontStyle.Bold); //for title
|
---|
| 138 | Font fBody = new Font(FontFamily.GenericSerif, 12);
|
---|
| 139 | g.DrawString(title, fTitle, Brushes.Black, printArea, sf); //title
|
---|
| 140 |
|
---|
| 141 | // move down
|
---|
| 142 | int titleHeight = (int)g.MeasureString(title, fTitle, printArea.Width).Height;
|
---|
| 143 | printArea.Y += titleHeight;
|
---|
| 144 | printArea.Height -= titleHeight;
|
---|
| 145 |
|
---|
| 146 | // draw underline
|
---|
| 147 | g.DrawLine(Pens.Black, printArea.Location, new Point(printArea.Right, printArea.Y));
|
---|
| 148 | printArea.Y += 15;
|
---|
| 149 | printArea.Height -= 15;
|
---|
[789] | 150 |
|
---|
| 151 | // write appointment date
|
---|
| 152 | string str = "Appointment Date: " + ptRow.ApptDate + "\n\n";
|
---|
| 153 | g.DrawString(str, fBody, Brushes.Black, printArea);
|
---|
| 154 |
|
---|
| 155 | // move down
|
---|
| 156 | int strHeight = (int)g.MeasureString(str, fBody, printArea.Width).Height;
|
---|
| 157 | printArea.Y += strHeight;
|
---|
| 158 | printArea.Height -= strHeight;
|
---|
| 159 |
|
---|
[788] | 160 | // write missive
|
---|
| 161 | g.DrawString(letter, fBody, Brushes.Black, printArea);
|
---|
| 162 |
|
---|
| 163 | //print Address in lower left corner for windowed envolopes
|
---|
| 164 | printArea.Location = new Point(e.MarginBounds.X, (int)(e.PageBounds.Height * 0.66));
|
---|
| 165 | printArea.Height = (int)(e.MarginBounds.Height * 0.20);
|
---|
| 166 | sf.Alignment = StringAlignment.Near;
|
---|
| 167 | sf.LineAlignment = StringAlignment.Center;
|
---|
| 168 | StringBuilder address = new StringBuilder(100);
|
---|
| 169 | address.AppendLine(ptRow.Name);
|
---|
| 170 | address.AppendLine(ptRow.STREET);
|
---|
| 171 | address.AppendLine(ptRow.CITY + ", " + ptRow.STATE + " " + ptRow.ZIP);
|
---|
| 172 | g.DrawString(address.ToString(), fBody, Brushes.Black, printArea, sf);
|
---|
| 173 | }
|
---|
| 174 |
|
---|
| 175 | /// <summary>
|
---|
[789] | 176 | /// Cancellation Letter to be given or mailed to the patient
|
---|
[788] | 177 | /// </summary>
|
---|
[789] | 178 | /// <param name="ptRow">Strongly typed PatientApptsRow to pass (just one ApptRow)</param>
|
---|
[788] | 179 | /// <param name="e">You know what that is</param>
|
---|
| 180 | /// <param name="letter">Contains letter string</param>
|
---|
| 181 | /// <param name="title">Title of the letter</param>
|
---|
| 182 | public static void PrintCancelLetter(dsRebookAppts.PatientApptsRow ptRow, PrintPageEventArgs e, string letter, string title)
|
---|
| 183 | {
|
---|
| 184 | Rectangle printArea = e.MarginBounds;
|
---|
| 185 | Graphics g = e.Graphics;
|
---|
| 186 | StringFormat sf = new StringFormat();
|
---|
| 187 | sf.Alignment = StringAlignment.Center; //for title
|
---|
| 188 | Font fTitle = new Font(FontFamily.GenericSerif, 24, FontStyle.Bold); //for title
|
---|
| 189 | Font fBody = new Font(FontFamily.GenericSerif, 12);
|
---|
| 190 | g.DrawString(title, fTitle, Brushes.Black, printArea, sf); //title
|
---|
| 191 |
|
---|
| 192 | // move down
|
---|
| 193 | int titleHeight = (int)g.MeasureString(title, fTitle, printArea.Width).Height;
|
---|
| 194 | printArea.Y += titleHeight;
|
---|
| 195 | printArea.Height -= titleHeight;
|
---|
| 196 |
|
---|
| 197 | // draw underline
|
---|
| 198 | g.DrawLine(Pens.Black, printArea.Location, new Point(printArea.Right, printArea.Y));
|
---|
| 199 | printArea.Y += 15;
|
---|
| 200 | printArea.Height -= 15;
|
---|
| 201 |
|
---|
[789] | 202 | // write appointment date
|
---|
| 203 | string str = "Appointment Date: " + ptRow.OldApptDate + "\n\n";
|
---|
| 204 | g.DrawString(str, fBody, Brushes.Black, printArea);
|
---|
| 205 |
|
---|
| 206 | // move down
|
---|
| 207 | int strHeight = (int)g.MeasureString(str, fBody, printArea.Width).Height;
|
---|
| 208 | printArea.Y += strHeight;
|
---|
| 209 | printArea.Height -= strHeight;
|
---|
| 210 |
|
---|
[788] | 211 | // write missive
|
---|
| 212 | g.DrawString(letter, fBody, Brushes.Black, printArea);
|
---|
| 213 |
|
---|
| 214 | //print Address in lower left corner for windowed envolopes
|
---|
| 215 | printArea.Location = new Point(e.MarginBounds.X, (int)(e.PageBounds.Height * 0.66));
|
---|
| 216 | printArea.Height = (int)(e.MarginBounds.Height * 0.20);
|
---|
| 217 | sf.Alignment = StringAlignment.Near;
|
---|
| 218 | sf.LineAlignment = StringAlignment.Center;
|
---|
| 219 | StringBuilder address = new StringBuilder(100);
|
---|
| 220 | address.AppendLine(ptRow.Name);
|
---|
| 221 | address.AppendLine(ptRow.STREET);
|
---|
| 222 | address.AppendLine(ptRow.CITY + ", " + ptRow.STATE + " " + ptRow.ZIP);
|
---|
| 223 | g.DrawString(address.ToString(), fBody, Brushes.Black, printArea, sf);
|
---|
| 224 | }
|
---|
| 225 |
|
---|
[789] | 226 | /// <summary>
|
---|
| 227 | /// Print rebook letters. Prints old and new appointments dates then the missive.
|
---|
| 228 | /// </summary>
|
---|
| 229 | /// <param name="ptRow">Strongly typed appointment row</param>
|
---|
| 230 | /// <param name="e">etc</param>
|
---|
| 231 | /// <param name="letter">Text of the letter to print</param>
|
---|
| 232 | /// <param name="title">Title to print at the top of the letter</param>
|
---|
| 233 | public static void PrintRebookLetter(dsRebookAppts.PatientApptsRow ptRow, PrintPageEventArgs e, string letter, string title)
|
---|
| 234 | {
|
---|
| 235 | Rectangle printArea = e.MarginBounds;
|
---|
| 236 | Graphics g = e.Graphics;
|
---|
| 237 | StringFormat sf = new StringFormat();
|
---|
| 238 | sf.Alignment = StringAlignment.Center; //for title
|
---|
| 239 | Font fTitle = new Font(FontFamily.GenericSerif, 24, FontStyle.Bold); //for title
|
---|
| 240 | Font fBody = new Font(FontFamily.GenericSerif, 12);
|
---|
| 241 | g.DrawString(title, fTitle, Brushes.Black, printArea, sf); //title
|
---|
| 242 |
|
---|
| 243 | // move down
|
---|
| 244 | int titleHeight = (int)g.MeasureString(title, fTitle, printArea.Width).Height;
|
---|
| 245 | printArea.Y += titleHeight;
|
---|
| 246 | printArea.Height -= titleHeight;
|
---|
| 247 |
|
---|
| 248 | // draw underline
|
---|
| 249 | g.DrawLine(Pens.Black, printArea.Location, new Point(printArea.Right, printArea.Y));
|
---|
| 250 | printArea.Y += 15;
|
---|
| 251 | printArea.Height -= 15;
|
---|
| 252 |
|
---|
| 253 | // write old and new appointment dates
|
---|
| 254 | string str = "Old Appointment Date:\t\t" + ptRow.OldApptDate + "\n";
|
---|
| 255 | str += "New Appointment Date:\t\t" + ptRow.NewApptDate + "\n\n";
|
---|
| 256 | g.DrawString(str, fBody, Brushes.Black, printArea);
|
---|
| 257 |
|
---|
| 258 | // move down
|
---|
| 259 | int strHeight = (int)g.MeasureString(str, fBody, printArea.Width).Height;
|
---|
| 260 | printArea.Y += strHeight;
|
---|
| 261 | printArea.Height -= strHeight;
|
---|
| 262 |
|
---|
| 263 | // write missive
|
---|
| 264 | g.DrawString(letter, fBody, Brushes.Black, printArea);
|
---|
| 265 |
|
---|
| 266 | //print Address in lower left corner for windowed envolopes
|
---|
| 267 | printArea.Location = new Point(e.MarginBounds.X, (int)(e.PageBounds.Height * 0.66));
|
---|
| 268 | printArea.Height = (int)(e.MarginBounds.Height * 0.20);
|
---|
| 269 | sf.Alignment = StringAlignment.Near;
|
---|
| 270 | sf.LineAlignment = StringAlignment.Center;
|
---|
| 271 | StringBuilder address = new StringBuilder(100);
|
---|
| 272 | address.AppendLine(ptRow.Name);
|
---|
| 273 | address.AppendLine(ptRow.STREET);
|
---|
| 274 | address.AppendLine(ptRow.CITY + ", " + ptRow.STATE + " " + ptRow.ZIP);
|
---|
| 275 | g.DrawString(address.ToString(), fBody, Brushes.Black, printArea, sf);
|
---|
| 276 |
|
---|
| 277 | }
|
---|
| 278 |
|
---|
| 279 | /// <summary>
|
---|
| 280 | /// Print message on a page; typically that there are no appointments to be found.
|
---|
| 281 | /// </summary>
|
---|
| 282 | /// <param name="msg">The exact string to print.</param>
|
---|
| 283 | /// <param name="e">Print Page event args</param>
|
---|
[788] | 284 | public static void PrintMessage(string msg, PrintPageEventArgs e)
|
---|
| 285 | {
|
---|
| 286 | e.Graphics.DrawString(msg, new Font(FontFamily.GenericSerif, 14),
|
---|
| 287 | Brushes.Black, e.MarginBounds);
|
---|
| 288 | }
|
---|
| 289 |
|
---|
[772] | 290 | }
|
---|
| 291 | }
|
---|