Index: cprs/trunk/CPRS-Chart/uSignItems.pas
===================================================================
--- cprs/trunk/CPRS-Chart/uSignItems.pas	(revision 456)
+++ cprs/trunk/CPRS-Chart/uSignItems.pas	(revision 830)
@@ -11,5 +11,5 @@
 type
   TSigItemType = (siServiceConnected, siAgentOrange, siIonizingRadiation,
-                  siEnvironmentalContaminants, siMST, siHeadNeckCancer, siCombatVeteran);
+                  siEnvironmentalContaminants, siMST, siHeadNeckCancer, siCombatVeteran, siSHAD);
 
   TSigItemTagInfo =  record
@@ -33,6 +33,4 @@
     FcbX: array[TSigItemType] of integer;
     function TagInfo(ASigType: TSigItemType; AIndex: integer): TSigItemTagInfo;
-    //function ItemToTag(Info: TSigItemTagInfo): integer;
-    //function TagToItem(ATag: integer): TSigItemTagInfo;
     procedure cbClicked(Sender: TObject);
     procedure cbEnter(Sender: TObject);
@@ -42,5 +40,5 @@
     function  FindCBValues(ATag: integer): TORCheckBox;
     function  GetTempCkBxState(Index: integer; CBValue:TSigItemType): string;
-    
+
   protected
     procedure Notification(AComponent: TComponent; Operation: TOperation); override;
@@ -62,16 +60,18 @@
     procedure CopyCB(FromIndex, ToIndex: integer); //BAPHII 1.3.1
     procedure SetSigItems(Sender: TObject; sourceOrderID: string); //BAPHII 1.3.1
-    //procedure SetSigItems(Sender: TObject; itemsList: TStringList; sourceOrderID: string); //BAPHII 1.3.1
     function ItemToTag(Info: TSigItemTagInfo): integer; //CQ5074
     function TagToItem(ATag: integer): TSigItemTagInfo; //CQ5074
+
   end;
 
 function SigItems: TSigItems;
 function SigItemHeight: integer;
+function  GetAllBtnLeftPos: integer;
 
 const
-
-  TC_Order_Error = 'All Service Connection and/or Rated Disabilities questions must be answered.';
-
+  SIG_ITEM_VERTICAL_PAD = 2;
+
+  TC_Order_Error = 'All Service Connection and/or Rated Disabilities questions must be answered, '+#13+
+                   'and at least one diagnosis selected for each order that requires a diagnosis.';
 
   TX_Order_Error = 'All Service Connection and/or Rated Disabilities questions must be answered, '+#13+
@@ -86,9 +86,10 @@
   uSigItems: TSigItems = nil; //BAPHII 1.3.1
 
+
 implementation
 
 uses
   ORFn, ORNet, uConst, TRPCB, rOrders, rPCE, fOrdersSign, fReview,UBAGlobals,
-  uCore ;
+  uCore , VAUtils;
 
 type
@@ -101,8 +102,9 @@
         { siAgentOrange               }  ('AO',  'Agent Orange Exposure'),
         { siIonizingRadiation         }  ('IR',  'Ionizing Radiation Exposure'),
-        { siEnvironmentalContaminants }  ('EC',  'Environmental Contaminants'),
+        { siEnvironmentalContaminants }  ('SWAC','Southwest Asia Conditions'),
         { siMST                       }  ('MST', 'MST'), //'Military Sexual Trauma'
         { siHeadNeckCancer            }  ('HNC', 'Head and/or Neck Cancer'),
-        { siCombatVeteran             }  ('CV',  'Combat Veteran Related'));
+        { siCombatVeteran             }  ('CV',  'Combat Veteran Related'),
+        { siSHAD                      }  ('SHD', 'Shipboard Hazard and Defense'));
 
   SigItemDisplayOrder: array[TSigItemType] of TSigItemType =
@@ -112,6 +114,7 @@
         siIonizingRadiation,
         siEnvironmentalContaminants,
