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

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

Initial Upload of Official WV CPRS 1.0.26.76

File size: 4.8 KB
RevLine 
[456]1unit fPCEProvider;
2
3interface
4
5uses
6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
7 StdCtrls, ORCtrls, ExtCtrls, uPCE, ORFn;
8
9type
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
31function NoPrimaryPCEProvider(AProviders: TPCEProviderList; PCEData: TPCEData): boolean;
32
33implementation
34
35uses rCore, uCore, rTIU, rPCE;
36
37{$R *.DFM}
38
39const
40 AreYouStr = 'Are You, ';
41 PEPStr2 = ' the Primary Provider for this Encounter';
42 PEPStr = PEPStr2 + '?';
43 IsStr = 'Is ';
44 SelectStr = 'Please Select' + PEPStr2 + '.';
45
46function NoPrimaryPCEProvider(AProviders: TPCEProviderList; PCEData: TPCEData): boolean;
47var
48 frmPCEProvider: TfrmPCEProvider;
49 idx: integer;
50 b: boolean;
51 X: string;
52 mr: TModalResult;
53
54begin
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;
108end;
109
110{ TfrmPCEProvider }
111
112procedure TfrmPCEProvider.cboPrimaryNeedData(Sender: TObject;
113 const StartFrom: String; Direction, InsertAt: Integer);
114begin
115 if(FPCEData.VisitCategory = 'E') then
116 cboPrimary.ForDataUse(SubSetOfPersons(StartFrom, Direction))
117 else
118 cboPrimary.ForDataUse(SubSetOfUsersWithClass(StartFrom, Direction,
119 FloatToStr(FPCEData.PersonClassDate)));
120end;
121
122procedure TfrmPCEProvider.cboPrimaryChange(Sender: TObject);
123var
124 txt: string;
125
126begin
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;
136end;
137
138procedure TfrmPCEProvider.FormCreate(Sender: TObject);
139begin
140 ResizeAnchoredFormToFont(self);
141 ClientHeight := cboPrimary.Top;
142end;
143
144procedure TfrmPCEProvider.btnSelectClick(Sender: TObject);
145begin
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);
156end;
157
158procedure TfrmPCEProvider.AskUser(ForceSelect: boolean);
159var
160 msg: string;
161
162begin
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;
185end;
186
187end.
Note: See TracBrowser for help on using the repository browser.