Index: /Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocument.cs
===================================================================
--- /Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocument.cs	(revision 1109)
+++ /Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocument.cs	(revision 1110)
@@ -177,5 +177,5 @@
         /// <returns>Clears and repopluates m_appointments</returns>
         /// </summary>
-        private bool RefreshDaysSchedule()
+        private bool RefreshAppointments()
         {
             try
@@ -239,5 +239,16 @@
                     bWalkIn = (sWalkIn == "1") ? true : false;
 
+                    Patient pt = new Patient()
+                    {
+                        DFN = Convert.ToInt32(sPatientID),
+                        Name = sPatientName,
+                        DOB = (DateTime)r["DOB"],
+                        ID = r["PID"].ToString(), 
+                        HRN = sHRN,
+                        Sex = r["SEX"].ToString() == "MALE" ? Sex.Male : Sex.Female
+                    };
+
                     pAppointment = new CGAppointment();
+                    pAppointment.Patient = pt;
                     pAppointment.CreateAppointment(dStart, dEnd, sNote, nKeyID, sResource);
                     pAppointment.PatientName = sPatientName;
@@ -396,5 +407,5 @@
         {
             this.RefreshAvailabilitySchedule();
-            this.RefreshDaysSchedule();
+            this.RefreshAppointments();
             return true;
         }
Index: /Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocumentManager.cs
===================================================================
--- /Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocumentManager.cs	(revision 1109)
+++ /Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocumentManager.cs	(revision 1110)
@@ -42,5 +42,5 @@
 
         //Custom Printing
-        private CustomPrinting                          m_PrintingObject = null; 
+        private Printing                          m_PrintingObject = null; 
 		#endregion
 
@@ -134,5 +134,5 @@
         }
 
-        public CustomPrinting PrintingObject
+        public Printing PrintingObject
         {
             get
@@ -445,5 +445,5 @@
             if (DllLocation == string.Empty)
             {
-                this.m_PrintingObject = new CustomPrinting();
+                this.m_PrintingObject = new Printing();
             }
             else
Index: /Scheduling/trunk/cs/bsdx0200GUISourceCode/CGView.cs
===================================================================
--- /Scheduling/trunk/cs/bsdx0200GUISourceCode/CGView.cs	(revision 1109)
+++ /Scheduling/trunk/cs/bsdx0200GUISourceCode/CGView.cs	(revision 1110)
@@ -1,4 +1,3 @@
 using System;
-using System.Drawing;
 using System.Collections;
 using System.ComponentModel;
@@ -9,4 +8,5 @@
 using IndianHealthService.BMXNet;
 using System.Runtime.InteropServices;
+using System.Drawing.Printing;
 
 namespace IndianHealthService.ClinicalScheduling
@@ -97,7 +97,6 @@
 		private System.Windows.Forms.MenuItem mnuDisplayWalkIns;
         private System.Windows.Forms.MenuItem mnuRPMSDivision;
-        private System.Drawing.Printing.PrintDocument printRoutingSlip;
         private MenuItem menuItem10;
-        private MenuItem ctxCalGridReprintRoutingSlip;
+        private MenuItem ctxCalGridReprintApptSlip;
         private IContainer components;
 
@@ -233,4 +232,5 @@
             this.lblResource = new System.Windows.Forms.Label();
             this.panelCenter = new System.Windows.Forms.Panel();
+            this.calendarGrid1 = new IndianHealthService.ClinicalScheduling.CalendarGrid();
             this.ctxCalendarGrid = new System.Windows.Forms.ContextMenu();
             this.ctxCalGridAdd = new System.Windows.Forms.MenuItem();
@@ -244,11 +244,9 @@
             this.ctxCalGridWalkin = new System.Windows.Forms.MenuItem();
             this.menuItem10 = new System.Windows.Forms.MenuItem();
-            this.ctxCalGridReprintRoutingSlip = new System.Windows.Forms.MenuItem();
+            this.ctxCalGridReprintApptSlip = new System.Windows.Forms.MenuItem();
             this.panelBottom = new System.Windows.Forms.Panel();
             this.statusBar1 = new System.Windows.Forms.StatusBar();
             this.splitter1 = new System.Windows.Forms.Splitter();
             this.splitter2 = new System.Windows.Forms.Splitter();
-            this.printRoutingSlip = new System.Drawing.Printing.PrintDocument();
-            this.calendarGrid1 = new IndianHealthService.ClinicalScheduling.CalendarGrid();
             this.panelRight.SuspendLayout();
             this.panelClip.SuspendLayout();
@@ -763,123 +761,4 @@
             this.panelCenter.Size = new System.Drawing.Size(857, 345);
             this.panelCenter.TabIndex = 7;
-            // 
-            // ctxCalendarGrid
-            // 
-            this.ctxCalendarGrid.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
-            this.ctxCalGridAdd,
-            this.ctxCalGridEdit,
-            this.ctxCalGridDelete,
-            this.ctxCalGridCheckIn,
-            this.menuItem2,
-            this.ctxCalGridNoShow,
-            this.ctxCalGridNoShowUndo,
-            this.menuItem9,
-            this.ctxCalGridWalkin,
-            this.menuItem10,
-            this.ctxCalGridReprintRoutingSlip});
-            this.ctxCalendarGrid.Popup += new System.EventHandler(this.ctxCalendarGrid_Popup);
-            // 
-            // ctxCalGridAdd
-            // 
-            this.ctxCalGridAdd.Index = 0;
-            this.ctxCalGridAdd.Text = "Add Appointment";
-            this.ctxCalGridAdd.Click += new System.EventHandler(this.ctxCalGridAdd_Click);
-            // 
-            // ctxCalGridEdit
-            // 
-            this.ctxCalGridEdit.Index = 1;
-            this.ctxCalGridEdit.Text = "Edit Appointment";
-            this.ctxCalGridEdit.Click += new System.EventHandler(this.ctxCalGridEdit_Click);
-            // 
-            // ctxCalGridDelete
-            // 
-            this.ctxCalGridDelete.Index = 2;
-            this.ctxCalGridDelete.Text = "Cancel Appointment";
-            this.ctxCalGridDelete.Click += new System.EventHandler(this.ctxCalGridDelete_Click);
-            // 
-            // ctxCalGridCheckIn
-            // 
-            this.ctxCalGridCheckIn.Index = 3;
-            this.ctxCalGridCheckIn.Text = "Check In Patient";
-            this.ctxCalGridCheckIn.Click += new System.EventHandler(this.ctxCalGridCheckIn_Click);
-            // 
-            // menuItem2
-            // 
-            this.menuItem2.Index = 4;
-            this.menuItem2.Text = "-";
-            // 
-            // ctxCalGridNoShow
-            // 
-            this.ctxCalGridNoShow.Index = 5;
-            this.ctxCalGridNoShow.Text = "Mark as No Show";
-            this.ctxCalGridNoShow.Click += new System.EventHandler(this.ctxCalGridNoShow_Click);
-            // 
-            // ctxCalGridNoShowUndo
-            // 
-            this.ctxCalGridNoShowUndo.Index = 6;
-            this.ctxCalGridNoShowUndo.Text = "Undo NoShow";
-            this.ctxCalGridNoShowUndo.Click += new System.EventHandler(this.ctxCalGridNoShowUndo_Click);
-            // 
-            // menuItem9
-            // 
-            this.menuItem9.Index = 7;
-            this.menuItem9.Text = "-";
-            // 
-            // ctxCalGridWalkin
-            // 
-            this.ctxCalGridWalkin.Index = 8;
-            this.ctxCalGridWalkin.Text = "Create Wal&k-In Appointment";
-            this.ctxCalGridWalkin.Click += new System.EventHandler(this.ctxCalGridWalkin_Click);
-            // 
-            // menuItem10
-            // 
-            this.menuItem10.Index = 9;
-            this.menuItem10.Text = "-";
-            // 
-            // ctxCalGridReprintRoutingSlip
-            // 
-            this.ctxCalGridReprintRoutingSlip.Index = 10;
-            this.ctxCalGridReprintRoutingSlip.Text = "&Reprint Routing Slip";
-            this.ctxCalGridReprintRoutingSlip.Click += new System.EventHandler(this.ctxCalGridReprintRoutingSlip_Click);
-            // 
-            // panelBottom
-            // 
-            this.panelBottom.Controls.Add(this.statusBar1);
-            this.panelBottom.Dock = System.Windows.Forms.DockStyle.Bottom;
-            this.panelBottom.Location = new System.Drawing.Point(136, 369);
-            this.panelBottom.Name = "panelBottom";
-            this.panelBottom.Size = new System.Drawing.Size(857, 24);
-            this.panelBottom.TabIndex = 8;
-            // 
-            // statusBar1
-            // 
-            this.statusBar1.Dock = System.Windows.Forms.DockStyle.Fill;
-            this.statusBar1.Location = new System.Drawing.Point(0, 0);
-            this.statusBar1.Name = "statusBar1";
-            this.statusBar1.Size = new System.Drawing.Size(857, 24);
-            this.statusBar1.SizingGrip = false;
-            this.statusBar1.TabIndex = 0;
-            // 
-            // splitter1
-            // 
-            this.splitter1.Location = new System.Drawing.Point(128, 24);
-            this.splitter1.Name = "splitter1";
-            this.splitter1.Size = new System.Drawing.Size(8, 369);
-            this.splitter1.TabIndex = 9;
-            this.splitter1.TabStop = false;
-            // 
-            // splitter2
-            // 
-            this.splitter2.Dock = System.Windows.Forms.DockStyle.Right;
-            this.splitter2.Location = new System.Drawing.Point(993, 24);
-            this.splitter2.Name = "splitter2";
-            this.splitter2.Size = new System.Drawing.Size(3, 369);
-            this.splitter2.TabIndex = 10;
-            this.splitter2.TabStop = false;
-            // 
-            // printRoutingSlip
-            // 
-            this.printRoutingSlip.DocumentName = "Routing Slip";
-            this.printRoutingSlip.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.printRoutingSlip_PrintPage);
             // 
             // calendarGrid1
