Function

TSigItems.UpdateListBox

Module

uSignItems

Last Modified

7/15/2014 3:26:44 PM

Visibility

Public

Owner

TSigItems

Declaration

function  UpdateListBox(lb: TCustomListBox): boolean;

Calls Hierarchy


TSigItems.UpdateListBox
 ├notRightOne
 ├IsOrderBillable
 │ └PrepOrderID
 ├RemoveOrderFromDxList
 │ └tempDxNodeExists
 ├rpcGetSC4Orders
 ├OrderRequiresSCEI
 ├GetUnsignedOrderFlags
 ├GetConsultFlags
 │ └SetConsultFlags
 ├TSigItems.cbClicked
 │ └TSigItems.TagToItem
 ├SigItemHeight
 ├TSigItems.lbDrawItem
 │ └TSigItems.TagToItem
 ├CreateCB
 │ ├TSigItems.cbClicked...
 │ ├TSigItems.cbEnter
 │ └TSigItems.cbExit
 ├TSigItems.ItemToTag
 ├TSigItems.TagInfo
 └TSigItems.TagToItem

Called-By Hierarchy


                                           TSigItems.UpdateListBox
                                               ExecuteSignOrders┤ 
                                    TfrmOrders.mnuActSignClick┘ │ 
                                            TfrmReview.BuildList┘ 
                                      TfrmReview.BuildFullList┤   
                                               ReviewChanges┘ │   
                           TfrmFrame.AllowContextChangeAll┤   │   
                                TfrmFrame.FormCloseQuery┤ │   │   
                              TfrmFrame.mnuFileNextClick┤ │   │   
                            TfrmFrame.mnuFileOpenClick┤ │ │   │   
                                TfrmFrame.UMInitiate┤ │ │ │   │   
                       TfrmFrame.mnuFileNextClick...┤ │ │ │   │   
                       TfrmFrame.mnuFileRefreshClick┤ │ │ │   │   
                       TfrmOrders.CheckOrderStatus┤ │ │ │ │   │   
                   TfrmOrders.mnuActChgEvntClick┤ │ │ │ │ │   │   
                      TfrmOrders.mnuActHoldClick┤ │ │ │ │ │   │   
                    TfrmOrders.mnuActUnholdClick┤ │ │ │ │ │   │   
                     TfrmOrders.mnuActRenewClick┤ │ │ │ │ │   │   
                    TfrmOrders.mnuActChangeClick┤ │ │ │ │ │   │   
                      TfrmOrders.mnuActCopyClick┘ │ │ │ │ │   │   
                            TfrmMeds.mnuActDCClick┤ │ │ │ │   │   
                           TfrmMeds.CheckMedStatus┘ │ │ │ │   │   
                        TfrmMeds.mnuActHoldClick┤   │ │ │ │   │   
                       TfrmMeds.mnuActRenewClick┤   │ │ │ │   │   
                      TfrmMeds.mnuActUnholdClick┤   │ │ │ │   │   
                      TfrmMeds.mnuActChangeClick┤   │ │ │ │   │   
                        TfrmMeds.mnuActCopyClick┤   │ │ │ │   │   
                      TfrmMeds.mnuActRefillClick┘   │ │ │ │   │   
                                  TfrmFrame.ViewInfo┘ │ │ │   │   
                               TfrmDCSumm.ViewInfo┤   │ │ │   │   
                             TfrmConsults.ViewInfo┤   │ │ │   │   
                     TfrmFrame.pnlRemindersMouseUp┤   │ │ │   │   
                      TfrmFrame.RemindersChanged┘ │   │ │ │   │   
                          TfrmFrame.FormCreate┘   │   │ │ │   │   
                            TfrmFrame.pnlCIRNClick┤   │ │ │   │   
                      TfrmFrame.pnlVistaWebClick┤ │   │ │ │   │   
                           TfrmFrame.FormKeyDown┘ │   │ │ │   │   
                         TfrmFrame.pnlPatientClick┤   │ │ │   │   
                           TfrmFrame.pnlVisitClick┤   │ │ │   │   
                     TfrmFrame.pnlPrimaryCareClick┤   │ │ │   │   
                       TfrmFrame.pnlRemindersClick┤   │ │ │   │   
                        TfrmFrame.pnlPostingsClick┤   │ │ │   │   
                            TfrmFrame.pnlFlagClick┤   │ │ │   │   
                              TfrmFrame.laMHVClick┤   │ │ │   │   
                             TfrmFrame.laVAA2Click┤   │ │ │   │   
                               TfrmOrders.ViewInfo┤   │ │ │   │   
                                 TfrmMeds.ViewInfo┤   │ │ │   │   
                              TfrmSurgery.ViewInfo┤   │ │ │   │   
                                TfrmNotes.ViewInfo┤   │ │ │   │   
                             TfrmProblems.ViewInfo┘   │ │ │   │   
                     TfrmFrame.mnuFileNotifRemoveClick┤ │ │   │   
                             TfrmFrame.NextButtonClick┘ │ │   │   
                           TfrmFrame.SetUpNextButton┘   │ │   │   
                     TfrmFrame.mnuFileOpenClick...┤     │ │   │   
                              TfrmFrame.FormResize┘     │ │   │   
                            TfrmFrame.ChangeFont┘       │ │   │   
                    TfrmFrame.LoadSizesForUser┤         │ │   │   
               TfrmFrame.LoadUserPreferences┘ │         │ │   │   
                      TfrmFrame.UMInitiate┘   │         │ │   │   
                    TfrmFrame.mnuFontSizeClick┘         │ │   │   
                           TfrmFrame.mnuFileOpenClick...┤ │   │   
                           TfrmFrame.ctxContextorPending┤ │   │   
                          TfrmFrame.StartCCOWContextor┘ │ │   │   
                                TfrmFrame.FormCreate┘   │ │   │   
                         TfrmFrame.ctxContextorCommitted┤ │   │   
                       TfrmFrame.StartCCOWContextor...┘ │ │   │   
                  TfrmFrame.mnuFileResumeContextGetClick┤ │   │   
                  TfrmFrame.mnuFileResumeContextSetClick┘ │   │   
                                  TfrmFrame.FormCloseQuery┤   │   
                              TfrmFrame.mnuFileReviewClick┤   │   
                                           UpdateEncounter┘   │   
                         TfrmFrame.mnuFileEncounterClick┤     │   
                                 TfrmFrame.ViewInfo...┤ │     │   
                    TfrmODMedIV.SetValuesFromResponses┤ │     │   
                             TfrmODMedIV.SetupDialog┤ │ │     │   
                   TfrmODMedIV.cboSolutionMouseClick┘ │ │     │   
                       TfrmODMedIV.cboSolutionExit┘   │ │     │   
                  TfrmODMedIV.cboSolutionMouseClick...┤ │     │   
                     TfrmODMedIV.cboAdditiveMouseClick┤ │     │   
                         TfrmODMedIV.cboAdditiveExit┘ │ │     │   
                                TfrmODAuto.SetupDialog┤ │     │   
                                   ActivateOrderDialog┤ │     │   
                           TfrmRemDlg.btnFinishClick┤ │ │     │   
           TfrmConsults.mnuActNewConsultRequestClick┤ │ │     │   
                   TfrmConsults.cmdNewConsultClick┘ │ │ │     │   
                TfrmConsults.mnuActNewProcedureClick┤ │ │     │   
                      TfrmConsults.cmdNewProcClick┘ │ │ │     │   
                                        ChangeOrders┤ │ │     │   
                      TfrmOrders.mnuActChangeClick┤ │ │ │     │   
                        TfrmMeds.mnuActChangeClick┘ │ │ │     │   
                                     ChangeOrdersEvt┤ │ │     │   
                                          CopyOrders┤ │ │     │   
                        TfrmOrders.mnuActCopyClick┤ │ │ │     │   
                          TfrmMeds.mnuActCopyClick┤ │ │ │     │   
                           TfrmODActive.btnOKClick┘ │ │ │     │   
                                      TransferOrders┤ │ │     │   
                        TfrmOrders.mnuActCopyClick┤ │ │ │     │   
                          TfrmMeds.mnuActCopyClick┤ │ │ │     │   
                           TfrmODActive.btnOKClick┘ │ │ │     │   
                            TfrmOrders.lstWriteClick┤ │ │     │   
               TfrmOrders.PlaceOrderForDefaultDialog┤ │ │     │   
                  TfrmOrders.DisplayDefaultDlgList┤ │ │ │     │   
                       TfrmOrders.ResetOrderPage┘ │ │ │ │     │   
               TfrmOrders.btnDelayedOrderClick┘   │ │ │ │     │   
                                 DisplayEvntDialog┤ │ │ │     │   
                             SetDelayEventForMed┘ │ │ │ │     │   
                      TfrmMeds.mnuActCopyClick┘   │ │ │ │     │   
                                 DisplayEvntDialog┤ │ │ │     │   
                                  SetViewForCopy┘ │ │ │ │     │   
                    TfrmOrders.mnuActCopyClick┘   │ │ │ │     │   
                                 DisplayEvntDialog┘ │ │ │     │   
                                ExecuteChangeEvt┘   │ │ │     │   
                 TfrmOrders.mnuActChgEvntClick┘     │ │ │     │   
                             TfrmMeds.mnuActNewClick┤ │ │     │   
                           TfrmOMNavA.ActivateDialog┤ │ │     │   
                         TfrmOMNavA.grdMenuKeyDown┤ │ │ │     │   
                         TfrmOMNavA.grdMenuMouseUp┘ │ │ │     │   
                                TfrmOMSet.DoNextItem┘ │ │     │   
                              TfrmOMSet.InsertList┤   │ │     │   
                               ActivateOrderList┘ │   │ │     │   
                     TfrmRemDlg.btnFinishClick┤   │   │ │     │   
                             ActivateOrderHTML┤   │   │ │     │   
                    TfrmOrders.lstWriteClick┤ │   │   │ │     │   
    TfrmOrders.PlaceOrderForDefaultDialog...┘ │   │   │ │     │   
                              ActivateOrderSet┤   │   │ │     │   
                   TfrmRemDlg.btnFinishClick┤ │   │   │ │     │   