+        siSHAD,
         siMST,
-        siHeadNeckCancer );
+        siHeadNeckCancer);
 
   StsChar: array[ItemStatus] of char =
@@ -123,5 +126,5 @@
   ColIdx = 30000;
   AllIdx = 31000;
-  NA_FLAGS = 'NNNNNNN';
+  NA_FLAGS = 'NNNNNNNN';
 
 var
@@ -132,4 +135,5 @@
   thisOrderID: string;
   thisChangeItem: TChangeItem;
+  AllBtnLeft: integer;
 
 
@@ -175,7 +179,4 @@
 
 procedure TSigItems.SetSigItems(Sender: TObject; sourceOrderID: string);
-{
- BAPHII 1.3.1
-}
 var
   i: integer;
@@ -212,6 +213,12 @@
 function SigItemHeight: integer;
 begin
-  Result := MainFontHeight + 2;
-end;
+  Result := MainFontHeight + 2 + SIG_ITEM_VERTICAL_PAD;
+end;
+
+function  GetAllBtnLeftPos: integer;
+ begin
+  Result := uSignItems.AllBtnLeft;
+ end;
+
 
 { TSigItems }
@@ -264,5 +271,4 @@
 var
   idx: integer;
-
 begin
   if ItemType = CH_ORD then
@@ -277,5 +283,4 @@
 var
   i: integer;
-
 begin
   for i := 0 to FItems.Count-1 do
@@ -334,5 +339,6 @@
   FirstValidItem: TSigItemType;
   x, y, MaxX, i, btnW, btnH, j, dx, ht, idx, dgrp: integer;
-  s, id, Code, cType, Flags: string;
+  s, id, Code, cType, Flags,OrderStatus,CVFlag,ChangedFlags: string;
+
   StsCode: char;
   sx, si: TSigItemType;
@@ -340,5 +346,5 @@
   StsUsed: array[TSigItemType] of boolean;
   AResponses : TResponses;
-  UFlags: string;
+  UFlags,HoldFlags: string;
   thisCB: TORCheckBox;
   cpFlags: string;
@@ -349,5 +355,5 @@
 
   function CreateCB(AParent: TWinControl): TORCheckBox;
-     begin
+  begin
      Result := TORCheckBox.Create(ownr);
      Result.Parent := AParent;
@@ -359,6 +365,7 @@
      Result.OnEnter := cbEnter;
      Result.OnExit := cbExit;
+     UpdateColorsFor508Compliance(Result);
      Fcb.Add(Result);
-     end;
+  end;
 
 begin
@@ -393,9 +400,6 @@
        if idx > 0 then
           begin
-         if  BILLING_AWARE then
-              rpcGetSC4Orders // get SC/EIC information for all CIDC TYPE orders
-          else
-             GetCoPay4Orders;   // enforces existing NON CIDC CO-PAY rules
-             for i := 0 to RPCBrokerV.Results.Count-1 do
+            rpcGetSC4Orders;
+            for i := 0 to RPCBrokerV.Results.Count-1 do
                begin
                   s := RPCBrokerV.Results[i];
@@ -405,17 +409,16 @@
                   if (CharAt(piece(s,';',2),1) <> '1') then
                     s := piece(s,U,1);
-                end;
-                 id := piece(s,U,1);
-                 idx := FItems.IndexOfPiece(id);
-
-                 if idx >= 0 then
-                    begin
+                end;  {End BillingAware }
+                id := piece(s,U,1);
+                idx := FItems.IndexOfPiece(id);
+
+                if idx >= 0 then
+                begin
                     FItems.SetStrPiece(idx, 3, '1'); // Mark as read from RPC
                     j := 2;
                     Flags := BaseFlags;
-
-                       repeat
+                     repeat
                          Code := piece(s,U,j);
-
+                         if Code = 'EC' then Code := 'SWAC';  // CQ:15431  ; resolve issue of displaying SWAC vs EC.
                          if Code <> '' then
                             begin
