Index: cprs/branches/foia-cprs/CPRS-Chart/fDCSumm.pas
===================================================================
--- cprs/branches/foia-cprs/CPRS-Chart/fDCSumm.pas	(revision 459)
+++ cprs/branches/foia-cprs/CPRS-Chart/fDCSumm.pas	(revision 460)
@@ -134,4 +134,14 @@
     popSummMemoInsTemplate: TMenuItem;
     popSummMemoEncounter: TMenuItem;
+    mnuViewInformation: TMenuItem;
+    mnuViewDemo: TMenuItem;
+    mnuViewVisits: TMenuItem;
+    mnuViewPrimaryCare: TMenuItem;
+    mnuViewMyHealtheVet: TMenuItem;
+    mnuInsurance: TMenuItem;
+    mnuViewFlags: TMenuItem;
+    mnuViewReminders: TMenuItem;
+    mnuViewRemoteData: TMenuItem;
+    mnuViewPostings: TMenuItem;
     procedure mnuChartTabClick(Sender: TObject);
     procedure lstSummsClick(Sender: TObject);
@@ -211,4 +221,6 @@
     procedure tvSummsAddition(Sender: TObject; Node: TTreeNode);
     procedure tvSummsDeletion(Sender: TObject; Node: TTreeNode);
+    procedure ViewInfo(Sender: TObject);
+    procedure mnuViewInformationClick(Sender: TObject);
   private
     FEditingIndex: Integer;                      // index of Summary being currently edited
@@ -230,5 +242,5 @@
     procedure ClearEditControls;
     function StartNewEdit(NewNoteType: integer): Boolean;
-    procedure DoAutoSave;
+    procedure DoAutoSave(Suppress: integer = 1);
     function LacksRequiredForCreate: Boolean;
     function GetTitleText(AnIndex: Integer): string;
@@ -1726,11 +1738,14 @@
 procedure TfrmDCSumm.SaveSignItem(const ItemID, ESCode: string);
 { saves and optionally signs a Discharge Summary or addendum }
+const
+  SIG_COSIGN = 'COSIGNATURE';
+  SIG_SIGN   = 'SIGNATURE';
 var
   AnIndex, IEN, i: Integer;
   Saved, ContinueSign: Boolean;   {*RAB* 8/26/99}
-  SignSts: TActionRec;
+  ActionSts, SignSts: TActionRec;
   APCEObject: TPCEData;
   OK: boolean;
-
+  ActionType, SignTitle: string;
 begin
   AnIndex := -1;
@@ -1757,5 +1772,20 @@
   if Length(ESCode) > 0 then
   begin
-    if not NoteHasText(IEN) then
+    if CosignDocument(IEN) then
+    begin
+      SignTitle := TX_COSIGN;
+      ActionType := SIG_COSIGN;
+    end else
+    begin
+      SignTitle := TX_SIGN;
+      ActionType := SIG_SIGN;
+    end;
+    ActOnDocument(ActionSts, IEN, ActionType);
+    if not ActionSts.Success then
+      begin
+        InfoBox(ActionSts.Reason, TX_IN_AUTH, MB_OK);
+        ContinueSign := False;
+      end
+    else if not NoteHasText(IEN) then
       begin
         InfoBox(TX_EMPTY_SUMM1, TC_EMPTY_SUMM, MB_OK or MB_ICONERROR);
@@ -1910,9 +1940,11 @@
 begin
   inherited;
-  DoAutoSave;
+  DoAutoSave(0);
   timAutoSave.Enabled := False;
   try
     SpellCheckForControl(memNewSumm);
   finally
+    FChanged := True;
+    DoAutoSave(0);
     timAutoSave.Enabled := True;
   end;
@@ -1922,9 +1954,11 @@
 begin
   inherited;
-  DoAutoSave;
+  DoAutoSave(0);
   timAutoSave.Enabled := False;
   try
     GrammarCheckForControl(memNewSumm);
   finally
+    FChanged := True;
+    DoAutoSave(0);
     timAutoSave.Enabled := True;
   end;
@@ -2013,4 +2047,5 @@
   SigAction: integer;
   SavedDocID: string;
+  ARefDate: TFMDateTime;
 begin
   inherited;
@@ -2052,5 +2087,8 @@
 
   Exclusions := GetCurrentSigners(lstSumms.ItemIEN);
-  SelectAdditionalSigners(Font.Size, lstSumms.ItemIEN, SigAction, Exclusions, SignerList, CT_DCSUMM);
+  ARefDate := ExtractFloat(Piece(Piece(lstSumms.Items[lstSumms.ItemIndex], U, 9), ';', 2));
+  if ARefDate = 0 then        //no discharge date, so use note date
+    ARefDate := StrToFloat(Piece(lstSumms.Items[lstSumms.ItemIndex], U, 3));
+  SelectAdditionalSigners(Font.Size, lstSumms.ItemIEN, SigAction, Exclusions, SignerList, CT_DCSUMM, ARefDate);
   with SignerList do
     begin
@@ -2308,4 +2346,5 @@
 var
   CurTitle: Integer;
+  ADateTime:  TFMDateTime;
 begin
   Result := False;
@@ -2321,5 +2360,9 @@
     begin
       if Title > 0 then CurTitle := Title else CurTitle := DocType;
-      if AskCosignerForTitle(CurTitle, Dictator) and (Cosigner <= 0) then Result := True;
+      if DischargeDateTime > 0 then
+        ADateTime := DischargeDateTime
+      else
+        ADateTime := DictDateTime;
+      if AskCosignerForTitle(CurTitle, Dictator, ADateTime) and (Cosigner <= 0) then Result := True;
     end;
   end;
@@ -2357,5 +2400,5 @@
 end;
 
-procedure TfrmDCSumm.DoAutoSave;
+procedure TfrmDCSumm.DoAutoSave(Suppress: integer = 1);
 var
   ErrMsg: string;
@@ -2367,5 +2410,5 @@
     timAutoSave.Enabled := False;
     try
-      SetText(ErrMsg, memNewSumm.Lines, lstSumms.GetIEN(EditingIndex),1);
+      SetText(ErrMsg, memNewSumm.Lines, lstSumms.GetIEN(EditingIndex), Suppress);
     finally
       timAutoSave.Enabled := True;
@@ -3216,4 +3259,24 @@
 end;
 
+procedure TfrmDCSumm.ViewInfo(Sender: TObject);
+begin
+  inherited;
+  frmFrame.ViewInfo(Sender);
+end;
+
+procedure TfrmDCSumm.mnuViewInformationClick(Sender: TObject);
+begin
+  inherited;
+  mnuViewDemo.Enabled := frmFrame.pnlPatient.Enabled;
+  mnuViewVisits.Enabled := frmFrame.pnlVisit.Enabled;
+  mnuViewPrimaryCare.Enabled := frmFrame.pnlPrimaryCare.Enabled;
+  mnuViewMyHealtheVet.Enabled := not (Copy(frmFrame.laMHV.Hint, 1, 2) = 'No');
+  mnuInsurance.Enabled := not (Copy(frmFrame.laVAA2.Hint, 1, 2) = 'No');
+  mnuViewFlags.Enabled := frmFrame.lblFlag.Enabled;
+  mnuViewRemoteData.Enabled := frmFrame.lblCirn.Enabled;
+  mnuViewReminders.Enabled := frmFrame.pnlReminders.Enabled;
+  mnuViewPostings.Enabled := frmFrame.pnlPostings.Enabled;
+end;
+
 initialization
   uPCEEdit := TPCEData.Create;