@@ -912,4 +791,118 @@
             this.calendarGrid1.MouseEnter += new System.EventHandler(this.calendarGrid1_MouseEnter);
             // 
+            // ctxCalendarGrid
+            // 
+            this.ctxCalendarGrid.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
+            this.ctxCalGridAdd,
+            this.ctxCalGridEdit,
+            this.ctxCalGridDelete,
+            this.ctxCalGridCheckIn,
+            this.menuItem2,
+            this.ctxCalGridNoShow,
+            this.ctxCalGridNoShowUndo,
+            this.menuItem9,
+            this.ctxCalGridWalkin,
+            this.menuItem10,
+            this.ctxCalGridReprintApptSlip});
+            this.ctxCalendarGrid.Popup += new System.EventHandler(this.ctxCalendarGrid_Popup);
+            // 
+            // ctxCalGridAdd
+            // 
+            this.ctxCalGridAdd.Index = 0;
+            this.ctxCalGridAdd.Text = "Add Appointment";
+            this.ctxCalGridAdd.Click += new System.EventHandler(this.ctxCalGridAdd_Click);
+            // 
+            // ctxCalGridEdit
+            // 
+            this.ctxCalGridEdit.Index = 1;
+            this.ctxCalGridEdit.Text = "Edit Appointment";
+            this.ctxCalGridEdit.Click += new System.EventHandler(this.ctxCalGridEdit_Click);
+            // 
+            // ctxCalGridDelete
+            // 
+            this.ctxCalGridDelete.Index = 2;
+            this.ctxCalGridDelete.Text = "Cancel Appointment";
+            this.ctxCalGridDelete.Click += new System.EventHandler(this.ctxCalGridDelete_Click);
+            // 
+            // ctxCalGridCheckIn
+            // 
+            this.ctxCalGridCheckIn.Index = 3;
+            this.ctxCalGridCheckIn.Text = "Check In Patient";
+            this.ctxCalGridCheckIn.Click += new System.EventHandler(this.ctxCalGridCheckIn_Click);
+            // 
+            // menuItem2
+            // 
+            this.menuItem2.Index = 4;
+            this.menuItem2.Text = "-";
+            // 
+            // ctxCalGridNoShow
+            // 
+            this.ctxCalGridNoShow.Index = 5;
+            this.ctxCalGridNoShow.Text = "Mark as No Show";
+            this.ctxCalGridNoShow.Click += new System.EventHandler(this.ctxCalGridNoShow_Click);
+            // 
+            // ctxCalGridNoShowUndo
+            // 
+            this.ctxCalGridNoShowUndo.Index = 6;
+            this.ctxCalGridNoShowUndo.Text = "Undo NoShow";
+            this.ctxCalGridNoShowUndo.Click += new System.EventHandler(this.ctxCalGridNoShowUndo_Click);
+            // 
+            // menuItem9
+            // 
+            this.menuItem9.Index = 7;
+            this.menuItem9.Text = "-";
+            // 
+            // ctxCalGridWalkin
+            // 
+            this.ctxCalGridWalkin.Index = 8;
+            this.ctxCalGridWalkin.Text = "Create Wal&k-In Appointment";
+            this.ctxCalGridWalkin.Click += new System.EventHandler(this.ctxCalGridWalkin_Click);
+            // 
+            // menuItem10
+            // 
+            this.menuItem10.Index = 9;
+            this.menuItem10.Text = "-";
+            // 
+            // ctxCalGridReprintApptSlip
+            // 
+            this.ctxCalGridReprintApptSlip.Index = 10;
+            this.ctxCalGridReprintApptSlip.Text = "&Reprint Appointment Slip";
+            this.ctxCalGridReprintApptSlip.Click += new System.EventHandler(this.ctxCalGridReprintApptSlip_Click);
+            // 
+            // panelBottom
+            // 
+            this.panelBottom.Controls.Add(this.statusBar1);
+            this.panelBottom.Dock = System.Windows.Forms.DockStyle.Bottom;
+            this.panelBottom.Location = new System.Drawing.Point(136, 369);
+            this.panelBottom.Name = "panelBottom";
+            this.panelBottom.Size = new System.Drawing.Size(857, 24);
+            this.panelBottom.TabIndex = 8;
+            // 
+            // statusBar1
+            // 
+            this.statusBar1.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.statusBar1.Location = new System.Drawing.Point(0, 0);
+            this.statusBar1.Name = "statusBar1";
+            this.statusBar1.Size = new System.Drawing.Size(857, 24);
+            this.statusBar1.SizingGrip = false;
+            this.statusBar1.TabIndex = 0;
+            // 
+            // splitter1
+            // 
+            this.splitter1.Location = new System.Drawing.Point(128, 24);
+            this.splitter1.Name = "splitter1";
+            this.splitter1.Size = new System.Drawing.Size(8, 369);
+            this.splitter1.TabIndex = 9;
+            this.splitter1.TabStop = false;
+            // 
+            // splitter2
+            // 
+            this.splitter2.Dock = System.Windows.Forms.DockStyle.Right;
+            this.splitter2.Location = new System.Drawing.Point(993, 24);
+            this.splitter2.Name = "splitter2";
+            this.splitter2.Size = new System.Drawing.Size(3, 369);
+            this.splitter2.TabIndex = 10;
+            this.splitter2.TabStop = false;
+            // 
             // CGView
             // 
@@ -1224,5 +1217,5 @@
 			ctxCalGridWalkin.Enabled = ctxCalGridAdd.Enabled;
             //smh new code
-            ctxCalGridReprintRoutingSlip.Enabled = ctxCalGridEdit.Enabled;
+            ctxCalGridReprintApptSlip.Enabled = ctxCalGridEdit.Enabled;
 		    //end new code
         }
@@ -1265,7 +1258,18 @@
 
         //new code smh
