source: cprs/branches/tmg-cprs/CPRS-Chart/Orders/fOrderVw.pas@ 1531

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

Initial upload of TMG-CPRS 1.0.26.69

File size: 9.3 KB
Line 
1//kt -- Modified with SourceScanner on 8/8/2007
2unit fOrderVw;
3
4interface
5
6uses
7 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
8 fAutoSz, StdCtrls, ComCtrls, ExtCtrls, ORCtrls, ORFn, rOrders, ORDtTm,
9 DKLang;
10
11type
12 TfrmOrderView = class(TfrmAutoSz)
13 pnlView: TPanel;
14 lblView: TLabel;
15 Panel1: TPanel;
16 Panel2: TPanel;
17 lblFilter: TLabel;
18 trFilters: TCaptionTreeView;
19 Panel3: TPanel;
20 treService: TCaptionTreeView;
21 lblService: TLabel;
22 Panel4: TPanel;
23 chkDateRange: TCheckBox;
24 GroupBox1: TGroupBox;
25 lblFrom: TLabel;
26 lblThru: TLabel;
27 calFrom: TORDateBox;
28 calThru: TORDateBox;
29 chkInvChrono: TCheckBox;
30 chkByService: TCheckBox;
31 cmdOK: TButton;
32 cmdCancel: TButton;
33 Splitter1: TSplitter;
34 procedure FormCreate(Sender: TObject);
35 procedure treServiceClick(Sender: TObject);
36 procedure cmdCancelClick(Sender: TObject);
37 procedure cmdOKClick(Sender: TObject);
38 procedure chkDateRangeClick(Sender: TObject);
39 procedure calChange(Sender: TObject);
40 procedure trFiltersClick(Sender: TObject);
41 procedure Splitter1Moved(Sender: TObject);
42 private
43 FChanged: Boolean;
44 FDGroup: Integer;
45 FDGroupName: string;
46 FFilter: Integer;
47 FFilterName: string;
48 FInvChrono: Boolean;
49 FByService: Boolean;
50 FTimeFrom: TFMDateTime;
51 FTimeThru: TFMDateTime;
52 procedure LoadDGroups(const Parent: string; Node: TTreeNode);
53 procedure LoadFilters(const Parent: string; Node: TTreeNode);
54 procedure SynchViewData;
55 procedure UpdateViewName;
56 public
57 { Public declarations }
58 end;
59
60procedure SelectOrderView(var OrderView: TOrderView);
61
62implementation
63
64{$R *.DFM}
65
66//const
67//TX_DATES = 'To list orders for a specific date range, both From & Thru dates are required.'; <-- original line. //kt 8/8/2007
68//TC_DATES = 'Error in Date Range'; <-- original line. //kt 8/8/2007
69
70var
71 TX_DATES : string; //kt
72 TC_DATES : string; //kt
73
74procedure SetupVars;
75//kt Added entire function to replace constant declarations 8/8/2007
76begin
77 TX_DATES := DKLangConstW('fOrderVw_To_list_orders_for_a_specific_date_rangex_both_From_x_Thru_dates_are_requiredx');
78 TC_DATES := DKLangConstW('fOrderVw_Error_in_Date_Range');
79end;
80
81var
82 uDGroupList: TStringList;
83 uFilterList: TStringList;
84
85procedure SelectOrderView(var OrderView: TOrderView);
86var
87 frmOrderView: TfrmOrderView;
88begin
89 frmOrderView := TfrmOrderView.Create(Application);
90 try
91 ResizeFormToFont(TForm(frmOrderView));
92 with frmOrderView do
93 begin
94 FDGroup := OrderView.DGroup;
95 FFilter := OrderView.Filter;
96 FInvChrono := OrderView.InvChrono;
97 FByService := OrderView.ByService;
98 FTimeFrom := OrderView.TimeFrom;
99 FTimeThru := OrderView.TimeThru;
100 SynchViewData;
101 ShowModal;
102 if FChanged then
103 begin
104 OrderView.Changed := FChanged;
105 OrderView.DGroup := FDGroup;
106 OrderView.Filter := FFilter;
107 OrderView.InvChrono := FInvChrono;
108 OrderView.ByService := FByService;
109 OrderView.TimeFrom := FTimeFrom;
110 OrderView.TimeThru := FTimeThru;
111 OrderView.CtxtTime := 0; // set by RefreshOrderList
112 OrderView.TextView := 0; // set by RefreshOrderList
113 OrderView.ViewName := lblView.Caption;
114 OrderView.EventDelay.EventType := 'C';
115 OrderView.EventDelay.Specialty := 0; // treating specialty only for event delayed
116 OrderView.EventDelay.Effective := 0; // effective date only for discharge orders
117 end
118 else OrderView.Changed := False;
119 end; {with}
120 finally
121 frmOrderView.Release;
122 end;
123end;
124
125procedure TfrmOrderView.FormCreate(Sender: TObject);
126begin
127 inherited;
128 FChanged := False;
129 uDGroupList := TStringList.Create;
130 uFilterList := TStringList.Create;
131 try
132 ListDGroupAll(uDGroupList);
133 LoadDGroups('0', nil);
134
135 ListOrderFiltersAll(uFilterList);
136 LoadFilters('0', nil);
137 finally
138 uDGroupList.Free;
139 uDGroupList := nil;
140 uFilterList.Free;
141 uFilterList := nil;
142 end;
143end;
144
145procedure TfrmOrderView.UpdateViewName;
146const
147 FMT_TIME = 'mm/dd/yy';
148var
149 DateText, FilterText: string;
150begin
151 if chkDateRange.Checked
152 then DateText := ' (' + FormatFMDateTime(FMT_TIME, calFrom.FMDateTime) +
153 ' thru ' + FormatFMDateTIme(FMT_TIME, calThru.FMDateTime) + ')'
154 else DateText := '';
155 if FFilter in [6, 8, 9, 10, 19, 20]
156 then FilterText := FFilterName
157// else FilterText := FFilterName + ' Orders'; <-- original line. //kt 8/8/2007
158 else FilterText := FFilterName + DKLangConstW('fOrderVw_Orders'); //kt added 8/8/2007
159 lblView.Caption := FilterText + ' - ' + FDGroupName + DateText;
160end;
161
162procedure TfrmOrderView.SynchViewData;
163var
164 i: Integer;
165begin
166 with treService.Items do for i := 0 to Count - 1 do if Integer(Item[i].Data) = FDGroup then
167 begin
168 Item[i].Expanded := True;
169 Item[i].Selected := True;
170 FDGroupName := Item[i].Text;
171 Break;
172 end;
173
174 with trFilters.Items do for i := 0 to Count - 1 do if Integer(Item[i].Data) = FFilter then
175 begin
176 Item[i].Expanded := True;
177 Item[i].Selected := True;
178 FDGroupName := Item[i].Text;
179 Break;
180 end;
181
182 if (FTimeFrom > 0) or (FTimeThru > 0) then
183 begin
184 calFrom.FMDateTime := FTimeFrom;
185 calThru.FMDateTime := FTimeThru;
186 chkDateRange.Checked := True;
187 chkDateRangeClick(Self);
188 end;
189 UpdateViewName;
190 chkByService.Checked := FByService;
191 chkInvChrono.Checked := FInvChrono;
192end;
193
194procedure TfrmOrderView.LoadDGroups(const Parent: string; Node: TTreeNode);
195var
196 MyID, MyParent, Name: string;
197 i, IEN: Integer;
198 ChildNode: TTreeNode;
199 HasChildren: Boolean;
200begin
201 with uDGroupList do for i := 0 to Count - 1 do
202 begin
203 MyParent := Piece(Strings[i], U, 3);
204 if MyParent = Parent then
205 begin
206 MyID := Piece(Strings[i], U, 1);
207 IEN := StrToIntDef(MyID, 0);
208 Name := Piece(Strings[i], U, 2);
209 HasChildren := Piece(Strings[i], U, 4) = '+';
210 ChildNode := treService.Items.AddChildObject(Node, Name, Pointer(IEN));
211 if HasChildren then LoadDGroups(MyID, ChildNode);
212 end;
213 end;
214end;
215
216procedure TfrmOrderView.LoadFilters(const Parent: string; Node: TTreeNode);
217var
218 MyID, MyParent, Name: string;
219 i, IEN: Integer;
220 ChildNode: TTreeNode;
221 HasChildren: Boolean;
222begin
223 with uFilterList do for i := 0 to Count - 1 do
224 begin
225 MyParent := Piece(Strings[i], U, 3);
226 if MyParent = Parent then
227 begin
228 MyID := Piece(Strings[i], U, 1);
229 IEN := StrToIntDef(MyID, 0);
230 Name := Piece(Strings[i], U, 2);
231 HasChildren := Piece(Strings[i], U, 4) = '+';
232 ChildNode := trFilters.Items.AddChildObject(Node, Name, Pointer(IEN));
233 if HasChildren then LoadFilters(MyID, ChildNode);
234 end;
235 end;
236end;
237
238procedure TfrmOrderView.treServiceClick(Sender: TObject);
239var
240 Node: TTreeNode;
241begin
242 inherited;
243 Node := treService.Selected;
244 if Node <> nil then
245 begin
246 FDGroup := Integer(Node.Data);
247 FDGroupName := Node.Text;
248 UpdateViewName;
249 end;
250end;
251
252procedure TfrmOrderView.chkDateRangeClick(Sender: TObject);
253begin
254 inherited;
255 lblThru.Enabled := chkDateRange.Checked;
256 calThru.Enabled := chkDateRange.Checked;
257 lblFrom.Enabled := chkDateRange.Checked;
258 calFrom.Enabled := chkDateRange.Checked;
259 if chkDateRange.Checked then
260 begin
261 calFrom.Color := clWindow;
262 calThru.Color := clWindow;
263 if calThru.FMDateTime = 0 then calThru.Text := 'NOW';
264 end else
265 begin
266 calFrom.FMDateTime := 0;
267 calThru.FMDateTime := 0;
268 calFrom.Color := clBtnFace;
269 calThru.Color := clBtnFace;
270 end;
271 UpdateViewName;
272end;
273
274procedure TfrmOrderView.calChange(Sender: TObject);
275begin
276 inherited;
277 UpdateViewName;
278end;
279
280procedure TfrmOrderView.cmdOKClick(Sender: TObject);
281begin
282 SetupVars; //kt added 8/8/2007 to replace constants with vars.
283 inherited;
284 if chkDateRange.Checked and ((not calFrom.IsValid) or (not calThru.IsValid)) then
285 begin
286 InfoBox(TX_DATES, TC_DATES, MB_OK);
287 Exit;
288 end;
289 if chkDateRange.Checked then
290 begin
291 FTimeFrom := calFrom.FMDateTime;
292 FTimeThru := calThru.FMDateTime;
293 end else
294 begin
295 FTimeFrom := 0;
296 FTimeThru := 0;
297 end;
298 FChanged := True;
299 FInvChrono := chkInvChrono.Checked;
300 FByService := chkByService.Checked;
301 Close;
302end;
303
304procedure TfrmOrderView.cmdCancelClick(Sender: TObject);
305begin
306 inherited;
307 Close;
308end;
309
310procedure TfrmOrderView.trFiltersClick(Sender: TObject);
311var
312 Node: TTreeNode;
313begin
314 inherited;
315 Node := trFilters.Selected;
316 if Node <> nil then
317 begin
318 FFilter := Integer(Node.Data);
319 FFilterName := Node.Text;
320 if FFilter = 2 then // disallow date range for active orders view
321 begin
322 chkDateRange.Checked := False;
323 chkDateRangeClick(Self);
324 end;
325 if FFilter in [8, 9, 10, 20] then chkDateRange.Checked := True else
326 begin
327 if (calFrom.Text = '') and (calThru.Text = '') then chkDateRange.Checked := False;
328 end;
329 UpdateViewName;
330 end;
331end;
332
333procedure TfrmOrderView.Splitter1Moved(Sender: TObject);
334begin
335 inherited;
336 Splitter1.Align := alNone;
337 Splitter1.Align := alLeft;
338end;
339
340end.
Note: See TracBrowser for help on using the repository browser.