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

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

Initial upload of TMG-CPRS 1.0.26.69

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