-        private void ctxCalGridReprintRoutingSlip_Click(object sender, EventArgs e)
+        private void ctxCalGridReprintApptSlip_Click(object sender, EventArgs e)
         {
-            printRoutingSlip.Print();
+            int apptID = this.CGrid.SelectedAppointment;
+            if (apptID <= 0) return;
+
+            CGAppointment a = (CGAppointment) this.Appointments.AppointmentTable[apptID];
+            
+            PrintDocument pd = new PrintDocument() { DocumentName = "Appointment Slip for Appt " + apptID };  //Autoinit for DocName
+            pd.PrintPage += (s, pe) =>  //son of a lambda
+            {
+                CGDocumentManager.Current.PrintingObject.PrintAppointmentSlip(a, pe);
+            };
+            
+            pd.Print();
         }
         //end new code
@@ -1996,5 +2000,5 @@
                 //smh new code
                 if (dlgCheckin.PrintRouteSlip)
-                    this.printRoutingSlip.Print();
+                 //   this.printRoutingSlip.Print();
                 // end new code
 
@@ -3247,5 +3251,5 @@
             int nApptID = this.calendarGrid1.SelectedAppointment;
             CGAppointment a = (CGAppointment)this.Appointments.AppointmentTable[nApptID];
-            ClinicalScheduling.Printing.PrintRoutingSlip(a, "Routing Slip", e);
+            CGDocumentManager.Current.PrintingObject.PrintRoutingSlip(a, "Routing Slip", e);
         }
 
Index: /Scheduling/trunk/cs/bsdx0200GUISourceCode/CGView.resx
===================================================================
--- /Scheduling/trunk/cs/bsdx0200GUISourceCode/CGView.resx	(revision 1109)
+++ /Scheduling/trunk/cs/bsdx0200GUISourceCode/CGView.resx	(revision 1110)
@@ -136,7 +136,4 @@
 </value>
   </data>
-  <metadata name="printRoutingSlip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
-    <value>512, 17</value>
-  </metadata>
   <metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>75</value>
Index: /Scheduling/trunk/cs/bsdx0200GUISourceCode/ClinicalScheduling.csproj
===================================================================
--- /Scheduling/trunk/cs/bsdx0200GUISourceCode/ClinicalScheduling.csproj	(revision 1109)
+++ /Scheduling/trunk/cs/bsdx0200GUISourceCode/ClinicalScheduling.csproj	(revision 1110)
@@ -303,5 +303,4 @@
     <Compile Include="Options.cs" />
     <Compile Include="Patient.cs" />
-    <Compile Include="Printing.cs" />
     <Compile Include="UCPatientAppts.cs">
       <SubType>UserControl</SubType>
