1 | unit fPtAdd;
|
---|
2 | //kt This entire module and form was added. Coded by Eddie Hagood 10/2007
|
---|
3 |
|
---|
4 | interface
|
---|
5 |
|
---|
6 | uses
|
---|
7 | Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
---|
8 | Dialogs, StdCtrls, Trpcb, mfunstr, ORNet, uCore, ExtCtrls, StrUtils,
|
---|
9 | Buttons, DKLang;
|
---|
10 |
|
---|
11 | const
|
---|
12 | SSNUM_REQUIRED = true; //set to true to force entry of ssnum
|
---|
13 |
|
---|
14 | type
|
---|
15 | TPatientInfo = class(TObject)
|
---|
16 | public
|
---|
17 | LName: String;
|
---|
18 | FName: String;
|
---|
19 | MName: String;
|
---|
20 | CombinedName: String;
|
---|
21 | Suffix: String;
|
---|
22 | DOB: String;
|
---|
23 | Sex: String;
|
---|
24 | SSNum: String;
|
---|
25 | PtType: String;
|
---|
26 | Veteran: String;
|
---|
27 | procedure ClearArray;
|
---|
28 | end;
|
---|
29 |
|
---|
30 | TfrmPtAdd = class(TForm)
|
---|
31 | LNameLabel: TLabel;
|
---|
32 | SexComboBox: TComboBox;
|
---|
33 | SSNumEdit: TEdit;
|
---|
34 | DOBEdit: TEdit;
|
---|
35 | SuffixEdit: TEdit;
|
---|
36 | MNameEdit: TEdit;
|
---|
37 | FNameEdit: TEdit;
|
---|
38 | LNameEdit: TEdit;
|
---|
39 | FNameLabel: TLabel;
|
---|
40 | MNameLabel: TLabel;
|
---|
41 | SuffixLabel: TLabel;
|
---|
42 | DOBLabel: TLabel;
|
---|
43 | SSNumLabel: TLabel;
|
---|
44 | SexLabel: TLabel;
|
---|
45 | PrefixLabel: TLabel;
|
---|
46 | PtTypeComboBox: TComboBox;
|
---|
47 | VeteranCheckBox: TCheckBox;
|
---|
48 | OkButton: TButton;
|
---|
49 | CloseButton: TButton;
|
---|
50 | Label1: TLabel;
|
---|
51 | SSNHelpBtn: TSpeedButton;
|
---|
52 | Label2: TLabel;
|
---|
53 | DKLanguageController1: TDKLanguageController;
|
---|
54 | procedure OnShow(Sender: TObject);
|
---|
55 | procedure CancelButtonClick(Sender: TObject);
|
---|
56 | procedure OkButtonClick(Sender: TObject);
|
---|
57 | procedure LNameEditChange(Sender: TObject);
|
---|
58 | procedure FNameEditChange(Sender: TObject);
|
---|
59 | procedure DOBEditChange(Sender: TObject);
|
---|
60 | procedure SSNumEditChange(Sender: TObject);
|
---|
61 | procedure SexComboBoxChange(Sender: TObject);
|
---|
62 | procedure MNameEditChange(Sender: TObject);
|
---|
63 | procedure SuffixEditChange(Sender: TObject);
|
---|
64 | procedure PtTypeComboBoxChange(Sender: TObject);
|
---|
65 | procedure VeteranCheckBoxClick(Sender: TObject);
|
---|
66 | procedure FormCreate(Sender: TObject);
|
---|
67 | procedure SSNumEditExit(Sender: TObject);
|
---|
68 | procedure SSNumEditKeyPress(Sender: TObject; var Key: Char);
|
---|
69 | procedure DOBEditKeyPress(Sender: TObject; var Key: Char);
|
---|
70 | procedure LNameEditKeyPress(Sender: TObject; var Key: Char);
|
---|
71 | procedure FNameEditKeyPress(Sender: TObject; var Key: Char);
|
---|
72 | procedure MNameEditKeyPress(Sender: TObject; var Key: Char);
|
---|
73 | procedure SuffixEditKeyPress(Sender: TObject; var Key: Char);
|
---|
74 | procedure SexComboBoxKeyPress(Sender: TObject; var Key: Char);
|
---|
75 | procedure PtTypeComboBoxKeyPress(Sender: TObject; var Key: Char);
|
---|
76 | procedure FormDestroy(Sender: TObject);
|
---|
77 | procedure DOBEditExit(Sender: TObject);
|
---|
78 | procedure SSNHelpBtnClick(Sender: TObject);
|
---|
79 | private
|
---|
80 | { Private declarations }
|
---|
81 | ThisPatientInfo: TPatientInfo;
|
---|
82 | ProgModSSNum : boolean;
|
---|
83 | procedure ResetColors();
|
---|
84 | procedure ResetFields();
|
---|
85 | procedure TestUserInput();
|
---|
86 | procedure DataToArray();
|
---|
87 | procedure CreatePSSN();
|
---|
88 | procedure PostInfo(ThisPatientInfo : TPatientInfo);
|
---|
89 | function FrmtSSNum(SSNumStr : string) : string;
|
---|
90 | function UnFrmtSSNum(SSNumStr : string) : string;
|
---|
91 | function SSNumInvalid(SSNumStr: string) : boolean;
|
---|
92 | public
|
---|
93 | { Public declarations }
|
---|
94 | DFN: Int64;
|
---|
95 | end;
|
---|
96 |
|
---|
97 | var
|
---|
98 | frmPtAdd: TfrmPtAdd;
|
---|
99 |
|
---|
100 | implementation
|
---|
101 |
|
---|
102 | uses fPtSel;
|
---|
103 |
|
---|
104 | {$R *.dfm}
|
---|
105 |
|
---|
106 | var
|
---|
107 | boolErrorFound: boolean;
|
---|
108 | boolDirtyForm: boolean;
|
---|
109 |
|
---|
110 | procedure TfrmPtAdd.OnShow(Sender: TObject);
|
---|
111 | begin
|
---|
112 | LNameEdit.SetFocus;
|
---|
113 | PtTypeComboBox.Text := 'NON-VETERAN (OTHER)';
|
---|
114 | ResetColors;
|
---|
115 | ResetFields;
|
---|
116 | ThisPatientInfo.ClearArray;
|
---|
117 | boolDirtyForm := False;
|
---|
118 | DFN := -1;
|
---|
119 | end;
|
---|
120 | //------------------------------------------------------------------------
|
---|
121 | procedure TfrmPtAdd.CancelButtonClick(Sender: TObject);
|
---|
122 | begin
|
---|
123 | if (boolDirtyForm = True) then begin
|
---|
124 | if MessageDlg('** Patient Not Yet Added **'+#10+#13+
|
---|
125 | 'ADD this patient before exiting?',
|
---|
126 | mtWarning, [mbYes, mbNo],0) = mrYes then begin
|
---|
127 | OkButtonClick(self);
|
---|
128 | end else begin
|
---|
129 | modalresult:=1;
|
---|
130 | end;
|
---|
131 | end else begin
|
---|
132 | modalresult:=1;
|
---|
133 | end;
|
---|
134 | end;
|
---|
135 | //------------------------------------------------------------------------
|
---|
136 | procedure TfrmPtAdd.ResetColors();
|
---|
137 | begin
|
---|
138 | LNameEdit.Color := clWindow;
|
---|
139 | FNameEdit.Color := clWindow;
|
---|
140 | DOBEdit.Color := clWindow;
|
---|
141 | SSNumEdit.Color := clWindow;
|
---|
142 | SexComboBox.Color := clWindow;
|
---|
143 | end;
|
---|
144 | //------------------------------------------------------------------------
|
---|
145 | procedure TfrmPtAdd.ResetFields();
|
---|
146 | begin
|
---|
147 | LNameEdit.text := '';
|
---|
148 | FNameEdit.text := '';
|
---|
149 | MNameEdit.text := '';
|
---|
150 | SuffixEdit.Text := '';
|
---|
151 | PtTypeComboBox.Text := 'NON-VETERAN (OTHER)';
|
---|
152 | DOBEdit.text := '';
|
---|
153 | SSNumEdit.text := '';
|
---|
154 | SexComboBox.text := '<Sex>';
|
---|
155 | Label1.Visible := False;
|
---|
156 | Label1.Caption := '';
|
---|
157 | VeteranCheckbox.Checked := False;
|
---|
158 | end;
|
---|
159 | //------------------------------------------------------------------------
|
---|
160 |
|
---|
161 | procedure TfrmPtAdd.OkButtonClick(Sender: TObject);
|
---|
162 |
|
---|
163 | begin
|
---|
164 | TestUserInput;
|
---|
165 | if boolErrorFound = False then begin
|
---|
166 | DataToArray;
|
---|
167 | PostInfo(ThisPatientInfo);
|
---|
168 | boolDirtyForm := False;
|
---|
169 | ThisPatientInfo.ClearArray;
|
---|
170 | modalresult:=1;
|
---|
171 | end else begin
|
---|
172 | label1.Caption := 'Needs: ' + label1.caption;
|
---|
173 | label1.Visible := True;
|
---|
174 | end;
|
---|
175 | end;
|
---|
176 | //------------------------------------------------------------------------
|
---|
177 | procedure TfrmPtAdd.LNameEditChange(Sender: TObject);
|
---|
178 | begin
|
---|
179 | ResetColors;
|
---|
180 | ThisPatientInfo.LName := LNameEdit.Text;
|
---|
181 | boolDirtyForm := True;
|
---|
182 | label1.Visible := False;
|
---|
183 | if Pos('P',SSNumEdit.Text) > 0 then begin
|
---|
184 | CreatePSSN();
|
---|
185 | end;
|
---|
186 | end;
|
---|
187 | //------------------------------------------------------------------------
|
---|
188 | procedure TfrmPtAdd.FNameEditChange(Sender: TObject);
|
---|
189 | begin
|
---|
190 | ResetColors;
|
---|
191 | ThisPatientInfo.FName := FNameEdit.Text;
|
---|
192 | boolDirtyForm := True;
|
---|
193 | label1.Visible := False;
|
---|
194 | if Pos('P',SSNumEdit.Text) > 0 then begin
|
---|
195 | CreatePSSN();
|
---|
196 | end;
|
---|
197 | end;
|
---|
198 | //------------------------------------------------------------------------
|
---|
199 | procedure TfrmPtAdd.MNameEditChange(Sender: TObject);
|
---|
200 | begin
|
---|
201 | ThisPatientInfo.MName := MNameEdit.Text;
|
---|
202 | boolDirtyForm := True;
|
---|
203 | label1.Visible := False;
|
---|
204 | if Pos('P',SSNumEdit.Text) > 0 then begin
|
---|
205 | CreatePSSN();
|
---|
206 | end;
|
---|
207 | end;
|
---|
208 | //------------------------------------------------------------------------
|
---|
209 | procedure TfrmPtAdd.DOBEditChange(Sender: TObject);
|
---|
210 | begin
|
---|
211 | ResetColors;
|
---|
212 | label1.Visible := False;
|
---|
213 | ThisPatientInfo.DOB := DOBEdit.Text;
|
---|
214 | if Pos('P',SSNumEdit.Text) > 0 then begin
|
---|
215 | CreatePSSN();
|
---|
216 | end;
|
---|
217 | end;
|
---|
218 | //------------------------------------------------------------------------
|
---|
219 | procedure TfrmPtAdd.SSNumEditChange(Sender: TObject);
|
---|
220 | begin
|
---|
221 | if ProgModSSNum = false then begin
|
---|
222 | ResetColors;
|
---|
223 | ThisPatientInfo.SSNum := UnFrmtSSNum(SSNumEdit.Text);
|
---|
224 | //ProgModSSNum := true;
|
---|
225 | //SSNumEdit.Text := FrmtSSNum(ThisPatientInfo.SSNum);
|
---|
226 | //ProgModSSNum := false;
|
---|
227 | boolDirtyForm := True;
|
---|
228 | label1.Visible := False;
|
---|
229 | end;
|
---|
230 | end;
|
---|
231 | //------------------------------------------------------------------------
|
---|
232 | procedure TfrmPtAdd.SexComboBoxChange(Sender: TObject);
|
---|
233 | begin
|
---|
234 | ResetColors;
|
---|
235 | ThisPatientInfo.Sex := SexComboBox.Text;
|
---|
236 | boolDirtyForm := True;
|
---|
237 | label1.Visible := False;
|
---|
238 | end;
|
---|
239 | //------------------------------------------------------------------------
|
---|
240 |
|
---|
241 | procedure TfrmPtAdd.TestUserInput();
|
---|
242 | begin
|
---|
243 | boolErrorFound := False;
|
---|
244 | label1.caption := '';
|
---|
245 | label1.Visible := False;
|
---|
246 | ResetColors;
|
---|
247 |
|
---|
248 | if SSNumInvalid(ThisPatientInfo.SSNum) then begin
|
---|
249 | if MessageDlg('Invalid SSN. Would you like to use a pseudo-SSN?', mtConfirmation, [mbYes, mbNo],0) = mrYes then begin
|
---|
250 | SSNumEdit.Text := 'p';
|
---|
251 | end else begin
|
---|
252 | label1.Caption := label1.Caption + 'SSN,';
|
---|
253 | boolErrorFound := True;
|
---|
254 | SSNumEdit.Color := clYellow;
|
---|
255 | end;
|
---|
256 | end;
|
---|
257 |
|
---|
258 | if LNameEdit.Text = '' then begin
|
---|
259 | label1.Caption := 'Last Name,';
|
---|
260 | boolErrorFound := True;
|
---|
261 | LNameEdit.Color := clYellow;
|
---|
262 | end;
|
---|
263 | if FNameEdit.Text = '' then begin
|
---|
264 | label1.Caption := label1.Caption + 'First Name,';
|
---|
265 | boolErrorFound := True;
|
---|
266 | FNameEdit.Color := clYellow;
|
---|
267 | end;
|
---|
268 | if DOBEdit.Text = '' then begin
|
---|
269 | label1.Caption := label1.Caption + 'DOB,';
|
---|
270 | boolErrorFound := True;
|
---|
271 | DOBEdit.Color := clYellow;
|
---|
272 | end;
|
---|
273 |
|
---|
274 | if SexComboBox.Text = '<Sex>' then begin
|
---|
275 | label1.Caption := label1.Caption + 'Gender';
|
---|
276 | boolErrorFound := True;
|
---|
277 | SexComboBox.Color := clYellow;
|
---|
278 | end;
|
---|
279 |
|
---|
280 | end;
|
---|
281 | //------------------------------------------------------------------------
|
---|
282 | procedure TfrmPtAdd.DataToArray();
|
---|
283 |
|
---|
284 | begin
|
---|
285 | ThisPatientInfo.ClearArray;
|
---|
286 | ThisPatientInfo.LName := LNameEdit.Text;
|
---|
287 | ThisPatientInfo.FName := FNameEdit.Text;
|
---|
288 | ThisPatientInfo.MName := MNameEdit.Text;
|
---|
289 | ThisPatientInfo.Suffix := SuffixEdit.Text;
|
---|
290 | ThisPatientInfo.DOB := DOBEdit.Text;
|
---|
291 | ThisPatientInfo.Sex := SexComboBox.Text;
|
---|
292 |
|
---|
293 | if Uppercase(SSNumEdit.Text) = 'P' then begin
|
---|
294 | CreatePSSN;
|
---|
295 | end else begin
|
---|
296 | ThisPatientInfo.SSNum := UnFrmtSSNum(SSNumEdit.Text);
|
---|
297 | end;
|
---|
298 |
|
---|
299 | ThisPatientInfo.PtType := PtTypeComboBox.Text;
|
---|
300 | if VeteranCheckBox.Checked = True then ThisPatientInfo.Veteran := 'True' else ThisPatientInfo.Veteran := 'False';
|
---|
301 |
|
---|
302 | end;
|
---|
303 | //------------------------------------------------------------------------
|
---|
304 | procedure TPatientInfo.ClearArray;
|
---|
305 | begin
|
---|
306 | LName := '';
|
---|
307 | FName := '';
|
---|
308 | MName := '';
|
---|
309 | Suffix := '';
|
---|
310 | DOB := '';
|
---|
311 | Sex := '';
|
---|
312 | SSNum := '';
|
---|
313 | PtType := '';
|
---|
314 | Veteran := '';
|
---|
315 | end;
|
---|
316 | //------------------------------------------------------------------------
|
---|
317 | procedure TfrmPtAdd.SuffixEditChange(Sender: TObject);
|
---|
318 | begin
|
---|
319 | ThisPatientInfo.Suffix := SuffixEdit.Text;
|
---|
320 | boolDirtyForm := True;
|
---|
321 | end;
|
---|
322 | //------------------------------------------------------------------------
|
---|
323 | procedure TfrmPtAdd.PtTypeComboBoxChange(Sender: TObject);
|
---|
324 | begin
|
---|
325 | ThisPatientInfo.PtType := PtTypeComboBox.Text;
|
---|
326 | boolDirtyForm := True;
|
---|
327 | end;
|
---|
328 | //------------------------------------------------------------------------
|
---|
329 | procedure TfrmPtAdd.VeteranCheckBoxClick(Sender: TObject);
|
---|
330 | begin
|
---|
331 | if VeteranCheckBox.Checked = True then ThisPatientInfo.Veteran := 'True' else ThisPatientInfo.Veteran := 'False';
|
---|
332 | boolDirtyForm := True;
|
---|
333 | end;
|
---|
334 | //------------------------------------------------------------------------
|
---|
335 | procedure TfrmPtAdd.FormCreate(Sender: TObject);
|
---|
336 | begin
|
---|
337 | ThisPatientInfo := TPatientInfo.Create;
|
---|
338 | DFN := -1;
|
---|
339 | ProgModSSNum := false;
|
---|
340 | end;
|
---|
341 | //------------------------------------------------------------------------
|
---|
342 | procedure TfrmPtAdd.SSNumEditExit(Sender: TObject);
|
---|
343 | begin
|
---|
344 | ProgModSSNum := true;
|
---|
345 | SSNumEdit.Text := FrmtSSNum(ThisPatientInfo.SSNum);
|
---|
346 | ProgModSSNum := false;
|
---|
347 |
|
---|
348 | if (SSNumInvalid(ThisPatientInfo.SSNum)) and (SSNumEdit.Text <>'') then begin
|
---|
349 | label1.Caption := 'SSN not correct length';
|
---|
350 | label1.Visible := True;
|
---|
351 | SSNumEdit.Color := clYellow;
|
---|
352 | end;
|
---|
353 | end;
|
---|
354 | //------------------------------------------------------------------------
|
---|
355 | function TfrmPtAdd.SSNumInvalid(SSNumStr: string) : boolean;
|
---|
356 | //kt 6/18/08 change. Made null entry to be VALID optionally
|
---|
357 | var targetLen : byte;
|
---|
358 | begin
|
---|
359 | if (SSNumStr<>'') or SSNUM_REQUIRED then begin
|
---|
360 | if Pos('P',SSNumStr)>0 then targetLen := 10 else targetLen := 9;
|
---|
361 | Result := (length(SSNumStr) <> targetLen);
|
---|
362 | end else begin
|
---|
363 | Result := false; //'' is valid entry now for SS (not required)
|
---|
364 | end;
|
---|
365 | end;
|
---|
366 |
|
---|
367 | //------------------------------------------------------------------------
|
---|
368 | procedure TfrmPtAdd.SSNumEditKeyPress(Sender: TObject; var Key: Char);
|
---|
369 | begin
|
---|
370 | if Key = 'p' then Key := 'P';
|
---|
371 | if Key=#8 then begin
|
---|
372 | if Pos('P',SSNumEdit.Text)>0 then begin
|
---|
373 | SSNumEdit.Text := '';
|
---|
374 | Key := #0;
|
---|
375 | end;
|
---|
376 | end else if Key='P' then begin
|
---|
377 | CreatePSSN;
|
---|
378 | Key := #0;
|
---|
379 | end else if not (Key in ['0'..'9','-']) then Key := #0;
|
---|
380 | end;
|
---|
381 | //------------------------------------------------------------------------
|
---|
382 | function TfrmPtAdd.FrmtSSNum(SSNumStr : string) : string;
|
---|
383 | var partA,partB,partC : string;
|
---|
384 | begin
|
---|
385 | partA := MidStr(SSNumStr,1,3);
|
---|
386 | partB := MidStr(SSNumStr,4,2);
|
---|
387 | partC := MidStr(SSNumStr,6,5);
|
---|
388 | Result := partA;
|
---|
389 | if length(partA)=3 then begin
|
---|
390 | Result := Result + '-' + partB;
|
---|
391 | if partC<>'' then begin
|
---|
392 | Result := Result + '-' + partC;
|
---|
393 | end;
|
---|
394 | end else begin
|
---|
395 | Result := SSNumStr;
|
---|
396 | end;
|
---|
397 | end;
|
---|
398 | //------------------------------------------------------------------------
|
---|
399 | function TfrmPtAdd.UnFrmtSSNum(SSNumStr : string) : string;
|
---|
400 | begin
|
---|
401 | Result := AnsiReplaceText(SSNumStr,'-','');
|
---|
402 | end;
|
---|
403 | //------------------------------------------------------------------------
|
---|
404 | procedure TfrmPtAdd.DOBEditKeyPress(Sender: TObject; var Key: Char);
|
---|
405 | begin
|
---|
406 | if Key in ['-', '\'] then Key := '/';
|
---|
407 | if Key in ['0'..'9'] + ['/'] then Key := Key
|
---|
408 | else if Key <> #8 then Key := #0;
|
---|
409 | end;
|
---|
410 | //------------------------------------------------------------------------
|
---|
411 | procedure TfrmPtAdd.LNameEditKeyPress(Sender: TObject; var Key: Char);
|
---|
412 | begin
|
---|
413 | Key := Uppercase(Key)[1];
|
---|
414 | if Key in ['0'..'9',','] then Key := #0
|
---|
415 | end;
|
---|
416 | //------------------------------------------------------------------------
|
---|
417 | procedure TfrmPtAdd.FNameEditKeyPress(Sender: TObject; var Key: Char);
|
---|
418 | begin
|
---|
419 | Key := Uppercase(Key)[1];
|
---|
420 | if Key in ['0'..'9'] then Key := #0
|
---|
421 | end;
|
---|
422 | //------------------------------------------------------------------------
|
---|
423 | procedure TfrmPtAdd.MNameEditKeyPress(Sender: TObject; var Key: Char);
|
---|
424 | begin
|
---|
425 | Key := Uppercase(Key)[1];
|
---|
426 | if Key in ['0'..'9'] then Key := #0
|
---|
427 | end;
|
---|
428 | //------------------------------------------------------------------------
|
---|
429 | procedure TfrmPtAdd.SuffixEditKeyPress(Sender: TObject; var Key: Char);
|
---|
430 | begin
|
---|
431 | if Key in ['0'..'9'] then Key := #0
|
---|
432 | end;
|
---|
433 | //------------------------------------------------------------------------
|
---|
434 | procedure TfrmPtAdd.SexComboBoxKeyPress(Sender: TObject; var Key: Char);
|
---|
435 | begin
|
---|
436 | Key := Uppercase(Key)[1];
|
---|
437 | if Key = 'M' then begin
|
---|
438 | SexComboBox.Text := 'MALE';
|
---|
439 | Key := #0;
|
---|
440 | end else if Key = 'F' then begin
|
---|
441 | SexComboBox.Text := 'FEMALE';
|
---|
442 | Key := #0;
|
---|
443 | end else if Key = #8 then begin
|
---|
444 | SexComboBox.Text := '';
|
---|
445 | Key := #0;
|
---|
446 | end else Key := #0;
|
---|
447 | end;
|
---|
448 | //------------------------------------------------------------------------
|
---|
449 | procedure TfrmPtAdd.PtTypeComboBoxKeyPress(Sender: TObject; var Key: Char);
|
---|
450 | begin
|
---|
451 | Key := #0;
|
---|
452 | end;
|
---|
453 | //------------------------------------------------------------------------
|
---|
454 | procedure TfrmPtAdd.PostInfo(ThisPatientInfo : TPatientInfo);
|
---|
455 | var tempResult: integer;
|
---|
456 | tempS,s2 : string;
|
---|
457 |
|
---|
458 | procedure CheckPost(Title, Value : string);
|
---|
459 | begin
|
---|
460 | if Value <> '' then RPCBrokerV.Param[0].Mult['"'+Title+'"'] := Value;
|
---|
461 | end;
|
---|
462 |
|
---|
463 | begin
|
---|
464 | if MessageDlg('Add New Patient? (Can Not Be Undone)',
|
---|
465 | mtConfirmation, [mbYes, mbNo],0) = mrNo then exit;
|
---|
466 |
|
---|
467 | RPCBrokerV.remoteprocedure := 'TMG ADD PATIENT';
|
---|
468 |
|
---|
469 | RPCBrokerV.Param[0].PType := list;
|
---|
470 | with ThisPatientInfo do begin
|
---|
471 | CombinedName := LName + ',' + FName;
|
---|
472 | If MName <> '' then CombinedName := CombinedName + ' ' + MName;
|
---|
473 | If Suffix <> '' then CombinedName := CombinedName + ' ' + Suffix;
|
---|
474 | CheckPost('COMBINED_NAME',CombinedName);
|
---|
475 | CheckPost('DOB',DOB);
|
---|
476 | CheckPost('SEX',Sex);
|
---|
477 | CheckPost('SS_NUM',SSNum);
|
---|
478 | //CheckPost('Veteran',Veteran);
|
---|
479 | //CheckPost('PtType',PtType);
|
---|
480 |
|
---|
481 | RPCBrokerV.Call;
|
---|
482 | tempS := RPCBrokerV.Results.Strings[0];
|
---|
483 | tempResult := strtoint(piece(tempS,'^',1));
|
---|
484 | DFN := tempResult;
|
---|
485 | if DFN > 0 then begin
|
---|
486 | //MessageDlg('Patient successfully added',mtInformation,[mbOK],0);
|
---|
487 | end else begin
|
---|
488 | s2 := piece(tempS,'^',2);
|
---|
489 | if (tempResult = 0) and (s2 <> '') then begin
|
---|
490 | DFN := strtoint(s2);
|
---|
491 | MessageDlg('Patient already exists.',mtError,[mbOK],0);
|
---|
492 | end else begin
|
---|
493 | MessageDlg('Error Adding: "'+tempS+'"',mtError,[mbOK],0);
|
---|
494 | end;
|
---|
495 | end;
|
---|
496 | end;
|
---|
497 | end;
|
---|
498 | //------------------------------------------------------------------------
|
---|
499 | procedure TfrmPtAdd.FormDestroy(Sender: TObject);
|
---|
500 | begin
|
---|
501 | ThisPatientInfo.Destroy;
|
---|
502 | end;
|
---|
503 | //------------------------------------------------------------------------
|
---|
504 | procedure TfrmPtAdd.CreatePSSN();
|
---|
505 | var
|
---|
506 | i: integer;
|
---|
507 | tempPseudo: string;
|
---|
508 | Init : array [1..3] of char;
|
---|
509 | code : char;
|
---|
510 | Month,Day,Year: string;
|
---|
511 |
|
---|
512 | begin
|
---|
513 | for i := 1 to 3 do Init[i]:=' ';
|
---|
514 | if ThisPatientInfo.FName<>'' then Init[1] := UpperCase(ThisPatientInfo.FName)[1];
|
---|
515 | if ThisPatientInfo.MName<>'' then Init[2] := UpperCase(ThisPatientInfo.MName)[1];
|
---|
516 | if ThisPatientInfo.LName<>'' then Init[3] := UpperCase(ThisPatientInfo.LName)[1];
|
---|
517 |
|
---|
518 | tempPseudo := '';
|
---|
519 | for i := 1 to 3 do begin
|
---|
520 | if Init[i] in ['A','B','C'] then code := '1'
|
---|
521 | else if Init[i] in ['D','E','F'] then code := '2'
|
---|
522 | else if Init[i] in ['G','H','I'] then code := '3'
|
---|
523 | else if Init[i] in ['J','K','L'] then code := '4'
|
---|
524 | else if Init[i] in ['M','N','O'] then code := '5'
|
---|
525 | else if Init[i] in ['P','Q','R'] then code := '6'
|
---|
526 | else if Init[i] in ['S','T','U'] then code := '7'
|
---|
527 | else if Init[i] in ['V','W','X'] then code := '8'
|
---|
528 | else if Init[i] in ['Y','Z'] then code := '9'
|
---|
529 | else if Init[i] in [' '] then code := '0'
|
---|
530 | else code := '0';
|
---|
531 | tempPseudo := tempPseudo + code;
|
---|
532 | end;
|
---|
533 |
|
---|
534 | Month := piece(ThisPatientInfo.DOB,'/',1);
|
---|
535 | Day := piece(ThisPatientInfo.DOB,'/',2);
|
---|
536 | Year := piece(ThisPatientInfo.DOB,'/',3);
|
---|
537 | tempPseudo := tempPseudo + Month + Day + Year + 'P';
|
---|
538 | ThisPatientInfo.SSNum := tempPseudo;
|
---|
539 | SSNumEdit.Text := ThisPatientInfo.SSNum;
|
---|
540 | SSNumEditExit(nil);
|
---|
541 | end;
|
---|
542 |
|
---|
543 | procedure TfrmPtAdd.DOBEditExit(Sender: TObject);
|
---|
544 | var
|
---|
545 | s,s2: string;
|
---|
546 | i:integer; boolInvalid: boolean;
|
---|
547 | begin
|
---|
548 | boolInvalid := False;
|
---|
549 | s2 := '';
|
---|
550 | For i:=1 to 3 do begin
|
---|
551 | s := piece(DobEdit.Text,'/',i);
|
---|
552 | if ((i = 3) and (length(s) = 4)) then s := rightstr(s,2);
|
---|
553 | if length(s) = 1 then s := '0' + s;
|
---|
554 | if s2 <> '' then s2 := s2 + '/';
|
---|
555 | s2 := s2 + s;
|
---|
556 | if length(s) <> 2 then boolInvalid := True;
|
---|
557 | end;
|
---|
558 |
|
---|
559 | if (boolInvalid = True) and (DOBEdit.Text<>'') then begin
|
---|
560 | messagedlg('DOB format is invalid. Please enter it in mm/dd/yy format.',mtError,[mbOK],0);
|
---|
561 | DOBEdit.text := '';
|
---|
562 | end else begin
|
---|
563 | DOBEdit.text := s2;
|
---|
564 | end;
|
---|
565 | end;
|
---|
566 |
|
---|
567 | procedure TfrmPtAdd.SSNHelpBtnClick(Sender: TObject);
|
---|
568 | begin
|
---|
569 | if MessageDlg('If Soc. Sec. Number (SSN) is unknown, a "Pseudo" SSN may be used.'+#10+#13+
|
---|
570 | 'Create a Pseudo-SSN For this Patient?',
|
---|
571 | mtConfirmation, [mbYes, mbNo],0) = mrYes then begin
|
---|
572 | CreatePSSN;
|
---|
573 | end else begin
|
---|
574 | SSNumEdit.Text := '';
|
---|
575 | end;
|
---|
576 | end;
|
---|
577 |
|
---|
578 | end.
|
---|
579 |
|
---|