source: cprs/branches/tmg-cprs/CPRS-Chart/TMG_Extra/LookupU.pas@ 1328

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

update

File size: 4.8 KB
Line 
1unit LookupU;
2 (*
3 WorldVistA Configuration Utility
4 (c) 8/2008 Kevin Toppenberg
5 Programmed by Kevin Toppenberg, Eddie Hagood
6
7 Family Physicians of Greeneville, PC
8 1410 Tusculum Blvd, Suite 2600
9 Greeneville, TN 37745
10 kdtop@yahoo.com
11
12 This library is free software; you can redistribute it and/or
13 modify it under the terms of the GNU Lesser General Public
14 License as published by the Free Software Foundation; either
15 version 2.1 of the License, or (at your option) any later version.
16
17 This library is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 Lesser General Public License for more details.
21
22 You should have received a copy of the GNU Lesser General Public
23 License along with this library; if not, write to the Free Software
24 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 *)
26
27interface
28
29uses
30 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
31 Dialogs, StdCtrls, ORCtrls, Buttons;
32
33type
34 TFieldLookupForm = class(TForm)
35 ORComboBox: TORComboBox;
36 OKBtn: TBitBtn;
37 CancelBtn: TBitBtn;
38 procedure ORComboBoxNeedData(Sender: TObject; const StartFrom: String;
39 Direction, InsertAt: Integer);
40 procedure FormShow(Sender: TObject);
41 procedure ORComboBoxDblClick(Sender: TObject);
42 private
43 { Private declarations }
44 FFileNum : String;
45
46 public
47 { Public declarations }
48 procedure InitORComboBox(ORComboBox: TORComboBox; initValue : string);
49 procedure PrepForm(FileNum,InitValue : string);
50 function SubSetOfFile(FileNum: string; const StartFrom: string;
51 Direction: Integer): TStrings;
52 end;
53
54var
55 FieldLookupForm: TFieldLookupForm;
56
57implementation
58
59uses
60ORNet, ORFn,
61Trpcb, //needed for .ptype types
62QControls, fPtDemoEdit;
63{$R *.dfm}
64
65 procedure TFieldLookupForm.ORComboBoxNeedData(Sender: TObject;
66 const StartFrom: String;
67 Direction, InsertAt: Integer);
68 var
69 Result : TStrings;
70 begin
71 Result := SubSetOfFile(FFileNum, StartFrom, Direction);
72 TORComboBox(Sender).ForDataUse(Result);
73 end;
74
75 procedure TFieldLookupForm.InitORComboBox(ORComboBox: TORComboBox; initValue : string);
76 begin
77 ORComboBox.Text := initValue;
78 ORComboBox.InitLongList(initValue);
79 if ORComboBox.Items.Count > 0 then begin
80 ORComboBox.Text := Piece(ORComboBox.Items[0],'^',2);
81 end else begin
82 ORComboBox.Text := '<Start Typing to Search>';
83 end;
84 end;
85
86 procedure TFieldLookupForm.PrepForm(FileNum,InitValue : string);
87 begin
88 FFileNum := FileNum;
89 Self.Caption := 'Pick Entry from File # ' + FileNum;
90 //if (FileNum='200') and (InitValue='') then begin
91 // InitValue := fPtDemoEdit.CurrentUserName;
92 //end;
93 InitORComboBox(ORComboBox,InitValue);
94 end;
95
96
97 function TFieldLookupForm.SubSetOfFile(FileNum: string;
98 const StartFrom: string;
99 Direction: Integer ): TStrings;
100
101 { returns a pointer to a list of file entries (for use in a long list box) -
102 The return value is a pointer to RPCBrokerV.Results, so the data must
103 be used BEFORE the next broker call! }
104 var
105 cmd,RPCResult : string;
106 begin
107 RPCBrokerV.remoteprocedure := 'TMG CHANNEL';
108 RPCBrokerV.Param[0].Value := '.X'; // not used
109 RPCBrokerV.param[0].ptype := list;
110 cmd := 'FILE ENTRY SUBSET';
111 cmd := cmd + '^' + FileNum + '^' + StartFrom + '^' + IntToStr(Direction);
112 RPCBrokerV.Param[0].Mult['"REQUEST"'] := cmd;
113 //RPCBrokerV.Call;
114 CallBroker;
115 RPCResult := RPCBrokerV.Results[0]; //returns: error: -1; success=1
116 if piece(RPCResult,'^',1)='-1' then begin
117 // handle error...
118 end else begin
119 RPCBrokerV.Results.Delete(0);
120 if RPCBrokerV.Results.Count=0 then begin
121 //RPCBrokerV.Results.Add('0^<NO DATA>');
122 end;
123 end;
124 Result := RPCBrokerV.Results;
125 end;
126
127 procedure TFieldLookupForm.FormShow(Sender: TObject);
128 var mousePos : TPoint;
129 begin
130 GetCursorPos(mousePos);
131 with FieldLookupForm do begin
132 Top := mousePos.Y - 39;
133 Left := mousePos.X - 15;
134 if Left + Width > Screen.DesktopWidth then begin
135 Left := Screen.DesktopWidth - Width;
136 end;
137 end;
138// ORComboBox.DroppedDown := true;
139 end;
140
141
142procedure TFieldLookupForm.ORComboBoxDblClick(Sender: TObject);
143begin
144 Modalresult := mrOK; //Close form, item should be selected (?)
145end;
146
147end.
148
Note: See TracBrowser for help on using the repository browser.