[476] | 1 | unit 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
|
---|
[493] | 25 | *)
|
---|
[476] | 26 |
|
---|
| 27 | interface
|
---|
| 28 |
|
---|
| 29 | uses
|
---|
| 30 | Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
---|
| 31 | Dialogs, StdCtrls, ORCtrls, Buttons;
|
---|
| 32 |
|
---|
| 33 | type
|
---|
| 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;
|
---|
[493] | 45 |
|
---|
[476] | 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 |
|
---|
| 54 | var
|
---|
| 55 | FieldLookupForm: TFieldLookupForm;
|
---|
| 56 |
|
---|
| 57 | implementation
|
---|
| 58 |
|
---|
| 59 | uses
|
---|
| 60 | ORNet, ORFn, Trpcb, QControls, MainU;
|
---|
| 61 | {$R *.dfm}
|
---|
| 62 |
|
---|
| 63 | procedure TFieldLookupForm.ORComboBoxNeedData(Sender: TObject;
|
---|
| 64 | const StartFrom: String;
|
---|
| 65 | Direction, InsertAt: Integer);
|
---|
| 66 | var
|
---|
| 67 | Result : TStrings;
|
---|
| 68 | begin
|
---|
| 69 | Result := SubSetOfFile(FFileNum, StartFrom, Direction);
|
---|
| 70 | TORComboBox(Sender).ForDataUse(Result);
|
---|
| 71 | end;
|
---|
| 72 |
|
---|
| 73 | {
|
---|
| 74 | procedure TFieldLookupForm.InitORComboBox(ORComboBox: TORComboBox; initValue : string);
|
---|
| 75 | begin
|
---|
| 76 | ORComboBox.Text := initValue;
|
---|
| 77 | ORComboBox.InitLongList(initValue);
|
---|
| 78 | if ORComboBox.Items.Count > 0 then begin
|
---|
| 79 | ORComboBox.Text := Piece(ORComboBox.Items[0],'^',2);
|
---|
| 80 | end else begin
|
---|
| 81 | ORComboBox.Text := '<Start Typing to Search>';
|
---|
| 82 | end;
|
---|
| 83 | end;
|
---|
| 84 | }
|
---|
| 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 := MainForm.CurrentUserName;
|
---|
| 92 | end;
|
---|
| 93 | MainForm.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 | RPCResult := RPCBrokerV.Results[0]; //returns: error: -1; success=1
|
---|
| 115 | if piece(RPCResult,'^',1)='-1' then begin
|
---|
| 116 | // handle error...
|
---|
| 117 | end else begin
|
---|
| 118 | RPCBrokerV.Results.Delete(0);
|
---|
| 119 | if RPCBrokerV.Results.Count=0 then begin
|
---|
[482] | 120 | //RPCBrokerV.Results.Add('0^<NO DATA>');
|
---|
[476] | 121 | end;
|
---|
| 122 | end;
|
---|
| 123 | Result := RPCBrokerV.Results;
|
---|
| 124 | end;
|
---|
| 125 |
|
---|
| 126 | procedure TFieldLookupForm.FormShow(Sender: TObject);
|
---|
| 127 | var mousePos : TPoint;
|
---|
| 128 | begin
|
---|
| 129 | GetCursorPos(mousePos);
|
---|
| 130 | with FieldLookupForm do begin
|
---|
| 131 | Top := mousePos.Y - 39;
|
---|
| 132 | Left := mousePos.X - 15;
|
---|
| 133 | if Left + Width > Screen.DesktopWidth then begin
|
---|
| 134 | Left := Screen.DesktopWidth - Width;
|
---|
| 135 | end;
|
---|
| 136 | end;
|
---|
| 137 | // ORComboBox.DroppedDown := true;
|
---|
| 138 | end;
|
---|
| 139 |
|
---|
| 140 |
|
---|
| 141 | procedure TFieldLookupForm.ORComboBoxDblClick(Sender: TObject);
|
---|
| 142 | begin
|
---|
| 143 | Modalresult := mrOK; //Close form, item should be selected (?)
|
---|
| 144 | end;
|
---|
| 145 |
|
---|
| 146 | end.
|
---|
| 147 |
|
---|