source: cprs/branches/tmg-cprs/CPRS-Chart/Encounter/fPCEProvider.pas@ 895

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

Initial upload of TMG-CPRS 1.0.26.69

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