source: cprs/trunk/CPRS-Chart/uSignItems.pas@ 745

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

Initial Upload of Official WV CPRS 1.0.26.76

File size: 32.5 KB
Line 
1unit uSignItems;
2
3{.$define debug}
4
5interface
6
7uses
8 SysUtils, Windows, Classes, Graphics, Controls, StdCtrls, CheckLst, ORClasses, ORCtrls,
9 Dialogs, UBAConst, fODBase, UBACore, Forms;
10
11type
12 TSigItemType = (siServiceConnected, siAgentOrange, siIonizingRadiation,
13 siEnvironmentalContaminants, siMST, siHeadNeckCancer, siCombatVeteran);
14
15 TSigItemTagInfo = record
16 SigType: TSigItemType;
17 Index: integer;
18 end;
19
20 TSigItems = class(TComponent)
21 private
22 FBuilding: boolean;
23 FStsCount: integer;
24 FItems: TORStringList;
25 FOldDrawItemEvent: TDrawItemEvent;
26 Fcb: TList;
27 Flb: TCustomListBox;
28 FLastValidX: integer;
29 FValidGap: integer;
30 FDy: integer;
31 FAllCheck: array[TSigItemType] of boolean;
32 FAllCatCheck: boolean;
33 FcbX: array[TSigItemType] of integer;
34 function TagInfo(ASigType: TSigItemType; AIndex: integer): TSigItemTagInfo;
35 //function ItemToTag(Info: TSigItemTagInfo): integer;
36 //function TagToItem(ATag: integer): TSigItemTagInfo;
37 procedure cbClicked(Sender: TObject);
38 procedure cbEnter(Sender: TObject);
39 procedure cbExit(Sender: TObject);
40 procedure lbDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
41 procedure CopyCBValues(FromIndex, ToIndex: integer);
42 function FindCBValues(ATag: integer): TORCheckBox;
43 function GetTempCkBxState(Index: integer; CBValue:TSigItemType): string;
44
45 protected
46 procedure Notification(AComponent: TComponent; Operation: TOperation); override;
47 public
48 constructor Create(AOwner: TComponent); override;
49 destructor Destroy; override;
50 procedure Add(ItemType: Integer; const ID: string; Index: integer);
51 procedure Remove(ItemType: integer; const ID: string);
52 procedure ResetOrders;
53 procedure Clear;
54 function UpdateListBox(lb: TCustomListBox): boolean;
55 procedure EnableSettings(Index: integer; Checked: boolean);
56 function OK2SaveSettings: boolean;
57 procedure SaveSettings;
58 procedure DisplayPlTreatmentFactors;
59 procedure DisplayUnsignedStsFlags(sFlags:string);
60 function GetSigItems : TORStringList; //BAPHII 1.3.1
61 function FindCB(ATag: integer): TORCheckBox; //BAPHII 1.3.1
62 procedure CopyCB(FromIndex, ToIndex: integer); //BAPHII 1.3.1
63 procedure SetSigItems(Sender: TObject; sourceOrderID: string); //BAPHII 1.3.1
64 //procedure SetSigItems(Sender: TObject; itemsList: TStringList; sourceOrderID: string); //BAPHII 1.3.1
65 function ItemToTag(Info: TSigItemTagInfo): integer; //CQ5074
66 function TagToItem(ATag: integer): TSigItemTagInfo; //CQ5074
67 end;
68
69function SigItems: TSigItems;
70function SigItemHeight: integer;
71
72const
73
74 TC_Order_Error = 'All Service Connection and/or Rated Disabilities questions must be answered.';
75
76
77 TX_Order_Error = 'All Service Connection and/or Rated Disabilities questions must be answered, '+#13+
78 'and at least one diagnosis selected for each order that requires a diagnosis.';
79
80 TC_Diagnosis_Error = ' Missing Diagnosis';
81 TX_Diagnosis_Error = ' One or more Orders have not been assigned a Diagnosis';
82 INIT_STR = '';
83
84
85var
86 uSigItems: TSigItems = nil; //BAPHII 1.3.1
87
88implementation
89
90uses
91 ORFn, ORNet, uConst, TRPCB, rOrders, rPCE, fOrdersSign, fReview,UBAGlobals,
92 uCore ;
93
94type
95 ItemStatus = (isNA, isChecked, isUnchecked, isUnknown);
96 SigDescType = (sdShort, sdLong);
97
98const
99 SigItemDesc: array[TSigItemType, SigDescType] of string =
100 { siServiceConnected } (('SC', 'Service Connected Condition'),
101 { siAgentOrange } ('AO', 'Agent Orange Exposure'),
102 { siIonizingRadiation } ('IR', 'Ionizing Radiation Exposure'),
103 { siEnvironmentalContaminants } ('EC', 'Environmental Contaminants'),
104 { siMST } ('MST', 'MST'), //'Military Sexual Trauma'
105 { siHeadNeckCancer } ('HNC', 'Head and/or Neck Cancer'),
106 { siCombatVeteran } ('CV', 'Combat Veteran Related'));
107
108 SigItemDisplayOrder: array[TSigItemType] of TSigItemType =
109 ( siServiceConnected,
110 siCombatVeteran,
111 siAgentOrange,
112 siIonizingRadiation,
113 siEnvironmentalContaminants,
114 siMST,
115 siHeadNeckCancer );
116
117 StsChar: array[ItemStatus] of char =
118 { isNA } ('N',
119 { isChecked } 'C',
120 { isUnchecked } 'U',
121 { isUnknown } '?');
122
123 ColIdx = 30000;
124 AllIdx = 31000;
125 NA_FLAGS = 'NNNNNNN';
126
127var
128 uSingletonFlag: boolean = FALSE;
129 FlagCount: integer;
130 BaseFlags: string;
131 tempCkBx: TORCheckBox;
132 thisOrderID: string;
133 thisChangeItem: TChangeItem;
134
135
136function TSigItems.GetSigItems : TORStringList;
137begin
138 Result := FItems;
139end;
140
141function TSigItems.FindCB(ATag: integer): TORCheckBox;
142var
143 i: integer;
144 wc: TWinControl;
145begin
146 for i := 0 to Fcb.Count-1 do
147 begin
148 wc := TWinControl(Fcb[i]);
149 if(wc is TORCheckBox) and (wc.Tag = ATag) then
150 begin
151 Result := TORCheckBox(wc);
152 exit;
153 end;
154 end;
155 Result := nil;
156end;
157
158procedure TSigItems.CopyCB(FromIndex, ToIndex: integer);
159var
160 si: TSigItemType;
161 FromTag, ToTag: integer;
162 FromCB, ToCB: TORCheckBox;
163
164begin
165 for si := low(TSigItemType) to high(TSigItemType) do
166 begin
167 FromTag := ItemToTag(TagInfo(si, FromIndex));
168 ToTag := ItemToTag(TagInfo(si, ToIndex));
169 FromCB := FindCB(FromTag);
170 ToCB := FindCB(ToTag);
171 if(Assigned(FromCB) and Assigned(ToCB)) then
172 ToCB.State := FromCB.State;
173 end;
174end;
175
176procedure TSigItems.SetSigItems(Sender: TObject; sourceOrderID: string);
177{
178 BAPHII 1.3.1
179}
180var
181 i: integer;
182begin
183 if (Sender as TCaptionCheckListBox).Name = 'clstOrders' then
184 for i := 0 to frmSignOrders.clstOrders.Count - 1 do
185 begin
186 if ((fOrdersSign.frmSignOrders.clstOrders.Selected[i]) and (fOrdersSign.targetOrderID <> fOrdersSign.srcOrderID)) then
187 CopyCB(fOrdersSign.srcIndex, i);
188 end
189 else
190 if (Sender as TCaptionCheckListBox).Name = 'lstReview' then
191 for i := 1 to frmReview.lstReview.Count -1 do
192 begin
193 if ((fReview.frmReview.lstReview.Selected[i]) and (fReview.targetOrderID <> fReview.srcOrderID)) then
194 CopyCB(fReview.srcIndex, i);
195 end;
196end;
197
198function SigItems: TSigItems;
199begin
200 if not assigned(uSigItems) then
201 begin
202 uSingletonFlag := TRUE;
203 try
204 uSigItems := TSigItems.Create(nil);
205 finally
206 uSingletonFlag := FALSE;
207 end;
208 end;
209 Result := uSigItems;
210end;
211
212function SigItemHeight: integer;
213begin
214 Result := MainFontHeight + 2;
215end;
216
217{ TSigItems }
218{
219FItems Layout:
2201 2 3 4 5
221OrderID ^ ListBox Index ^ RPC Call was Made (0 or 1) ^ Settings by char pos ^ Disabled Flag
222}
223
224procedure TSigItems.Add(ItemType: Integer; const ID: string; Index: integer);
225var
226 idx: integer;
227begin
228 if ItemType = CH_ORD then
229 begin
230 idx := FItems.IndexOfPiece(ID);
231 if idx < 0 then
232 idx := FItems.Add(ID);
233 FItems.SetStrPiece(idx, 2, IntToStr(Index));
234 FItems.SetStrPiece(idx,5,INIT_STR); // hds4807 value was being reatained when same order selected in FReview.
235
236 end;
237end;
238
239procedure TSigItems.Clear;
240begin
241 FItems.Clear;
242 Fcb.Clear;
243end;
244
245constructor TSigItems.Create(AOwner: TComponent);
246begin
247 if not uSingletonFlag then
248 raise Exception.Create('Only one instance of TSigItems allowed');
249 inherited Create(AOwner);
250 FItems := TORStringList.Create;
251 Fcb := TList.Create;
252 tempCkBx := TORCheckBox.Create(Owner);
253
254end;
255
256destructor TSigItems.Destroy;
257begin
258 FreeAndNil(FItems);
259 FreeAndNil(Fcb);
260 inherited;
261end;
262
263procedure TSigItems.Remove(ItemType: integer; const ID: string);
264var
265 idx: integer;
266
267begin
268 if ItemType = CH_ORD then
269 begin
270 idx := FItems.IndexOfPiece(ID);
271 if idx >= 0 then
272 FItems.Delete(idx);
273 end;
274end;
275
276procedure TSigItems.ResetOrders; // Resets ListBox positions, to avoid old data messing things up
277var
278 i: integer;
279
280begin
281 for i := 0 to FItems.Count-1 do
282 FItems.SetStrPiece(i, 2, '-1');
283end;
284
285function TSigItems.ItemToTag(Info: TSigItemTagInfo): integer;
286begin
287 if Info.Index < 0 then
288 Result := 0
289 else
290 Result := (Info.Index*FlagCount) + ord(Info.SigType) + 1;
291end;
292
293
294function TSigItems.TagInfo(ASigType: TSigItemType; AIndex: integer): TSigItemTagInfo;
295begin
296 Result.SigType := ASigType;
297 Result.Index := AIndex;
298end;
299
300function TSigItems.TagToItem(ATag: integer): TSigItemTagInfo;
301begin
302 if ATag <= 0 then
303 begin
304 Result.Index := -1;
305 Result.SigType := TSigItemType(0);
306 end
307 else
308 begin
309 dec(ATag);
310 Result.SigType := TSigItemType(ATag mod FlagCount);
311 Result.Index := ATag div FlagCount;
312 end;
313end;
314
315type
316 TExposedListBox = class(TCustomListBox)
317 public
318 property OnDrawItem;
319 end;
320
321function TSigItems.UpdateListBox(lb: TCustomListBox): boolean;
322const
323 cbWidth = 13;
324 cbHeight = 13;
325 btnGap = 2;
326 AllTxt = 'All';
327
328var
329 cb: TORCheckBox;
330 btn: TButton;
331 lbl: TLabel;
332 prnt: TWinControl;
333 ownr: TComponent;
334 FirstValidItem: TSigItemType;
335 x, y, MaxX, i, btnW, btnH, j, dx, ht, idx, dgrp: integer;
336 s, id, Code, cType, Flags: string;
337 StsCode: char;
338 sx, si: TSigItemType;
339 sts, StsIdx: ItemStatus;
340 StsUsed: array[TSigItemType] of boolean;
341 AResponses : TResponses;
342 UFlags: string;
343 thisCB: TORCheckBox;
344 cpFlags: string;
345
346
347 itemText: string;
348 thisTagInfo: TSigItemTagInfo;
349
350 function CreateCB(AParent: TWinControl): TORCheckBox;
351 begin
352 Result := TORCheckBox.Create(ownr);
353 Result.Parent := AParent;
354 Result.Height := cbHeight;
355 Result.Width := cbWidth;
356 Result.GrayedStyle := gsBlueQuestionMark;
357 Result.GrayedToChecked := FALSE;
358 Result.OnClick := cbClicked;
359 Result.OnEnter := cbEnter;
360 Result.OnExit := cbExit;
361 Fcb.Add(Result);
362 end;
363
364begin
365 Result := FALSE;
366 Fcb.Clear;
367 FBuilding := TRUE;
368try
369
370 try
371 idx := 0;
372 RPCBrokerV.ClearParameters := True;
373
374 for i := 0 to FItems.Count-1 do
375 begin
376 s := FItems[i];
377 thisOrderID := Piece(s,U,1);
378 if BILLING_AWARE then
379 if NOT UBACore.IsOrderBillable(thisOrderID) then
380 RemoveOrderFromDxList(thisOrderID);
381 if (piece(s, U, 2) <> '-1') and (piece(s, U, 3) <> '1') then
382 begin
383 with RPCBrokerV do
384 begin
385 if idx = 0 then
386 Param[1].PType := list;
387 inc(idx);
388 Param[1].Mult[IntToStr(idx)] := piece(s, U, 1);
389 end;
390 end;
391 end; //for
392
393 if idx > 0 then
394 begin
395 if BILLING_AWARE then
396 rpcGetSC4Orders // get SC/EIC information for all CIDC TYPE orders
397 else
398 GetCoPay4Orders; // enforces existing NON CIDC CO-PAY rules
399 for i := 0 to RPCBrokerV.Results.Count-1 do
400 begin
401 s := RPCBrokerV.Results[i];
402 {Begin BillingAware}
403 if BILLING_AWARE then
404 begin
405 if (CharAt(piece(s,';',2),1) <> '1') then
406 s := piece(s,U,1);
407 end;
408 id := piece(s,U,1);
409 idx := FItems.IndexOfPiece(id);
410
411 if idx >= 0 then
412 begin
413 FItems.SetStrPiece(idx, 3, '1'); // Mark as read from RPC
414 j := 2;
415 Flags := BaseFlags;
416
417 repeat
418 Code := piece(s,U,j);
419
420 if Code <> '' then
421 begin
422 cType := piece(Code, ';', 1);
423
424 for si := low(TSigItemType) to high(TSigItemType) do
425 begin
426 if cType = SigItemDesc[si, sdShort] then
427 begin
428 cType := piece(Code, ';', 2);
429
430 if cType = '0' then
431 sts := isUnchecked
432 else
433 if cType = '1' then
434 sts := isChecked
435 else
436 sts := isUnknown;
437
438 Flags[ord(si)+1] := StsChar[sts];
439 break;
440
441 end; //if cType = SigItemDesc[si, sdShort]
442 end; //for
443 end; //if Code <> ''
444
445 inc(j);
446 until(Code = '');
447
448 FItems.SetStrPiece(idx, 4, Flags);
449 // new code if deleted order and ba on then
450 // reset appropriate tf flags to "?".
451
452
453 if BILLING_AWARE then
454 begin
455 if not UBACore.OrderRequiresSCEI(Piece(s,U,1)) then
456 FItems.SetStrPiece(idx,4, NA_FLAGS)
457 else
458 begin
459
460 if UBAGlobals.BAUnsignedOrders.Count > 0 then
461 begin
462 UFlags := UBACore.GetUnsignedOrderFlags(Piece(s,U,1),UBAGlobals.BAUnsignedOrders);
463 if UFlags <> '' then FItems.SetStrPiece(idx,4, UFlags)
464 end;
465 //********************************
466 if UBAGlobals.BACopiedOrderFlags.Count > 0 then //BAPHII 1.3.2
467 begin
468 UFlags := UBACore.GetUnsignedOrderFlags(Piece(s,U,1),UBAGlobals.BACopiedOrderFlags); //BAPHII 1.3.2
469 if UFlags <> '' then //BAPHII 1.3.2
470 FItems.SetStrPiece(idx,4,UFlags); //BAPHII 1.3.2
471 end;
472 //********************************
473 if UBAGlobals.BAConsultPLFlags.Count > 0 then
474 begin
475 UFlags := GetConsultFlags(Piece(s,U,1),UBAGlobals.BAConsultPLFlags,Flags);
476
477 if UFlags <> '' then
478 FItems.SetStrPiece(idx,4, UFlags);
479 end;
480
481 UBAGlobals.BAFlagsIN := Flags;
482 end; //else
483 end; //if BILLING_AWARE
484
485 end; //if idx >= 0
486
487 end; //for i := 0 to RPCBrokerV.Results.Count-1
488 end; //if idx > 0
489
490 FStsCount := 0;
491
492 for si := low(TSigItemType) to high(TSigItemType) do
493 StsUsed[si] := FALSE;
494 // loop thru orders selected to be signed fReview/fOrdersSign.
495 for i := 0 to FItems.Count-1 do
496 begin
497 s := FItems[i];
498
499 if (piece(s,u,2) <> '-1') and (piece(s,u,3) = '1') then
500 begin
501 s := piece(s, u, 4); // SC/EI
502 // code added 01/17/2006 - check dc'd nurse orders, originals where requiring CIDC if assigned to patient.
503 if (BILLING_AWARE) and (not UBACore.IsOrderBillable(Piece(s,U,1))) then
504 s := NA_FLAGS;
505
506 for si := low(TSigItemType) to high(TSigItemType) do
507 if (not StsUsed[si]) and (s[ord(si)+1] <> StsChar[isNA]) then
508 begin
509 StsUsed[si] := TRUE;
510 inc(FStsCount);
511 if FStsCount >= FlagCount then break;
512 end;
513 end;
514
515 if FStsCount >= FlagCount then
516 Break;
517 end; //for
518
519 {Begin BillingAware}
520 if BILLING_AWARE then
521 begin
522 if FStsCount = 0 then // Billing Awareness. Force Grid to paint correctly
523 FStsCount := 1;
524 end;
525 {End BillingAware}
526
527 if FStsCount > 0 then
528 begin
529 Result := TRUE;
530 FirstValidItem := TSigItemType(0);
531
532 prnt := lb.Parent;
533 ownr := lb.Owner;
534 MaxX := lb.ClientWidth;
535 lb.Canvas.Font := MainFont;
536 btnW := 0;
537
538 for si := low(TSigItemType) to high(TSigItemType) do
539 begin
540 j := lb.Canvas.TextWidth(SigItemDesc[si, sdShort]);
541 if btnW < j then
542 btnW := j;
543 end;
544
545 inc(btnW, 8);
546 btnH := ResizeHeight( BaseFont, MainFont, 21);
547 x := MaxX;
548 dx := (btnW - cbWidth) div 2;
549
550 for si := high(TSigItemType) downto low(TSigItemType) do
551 begin
552 FcbX[si] := x - btnW + dx;
553 dec(x, btnW + btnGap);
554 end;
555
556 if FStsCount > 1 then
557 begin
558 FAllCatCheck := FALSE;
559 btn := TButton.Create(ownr);
560 btn.Parent := prnt;
561 btn.Height := btnH;
562 btn.Width := btnW;
563 btn.Caption := AllTxt;
564 btn.OnClick := cbClicked;
565 btn.Left := FcbX[TSigItemType(0)] + lb.Left - dx + 2 - (FcbX[TSigItemType(1)] - FcbX[TSigItemType(0)]);
566 btn.Top := lb.Top - btn.height - 2;
567 btn.Tag := AllIdx;
568 btn.ShowHint := TRUE;
569 btn.Hint := 'Set All Related Entries';
570 btn.TabOrder := lb.TabOrder;
571 Fcb.Add(btn);
572 end;
573
574 for sx := low(TSigItemType) to high(TSigItemType) do
575 begin
576 si := SigItemDisplayOrder[sx];
577 FAllCheck[si] := TRUE;
578 btn := TButton.Create(ownr);
579 btn.Parent := prnt;
580 btn.Height := btnH;
581 btn.Width := btnW;
582 btn.Caption := SigItemDesc[si, sdShort];
583 btn.OnClick := cbClicked;
584 btn.Left := FcbX[sx] + lb.Left - dx + 2;
585 btn.Top := lb.Top - btn.height - 2;
586 btn.Tag := ColIdx + ord(si);
587 btn.ShowHint := TRUE;
588 btn.Hint := 'Set all ' + SigItemDesc[si, sdLong];
589 btn.Enabled := StsUsed[si];
590 //tab order before listbox but after previous buttons.
591 btn.TabOrder := lb.TabOrder;
592 Fcb.Add(btn);
593 end;
594
595 FValidGap := ((FcbX[succ(TSigItemType(0))] - FcbX[TSigItemType(0)] - cbWidth) div 2) + 1;
596 FLastValidX := FcbX[FirstValidItem] - FValidGap;
597 lb.ControlStyle := lb.ControlStyle + [csAcceptsControls];
598
599 try
600 ht := SigItemHeight;
601 FDy := ((ht - cbHeight) div 2);
602 y := lb.TopIndex;
603 FOldDrawItemEvent := TExposedListBox(lb).OnDrawItem;
604 Flb := lb;
605 TExposedListBox(lb).OnDrawItem := lbDrawItem;
606 lb.FreeNotification(Self);
607
608 for i := 0 to FItems.Count-1 do
609 begin
610 s := FItems[i];
611
612 if piece(s,u,3) = '1' then
613 begin
614 idx := StrToIntDef(piece(s,U,2),-1);
615
616 if idx >= 0 then
617 begin
618 Flags := piece(s,u,4);
619 //loop thru treatment factors
620 for sx := low(TSigItemType) to high(TSigItemType) do
621 begin
622 si := SigItemDisplayOrder[sx];
623 StsCode := Flags[ord(si)+1];
624 StsIdx := isNA;
625
626 for sts := low(ItemStatus) to high(ItemStatus) do
627 if StsCode = StsChar[sts] then
628 begin
629 StsIdx := sts;
630 Break;
631 end;
632
633 if (StsIdx <> isNA) then
634 begin
635 cb := CreateCB(lb);
636 cb.Left := FcbX[sx];
637 cb.Top := (ht * (idx - y)) + FDy;
638 cb.Tag := ItemToTag(TagInfo(si, idx));
639 cb.ShowHint := TRUE;
640 cb.Hint := SigItemDesc[si, sdLong];
641
642 //CQ3301/3302
643 thisTagInfo := TagToItem(cb.Tag);
644 itemText := '';
645 thisChangeItem := nil; //init
646
647 thisChangeItem := TChangeItem(lb.Items.Objects[thisTagInfo.Index]);
648
649 if (thisChangeItem <> nil) then
650 begin
651 itemText := (FilteredString(lb.Items[thisTagInfo.Index]));
652 cb.Caption := itemText + cb.Hint; //CQ3301/3302 - gives JAWS a caption to read
653 end;
654 //end CQ3301/3302
655
656 //PATCH: Added OR_3_215v26_70 11/07/2007 jb
657 // GWOT - CV Default to Yes.
658 if ( (si = siCombatVeteran) and (StsIdx = isUnKnown) ) then
659 begin
660 StsIdx := isChecked;
661 Flags[7] := 'C'; // HD200866 default as Combat Related - GWOT mandated Change
662 FItems.SetStrPiece(i, 4, Flags); // HD200866 default as Combat Related - GWOT mandated Change
663 end;
664 //End Patch
665
666 case StsIdx of
667 isChecked: cb.State := cbChecked;
668 isUnchecked: cb.State := cbUnchecked;
669 else cb.State := cbGrayed;
670 end; //case
671
672 end; //if (StsIdx <> isNA)
673
674 end; //for sx := low(TSigItemType) to high(TSigItemType)
675
676 end; // if idx >= 0
677
678 end; //if piece(s,u,3) = '1'
679
680 end; //for i := 0 to FItems.Count-1
681
682 finally
683 lb.ControlStyle := lb.ControlStyle - [csAcceptsControls];
684 end; //if FStsCount > 0
685 end;
686
687 finally
688 FBuilding := FALSE;
689 end;
690 except
691 on ERangeError do
692 begin
693 ShowMessage('ERangeError in UpdateListBox' + s);
694 raise;
695 end;
696 end;
697end;
698
699procedure TSigItems.cbClicked(Sender: TObject);
700var
701 i,cnt,p: integer;
702 cb: TORCheckBox;
703 sType: TSigItemType;
704 idx, Flags: string;
705 Info: TSigItemTagInfo;
706 wc, w: TWinControl;
707
708begin
709 if FBuilding then exit;
710 wc := TWinControl(Sender);
711 if wc.Tag = AllIdx then
712 begin
713 FAllCatCheck := not FAllCatCheck;
714 for sType := low(TSigItemType) to high(TSigItemType) do
715 FAllCheck[sType] := FAllCatCheck;
716 cnt := 0;
717 for i := 0 to Fcb.Count-1 do
718 begin
719 w := TWinControl(Fcb[i]);
720 if (w <> wc) and (w.Tag >= ColIdx) and (w is TButton) then
721 begin
722 inc(cnt);
723 if w.Enabled then
724 TButton(w).Click;
725 if cnt >= FlagCount then break;
726 end;
727 end;
728 end
729 else
730 if wc.Tag >= ColIdx then
731 begin
732 sType := TSigItemType(wc.Tag - ColIdx);
733 FAllCheck[sType] := not FAllCheck[sType];
734 for i := 0 to Fcb.Count-1 do
735 begin
736 w := TWinControl(Fcb[i]);
737 if (w.Tag < ColIdx) and (w is TORCheckBox) then
738 begin
739 if TagToItem(w.Tag).SigType = sType then
740 TORCheckBox(w).Checked := FAllCheck[sType];
741 end;
742 end;
743 end
744 else
745 begin
746 cb := TORCheckBox(wc);
747 info := TagToItem(cb.Tag);
748 if info.Index >= 0 then
749 begin
750 idx := inttostr(info.Index);
751 i := FItems.IndexOfPiece(idx,U,2);
752 if i >= 0 then
753 begin
754 p := ord(Info.SigType)+1;
755 Flags := piece(FItems[i],U,4);
756 case cb.State of
757 cbUnchecked: Flags[p] := StsChar[isUnchecked];
758 cbChecked: Flags[p] := StsChar[isChecked];
759 else Flags[p] := StsChar[isUnknown];
760 end;
761 FItems.SetStrPiece(i,4,Flags);
762 if BILLING_AWARE then
763 UBAGlobals.BAFlagsIN := Flags;
764 end;
765 end;
766 end;
767end;
768
769procedure TSigItems.cbEnter(Sender: TObject);
770var
771 cb: TORCheckBox;
772begin
773 cb := TORCheckBox(Sender);
774 cb.Color := clHighlight;
775 cb.Font.Color := clHighlightText;
776
777 // commented out causing check box states to be out of sync when
778 //checked individually and/or when by column or all.
779 //CQ5074
780 if ( (cb.Focused) and (cb.State = cbGrayed) ) and (not IsAMouseButtonDown) then
781 cb.Checked := false;
782 //end CQ5074
783end;
784
785procedure TSigItems.cbExit(Sender: TObject);
786var
787 cb: TORCheckBox;
788begin
789 cb := TORCheckBox(Sender);
790 cb.Color := clWindow;
791 cb.Font.Color := clWindowText;
792end;
793
794
795procedure TSigItems.lbDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
796var
797 OldRect: TRect;
798 i: integer;
799 cb: TORCheckBox;
800 si: TSigItemType;
801 DrawGrid: boolean;
802
803begin
804 DrawGrid := (Index < flb.Items.Count);
805 if DrawGrid and (trim(Flb.Items[Index]) = '') and
806 (Index = (flb.Items.Count - 1)) then
807 DrawGrid := FALSE;
808 if DrawGrid then
809 dec(Rect.Bottom);
810 OldRect := Rect;
811
812 Rect.Right := FlastValidX - 4;
813 {Begin BillingAware}
814 if BILLING_AWARE then Rect.Right := FLastValidX - 55;
815 {End BillingAware}
816
817 if assigned(FOldDrawItemEvent) then
818 FOldDrawItemEvent(Control, Index, Rect, State)
819 else
820 begin
821 Flb.Canvas.FillRect(Rect);
822 if Index < flb.Items.Count then
823 Flb.Canvas.TextRect(Rect, Rect.Left + 2, Rect.Top, FilteredString(Flb.Items[Index]));
824 end;
825
826 if DrawGrid then
827 begin
828 Flb.Canvas.Pen.Color := clBtnFace;
829 Flb.Canvas.MoveTo(Rect.Left, Rect.Bottom);
830 Flb.Canvas.LineTo(OldRect.RIght, Rect.Bottom);
831 end;
832
833 if BILLING_AWARE then OldRect.Left := Rect.Right + 90
834 else OldRect.Left := Rect.Right;
835
836 //// SC Column
837 Flb.Canvas.FillRect(OldRect);
838 for i := 0 to Fcb.Count-1 do
839 begin
840 cb := TORCheckBox(Fcb[i]);
841
842 if TagToItem(cb.Tag).Index = Index then
843 begin
844 cb.Invalidate;
845 cb.Top := Rect.Top + FDy;
846 end;
847 end;
848
849 // EI Columns
850 if DrawGrid then
851 begin
852 for si := low(TSigItemType) to high(TSigItemType) do
853 begin
854 if FcbX[si] > FLastValidX then
855 begin
856 Flb.Canvas.MoveTo(FcbX[si] - FValidGap, Rect.Top);
857 Flb.Canvas.LineTo(FcbX[si] - FValidGap, Rect.Bottom);
858 end;
859 end;
860 end;
861
862end;
863
864procedure TSigItems.Notification(AComponent: TComponent;
865 Operation: TOperation);
866begin
867 inherited;
868 if (AComponent = Flb) and (Operation = opRemove) then
869 begin
870 Fcb.Clear;
871 TExposedListBox(Flb).OnDrawItem := FOldDrawItemEvent;
872 FOldDrawItemEvent := nil;
873 Flb := nil;
874 end;
875end;
876
877procedure TSigItems.EnableSettings(Index: integer; Checked: boolean);
878var
879 cb: TORCheckBox;
880 i: integer;
881 Info: TSigItemTagInfo;
882
883begin
884 if Index < 0 then exit;
885 for i := 0 to Fcb.Count-1 do
886 begin
887 if TObject(Fcb[i]) is TORCheckBox then
888 begin
889 cb := TORCheckBox(Fcb[i]);
890 info := TagToItem(cb.Tag);
891 if info.Index = Index then
892 cb.enabled := Checked;
893 end;
894 end;
895 i := FItems.IndexOfPiece(IntToStr(Index), U, 2);
896 if i >= 0 then
897 FItems.SetStrPiece(i, 5, BoolChar[not Checked]);
898end;
899
900function TSigItems.OK2SaveSettings: boolean;
901var
902 i, Index: integer;
903 s: string;
904
905begin
906 {Begin BillingAware}
907 if BILLING_AWARE then
908 begin
909 if Assigned(UBAGlobals.BAOrderList) then
910 BAOrderList.Clear
911 else
912 begin
913 BAOrderList := TStringList.Create;
914 BAOrderList.Clear;
915 end;
916{End BillingAware}
917 end;
918
919 Result := TRUE;
920 for i := 0 to FItems.Count-1 do
921 begin
922 s := FItems[i];
923 Index := StrToIntDef(piece(s,U,2),-1);
924 if(Index >= 0) and (piece(s,U,5) <> '1') then
925 begin
926 if pos(StsChar[isUnknown], piece(s, U, 4)) > 0 then
927 begin
928 Result := FALSE;
929 break;
930 end{end if}
931 else
932 if BILLING_AWARE then
933 BAOrderList.Add(piece(s,U,1)+ piece(s,U,3) + piece(s,U,4)); //baph1
934 end; {end if}
935 end;{end for}
936end;
937
938procedure TSigItems.SaveSettings;
939var
940 s: string;
941 i, Index: integer;
942 TmpSL: TStringList;
943
944begin
945 TmpSL := TStringList.Create;
946
947 try
948 for i := 0 to FItems.Count-1 do
949 begin
950 s := FItems[i];
951 Index := StrToIntDef(piece(s,U,2),-1);
952 if(Index >= 0) and (piece(s,U,5) <> '1') then
953 begin
954 TmpSL.Add(Piece(s,U,1) + U + piece(s,U,4));
955 FItems.SetStrPiece(i, 6, '1');
956 end;
957 end;
958
959 SaveCoPayStatus(TmpSL);
960
961 finally
962 TmpSL.Free;
963 end;
964 i := 0;
965 while i < FItems.Count do
966 begin
967 if Piece(FItems[i], U, 6) = '1' then
968 FItems.Delete(i)
969 else
970 inc(i);
971 end;
972 Fcb.Clear;
973end;
974
975{ Begin Billing Aware }
976
977procedure TSigItems.DisplayUnsignedStsFlags(sFlags:string);
978var
979 Index: integer;
980 flags : string;
981begin
982 Index := 0;
983 Flags := sFlags;
984 CopyCBValues(Index,Index);
985
986end;
987
988procedure TSigItems.DisplayPlTreatmentFactors;
989var
990 FactorsOut:TStringList;
991 y: integer;
992 Index: integer;
993begin
994 FactorsOut := TStringList.Create;
995 FactorsOut.Clear;
996 FactorsOut := UBAGlobals.PLFactorsIndexes;
997 for y := 0 to FactorsOut.Count-1 do
998 begin
999 Index := StrToInt(Piece(FactorsOut.Strings[y],U,1));
1000 CopyCBValues(Index,Index);
1001 end;
1002end;
1003
1004
1005
1006procedure TSigItems.CopyCBValues(FromIndex, ToIndex: integer);
1007var
1008 si: TSigItemType;
1009 FromTag, ToTag: integer;
1010 FromCB, ToCB: TORCheckBox;
1011 x: string;
1012begin
1013 tempCkBx.GrayedStyle := gsBlueQuestionMark;
1014
1015 for si := low(TSigItemType) to high(TSigItemType) do
1016 begin
1017 FromTag := ItemToTag(TagInfo(si, FromIndex));
1018 ToTag := ItemToTag(TagInfo(si, ToIndex));
1019 FromCB := FindCBValues(FromTag);
1020 ToCB := FindCBValues(ToTag);
1021
1022 if assigned(FromCB) then // and assigned(ToCB)) then
1023 begin
1024 tempCkBx.State := cbGrayed;
1025 x:= GetTempCkBxState(FromIndex,si);
1026 if x = 'C' then tempCkBx.State := cbChecked
1027 else if x = 'U' then tempCkBx.State := cbUnChecked ;
1028 ToCB.State := tempCkBx.State;// FromCB.State;
1029 end;
1030 end; //for
1031
1032end;
1033
1034function TSigItems.FindCBValues(ATag: integer):TORCheckBox;
1035var
1036 i: integer;
1037 wc: TWinControl;
1038begin
1039 for i := 0 to Fcb.Count-1 do
1040 begin
1041 wc := TWinControl(Fcb[i]);
1042 if(wc is TORCheckBox) and (wc.Tag = ATag) then
1043 begin
1044 Result := TORCheckBox(wc);
1045 Exit;
1046 end;
1047 end;
1048 Result := nil;
1049end;
1050
1051function TSigItems.GetTempCkBxState(Index: integer; CBValue:TSIGItemType):string;
1052var
1053 locateIdx,thisIdx,i: integer;
1054 iFactor: integer;
1055 TmpCBStatus : string;
1056begin
1057 try
1058 locateIdx := Index;
1059 iFactor := Ord(CBValue) +1;
1060 for i := 0 to UBAGlobals.BAFlagsOut.count-1 do
1061 begin
1062 thisIdx := StrToInt(Piece(UBAGlobals.BAFlagsOut.Strings[i],U,1));
1063 if thisIdx = locateIdx then
1064 begin
1065 TmpCBStatus := Piece(UBAGlobals.BAFlagsOut.Strings[i],U,2);
1066 TmpCBStatus := Copy(TmpCBStatus,iFactor,1);
1067 Result :=TmpCBStatus;
1068 end;
1069 end;
1070 except
1071 on EAccessViolation do
1072 begin
1073 {$ifdef debug}ShowMessage('EAccessViolation in uSignItems.GetTempCkBxState()');{$endif}
1074 raise;
1075 end;
1076 end;
1077end;
1078 { End Billing Aware }
1079
1080
1081initialization
1082 FlagCount := ord(high(TSigItemType)) - ord(low(TSigItemType)) + 1;
1083 BaseFlags := StringOfChar(StsChar[isNA], FlagCount);
1084 thisChangeItem := TChangeItem.Create; //CQ3301/3302
1085
1086finalization
1087 FreeAndNil(uSigItems);
1088
1089end.
1090
Note: See TracBrowser for help on using the repository browser.