@@ -449,5 +452,4 @@
                       // new code  if deleted order and ba on then
                       // reset appropriate tf flags to "?".
-
 
                      if BILLING_AWARE then
@@ -489,4 +491,5 @@
 
     FStsCount := 0;
+    AllBtnLeft := 0;
 
     for si := low(TSigItemType) to high(TSigItemType) do
@@ -500,5 +503,6 @@
             begin
              s := piece(s, u, 4); // SC/EI
-             // code added 01/17/2006 - check dc'd nurse orders, originals where requiring CIDC if assigned to patient.
+            // code added 01/17/2006 - check dc'd nurse orders,
+            // originals where requiring CIDC if assigned to patient.
              if (BILLING_AWARE) and (not UBACore.IsOrderBillable(Piece(s,U,1))) then
                s :=  NA_FLAGS;
@@ -506,9 +510,9 @@
             for si := low(TSigItemType) to high(TSigItemType) do
               if (not StsUsed[si]) and (s[ord(si)+1] <> StsChar[isNA]) then
-                begin
+              begin
                 StsUsed[si] := TRUE;
                 inc(FStsCount);
                 if FStsCount >= FlagCount then break;
-                end;
+              end;
             end;
 
@@ -537,9 +541,9 @@
 
          for si := low(TSigItemType) to high(TSigItemType) do
-            begin
+         begin
             j := lb.Canvas.TextWidth(SigItemDesc[si, sdShort]);
             if btnW < j then
              btnW := j;
-            end;
+         end;
 
          inc(btnW, 8);
@@ -549,11 +553,11 @@
 
          for si := high(TSigItemType) downto low(TSigItemType) do
-            begin
+         begin
             FcbX[si] := x - btnW + dx;
             dec(x, btnW + btnGap);
-            end;
+         end;
          
          if FStsCount > 1 then
-           begin
+         begin
            FAllCatCheck := FALSE;
            btn := TButton.Create(ownr);
@@ -564,4 +568,5 @@
            btn.OnClick := cbClicked;
            btn.Left := FcbX[TSigItemType(0)] + lb.Left - dx + 2 - (FcbX[TSigItemType(1)] - FcbX[TSigItemType(0)]);
+           AllBtnLeft := btn.left;
            btn.Top := lb.Top - btn.height - 2;
            btn.Tag := AllIdx;
@@ -569,9 +574,10 @@
            btn.Hint := 'Set All Related Entries';
            btn.TabOrder := lb.TabOrder;
+           UpdateColorsFor508Compliance(btn);
            Fcb.Add(btn);
-           end;
+         end;
 
          for sx := low(TSigItemType) to high(TSigItemType) do
-            begin
+         begin                                                // print buttons on header of columns ie SC,AO,IR, etc....
             si := SigItemDisplayOrder[sx];
             FAllCheck[si] := TRUE;
@@ -590,6 +596,7 @@
             //tab order before listbox but after previous buttons.
             btn.TabOrder := lb.TabOrder;
+            UpdateColorsFor508Compliance(btn);
             Fcb.Add(btn);
-            end;
+         end;
 
             FValidGap := ((FcbX[succ(TSigItemType(0))] - FcbX[TSigItemType(0)] - cbWidth) div 2) + 1;
@@ -599,5 +606,5 @@
             try
               ht := SigItemHeight;
-              FDy := ((ht - cbHeight) div 2);
+              FDy := ((ht - cbHeight) div 2)+1;
               y := lb.TopIndex;
               FOldDrawItemEvent := TExposedListBox(lb).OnDrawItem;
@@ -608,25 +615,25 @@
               for i := 0 to FItems.Count-1 do
                   begin
-                  s := FItems[i];
-                  
+                    s := FItems[i];
+                    orderStatus := (Piece(s,u,1));
                   if piece(s,u,3) = '1' then
                      begin
-                     idx := StrToIntDef(piece(s,U,2),-1);
+                       idx := StrToIntDef(piece(s,U,2),-1);
 
                      if idx >= 0 then