TfrmConsults.mnuActNewConsultRequestClick...┤ │   │   │ │     │   
     TfrmConsults.mnuActNewProcedureClick...┤ │   │   │ │     │   
                    TfrmOrders.lstWriteClick┤ │   │   │ │     │   
    TfrmOrders.PlaceOrderForDefaultDialog...┤ │   │   │ │     │   
                     TfrmMeds.mnuActNewClick┤ │   │   │ │     │   
                TfrmOMNavA.ActivateDialog...┤ │   │   │ │     │   
                     TfrmOMSet.DoNextItem...┘ │   │   │ │     │   
                       TfrmOMNavA.DoSelectList┘   │   │ │     │   
                     TfrmOMNavA.grdMenuKeyUp┤     │   │ │     │   
                   TfrmOMNavA.grdMenuMouseUp┘     │   │ │     │   
                                        SkipToNext┤   │ │     │   
                         TfrmOMSet.DoNextItem...┘ │   │ │     │   
                            TfrmOMSet.UMDelayEvent┘   │ │     │   
                               TfrmOMSet.InsertList...┤ │     │   
                                TfrmODMeds.SetupDialog┤ │     │   
                             TfrmODMeds.btnSelectClick┤ │     │   
                             TfrmODMeds.UMDelayClick┘ │ │     │   
                                    ExecuteRenewOrders┘ │     │   
                         TfrmOrders.mnuActRenewClick┤   │     │   
                           TfrmMeds.mnuActRenewClick┘   │     │   
                                        EncounterPresent┤     │   
                                      ReadyForNewOrder┤ │     │   
                           TfrmRemDlg.btnFinishClick┤ │ │     │   
        TfrmConsults.mnuActNewConsultRequestClick...┤ │ │     │   
             TfrmConsults.mnuActNewProcedureClick...┤ │ │     │   
                                     ChangeOrders...┤ │ │     │   
                                     ChangeOrdersEvt┤ │ │     │   
                                       CopyOrders...┤ │ │     │   
                                   TransferOrders...┤ │ │     │   
                            TfrmOrders.lstWriteClick┤ │ │     │   
                             TfrmMeds.mnuActNewClick┘ │ │     │   
                                     ReadyForNewOrder1┤ │     │   
            TfrmOrders.PlaceOrderForDefaultDialog...┘ │ │     │   
                              TfrmOrders.mnuActDCClick┤ │     │   
                             TfrmOrders.mnuActRelClick┤ │     │   
                            TfrmOrders.mnuActHoldClick┤ │     │   
                          TfrmOrders.mnuActUnholdClick┤ │     │   
                           TfrmOrders.mnuActRenewClick┤ │     │   
                         TfrmOrders.mnuActReleaseClick┤ │     │   
                         TfrmOrders.mnuActOnChartClick┤ │     │   
                            TfrmOrders.mnuActSignClick┤ │     │   
                                TfrmMeds.mnuActDCClick┤ │     │   
                              TfrmMeds.mnuActHoldClick┤ │     │   
                             TfrmMeds.mnuActRenewClick┤ │     │   
                            TfrmMeds.mnuActUnholdClick┤ │     │   
                              TfrmMeds.mnuActCopyClick┤ │     │   
                            TfrmMeds.mnuActRefillClick┘ │     │   
                                     EncounterPresentEDO┤     │   
                                   ReadyForNewOrder...┤ │     │   
                         TfrmOrders.mnuActChgEvntClick┤ │     │   
                          TfrmOrders.mnuActChangeClick┤ │     │   
                            TfrmOrders.mnuActCopyClick┤ │     │   
                       TfrmOrders.btnDelayedOrderClick┤ │     │   
                            TfrmMeds.mnuActChangeClick┤ │     │   
                              TfrmMeds.mnuActCopyClick┘ │     │   
                                             UpdateVisit┤     │   
                                           EditPCEData┤ │     │   
                             TfrmSurgery.cmdPCEClick┤ │ │     │   
                                 UpdateEncounterInfo┘ │ │     │   
                             TfrmNotes.cmdPCEClick┘   │ │     │   
                        TfrmVitals.btnEnterVitalsClick┘ │     │   
                                             UpdateVisit┤     │   
                                        EncounterPresent┘     │   
                         TfrmProblems.lstProbActsClick┘       │   
                     TfrmProblems.wgProbDataDblClick┤         │   
                           TfrmProblems.lstViewClick┘         │   
                   TfrmProblems.HighlightDuplicate┘           │   
                         TfrmProblems.AddProblem┤             │   
              TfrmProblems.lstProbActsClick...┤ │             │   
                 TfrmProblems.lstProbPickClick┤ │             │   
              TfrmProblems.lstProbPickDblClick┤ │             │   
              TfrmProblems.edProbEntKeyPress┘ │ │             │   
                      TfrmProblems.UMPLLexicon┘ │             │   
                   TfrmdlgProb.bbChangeProbClick┘             │   
                                      TfrmReview.BuildSignList┘   
                                            ReviewChanges...┘     