Index: heduling/trunk/cs/bsdx0200GUISourceCode/CustomPrinting.cs
===================================================================
--- /Scheduling/trunk/cs/bsdx0200GUISourceCode/CustomPrinting.cs	(revision 1109)
+++ 	(revision )
@@ -1,387 +1,0 @@
-﻿using System;
-using System.Drawing.Printing;
-using System.Drawing;
-using System.Text;
-
-namespace IndianHealthService.ClinicalScheduling
-{
-    public class CustomPrinting
-    { 
-        /// <summary>
-        /// Print Appointments
-        /// </summary>
-        /// <param name="ds">Strongly Typed DataSet contains Resources and Appointments</param>
-        /// <param name="e">PrintPageEventArgs from PrintDocument Print handler</param>
-        /// <param name="beg">Begin Datetime to print appointments</param>
-        /// <param name="end">End Datetime to print appointments</param
-        /// <param name="resourceToPrint">The resouce to print</param>
-        /// <param name="apptPrinting">Current Appointment printing</param>
-        /// <param name="pageNumber">Current page number</param>
-        /// <remarks>beg and end have no effect on operation--they are there for documentation for user only</remarks>
-        public virtual void PrintAppointments(dsPatientApptDisplay2 ds, PrintPageEventArgs e, DateTime beg, DateTime end, int resourceToPrint, ref int apptPrinting, int pageNumber)
-        {
-            Graphics g = e.Graphics;
-            //g.PageUnit = GraphicsUnit.Millimeter;
-            //SizeF szVCB = g.VisibleClipBounds.Size;
-            //PointF[] ptszVCB = {new PointF(szVCB.Width,szVCB.Height)};
-            //g.TransformPoints(CoordinateSpace.Page, CoordinateSpace.Device, ptszVCB);
-            //Create Fonts
-            Font f8 = new Font(FontFamily.GenericSerif, 8);
-            Font f10 = new Font(FontFamily.GenericSerif, 10);
-            Font f14bold = new Font(FontFamily.GenericSerif, 14, FontStyle.Bold);
-            
-            //Center Alignment for some stuff
-            StringFormat sf = new StringFormat();
-            sf.Alignment = StringAlignment.Center;
-            
-            //Header
-            g.DrawString("Confidential Patient Information", f8, Brushes.Black, e.PageBounds, sf);
-            
-            //Footer
-            sf.Alignment = StringAlignment.Center;
-            sf.LineAlignment = StringAlignment.Far;
-            g.DrawString("Page " + pageNumber, f8, Brushes.Black, e.PageBounds, sf);
-
-            //Typical manipulable print area
-            Rectangle printArea = e.MarginBounds;
-            
-            //resource we want to print
-            dsPatientApptDisplay2.BSDXResourceRow r = ds.BSDXResource[resourceToPrint];
-            
-            //header
-            string toprint;
-            if (beg == end) toprint = "Appointments for " + r.RESOURCE_NAME + " on " + beg.ToLongDateString();
-            else toprint = "Appointments for " + r.RESOURCE_NAME + " from " + beg.ToShortDateString() + " to "
-                + end.ToShortDateString();
-            g.DrawString(toprint, f14bold, Brushes.Black, printArea);
-            
-            //Move print area down
-            printArea.Height -= (int)f14bold.GetHeight();
-            printArea.Y += (int)f14bold.GetHeight();
-
-            //Draw Line
-            g.DrawLine(new Pen(Brushes.Black, 0), printArea.X, printArea.Y, printArea.X + printArea.Width, printArea.Y);
-            
-            //Move print area down
-            printArea.Y += 5; 
-            printArea.Height -= 5;
-            
-            System.Data.DataRow[] appts = r.GetChildRows(ds.Relations[0]); //ds has only one relation 
-
-            StringFormat sf2 = new StringFormat();                 //sf to hold tab stops
-            sf2.SetTabStops(50, new float[] { 100, 250, 25 });     
-
-            //appt printed starts at zero
-            while (apptPrinting < appts.Length)
-            {
-                dsPatientApptDisplay2.PatientApptsRow a = (dsPatientApptDisplay2.PatientApptsRow)appts[apptPrinting];
-                
-                StringBuilder apptPrintStr = new StringBuilder(200); 
-                apptPrintStr.AppendLine(a.ApptDate.ToString() + "\t" + a.Name + " (" + a.Sex + ")" + "\t" + "DOB: " + a.DOB.ToShortDateString() + "\t" + "ID: " + a.HRN);
-                apptPrintStr.AppendLine("P: " + a.HOMEPHONE + "\t" + "Address: " + a.STREET + ", " + a.CITY + ", " + a.STATE + " " + a.ZIP);
-                apptPrintStr.AppendLine("Note: " + a.NOTE);
-                apptPrintStr.AppendLine("Appointment made by " + a.APPT_MADE_BY + " on " + a.DATE_APPT_MADE);
-
-                int printedApptHeight = (int)g.MeasureString(apptPrintStr.ToString(), f10, printArea.Width).Height;
-                if (printedApptHeight > printArea.Height) // too much to print -- move to next page
-                    // but don't increment the appointment to print since we haven't printed it yet.
-                    // i.e. apptPrinting stays the same.
-                {
-                    e.HasMorePages = true;
-                    break;
-                }
-   
-                //otherwise print it
-                g.DrawString(apptPrintStr.ToString(), f10, Brushes.Black, printArea, sf2);
-                
-                //Move print area down
-                printArea.Y += printedApptHeight + 3;
-                printArea.Height -= printedApptHeight + 3;
-
-                //Draw a divider line
-                Point pt1 = new Point((int)(printArea.X + printArea.Width * 0.25), printArea.Y);
-                Point pt2 = new Point((int)(printArea.X + printArea.Width * 0.75), printArea.Y);
-                g.DrawLine(Pens.Gray, pt1, pt2);
-
-                //move down, again
-                printArea.Y += 3;
-                printArea.Height -= 3;
-
-                //go to the next appointment
-                apptPrinting++;
-            }
-        }
-
-        /// <summary>
-        /// Prints a single appointment slip to give to the patient
-        /// </summary>
-        /// <param name="appt">The Appointment to print</param>
-        /// <param name="e">PrintPageEventArgs from PrintDocument Print handler</param>
-        public virtual void PrintAppointmentSlip(CGAppointment appt, PrintPageEventArgs e)
-        {
-            Rectangle printArea = e.MarginBounds;
-            Graphics g = e.Graphics;
-            StringFormat sf = new StringFormat();
-            sf.Alignment = StringAlignment.Center; //for title
-            Font fTitle = new Font(FontFamily.GenericSerif, 24, FontStyle.Bold); //for title
-            Font fBody = new Font(FontFamily.GenericSerif, 12);
-            string s = "Appointment Reminder Slip";
-            g.DrawString(s, fTitle, Brushes.Black, printArea, sf); //title
-
-            // move down
-            int titleHeight = (int)g.MeasureString(s, fTitle, printArea.Width).Height;
-            printArea.Y += titleHeight;
-            printArea.Height -= titleHeight;
-
-            // draw underline
-            g.DrawLine(Pens.Black, printArea.Location, new Point(printArea.Right, printArea.Y));
-            printArea.Y += 15;
-            printArea.Height -= 15;
-
-
-
-        }
-
-
-        /// <summary>
-        /// Print Letter to be given or mailed to the patient
-        /// </summary>
-        /// <param name="ptrow">Strongly typed PatientApptsRow to pass (just one ApptRow)</param>
-        /// <param name="e">You know what that is</param>
-        /// <param name="letter">Contains letter string</param>
-        /// <param name="title">Title of the letter</param>
-        public virtual void PrintReminderLetter(dsPatientApptDisplay2.PatientApptsRow ptRow, PrintPageEventArgs e, string letter, string title)
-        {
-
-            Rectangle printArea = e.MarginBounds;
-            Graphics g = e.Graphics;
-            StringFormat sf = new StringFormat();
-            sf.Alignment = StringAlignment.Center; //for title
-            Font fTitle = new Font(FontFamily.GenericSerif, 24, FontStyle.Bold); //for title
-            Font fBody = new Font(FontFamily.GenericSerif, 12);
-            g.DrawString(title, fTitle, Brushes.Black, printArea, sf); //title
-
-            // move down
-            int titleHeight = (int)g.MeasureString(title, fTitle, printArea.Width).Height;
-            printArea.Y += titleHeight;
-            printArea.Height -= titleHeight;
-            
-            // draw underline
-            g.DrawLine(Pens.Black, printArea.Location, new Point(printArea.Right, printArea.Y));
-            printArea.Y += 15;
-            printArea.Height -= 15;
-
-            // write appointment date
-            string str = "Appointment Date: " + ptRow.ApptDate + "\n\n";
-            g.DrawString(str, fBody, Brushes.Black, printArea);
-
-            // move down
-            int strHeight = (int)g.MeasureString(str, fBody, printArea.Width).Height;
-            printArea.Y += strHeight;
-            printArea.Height -= strHeight;
-
-            //Text Direction
-            StringFormat sf2 = new StringFormat();
-            if (System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.IsRightToLeft)
-                sf2.FormatFlags = StringFormatFlags.DirectionRightToLeft;
-
-            // write missive
-            g.DrawString(letter, fBody, Brushes.Black, printArea, sf2);
-
-            //print Address in lower left corner for windowed envolopes
-            printArea.Location = new Point(e.MarginBounds.X, (int)(e.PageBounds.Height * 0.66));
-            printArea.Height = (int)(e.MarginBounds.Height * 0.20);
-            sf.Alignment = StringAlignment.Near;
-            sf.LineAlignment = StringAlignment.Center;
-            StringBuilder address = new StringBuilder(100);
-            address.AppendLine(ptRow.Name);
-            address.AppendLine(ptRow.STREET);
-            address.AppendLine(ptRow.CITY + ", " + ptRow.STATE + " " + ptRow.ZIP);
-            g.DrawString(address.ToString(), fBody, Brushes.Black, printArea, sf);
-        }
-       
-        /// <summary>
-        /// Cancellation Letter to be given or mailed to the patient
-        /// </summary>
-        /// <param name="ptRow">Strongly typed PatientApptsRow to pass (just one ApptRow)</param>
-        /// <param name="e">You know what that is</param>
-        /// <param name="letter">Contains letter string</param>
-        /// <param name="title">Title of the letter</param>
-        public virtual void PrintCancelLetter(dsRebookAppts.PatientApptsRow ptRow, PrintPageEventArgs e, string letter, string title)
-        {
-            Rectangle printArea = e.MarginBounds;
-            Graphics g = e.Graphics;
-            StringFormat sf = new StringFormat();
-            sf.Alignment = StringAlignment.Center; //for title
-            Font fTitle = new Font(FontFamily.GenericSerif, 24, FontStyle.Bold); //for title
-            Font fBody = new Font(FontFamily.GenericSerif, 12);
-            g.DrawString(title, fTitle, Brushes.Black, printArea, sf); //title
-
-            // move down
-            int titleHeight = (int)g.MeasureString(title, fTitle, printArea.Width).Height;
-            printArea.Y += titleHeight;
-            printArea.Height -= titleHeight;
-
-            // draw underline
-            g.DrawLine(Pens.Black, printArea.Location, new Point(printArea.Right, printArea.Y));
-            printArea.Y += 15;
-            printArea.Height -= 15;
-
-            // write appointment date
-            string str = "Appointment Date: " + ptRow.OldApptDate + "\n\n";
-            g.DrawString(str, fBody, Brushes.Black, printArea);
-
-            // move down
-            int strHeight = (int)g.MeasureString(str, fBody, printArea.Width).Height;
-            printArea.Y += strHeight;
-            printArea.Height -= strHeight;
-
-            //Text Direction
-            StringFormat sf2 = new StringFormat();
-            if (System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.IsRightToLeft)
-                sf2.FormatFlags = StringFormatFlags.DirectionRightToLeft;
-            
-            // write missive
-            g.DrawString(letter, fBody, Brushes.Black, printArea, sf2);
-
-            //print Address in lower left corner for windowed envolopes
-            printArea.Location = new Point(e.MarginBounds.X, (int)(e.PageBounds.Height * 0.66));
-            printArea.Height = (int)(e.MarginBounds.Height * 0.20);
-            sf.Alignment = StringAlignment.Near;
-            sf.LineAlignment = StringAlignment.Center;
-            StringBuilder address = new StringBuilder(100);
-            address.AppendLine(ptRow.Name);
-            address.AppendLine(ptRow.STREET);
-            address.AppendLine(ptRow.CITY + ", " + ptRow.STATE + " " + ptRow.ZIP);
-            g.DrawString(address.ToString(), fBody, Brushes.Black, printArea, sf);
-        }
-
-        /// <summary>
-        /// Print rebook letters. Prints old and new appointments dates then the missive.
-        /// </summary>
-        /// <param name="ptRow">Strongly typed appointment row</param>
-        /// <param name="e">etc</param>
-        /// <param name="letter">Text of the letter to print</param>
-        /// <param name="title">Title to print at the top of the letter</param>
-        public virtual void PrintRebookLetter(dsRebookAppts.PatientApptsRow ptRow, PrintPageEventArgs e, string letter, string title)
-        {
-            Rectangle printArea = e.MarginBounds;
-            Graphics g = e.Graphics;
-            StringFormat sf = new StringFormat();
-            sf.Alignment = StringAlignment.Center; //for title
-            Font fTitle = new Font(FontFamily.GenericSerif, 24, FontStyle.Bold); //for title
-            Font fBody = new Font(FontFamily.GenericSerif, 12);
-            g.DrawString(title, fTitle, Brushes.Black, printArea, sf); //title
-
-            // move down
-            int titleHeight = (int)g.MeasureString(title, fTitle, printArea.Width).Height;
-            printArea.Y += titleHeight;
-            printArea.Height -= titleHeight;
-
-            // draw underline
-            g.DrawLine(Pens.Black, printArea.Location, new Point(printArea.Right, printArea.Y));
-            printArea.Y += 15;
-            printArea.Height -= 15;
-
-            // write old and new appointment dates
-            string str = "Old Appointment Date:\t\t" + ptRow.OldApptDate + "\n";
-            str += "New Appointment Date:\t\t" + ptRow.NewApptDate + "\n\n";
-            g.DrawString(str, fBody, Brushes.Black, printArea);
-
-            // move down
-            int strHeight = (int)g.MeasureString(str, fBody, printArea.Width).Height;
-            printArea.Y += strHeight;
-            printArea.Height -= strHeight;
-
-            //Text Direction
-            StringFormat sf2 = new StringFormat();
-            if (System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.IsRightToLeft)
-                sf2.FormatFlags = StringFormatFlags.DirectionRightToLeft;
-
-            // write missive
-            g.DrawString(letter, fBody, Brushes.Black, printArea, sf2);
-
-            //print Address in lower left corner for windowed envolopes
-            printArea.Location = new Point(e.MarginBounds.X, (int)(e.PageBounds.Height * 0.66));
-            printArea.Height = (int)(e.MarginBounds.Height * 0.20);
-            sf.Alignment = StringAlignment.Near;
-            sf.LineAlignment = StringAlignment.Center;
-            StringBuilder address = new StringBuilder(100);
-            address.AppendLine(ptRow.Name);
-            address.AppendLine(ptRow.STREET);
-            address.AppendLine(ptRow.CITY + ", " + ptRow.STATE + " " + ptRow.ZIP);
-            g.DrawString(address.ToString(), fBody, Brushes.Black, printArea, sf);
-
-        }
-
-        /// <summary>
-        /// Print message on a page; typically that there are no appointments to be found.
-        /// Or just a test message to verify that printing works.
-        /// </summary>
-        /// <param name="msg">The exact string to print.</param>
-        /// <param name="e">Print Page event args</param>
-        public virtual void PrintMessage(string msg, PrintPageEventArgs e)
-        {
-            e.Graphics.DrawString(msg, new Font(FontFamily.GenericSerif, 14),
-                Brushes.Black, e.MarginBounds);
-        }
-
-        /// <summary>
-        /// Print Routing Slip
-        /// </summary>
-        /// <param name="a">Appointment Data Structure</param>
-        /// <param name="title">String to print for title</param>
-        /// <param name="e">etc</param>
-        public virtual void PrintRoutingSlip(CGAppointment a, string title, PrintPageEventArgs e)
-        {
-            Rectangle printArea = e.MarginBounds;
-            Graphics g = e.Graphics;
-            StringFormat sf = new StringFormat();
-            sf.Alignment = StringAlignment.Center; //for title
-            Font fTitle = new Font(FontFamily.GenericSerif, 24, FontStyle.Bold); //for title
-            Font fBody = new Font(FontFamily.GenericSerif, 18);
-            Font fBodyEm = new Font(FontFamily.GenericSerif, 18, FontStyle.Bold);
-            g.DrawString(title, fTitle, Brushes.Black, printArea, sf); //title
-
-            // move down
-            int titleHeight = (int)g.MeasureString(title, fTitle, printArea.Width).Height;
-            printArea.Y += titleHeight;
-            printArea.Height -= titleHeight;
-
-            // draw underline
-            g.DrawLine(Pens.Black, printArea.Location, new Point(printArea.Right, printArea.Y));
-
-            // move down
-            printArea.Y += 15;
-            printArea.Height -= 15;
-
-            //construct what to print
-            string toprint = "Patient: " + a.PatientName + "\t" + "ID: " + a.HealthRecordNumber;
-            toprint += "\n\n";
-            toprint += "Clinic: " + a.Resource;
-            toprint += "\n\n";
-            toprint += "Appointment Time: " + a.StartTime;
-            toprint += "\n\n";
-            toprint += "Notes:\n" + a.Note;
-
-            //print
-            g.DrawString(toprint, fBody, Brushes.Black, printArea);
-
-            // Print Date Printed
-            //sf to move to bottom center
-            StringFormat sf2 = new StringFormat();
-            sf2.LineAlignment = StringAlignment.Far;
-            sf2.Alignment = StringAlignment.Center;
-
-            //Print
-            Font fFooter = new Font(FontFamily.GenericSerif, 8);
-            g.DrawString("Printed: " + DateTime.Now, fFooter, Brushes.Black, printArea, sf2);
-        }
-
-    }
-    public abstract class PrintingCreator
-    {
-        public abstract CustomPrinting PrintFactory();
-    }
-
-}
Index: /Scheduling/trunk/cs/bsdx0200GUISourceCode/DAppointPage.cs
===================================================================
--- /Scheduling/trunk/cs/bsdx0200GUISourceCode/DAppointPage.cs	(revision 1109)
+++ /Scheduling/trunk/cs/bsdx0200GUISourceCode/DAppointPage.cs	(revision 1110)
@@ -64,4 +64,6 @@
         private TextBox txtCountry;
         private CheckBox chkPrint;
