source: cprs/branches/tmg-cprs/CPRS-Chart/TMG_Extra/fPtDemoEdit.pas@ 495

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

Tweaked edit patient demographics window (isolate phone #)

File size: 41.3 KB
Line 
1unit fPtDemoEdit;
2//kt Added this entire unit for demographics editing at runtime.
3
4interface
5
6uses
7 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
8 Dialogs, ComCtrls, StdCtrls, ExtCtrls, DKLang;
9
10type
11 BoolUC = (bucFalse, bucTrue, bucUnchanged);
12
13 TPatientInfo = class(TObject)
14 public
15 LName: String;
16 FName: String;
17 MName: String;
18 CombinedName: String;
19 Prefix: String;
20 Suffix: String;
21 Degree: String;
22 DOB: String;
23 Sex: String;
24 SSNum: String;
25 AliasInfo : TStringList; //format: s=IEN#, Object is ^tAlias
26 AddressLine1: String;
27 AddressLine2: String;
28 AddressLine3: String;
29 City: String;
30 State: String;
31 Zip4: String;
32 BadAddress: BoolUC;
33 PhoneNumResidence: String;
34 PhoneNumWork: String;
35 PhoneNumCell: String;
36 PhoneNumTemp: String;
37
38 TempAddressLine1: String;
39 TempAddressLine2: String;
40 TempAddressLine3: String;
41 TempCity: String;
42 TempState: String;
43 TempZip4: String;
44 TempStartingDate : String;
45 TempEndingDate : String;
46 TempAddressActive: BoolUC;
47
48 ConfidentalAddressLine1: String;
49 ConfidentalAddressLine2: String;
50 ConfidentalAddressLine3: String;
51 ConfidentalCity: String;
52 ConfidentalState: String;
53 ConfidentalZip4: String;
54 ConfidentalStartingDate : String;
55 ConfidentalEndingDate : String;
56 ConfAddressActive : BoolUC;
57
58 Modified : boolean;
59
60 constructor Create;
61 destructor Destroy; override;
62 procedure ClearAliasInfo;
63 procedure Clear;
64 procedure Assign(Source : TPatientInfo);
65 procedure RemoveUnchanged(OldInfo : TPatientInfo);
66 end;
67
68 TfrmPtDemoEdit = class(TForm)
69 OKBtn: TButton;
70 CancelBtn: TButton;
71 ApplyBtn: TButton;
72 PageControl: TPageControl;
73 DemoTabSheet: TTabSheet;
74 LNameLabel: TLabel;
75 FNameLabel: TLabel;
76 MNameLabel: TLabel;
77 CombinedNameLabel: TLabel;
78 PrefixLabel: TLabel;
79 SuffixLabel: TLabel;
80 DOBLabel: TLabel;
81 SSNumLabel: TLabel;
82 CombinedNameEdit: TEdit;
83 LNameEdit: TEdit;
84 FNameEdit: TEdit;
85 MNameEdit: TEdit;
86 PrefixEdit: TEdit;
87 SuffixEdit: TEdit;
88 DOBEdit: TEdit;
89 SSNumEdit: TEdit;
90 AliasGroupBox: TGroupBox;
91 AliasComboBox: TComboBox;
92 AliasNameLabel: TLabel;
93 AliasSSNumLabel: TLabel;
94 AliasNameEdit: TEdit;
95 AliasSSNEdit: TEdit;
96 AddressGroupBox: TGroupBox;
97 AddressRGrp: TRadioGroup;
98 AddressLine1Edit: TEdit;
99 AddressLine2Edit: TEdit;
100 AddressLine3Edit: TEdit;
101 CityLabel: TLabel;
102 CityEdit: TEdit;
103 StateComboBox: TComboBox;
104 Zip4Edit: TEdit;
105 Zip4Label: TLabel;
106 BadAddressCB: TCheckBox;
107 TempActiveCB: TCheckBox;
108 SexLabel: TLabel;
109 SexComboBox: TComboBox;
110 DelAliasBtn: TButton;
111 StartingDateEdit: TEdit;
112 StartingDateLabel: TLabel;
113 EndingDateLabel: TLabel;
114 EndingDateEdit: TEdit;
115 ConfActiveCB: TCheckBox;
116 DegreeEdit: TEdit;
117 DegreeLabel: TLabel;
118 AddAliasBtn: TButton;
119 DKLanguageController1: TDKLanguageController;
120 GroupBox1: TGroupBox;
121 PhoneNumGrp: TRadioGroup;
122 PhoneNumEdit: TEdit;
123 procedure AliasComboBoxChange(Sender: TObject);
124 procedure FormCreate(Sender: TObject);
125 procedure AddressRGrpClick(Sender: TObject);
126 procedure PhoneNumGrpClick(Sender: TObject);
127 procedure DelAliasBtnClick(Sender: TObject);
128 procedure FormDestroy(Sender: TObject);
129 procedure FormShow(Sender: TObject);
130 procedure CombinedNameEditChange(Sender: TObject);
131 procedure LNameEditChange(Sender: TObject);
132 procedure FNameEditChange(Sender: TObject);
133 procedure MNameEditChange(Sender: TObject);
134 procedure PrefixEditChange(Sender: TObject);
135 procedure SuffixEditChange(Sender: TObject);
136 procedure SexComboBoxChange(Sender: TObject);
137 procedure AddressLine1EditChange(Sender: TObject);
138 procedure AddressLine2EditChange(Sender: TObject);
139 procedure AddressLine3EditChange(Sender: TObject);
140 procedure CityEditChange(Sender: TObject);
141 procedure Zip4EditChange(Sender: TObject);
142 procedure StateComboBoxChange(Sender: TObject);
143 procedure TempActiveCBClick(Sender: TObject);
144 procedure ConfActiveCBClick(Sender: TObject);
145 procedure BadAddressCBClick(Sender: TObject);
146 procedure DegreeEditChange(Sender: TObject);
147 procedure PhoneNumEditChange(Sender: TObject);
148 procedure StartingDateEditChange(Sender: TObject);
149 procedure EndingDateEditChange(Sender: TObject);
150 procedure AliasNameEditChange(Sender: TObject);
151 procedure AliasSSNEditChange(Sender: TObject);
152 procedure ApplyBtnClick(Sender: TObject);
153 procedure AddAliasBtnClick(Sender: TObject);
154 procedure OKBtnClick(Sender: TObject);
155 procedure CancelBtnClick(Sender: TObject);
156 procedure DOBEditChange(Sender: TObject);
157 procedure SSNumEditChange(Sender: TObject);
158 private
159 { Private declarations }
160 FCurPatientInfo : TPatientInfo;
161 FServerPatientInfo : TPatientInfo;
162 FCurAliasEdit : integer;
163 ProgAliasChangeOccuring : boolean;
164 ProgNameChangeOccuring : boolean;
165 ProgPhoneChangeOccuring : boolean;
166 ProgAddressChangeOccuring : boolean;
167 MaxAliasIEN : integer;
168 ChangesMade : boolean;
169 procedure GetPtInfo(PatientInfo : TPatientInfo);
170 procedure PostChangedInfo(PatientInfo : TPatientInfo);
171 procedure ShowAliasInfo(Patient : TPatientInfo);
172 procedure ShowPtInfo(Patient : TPatientInfo);
173 function CombinedName : string;
174 procedure NameParts(CombinedName: string; var LName, FName, MName : string);
175 procedure SetModified(value : boolean);
176 procedure SetAliasEnabled(value : boolean);
177 public
178 { Public declarations }
179 end;
180
181var
182 frmPtDemoEdit: TfrmPtDemoEdit;
183
184implementation
185
186{$R *.dfm}
187
188uses
189 IniFiles,Trpcb,ORNet,uCore, mfunstr;
190
191const
192 ADD_NEW_ALIAS = '<Add New Alias>';
193
194type
195 tAlias= class
196 Name : string;
197 SSN : string;
198 procedure Assign(Source: tAlias);
199 end;
200
201procedure tAlias.Assign(Source : tAlias);
202begin
203 Name := Source.Name;
204 SSN := Source.SSN;
205end;
206
207//=========================================================
208//=========================================================
209//=========================================================
210
211constructor TPatientInfo.Create;
212begin
213 AliasInfo := TStringList.Create;
214 Clear;
215end;
216
217destructor TPatientInfo.Destroy;
218begin
219 ClearAliasInfo;
220 AliasInfo.Free;
221 inherited Destroy;
222End;
223
224procedure TPatientInfo.ClearAliasInfo;
225var i : integer;
226 pAlias : tAlias;
227begin
228 for i := 0 to AliasInfo.Count-1 do begin
229 pAlias := tAlias(AliasInfo.Objects[i]);
230 pAlias.Free;
231 end;
232 AliasInfo.Clear
233End;
234
235procedure TPatientInfo.Clear;
236begin
237 LName:= '';
238 FName:= '';
239 MName:= '';
240 CombinedName:= '';
241 Prefix:= '';
242 Suffix:= '';
243 Degree:= '';
244 DOB:= '';
245 SSNum:= '';
246 ClearAliasInfo;
247 AddressLine1:= '';
248 AddressLine2:= '';
249 AddressLine3:= '';
250 City:= '';
251 State:= '';
252 Zip4:= '';
253 TempAddressLine1:= '';
254 TempAddressLine2:= '';
255 TempAddressLine3:= '';
256 TempCity:= '';
257 TempState:= '';
258 TempZip4:= '';
259 TempStartingDate := '';
260 TempEndingDate := '';
261 ConfidentalAddressLine1:= '';
262 ConfidentalAddressLine2:= '';
263 ConfidentalAddressLine3:= '';
264 ConfidentalCity:= '';
265 ConfidentalState:= '';
266 ConfidentalZip4:= '';
267 ConfidentalStartingDate := '';
268 ConfidentalEndingDate := '';
269 BadAddress:= bucFalse;
270 TempAddressActive:= bucFalse;
271 ConfAddressActive := bucFalse;
272 Modified := false;
273
274 PhoneNumResidence:= '';
275 PhoneNumWork:= '';
276 PhoneNumCell:= '';
277 PhoneNumTemp:= '';
278 Sex:= '';
279end;
280
281
282procedure TPatientInfo.Assign(Source : TPatientInfo);
283var i : integer;
284 pAlias : tAlias;
285 OtherpAlias : tAlias;
286begin
287 LName:=Source.LName;
288 FName:=Source.FName;
289 MName:=Source.MName;
290 CombinedName:=Source.CombinedName;
291 Prefix:=Source.Prefix;
292 Suffix:=Source.Suffix;
293 Degree:=Source.Degree;
294 DOB:=Source.DOB;
295 SSNum:=Source.SSNum;
296
297 ClearAliasInfo;
298 //Copy pointed to tAlias entries, don't simply copy references
299 for i := 0 to Source.AliasInfo.Count-1 do begin
300 AliasInfo.Add(Source.AliasInfo.Strings[i]);
301 OtherpAlias := tAlias(Source.AliasInfo.Objects[i]);
302 if OtherpAlias<>nil then begin
303 pAlias := tAlias.Create;
304 pAlias.Name := OtherpAlias.Name;
305 pAlias.SSN := OtherpAlias.SSN;
306 AliasInfo.Objects[i]:=pAlias;
307 end;
308 end;
309 AddressLine1:=Source.AddressLine1;
310 AddressLine2:=Source.AddressLine2;
311 AddressLine3:=Source.AddressLine3;
312 City:=Source.City;
313 State:=Source.State;
314 Zip4:=Source.Zip4;
315 TempAddressLine1:=Source.TempAddressLine1;
316 TempAddressLine2:=Source.TempAddressLine2;
317 TempAddressLine3:=Source.TempAddressLine3;
318 TempCity:=Source.TempCity;
319 TempState:=Source.TempState;
320 TempZip4:=Source.TempZip4;
321 TempStartingDate :=Source.TempStartingDate ;
322 TempEndingDate :=Source.TempEndingDate ;
323 ConfidentalAddressLine1:=Source.ConfidentalAddressLine1;
324 ConfidentalAddressLine2:=Source.ConfidentalAddressLine2;
325 ConfidentalAddressLine3:=Source.ConfidentalAddressLine3;
326 ConfidentalCity:=Source.ConfidentalCity;
327 ConfidentalState:=Source.ConfidentalState;
328 ConfidentalZip4:=Source.ConfidentalZip4;
329 ConfidentalStartingDate :=Source.ConfidentalStartingDate ;
330 ConfidentalEndingDate :=Source.ConfidentalEndingDate ;
331 BadAddress:= Source.BadAddress;
332 TempAddressActive:= Source.TempAddressActive;
333 ConfAddressActive := Source.ConfAddressActive;
334 PhoneNumResidence:=Source.PhoneNumResidence;
335 PhoneNumWork:=Source.PhoneNumWork;
336 PhoneNumCell:=Source.PhoneNumCell;
337 PhoneNumTemp:=Source.PhoneNumTemp;
338 Sex:=Source.Sex;
339end;
340
341
342procedure TPatientInfo.RemoveUnchanged(OldInfo : TPatientInfo);
343//Will remove entries that are unchanged from OldInfo
344//ALSO, will change AliasInfo entries:
345// Other code adds "IEN" numbers that don't have any corresponding
346// true IEN on the server. This will convert these to +1,+2 etc.
347// And, if there is an alias entry in the OldInfo that is not
348// in this info, then a matching @ entry for that IEN will be generated.
349
350 procedure CompStrs(var newS, oldS : string);
351 begin
352 if newS = oldS then begin
353 newS := ''; //no change,
354 end else begin
355 if (newS = '') and (oldS <> '') then newS := '@' //delete symbol
356 end;
357 end;
358
359 procedure CompBoolUC(var newBN, oldBN : BoolUC);
360 begin
361 if newBN=oldBN then begin
362 newBN := bucUnchanged; //Mark unchanged
363 end;
364 end;
365
366 const
367 BOOL_STR : array[false..true] of string =('TRUE','FALSE');
368 NO_CHANGE = 1;
369 NEW_RECORD = 2;
370 DELETED_RECORD = 3;
371 CHANGED_RECORD = 4;
372
373 function CompAliasRec(curAlias,oldAlias : tAlias) : integer;
374 //Returns: NO_CHANGE = 1; NEW_RECORD = 2; DELETED_RECORD = 3; CHANGED_RECORD = 4;
375 begin
376 Result := NO_CHANGE;
377 if (curAlias <> nil) and (oldAlias <> nil) then begin
378 if curAlias.Name = '' then begin
379 if oldAlias.Name <> '' then Result := DELETED_RECORD;
380 end else if curAlias.Name <> oldAlias.Name then begin
381 Result := CHANGED_RECORD;
382 end;
383 if Result = NO_CHANGE then begin
384 if curAlias.SSN <> oldAlias.SSN then Result := CHANGED_RECORD;
385 end;
386 end;
387 end;
388
389 function CompAlias(IEN : string; pAlias : tAlias; OldInfo : TPatientInfo) : integer;
390 //format: s=IEN#, Object is ^tAlias
391 //Returns: NO_CHANGE = 1; NEW_RECORD = 2; DELETED_RECORD = 3; CHANGED_RECORD = 4;
392 var i : integer;
393 oldPAlias : tAlias;
394 begin
395 Result := NEW_RECORD;
396 for i := 0 to OldInfo.AliasInfo.Count-1 do begin
397 if OldInfo.AliasInfo.Strings[i] = IEN then begin
398 oldPAlias := tAlias(OldInfo.AliasInfo.Objects[i]);
399 Result := CompAliasRec(pAlias,oldPAlias);
400 break;
401 end;
402 end;
403 end;
404
405 var i,j,AddCt : integer;
406 pAlias, tempPAlias : tAlias;
407
408begin
409 {if OldInfo = This Info, then remove entries}
410 CompStrs(LName, OldInfo.LName);
411 CompStrs(FName, OldInfo.FName);
412 CompStrs(MName, OldInfo.MName);
413 CompStrs(CombinedName, OldInfo.CombinedName);
414 CompStrs(Prefix, OldInfo.Prefix);
415 CompStrs(Suffix, OldInfo.Suffix);
416 CompStrs(Degree, OldInfo.Degree);
417 CompStrs(DOB, OldInfo.DOB);
418 CompStrs(SSNum, OldInfo.SSNum);
419
420 CompStrs(AddressLine1, OldInfo.AddressLine1);
421 CompStrs(AddressLine2, OldInfo.AddressLine2);
422 CompStrs(AddressLine3, OldInfo.AddressLine3);
423 CompStrs(City, OldInfo.City);
424 CompStrs(State, OldInfo.State);
425 CompStrs(Zip4, OldInfo.Zip4);
426 CompStrs(TempAddressLine1, OldInfo.TempAddressLine1);
427 CompStrs(TempAddressLine2, OldInfo.TempAddressLine2);
428 CompStrs(TempAddressLine3, OldInfo.TempAddressLine3);
429 CompStrs(TempCity, OldInfo.TempCity);
430 CompStrs(TempState, OldInfo.TempState);
431 CompStrs(TempZip4, OldInfo.TempZip4);
432 CompStrs(TempStartingDate , OldInfo.TempStartingDate );
433 CompStrs(TempEndingDate , OldInfo.TempEndingDate );
434 CompStrs(ConfidentalAddressLine1, OldInfo.ConfidentalAddressLine1);
435 CompStrs(ConfidentalAddressLine2, OldInfo.ConfidentalAddressLine2);
436 CompStrs(ConfidentalAddressLine3, OldInfo.ConfidentalAddressLine3);
437 CompStrs(ConfidentalCity, OldInfo.ConfidentalCity);
438 CompStrs(ConfidentalState, OldInfo.ConfidentalState);
439 CompStrs(ConfidentalZip4, OldInfo.ConfidentalZip4);
440 CompStrs(ConfidentalStartingDate , OldInfo.ConfidentalStartingDate );
441 CompStrs(ConfidentalEndingDate , OldInfo.ConfidentalEndingDate );
442
443 CompBoolUC(BadAddress, OldInfo.BadAddress);
444 CompBoolUC(TempAddressActive, OldInfo.TempAddressActive);
445 CompBoolUC(ConfAddressActive, OldInfo.ConfAddressActive);
446
447 CompStrs(PhoneNumResidence, OldInfo.PhoneNumResidence);
448 CompStrs(PhoneNumWork, OldInfo.PhoneNumWork);
449 CompStrs(PhoneNumCell, OldInfo.PhoneNumCell);
450 CompStrs(PhoneNumTemp, OldInfo.PhoneNumTemp);
451 CompStrs(Sex, OldInfo.Sex);
452
453 //Compare Aliases
454 //format: s=IEN#, Object is ^tAlias
455
456 //first, see which entries in OldInfo are deleted in CurInfo.
457 for i := 0 to OldInfo.AliasInfo.Count-1 do begin
458 pAlias := tAlias(OldInfo.AliasInfo.Objects[i]);
459 if CompAlias(OldInfo.AliasInfo.Strings[i], pAlias, self) = NEW_RECORD then begin
460 //here we have an entry in OldInfo, not in CurInfo, so must represent a Delete
461 //This needs to be posted to server with old IEN and @ symbol
462 tempPAlias := tAlias.Create;
463 tempPAlias.Name := '@';
464 AliasInfo.AddObject(OldInfo.AliasInfo.Strings[i],tempPAlias);
465 end;
466 end;
467
468 AddCt := 0;
469 //First, see which entries in New PatientInfo are new, or unchanged.
470 for i := 0 to AliasInfo.Count-1 do begin
471 pAlias := tAlias(AliasInfo.Objects[i]);
472 if (pAlias=nil) then continue;
473 if pAlias.Name= '@' then continue; //skip those marked as deleted from OldInfo
474 case CompAlias(AliasInfo.Strings[i], pAlias, OldInfo) of
475 NO_CHANGE : begin //delete unchanged data (no need to repost to server)
476 pAlias.Destroy;
477 AliasInfo.Strings[i] :='<@>'; //mark for deletion below
478 end;
479 NEW_RECORD : begin //mark as +1, +2 etc IEN
480 AddCt := AddCt + 1;
481 AliasInfo.Strings[i] := '+' + IntToStr(AddCt);
482 end;
483 CHANGED_RECORD : begin end; // do nothing, leave changes in place
484 end; {case}
485 end;
486
487 for i := AliasInfo.Count-1 downto 0 do begin
488 if AliasInfo.Strings[i] = '<@>' then AliasInfo.Delete(i);
489 end;
490
491
492end;
493
494
495//=========================================================
496//=========================================================
497//=========================================================
498
499procedure TfrmPtDemoEdit.GetPtInfo;
500var tempINI : TMemINIFile; //I do this to make dealing with hash table read easier
501 i,index : integer;
502 IEN, Key,Value,s : string;
503 pAlias : tAlias;
504
505begin
506 FServerPatientInfo.Clear;
507 tempINI := TMemINIFile.Create('xxx.ini');
508
509 RPCBrokerV.remoteprocedure := 'TMG GET PATIENT DEMOGRAPHICS';
510 RPCBrokerV.param[0].value := Patient.DFN; RPCBrokerV.param[0].ptype := literal;
511 RPCBrokerV.Call;
512
513 with FServerPatientInfo do begin
514 //Store results in a hash table for easier random access
515 //Don't store Alias info in hash table, put directly into AliasInfo stringlist
516 for i := 0 to RPCBrokerV.Results.Count-1 do begin
517 s := RPCBrokerV.Results.Strings[i];
518 if Pos('ALIAS',s)=0 then begin
519 Key := piece(s,'=',1);
520 Value := piece(s,'=',2);
521 tempINI.WriteString('DATA',Key,Value);
522 end else begin
523 IEN := piece(s,' ',2);
524 if StrToInt(IEN)>MaxAliasIEN then MaxAliasIEN := StrToInt(IEN);
525 index := AliasInfo.IndexOf(IEN);
526 if index <0 then begin
527 pAlias := tAlias.Create; //AliasInfo will own these.
528 AliasInfo.AddObject(IEN,pAlias);
529 end else begin
530 pAlias := tAlias(AliasInfo.Objects[index]);
531 end;
532 if Pos('NAME=',s)>0 then begin
533 pAlias.Name := piece(s,'=',2);
534 end else if Pos('SSN=',s)>0 then begin
535 pAlias.SSN := piece(s,'=',2);
536 end;
537 end;
538 end;
539 LName:=tempINI.ReadString('DATA','LNAME','');
540 FName:=tempINI.ReadString('DATA','FNAME','');
541 MName:=tempINI.ReadString('DATA','MNAME','');
542 CombinedName:=tempINI.ReadString('DATA','COMBINED_NAME','');
543 Prefix:=tempINI.ReadString('DATA','PREFIX','');
544 Suffix:=tempINI.ReadString('DATA','SUFFIX','');
545 Degree:=tempINI.ReadString('DATA','DEGREE','');
546 DOB:= tempINI.ReadString('DATA','DOB','');
547 Sex:= tempINI.ReadString('DATA','SEX','');
548 SSNum:= tempINI.ReadString('DATA','SS_NUM','');
549 AddressLine1:= tempINI.ReadString('DATA','ADDRESS_LINE_1','');
550 AddressLine2:= tempINI.ReadString('DATA','ADDRESS_LINE_2','');
551 AddressLine3:= tempINI.ReadString('DATA','ADDRESS_LINE_3','');
552 City:= tempINI.ReadString('DATA','CITY','');
553 State:= tempINI.ReadString('DATA','STATE','');
554 Zip4:= tempINI.ReadString('DATA','ZIP4','');
555 BadAddress:= BoolUC(tempINI.ReadString('DATA','BAD_ADDRESS','')<>'');
556 TempAddressLine1:= tempINI.ReadString('DATA','TEMP_ADDRESS_LINE_1','');
557 TempAddressLine2:= tempINI.ReadString('DATA','TEMP_ADDRESS_LINE_2','');
558 TempAddressLine3:= tempINI.ReadString('DATA','TEMP_ADDRESS_LINE_3','');
559 TempCity:= tempINI.ReadString('DATA','TEMP_CITY','');
560 TempState:=tempINI.ReadString('DATA','TEMP_STATE','');
561 TempZip4:= tempINI.ReadString('DATA','TEMP_ZIP4','');
562 TempStartingDate :=tempINI.ReadString('DATA','TEMP_STARTING_DATE','');
563 TempEndingDate := tempINI.ReadString('DATA','TEMP_ENDING_DATE','');
564 TempAddressActive:= BoolUC(tempINI.ReadString('DATA','TEMP_ADDRESS_ACTIVE','')='YES');
565 ConfidentalAddressLine1:= tempINI.ReadString('DATA','CONF_ADDRESS_LINE_1','');
566 ConfidentalAddressLine2:= tempINI.ReadString('DATA','CONF_ADDRESS_LINE_2','');
567 ConfidentalAddressLine3:= tempINI.ReadString('DATA','CONF_ADDRESS_LINE_3','');
568 ConfidentalCity:= tempINI.ReadString('DATA','CONF_CITY','');
569 ConfidentalState:= tempINI.ReadString('DATA','CONF_STATE','');
570 ConfidentalZip4:= tempINI.ReadString('DATA','CONF_ZIP4','');
571 ConfidentalStartingDate := tempINI.ReadString('DATA','CONG_STARTING_DATE','');
572 ConfidentalEndingDate := tempINI.ReadString('DATA','CONF_ENDING_DATE','');
573 ConfAddressActive:= BoolUC(tempINI.ReadString('DATA','CONF_ADDRESS_ACTIVE','')='YES');
574 PhoneNumResidence:= tempINI.ReadString('DATA','PHONE_RESIDENCE','');
575 PhoneNumWork:= tempINI.ReadString('DATA','PHONE_WORK','');
576 PhoneNumCell:= tempINI.ReadString('DATA','PHONE_CELL','');
577 PhoneNumTemp:= tempINI.ReadString('DATA','PHONE_TEMP','');
578 end;
579 FCurPatientInfo.Assign(FServerPatientInfo);
580 tempINI.Free; //I don't write out, so should never end up on disk.
581end;
582
583procedure TfrmPtDemoEdit.PostChangedInfo(PatientInfo : TPatientInfo);
584
585 procedure CheckBUCPost(Title : string; Value : BoolUC);
586 begin
587 if Value <> bucUnchanged then begin
588 if Value = bucTrue then RPCBrokerV.Param[1].Mult['"'+Title+'"'] := 'YES';
589 if Value = bucFalse then RPCBrokerV.Param[1].Mult['"'+Title+'"'] := 'NO';
590 end;
591 end;
592
593 procedure CheckPost(Title, Value : string);
594 begin
595 if Value <> '' then RPCBrokerV.Param[1].Mult['"'+Title+'"'] := Value;
596 end;
597
598 var i : integer;
599 pAlias : tAlias;
600begin
601 RPCBrokerV.remoteprocedure := 'TMG SET PATIENT DEMOGRAPHICS';
602 RPCBrokerV.param[0].value := Patient.DFN; RPCBrokerV.param[0].ptype := literal;
603
604 RPCBrokerV.Param[1].PType := list;
605 with PatientInfo do begin
606 CheckPost('COMBINED_NAME',CombinedName);
607 //CheckPost('LNAME', LName); //Don't send because data is in COMBINED NAME
608 //CheckPost('FNAME',FName);
609 //CheckPost('MNAME',MName);
610 //CheckPost('PREFIX',Prefix);
611 //CheckPost('SUFFIX',Suffix);
612 //CheckPost('DEGREE',Degree);
613 CheckPost('DOB',DOB);
614 CheckPost('SEX',Sex);
615 CheckPost('SS_NUM',SSNum);
616 CheckPost('ADDRESS_LINE_1',AddressLine1);
617 CheckPost('ADDRESS_LINE_2',AddressLine2);
618 CheckPost('ADDRESS_LINE_3',AddressLine3);
619 CheckPost('CITY',City);
620 CheckPost('STATE',State);
621 CheckPost('ZIP4',Zip4);
622
623 CheckPost('TEMP_ADDRESS_LINE_1',TempAddressLine1);
624 CheckPost('TEMP_ADDRESS_LINE_2',TempAddressLine2);
625 CheckPost('TEMP_ADDRESS_LINE_3',TempAddressLine3);
626 CheckPost('TEMP_CITY',TempCity);
627 CheckPost('TEMP_STATE',TempState);
628 CheckPost('TEMP_ZIP4',TempZip4);
629 CheckPost('TEMP_STARTING_DATE',TempStartingDate );
630 CheckPost('TEMP_ENDING_DATE',TempEndingDate );
631 CheckPost('CONF_ADDRESS_LINE_1',ConfidentalAddressLine1);
632 CheckPost('CONF_ADDRESS_LINE_2',ConfidentalAddressLine2);
633 CheckPost('CONF_ADDRESS_LINE_3',ConfidentalAddressLine3);
634 CheckPost('CONF_CITY',ConfidentalCity);
635 CheckPost('CONF_STATE',ConfidentalState);
636 CheckPost('CONF_ZIP4',ConfidentalZip4);
637 CheckPost('CONG_STARTING_DATE',ConfidentalStartingDate );
638 CheckPost('CONF_ENDING_DATE',ConfidentalEndingDate );
639 CheckPost('PHONE_RESIDENCE',PhoneNumResidence);
640 CheckPost('PHONE_WORK',PhoneNumWork);
641 CheckPost('PHONE_CELL',PhoneNumCell);
642 CheckPost('PHONE_TEMP',PhoneNumTemp);
643
644 case BadAddress of
645 bucTrue: RPCBrokerV.Param[1].Mult['"BAD_ADDRESS"'] := 'UNDELIVERABLE';
646 bucFalse: RPCBrokerV.Param[1].Mult['"BAD_ADDRESS"'] := '@';
647 end; {case}
648 CheckBUCPost('TEMP_ADDRESS_ACTIVE', TempAddressActive);
649 CheckBUCPost('CONF_ADDRESS_ACTIVE', ConfAddressActive);
650
651 for i := 0 to AliasInfo.Count-1 do begin
652 pAlias := tAlias(AliasInfo.Objects[i]);
653 if (pAlias=nil) then continue;
654 RPCBrokerV.Param[1].Mult['"ALIAS ' + AliasInfo.Strings[i] + ' NAME"'] := pAlias.Name;
655 if pAlias.Name <> '@' then begin
656 RPCBrokerV.Param[1].Mult['"ALIAS ' + AliasInfo.Strings[i] + ' SSN"'] := pAlias.SSN;
657 end;
658 end;
659
660 RPCBrokerV.Call;
661 if RPCBrokerV.Results.Strings[0]<>'1' then begin
662 MessageDlg(RPCBrokerV.Results.Strings[0],mtError,[mbOK],0);
663 end else begin
664 ChangesMade := true;
665 end;
666 end;
667end;
668
669
670procedure TfrmPtDemoEdit.ShowPtInfo(Patient : TPatientInfo);
671var i : integer;
672 pAlias : tAlias;
673begin
674 ProgNameChangeOccuring := true;
675 With Patient do begin
676 LNameEdit.Text := LName;
677 FNameEdit.Text := FName;
678 MNameEdit.Text := MName;
679 CombinedNameEdit.Text := CombinedName;
680 PrefixEdit.Text := Prefix;
681 SuffixEdit.Text := Suffix;
682 DegreeEdit.Text := Degree;
683 DOBEdit.Text := DOB;
684 SSNumEdit.Text := SSNum;
685 if Sex='MALE' then SexComboBox.ItemIndex := 0 else SexComboBox.ItemIndex := 1;
686 AliasComboBox.Items.Clear;
687 for i := 0 to AliasInfo.Count-1 do begin
688 pAlias := tAlias(AliasInfo.Objects[i]);
689 if pAlias<>nil then begin
690 AliasComboBox.Items.AddObject(pAlias.Name,pAlias);
691 end;
692 end;
693 if AliasComboBox.Items.count>0 then begin
694 AliasComboBox.ItemIndex := 0;
695 SetAliasEnabled(true);
696 end;
697 ShowAliasInfo(Patient);
698
699 PhoneNumGrp.ItemIndex := 0;
700 PhoneNumGrpClick(self);
701 end;
702
703 BadAddressCB.Visible := false;
704 TempActiveCB.Visible := false;
705 ProgNameChangeOccuring := false;
706end;
707
708procedure TfrmPtDemoEdit.ShowAliasInfo(Patient : TPatientInfo);
709var i : integer;
710 pAlias : tAlias;
711begin
712 i := AliasComboBox.ItemIndex;
713 if i > -1 then begin
714 if i < Patient.AliasInfo.Count then begin
715 pAlias := tAlias(Patient.AliasInfo.Objects[i]);
716 end else pAlias := nil;
717 ProgAliasChangeOccuring := true;
718 if pAlias<>nil then begin
719 AliasNameEdit.Text := pAlias.Name;
720 AliasSSNEdit.Text := pAlias.SSN;
721 end else begin
722 AliasNameEdit.Text := '';
723 AliasSSNEdit.Text := '';
724 end;
725 ProgAliasChangeOccuring := false;
726 end;
727end;
728
729
730procedure TfrmPtDemoEdit.AliasComboBoxChange(Sender: TObject);
731var s : string;
732 i : integer;
733begin
734 if ProgAliasChangeOccuring=false then begin
735 i := AliasCombobox.ItemIndex;
736 if i>-1 then begin
737 s := AliasCombobox.Items.Strings[i];
738 SetAliasEnabled(true);
739 end else begin
740 SetAliasEnabled(false);
741 end;
742 ShowAliasInfo(FCurPatientInfo);
743 end;
744end;
745
746procedure TfrmPtDemoEdit.FormCreate(Sender: TObject);
747begin
748 FCurAliasEdit := -1;
749 FCurPatientInfo := TPatientInfo.Create;
750 FServerPatientInfo := TPatientInfo.Create;
751 ProgAliasChangeOccuring := false;
752 ProgNameChangeOccuring := false;
753 ProgPhoneChangeOccuring := false;
754 ProgAddressChangeOccuring := false;
755 MaxAliasIEN := 0;
756 ChangesMade := false;
757end;
758
759procedure TfrmPtDemoEdit.FormDestroy(Sender: TObject);
760begin
761 FCurPatientInfo.Destroy;
762 FServerPatientInfo.Destroy;
763end;
764
765
766procedure TfrmPtDemoEdit.AddressRGrpClick(Sender: TObject);
767begin
768 {fill in data for newly selected fields}
769 ProgAddressChangeOccuring := true;
770 TempActiveCB.Visible := false;
771 BadAddressCB.Visible := false;
772 ConfActiveCB.Visible := false;
773 StartingDateLabel.Visible := false;
774 StartingDateEdit.Visible := false;
775 EndingDateLabel.Visible := false;
776 EndingDateEdit.Visible := false;
777 case AddressRGrp.ItemIndex of
778 0 : begin //Permanant
779 AddressLine1Edit.Text := FCurPatientInfo.AddressLine1;
780 AddressLine2Edit.Text := FCurPatientInfo.AddressLine2;
781 AddressLine3Edit.text := FCurPatientInfo.AddressLine3;
782 CityEdit.text := FCurPatientInfo.City;
783 StateComboBox.text := FCurPatientInfo.State;
784 Zip4Edit.text := FCurPatientInfo.Zip4;
785 BadAddressCB.Visible := true;
786 BadAddressCB.Checked := (FCurPatientInfo.BadAddress=bucTrue);
787 end;
788 1 : begin //temp
789 AddressLine1Edit.Text := FCurPatientInfo.TempAddressLine1;
790 AddressLine2Edit.Text := FCurPatientInfo.TempAddressLine2;
791 AddressLine3Edit.Text := FCurPatientInfo.TempAddressLine3;
792 CityEdit.Text := FCurPatientInfo.TempCity;
793 StateComboBox.Text := FCurPatientInfo.TempState;
794 Zip4Edit.Text := FCurPatientInfo.TempZip4;
795 StartingDateEdit.Text := FCurPatientInfo.TempStartingDate ;
796 EndingDateEdit.Text := FCurPatientInfo.TempEndingDate ;
797 StartingDateLabel.Visible := true;
798 StartingDateEdit.Visible := true;
799 EndingDateLabel.Visible := true;
800 EndingDateEdit.Visible := true;
801 TempActiveCB.Visible := true;
802 TempActiveCB.Checked := (FCurPatientInfo.TempAddressActive=bucTrue);
803 end;
804 2 : begin //confidental
805 AddressLine1Edit.Text := FCurPatientInfo.ConfidentalAddressLine1;
806 AddressLine2Edit.Text := FCurPatientInfo.ConfidentalAddressLine2;
807 AddressLine3Edit.Text := FCurPatientInfo.ConfidentalAddressLine3;
808 CityEdit.Text := FCurPatientInfo.ConfidentalCity;
809 StateComboBox.Text := FCurPatientInfo.ConfidentalState;
810 Zip4Edit.Text := FCurPatientInfo.ConfidentalZip4;
811 StartingDateEdit.Text := FCurPatientInfo.ConfidentalStartingDate ;
812 EndingDateEdit.Text := FCurPatientInfo.ConfidentalEndingDate ;
813 StartingDateLabel.Visible := true;
814 StartingDateEdit.Visible := true;
815 EndingDateLabel.Visible := true;
816 EndingDateEdit.Visible := true;
817 ConfActiveCB.Visible := true;
818 ConfActiveCB.Checked := (FCurPatientInfo.ConfAddressActive=bucTrue);
819 end;
820 end; {case}
821 ProgAddressChangeOccuring := false;
822end;
823
824procedure TfrmPtDemoEdit.PhoneNumGrpClick(Sender: TObject);
825begin
826 ProgPhoneChangeOccuring := true;
827 case PhoneNumGrp.ItemIndex of
828 0 : begin //Residence
829 PhoneNumEdit.Text := FCurPatientInfo.PhoneNumResidence;
830 end;
831 1 : begin //work
832 PhoneNumEdit.Text := FCurPatientInfo.PhoneNumWork;
833 end;
834 2 : begin //cell
835 PhoneNumEdit.Text := FCurPatientInfo.PhoneNumCell;
836 end;
837 3 : begin //temp
838 PhoneNumEdit.Text := FCurPatientInfo.PhoneNumTemp;
839 end;
840 else begin
841 PhoneNumEdit.Text := '';
842 end;
843 end; {case}
844 ProgPhoneChangeOccuring := false;
845end;
846
847procedure TfrmPtDemoEdit.DelAliasBtnClick(Sender: TObject);
848var i, j : integer;
849 pAlias : tAlias;
850begin
851 i := AliasComboBox.ItemIndex;
852 if i > -1 then begin
853 pAlias := tAlias(AliasComboBox.Items.Objects[i]);
854 if pAlias<>nil then begin
855 for j := 0 to FCurPatientInfo.AliasInfo.Count-1 do begin
856 if FCurPatientInfo.AliasInfo.Objects[j] = pAlias then begin
857 FCurPatientInfo.AliasInfo.Delete(j);
858 SetModified(true);
859 pAlias.Free;
860 AliasComboBox.Items.Delete(i);
861 //AliasComboBox.ItemIndex := 0;
862 //ShowAliasInfo(FCurPatientInfo);
863 ProgAliasChangeOccuring:= true;
864 AliasNameEdit.Text:='';
865 AliasSSNEdit.Text:='';
866 ProgAliasChangeOccuring:= false;
867 break;
868 end;
869 end;
870 end;
871 end;
872 if AliasCombobox.Items.Count=0 then begin
873 AliasNameEdit.Text:='';
874 AliasSSNEdit.Text:='';
875 SetAliasEnabled(false);
876 AliasCombobox.Text := '';
877 end;
878end;
879
880procedure TfrmPtDemoEdit.FormShow(Sender: TObject);
881begin
882 GetPtInfo(FServerPatientInfo);
883 FCurPatientInfo.Assign(FServerPatientInfo);
884 ShowPtInfo(FCurPatientInfo);
885end;
886
887procedure TfrmPtDemoEdit.CombinedNameEditChange(Sender: TObject);
888var LName,FName,MName : string;
889begin
890 if ProgNameChangeOccuring = false then begin
891 FCurPatientInfo.CombinedName := CombinedNameEdit.Text;
892 SetModified(true);
893 if CombinedNameEdit.Text <> CombinedName then begin
894 ProgNameChangeOccuring := true;
895 NameParts(CombinedNameEdit.Text, LName, FName, MName);
896 LNameEdit.Text := LName;
897 FNameEdit.Text := FName;
898 MNameEdit.Text := MName;
899 ProgNameChangeOccuring := false;
900 end;
901 end;
902end;
903
904procedure TfrmPtDemoEdit.LNameEditChange(Sender: TObject);
905begin
906 if ProgNameChangeOccuring = false then begin
907 FCurPatientInfo.LName := LNameEdit.Text;
908 SetModified(true);
909 CombinedNameEdit.Text := CombinedName;
910 end;
911end;
912
913procedure TfrmPtDemoEdit.FNameEditChange(Sender: TObject);
914begin
915 if ProgNameChangeOccuring = false then begin
916 FCurPatientInfo.FName := FNameEdit.Text;
917 SetModified(true);
918 CombinedNameEdit.Text := CombinedName;
919 end
920end;
921
922procedure TfrmPtDemoEdit.MNameEditChange(Sender: TObject);
923begin
924 if ProgNameChangeOccuring = false then begin
925 FCurPatientInfo.MName := MNameEdit.Text;
926 SetModified(true);
927 CombinedNameEdit.Text := CombinedName;
928 end;
929end;
930
931procedure TfrmPtDemoEdit.PrefixEditChange(Sender: TObject);
932begin
933 if ProgNameChangeOccuring = false then begin
934 FCurPatientInfo.Prefix := PrefixEdit.Text;
935 SetModified(true);
936 end;
937end;
938
939procedure TfrmPtDemoEdit.SuffixEditChange(Sender: TObject);
940begin
941 if ProgNameChangeOccuring = false then begin
942 FCurPatientInfo.Suffix := SuffixEdit.Text;
943 SetModified(true);
944 CombinedNameEdit.Text := CombinedName;
945 end;
946end;
947
948procedure TfrmPtDemoEdit.DOBEditChange(Sender: TObject);
949begin
950 if ProgNameChangeOccuring = false then begin
951 FCurPatientInfo.DOB := DOBEdit.Text;
952 SetModified(true);
953 end;
954end;
955
956procedure TfrmPtDemoEdit.SSNumEditChange(Sender: TObject);
957begin
958 if ProgNameChangeOccuring = false then begin
959 FCurPatientInfo.SSNum := SSNumEdit.Text;
960 SetModified(true);
961 end;
962end;
963
964procedure TfrmPtDemoEdit.SexComboBoxChange(Sender: TObject);
965begin
966 if ProgNameChangeOccuring = false then begin
967 FCurPatientInfo.Sex := SexComboBox.Text;
968 SetModified(true);
969 end;
970end;
971
972procedure TfrmPtDemoEdit.DegreeEditChange(Sender: TObject);
973begin
974 if ProgNameChangeOccuring = false then begin
975 FCurPatientInfo.Degree := DegreeEdit.Text;
976 SetModified(true);
977 end;
978end;
979
980procedure TfrmPtDemoEdit.AddressLine1EditChange(Sender: TObject);
981begin
982 if ProgAddressChangeOccuring = false then SetModified(true);
983 Case AddressRGrp.ItemIndex of
984 0 : FCurPatientInfo.AddressLine1 := AddressLine1Edit.Text;
985 1 : FCurPatientInfo.TempAddressLine1 := AddressLine1Edit.Text;
986 2 : FCurPatientInfo.ConfidentalAddressLine1 := AddressLine1Edit.Text;
987 end; {case}
988end;
989
990procedure TfrmPtDemoEdit.AddressLine2EditChange(Sender: TObject);
991begin
992 if ProgAddressChangeOccuring = false then SetModified(true);
993 Case AddressRGrp.ItemIndex of
994 0 : FCurPatientInfo.AddressLine2 := AddressLine2Edit.Text;
995 1 : FCurPatientInfo.TempAddressLine2 := AddressLine2Edit.Text;
996 2 : FCurPatientInfo.ConfidentalAddressLine2 := AddressLine2Edit.Text;
997 end; {case}
998end;
999
1000procedure TfrmPtDemoEdit.AddressLine3EditChange(Sender: TObject);
1001begin
1002 if ProgAddressChangeOccuring = false then SetModified(true);
1003 Case AddressRGrp.ItemIndex of
1004 0 : FCurPatientInfo.AddressLine3 := AddressLine3Edit.Text;
1005 1 : FCurPatientInfo.TempAddressLine3 := AddressLine3Edit.Text;
1006 2 : FCurPatientInfo.ConfidentalAddressLine3 := AddressLine3Edit.Text;
1007 end; {case}
1008end;
1009
1010procedure TfrmPtDemoEdit.CityEditChange(Sender: TObject);
1011begin
1012 if ProgAddressChangeOccuring = false then SetModified(true);
1013 Case AddressRGrp.ItemIndex of
1014 0 : FCurPatientInfo.City := CityEdit.Text;
1015 1 : FCurPatientInfo.TempCity := CityEdit.Text;
1016 2 : FCurPatientInfo.ConfidentalCity := CityEdit.Text;
1017 end; {case}
1018end;
1019
1020procedure TfrmPtDemoEdit.Zip4EditChange(Sender: TObject);
1021begin
1022 if ProgAddressChangeOccuring = false then SetModified(true);
1023 Case AddressRGrp.ItemIndex of
1024 0 : FCurPatientInfo.Zip4 := Zip4Edit.Text;
1025 1 : FCurPatientInfo.TempZip4 := Zip4Edit.Text;
1026 2 : FCurPatientInfo.ConfidentalZip4 := Zip4Edit.Text;
1027 end; {case}
1028end;
1029
1030procedure TfrmPtDemoEdit.StateComboBoxChange(Sender: TObject);
1031begin
1032 if ProgAddressChangeOccuring = false then SetModified(true);
1033 Case AddressRGrp.ItemIndex of
1034 0 : FCurPatientInfo.State := StateComboBox.Text;
1035 1 : FCurPatientInfo.TempState := StateComboBox.Text;
1036 2 : FCurPatientInfo.ConfidentalState := StateComboBox.Text;
1037 end; {case}
1038end;
1039
1040procedure TfrmPtDemoEdit.TempActiveCBClick(Sender: TObject);
1041begin
1042 FCurPatientInfo.TempAddressActive := BoolUC(TempActiveCB.Checked);
1043 if ProgAddressChangeOccuring = false then SetModified(true);
1044end;
1045
1046procedure TfrmPtDemoEdit.ConfActiveCBClick(Sender: TObject);
1047begin
1048 FCurPatientInfo.ConfAddressActive := BoolUC(ConfActiveCB.Checked);
1049 if ProgAddressChangeOccuring = false then SetModified(true);
1050end;
1051
1052procedure TfrmPtDemoEdit.BadAddressCBClick(Sender: TObject);
1053begin
1054 FCurPatientInfo.BadAddress := BoolUC(BadAddressCB.Checked);
1055 if ProgAddressChangeOccuring = false then SetModified(true);
1056end;
1057
1058procedure TfrmPtDemoEdit.PhoneNumEditChange(Sender: TObject);
1059begin
1060 if ProgPhoneChangeOccuring = false then SetModified(true);
1061 Case PhoneNumGrp.ItemIndex of
1062 0 : FCurPatientInfo.PhoneNumResidence := PhoneNumEdit.Text;
1063 1 : FCurPatientInfo.PhoneNumWork := PhoneNumEdit.Text;
1064 2 : FCurPatientInfo.PhoneNumCell := PhoneNumEdit.Text;
1065 3 : FCurPatientInfo.PhoneNumTemp := PhoneNumEdit.Text;
1066 end; {case}
1067
1068end;
1069
1070procedure TfrmPtDemoEdit.StartingDateEditChange(Sender: TObject);
1071begin
1072 if ProgAddressChangeOccuring = false then SetModified(true);
1073 Case AddressRGrp.ItemIndex of
1074 1 : FCurPatientInfo.TempStartingDate := StartingDateEdit.Text;
1075 2 : FCurPatientInfo.ConfidentalStartingDate := StartingDateEdit.Text;
1076 end; {case}
1077end;
1078
1079procedure TfrmPtDemoEdit.EndingDateEditChange(Sender: TObject);
1080begin
1081 if ProgAddressChangeOccuring = false then SetModified(true);
1082 Case AddressRGrp.ItemIndex of
1083 1 : FCurPatientInfo.TempEndingDate := EndingDateEdit.Text;
1084 2 : FCurPatientInfo.ConfidentalEndingDate := EndingDateEdit.Text;
1085 end; {case}
1086end;
1087
1088procedure TfrmPtDemoEdit.AliasNameEditChange(Sender: TObject);
1089var i : integer;
1090 pAlias : tAlias;
1091 tempB : boolean;
1092begin
1093 if ProgAliasChangeOccuring=false then begin
1094 i := AliasComboBox.ItemIndex;
1095 if i > -1 then begin
1096 pAlias := tAlias(AliasComboBox.Items.Objects[i]);
1097 if pAlias<>nil then begin
1098 pAlias.Name := AliasNameEdit.Text;
1099 AliasComboBox.Items.Strings[i]:= AliasNameEdit.Text;
1100 AliasComboBox.Text := AliasNameEdit.Text;
1101 tempB := ProgAliasChangeOccuring;
1102 ProgAliasChangeOccuring:=true;
1103 AliasComboBox.ItemIndex := i;
1104 ProgAliasChangeOccuring:=tempB;
1105 SetModified(true);
1106 end;
1107 end;
1108 end;
1109end;
1110
1111
1112procedure TfrmPtDemoEdit.AliasSSNEditChange(Sender: TObject);
1113var i : integer;
1114 pAlias : tAlias;
1115begin
1116 if ProgAliasChangeOccuring=false then begin
1117 i := AliasComboBox.ItemIndex;
1118 if i > -1 then begin
1119 pAlias := tAlias(AliasComboBox.Items.Objects[i]);
1120 if pAlias<>nil then begin
1121 pAlias.SSN := AliasSSNEdit.Text;
1122 SetModified(true);
1123 end;
1124 end;
1125 end;
1126end;
1127
1128procedure TfrmPtDemoEdit.SetAliasEnabled(value : boolean);
1129begin
1130 AliasNameEdit.Enabled := value;
1131 AliasSSNEdit.Enabled := value;
1132 if value=true then begin
1133 AliasNameEdit.Color := clWindow;
1134 AliasSSNEdit.Color := clWindow;
1135 end else begin
1136 AliasNameEdit.Color := clInactiveBorder;
1137 AliasSSNEdit.Color := clInactiveBorder;
1138 end;
1139end;
1140
1141
1142function TfrmPtDemoEdit.CombinedName : string;
1143begin
1144 Result := '';
1145 Result := FNameEdit.Text;
1146 if MNameEdit.Text <> '' then Result := Result + ' ' + MNameEdit.Text;
1147 if SuffixEdit.Text <> '' then Result := Result + ' ' + SuffixEdit.Text;
1148 if Result <> '' then Result := ',' + Result;
1149 Result := LNameEdit.Text + Result;
1150end;
1151
1152procedure TfrmPtDemoEdit.NameParts(CombinedName: string; var LName, FName, MName : string);
1153var tempS : string;
1154begin
1155 LName := piece(CombinedName,',',1);
1156 tempS := piece(CombinedName,',',2);
1157 FName := piece(tempS,' ',1);
1158 MName := piece(tempS,' ',2,16);
1159end;
1160
1161
1162procedure TfrmPtDemoEdit.ApplyBtnClick(Sender: TObject);
1163var TempPatientInfo : tPatientInfo;
1164begin
1165 TempPatientInfo := tPatientInfo.Create;
1166 TempPatientInfo.Assign(FCurPatientInfo);
1167 TempPatientInfo.RemoveUnchanged(FServerPatientInfo);
1168 PostChangedInfo(TempPatientInfo);
1169 TempPatientInfo.Destroy;
1170 SetModified(false);
1171end;
1172
1173procedure TfrmPtDemoEdit.SetModified(value : boolean);
1174begin
1175 FCurPatientInfo.Modified := value;
1176 ApplyBtn.Enabled := FCurPatientInfo.Modified;
1177end;
1178
1179procedure TfrmPtDemoEdit.AddAliasBtnClick(Sender: TObject);
1180var pAlias : tAlias;
1181 IEN : string;
1182begin
1183 pAlias := tAlias.Create;
1184 if FCurPatientInfo.AliasInfo.count>0 then begin
1185 IEN := FCurPatientInfo.AliasInfo.Strings[FCurPatientInfo.AliasInfo.count-1];
1186 end else begin
1187 IEN := IntToStr(MaxAliasIEN);
1188 end;
1189 MaxAliasIEN := StrToInt(IEN)+1;
1190 IEN := IntToStr(MaxAliasIEN);
1191 FCurPatientInfo.AliasInfo.AddObject(IEN,pAlias);
1192 SetModified(true);
1193 AliasCombobox.Items.AddObject('<Edit New Alias>',pAlias);
1194 //pAlias.Name := '<Edit New Alias>';
1195 //AliasCombobox.Items.Add(ADD_NEW_ALIAS);
1196 AliasCombobox.ItemIndex := AliasCombobox.Items.Count-1;
1197 SetAliasEnabled(true);
1198 ShowAliasInfo(FCurPatientInfo);
1199end;
1200
1201procedure TfrmPtDemoEdit.OKBtnClick(Sender: TObject);
1202begin
1203 if FCurPatientInfo.Modified = true then begin
1204 case MessageDlg('Apply Changes?',mtConfirmation,mbYesNoCancel,0) of
1205 mrYes : begin
1206 ApplyBtnClick(Sender);
1207 frmPtDemoEdit.ModalResult := mrOK; //closes form
1208 end;
1209 mrNo : begin
1210 if ChangesMade = false then frmPtDemoEdit.ModalResult := mrCancel // closes form, signal no need for refresh
1211 else frmPtDemoEdit.ModalResult := mrOK; // closes form.
1212 end;
1213 mrCancel : frmPtDemoEdit.ModalResult := mrNone; //do nothing
1214 end; {case}
1215 end else begin
1216 if ChangesMade = false then frmPtDemoEdit.ModalResult := mrCancel // closes form, signal no need for refresh
1217 else frmPtDemoEdit.ModalResult := mrOK; // closes form.
1218 end;
1219end;
1220
1221procedure TfrmPtDemoEdit.CancelBtnClick(Sender: TObject);
1222begin
1223 if FCurPatientInfo.Modified = true then begin
1224 case MessageDlg('Cancel Changes?',mtConfirmation,mbYesNoCancel,0) of
1225 mrYes : frmPtDemoEdit.ModalResult := mrCancel; //closes form
1226 mrNo : frmPtDemoEdit.ModalResult := mrNone; //do nothing
1227 mrCancel : frmPtDemoEdit.ModalResult := mrNone; //do nothing
1228 end; {case}
1229 end else begin
1230 frmPtDemoEdit.ModalResult := mrCancel; // closes form.
1231 end;
1232
1233end;
1234
1235
1236
1237end.
Note: See TracBrowser for help on using the repository browser.