Index: cprs/branches/foia-cprs/CPRS-Chart/Consults/fConsults.pas
===================================================================
--- cprs/branches/foia-cprs/CPRS-Chart/Consults/fConsults.pas	(revision 459)
+++ cprs/branches/foia-cprs/CPRS-Chart/Consults/fConsults.pas	(revision 460)
@@ -162,4 +162,14 @@
     popNoteMemoInsTemplate: TMenuItem;
     popNoteMemoEncounter: 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 lstConsultsClick(Sender: TObject);
@@ -267,4 +277,6 @@
     procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
       Y: Integer);
+    procedure ViewInfo(Sender: TObject);
+    procedure mnuViewInformationClick(Sender: TObject);
   private
     FEditingIndex: Integer;      // TIU index of document being currently edited
@@ -296,5 +308,5 @@
     procedure frmDrawerPnlEncounterButtonExit(Sender: TObject);
     procedure frmDrawerEdtSearchExit(Sender: TObject);
-    procedure DoAutoSave;
+    procedure DoAutoSave(Suppress: integer = 1);
     function GetTitleText(AnIndex: Integer): string;
     //function MakeTitleText(IsAddendum: Boolean = False): string;
@@ -870,9 +882,5 @@
             lstNotesClick(Self);  // will make pnlWrite visible
             if timAutoSave.Interval <> 0 then EnableAutosave := TRUE;
-
-            if txtSubject.Visible then
-              txtSubject.SetFocus
-            else
-              memResults.SetFocus;
+            if txtSubject.Visible then txtSubject.SetFocus else memResults.SetFocus;
           end
         else  //  CreatedNote.ErrorText <> ''
@@ -947,5 +955,6 @@
     else HaveRequired := True;
   // lock the consult request if there is a consult
-  if FEditNote.PkgIEN > 0 then HaveRequired := LockConsultRequest(FEditNote.PkgIEN);
+  if HaveRequired and (FEditNote.PkgIEN > 0) then
+    HaveRequired := LockConsultRequest(FEditNote.PkgIEN);
   if HaveRequired then
   begin
@@ -1529,5 +1538,5 @@
       CompleteConsult(IS_ID_CHILD, 0, UseClinProcTitles);
     end
-  else if NoteIEN = -1 then Exit;
+  else if NoteIEN = -1 then Exit
 end;
 