Calls

Name Declaration Comments
TSigItems.cbClicked procedure cbClicked(Sender: TObject); -
CreateCB function CreateCB(AParent: TWinControl): TORCheckBox; -
GetConsultFlags function GetConsultFlags(pOrderID:String; pFlagList:TStringList;FlagsAsIs:string):string; -
GetUnsignedOrderFlags function GetUnsignedOrderFlags(pOrderID: string; pFlagList: TStringList):string; -
IsOrderBillable function IsOrderBillable(pOrderID: string):boolean; -
TSigItems.ItemToTag function ItemToTag(Info: TSigItemTagInfo): integer; -
TSigItems.lbDrawItem procedure lbDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); -
notRightOne function notRightOne(cnter: Integer): Boolean; -
OrderRequiresSCEI function OrderRequiresSCEI(pOrderID :String): boolean; -
RemoveOrderFromDxList procedure RemoveOrderFromDxList(thisOrderID: string); -
rpcGetSC4Orders procedure rpcGetSC4Orders; -
SigItemHeight function SigItemHeight: integer; -
TSigItems.TagInfo function TagInfo(ASigType: TSigItemType; AIndex: integer): TSigItemTagInfo; -
TSigItems.TagToItem function TagToItem(ATag: integer): TSigItemTagInfo; -