-                        begin
+                     begin
                         Flags := piece(s,u,4);
-                                                 //loop thru treatment factors
+                          //loop thru treatment factors
                         for sx := low(TSigItemType) to high(TSigItemType) do
                            begin
-                           si := SigItemDisplayOrder[sx];
-                           StsCode := Flags[ord(si)+1];
-                           StsIdx := isNA;
+                             si := SigItemDisplayOrder[sx];
+                             StsCode := Flags[ord(si)+1];
+                             StsIdx := isNA;
 
                            for sts := low(ItemStatus) to high(ItemStatus) do
                               if StsCode = StsChar[sts] then
                                  begin
-                                 StsIdx := sts;
-                                 Break;
+                                   StsIdx := sts;
+                                   Break;
                                  end;
 
@@ -653,15 +660,10 @@
                                      end;
                                  //end CQ3301/3302
-
-                               //PATCH: Added OR_3_215v26_70 11/07/2007 jb
-                                 	// GWOT - CV Default to Yes.
-	                                if ( (si = siCombatVeteran) and (StsIdx = isUnKnown) ) then
-	                                 begin
-                                   		StsIdx := isChecked;
-                                      Flags[7] := 'C';                  // HD200866 default as Combat Related - GWOT mandated Change
-                                      FItems.SetStrPiece(i, 4, Flags);  // HD200866 default as Combat Related - GWOT mandated Change
-                                   end;
-                              //End Patch
-
+                                  if ( (si = siCombatVeteran) and (StsIdx = isUnKnown) ) then
+                                  begin
+                                     StsIdx := isChecked;
+                                     Flags[7] := 'C';                  // HD200866 default as Combat Related - GWOT mandated Change
+                                     FItems.SetStrPiece(i, 4, Flags);  // HD200866 default as Combat Related - GWOT mandated Change
+                                  end;
                                  case StsIdx of
                                    isChecked:   cb.State := cbChecked;
@@ -691,5 +693,5 @@
   on ERangeError do
   begin
-     ShowMessage('ERangeError in UpdateListBox' + s);
+     ShowMsg('ERangeError in UpdateListBox' + s);
   raise;
   end;
@@ -802,62 +804,66 @@
 
 begin
