Index: cprs/trunk/CPRS-Chart/fDCSummProps.pas
===================================================================
--- cprs/trunk/CPRS-Chart/fDCSummProps.pas	(revision 456)
+++ cprs/trunk/CPRS-Chart/fDCSummProps.pas	(revision 830)
@@ -5,8 +5,9 @@
 uses
   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
-  StdCtrls, ORDtTm, ORCtrls, ExtCtrls, uConst, rTIU, rDCSumm, uDocTree, uDCSumm, uTIU;
+  StdCtrls, ORDtTm, ORCtrls, ExtCtrls, uConst, rTIU, rDCSumm, uDocTree, uDCSumm,
+  uTIU, fBase508Form, VA508AccessibilityManager;
 
 type
-  TfrmDCSummProperties = class(TForm)
+  TfrmDCSummProperties = class(TfrmBase508Form)
     bvlConsult: TBevel;
     pnlFields: TORAutoPanel;
@@ -55,4 +56,5 @@
     procedure cboNewTitleDblClick(Sender: TObject);
     procedure FormClose(Sender: TObject; var Action: TCloseAction);
+    procedure cboNewTitleChange(Sender: TObject);
   private
     FCosignIEN: Int64;      // store cosigner that was passed in
@@ -136,5 +138,5 @@
           Top := Top  - pnlTranscription.Height;
         end;
-      Height := Height - pnlAdmissions.Height - pnlLabels.Height;
+//      Height := Height - pnlAdmissions.Height - pnlLabels.Height;
       if ASumm.DocType <> TYP_ADDENDUM then
         begin
@@ -149,5 +151,5 @@
       cboAuthor.InitLongList(ASumm.DictatorName);
       if ASumm.Dictator > 0 then cboAuthor.SelectByIEN(ASumm.Dictator);
-      cboUrgency.Items.Assign(LoadDCUrgencies);
+      FastAssign(LoadDCUrgencies, cboUrgency.Items);
       cboUrgency.SelectByID('R');
       if Asumm.Attending = 0 then
@@ -156,6 +158,4 @@
           ASumm.AttendingName := FLastCosignerName;
         end;
-      cboAttending.InitLongList(ASumm.AttendingName);
-      if ASumm.Attending > 0 then cboAttending.SelectByIEN(ASumm.Attending);
       calSumm.FMDateTime := ASumm.DictDateTime;
       if FShowAdmissions then ShowAdmissionList;
@@ -165,4 +165,6 @@
       FLastCosignerName := ASumm.LastCosignerName;
       FEditIEN    := 0;
+      cboAttending.InitLongList(ASumm.AttendingName);
+      if ASumm.Attending > 0 then cboAttending.SelectByIEN(ASumm.Attending);
       // restrict edit of title if addendum
       if FDocType = TYP_ADDENDUM then
@@ -212,5 +214,5 @@
               ListBoxItem := x;
               if Lines = nil then Lines := TStringList.Create;
-              Lines.Assign(EditLines);
+              FastAssign(EditLines, Lines);
             end
           else
@@ -320,5 +322,5 @@
   if FShowAdmissions and (not pnlAdmissions.Visible) then
     begin
-      Height := Height + pnlAdmissions.Height + pnlLabels.Height;
+//      Height := Height + pnlAdmissions.Height + pnlLabels.Height;
       pnlAdmissions.Visible := True;
       pnlLabels.Visible := True;
@@ -342,7 +344,18 @@
 procedure TfrmDCSummProperties.cboAttendingNeedData(Sender: TObject; const StartFrom: String;
   Direction, InsertAt: Integer);
-begin   // changed in v15.2, per BRX-1100-10981
+var TitleIEN: Int64;
+begin
 //  (Sender as TORComboBox).ForDataUse(SubSetOfPersons(StartFrom, Direction));
