| 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> | 
|---|
| 23 | /// <param name="end">End Datetime to print appointments</param> | 
|---|
| 24 | /// <remarks>beg and end have no effect on operation--they are there for documentation for user only</remarks> | 
|---|
| 25 | public static void PrintAppointments(dsPatientApptDisplay2 ds, PrintPageEventArgs e, DateTime beg, DateTime end, | 
|---|
| 26 | int resourceToPrint, ref int apptPrinted) | 
|---|
| 27 | { | 
|---|
| 28 | Graphics g = e.Graphics; | 
|---|
| 29 | //g.PageUnit = GraphicsUnit.Millimeter; | 
|---|
| 30 | //SizeF szVCB = g.VisibleClipBounds.Size; | 
|---|
| 31 | //PointF[] ptszVCB = {new PointF(szVCB.Width,szVCB.Height)}; | 
|---|
| 32 | //g.TransformPoints(CoordinateSpace.Page, CoordinateSpace.Device, ptszVCB); | 
|---|
| 33 | //Create Fonts | 
|---|
| 34 | Font f8 = new Font(FontFamily.GenericSerif, 8); | 
|---|
| 35 | Font f10 = new Font(FontFamily.GenericSerif, 10); | 
|---|
| 36 | Font f14bold = new Font(FontFamily.GenericSerif, 14, FontStyle.Bold); | 
|---|
| 37 |  | 
|---|
| 38 | //Center Alignment for some stuff | 
|---|
| 39 | StringFormat sf = new StringFormat(); | 
|---|
| 40 | sf.Alignment = StringAlignment.Center; | 
|---|
| 41 |  | 
|---|
| 42 | g.DrawString("Confidential Patient Information", f8, Brushes.Black, e.PageBounds, sf); | 
|---|
| 43 |  | 
|---|
| 44 | //Typical manipulable print area | 
|---|
| 45 | Rectangle printArea = e.MarginBounds; | 
|---|
| 46 |  | 
|---|
| 47 | dsPatientApptDisplay2.BSDXResourceRow r = ds.BSDXResource[resourceToPrint]; | 
|---|
| 48 |  | 
|---|
| 49 | string toprint; | 
|---|
| 50 | if (beg == end) toprint = "Appointments for " + r.RESOURCE_NAME + " on " + beg.ToLongDateString(); | 
|---|
| 51 | else toprint = "Appointments for " + r.RESOURCE_NAME + " from " + beg.ToShortDateString() + " to " | 
|---|
| 52 | + end.ToShortDateString(); | 
|---|
| 53 | g.DrawString(toprint, f14bold, Brushes.Black, printArea); | 
|---|
| 54 |  | 
|---|
| 55 | printArea.Y += (int)f14bold.GetHeight(); | 
|---|
| 56 | g.DrawLine(new Pen(Brushes.Black, 0), printArea.X, printArea.Y, printArea.X + printArea.Width, printArea.Y); | 
|---|
| 57 | printArea.Y += 5; | 
|---|
| 58 |  | 
|---|
| 59 | System.Data.DataRow[] appts = r.GetChildRows(ds.Relations[0]); //only one relation | 
|---|
| 60 |  | 
|---|
| 61 | toprint = ""; | 
|---|
| 62 | StringFormat sf2 = new StringFormat(); | 
|---|
| 63 | sf2.SetTabStops(50, new float[] { 100, 200, 200 }); | 
|---|
| 64 |  | 
|---|
| 65 | foreach (dsPatientApptDisplay2.PatientApptsRow a in appts) | 
|---|
| 66 | { | 
|---|
| 67 | toprint += a.ApptDate.ToString() + "\t" + a.Name +"(" + a.Sex + ")" + "\t" + "DOB: " + a.DOB.ToString("dd-MMM-yyyy") + "\t" + "ID: " + a.HRN; | 
|---|
| 68 | toprint += "\n"; | 
|---|
| 69 | toprint += "Home Phone: " + a.HOMEPHONE + "\t" + "Address: " + a.STREET + ", " + a.CITY + ", " + a.STATE + " " + a.ZIP; | 
|---|
| 70 | toprint += "\n"; | 
|---|
| 71 | toprint += "Note: " + a.NOTE; | 
|---|
| 72 | toprint += "\n"; | 
|---|
| 73 | toprint += "Appointment made by " + a.APPT_MADE_BY + " on " + a.DATE_APPT_MADE; | 
|---|
| 74 | toprint += "\n\n"; | 
|---|
| 75 | } | 
|---|
| 76 | g.DrawString(toprint, f10, Brushes.Black, printArea, sf2); | 
|---|
| 77 | } | 
|---|
| 78 | } | 
|---|
| 79 | } | 
|---|