source: cprs/branches/foia-cprs/CPRS-Chart/Options/fOptionsOther.pas@ 1328

Last change on this file since 1328 was 460, checked in by Kevin Toppenberg, 16 years ago

Uploading from OR_30_258

File size: 7.6 KB
Line 
1unit fOptionsOther;
2
3interface
4
5uses
6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
7 StdCtrls, ExtCtrls, ComCtrls, ORCtrls, ORFn, rOrders, uCore, ORDtTm;
8
9type
10 TfrmOptionsOther = class(TForm)
11 pnlBottom: TPanel;
12 btnOK: TButton;
13 btnCancel: TButton;
14 bvlBottom: TBevel;
15 stStart: TStaticText;
16 stStop: TStaticText;
17 dtStart: TORDateBox;
18 dtStop: TORDateBox;
19 lblMedsTab: TLabel;
20 lblTabDefault: TStaticText;
21 lblTab: TLabel;
22 cboTab: TORComboBox;
23 chkLastTab: TCheckBox;
24 Bevel1: TBevel;
25 lblEncAppts: TLabel;
26 stStartEncAppts: TStaticText;
27 txtTodayMinus: TStaticText;
28 txtEncStart: TCaptionEdit;
29 txtDaysMinus: TStaticText;
30 spnEncStart: TUpDown;
31 txtDaysPlus: TStaticText;
32 spnEncStop: TUpDown;
33 txtEncStop: TCaptionEdit;
34 txtTodayPlus: TStaticText;
35 stStopEncAppts: TStaticText;
36 Bevel2: TBevel;
37 btnEncDefaults: TButton;
38 procedure FormShow(Sender: TObject);
39 procedure btnOKClick(Sender: TObject);
40 procedure FormCreate(Sender: TObject);
41 procedure dtStartExit(Sender: TObject);
42 procedure dtStopExit(Sender: TObject);
43 procedure dtStartChange(Sender: TObject);
44 procedure txtEncStartChange(Sender: TObject);
45 procedure txtEncStopChange(Sender: TObject);
46 procedure txtEncStartExit(Sender: TObject);
47 procedure txtEncStopExit(Sender: TObject);
48 procedure btnEncDefaultsClick(Sender: TObject);
49 private
50 { Private declarations }
51 FstartDt: TFMDateTime;
52 FstopDt: TFMDateTime;
53 FEncStartDays, FEncStopDays, FEncDefStartDays, FEncDefStopDays: integer;
54 //FDefaultEvent: string;
55 public
56 { Public declarations }
57 end;
58
59var
60 frmOptionsOther: TfrmOptionsOther;
61
62const
63 ENC_MAX_LIMIT = 999;
64
65procedure DialogOptionsOther(topvalue, leftvalue, fontsize: integer; var actiontype: Integer);
66
67implementation
68
69{$R *.DFM}
70
71uses
72 rOptions, uOptions, rCore, rSurgery, uConst, fMeds;
73
74procedure DialogOptionsOther(topvalue, leftvalue, fontsize: integer; var actiontype: Integer);
75// create the form and make it modal, return an action
76var
77 frmOptionsOther: TfrmOptionsOther;
78begin
79 frmOptionsOther := TfrmOptionsOther.Create(Application);
80 actiontype := 0;
81 try
82 with frmOptionsOther do
83 begin
84 if (topvalue < 0) or (leftvalue < 0) then
85 Position := poScreenCenter
86 else
87 begin
88 Position := poDesigned;
89 Top := topvalue;
90 Left := leftvalue;
91 end;
92 ResizeAnchoredFormToFont(frmOptionsOther);
93 ShowModal;
94 actiontype := btnOK.Tag;
95 end;
96 finally
97 frmOptionsOther.Release;
98 end;
99end;
100
101procedure TfrmOptionsOther.FormShow(Sender: TObject);
102// displays defaults
103// opening tab^use last tab^autosave seconds^verify note title
104var
105 last: integer;
106 values, tab: string;
107begin
108 cboTab.Items.Assign(rpcGetOtherTabs);
109 if (cboTab.Items.IndexOf('Surgery') > -1) and (not ShowSurgeryTab) then
110 cboTab.Items.Delete(cboTab.Items.IndexOf('Surgery'));
111 values := rpcGetOther;
112 tab := Piece(values, '^', 1);
113 last := strtointdef(Piece(values, '^', 2), 0);
114 cboTab.SelectByID(tab);
115 cboTab.Tag := strtointdef(tab, -1);
116 chkLastTab.Checked := last = 1;
117 chkLastTab.Tag := last;
118 cboTab.SetFocus;
119 rpcGetRangeForMeds(FstartDt, FstopDt);
120 if FstartDt > 1 then
121 dtStart.Text := FormatFMDateTime('mmm d, yyyy',FstartDt);
122 if FstopDt > 1 then
123 dtStop.Text := FormatFMDateTime('mmm d, yyyy', FstopDt);
124 rpcGetRangeForEncs(FEncDefStartDays, FEncDefStopDays, True); // True gets params settings above User/Service level.
125 if FEncDefStartDays < 1 then
126 FEncDefStartDays := 0;
127 if FEncDefStopDays < 1 then
128 FEncDefStopDays := 0;
129 rpcGetRangeForEncs(FEncStartDays, FEncStopDays, False); // False gets User/Service params.
130 if ((FEncStartDays < 0) and (FEncStartDays <> 0)) then
131 FEncStartDays := FEncDefStartDays;
132 txtEncStart.Text := IntToStr(FEncStartDays);
133 if ((FEncStopDays < 0) and (FEncStopDays <> 0)) then
134 FEncStopDays := FEncDefStopDays;
135 txtEncStop.Text := IntToStr(FEncStopDays);
136end;
137
138procedure TfrmOptionsOther.btnOKClick(Sender: TObject);
139// opening tab^use last tab^autosave seconds^verify note title
140var
141 values, theVal: string;
142begin
143 values := '';
144 if cboTab.ItemIEN <> cboTab.Tag then
145 values := values + cboTab.ItemID;
146 values := values + '^';
147 if chkLastTab.Checked then
148 if chkLastTab.Tag <> 1 then
149 values := values + '1';
150 if not chkLastTab.Checked then
151 if chkLastTab.Tag <> 0 then
152 values := values + '0';
153 values := values + '^^';
154 rpcSetOther(values);
155 if (dtStop.FMDateTime > 0) and (dtStart.FMDateTime > 0) then
156 begin
157 if dtStop.FMDateTime < dtStart.FMDateTime then
158 begin
159 ShowMessage('The stop time can not prior to the start time.');
160 dtStop.FMDateTime := FMToday;
161 dtStop.SetFocus;
162 Exit;
163 end;
164 theVal := dtStart.RelativeTime + ';' + dtStop.RelativeTime;
165 rpcPutRangeForMeds(theVal);
166 end;
167 if (dtStart.Text = '') and (dtStop.Text = '') then
168 rpcPutRangeForMeds('');
169 rpcPutRangeForEncs(txtEncStart.Text, txtEncStop.Text);
170 if frmMeds <> nil then
171 frmMeds.RefreshMedLists;
172end;
173
174procedure TfrmOptionsOther.FormCreate(Sender: TObject);
175begin
176 FStartDT := 0;
177 FStopDT := 0;
178end;
179
180procedure TfrmOptionsOther.dtStartExit(Sender: TObject);
181begin
182 if dtStart.FMDateTime > FMToday then
183 begin
184 ShowMessage('Start time can not greater than today.');
185 dtStart.FMDateTime := FMToday;
186 dtStart.SetFocus;
187 Exit;
188 end;
189end;
190
191procedure TfrmOptionsOther.dtStopExit(Sender: TObject);
192begin
193 if (dtStop.FMDateTime > 0) and (dtStart.FMDateTime > 0) then
194 if (dtStop.FMDateTime < dtStart.FMDateTime) then
195 begin
196 ShowMessage('Stop time can not prior to start time');
197 dtStop.FMDateTime := FMToday;
198 dtStop.SetFocus;
199 Exit;
200 end;
201end;
202
203procedure TfrmOptionsOther.dtStartChange(Sender: TObject);
204begin
205 if (dtStart.FMDateTime > FMToday) then
206 begin
207 ShowMessage('Start time can not greater than today.');
208 dtStart.FMDateTime := FMToday;
209 dtStart.SetFocus;
210 Exit;
211 end;
212end;
213
214procedure TfrmOptionsOther.txtEncStartChange(Sender: TObject);
215begin
216with txtEncStart do
217 begin
218 if Text = '' then
219 Exit;
220 if Text = ' ' then
221 Text := '0';
222 if StrToInt(Text) < 0 then
223 Text := '0';
224 if StrToIntDef(Text, ENC_MAX_LIMIT) > ENC_MAX_LIMIT then
225 begin
226 Text := IntToStr(ENC_MAX_LIMIT);
227 Beep;
228 InfoBox('Number must be < ' + IntToStr(ENC_MAX_LIMIT), 'Warning', MB_OK or MB_ICONWARNING);
229 end;
230 end;
231end;
232
233procedure TfrmOptionsOther.txtEncStopChange(Sender: TObject);
234begin
235with txtEncStop do
236 begin
237 if Text = '' then
238 Exit;
239 if Text = ' ' then
240 Text := '0';
241 if StrToInt(Text) < 0 then
242 Text := '0';
243 if StrToIntDef(Text, ENC_MAX_LIMIT) > ENC_MAX_LIMIT then
244 begin
245 Text := IntToStr(ENC_MAX_LIMIT);
246 Beep;
247 InfoBox('Number must be < ' + IntToStr(ENC_MAX_LIMIT), 'Warning', MB_OK or MB_ICONWARNING);
248 end;
249 end;
250end;
251
252procedure TfrmOptionsOther.txtEncStartExit(Sender: TObject);
253begin
254with txtEncStart do
255 if Text = '' then
256 Text := '0';
257end;
258
259procedure TfrmOptionsOther.txtEncStopExit(Sender: TObject);
260begin
261with txtEncStart do
262 if Text = '' then
263 Text := '0';
264end;
265
266procedure TfrmOptionsOther.btnEncDefaultsClick(Sender: TObject);
267begin
268txtEncStart.Text := IntToStr(FEncDefStartDays);
269txtEncStop.Text := IntToStr(FEncDefStopDays);
270end;
271
272end.
Note: See TracBrowser for help on using the repository browser.