+        private Label label18;
+        private TextBox txtSex;
         private IContainer components;
 
@@ -121,4 +123,5 @@
             this.txtStreet = new System.Windows.Forms.TextBox();
             this.panel1 = new System.Windows.Forms.Panel();
+            this.chkPrint = new System.Windows.Forms.CheckBox();
             this.cmdCancel = new System.Windows.Forms.Button();
             this.cmdOK = new System.Windows.Forms.Button();
@@ -126,5 +129,6 @@
             this.dsPatientApptDisplay2BindingSource = new System.Windows.Forms.BindingSource(this.components);
             this.dsPatientApptDisplay2 = new IndianHealthService.ClinicalScheduling.dsPatientApptDisplay2();
-            this.chkPrint = new System.Windows.Forms.CheckBox();
+            this.label18 = new System.Windows.Forms.Label();
+            this.txtSex = new System.Windows.Forms.TextBox();
             this.tabControl1.SuspendLayout();
             this.tabAppointment.SuspendLayout();
@@ -260,4 +264,6 @@
             // groupBox1
             // 
+            this.groupBox1.Controls.Add(this.txtSex);
+            this.groupBox1.Controls.Add(this.label18);
             this.groupBox1.Controls.Add(this.label14);
             this.groupBox1.Controls.Add(this.txtHRN);
@@ -277,5 +283,5 @@
             // label14
             // 
-            this.label14.Location = new System.Drawing.Point(56, 64);
+            this.label14.Location = new System.Drawing.Point(50, 64);
             this.label14.Name = "label14";
             this.label14.Size = new System.Drawing.Size(40, 16);
@@ -294,5 +300,5 @@
             // label6
             // 
-            this.label6.Location = new System.Drawing.Point(224, 40);
+            this.label6.Location = new System.Drawing.Point(227, 65);
             this.label6.Name = "label6";
             this.label6.Size = new System.Drawing.Size(40, 16);
@@ -303,5 +309,5 @@
             // txtPID
             // 
-            this.txtPID.Location = new System.Drawing.Point(272, 40);
+            this.txtPID.Location = new System.Drawing.Point(272, 63);
             this.txtPID.Name = "txtPID";
             this.txtPID.ReadOnly = true;
