source: cprs/trunk/CPRS-Chart/Encounter/fPCEProvider.pas@ 1702

Last change on this file since 1702 was 829, checked in by Kevin Toppenberg, 14 years ago

Upgrade to version 27

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