source: cprs/branches/foia-cprs/CPRS-Chart/Encounter/fHFSearch.pas@ 1154

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

Adding foia-cprs branch

File size: 5.3 KB
Line 
1unit fHFSearch;
2
3interface
4
5uses
6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
7 fAutoSz, ORFn, StdCtrls, ComCtrls, ORCtrls, ExtCtrls;
8
9type
10 TfrmHFSearch = class(TfrmAutoSz)
11 cbxSearch: TORComboBox;
12 tvSearch: TORTreeView;
13 pnlBottom: TPanel;
14 btnOK: TButton;
15 btnCancel: TButton;
16 splMain: TSplitter;
17 lblCat: TLabel;
18 procedure FormCreate(Sender: TObject);
19 procedure btnOKClick(Sender: TObject);
20 procedure tvSearchDblClick(Sender: TObject);
21 procedure tvSearchGetImageIndex(Sender: TObject; Node: TTreeNode);
22 procedure tvSearchChange(Sender: TObject; Node: TTreeNode);
23 procedure cbxSearchChange(Sender: TObject);
24 private
25 FCode: string;
26 FChanging: boolean;
27 procedure UpdateCat;
28 public
29 end;
30
31procedure HFLookup(var Code: string);
32
33implementation
34
35uses rPCE, dShared, fEncounterFrame;
36
37{$R *.DFM}
38
39const
40 CatTxt = 'Category: ';
41
42procedure HFLookup(var Code: string);
43var
44 frmHFSearch: TfrmHFSearch;
45
46begin
47 frmHFSearch := TfrmHFSearch.Create(Application);
48 try
49 ResizeFormToFont(TForm(frmHFSearch));
50 frmHFSearch.ShowModal;
51 Code := frmHFSearch.FCode;
52 finally
53 frmHFSearch.Free;
54 end;
55end;
56
57procedure TfrmHFSearch.cbxSearchChange(Sender: TObject);
58var
59 Node: TORTreeNode;
60 CurCat, NodeCat: TTreeNode;
61 ID: string;
62
63begin
64 inherited;
65 if(not FChanging) then
66 begin
67 FChanging := TRUE;
68 try
69 btnOK.Enabled := (cbxSearch.ItemIndex >= 0);
70 if(cbxSearch.ItemIndex < 0) then
71 tvSearch.Selected := nil
72 else
73 begin
74 ID := cbxSearch.ItemID;
75 if(assigned(tvSearch.Selected)) then
76 begin
77 CurCat := tvSearch.Selected;
78 while (assigned(CurCat.Parent)) do
79 CurCat := CurCat.Parent;
80 end
81 else
82 CurCat := nil;
83 Node := TORTreeNode(tvSearch.Items.GetFirstNode);
84 while assigned(Node) do
85 begin
86 if(piece(Node.StringData,U,1)= ID) then
87 begin
88 NodeCat := Node;
89 while (assigned(NodeCat.Parent)) do
90 NodeCat := NodeCat.Parent;
91 RedrawSuspend(tvSearch.Handle);
92 try
93 if(CurCat <> NodeCat) then
94 tvSearch.FullCollapse;
95 tvSearch.Selected := Node;
96 Node.EnsureVisible;
97 finally
98 RedrawActivate(tvSearch.Handle);
99 end;
100 break;
101 end;
102 Node := TORTreeNode(Node.GetNext);
103 end;
104 end;
105 UpdateCat;
106 finally
107 FChanging := FALSE;
108 end;
109 end;
110end;
111
112
113procedure TfrmHFSearch.FormCreate(Sender: TObject);
114var
115 HFList: TStringList;
116 i: integer;
117 Node :TORTreeNode;
118 CAT: string;
119
120begin
121 inherited;
122 HFList := TStringList.Create;
123 try
124 LoadcboOther(HFList, uEncPCEData.Location, PCE_HF);
125 for i := 0 to HFList.Count-1 do
126 begin
127 if(Piece(HFList[i],U,3)='F') then
128 cbxSearch.Items.Add(pieces(HFList[i],U,1,2));
129 end;
130 for i := 0 to HFList.Count-1 do
131 begin
132 if(Piece(HFList[i],U,3)='C') then
133 begin
134 with TORTreeNode(tvSearch.Items.Add(nil, '')) do
135 begin
136 StringData := HFList[i];
137 StateIndex := 2;
138 end;
139 end;
140 end;
141 for i := 0 to HFList.Count-1 do
142 begin
143 if(Piece(HFList[i],U,3)='F') then
144 begin
145 CAT := piece(HFList[i],U,4);
146 Node := TORTreeNode(tvSearch.Items.GetFirstNode);
147 while(assigned(Node)) do
148 begin
149 if(Piece(Node.StringData, U, 1) = CAT) then
150 break;
151 Node := TORTreeNode(Node.GetNextSibling);
152 end;
153 TORTreeNode(tvSearch.Items.AddChild(Node, '')).StringData := Pieces(HFList[i],U,1,2);
154 end;
155 end;
156// tvSearch.Invalidate;
157 finally
158 HFList.Free;
159 end;
160end;
161
162procedure TfrmHFSearch.btnOKClick(Sender: TObject);
163begin
164 inherited;
165 if cbxSearch.ItemIndex = -1 then Exit;
166 FCode := cbxSearch.Items[cbxSearch.ItemIndex];
167 ModalResult := mrOK;
168end;
169
170procedure TfrmHFSearch.tvSearchDblClick(Sender: TObject);
171begin
172 inherited;
173 btnOKClick(Sender);
174end;
175
176procedure TfrmHFSearch.tvSearchGetImageIndex(Sender: TObject;
177 Node: TTreeNode);
178begin
179 inherited;
180 if(piece(TORTreeNode(Node).StringData,U,3)= 'C') then
181 begin
182 if(Node.Expanded) then
183 Node.StateIndex := 3
184 else
185 Node.StateIndex := 2;
186 end;
187// tvSearch.Invalidate;
188end;
189
190procedure TfrmHFSearch.tvSearchChange(Sender: TObject; Node: TTreeNode);
191begin
192 inherited;
193 if(not FChanging) then
194 begin
195 FChanging := TRUE;
196 try
197 if(assigned(Node)) then
198 cbxSearch.SelectByID(Piece(TORTreeNode(Node).StringData,U,1))
199 else
200 cbxSearch.ItemIndex := -1;
201 btnOK.Enabled := (cbxSearch.ItemIndex >= 0);
202 UpdateCat;
203 finally
204 FChanging := FALSE;
205 end;
206 end;
207end;
208
209procedure TfrmHFSearch.UpdateCat;
210var
211 NodeCat: TTreeNode;
212
213begin
214 NodeCat := tvSearch.Selected;
215 if(assigned(NodeCat)) then
216 begin
217 while (assigned(NodeCat.Parent)) do
218 NodeCat := NodeCat.Parent;
219 lblCat.Caption := CatTxt + NodeCat.Text;
220 end
221 else
222 lblCat.Caption := CatTxt;
223 cbxSearch.Caption := lblCat.Caption;
224end;
225
226end.
Note: See TracBrowser for help on using the repository browser.