-        DrawGrid := (Index < flb.Items.Count);
-        if DrawGrid and (trim(Flb.Items[Index]) = '') and
-                        (Index = (flb.Items.Count - 1)) then
-          DrawGrid := FALSE;
-        if DrawGrid then
-          dec(Rect.Bottom);
-        OldRect := Rect;
-
-        Rect.Right := FlastValidX - 4;
-      {Begin BillingAware}
-        if  BILLING_AWARE then Rect.Right := FLastValidX - 55;
-      {End BillingAware}
-
-        if assigned(FOldDrawItemEvent) then
-          FOldDrawItemEvent(Control, Index, Rect, State)
-        else
-           begin
-           Flb.Canvas.FillRect(Rect);
-           if Index < flb.Items.Count then
-             Flb.Canvas.TextRect(Rect, Rect.Left + 2, Rect.Top, FilteredString(Flb.Items[Index]));
-           end;
-
-        if DrawGrid then
-           begin
-             Flb.Canvas.Pen.Color := clBtnFace;
-             Flb.Canvas.MoveTo(Rect.Left, Rect.Bottom);
-             Flb.Canvas.LineTo(OldRect.RIght, Rect.Bottom);
-           end;
-
-        if  BILLING_AWARE then OldRect.Left := Rect.Right + 90
-        else OldRect.Left := Rect.Right;
-
-       //// SC Column
-        Flb.Canvas.FillRect(OldRect);
-        for i := 0 to Fcb.Count-1 do
-           begin
-             cb := TORCheckBox(Fcb[i]);
-
-             if TagToItem(cb.Tag).Index = Index then
-                begin
-                  cb.Invalidate;
-                  cb.Top := Rect.Top + FDy;
-                end;
-           end;
-
-        // EI Columns
-        if DrawGrid then
-        begin
-          for si := low(TSigItemType) to high(TSigItemType) do
+  DrawGrid := (Index < flb.Items.Count);
+  if DrawGrid and (trim(Flb.Items[Index]) = '') and
+                  (Index = (flb.Items.Count - 1)) then
+    DrawGrid := FALSE;
+  if DrawGrid then
+    dec(Rect.Bottom);
+  OldRect := Rect;
+
+  Rect.Right := FlastValidX - 4;
+{Begin BillingAware}
+  if  BILLING_AWARE then Rect.Right := FLastValidX - 55;
+{End BillingAware}
+
+  if assigned(FOldDrawItemEvent) then
+  begin
+    inc(Rect.Bottom);
+    FOldDrawItemEvent(Control, Index, Rect, State);
+    dec(Rect.Bottom);
+  end
+  else
+     begin
+     Flb.Canvas.FillRect(Rect);
+     if Index < flb.Items.Count then
+       Flb.Canvas.TextRect(Rect, Rect.Left + 2, Rect.Top, FilteredString(Flb.Items[Index]));
+     end;
+
+  if DrawGrid then
+     begin
+       Flb.Canvas.Pen.Color := Get508CompliantColor(clSilver);
+       Flb.Canvas.MoveTo(Rect.Left, Rect.Bottom);
+       Flb.Canvas.LineTo(OldRect.RIght, Rect.Bottom);
+     end;
+
+  if  BILLING_AWARE then OldRect.Left := Rect.Right + 90
+  else OldRect.Left := Rect.Right;
+
+ //// SC Column
+ ///
+  Flb.Canvas.FillRect(OldRect);
+  for i := 0 to Fcb.Count-1 do
+     begin
+       cb := TORCheckBox(Fcb[i]);
+
+       if TagToItem(cb.Tag).Index = Index then
           begin
-            if FcbX[si] > FLastValidX then
-            begin
-              Flb.Canvas.MoveTo(FcbX[si] - FValidGap, Rect.Top);
-              Flb.Canvas.LineTo(FcbX[si] - FValidGap, Rect.Bottom);
-            end;
+            cb.Invalidate;
+            cb.Top := Rect.Top + FDy;
           end;
-        end; 
-
+     end;
+
+  // EI Columns
+  if DrawGrid then
+  begin
+    for si := low(TSigItemType) to high(TSigItemType) do
+    begin
+      if FcbX[si] > FLastValidX then
+      begin
+        Flb.Canvas.MoveTo(FcbX[si] - FValidGap, Rect.Top);
+        Flb.Canvas.LineTo(FcbX[si] - FValidGap, Rect.Bottom);
+      end;
+    end;
+  end;
 end;
 
@@ -913,5 +919,5 @@
           BAOrderList := TStringList.Create;
           BAOrderList.Clear;
-    end;
+       end;
 {End BillingAware}
   end;
@@ -999,5 +1005,5 @@
         Index := StrToInt(Piece(FactorsOut.Strings[y],U,1));
         CopyCBValues(Index,Index);
-        end;
+     end;
 end;
 
@@ -1029,6 +1035,5 @@
           end;
        end; //for
-
-end;
+  end;
 
 function TSigItems.FindCBValues(ATag: integer):TORCheckBox;
@@ -1071,5 +1076,5 @@
      on EAccessViolation do
         begin
-        {$ifdef debug}ShowMessage('EAccessViolation in uSignItems.GetTempCkBxState()');{$endif}
+        {$ifdef debug}Show508Message('EAccessViolation in uSignItems.GetTempCkBxState()');{$endif}
         raise;
         end;
@@ -1083,4 +1088,5 @@
   BaseFlags := StringOfChar(StsChar[isNA], FlagCount);
   thisChangeItem := TChangeItem.Create; //CQ3301/3302
+  AllBtnLeft := 0;
 
 finalization
