source: cprs/branches/HealthSevak-CPRS/CPRS-Chart/Orders/fOrderVw.pas@ 1727

Last change on this file since 1727 was 829, checked in by Kevin Toppenberg, 14 years ago

Upgrade to version 27

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