Changeset 1112


Ignore:
Timestamp:
Mar 24, 2011, 9:26:14 AM (13 years ago)
Author:
Sam Habiel
Message:

CGDocument: Minor Change: Add appointment ID to Appointment
CGDocumentManager: added parameter /culture to set Thread.CurrentThread.CurrentUICulture
CGView: Minor changes in CheckInAppointment: Printing of Routing Slip now always happens.

Routing slip now get parameter for patient order.

Patient: i18n of UserFriendlyAge
Printing: Extensive changes. Support for i18n; new routing slip and appt slip. i18n support only for appt slip.

Location:
Scheduling/trunk/cs/bsdx0200GUISourceCode
Files:
10 edited

Legend:

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

    r1111 r1112  
    10031003            this.m_appointments.AddAppointment(aCopy);
    10041004           
    1005            
     1005            //TODO: Improve
     1006            //Yucky hack for now... haven't investigated why we need to create a new CGAppointment beyond
     1007            //the one that we pass.
     1008            rApptInfo.AppointmentKey = nApptID;
     1009
    10061010            //Have make appointment from CGView responsible for requesting an update for the avialability.
    10071011            //bool bRet = RefreshAvailabilitySchedule();
  • Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocumentManager.cs

    r1111 r1112  
    88using Mono.Options;
    99using System.Runtime.InteropServices;
     10using System.Globalization;
    1011
    1112namespace IndianHealthService.ClinicalScheduling
     
    3334        private string                      m_Encoding="";  //Encoding is "" by default;
    3435
     36        //Globalization Object (tied to command line parameter /culture)
     37        private string                      m_CultureName = "";
     38
    3539        //Data Access Layer
    3640        private DAL                         _dal = null;
     
    96100
    97101        /// <summary>
    98         /// More later...
     102        /// User Preferences Auto Property
    99103        /// </summary>
    100104        public UserPreferences UserPreferences { get; private set; }
     
    171175        /// /v or -v = Verify Code
    172176        /// /e or -e = Encoding (name of encoding as known to windows, such as windows-1256)
     177        /// /culture or -culture = Culture Name for UI Culture if you wish to override the Windows Culture
    173178        /// </param>
    174179        /// <remarks>
     
    200205                { "a=", a => _current.m_AccessCode = a },
    201206                { "v=", v => _current.m_VerifyCode = v },
    202                 { "e=", e => _current.m_Encoding = e}
     207                { "e=", e => _current.m_Encoding = e},
     208                { "culture=", culture => _current.m_CultureName = culture }
    203209            };
    204210
     
    469475            _current.UserPreferences = new UserPreferences();
    470476
     477            //User Interface Culture (m_CultureName is set from the command line flag /culture)
     478            try { Thread.CurrentThread.CurrentUICulture = new CultureInfo(m_CultureName); } // if "", invariant culture
     479            catch (CultureNotFoundException) { Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture; }
     480
    471481            //Create global dataset
    472482                        _current.m_dsGlobal = new DataSet("GlobalDataSet");
  • Scheduling/trunk/cs/bsdx0200GUISourceCode/CGView.cs

    r1111 r1112  
    99using System.Runtime.InteropServices;
    1010using System.Drawing.Printing;
     11using System.Linq;
    1112
    1213namespace IndianHealthService.ClinicalScheduling
     
    19541955                                calendarGrid1.CGToolTip.Active = true;
    19551956
    1956                                 if (bAlreadyCheckedIn == true)
    1957                                         return;
    1958 
    1959                                 DateTime dtCheckIn = dlgCheckin.CheckInTime;
    1960 
    1961                 //Tell appointment that it is checked in, for proper coloring;
    1962                 //When you refresh from the DB, it will have this property.
    1963                 a.CheckInTime = DateTime.Now;
     1957                if (bAlreadyCheckedIn != true)
     1958                {
     1959                    DateTime dtCheckIn = dlgCheckin.CheckInTime;
     1960
     1961                    //Tell appointment that it is checked in, for proper coloring;
     1962                    //When you refresh from the DB, it will have this property.
     1963                    a.CheckInTime = DateTime.Now;
     1964
     1965                    //Save to Database
     1966                    this.Document.CheckInAppointment(nApptID, dtCheckIn);
     1967                }
    19641968               
    1965                 //Save to Database
    1966                 this.Document.CheckInAppointment(nApptID, dtCheckIn);
    1967 
    19681969                //Get Provider (XXXXXXXX: NOT SAVED TO THE DATABASE RIGHT NOW)
    19691970                a.Provider = dlgCheckin.Provider;
     
    21032104                        try
    21042105                        {
    2105                                
    2106                        
    21072106                                //Get Time and Resource from Selected Cell
    21082107                                DateTime dStart = DateTime.Today;
     
    32173216        private void PrintRoutingSlip(CGAppointment appt)
    32183217        {
     3218            //get this appointment's order
     3219            //Today's appointments
     3220            var todaysAppts = (from lkappts in this.Document.Appointments.AppointmentTable.Values.Cast<CGAppointment>()
     3221                               where lkappts.StartTime > appt.StartTime.Date && lkappts.StartTime < appt.StartTime.AddDays(1).Date
     3222                              orderby lkappts.StartTime
     3223                              select lkappts).ToList();
     3224           
     3225            //Find the order of the appointment
     3226            int apptOrder = todaysAppts.FindIndex(eachappt => eachappt.StartTime == appt.StartTime && eachappt.PatientID == appt.PatientID);
     3227 
     3228            //Index is zero based, so add 1
     3229            apptOrder++;
     3230
     3231            //Send that to the routing slip as a parameter
    32193232            PrintDocument pd = new PrintDocument() { DocumentName = "Routing Slip for Appt " + appt.AppointmentKey };
    3220             pd.PrintPage += (object s, System.Drawing.Printing.PrintPageEventArgs e) => CGDocumentManager.Current.PrintingObject.PrintRoutingSlip(appt, "Routing Slip", e);
     3233            pd.PrintPage += (object s, System.Drawing.Printing.PrintPageEventArgs e) => CGDocumentManager.Current.PrintingObject.PrintRoutingSlip(appt, apptOrder, e);
    32213234            pd.Print();
    32223235        }
  • Scheduling/trunk/cs/bsdx0200GUISourceCode/ClinicalScheduling.csproj

    r1111 r1112  
    141141  <ItemGroup>
    142142    <Compile Include="Provider.cs" />
     143    <Compile Include="strings.ar.Designer.cs">
     144      <AutoGen>True</AutoGen>
     145      <DesignTime>True</DesignTime>
     146      <DependentUpon>strings.ar.resx</DependentUpon>
     147    </Compile>
     148    <Compile Include="strings.Designer.cs">
     149      <AutoGen>True</AutoGen>
     150      <DesignTime>True</DesignTime>
     151      <DependentUpon>strings.resx</DependentUpon>
     152    </Compile>
    143153    <Compile Include="UserPreferences.cs" />
    144154    <None Include="app.config" />
     
    412422    <EmbeddedResource Include="LoadingSplash.resx">
    413423      <DependentUpon>LoadingSplash.cs</DependentUpon>
     424    </EmbeddedResource>
     425    <EmbeddedResource Include="strings.ar.resx">
     426      <Generator>ResXFileCodeGenerator</Generator>
     427      <LastGenOutput>strings.ar.Designer.cs</LastGenOutput>
     428    </EmbeddedResource>
     429    <EmbeddedResource Include="strings.resx">
     430      <Generator>ResXFileCodeGenerator</Generator>
     431      <LastGenOutput>strings.Designer.cs</LastGenOutput>
    414432    </EmbeddedResource>
    415433    <EmbeddedResource Include="UCPatientAppts.resx">
  • Scheduling/trunk/cs/bsdx0200GUISourceCode/ClinicalScheduling.csproj.user

    r1111 r1112  
    3737    </RemoteDebugMachine>
    3838    <StartAction>Project</StartAction>
    39     <StartArguments>/s=172.16.16.108 /p=9250 /a=BASMA.ALDWAIRI /v=SELEN.123</StartArguments>
     39    <StartArguments>/s=172.16.16.108 /p=9250 /a=BASMA.ALDWAIRI /v=SELEN.123 /culture="ar-JO"</StartArguments>
    4040    <StartPage>
    4141    </StartPage>
  • Scheduling/trunk/cs/bsdx0200GUISourceCode/Patient.cs

    r1111 r1112  
    5454            {
    5555                if (Age.TotalDays / 365.24 > 5)
    56                     return Math.Floor((Age.TotalDays / 365.24)).ToString() + " years";
     56                    return Math.Floor((Age.TotalDays / 365.24)).ToString() + " " + strings.years;
    5757                else
    58                     return Math.Floor((Age.TotalDays / 365.24)).ToString() + " years & "
    59                      + Math.Floor(Age.TotalDays % 365.24 / 30).ToString() + " months";
     58                    return Math.Floor((Age.TotalDays / 365.24)).ToString() + " " + strings.years + " " + strings.and + " "
     59                     + Math.Floor(Age.TotalDays % 365.24 / 30).ToString() + " " + strings.months;
    6060            }
    6161        }
  • Scheduling/trunk/cs/bsdx0200GUISourceCode/Printing.cs

    r1110 r1112  
    99namespace IndianHealthService.ClinicalScheduling
    1010{
    11     public class Printing
     11    public partial class Printing
    1212    {
    1313        /// <summary>
     
    4848            //Typical manipulable print area
    4949            Rectangle printArea = e.MarginBounds;
    50            
     50            Rectangle pageArea = e.PageBounds;
     51            Rectangle headerArea = new Rectangle()
     52            {
     53                X = e.MarginBounds.X,
     54                Y = e.PageBounds.Y,
     55                Height = e.MarginBounds.Y - e.PageBounds.Y,
     56                Width = e.MarginBounds.Width
     57            };
     58            Rectangle footerArea = new Rectangle()
     59            {
     60                X = e.MarginBounds.X,
     61                Y = e.MarginBounds.Height + headerArea.Height,
     62                Width = e.MarginBounds.Width,
     63                Height = pageArea.Height - (e.MarginBounds.Height + headerArea.Height)
     64            };
     65
     66            //print footer
     67            StringFormat sfFooter = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center };
     68            string s = strings.Printed + ": " + DateTime.Now.ToString();
     69            Font fFooter = new Font(FontFamily.GenericSerif, 7);
     70            g.DrawString(s, fFooter, Brushes.Black, footerArea, sfFooter);
     71
    5172            //resource we want to print
    5273            dsPatientApptDisplay2.BSDXResourceRow r = ds.BSDXResource[resourceToPrint];
     
    5475            //header
    5576            string toprint;
    56             if (beg == end) toprint = "Appointments for " + r.RESOURCE_NAME + " on " + beg.ToLongDateString();
     77            if (beg.Date == end.Date) toprint = "Appointments for " + r.RESOURCE_NAME + " on " + beg.ToLongDateString();
    5778            else toprint = "Appointments for " + r.RESOURCE_NAME + " from " + beg.ToShortDateString() + " to "
    5879                + end.ToShortDateString();
     
    6081           
    6182            //Move print area down
    62             printArea.Height -= (int)f14bold.GetHeight();
    63             printArea.Y += (int)f14bold.GetHeight();
     83            int titleHeight = (int)g.MeasureString(toprint, f14bold, printArea.Size).Height;
     84            printArea.Height -= titleHeight;
     85            printArea.Y += titleHeight;
    6486
    6587            //Draw Line
     
    134156                Width = e.MarginBounds.Width
    135157            };
    136 
    137             // A few fonts
    138             Font fTitle = new Font(FontFamily.GenericSerif, 24, FontStyle.Bold); //for title
    139             Font fBody = new Font(FontFamily.GenericSerif, 12);
    140             Font fGroupTitle = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Bold);
    141 
    142             StringFormat sf0 = new StringFormat()
    143             {
    144                  Alignment = StringAlignment.Center,
    145                  LineAlignment = StringAlignment.Center
    146             };
    147            
    148             // Draw Header
    149             string division = CGDocumentManager.Current.ConnectInfo.DivisionName;
    150             g.DrawString(division, fBody, Brushes.Black, headerArea, sf0);
    151            
    152             // Draw Title
    153             StringFormat sf = new StringFormat();
    154             sf.Alignment = StringAlignment.Center; //for title & header
    155 
    156             string s = "Appointment Reminder Slip";
    157             g.DrawString(s, fTitle, Brushes.Black, printArea, sf); //title
    158 
    159             // move down
    160             int titleHeight = (int)g.MeasureString(s, fTitle, printArea.Width).Height;
    161             printArea.Y += titleHeight;
    162             printArea.Height -= titleHeight;
    163 
    164             // draw underline
    165             g.DrawLine(Pens.Black, printArea.Location, new Point(printArea.Right, printArea.Y));
    166             printArea.Y += 15;
    167             printArea.Height -= 15;
    168 
    169             // draw curved rectangle.
    170             Rectangle personalInfoRectangle = new Rectangle(e.MarginBounds.X, printArea.Y + 30, 280, 300);
    171             using (GraphicsPath path = GetRoundedRectPath(personalInfoRectangle, 10))
    172             {
    173                 g.DrawPath(Pens.Black, path);
    174             }
    175 
    176             // group header
    177             g.DrawString("Patient Information", fGroupTitle, Brushes.Black, new Point(personalInfoRectangle.X, personalInfoRectangle.Y - 20));
    178            
    179             // inner rectangle for drawing strings:
    180             Rectangle personalInfoInnerRectangle = new Rectangle(personalInfoRectangle.X + 20, personalInfoRectangle.Y + 20, 280 - 40, 300 - 40);
    181            
    182             // Strings to write
    183             StringBuilder sb = new StringBuilder(500);
    184             sb.AppendLine("Name:" + "\t" + appt.Patient.Name);
    185             sb.AppendLine();
    186             sb.AppendLine("ID#:" + "\t" + appt.Patient.ID);
    187             sb.AppendLine();
    188             sb.AppendLine("DOB:" + "\t" + appt.Patient.DOB.ToShortDateString());
    189             sb.AppendLine();
    190             sb.AppendLine("Age:" + "\t" + appt.Patient.UserFriendlyAge);
    191             sb.AppendLine();
    192             sb.AppendLine("Sex:" + "\t" + appt.Patient.Sex.ToString());
    193            
    194             // Draw them
    195             g.DrawString(sb.ToString(), fBody, Brushes.Black, personalInfoInnerRectangle);
    196 
    197             // draw curved rectangle
    198             Rectangle apptInfoRectangle = new Rectangle(e.MarginBounds.X + e.MarginBounds.Width - 280, printArea.Y + 30, 280, 300);
    199             using (GraphicsPath path = GetRoundedRectPath(apptInfoRectangle, 10))
    200             {
    201                 g.DrawPath(Pens.Black, path);
    202             }
    203 
    204             // group header
    205             g.DrawString("Appointment Information", fGroupTitle, Brushes.Black, new Point(apptInfoRectangle.X, apptInfoRectangle.Y - 20));
    206 
    207             // Strings to write
    208             sb = new StringBuilder();
    209             sb.AppendLine("Clinic: " + "\t" + appt.Resource);
    210             sb.AppendLine();
    211             sb.AppendLine("Date: " + "\t" + appt.StartTime.ToShortDateString());
    212             sb.AppendLine();
    213             sb.AppendLine("Day: " + "\t" + appt.StartTime.DayOfWeek.ToString());
    214             sb.AppendLine();
    215             sb.AppendLine("Time: " + "\t" + appt.StartTime.ToShortTimeString());
    216 
    217             // Draw them
    218             Rectangle apptInfoInnerRectangle = new Rectangle(apptInfoRectangle.X + 20, apptInfoRectangle.Y + 20, 280 - 40, 300 - 40);
    219 
    220             // Draw them
    221             g.DrawString(sb.ToString(), fBody, Brushes.Black, apptInfoInnerRectangle);
    222 
    223             // Move Drawing Rectangle Down
    224             printArea.Y += 300 + 30 + 20;
    225             printArea.Height -= 300 + 30 + 20;
    226 
    227             // Draw New Line
    228             g.DrawLine(Pens.Black, printArea.Location, new Point(printArea.Right, printArea.Y));
    229             printArea.Y += 5;
    230             printArea.Height -= 5;
    231 
    232             // Draw new Title
    233             s = "Clinic Instructions";
    234             g.DrawString(s, fTitle, Brushes.Black, printArea, sf); //title
    235 
    236             // move down
    237             titleHeight = (int)g.MeasureString(s, fTitle, printArea.Width).Height;
    238             printArea.Y += titleHeight;
    239             printArea.Height -= titleHeight;
    240 
    241             // Draw New Line
    242             g.DrawLine(Pens.Black, printArea.Location, new Point(printArea.Right, printArea.Y));
    243             printArea.Y += 15;
    244             printArea.Height -= 15;
    245 
    246             // Get Resource Clinic Appointment Letter Text
    247             DataTable resources = CGDocumentManager.Current.GlobalDataSet.Tables["Resources"];
    248 
    249             string ltrTxt = (from resource in resources.AsEnumerable()
    250                              where resource.Field<string>("RESOURCE_NAME") == appt.Resource
    251                              select resource.Field<string>("LETTER_TEXT")).SingleOrDefault<string>();
    252 
    253             if (String.IsNullOrWhiteSpace(ltrTxt)) ltrTxt = "(no instructions provided)";
    254 
    255             g.DrawString(ltrTxt, fBody, Brushes.Black, printArea);
    256 
    257             int ltrTxtHeight = (int)g.MeasureString(ltrTxt, fBody).Height;
    258 
    259             printArea.Y += ltrTxtHeight + 15;
    260             printArea.Height -= ltrTxtHeight + 15;
    261 
    262             g.DrawLine(Pens.Black, printArea.Location, new Point(printArea.Right, printArea.Y));
    263             printArea.Y += 5;
    264             printArea.Height -= 5;
    265 
    266             s = "Notes";
    267             g.DrawString(s, fTitle, Brushes.Black, printArea, sf); // Notes title
    268            
    269             // move down
    270             titleHeight = (int)g.MeasureString(s, fTitle, printArea.Width).Height;
    271             printArea.Y += titleHeight;
    272             printArea.Height -= titleHeight;
    273 
    274             // Draw New Line
    275             g.DrawLine(Pens.Black, printArea.Location, new Point(printArea.Right, printArea.Y));
    276             printArea.Y += 15;
    277             printArea.Height -= 15;
    278 
    279             // Draw Notes Area
    280             using (GraphicsPath path = GetRoundedRectPath(printArea, 15))
    281             {
    282                 g.DrawPath(Pens.Black, path);
    283             }
    284 
    285             // Draw Footer
    286             // Get footer rectangle
    287158            Rectangle footerArea = new Rectangle()
    288159            {
     
    293164            };
    294165
     166
     167            // A few fonts
     168            Font fTitle = new Font(FontFamily.GenericSerif, 24, FontStyle.Bold); //for title
     169            Font fBody = new Font(FontFamily.GenericSerif, 12);
     170            Font fGroupTitle = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Bold);
     171
     172            StringFormat sf0 = new StringFormat()
     173            {
     174                 Alignment = StringAlignment.Center,
     175                 LineAlignment = StringAlignment.Center
     176            };
     177           
     178            // Draw Header
     179            string division = CGDocumentManager.Current.ConnectInfo.DivisionName;
     180            g.DrawString(division, fBody, Brushes.Black, headerArea, sf0);
     181           
     182            // Draw Title
     183            StringFormat sf = new StringFormat();
     184            sf.Alignment = StringAlignment.Center; //for title & header
     185
     186            //string s = "Appointment Reminder Slip";
     187            string s = strings.ApptRoutingSlip;
     188            g.DrawString(s, fTitle, Brushes.Black, printArea, sf); //title
     189
     190            // move down
     191            int titleHeight = (int)g.MeasureString(s, fTitle, printArea.Width).Height;
     192            printArea.Y += titleHeight;
     193            printArea.Height -= titleHeight;
     194
     195            // draw underline
     196            g.DrawLine(Pens.Black, printArea.Location, new Point(printArea.Right, printArea.Y));
     197            printArea.Y += 15;
     198            printArea.Height -= 15;
     199
     200            // draw curved rectangle.
     201            Rectangle personalInfoRectangle = new Rectangle(e.MarginBounds.X, printArea.Y + 30, 280, 300);
     202            using (GraphicsPath path = GetRoundedRectPath(personalInfoRectangle, 10))
     203            {
     204                g.DrawPath(Pens.Black, path);
     205            }
     206
     207            // group header
     208            s = strings.PtInfo;
     209            StringFormat sf3 = new StringFormat(System.Threading.Thread.CurrentThread.CurrentUICulture.TextInfo.IsRightToLeft ? StringFormatFlags.DirectionRightToLeft : 0);
     210            g.DrawString(s, fGroupTitle, Brushes.Black, new Rectangle(personalInfoRectangle.X, personalInfoRectangle.Y - 20,personalInfoRectangle.Width, 20),sf3);
     211           
     212            // inner rectangle for drawing strings:
     213            Rectangle personalInfoInnerRectangle = new Rectangle(personalInfoRectangle.X + 20, personalInfoRectangle.Y + 20, 280 - 40, 300 - 40);
     214           
     215            // Strings to write
     216            StringBuilder sb = new StringBuilder(500);
     217            sb.AppendLine(strings.Name + ":" + "\t" + appt.Patient.Name);
     218            sb.AppendLine();
     219            sb.AppendLine(strings.ID + ":" + "\t" + appt.Patient.ID);
     220            sb.AppendLine();
     221            sb.AppendLine(strings.DOB + ":" + "\t" + appt.Patient.DOB.ToShortDateString());
     222            sb.AppendLine();
     223            sb.AppendLine(strings.Age + ":" + "\t" + appt.Patient.UserFriendlyAge);
     224            sb.AppendLine();
     225            s = appt.Patient.Sex == Sex.Male ? strings.Male : strings.Female;
     226            sb.AppendLine(strings.Sex + ":" + "\t" + s);
     227
     228            // Draw them
     229            sf3 = new StringFormat(System.Threading.Thread.CurrentThread.CurrentUICulture.TextInfo.IsRightToLeft ? StringFormatFlags.DirectionRightToLeft : 0);
     230            sf3.SetTabStops(0, new float[] {75} );
     231            sf3.SetDigitSubstitution(System.Threading.Thread.CurrentThread.CurrentUICulture.LCID, StringDigitSubstitute.Traditional);
     232            g.DrawString(sb.ToString(), fBody, Brushes.Black, personalInfoInnerRectangle, sf3);
     233
     234            // draw curved rectangle
     235            Rectangle apptInfoRectangle = new Rectangle(e.MarginBounds.X + e.MarginBounds.Width - 280, printArea.Y + 30, 280, 300);
     236            using (GraphicsPath path = GetRoundedRectPath(apptInfoRectangle, 10))
     237            {
     238                g.DrawPath(Pens.Black, path);
     239            }
     240
     241            s = strings.ApptInfo;
     242            // group header
     243            g.DrawString(s, fGroupTitle, Brushes.Black, new Rectangle(apptInfoRectangle.X, apptInfoRectangle.Y - 20,apptInfoRectangle.Width, 20), sf3);
     244
     245            // Strings to write
     246            sb = new StringBuilder();
     247            sb.AppendLine(strings.Clinic + ":" + "\t" + appt.Resource);
     248            sb.AppendLine();
     249            sb.AppendLine(strings.Date + ":" + "\t" + appt.StartTime.ToShortDateString());
     250            sb.AppendLine();
     251            sb.AppendLine(strings.Day + ":" + "\t" + appt.StartTime.ToString("dddd"));
     252            sb.AppendLine();
     253            sb.AppendLine(strings.Time + ":" + "\t" + appt.StartTime.ToShortTimeString());
     254
     255            // Draw them
     256            Rectangle apptInfoInnerRectangle = new Rectangle(apptInfoRectangle.X + 20, apptInfoRectangle.Y + 20, 280 - 40, 300 - 40);
     257
     258            // Draw them
     259            g.DrawString(sb.ToString(), fBody, Brushes.Black, apptInfoInnerRectangle, sf3);
     260
     261            // Move Drawing Rectangle Down
     262            printArea.Y += 300 + 30 + 20;
     263            printArea.Height -= 300 + 30 + 20;
     264
     265            // Draw New Line
     266            g.DrawLine(Pens.Black, printArea.Location, new Point(printArea.Right, printArea.Y));
     267            printArea.Y += 5;
     268            printArea.Height -= 5;
     269
     270            // Draw new Title
     271            s = strings.ClinicInstructions;
     272            g.DrawString(s, fTitle, Brushes.Black, printArea, sf); //title
     273
     274            // move down
     275            titleHeight = (int)g.MeasureString(s, fTitle, printArea.Width).Height;
     276            printArea.Y += titleHeight;
     277            printArea.Height -= titleHeight;
     278
     279            // Draw New Line
     280            g.DrawLine(Pens.Black, printArea.Location, new Point(printArea.Right, printArea.Y));
     281            printArea.Y += 15;
     282            printArea.Height -= 15;
     283
     284            // Get Resource Clinic Appointment Letter Text
     285            DataTable resources = CGDocumentManager.Current.GlobalDataSet.Tables["Resources"];
     286
     287            string ltrTxt = (from resource in resources.AsEnumerable()
     288                             where resource.Field<string>("RESOURCE_NAME") == appt.Resource
     289                             select resource.Field<string>("LETTER_TEXT")).SingleOrDefault<string>();
     290
     291            if (String.IsNullOrWhiteSpace(ltrTxt)) ltrTxt = strings.NoInstructionsProvided;
     292
     293            g.DrawString(ltrTxt, fBody, Brushes.Black, printArea, sf3);
     294
     295            int ltrTxtHeight = (int)g.MeasureString(ltrTxt, fBody).Height;
     296
     297            printArea.Y += ltrTxtHeight + 15;
     298            printArea.Height -= ltrTxtHeight + 15;
     299
     300            g.DrawLine(Pens.Black, printArea.Location, new Point(printArea.Right, printArea.Y));
     301            printArea.Y += 5;
     302            printArea.Height -= 5;
     303
     304            s = strings.Notes;
     305            g.DrawString(s, fTitle, Brushes.Black, printArea, sf); // Notes title
     306           
     307            // move down
     308            titleHeight = (int)g.MeasureString(s, fTitle, printArea.Width).Height;
     309            printArea.Y += titleHeight;
     310            printArea.Height -= titleHeight;
     311
     312            // Draw New Line
     313            g.DrawLine(Pens.Black, printArea.Location, new Point(printArea.Right, printArea.Y));
     314            printArea.Y += 15;
     315            printArea.Height -= 15;
     316
     317            // Draw Notes Area
     318            using (GraphicsPath path = GetRoundedRectPath(printArea, 15))
     319            {
     320                g.DrawPath(Pens.Black, path);
     321            }
     322
    295323            //use sf0 to print the footer (center all the way)
    296             s = "Printed: " + DateTime.Now.ToString();
     324            s = strings.Printed + ": " + DateTime.Now.ToString();
    297325            Font fFooter = new Font(FontFamily.GenericSerif, 7);
    298326            g.DrawString(s, fFooter, Brushes.Black, footerArea, sf0);
     
    510538        /// <param name="title">String to print for title</param>
    511539        /// <param name="e">etc</param>
    512         public virtual void PrintRoutingSlip(CGAppointment a, string title, PrintPageEventArgs e)
     540        public virtual void PrintRoutingSlip(CGAppointment appt, int apptOrder, PrintPageEventArgs e)
    513541        {
     542            // Prep
     543            Graphics g = e.Graphics;
    514544            Rectangle printArea = e.MarginBounds;
    515             Graphics g = e.Graphics;
     545            Rectangle pageArea = e.PageBounds;
     546            Rectangle headerArea = new Rectangle()
     547            {
     548                X = e.MarginBounds.X,
     549                Y = e.PageBounds.Y,
     550                Height = e.MarginBounds.Y - e.PageBounds.Y,
     551                Width = e.MarginBounds.Width
     552            };
     553            Rectangle footerArea = new Rectangle()
     554            {
     555                X = e.MarginBounds.X,
     556                Y = e.MarginBounds.Height + headerArea.Height,
     557                Width = e.MarginBounds.Width,
     558                Height = pageArea.Height - (e.MarginBounds.Height + headerArea.Height)
     559            };
     560
     561            const int part1Height = 400;
     562            string s;
     563
     564            // A few fonts
     565            Font fTitle = new Font(FontFamily.GenericSerif, 24, FontStyle.Bold); //for title
     566            Font fBody = new Font(FontFamily.GenericSerif, 12);
     567            Font fGroupTitle = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Bold);
     568
     569            StringFormat sf0 = new StringFormat()
     570            {
     571                Alignment = StringAlignment.Center,
     572                LineAlignment = StringAlignment.Center
     573            };
     574
     575            // Draw Header
     576            string division = CGDocumentManager.Current.ConnectInfo.DivisionName;
     577            g.DrawString(division, fBody, Brushes.Black, headerArea, sf0);
     578
     579            // Draw Title
    516580            StringFormat sf = new StringFormat();
    517             sf.Alignment = StringAlignment.Center; //for title
    518             Font fTitle = new Font(FontFamily.GenericSerif, 24, FontStyle.Bold); //for title
    519             Font fBody = new Font(FontFamily.GenericSerif, 18);
    520             Font fBodyEm = new Font(FontFamily.GenericSerif, 18, FontStyle.Bold);
     581            sf.Alignment = StringAlignment.Center; //for title & header
     582            string title = "Routing Slip";
    521583            g.DrawString(title, fTitle, Brushes.Black, printArea, sf); //title
    522584
     
    528590            // draw underline
    529591            g.DrawLine(Pens.Black, printArea.Location, new Point(printArea.Right, printArea.Y));
    530 
    531             // move down
    532592            printArea.Y += 15;
    533593            printArea.Height -= 15;
    534594
    535             //construct what to print
    536             string toprint = "Patient: " + a.PatientName + "\t" + "ID: " + a.HealthRecordNumber;
    537             toprint += "\n\n";
    538             toprint += "Clinic: " + a.Resource;
    539             toprint += "\n\n";
    540             toprint += "Appointment Time: " + a.StartTime;
    541             toprint += "\n\n";
    542             toprint += "Notes:\n" + a.Note;
    543 
    544             //print
    545             g.DrawString(toprint, fBody, Brushes.Black, printArea);
    546 
    547             // Print Date Printed
    548             //sf to move to bottom center
    549             StringFormat sf2 = new StringFormat();
    550             sf2.LineAlignment = StringAlignment.Far;
    551             sf2.Alignment = StringAlignment.Center;
    552 
    553             //Print
    554             Font fFooter = new Font(FontFamily.GenericSerif, 8);
    555             g.DrawString("Printed: " + DateTime.Now, fFooter, Brushes.Black, printArea, sf2);
     595            // draw curved rectangle.
     596            Rectangle personalInfoRectangle = new Rectangle(e.MarginBounds.X, printArea.Y + 30, 280, part1Height);
     597            using (GraphicsPath path = GetRoundedRectPath(personalInfoRectangle, 10))
     598            {
     599                g.DrawPath(Pens.Black, path);
     600            }
     601
     602            // group header
     603            g.DrawString("Patient Information", fGroupTitle, Brushes.Black, new Point(personalInfoRectangle.X, personalInfoRectangle.Y - 20));
     604
     605            // inner rectangle for drawing strings:
     606            Rectangle personalInfoInnerRectangle = new Rectangle(personalInfoRectangle.X + 20, personalInfoRectangle.Y + 20, personalInfoRectangle.Width - 40, personalInfoRectangle.Height - 40);
     607
     608            // Strings to write
     609            StringBuilder sb = new StringBuilder(500);
     610            sb.AppendLine("Name:" + "\t" + appt.Patient.Name);
     611            sb.AppendLine();
     612            sb.AppendLine("ID#:" + "\t" + appt.Patient.ID);
     613            sb.AppendLine();
     614            sb.AppendLine("DOB:" + "\t" + appt.Patient.DOB.ToShortDateString());
     615            sb.AppendLine();
     616            sb.AppendLine("Age:" + "\t" + appt.Patient.UserFriendlyAge);
     617            sb.AppendLine();
     618            sb.AppendLine("Sex:" + "\t" + appt.Patient.Sex.ToString());
     619
     620            // Draw them
     621            g.DrawString(sb.ToString(), fBody, Brushes.Black, personalInfoInnerRectangle);
     622
     623            // draw curved rectangle
     624            Rectangle apptInfoRectangle = new Rectangle(e.MarginBounds.X + e.MarginBounds.Width - 280, printArea.Y + 30, 280, part1Height);
     625            using (GraphicsPath path = GetRoundedRectPath(apptInfoRectangle, 10))
     626            {
     627                g.DrawPath(Pens.Black, path);
     628            }
     629
     630            // group header
     631            g.DrawString("Appointment Information", fGroupTitle, Brushes.Black, new Point(apptInfoRectangle.X, apptInfoRectangle.Y - 20));
     632
     633            // Strings to write
     634            sb = new StringBuilder();
     635            sb.AppendLine("Clinic:");
     636            sb.AppendLine(appt.Resource);
     637            sb.AppendLine();
     638            sb.AppendLine("Appointment Provider:");
     639            sb.AppendLine((appt.Provider == null) ? "(none)" : appt.Provider.ToString());  //Appt Provider or (none) if null
     640            sb.AppendLine();
     641            sb.AppendLine("Patient Order:" + "\t" + apptOrder);
     642            sb.AppendLine("Date: " + "\t" + appt.StartTime.ToShortDateString() + " " + appt.StartTime.ToShortTimeString());
     643            sb.AppendLine();
     644            sb.AppendLine("Appointment Note: ");
     645            sb.AppendLine(String.IsNullOrWhiteSpace(appt.Note)? "(none)" : appt.Note);
     646
     647            // Draw them
     648            Rectangle apptInfoInnerRectangle = new Rectangle(apptInfoRectangle.X + 20, apptInfoRectangle.Y + 20, apptInfoRectangle.Width - 40, apptInfoRectangle.Height - 40);
     649
     650            // Draw them
     651            g.DrawString(sb.ToString(), fBody, Brushes.Black, apptInfoInnerRectangle);
     652
     653            // Move Drawing Rectangle Down
     654            printArea.Y += apptInfoRectangle.Height + 30 + 20;
     655            printArea.Height -= apptInfoRectangle.Height + 30 + 20;
     656
     657            // Draw New Line
     658            using (Pen dashpen = new Pen(Color.Black))
     659            {
     660                dashpen.DashStyle = DashStyle.Dash;
     661                g.DrawLine(dashpen, printArea.Location, new Point(printArea.Right, printArea.Y));
     662            }
     663
     664            printArea.Y += 5;
     665            printArea.Height -= 5;
     666
     667            s = "Scratch Area";
     668            g.DrawString(s, fGroupTitle, Brushes.Black, printArea);
     669
     670            // move down
     671            printArea.Y += 300;
     672            printArea.Height -= 300;
     673
     674            //TODO: Put Next Appointment Area
     675            using (Pen dashpen = new Pen(Color.Black))
     676            {
     677                dashpen.DashStyle = DashStyle.Dot;
     678                g.DrawLine(dashpen, printArea.Location, new Point(printArea.Right, printArea.Y));
     679            }
     680
     681            printArea.Y += 5;
     682            printArea.Height -= 5;
     683
     684            s = "Next Appointment Instructions";
     685            g.DrawString(s, fGroupTitle, Brushes.Black, printArea);
     686
     687            // Draw Footer
     688            //use sf0 to print the footer (center all the way)
     689            s = "Printed: " + DateTime.Now.ToString();
     690            Font fFooter = new Font(FontFamily.GenericSerif, 7);
     691            g.DrawString(s, fFooter, Brushes.Black, footerArea, sf0);
     692
     693            g.Dispose();
     694
    556695        }
    557696
Note: See TracChangeset for help on using the changeset viewer.