Ignore:
Timestamp:
Aug 12, 2009, 7:14:16 PM (15 years ago)
Author:
Kevin Toppenberg
Message:

TMG Ver 1.1 Added HTML Support, better demographics editing

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cprs/branches/tmg-cprs/CPRS-Chart/rReports.pas

    r453 r541  
    44interface
    55
    6 uses Windows, SysUtils, Classes, ORNet, ORFn, ComCtrls, Chart, graphics;
     6uses
     7  Windows, SysUtils, Classes, ORNet, ORFn,
     8  Forms, //kt 8/09
     9  ComCtrls, Chart, graphics;
    710
    811{ Consults }
     
    4750           aComponents: TStringlist; ARemoteSiteID, ARemoteQuery, AHSTag: string): TStrings;
    4851procedure PrintWindowsReport(ARichEdit: TRichEdit; APageBreak, ATitle: string;
    49   var ErrMsg: string);
     52                             var ErrMsg: string; Application : TApplication); //kt 8/09 added Application
    5053function DefaultToWindowsPrinter: Boolean;
    5154procedure PrintGraph(GraphImage: TChart; PageTitle: string);
     
    6366
    6467uses uCore, rCore, Printers, clipbrd, uReports, fReports,
     68      rHTMLTools,  //kt 8/09
    6569      DKLang  //kt
    6670      ;
     
    541545end;
    542546
    543 procedure PrintWindowsReport(ARichEdit: TRichEdit; APageBreak, Atitle: string; var ErrMsg: string);
     547procedure PrintWindowsReport(ARichEdit: TRichEdit; APageBreak, Atitle: string;
     548                             var ErrMsg: string;
     549                             Application : TApplication //kt added 8/09
     550                             );
    544551var
    545552  i, j, x, y, LineHeight: integer;
    546553  aGoHead: string;
    547554  aHeader: TStringList;
     555  Header,Footer,TempLines: TStringList;  //kt added 8/09
     556  IsHTML : Boolean;                      //kt added 8/09
     557
    548558const
    549559//TX_ERR_CAP = 'Print Error';  <-- original line.  //kt 8/20/2007
     
    566576    end;
    567577  CreatePatientHeader(aHeader ,ATitle);
    568   with ARichEdit do
    569     begin
    570 (*      if Lines[Lines.Count - 1] = APageBreak then      //  remove trailing form feed
     578  IsHTML := rHTMLTools.IsHTML(ARichEdit.Lines); //kt 8/09
     579  if not IsHTML then begin  //kt 8/09
     580    with ARichEdit do  begin
     581  (*  if Lines[Lines.Count - 1] = APageBreak then      //  remove trailing form feed
    571582        Lines.Delete(Lines.Count - 1);
    572583      while (Lines[0] = '') or (Lines[0] = APageBreak) do
    573584        Lines.Delete(0);                               //  remove leading blank lines and form feeds*)
    574585
    575         {v20.4 - SFC-0602-62899 - RV}
    576         while (Lines.Count > 0) and ((Lines[Lines.Count - 1] = '') or (Lines[Lines.Count - 1] = APageBreak)) do
    577           Lines.Delete(Lines.Count - 1);                 //  remove trailing blank lines and form feeds
    578         while (Lines.Count > 0) and ((Lines[0] = '') or (Lines[0] = APageBreak)) do
    579           Lines.Delete(0);                               //  remove leading blank lines and form feeds
    580 
    581       if Lines.Count > 1 then
    582         begin
    583 (*          i := Lines.IndexOf(APageBreak);
    584           if ((i >= 0 ) and (i < Lines.Count - 1)) then        // removed in v15.9 (RV)
    585             begin*)
    586               Printer.Canvas.Font.Size := TX_FONT_SIZE;
    587               Printer.Canvas.Font.Name := TX_FONT_NAME;
    588               Printer.Title := ATitle;
    589               x := Trunc(Printer.Canvas.TextWidth(StringOfChar('=', TX_FONT_SIZE)) * 0.75);
    590               LineHeight := Printer.Canvas.TextHeight(TX_FONT_NAME);
    591               y := LineHeight * 5;            // 5 lines = .83" top margin   v15.9 (RV)
    592               Printer.BeginDoc;
    593               for i := 0 to Lines.Count - 1 do
    594                 begin
    595                   if Lines[i] = APageBreak then
    596                     begin
    597                       Printer.NewPage;
    598                       y := LineHeight * 5;   // 5 lines = .83" top margin    v15.9 (RV)
    599                       if aGoHead = '1' then
    600                         begin
    601                           for j := 0 to aHeader.Count - 1 do
    602                             begin
    603                               Printer.Canvas.TextOut(x, y, aHeader[j]);
    604                               y := y + LineHeight;
    605                             end;
    606                         end;
    607                     end
    608                   else
    609                     begin
    610                       Printer.Canvas.TextOut(x, y, Lines[i]);
    611                       y := y + LineHeight;
    612                     end;
    613                 end;
    614               Printer.EndDoc;
    615 (*            end
    616           else                               // removed in v15.9 (RV)  TRichEdit.Print no longer used.
     586      {v20.4 - SFC-0602-62899 - RV}
     587      while (Lines.Count > 0) and ((Lines[Lines.Count - 1] = '') or (Lines[Lines.Count - 1] = APageBreak)) do
     588        Lines.Delete(Lines.Count - 1);                 //  remove trailing blank lines and form feeds
     589      while (Lines.Count > 0) and ((Lines[0] = '') or (Lines[0] = APageBreak)) do
     590        Lines.Delete(0);                               //  remove leading blank lines and form feeds
     591
     592      if Lines.Count > 1 then begin
     593  (*    i := Lines.IndexOf(APageBreak);
     594        if ((i >= 0 ) and (i < Lines.Count - 1)) then        // removed in v15.9 (RV)
     595              begin*)
     596        Printer.Canvas.Font.Size := TX_FONT_SIZE;
     597        Printer.Canvas.Font.Name := TX_FONT_NAME;
     598        Printer.Title := ATitle;
     599        x := Trunc(Printer.Canvas.TextWidth(StringOfChar('=', TX_FONT_SIZE)) * 0.75);
     600        LineHeight := Printer.Canvas.TextHeight(TX_FONT_NAME);
     601        y := LineHeight * 5;            // 5 lines = .83" top margin   v15.9 (RV)
     602        Printer.BeginDoc;
     603        for i := 0 to Lines.Count - 1 do begin
     604          if Lines[i] = APageBreak then begin
     605            Printer.NewPage;
     606            y := LineHeight * 5;   // 5 lines = .83" top margin    v15.9 (RV)
     607            if aGoHead = '1' then begin
     608              for j := 0 to aHeader.Count - 1 do begin
     609                Printer.Canvas.TextOut(x, y, aHeader[j]);
     610                y := y + LineHeight;
     611              end;
     612            end;
     613          end else begin
     614            Printer.Canvas.TextOut(x, y, Lines[i]);
     615            y := y + LineHeight;
     616          end;
     617        end;
     618        Printer.EndDoc;
     619(*      end
     620        else                               // removed in v15.9 (RV)  TRichEdit.Print no longer used.
    617621            try
    618622              Font.Size := TX_FONT_SIZE;
     
    622626              ErrMsg := TX_ERR_CAP;
    623627            end;*)
    624         end
    625       else if ARichEdit.Lines.Count = 1 then
     628      end else if ARichEdit.Lines.Count = 1 then
    626629        if Piece(ARichEdit.Lines[0], U, 1) <> '0' then
    627630          ErrMsg := Piece(ARichEdit.Lines[0], U, 2);
    628631    end;
     632  end else begin  //kt added this entire block. 8/09
     633    TempLines := TStringList.Create;
     634    Header := TStringList.Create;
     635    Footer := TStringList.Create;
     636    TempLines.Assign(ARichEdit.Lines);
     637    StripBeforeAfterHTML(TempLines,Header,Footer);
     638    //LoadDocumentText(TempLines, FNote);  //Get document without headers/footers
     639    PrintHTMLReport(TempLines,ErrMsg,
     640                    Patient.Name,
     641                    FormatFMDateTime('mm/dd/yyyy', Patient.DOB),
     642                    Encounter.LocationName, Application);
     643    TempLines.Free;
     644    Header.Free;
     645    Footer.Free;
     646  end;  //kt end of added block 8/09
    629647  aHeader.Free;
    630648end;
Note: See TracChangeset for help on using the changeset viewer.