Called-By

Name Declaration Comments
TfrmReview.BuildList procedure BuildList(FullList: boolean); -
ExecuteSignOrders {Forward} function ExecuteSignOrders(SelectedList: TList): Boolean; -


Source

360   function TSigItems.UpdateListBox(lb: TCustomListBox): boolean;
361   const
362     cbWidth = 13;
363     cbHeight = 13;
364     btnGap = 2;
365     AllTxt = 'All';
366   
367   var
368     cb: TORCheckBox;
369     btn: TButton;
370     lbl: TLabel;
371     prnt: TWinControl;
372     ownr: TComponent;
373     FirstValidItem: TSigItemType;
374     x, y, MaxX, i, btnW, btnH, j, dx, ht, idx, dgrp: integer;
375     s, id, Code, cType, Flags,OrderStatus,CVFlag,ChangedFlags: string;
376     odie: TlbOnDrawEvent;
377     StsCode: char;
378     sx, si: TSigItemType;
379     sts, StsIdx: ItemStatus;
380     StsUsed: array[TSigItemType] of boolean;
381     AResponses : TResponses;
382     UFlags,HoldFlags: string;
383     thisCB: TORCheckBox;
384     cpFlags: string;
385     
386   
387     itemText: string;
388     thisTagInfo: TSigItemTagInfo;
389   
390     function CreateCB(AParent: TWinControl): TORCheckBox;
391     begin
392        Result := TORCheckBox.Create(ownr);
393        Result.Parent := AParent;
394        Result.Height := cbHeight;
395        Result.Width := cbWidth;
396        Result.GrayedStyle := gsBlueQuestionMark;
397        Result.GrayedToChecked := FALSE;
398        Result.OnClick := cbClicked;
399        Result.OnEnter := cbEnter;
400        Result.OnExit := cbExit;
401        UpdateColorsFor508Compliance(Result);
402        Fcb.Add(Result);
403     end;
404   
405     function notRightOne(cnter: Integer): Boolean;
406     var
407       id,idx: string;
408       ix: Integer;
409     begin
410       Result := TRUE;
411       id := piece(FItems[cnter],'^',1);
412       for ix := 0 to lb.Items.Count - 1 do
413         begin
414           if lb.Items.Objects[ix] is TOrder then
415           begin
416             idx := TOrder(lb.Items.Objects[ix]).ID;
417             if id = idx then Result := FALSE;
418           end;
419           if lb.Items.Objects[ix] is TChangeItem then
420           begin
421             idx := TChangeItem(lb.Items.Objects[ix]).ID;
422             if id = idx then Result := FALSE;
423             
424           end;
425         end;
426     end;
427   
428   begin
429     Result := FALSE;
430   //  Fcb.Clear;
431     FBuilding := TRUE;
432   try
433   
434     try
435       idx := 0;
436       RPCBrokerV.ClearParameters := True;
437   
438       for i := 0 to FItems.Count-1 do
439       begin
440          if notRightOne(i) then continue;
441          
442          s := FItems[i];
443          thisOrderID := Piece(s,U,1);
444          if BILLING_AWARE then
445            if NOT UBACore.IsOrderBillable(thisOrderID) then
446                RemoveOrderFromDxList(thisOrderID);
447          if (piece(s, U, 2) <> '-1') and (piece(s, U, 3) <> '1') then
448          begin
449             with RPCBrokerV do
450                 begin
451                 if idx = 0 then
452                   Param[1].PType := list;
453                 inc(idx);
454                 Param[1].Mult[IntToStr(idx)] := piece(s, U, 1);
455                 end;
456             end;
457          end; //for
458   
459          if idx > 0 then
460             begin
461               rpcGetSC4Orders;
462               for i := 0 to RPCBrokerV.Results.Count-1 do
463                  begin
464                     s := RPCBrokerV.Results[i];
465                   {Begin BillingAware}
466                   if  BILLING_AWARE then
467                   begin
468                     if (CharAt(piece(s,';',2),1) <> '1') then
469                       s := piece(s,U,1);
470                   end;  {End BillingAware }
471                   id := piece(s,U,1);
472                   idx := FItems.IndexOfPiece(id);
473   
474                   if idx >= 0 then
475                   begin
476                       FItems.SetStrPiece(idx, 3, '1'); // Mark as read from RPC
477                       j := 2;
478                       Flags := BaseFlags;
479                        repeat
480                            Code := piece(s,U,j);
481                            if Code = 'EC' then Code := 'SWAC';  // CQ:15431  ; resolve issue of displaying SWAC vs EC.
482                            if Code <> '' then
483                               begin
484                               cType := piece(Code, ';', 1);
485   
486                               for si := low(TSigItemType) to high(TSigItemType) do
487                                  begin
488                                    if cType = SigItemDesc[si, sdShort] then
489                                       begin
490                                       cType := piece(Code, ';', 2);
491   
492                                       if cType = '0' then
493                                         sts := isUnchecked
494                                       else
495                                          if cType = '1' then
496                                            sts := isChecked
497                                          else
498                                            sts := isUnknown;
499   
500                                       Flags[ord(si)+1] := StsChar[sts];
501                                       break;
502   
503                                       end; //if cType = SigItemDesc[si, sdShort]
504                                    end; //for
505                               end; //if Code <> ''
506   
507                              inc(j);
508                          until(Code = '');
509   
510                        FItems.SetStrPiece(idx, 4, Flags);
511                         // new code  if deleted order and ba on then
512                         // reset appropriate tf flags to "?".
513   
514                        if BILLING_AWARE then
515                           begin
516                              if not UBACore.OrderRequiresSCEI(Piece(s,U,1)) then
517                                 FItems.SetStrPiece(idx,4, NA_FLAGS)
518                              else
519                                 begin
520   
521                                 if UBAGlobals.BAUnsignedOrders.Count > 0 then
522                                    begin
523                                    UFlags := UBACore.GetUnsignedOrderFlags(Piece(s,U,1),UBAGlobals.BAUnsignedOrders);
524                                    if UFlags <> '' then FItems.SetStrPiece(idx,4, UFlags)
525                                    end;
526                                 //********************************
527                                 if UBAGlobals.BACopiedOrderFlags.Count > 0 then  //BAPHII 1.3.2
528                                    begin
529                                    UFlags := UBACore.GetUnsignedOrderFlags(Piece(s,U,1),UBAGlobals.BACopiedOrderFlags); //BAPHII 1.3.2
530                                    if UFlags <> '' then //BAPHII 1.3.2
531                                       FItems.SetStrPiece(idx,4,UFlags); //BAPHII 1.3.2
532                                    end;
533                                 //********************************
534                                 if UBAGlobals.BAConsultPLFlags.Count > 0 then
535                                    begin
536                                       UFlags :=  GetConsultFlags(Piece(s,U,1),UBAGlobals.BAConsultPLFlags,Flags);
537   
538                                    if UFlags <> '' then
539                                       FItems.SetStrPiece(idx,4, UFlags);
540                                    end;
541   
542                                    UBAGlobals.BAFlagsIN := Flags;
543                                 end; //else
544                              end; //if BILLING_AWARE
545   
546                          end; //if idx >= 0
547   
548                     end; //for i := 0 to RPCBrokerV.Results.Count-1
549                end; //if idx > 0
550   
551       FStsCount := 0;
552       AllBtnLeft := 0;
553   
554       for si := low(TSigItemType) to high(TSigItemType) do
555         StsUsed[si] := FALSE;
556       //  loop thru orders selected to be signed fReview/fOrdersSign.
557       for i := 0 to FItems.Count-1 do
558          begin                     
559            if notRightOne(i) then continue;
560            s := FItems[i];
561   
562            if (piece(s,u,2) <> '-1') and (piece(s,u,3) = '1') then
563               begin
564                s := piece(s, u, 4); // SC/EI
565               // code added 01/17/2006 - check dc'd nurse orders,
566               // originals where requiring CIDC if assigned to patient.
567                if (BILLING_AWARE) and (not UBACore.IsOrderBillable(Piece(s,U,1))) then
568                  s :=  NA_FLAGS;
569   
570               for si := low(TSigItemType) to high(TSigItemType) do
571                 if (not StsUsed[si]) and (s[ord(si)+1] <> StsChar[isNA]) then
572                 begin
573                   StsUsed[si] := TRUE;
574                   inc(FStsCount);
575                   if FStsCount >= FlagCount then break;
576                 end;
577               end;
578   
579            if FStsCount >= FlagCount then
580              Break;
581          end; //for
582   
583      {Begin BillingAware}
584        if  BILLING_AWARE then
585            begin
586               if FStsCount = 0 then //  Billing Awareness.  Force Grid to paint correctly
587                  FStsCount := 1;
588            end;
589      {End BillingAware}
590   
591       if FStsCount > 0 then
592          begin
593            Result := TRUE;
594            FirstValidItem := TSigItemType(0);
595   
596            prnt := lb.Parent;
597            ownr := lb.Owner;
598            MaxX := lb.ClientWidth;
599            lb.Canvas.Font := BaseFont;
600            btnW := 0;
601   
602            for si := low(TSigItemType) to high(TSigItemType) do
603            begin
604               j := lb.Canvas.TextWidth(SigItemDesc[si, sdShort]);
605               if btnW < j then
606                btnW := j;
607            end;
608   
609            inc(btnW, 8);
610            btnH := ResizeHeight( BaseFont, BaseFont, 21);
611            x := MaxX;
612            dx := (btnW - cbWidth) div 2;
613   
614            for si := high(TSigItemType) downto low(TSigItemType) do
615            begin
616               FcbX[si] := x - btnW + dx;
617               dec(x, btnW + btnGap);
618            end;
619            
620            if FStsCount > 1 then
621            begin
622              FAllCatCheck := FALSE;
623              btn := TButton.Create(ownr);
624              btn.Parent := prnt;
625              btn.Height := btnH;
626              btn.Width := btnW;
627              btn.Caption := AllTxt;
628              btn.OnClick := cbClicked;
629              btn.Left := FcbX[TSigItemType(0)] + lb.Left - dx + 2 - (FcbX[TSigItemType(1)] - FcbX[TSigItemType(0)]);
630              AllBtnLeft := btn.left;
631              btn.Top := lb.Top - btn.height - 2;
632              btn.Tag := AllIdx;
633              btn.ShowHint := TRUE;
634              btn.Hint := 'Set All Related Entries';
635              btn.TabOrder := lb.TabOrder;
636              UpdateColorsFor508Compliance(btn);
637              Fcb.Add(btn);
638            end;
639   
640            for sx := low(TSigItemType) to high(TSigItemType) do
641            begin                                                // print buttons on header of columns ie SC,AO,IR, etc....
642               si := SigItemDisplayOrder[sx];
643               FAllCheck[si] := TRUE;
644               btn := TButton.Create(ownr);
645               btn.Parent := prnt;
646               btn.Height := btnH;
647               btn.Width := btnW;
648               btn.Caption := SigItemDesc[si, sdShort];
649               btn.OnClick := cbClicked;
650               btn.Left := FcbX[sx] + lb.Left - dx + 2;
651               btn.Top := lb.Top - btn.height - 2;
652               btn.Tag := ColIdx + ord(si);
653               btn.ShowHint := TRUE;
654               btn.Hint := 'Set all ' + SigItemDesc[si, sdLong];
655               btn.Enabled := StsUsed[si];
656               //tab order before listbox but after previous buttons.
657               btn.TabOrder := lb.TabOrder;
658               UpdateColorsFor508Compliance(btn);
659               Fcb.Add(btn);
660            end;
661   
662               FValidGap := ((FcbX[succ(TSigItemType(0))] - FcbX[TSigItemType(0)] - cbWidth) div 2) + 1;
663               FLastValidX := FcbX[FirstValidItem] - FValidGap;
664               lb.ControlStyle := lb.ControlStyle + [csAcceptsControls];
665               
666               try
667                 ht := SigItemHeight;
668                 FDy := ((ht - cbHeight) div 2)+1;
669                 y := lb.TopIndex;
670                 FOldDrawItemEvent := TExposedListBox(lb).OnDrawItem;
671                 odie.xcontrol := lb;
672                 odie.xevent := FOldDrawItemEvent;
673                 SetLength(FOldDrawItemEvents,Length(FOldDrawItemEvents)+1);
674                 FOldDrawItemEvents[Length(FOldDrawItemEvents)-1] := odie;
675                 Flb := lb;
676                 TExposedListBox(lb).OnDrawItem := lbDrawItem;
677                 lb.FreeNotification(Self);
678   
679                 for i := 0 to FItems.Count-1 do
680                     begin
681                       if notRightOne(i) then continue;
682                       s := FItems[i];
683                       orderStatus := (Piece(s,u,1));
684                     if piece(s,u,3) = '1' then
685                        begin
686                          idx := StrToIntDef(piece(s,U,2),-1);
687   
688                        if idx >= 0 then
689                        begin
690                           Flags := piece(s,u,4);
691                             //loop thru treatment factors
692                           for sx := low(TSigItemType) to high(TSigItemType) do
693                              begin
694                                si := SigItemDisplayOrder[sx];
695                                StsCode := Flags[ord(si)+1];
696                                StsIdx := isNA;
697   
698                              for sts := low(ItemStatus) to high(ItemStatus) do
699                                 if StsCode = StsChar[sts] then
700                                    begin
701                                      StsIdx := sts;
702                                      Break;
703                                    end;
704   
705                                if (StsIdx <> isNA) then
706                                  begin
707                                    cb := CreateCB(lb);
708                                    cb.Left := FcbX[sx];
709                                    cb.Top := (ht * (idx - y)) + FDy;
710                                    cb.Tag := ItemToTag(TagInfo(si, idx));
711                                    cb.ShowHint := TRUE;
712                                    cb.Hint := SigItemDesc[si, sdLong];
713   
714                                    //CQ3301/3302
715                                    thisTagInfo := TagToItem(cb.Tag);
716                                    itemText := '';
717                                    thisChangeItem := nil; //init
718   
719                                    thisChangeItem := TChangeItem(lb.Items.Objects[thisTagInfo.Index]);
720   
721                                    if (thisChangeItem <> nil) then
722                                        begin
723                                           itemText := (FilteredString(lb.Items[thisTagInfo.Index]));
724                                           cb.Caption := itemText + cb.Hint;  //CQ3301/3302 - gives JAWS a caption to read
725                                        end;
726                                    //end CQ3301/3302
727                                     if ( (si = siCombatVeteran) and (StsIdx = isUnKnown) ) then
728                                     begin
729                                        StsIdx := isChecked;
730                                        Flags[7] := 'C';                  // HD200866 default as Combat Related - GWOT mandated Change
731                                        FItems.SetStrPiece(i, 4, Flags);  // HD200866 default as Combat Related - GWOT mandated Change
732                                     end;
733                                    case StsIdx of
734                                      isChecked:   cb.State := cbChecked;
735                                      isUnchecked: cb.State := cbUnchecked;
736                                    else cb.State := cbGrayed;
737                                    end; //case
738   
739                                  end; //if (StsIdx <> isNA)
740   
741                           end; //for sx := low(TSigItemType) to high(TSigItemType)
742   
743                        end; // if idx >= 0
744   
745                        end; //if piece(s,u,3) = '1'
746   
747                 end; //for i := 0 to FItems.Count-1
748   
749            finally
750              lb.ControlStyle := lb.ControlStyle - [csAcceptsControls];
751            end; //if FStsCount > 0
752       end;
753   
754     finally
755       FBuilding := FALSE;
756     end;
757     except
758     on ERangeError do
759     begin
760        ShowMsg('ERangeError in UpdateListBox' + s);
761     raise;
762     end;
763     end;
764   end;