[459] | 1 | unit fPCEProvider;
|
---|
| 2 |
|
---|
| 3 | interface
|
---|
| 4 |
|
---|
| 5 | uses
|
---|
| 6 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
---|
| 7 | StdCtrls, ORCtrls, ExtCtrls, uPCE, ORFn;
|
---|
| 8 |
|
---|
| 9 | type
|
---|
| 10 | TfrmPCEProvider = class(TForm)
|
---|
| 11 | cboPrimary: TORComboBox;
|
---|
| 12 | lblMsg: TMemo;
|
---|
| 13 | btnYes: TButton;
|
---|
| 14 | btnNo: TButton;
|
---|
| 15 | btnSelect: TButton;
|
---|
| 16 | Spacer1: TLabel;
|
---|
| 17 | procedure cboPrimaryNeedData(Sender: TObject; const StartFrom: String;
|
---|
| 18 | Direction, InsertAt: Integer);
|
---|
| 19 | procedure cboPrimaryChange(Sender: TObject);
|
---|
| 20 | procedure FormCreate(Sender: TObject);
|
---|
| 21 | procedure btnSelectClick(Sender: TObject);
|
---|
| 22 | private
|
---|
| 23 | FPCEData: TPCEData;
|
---|
| 24 | FUseDefault: boolean;
|
---|
| 25 | FIEN: array[boolean] of Int64;
|
---|
| 26 | FName: array[boolean] of string;
|
---|
| 27 | public
|
---|
| 28 | procedure AskUser(ForceSelect: boolean);
|
---|
| 29 | end;
|
---|
| 30 |
|
---|
| 31 | function NoPrimaryPCEProvider(AProviders: TPCEProviderList; PCEData: TPCEData): boolean;
|
---|
| 32 |
|
---|
| 33 | implementation
|
---|
| 34 |
|
---|
| 35 | uses rCore, uCore, rTIU, rPCE;
|
---|
| 36 |
|
---|
| 37 | {$R *.DFM}
|
---|
| 38 |
|
---|
| 39 | const
|
---|
| 40 | AreYouStr = 'Are You, ';
|
---|
| 41 | PEPStr2 = ' the Primary Provider for this Encounter';
|
---|
| 42 | PEPStr = PEPStr2 + '?';
|
---|
| 43 | IsStr = 'Is ';
|
---|
| 44 | SelectStr = 'Please Select' + PEPStr2 + '.';
|
---|
| 45 |
|
---|
| 46 | function NoPrimaryPCEProvider(AProviders: TPCEProviderList; PCEData: TPCEData): boolean;
|
---|
| 47 | var
|
---|
| 48 | frmPCEProvider: TfrmPCEProvider;
|
---|
| 49 | idx: integer;
|
---|
| 50 | b: boolean;
|
---|
| 51 | X: string;
|
---|
| 52 | mr: TModalResult;
|
---|
| 53 |
|
---|
| 54 | begin
|
---|
| 55 | if(AProviders.PrimaryIdx < 0) then
|
---|
| 56 | SetDefaultProvider(AProviders, PCEData);
|
---|
| 57 | if(AProviders.PrimaryIdx < 0) then
|
---|
| 58 | begin
|
---|
| 59 | frmPCEProvider := TfrmPCEProvider.Create(Application);
|
---|
| 60 | try
|
---|
| 61 | with frmPCEProvider do
|
---|
| 62 | begin
|
---|
| 63 | FPCEData := PCEData;
|
---|
| 64 | for b := FALSE to TRUE do
|
---|
| 65 | begin
|
---|
| 66 | FIEN[b] := AProviders.PendingIEN(b);
|
---|
| 67 | FName[b] := AProviders.PendingNAME(b);
|
---|
| 68 | end;
|
---|
| 69 | if(FIEN[TRUE] = 0) and (FIEN[FALSE] = 0) then
|
---|
| 70 | begin
|
---|
| 71 | AskUser(TRUE);
|
---|
| 72 | mr := ModalResult;
|
---|
| 73 | end
|
---|
| 74 | else
|
---|
| 75 | begin
|
---|
| 76 | FUseDefault := TRUE;
|
---|
| 77 | AskUser(FALSE);
|
---|
| 78 | mr := ModalResult;
|
---|
| 79 | if((mr in [mrAbort, mrNo]) and (FIEN[TRUE] <> FIEN[FALSE])) then
|
---|
| 80 | begin
|
---|
| 81 | FUseDefault := FALSE;
|
---|
| 82 | AskUser(FALSE);
|
---|
| 83 | mr := ModalResult;
|
---|
| 84 | end;
|
---|
| 85 | end;
|
---|
| 86 | if (mr = mrYes) then
|
---|
| 87 | begin
|
---|
| 88 | AProviders.AddProvider(IntToStr(FIEN[FUseDefault]), FName[FUseDefault], TRUE);
|
---|
| 89 | end
|
---|
| 90 | else
|
---|
| 91 | if (mr = mrOK) then
|
---|
| 92 | begin
|
---|
| 93 | idx := cboPrimary.ItemIndex;
|
---|
| 94 | if(idx >= 0) then
|
---|
| 95 | begin
|
---|
| 96 | X := frmPCEProvider.cboPrimary.Items[idx];
|
---|
| 97 | AProviders.AddProvider(Piece(X, U, 1), Piece(X, U, 2), TRUE);
|
---|
| 98 | end;
|
---|
| 99 | end;
|
---|
| 100 | end;
|
---|
| 101 | finally
|
---|
| 102 | frmPCEProvider.Free;
|
---|
| 103 | end;
|
---|
| 104 | Result := (AProviders.PrimaryIdx < 0);
|
---|
| 105 | end
|
---|
| 106 | else
|
---|
| 107 | Result := FALSE;
|
---|
| 108 | end;
|
---|
| 109 |
|
---|
| 110 | { TfrmPCEProvider }
|
---|
| 111 |
|
---|
| 112 | procedure TfrmPCEProvider.cboPrimaryNeedData(Sender: TObject;
|
---|
| 113 | const StartFrom: String; Direction, InsertAt: Integer);
|
---|
| 114 | begin
|
---|
| 115 | if(FPCEData.VisitCategory = 'E') then
|
---|
| 116 | cboPrimary.ForDataUse(SubSetOfPersons(StartFrom, Direction))
|
---|
| 117 | else
|
---|
| 118 | cboPrimary.ForDataUse(SubSetOfUsersWithClass(StartFrom, Direction,
|
---|
| 119 | FloatToStr(FPCEData.PersonClassDate)));
|
---|
| 120 | end;
|
---|
| 121 |
|
---|
| 122 | procedure TfrmPCEProvider.cboPrimaryChange(Sender: TObject);
|
---|
| 123 | var
|
---|
| 124 | txt: string;
|
---|
| 125 |
|
---|
| 126 | begin
|
---|
| 127 | if(cboPrimary.ItemIEN <> 0) and (FPCEData.VisitCategory <> 'E') then
|
---|
| 128 | begin
|
---|
| 129 | txt := InvalidPCEProviderTxt(cboPrimary.ItemIEN, FPCEData.PersonClassDate);
|
---|
| 130 | if(txt <> '') then
|
---|
| 131 | begin
|
---|
| 132 | InfoBox(cboPrimary.DisplayText[cboPrimary.ItemIndex] + txt, TX_BAD_PROV, MB_OK);
|
---|
| 133 | cboPrimary.ItemIndex := -1;
|
---|
| 134 | end;
|
---|
| 135 | end;
|
---|
| 136 | end;
|
---|
| 137 |
|
---|
| 138 | procedure TfrmPCEProvider.FormCreate(Sender: TObject);
|
---|
| 139 | begin
|
---|
| 140 | ResizeAnchoredFormToFont(self);
|
---|
| 141 | ClientHeight := cboPrimary.Top;
|
---|
| 142 | end;
|
---|
| 143 |
|
---|
| 144 | procedure TfrmPCEProvider.btnSelectClick(Sender: TObject);
|
---|
| 145 | begin
|
---|
| 146 | ClientHeight := cboPrimary.Top + cboPrimary.Height + 5;
|
---|
| 147 | cboPrimary.Visible := TRUE;
|
---|
| 148 | btnSelect.Visible := FALSE;
|
---|
| 149 | btnYes.Caption := '&OK';
|
---|
| 150 | btnYes.ModalResult := mrOK;
|
---|
| 151 | btnNo.Caption := '&Cancel';
|
---|
| 152 | btnNo.ModalResult := mrCancel;
|
---|
| 153 | lblMsg.Text := SelectStr;
|
---|
| 154 | cboPrimary.Caption := lblMsg.Text;
|
---|
| 155 | cboPrimary.InitLongList(User.Name);
|
---|
| 156 | end;
|
---|
| 157 |
|
---|
| 158 | procedure TfrmPCEProvider.AskUser(ForceSelect: boolean);
|
---|
| 159 | var
|
---|
| 160 | msg: string;
|
---|
| 161 |
|
---|
| 162 | begin
|
---|
| 163 | if(ForceSelect) then
|
---|
| 164 | begin
|
---|
| 165 | btnSelectClick(Self);
|
---|
| 166 | end
|
---|
| 167 | else
|
---|
| 168 | begin
|
---|
| 169 | if(FIEN[FUseDefault] = 0) then
|
---|
| 170 | begin
|
---|
| 171 | ModalResult := mrAbort;
|
---|
| 172 | exit;
|
---|
| 173 | end
|
---|
| 174 | else
|
---|
| 175 | begin
|
---|
| 176 | if(FIEN[FUseDefault] = User.DUZ) then
|
---|
| 177 | msg := AreYouStr + FName[FUseDefault] + ',' + PEPStr
|
---|
| 178 | else
|
---|
| 179 | msg := IsStr + FName[FUseDefault] + PEPStr;
|
---|
| 180 | end;
|
---|
| 181 | lblMsg.text := msg;
|
---|
| 182 | cboPrimary.Caption := lblMsg.text;
|
---|
| 183 | end;
|
---|
| 184 | ShowModal;
|
---|
| 185 | end;
|
---|
| 186 |
|
---|
| 187 | end.
|
---|