Module

fOrderVw

Path

C:\CPRS\CPRS30\Orders\fOrderVw.pas

Last Modified

7/15/2014 3:26:42 PM

Units Used in Interface

Name Comments
fAutoSz -
rOrders -

Classes

Name Comments
TfrmOrderView -

Procedures

Name Owner Declaration Scope Comments
calChange TfrmOrderView procedure calChange(Sender: TObject); Public/Published -
chkDateRangeClick TfrmOrderView procedure chkDateRangeClick(Sender: TObject); Public/Published -
cmdCancelClick TfrmOrderView procedure cmdCancelClick(Sender: TObject); Public/Published -
cmdOKClick TfrmOrderView procedure cmdOKClick(Sender: TObject); Public/Published -
FormCreate TfrmOrderView procedure FormCreate(Sender: TObject); Public/Published -
LoadDGroups TfrmOrderView procedure LoadDGroups(const Parent: string; Node: TTreeNode); Private -
LoadFilters TfrmOrderView procedure LoadFilters(const Parent: string; Node: TTreeNode); Private -
SelectOrderView - procedure SelectOrderView(var OrderView: TOrderView); Interfaced -
Splitter1Moved TfrmOrderView procedure Splitter1Moved(Sender: TObject); Public/Published -
SynchViewData TfrmOrderView procedure SynchViewData; Private -
treServiceClick TfrmOrderView procedure treServiceClick(Sender: TObject); Public/Published -
trFiltersClick TfrmOrderView procedure trFiltersClick(Sender: TObject); Public/Published -
UpdateViewName TfrmOrderView procedure UpdateViewName; Private -

Global Variables

Name Type Declaration Comments
uDGroupList TStringList uDGroupList: TStringList; -
uFilterList TStringList uFilterList: TStringList; -

Constants

Name Declaration Scope Comments
TC_DATES 'Error in Date Range' Global -
TX_DATES 'To list orders for a specific date range, both From & Thru dates are required.' Global -


Module Source

1     unit fOrderVw;
2     
3     interface
4     
5     uses
6       Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
7       fAutoSz, StdCtrls, ComCtrls, ExtCtrls, ORCtrls, ORFn, rOrders, ORDtTm,
8       VA508AccessibilityManager;
9     
10    type
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    
59    procedure SelectOrderView(var OrderView: TOrderView);
60    
61    implementation
62    
63    {$R *.DFM}
64    
65    const
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    
69    var
70      uDGroupList: TStringList;
71      uFilterList: TStringList;
72    
73    procedure SelectOrderView(var OrderView: TOrderView);
74    var
75      frmOrderView: TfrmOrderView;
76    begin
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;
111   end;
112   
113   procedure TfrmOrderView.FormCreate(Sender: TObject);
114   begin
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;
131   end;
132   
133   procedure TfrmOrderView.UpdateViewName;
134   const
135     FMT_TIME = 'mm/dd/yy';
136   var
137     DateText, FilterText: string;
138   begin
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;
147   end;
148   
149   procedure TfrmOrderView.SynchViewData;
150   var
151     i: Integer;
152   begin
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;
180   end;
181   
182   procedure TfrmOrderView.LoadDGroups(const Parent: string; Node: TTreeNode);
183   var
184     MyID, MyParent, Name: string;
185     i, IEN: Integer;
186     ChildNode: TTreeNode;
187     HasChildren: Boolean;
188   begin
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;
202   end;
203   
204   procedure TfrmOrderView.LoadFilters(const Parent: string; Node: TTreeNode);
205   var
206     MyID, MyParent, Name: string;
207     i, IEN: Integer;
208     ChildNode: TTreeNode;
209     HasChildren: Boolean;
210   begin
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;
224   end;
225   
226   procedure TfrmOrderView.treServiceClick(Sender: TObject);
227   var
228     Node: TTreeNode;
229   begin
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;
238   end;
239   
240   procedure TfrmOrderView.chkDateRangeClick(Sender: TObject);
241   begin
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;
260   end;
261   
262   procedure TfrmOrderView.calChange(Sender: TObject);
263   begin
264     inherited;
265     UpdateViewName;
266   end;
267   
268   procedure TfrmOrderView.cmdOKClick(Sender: TObject);
269   begin
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;
289   end;
290   
291   procedure TfrmOrderView.cmdCancelClick(Sender: TObject);
292   begin
293     inherited;
294     Close;
295   end;
296   
297   procedure TfrmOrderView.trFiltersClick(Sender: TObject);
298   var
299     Node: TTreeNode;
300   begin
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;
325   end;
326   
327   procedure TfrmOrderView.Splitter1Moved(Sender: TObject);
328   begin
329     inherited;
330     Splitter1.Align := alNone;
331     Splitter1.Align := alLeft;
332   end;
333   
334   end.

Module Calls (2 levels)


fOrderVw
 ├fAutoSz
 │ └fBase508Form
 └rOrders
   ├uCore
   ├rCore
   ├uConst
   ├UBAGlobals
   └UBACore

Module Called-By (2 levels)


               fOrderVw
              fOrders┘ 
            uOrders┤   
            fODBase┤   
             fFrame┤   
              rMisc┤   
            uODBase┤   
              fMeds┤   
          fOrdersDC┤   
          fOrdersCV┤   
            fOMNavA┤   
             fOMSet┤   
 fOrdersEvntRelease┤   
    fODReleaseEvent┤   
         mEvntDelay┤   
          fODActive┤   
        fOrdersCopy┤   
           fMedCopy┤   
fActivateDeactivate┘