@@ -2003,8 +2012,11 @@
 procedure TfrmConsults.SaveSignItem(const ItemID, ESCode: string);
 { saves and optionally signs a progress note 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;
@@ -2012,4 +2024,5 @@
   tmpNode: TORTreeNode;
   ErrMsg: string;
+  ActionType, SignTitle: string;
 begin
   AnIndex := -1;
@@ -2039,15 +2052,20 @@
   if Length(ESCode) > 0 then
   begin
-(*    if LacksClinProcFieldsForSignature(IEN, ErrMsg) then
-       begin
-         InfoBox(ErrMsg, TC_CLIN_PROC, MB_OK);
-         ContinueSign := False;
-       end
-    else ContinueSign := True;
-    if not LastSaveClean(IEN) and
-      (InfoBox(TX_ABSAVE, TC_ABSAVE, MB_YESNO or MB_DEFBUTTON2) <> IDYES)
-       then ContinueSign := False;
-       //else ContinueSign := True;*)
-    if LacksClinProcFieldsForSignature(IEN, ErrMsg) 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 LacksClinProcFieldsForSignature(IEN, ErrMsg) then
       begin
        InfoBox(ErrMsg, TC_CLIN_PROC, MB_OK);
@@ -2063,5 +2081,4 @@
        then ContinueSign := False
     else ContinueSign := True;
-
     if ContinueSign then
     begin
@@ -2753,9 +2770,11 @@
 begin
   inherited;
-  DoAutoSave;
+  DoAutoSave(0);
   timAutoSave.Enabled := False;
   try
     SpellCheckForControl(memResults);
   finally
+    FChanged := True;
+    DoAutoSave(0);
     timAutoSave.Enabled := True;
   end;
@@ -2765,9 +2784,11 @@
 begin
   inherited;
-  DoAutoSave;
+  DoAutoSave(0);
   timAutoSave.Enabled := False;
   try
     GrammarCheckForControl(memResults);
   finally
+    FChanged := True;
+    DoAutoSave(0);
     timAutoSave.Enabled := True;
   end;
@@ -2985,4 +3006,5 @@
   SigAction: integer;
   SavedDocID, SavedCsltID: string;
+  ARefDate: TFMDateTime;
 begin
   inherited;
@@ -3017,7 +3039,11 @@
     end;
 
-  if not LockConsultRequestAndNote(lstNotes.ItemIEN) then Exit;
-  Exclusions := GetCurrentSigners(lstNotes.ItemIEN);
-  SelectAdditionalSigners(Font.Size, lstNotes.ItemIEN, SigAction, Exclusions, SignerList, CT_CONSULTS);
+  with lstNotes do
+    begin
+      if not LockConsultRequestAndNote(ItemIEN) then Exit;
+      Exclusions := GetCurrentSigners(ItemIEN);
+      ARefDate := StrToFloat(Piece(Items[ItemIndex], U, 3));
+      SelectAdditionalSigners(Font.Size, ItemIEN, SigAction, Exclusions, SignerList, CT_CONSULTS, ARefDate);
+    end;
   with SignerList do
     begin
@@ -3556,5 +3582,5 @@
     begin
       if Title > 0 then CurTitle := Title else CurTitle := DocType;
-      if AskCosignerForTitle(CurTitle, Author) and (Cosigner <= 0) then Result := True;
+      if AskCosignerForTitle(CurTitle, Author, DateTime) and (Cosigner <= 0) then Result := True;
     end;
   end;
@@ -3572,5 +3598,5 @@
           ErrMsg := TX_NO_AUTHOR;
         end;
-      if AskCosignerForTitle(Title, Author) and (Cosigner = 0) then
+      if AskCosignerForTitle(Title, Author, DateTime) and (Cosigner = 0) then
         begin
           Result := True;
@@ -3665,5 +3691,5 @@
 end;
 
-procedure TfrmConsults.DoAutoSave;
+procedure TfrmConsults.DoAutoSave(Suppress: integer = 1);
 var
   ErrMsg: string;
@@ -3672,8 +3698,8 @@
   begin
     StatusText('Autosaving note...');
-    //PutTextOnly(ErrMsg, memNewNote.Lines, lstNotes.GetIEN(EditingIndex));
+    //PutTextOnly(ErrMsg, memResults.Lines, lstNotes.GetIEN(EditingIndex));
     timAutoSave.Enabled := False;
     try
-      SetText(ErrMsg, memResults.Lines, lstNotes.GetIEN(EditingIndex),1);
+      SetText(ErrMsg, memResults.Lines, lstNotes.GetIEN(EditingIndex), Suppress);
     finally
       timAutoSave.Enabled := True;
@@ -4682,6 +4708,11 @@
         (Screen.ActiveControl = txtSubject) or
         (Screen.ActiveControl = memResults) then
-      //frmFrame.pnlPatient.SetFocus  //COMMENTED OUT FOR CQ6498
-      memResults.SetFocus //ADDED THIS LINE FOR CQ6498
+      begin
+        //frmFrame.pnlPatient.SetFocus  //COMMENTED OUT FOR CQ6498
+        if memResults.CanFocus then
+          memResults.SetFocus //ADDED THIS LINE FOR CQ6498
+        else
+          memConsult.SetFocus;
+      end
     else
     if (Screen.ActiveControl = tvConsults) then
@@ -4729,5 +4760,6 @@
   {Below is a fix for ClearQuest Defect HDS0000948, Kind of Kloogy I looked
   and looked for side effects and a better solution and this was the best!}
-  frmDrawers.Hide;
+  if (EditingIndex = -1) or (lstNotes.ItemIndex <> EditingIndex) then
+    frmDrawers.Hide;
   {This TStaticText I am looking for doesn't have a Name! So
    I have to loop through the panel's controls and disable the TStaticText.}
@@ -4768,4 +4800,24 @@
 end;
 
+procedure TfrmConsults.ViewInfo(Sender: TObject);
+begin
+  inherited;
+  frmFrame.ViewInfo(Sender);
+end;
+
+procedure TfrmConsults.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;