@@ -311,5 +317,5 @@
             // label5
             // 
-            this.label5.Location = new System.Drawing.Point(64, 40);
+            this.label5.Location = new System.Drawing.Point(58, 41);
             this.label5.Name = "label5";
             this.label5.Size = new System.Drawing.Size(32, 16);
@@ -328,5 +334,5 @@
             // label2
             // 
-            this.label2.Location = new System.Drawing.Point(56, 16);
+            this.label2.Location = new System.Drawing.Point(50, 16);
             this.label2.Name = "label2";
             this.label2.Size = new System.Drawing.Size(40, 16);
@@ -543,4 +549,14 @@
             this.panel1.TabIndex = 1;
             // 
+            // chkPrint
+            // 
+            this.chkPrint.AutoSize = true;
+            this.chkPrint.Location = new System.Drawing.Point(13, 14);
+            this.chkPrint.Name = "chkPrint";
+            this.chkPrint.Size = new System.Drawing.Size(144, 17);
+            this.chkPrint.TabIndex = 2;
+            this.chkPrint.Text = "Print Appointment Letter";
+            this.chkPrint.UseVisualStyleBackColor = true;
+            // 
             // cmdCancel
             // 
@@ -577,13 +593,21 @@
             this.dsPatientApptDisplay2.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema;
             // 
-            // chkPrint
-            // 
-            this.chkPrint.AutoSize = true;
-            this.chkPrint.Location = new System.Drawing.Point(13, 14);
-            this.chkPrint.Name = "chkPrint";
-            this.chkPrint.Size = new System.Drawing.Size(144, 17);
-            this.chkPrint.TabIndex = 2;
-            this.chkPrint.Text = "Print Appointment Letter";
-            this.chkPrint.UseVisualStyleBackColor = true;
+            // label18
+            // 
+            this.label18.AutoSize = true;
+            this.label18.Location = new System.Drawing.Point(238, 44);
+            this.label18.Name = "label18";
+            this.label18.Size = new System.Drawing.Size(29, 13);
+            this.label18.TabIndex = 14;
+            this.label18.Text = "Sex:";
+            // 
+            // txtSex
+            // 
+            this.txtSex.BackColor = System.Drawing.SystemColors.Control;
+            this.txtSex.Location = new System.Drawing.Point(273, 41);
+            this.txtSex.Name = "txtSex";
+            this.txtSex.ReadOnly = true;
+            this.txtSex.Size = new System.Drawing.Size(160, 20);
+            this.txtSex.TabIndex = 15;
             // 
             // DAppointPage
@@ -623,4 +647,5 @@
 
 		private string			m_sPatientName;
+        private Sex             m_enumPatientSex;
 		private string			m_sPatientHRN;
 		private string			m_sPatientIEN;
@@ -674,4 +699,5 @@
 				DataRow r = tb.Rows[0];
 				this.m_sPatientName = r["NAME"].ToString();
+                this.m_enumPatientSex = r["SEX"].ToString() == "MALE" ? Sex.Male : Sex.Female;
 				this.m_sPatientHRN = r["HRN"].ToString();
 				this.m_sPatientIEN = r["IEN"].ToString();
@@ -716,4 +742,5 @@
 				txtNote.Text = this.m_sNote;
 				txtPatientName.Text = m_sPatientName;
+                txtSex.Text = m_enumPatientSex.ToString();
 				txtPhoneHome.Text = this.m_sPhoneHome;
 				txtPhoneOffice.Text = this.m_sPhoneOffice;
@@ -797,4 +824,5 @@
                     DFN = Int32.Parse(m_sPatientIEN),
                     Name = m_sPatientName,
+                    Sex = m_enumPatientSex,
                     DOB = m_dPatientDOB,
                     ID = m_sPatientPID,
Index: /Scheduling/trunk/cs/bsdx0200GUISourceCode/DAppointPage.resx
===================================================================
--- /Scheduling/trunk/cs/bsdx0200GUISourceCode/DAppointPage.resx	(revision 1109)
+++ /Scheduling/trunk/cs/bsdx0200GUISourceCode/DAppointPage.resx	(revision 1110)
@@ -124,4 +124,10 @@
     <value>179, 17</value>
   </metadata>
+  <metadata name="dsPatientApptDisplay2BindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>179, 17</value>
+  </metadata>
+  <metadata name="dsPatientApptDisplay2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>17, 17</value>
+  </metadata>
   <metadata name="dsPatientApptDisplay2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     <value>17, 17</value>
Index: /Scheduling/trunk/cs/bsdx0200GUISourceCode/DPatientLetter.cs
===================================================================
--- /Scheduling/trunk/cs/bsdx0200GUISourceCode/DPatientLetter.cs	(revision 1109)
+++ /Scheduling/trunk/cs/bsdx0200GUISourceCode/DPatientLetter.cs	(revision 1110)
@@ -302,5 +302,5 @@
             
             // _currentResourcePrinting starts with zero. There will be at least this one.
-            ClinicalScheduling.Printing.PrintAppointments(_dsApptDisplay, e, _dtBegin, _dtEnd,
+            CGDocumentManager.Current.PrintingObject.PrintAppointments(_dsApptDisplay, e, _dtBegin, _dtEnd,
                     _currentResourcePrinting, ref _currentApptPrinting, _pageNumber);
 
@@ -332,5 +332,5 @@
             if (_dsApptDisplay.PatientAppts.Count == 0)
             {
-                ClinicalScheduling.Printing.PrintMessage("No Appointments found", e);
+                CGDocumentManager.Current.PrintingObject.PrintMessage("No Appointments found", e);
                 return;
             }
@@ -340,5 +340,5 @@
                 dsPatientApptDisplay2.BSDXResourceRow c = (dsPatientApptDisplay2.BSDXResourceRow)
                    _dsApptDisplay.PatientAppts[_currentApptPrinting].GetParentRow(_dsApptDisplay.Relations[0]);
-                ClinicalScheduling.Printing.PrintReminderLetter(_dsApptDisplay.PatientAppts[_currentApptPrinting], e, c.LETTER_TEXT, "Reminder Letter");
+                CGDocumentManager.Current.PrintingObject.PrintReminderLetter(_dsApptDisplay.PatientAppts[_currentApptPrinting], e, c.LETTER_TEXT, "Reminder Letter");
                 _currentApptPrinting++;
                 if (_currentApptPrinting < _dsApptDisplay.PatientAppts.Count)
@@ -359,5 +359,5 @@
             if (_dsRebookAppts.PatientAppts.Count == 0)
             {
-                ClinicalScheduling.Printing.PrintMessage("No Appointments found", e);
+                CGDocumentManager.Current.PrintingObject.PrintMessage("No Appointments found", e);
                 return;
             }
@@ -367,5 +367,5 @@
                 dsRebookAppts.BSDXResourceRow c = (dsRebookAppts.BSDXResourceRow)
                    _dsRebookAppts.PatientAppts[_currentApptPrinting].GetParentRow(_dsRebookAppts.Relations[0]);
-                ClinicalScheduling.Printing.PrintCancelLetter(_dsRebookAppts.PatientAppts[_currentApptPrinting], e, c.CLINIC_CANCELLATION_LETTER, "Cancellation Letter");
+                CGDocumentManager.Current.PrintingObject.PrintCancelLetter(_dsRebookAppts.PatientAppts[_currentApptPrinting], e, c.CLINIC_CANCELLATION_LETTER, "Cancellation Letter");
                 _currentApptPrinting++;
                 if (_currentApptPrinting < _dsRebookAppts.PatientAppts.Count)
@@ -384,5 +384,5 @@
             if (_dsRebookAppts.PatientAppts.Count == 0)
             {
-                ClinicalScheduling.Printing.PrintMessage("No Appointments found", e);
+                CGDocumentManager.Current.PrintingObject.PrintMessage("No Appointments found", e);
                 return;
             }
@@ -393,5 +393,5 @@
                    _dsRebookAppts.PatientAppts[_currentApptPrinting].GetParentRow(_dsRebookAppts.Relations[0]);
                 //XXX: Rebook letter rather oddly currently stored in NO SHOW LETTER field. What gives???
-                ClinicalScheduling.Printing.PrintRebookLetter(_dsRebookAppts.PatientAppts[_currentApptPrinting], e, c.NO_SHOW_LETTER, "Rebook Letter");
+                CGDocumentManager.Current.PrintingObject.PrintRebookLetter(_dsRebookAppts.PatientAppts[_currentApptPrinting], e, c.NO_SHOW_LETTER, "Rebook Letter");
                 _currentApptPrinting++;
                 if (_currentApptPrinting < _dsRebookAppts.PatientAppts.Count)
Index: /Scheduling/trunk/cs/bsdx0200GUISourceCode/Patient.cs
===================================================================
--- /Scheduling/trunk/cs/bsdx0200GUISourceCode/Patient.cs	(revision 1109)
+++ /Scheduling/trunk/cs/bsdx0200GUISourceCode/Patient.cs	(revision 1110)
@@ -6,4 +6,13 @@
 namespace IndianHealthService.ClinicalScheduling
 {
+
+    /// <summary>
+    /// You guessed it.
+    /// </summary>
+    public enum Sex
+    {
+        Male, Female
+    };
+
     /// <summary>
     /// Puppet standing for a Real Patient
@@ -13,4 +22,5 @@
         public int DFN { get; set; }
         public string Name { get; set; }
+        public Sex Sex;
         public DateTime DOB { get; set; }
         public string ID { get; set; }
@@ -26,4 +36,23 @@
         public string WorkPHone { get; set; }
         public string CellPhone { get; set; }
+        public TimeSpan Age
+        {
+            get 
+            { 
+                return (DateTime.Today - this.DOB); 
+            }
+        }
+
+        public string UserFriendlyAge
+        {
+            get
+            {
+                if (Age.TotalDays / 365.24 > 5)
+                    return Math.Floor((Age.TotalDays / 365.24)).ToString() + " years";
+                else
+                    return Math.Floor((Age.TotalDays / 365.24)).ToString() + " years & "
+                     + Math.Floor(Age.TotalDays % 365.24 / 30).ToString() + " months";
+            }
+        }
     }
 }
