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

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

Added Colorful Tabs, Changable Tab positions, Demographics translation enabled

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