Index: cprs/branches/HealthSevak-CPRS/CPRS-Chart/fProbs.pas
===================================================================
--- cprs/branches/HealthSevak-CPRS/CPRS-Chart/fProbs.pas	(revision 1676)
+++ cprs/branches/HealthSevak-CPRS/CPRS-Chart/fProbs.pas	(revision 1693)
@@ -7,5 +7,5 @@
   fHSplit, StdCtrls, ExtCtrls, Menus, ORCtrls, Buttons, uProbs,
   Grids, Vawrgrid, ORfn, uCore, fProbEdt, uConst, ComCtrls,
-  VA508AccessibilityManager, fBase508Form;
+  VA508AccessibilityManager, VAUtils, fBase508Form;
 
 type
@@ -188,9 +188,10 @@
   TX_INVALID_PATIENT = 'Problem list is unavailable:  Patient DFN is undefined.';
   TC_NO_PATIENT      = 'No patient is selected';
-  TX_INACTIVE_CODE_V = 'references an inactive ICD code, and must be updated'  + #13#10 +
+  TX_INACTIVE_CODE_V = 'references an inactive ICD-9-CM code, and must be updated'  + #13#10 +
                        'using the ''Change'' option before it can be verified.';
   TC_INACTIVE_CODE   = 'Inactive Code';
-  TX_INACTIVE_CODE   = 'This problem references an inactive ICD code,' + #13#10 +
+  TX_INACTIVE_ICODE  = 'This problem references an inactive ICD-9-CM code,' + #13#10 +
                        'and must be updated using the ''Change'' option.';
+  TC_INACTIVE_ICODE  = 'Inactive ICD-9-CM code';
   TX_ADD_REMOVED     = 'Cannot add to the "Removed Problem List"';
   TC_ADD_REMOVED     = 'Unable to add';
@@ -282,4 +283,10 @@
       LoadProblems ;
     end;
+  //CQ #11529: 508 PL tab - defaults the focus to the New Problem button ONLY upon switching to the Probs tab.  {TC}
+  if TabCtrlClicked and (ChangingTab = CT_PROBLEMS) then ProbTabClicked := True;
+  if (bbNewProb.CanFocus) and (not pnlButtons.Visible) and ((not PTSwitchRefresh) or ProbTabClicked) then bbNewProb.SetFocus;
+  if PTSwitchRefresh then PTSwitchRefresh := False;
+  if TabCtrlClicked then TabCtrlClicked := False;
+  if ProbTabClicked then ProbTabClicked := False;
 end;
 
@@ -570,7 +577,7 @@
               if not IsActiveICDCode(ProbRec.Diagnosis.extern) then
                 begin
-                  InfoBox(TX_INACTIVE_CODE, TC_INACTIVE_CODE, MB_ICONWARNING or MB_OK);
+                  InfoBox(TX_INACTIVE_ICODE, TC_INACTIVE_ICODE, MB_ICONWARNING or MB_OK);
                   exit;
-                end ;
+                end;
               if ProbRec.CmtIsXHTML then
                 begin
@@ -584,5 +591,5 @@
                   ut := '';
                   If PLUser.usPrimeUser then ut := '1';
-                  FastAssign(EditSave(ProblemIFN,pProviderID,PLPt.ptVAMC,ut,ProbRec.FilerObject), AList) ;
+                  FastAssign(EditSave(ProblemIFN, pProviderID, PLPt.ptVAMC, ut, ProbRec.FilerObject), AList);
                   LoadPatientProblems(AList,PlUser.usViewAct[1],true);
                 end ;
@@ -717,5 +724,5 @@
   pnlRight.font.color := self.font.color;
   S := MString(wgProbData.ItemIndex);