Index: /Scheduling/trunk/cs/bsdx0200GUISourceCode/Printing.cs
===================================================================
--- /Scheduling/trunk/cs/bsdx0200GUISourceCode/Printing.cs	(revision 1109)
+++ /Scheduling/trunk/cs/bsdx0200GUISourceCode/Printing.cs	(revision 1110)
@@ -1,18 +1,14 @@
 ﻿using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
 using System.Drawing.Printing;
 using System.Drawing;
+using System.Text;
+using System.Drawing.Drawing2D;
+using System.Linq;
 using System.Data;
-using System.Drawing.Drawing2D;
 
 namespace IndianHealthService.ClinicalScheduling
 {
-    /// <summary>
-    /// Class that encapsulates printing functions in Clinical Scheduling
-    /// </summary>
-    public static class Printing
-    {
+    public class Printing
+    { 
         /// <summary>
         /// Print Appointments
@@ -26,6 +22,5 @@
         /// <param name="pageNumber">Current page number</param>
         /// <remarks>beg and end have no effect on operation--they are there for documentation for user only</remarks>
-        public static void PrintAppointments(dsPatientApptDisplay2 ds, PrintPageEventArgs e, DateTime beg, DateTime end,
-            int resourceToPrint, ref int apptPrinting, int pageNumber)
+        public virtual void PrintAppointments(dsPatientApptDisplay2 ds, PrintPageEventArgs e, DateTime beg, DateTime end, int resourceToPrint, ref int apptPrinting, int pageNumber)
         {
             Graphics g = e.Graphics;
@@ -122,4 +117,209 @@
 
         /// <summary>
+        /// Prints a single appointment slip to give to the patient
+        /// </summary>
+        /// <param name="appt">The Appointment to print</param>
+        /// <param name="e">PrintPageEventArgs from PrintDocument Print handler</param>
+        public virtual void PrintAppointmentSlip(CGAppointment appt, PrintPageEventArgs e)
+        {
+            // Prep
+            Graphics g = e.Graphics;
+            Rectangle printArea = e.MarginBounds;
+            Rectangle pageArea = e.PageBounds;
+            Rectangle headerArea = new Rectangle()
+            {
+                X = e.MarginBounds.X,
+                Y = e.PageBounds.Y,
+                Height = e.MarginBounds.Y - e.PageBounds.Y,
+                Width = e.MarginBounds.Width
+            };
+
+            // A few fonts
+            Font fTitle = new Font(FontFamily.GenericSerif, 24, FontStyle.Bold); //for title
+            Font fBody = new Font(FontFamily.GenericSerif, 12);
+            Font fGroupTitle = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Bold);
+
+            StringFormat sf0 = new StringFormat()
+            {
+                 Alignment = StringAlignment.Center,
+                 LineAlignment = StringAlignment.Center
+            };
+            
+            // Draw Header
+            string division = CGDocumentManager.Current.ConnectInfo.DivisionName;
+            g.DrawString(division, fBody, Brushes.Black, headerArea, sf0);
+            
+            // Draw Title
+            StringFormat sf = new StringFormat();
+            sf.Alignment = StringAlignment.Center; //for title & header
+
+            string s = "Appointment Reminder Slip";
+            g.DrawString(s, fTitle, Brushes.Black, printArea, sf); //title
+
+            // move down
+            int titleHeight = (int)g.MeasureString(s, fTitle, printArea.Width).Height;
+            printArea.Y += titleHeight;
+            printArea.Height -= titleHeight;
+
+            // draw underline
+            g.DrawLine(Pens.Black, printArea.Location, new Point(printArea.Right, printArea.Y));
+            printArea.Y += 15;
+            printArea.Height -= 15;
+
+            // draw curved rectangle.
+            Rectangle personalInfoRectangle = new Rectangle(e.MarginBounds.X, printArea.Y + 30, 280, 300);
+            using (GraphicsPath path = GetRoundedRectPath(personalInfoRectangle, 10))
+            {
+                g.DrawPath(Pens.Black, path);
+            }
+
+            // group header
+            g.DrawString("Patient Information", fGroupTitle, Brushes.Black, new Point(personalInfoRectangle.X, personalInfoRectangle.Y - 20));
+            
+            // inner rectangle for drawing strings:
+            Rectangle personalInfoInnerRectangle = new Rectangle(personalInfoRectangle.X + 20, personalInfoRectangle.Y + 20, 280 - 40, 300 - 40);
+            
+            // Strings to write
+            StringBuilder sb = new StringBuilder(500);
+            sb.AppendLine("Name:" + "\t" + appt.Patient.Name);
+            sb.AppendLine();
+            sb.AppendLine("ID#:" + "\t" + appt.Patient.ID);
+            sb.AppendLine();
+            sb.AppendLine("DOB:" + "\t" + appt.Patient.DOB.ToShortDateString());
+            sb.AppendLine();
+            sb.AppendLine("Age:" + "\t" + appt.Patient.UserFriendlyAge);
+            sb.AppendLine();
+            sb.AppendLine("Sex:" + "\t" + appt.Patient.Sex.ToString());
+            
+            // Draw them
+            g.DrawString(sb.ToString(), fBody, Brushes.Black, personalInfoInnerRectangle);
+
+            // draw curved rectangle
+            Rectangle apptInfoRectangle = new Rectangle(e.MarginBounds.X + e.MarginBounds.Width - 280, printArea.Y + 30, 280, 300);
+            using (GraphicsPath path = GetRoundedRectPath(apptInfoRectangle, 10))
+            {
+                g.DrawPath(Pens.Black, path);
+            }
+
+            // group header
+            g.DrawString("Appointment Information", fGroupTitle, Brushes.Black, new Point(apptInfoRectangle.X, apptInfoRectangle.Y - 20));
+
+            // Strings to write
+            sb = new StringBuilder();
+            sb.AppendLine("Clinic: " + "\t" + appt.Resource);
+            sb.AppendLine();
+            sb.AppendLine("Date: " + "\t" + appt.StartTime.ToShortDateString());
+            sb.AppendLine();
+            sb.AppendLine("Day: " + "\t" + appt.StartTime.DayOfWeek.ToString());
+            sb.AppendLine();
+            sb.AppendLine("Time: " + "\t" + appt.StartTime.ToShortTimeString());
+
+            // Draw them
+            Rectangle apptInfoInnerRectangle = new Rectangle(apptInfoRectangle.X + 20, apptInfoRectangle.Y + 20, 280 - 40, 300 - 40);
+
+            // Draw them
+            g.DrawString(sb.ToString(), fBody, Brushes.Black, apptInfoInnerRectangle);
+
+            // Move Drawing Rectangle Down
+            printArea.Y += 300 + 30 + 20;
+            printArea.Height -= 300 + 30 + 20;
+
+            // Draw New Line
+            g.DrawLine(Pens.Black, printArea.Location, new Point(printArea.Right, printArea.Y));
+            printArea.Y += 5;
+            printArea.Height -= 5;
+
+            // Draw new Title
+            s = "Clinic Instructions";
+            g.DrawString(s, fTitle, Brushes.Black, printArea, sf); //title
+
+            // move down
+            titleHeight = (int)g.MeasureString(s, fTitle, printArea.Width).Height;
+            printArea.Y += titleHeight;
+            printArea.Height -= titleHeight;
+
+            // Draw New Line
+            g.DrawLine(Pens.Black, printArea.Location, new Point(printArea.Right, printArea.Y));
+            printArea.Y += 15;
+            printArea.Height -= 15;
+
+            // Get Resource Clinic Appointment Letter Text
+            DataTable resources = CGDocumentManager.Current.GlobalDataSet.Tables["Resources"];
+
+            string ltrTxt = (from resource in resources.AsEnumerable()
+                             where resource.Field<string>("RESOURCE_NAME") == appt.Resource
+                             select resource.Field<string>("LETTER_TEXT")).SingleOrDefault<string>();
+
+            if (String.IsNullOrWhiteSpace(ltrTxt)) ltrTxt = "(no instructions provided)";
+
+            g.DrawString(ltrTxt, fBody, Brushes.Black, printArea);
+
+            int ltrTxtHeight = (int)g.MeasureString(ltrTxt, fBody).Height;
+
+            printArea.Y += ltrTxtHeight + 15;
+            printArea.Height -= ltrTxtHeight + 15;
+
+            g.DrawLine(Pens.Black, printArea.Location, new Point(printArea.Right, printArea.Y));
+            printArea.Y += 5;
+            printArea.Height -= 5;
+
+            s = "Notes";
+            g.DrawString(s, fTitle, Brushes.Black, printArea, sf); // Notes title
+            
+            // move down
+            titleHeight = (int)g.MeasureString(s, fTitle, printArea.Width).Height;
+            printArea.Y += titleHeight;
+            printArea.Height -= titleHeight;
+
+            // Draw New Line
+            g.DrawLine(Pens.Black, printArea.Location, new Point(printArea.Right, printArea.Y));
+            printArea.Y += 15;
+            printArea.Height -= 15;
+
+            // Draw Notes Area
+            using (GraphicsPath path = GetRoundedRectPath(printArea, 15))
+            {
+                g.DrawPath(Pens.Black, path);
+            }
+
+            // Draw Footer
+            // Get footer rectangle
+            Rectangle footerArea = new Rectangle()
+            {
+                X = e.MarginBounds.X,
+                Y = e.MarginBounds.Height + headerArea.Height,
+                Width = e.MarginBounds.Width,
+                Height = pageArea.Height - (e.MarginBounds.Height + headerArea.Height)
+            };
+
+            //use sf0 to print the footer (center all the way)
+            s = "Printed: " + DateTime.Now.ToString();
+            Font fFooter = new Font(FontFamily.GenericSerif, 7);
+            g.DrawString(s, fFooter, Brushes.Black, footerArea, sf0);
+
+        }
+
+
+        private GraphicsPath GetRoundedRectPath(Rectangle rect, int radius)
+        {
+            int diameter = 2 * radius;
+           
+            Rectangle arcRect = new Rectangle(rect.Location, new Size(diameter, diameter));
+            GraphicsPath path = new GraphicsPath();
+            
+            path.AddArc(arcRect, 180, 90); //top left
+            arcRect.X = rect.Right - diameter;
+            path.AddArc(arcRect, 270, 90); // top right
+            arcRect.Y = rect.Bottom - diameter;
+            path.AddArc(arcRect, 0, 90); // bottom right
+            arcRect.X = rect.Left;
+            path.AddArc(arcRect, 90, 90); // bottom left
+
+            path.CloseFigure();
+
+            return path;
+        }
+
+        /// <summary>
         /// Print Letter to be given or mailed to the patient
         /// </summary>
@@ -128,5 +328,5 @@
         /// <param name="letter">Contains letter string</param>
         /// <param name="title">Title of the letter</param>
-        public static void PrintReminderLetter(dsPatientApptDisplay2.PatientApptsRow ptRow, PrintPageEventArgs e, string letter, string title)
+        public virtual void PrintReminderLetter(dsPatientApptDisplay2.PatientApptsRow ptRow, PrintPageEventArgs e, string letter, string title)
         {
 
@@ -177,5 +377,5 @@
             g.DrawString(address.ToString(), fBody, Brushes.Black, printArea, sf);
         }
-
+       
         /// <summary>
         /// Cancellation Letter to be given or mailed to the patient
@@ -185,5 +385,5 @@
         /// <param name="letter">Contains letter string</param>
         /// <param name="title">Title of the letter</param>
-        public static void PrintCancelLetter(dsRebookAppts.PatientApptsRow ptRow, PrintPageEventArgs e, string letter, string title)
+        public virtual void PrintCancelLetter(dsRebookAppts.PatientApptsRow ptRow, PrintPageEventArgs e, string letter, string title)
         {
             Rectangle printArea = e.MarginBounds;
@@ -241,5 +441,5 @@
         /// <param name="letter">Text of the letter to print</param>
         /// <param name="title">Title to print at the top of the letter</param>
-        public static void PrintRebookLetter(dsRebookAppts.PatientApptsRow ptRow, PrintPageEventArgs e, string letter, string title)
+        public virtual void PrintRebookLetter(dsRebookAppts.PatientApptsRow ptRow, PrintPageEventArgs e, string letter, string title)
         {
             Rectangle printArea = e.MarginBounds;
@@ -298,5 +498,5 @@
         /// <param name="msg">The exact string to print.</param>
         /// <param name="e">Print Page event args</param>
-        public static void PrintMessage(string msg, PrintPageEventArgs e)
+        public virtual void PrintMessage(string msg, PrintPageEventArgs e)
         {
             e.Graphics.DrawString(msg, new Font(FontFamily.GenericSerif, 14),
@@ -310,5 +510,5 @@
         /// <param name="title">String to print for title</param>
         /// <param name="e">etc</param>
-        public static void PrintRoutingSlip(CGAppointment a, string title, PrintPageEventArgs e)
+        public virtual void PrintRoutingSlip(CGAppointment a, string title, PrintPageEventArgs e)
         {
             Rectangle printArea = e.MarginBounds;
@@ -354,6 +554,11 @@
             Font fFooter = new Font(FontFamily.GenericSerif, 8);
             g.DrawString("Printed: " + DateTime.Now, fFooter, Brushes.Black, printArea, sf2);
-
-        }
+        }
+
     }
+    public abstract class PrintingCreator
+    {
+        public abstract Printing PrintFactory();
+    }
+
 }
