1 | unit fAllgyBox;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
---|
7 | Dialogs, fRptBox, StdCtrls, ExtCtrls, ComCtrls, fARTAllgy, ORFn;
|
---|
8 |
|
---|
9 | type
|
---|
10 | TfrmAllgyBox = class(TfrmReportBox)
|
---|
11 | cmdEdit: TButton;
|
---|
12 | cmdAdd: TButton;
|
---|
13 | cmdInError: TButton;
|
---|
14 | procedure cmdAddClick(Sender: TObject);
|
---|
15 | procedure cmdEditClick(Sender: TObject);
|
---|
16 | procedure cmdInErrorClick(Sender: TObject);
|
---|
17 | private
|
---|
18 | { Private declarations }
|
---|
19 | FAllergyIEN: integer;
|
---|
20 | procedure RefreshText;
|
---|
21 | public
|
---|
22 | { Public declarations }
|
---|
23 | end;
|
---|
24 |
|
---|
25 | procedure AllergyBox(ReportText: TStrings; ReportTitle: string; AllowPrint: boolean; AllergyIEN: integer);
|
---|
26 |
|
---|
27 | var
|
---|
28 | frmAllgyBox: TfrmAllgyBox;
|
---|
29 |
|
---|
30 | implementation
|
---|
31 |
|
---|
32 | {$R *.dfm}
|
---|
33 |
|
---|
34 | uses rCover, fCover, rODAllergy;
|
---|
35 |
|
---|
36 | const
|
---|
37 | NEW_ALLERGY = True;
|
---|
38 | ENTERED_IN_ERROR = True;
|
---|
39 |
|
---|
40 | function CreateAllergyBox(ReportText: TStrings; ReportTitle: string; AllowPrint: boolean): TfrmAllgyBox;
|
---|
41 | var
|
---|
42 | i, AWidth, MaxWidth, AHeight: Integer;
|
---|
43 | Rect: TRect;
|
---|
44 | // %$@# buttons!
|
---|
45 | BtnArray: array of TButton;
|
---|
46 | BtnRight: array of integer;
|
---|
47 | BtnLeft: array of integer;
|
---|
48 | j, k: integer;
|
---|
49 | x: string;
|
---|
50 | begin
|
---|
51 | Result := TfrmAllgyBox.Create(Application);
|
---|
52 | try
|
---|
53 | with Result do
|
---|
54 | begin
|
---|
55 | k := 0;
|
---|
56 | with pnlButton do for j := 0 to ControlCount - 1 do
|
---|
57 | if Controls[j] is TButton then
|
---|
58 | begin
|
---|
59 | SetLength(BtnArray, k+1);
|
---|
60 | SetLength(BtnRight, k+1);
|
---|
61 | BtnArray[j] := TButton(Controls[j]);
|
---|
62 | BtnRight[j] := ResizeWidth(Font, MainFont, BtnArray[j].Width - BtnArray[j].Width - BtnArray[j].Left);
|
---|
63 | k := k + 1;
|
---|
64 | end;
|
---|
65 | MaxWidth := 350;
|
---|
66 | for i := 0 to ReportText.Count - 1 do
|
---|
67 | begin
|
---|
68 | AWidth := lblFontTest.Canvas.TextWidth(ReportText[i]);
|
---|
69 | if AWidth > MaxWidth then MaxWidth := AWidth;
|
---|
70 | end;
|
---|
71 | MaxWidth := MaxWidth + GetSystemMetrics(SM_CXVSCROLL);
|
---|
72 | AHeight := (ReportText.Count * (lblFontTest.Height + 2)) + pnlbutton.Height;
|
---|
73 | AHeight := HigherOf(AHeight, 250);
|
---|
74 | if AHeight > (Screen.Height - 80) then AHeight := Screen.Height - 80;
|
---|
75 | if MaxWidth > Screen.Width then MaxWidth := Screen.Width;
|
---|
76 | ClientWidth := MaxWidth;
|
---|
77 | ClientHeight := AHeight;
|
---|
78 | Rect := BoundsRect;
|
---|
79 | ForceInsideWorkArea(Rect);
|
---|
80 | BoundsRect := Rect;
|
---|
81 | ResizeAnchoredFormToFont(Result);
|
---|
82 | SetLength(BtnLeft, k);
|
---|
83 | for j := 0 to k - 1 do
|
---|
84 | BtnLeft[j] := pnlButton.Width - BtnArray[j].Width - BtnRight[j];
|
---|
85 | memReport.Lines.Assign(ReportText);
|
---|
86 | for i := 1 to Length(ReportTitle) do if ReportTitle[i] = #9 then ReportTitle[i] := ' ';
|
---|
87 | Caption := ReportTitle;
|
---|
88 | memReport.SelStart := 0;
|
---|
89 | cmdPrint.Visible := AllowPrint;
|
---|
90 | cmdAdd.Enabled := True; //IsARTClinicalUser(x); v26.12
|
---|
91 | cmdEdit.Enabled := IsARTClinicalUser(x);
|
---|
92 | cmdInError.Enabled := IsARTClinicalUser(x);
|
---|
93 | end;
|
---|
94 | except
|
---|
95 | KillObj(@Result);
|
---|
96 | raise;
|
---|
97 | end;
|
---|
98 | end;
|
---|
99 |
|
---|
100 | procedure AllergyBox(ReportText: TStrings; ReportTitle: string; AllowPrint: boolean; AllergyIEN: integer);
|
---|
101 | begin
|
---|
102 | frmAllgyBox := CreateAllergyBox(ReportText, ReportTitle, AllowPrint);
|
---|
103 | try
|
---|
104 | with frmAllgyBox do
|
---|
105 | begin
|
---|
106 | FAllergyIEN := AllergyIEN;
|
---|
107 | if not ContainsVisibleChar(memReport.Text) then RefreshText;
|
---|
108 | ShowModal;
|
---|
109 | end;
|
---|
110 | finally
|
---|
111 | frmAllgyBox.Release;
|
---|
112 | end;
|
---|
113 | end;
|
---|
114 |
|
---|
115 | procedure TfrmAllgyBox.cmdAddClick(Sender: TObject);
|
---|
116 | var
|
---|
117 | Changed: boolean;
|
---|
118 | begin
|
---|
119 | inherited;
|
---|
120 | Visible := False;
|
---|
121 | Changed := EnterEditAllergy(0, NEW_ALLERGY, not ENTERED_IN_ERROR);
|
---|
122 | if not Changed then
|
---|
123 | Close
|
---|
124 | else
|
---|
125 | begin
|
---|
126 | frmCover.UpdateAllergiesList;
|
---|
127 | Close;
|
---|
128 | end
|
---|
129 | end;
|
---|
130 |
|
---|
131 | procedure TfrmAllgyBox.cmdEditClick(Sender: TObject);
|
---|
132 | var
|
---|
133 | Changed: boolean;
|
---|
134 | begin
|
---|
135 | inherited;
|
---|
136 | Visible := False;
|
---|
137 | Changed := EnterEditAllergy(FAllergyIEN, not NEW_ALLERGY, not ENTERED_IN_ERROR);
|
---|
138 | if Changed then RefreshText;
|
---|
139 | Visible := True;
|
---|
140 | end;
|
---|
141 |
|
---|
142 | procedure TfrmAllgyBox.cmdInErrorClick(Sender: TObject);
|
---|
143 | var
|
---|
144 | Changed: boolean;
|
---|
145 | begin
|
---|
146 | inherited;
|
---|
147 | Visible := False;
|
---|
148 | Changed := MarkEnteredInError(FAllergyIEN);
|
---|
149 | if Changed then
|
---|
150 | begin
|
---|
151 | frmCover.UpdateAllergiesList;
|
---|
152 | Close;
|
---|
153 | end
|
---|
154 | else Visible := True;
|
---|
155 | end;
|
---|
156 |
|
---|
157 | procedure TfrmAllgyBox.RefreshText;
|
---|
158 | begin
|
---|
159 | memReport.Clear;
|
---|
160 | memReport.Lines.Assign(DetailAllergy(FAllergyIEN));
|
---|
161 | end;
|
---|
162 |
|
---|
163 | end.
|
---|