-  (Sender as TORComboBox).ForDataUse(SubSetOfProviders(StartFrom, Direction));
+
+// CQ#11666
+//  (Sender as TORComboBox).ForDataUse(SubSetOfCosigners(StartFrom, Direction,
+//        FMToday, cboNewTitle.ItemIEN, FDocType));
+
+// CQ #17218 - Updated to properly filter co-signers - JCS
+  TitleIEN := cboNewTitle.ItemIEN;
+  if TitleIEN = 0 then TitleIEN := FDocType;
+
+  (Sender as TORComboBox).ForDataUse(SubSetOfCosigners(StartFrom, Direction,
+        FMToday, TitleIEN, 0));
 end;
 
@@ -367,6 +380,14 @@
 begin
   with cboAttending do if Text = '' then ItemIndex := -1;
-  FCosignIEN := cboAttending.ItemIEN;
-  FCosignName := Piece(cboAttending.Items[cboAttending.ItemIndex], U, 2);
+  if cboAttending.ItemIndex < 0 then
+  begin
+    FCosignIEN := 0;
+    FCosignName := '';
+  end
+  else
+  begin
+    FCosignIEN := cboAttending.ItemIEN;
+    FCosignName := Piece(cboAttending.Items[cboAttending.ItemIndex], U, 2);
+  end;
 end;
 
@@ -390,7 +411,16 @@
   if cboAttending.Visible and (cboAttending.ItemIEN = 0)   then ErrMsg := ErrMsg + TX_REQ_COSIGNER;
   //if cboAttending.ItemIEN = User.DUZ                      then ErrMsg := TX_COS_SELF;
-  if (cboAttending.ItemIEN > 0) and not IsUserAProvider(cboAttending.ItemIEN, FMNow) then
-  //if (cboAttending.ItemIEN > 0) and not CanCosign(cboNewTitle.ItemIEN, FDocType, cboAttending.ItemIEN) then
-    ErrMsg := cboAttending.Text + TX_COS_AUTH;
+
+// --------------------------------- REPLACED THIS BLOCK IN V27.37-----------------------------------------------
+/// if (cboAttending.ItemIEN > 0) and not IsUserAProvider(cboAttending.ItemIEN, FMNow) then
+//  //if (cboAttending.ItemIEN > 0) and not CanCosign(cboNewTitle.ItemIEN, FDocType, cboAttending.ItemIEN) then
+//   ErrMsg := cboAttending.Text + TX_COS_AUTH;
+// ------------------------------------ NEW CODE FOLLOWS --------------------------------------------------------
+  if (cboAttending.ItemIEN > 0) then
+     if ((not IsUserAUSRProvider(cboAttending.ItemIEN, FMNow)) or
+        (not CanCosign(cboNewTitle.ItemIEN, FDocType, cboAttending.ItemIEN, calSumm.FMDateTime))) then
+     ErrMsg := cboAttending.Text + TX_COS_AUTH;
+// -----------------------------------END OF NEW REPLACEMENT CODE -----------------------------------------------
+
   if pnlAdmissions.Visible then
   with lstAdmissions do
@@ -473,5 +503,5 @@
         cboAuthor.InitLongList(AnEditSumm.DictatorName);
         if AnEditSumm.Dictator > 0 then cboAuthor.SelectByIEN(AnEditSumm.Dictator);
-        cboUrgency.Items.Assign(LoadDCUrgencies);
+        FastAssign(LoadDCUrgencies, cboUrgency.Items);
         cboUrgency.SelectByID('R');
         cboAttending.InitLongList(AnEditSumm.AttendingName);
@@ -509,4 +539,28 @@
 end;
 
+procedure TfrmDCSummProperties.cboNewTitleChange(Sender: TObject);
+var
+  IEN: Int64;
+  name: string;
+  Index: Integer;
+
+begin
+  inherited;
+  index := cboAttending.ItemIndex;
+  if index >= 0 then
+  begin
+    IEN := cboAttending.ItemIEN;
+    name := cboAttending.DisplayText[index];
+  end
+  else
+  begin
+    name := '';
+    IEN := 0;
+  end;
+  cboAttending.InitLongList(name);
+  if index >= 0 then
+    cboAttending.SelectByIEN(IEN);
+end;
+
 procedure TfrmDCSummProperties.cboNewTitleDblClick(Sender: TObject);
 begin