-  pnlRight.caption := Piece(Piece(S, U , 3), #13, 1);
+  //pnlRight.caption := Piece(Piece(S, U , 3), #13, 1); //fixes part (b) of CQ #15531: 508 Problems Tab [CPRS v28.1] {TC}
   if (Piece(S, U, 1) = '') or
      (Pos('No data available',  Piece(S, U, 2)) > 0) or
@@ -995,5 +1002,5 @@
 var {init should only be true when initializing a list for a new patient}
   x, line, ver, prio, comments: string;
-  i, j, inact: Integer;
+  i, j, inactI: Integer;
   st: char;
   CmtList: TStringList;
@@ -1020,5 +1027,5 @@
   try
     ClearGrid;
-    inact := 0;
+    inactI := 0;
     if PLPt = nil then
       begin
@@ -1063,5 +1070,5 @@
         begin
           ver := '#';      // inactive ICD code flag takes precedence over unverified flag
-          if (Piece(x, U, 2) = 'A') then inact := inact + 1;
+          if (Piece(x, U, 2) = 'A') then inactI := inactI + 1;
         end
       else if (PlUSer.usVerifyTranscribed) and
@@ -1126,9 +1133,9 @@
       NoRowSelected;
     pnlRightResize(Self);
-    if (not FWarningShown) and (inact > 0) and (CharAt(UpperCase(Status), 1) in ['A', 'B']) then
-      begin
-       InfoBox('There are ' + IntToStr(inact) + ' active problem(s) flagged with a "#" as having' + #13#10 +
-               'inactive ICD codes as of today''s date.  Please correct these' + #13#10 +
-               'problems using the "Change" option.', 'Inactive ICD Codes Found', MB_ICONWARNING or MB_OK);
+    if (not FWarningShown) and (inactI > 0) and (CharAt(UpperCase(Status), 1) in ['A', 'B']) then
+      begin
+       InfoBox('There are ' + IntToStr(inactI) + ' active problem(s) flagged with a "#" as having' + #13#10 +
+               'inactive ICD-9-CM codes as of today''s date.  Please correct these' + #13#10 +
+               'problems using the "Change" option.', 'Inactive ICD-9-CM Codes Found', MB_ICONWARNING or MB_OK);
        FWarningShown := True;
       end;
@@ -1216,9 +1223,10 @@
 var
   dup: string;
-  cmplist: TstringList;
-  cmpp, i: integer;
+  exprList, icdList, textList: TstringList;
+  cmpp, i, exprPos, icdPos, textPos: integer;
   collapserow: boolean;
 begin
   Result := False;
+  cmpp := -1;
   if Piece(newprob, U, 1) = '' then
     dup := CheckForDuplicateProblem('1', Piece(newprob, U, 2))
@@ -1236,11 +1244,25 @@
             lstViewClick(Self);
           end;
-        cmplist:=Tstringlist.create;
+        exprList := TStringList.Create;
+        icdList := TStringList.Create;
+        textList := TStringList.create;
         try {find and highlight duplicate problem - match problem text minus trailing '*'}
           for i := 0 to FAllProblems.Count - 1 do
-            cmpList.Add(TrimRight(Piece(Piece(Piece(FAllProblems[i], U, 3), #13, 1), '*', 1)));
-          cmpp:=cmpList.indexof(TrimRight(Piece(Piece(newprob, U, 2), '*', 1)));
+          begin
+            exprList.Add(TrimRight(Piece(FAllProblems[i], U, 1)));
+            icdList.Add(TrimRight(Piece(FAllProblems[i], U, 14)));
+            textList.Add(TrimRight(Piece(Piece(Piece(Piece(FAllProblems[i], U, 3), #13, 1), '*', 1),'(', 1)));
+          end;
+          exprPos := exprList.IndexOf(TrimRight(Piece(dup, U, 1)));
+          icdPos  := icdList.IndexOf(TrimRight(Piece(newprob, U, 3)));
+          textPos := textList.indexof(TrimRight(Piece(Piece(Piece(newprob, U, 2), '*', 1),'(', 1)));
+          if exprPos > -1 then
+            cmpp := exprPos
+          else if icdPos > -1 then
+            cmpp := icdPos
+          else if textPos > -1 then
+            cmpp := textPos;
         finally
-          cmplist.free;
+          textList.free;
         end;
         if cmpp > -1 then
@@ -1257,6 +1279,8 @@
                 ItemIndex := i;
                 Selected[i] := True;
-                break;
-              end;
+                //break;
+              end
+              else if wgProbData.Selected[i] = True then
+                wgProbData.Selected[i] := False;
             end;
             case DlgType of
@@ -1326,4 +1350,7 @@
       dlgProbs.show;
       PostMessage(dlgProbs.Handle, UM_TAKEFOCUS, 0, 0);
+      wgProbData.TabStop := False; //fixes part (c) of CQ #15531: 508 Problems tab [CPRS v28.1] {TC}.
+      //prevents the selected problem or last entered problem from the PL captionlistbox
+      //underneath pnlProbDlg to be focused & read by Jaws
     end
   else
@@ -1354,4 +1381,6 @@
       pnlProbDlg.Visible := True;
       pnlProbDlg.BringToFront ;
+      //prevents JAWS from reading the top item in the wgProbData caption listbox when hidden from view.
+      pnlProbDlg.SetFocus;
       dlgProbs           := TFrmDlgProb.create(pnlProbDlg);
       dlgProbs.HorzScrollBar.Range := dlgProbs.ClientWidth;
@@ -1364,4 +1393,7 @@
       dlgProbs.Show;
       PostMessage(dlgProbs.Handle, UM_TAKEFOCUS, 0, 0);
+      wgProbData.TabStop := False;  //fixes part (c) of CQ #15531: 508 Problems tab [CPRS v28.1] {TC}.
+      //prevents the selected problem or last entered problem from the PL captionlistbox
+      //underneath pnlProbDlg to be focused & read by Jaws
     end
   else
@@ -1406,5 +1438,5 @@
             if not IsActiveICDCode(ProbRec.Diagnosis.extern) then
               begin
-                InfoBox(TX_INACTIVE_CODE, TC_INACTIVE_CODE, MB_ICONWARNING or MB_OK);
+                InfoBox(TX_INACTIVE_ICODE, TC_INACTIVE_ICODE, MB_ICONWARNING or MB_OK);
                 exit;
               end;
@@ -1608,4 +1640,7 @@
   //Show pnlView & Add Back to tab Order
   ShowPnlView;
+  //shift focus to another ctrl so the Cancel btn does not get read twice by JAWS,
+  //once upon tabbing to the btn & 2nd after it is selected/clicked (focus remained on btn)
+  lstView.SetFocus;
 end;
 
@@ -1687,4 +1722,6 @@
       PLUser := nil;
     end;
+  if ScreenReaderActive then
+     GetScreenReader.Speak('Returning to default view.');
   ShowPnlView;
   LoadProblems ;
