source: cprs/branches/tmg-cprs/CPRS-Chart/fPtDemo.pas@ 697

Last change on this file since 697 was 541, checked in by Kevin Toppenberg, 15 years ago

TMG Ver 1.1 Added HTML Support, better demographics editing

File size: 5.4 KB
RevLine 
[453]1unit fPtDemo;
2
3interface
4
5uses
6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
7 StdCtrls, ExtCtrls, ORCtrls, ORFn, ComCtrls, DKLang;
8
9type
10 TfrmPtDemo = class(TForm)
11 lblFontTest: TLabel;
12 memPtDemo: TRichEdit;
13 pnlTop: TORAutoPanel;
14 cmdNewPt: TButton;
15 cmdClose: TButton;
16 cmdPrint: TButton;
17 dlgPrintReport: TPrintDialog;
18 DKLanguageController1: TDKLanguageController;
19 EditaPtButton: TButton;
20 procedure cmdCloseClick(Sender: TObject);
21 procedure cmdNewPtClick(Sender: TObject);
22 procedure FormCreate(Sender: TObject);
23 procedure cmdPrintClick(Sender: TObject);
24 procedure EditaPtButtonClick(Sender: TObject);
25 private
26 { Private declarations }
27 FNewPt: Boolean;
28 public
29 { Public declarations }
30 end;
31
32procedure PatientInquiry(var NewPt: Boolean);
33
34implementation
35
36{$R *.DFM}
37
38uses rCover, rReports, Printers, uCore, fPtDemoEdit, fFrame;
39
40procedure PatientInquiry(var NewPt: Boolean);
41{ displays patient demographics, returns true in NewPt if the user pressed 'Select New' btn }
42var
43 frmPtDemo: TfrmPtDemo;
44begin
45 if StrToInt64Def(Patient.DFN, 0) <= 0 then exit;
46 frmPtDemo := TfrmPtDemo.Create(Application);
47 try
48 with frmPtDemo do
49 begin
50 frmPtDemo.ShowModal;
51 NewPt := FNewPt;
52 end; {with frmPtDemo}
53 finally
54 frmPtDemo.Release;
55 end;
56end;
57
58procedure TfrmPtDemo.FormCreate(Sender: TObject);
59var
60 i, MaxWidth, AWidth, AHeight: Integer;
61 Rect: TRect;
62begin
63 memPtDemo.Color := ReadOnlyColor;
64 FNewPt := False;
65 LoadDemographics(memPtDemo.Lines);
66 memPtDemo.SelStart := 0;
67 ResizeAnchoredFormToFont(self);
68 MaxWidth := 350; // make sure at least 350 wide
69 for i := 0 to memPtDemo.Lines.Count - 1 do
70 begin
71 AWidth := lblFontTest.Canvas.TextWidth(memPtDemo.Lines[i]);
72 if AWidth > MaxWidth then MaxWidth := AWidth;
73 end;
74 { width = borders + inset of memo box (left=8) }
75 MaxWidth := MaxWidth + (GetSystemMetrics(SM_CXFRAME) * 2)
76 + GetSystemMetrics(SM_CXVSCROLL) + 16;
77 { height = height of lines + title bar + borders + 4 lines (room for buttons) }
78 AHeight := ((memPtDemo.Lines.Count + 4) * (lblFontTest.Height + 1))
79 + (GetSystemMetrics(SM_CYFRAME) * 3) + GetSystemMetrics(SM_CYCAPTION);
80 AHeight := HigherOf(AHeight, 250); // make sure at least 250 high
81 if AHeight > (Screen.Height - 120) then AHeight := Screen.Height - 120;
82 if MaxWidth > Screen.Width then MaxWidth := Screen.Width;
83 Width := MaxWidth;
84 Height := AHeight;
85 Rect := BoundsRect;
86 EditaPtButton.Visible := boolTMGPatchInstalled; //elh 6/20/08
87 ForceInsideWorkArea(Rect);
88 BoundsRect := Rect;
89end;
90
91procedure TfrmPtDemo.cmdNewPtClick(Sender: TObject);
92begin
93 FNewPt := True;
94 Close;
95end;
96
97procedure TfrmPtDemo.cmdCloseClick(Sender: TObject);
98begin
99 Close;
100end;
101
102procedure TfrmPtDemo.cmdPrintClick(Sender: TObject);
103var
104 AHeader: TStringList;
105 memPrintReport: TRichEdit;
106 StartLine, MaxLines, LastLine, ThisPage, i: integer;
107 ErrMsg: string;
108 RemoteSiteID: string; //for Remote site printing
109 RemoteQuery: string; //for Remote site printing
110const
111 PAGE_BREAK = '**PAGE BREAK**';
112begin
113 RemoteSiteID := '';
114 RemoteQuery := '';
115 if dlgPrintReport.Execute then
116 begin
117 AHeader := TStringList.Create;
118 CreatePatientHeader(AHeader, Self.Caption);
119 memPrintReport := TRichEdit.Create(Self);
120 try
121 MaxLines := 60 - AHeader.Count;
122 LastLine := 0;
123 ThisPage := 0;
124 with memPrintReport do
125 begin
126 Visible := False;
127 Parent := Self;
128 Width := Printer.Canvas.TextWidth(StringOfChar('-', 74));
129 Font.Name := 'Courier New';
130 Font.Size := MainFontSize;
131 StartLine := 4;
132 repeat
133 with Lines do
134 begin
135 AddStrings(AHeader);
136 for i := StartLine to MaxLines do
137 //if i < memPtDemo.Lines.Count - 1 then
138 if i < memPtDemo.Lines.Count then
139 Add(memPtDemo.Lines[LastLine + i])
140 else
141 Break;
142 LastLine := LastLine + i;
143 Add(' ');
144 Add(' ');
145 Add(StringOfChar('-', 74));
146 if LastLine >= memPtDemo.Lines.Count - 1 then
147 Add('End of report')
148 else
149 begin
150 ThisPage := ThisPage + 1;
151 Add('Page ' + IntToStr(ThisPage));
152 Add(PAGE_BREAK);
153 StartLine := 0;
154 end;
155 end;
156 until LastLine >= memPtDemo.Lines.Count - 1;
[541]157 PrintWindowsReport(memPrintReport, PAGE_BREAK, Self.Caption, ErrMsg, Application); //kt 8/09 added 'Application'
[453]158 end;
159 finally
160 memPrintReport.Free;
161 AHeader.Free;
162 end;
163 end;
164 memPtDemo.SelStart := 0;
165 memPtDemo.Invalidate;
166end;
167
168procedure TfrmPtDemo.EditaPtButtonClick(Sender: TObject); //kt adde procedure 6/6/08
169var EditResult : integer;
170begin
171 EditResult := frmPtDemoEdit.ShowModal;
172 Close; //close this form
173 if EditResult <> mrCancel then frmFrame.mnuFileRefreshClick(Sender);
174end;
175
176end.
Note: See TracBrowser for help on using the repository browser.