Index: cprs/branches/foia-cprs/CPRS-Chart/Consults/fODConsult.pas
===================================================================
--- cprs/branches/foia-cprs/CPRS-Chart/Consults/fODConsult.pas	(revision 459)
+++ cprs/branches/foia-cprs/CPRS-Chart/Consults/fODConsult.pas	(revision 460)
@@ -85,4 +85,5 @@
     procedure btnDiagnosisClick(Sender: TObject);
     procedure cmdQuitClick(Sender: TObject);
+    procedure FormClose(Sender: TObject; var Action: TCloseAction);
 
   private
@@ -97,5 +98,5 @@
     procedure SetupReasonForRequest(OrderAction: integer);
     procedure GetProvDxandValidateCode(AResponses: TResponses);
-    function  ShowPrerequisites: boolean;
+    function ShowPrerequisites: boolean;
     procedure DoSetFontSize(FontSize: integer);
     procedure SetUpQuickOrderDX;
@@ -106,4 +107,5 @@
     procedure Validate(var AnErrMsg: string); override;
     function DefaultReasonForRequest(Service: string; Resolve: Boolean): TStrings;
+    
   public
     procedure SetupDialog(OrderAction: Integer; const ID: string); override;
@@ -123,5 +125,5 @@
 uses
     rODBase, rConsults, uCore, uConsults, rCore, fConsults, fPCELex, rPCE, fPreReq,
-    ORClasses, clipbrd, uTemplates;
+    ORClasses, clipbrd, uTemplates, fFrame, uODBase;
 
 var
@@ -131,5 +133,5 @@
   BADxUpdated: boolean;
   quickCode: string;
-  
+
 
 
@@ -153,4 +155,5 @@
 procedure TfrmODCslt.FormCreate(Sender: TObject);
 begin
+  frmFrame.pnlVisit.Enabled := false;
   AutoSizeDisabled := True;
   inherited;
@@ -223,5 +226,7 @@
   cboService.Enabled := True;
   cboService.Font.Color := clWindowText;
+  cboService.Height := 25 + (7 * cboService.ItemHeight);
   btnServiceTree.Enabled := True;
+  pnlServiceTreeButton.Enabled := True;
   ActiveControl := cboService;
   SetProvDiagPromptingMode;
@@ -271,4 +276,5 @@
       cboService.Font.Color := clGrayText;
       btnServiceTree.Enabled := False;
+      pnlServiceTreeButton.Enabled := False;
       if (OrderAction in [ORDER_COPY, ORDER_QUICK]) and (not ShowPrerequisites) then
         begin
@@ -286,5 +292,4 @@
     begin
       if QuickList.Count > 0 then BuildQuickTree(QuickList, '0', nil) ;
-      //SvcList.Assign(LoadServiceList(CN_SVC_LIST_ORD))   ;
       SvcList.Assign(LoadServiceListWithSynonyms(CN_SVC_LIST_ORD));           {RV}
       AList.Assign(SvcList);
@@ -512,4 +517,5 @@
         cboService.Font.Color := clGrayText;
         btnServiceTree.Enabled := False;
+        pnlServiceTreeButton.Enabled := False;
         Changing := False;
       end;
@@ -645,8 +651,6 @@
  begin
  inherited;
-
- //if NOT BILLING_AWARE then
-    if treService.Selected <> nil then
-       LastNode := treService.Selected.AbsoluteIndex;
+ if treService.Selected <> nil then
+    LastNode := treService.Selected.AbsoluteIndex;
 
  if  BILLING_AWARE and CIDCOkToSave  then
@@ -657,5 +661,4 @@
        begin
           uBACore.CompleteConsultOrderRec(uBAGlobals.BAOrderID,UBAGlobals.BAConsultDxList);
-       //   if ProvDx.Reqd = 'R' then UBAGlobals.BAConsultOrdersRequireDx.Add(uBAGlobals.BAOrderID); //allow special handling of non cidc consults that require dx .
           uBAGlobals.BAConsultDxList.Clear;
        end;
@@ -743,4 +746,5 @@
           Font.Color := clGrayText;
           btnServiceTree.Enabled := False;
+          pnlServiceTreeButton.Enabled := False;
           Changing := False;
           with Responses do if QuickOrder > 0 then
@@ -945,5 +949,8 @@
   with ProvDx do if (Reqd = '') or (PromptMode = '') then Exit;
   if ProvDx.Reqd = 'R' then
-    lblProvDiag.Caption := TX_PROVDX_REQD
+  begin
+    lblProvDiag.Caption := TX_PROVDX_REQD;
+    if (BILLING_AWARE)  and (ProvDx.PromptMode[1] = '') then btnDiagnosis.Enabled := True;
+  end
   else
     lblProvDiag.Caption := TX_PROVDX_OPT;
@@ -1066,6 +1073,5 @@
                   Result := False;
                   AbortOrder := True;
-                  //cmdQuitClick(Self);
-                end
+               end
               else Result := True;
             end;
@@ -1076,7 +1082,4 @@
 end;
 
-////////// NOTE THIS FUNCTION IS NO LONGER ASSIGNED TO OnExit EVENT
-///////// Calling this with enter making a selection had serious errors
-///////// No ill effect can be seen for not calling it.
 procedure TfrmODCslt.cboServiceExit(Sender: TObject);
 begin
@@ -1086,5 +1089,7 @@
   if cboService.ItemID = FLastServiceID then Exit;
   cboServiceSelect(cboService);
-  cboService.SetFocus;
+  // CQ #7490, following line commented out v26.24 (RV)
+  // CQ #9610 and 10074 - uncommented and "if" added v26.54 (RV)
+  if cboService.Enabled then cboService.SetFocus;
   PostMessage(Handle, WM_NEXTDLGCTL, 0, 0);
 end;
@@ -1141,6 +1146,8 @@
   TmpSL: TStringList;
   DocInfo: string;
-
-begin
+  x: string;
+  HasObjects: boolean;
+begin
+  Resolve := FALSE ;  // override value passed in - resolve on client - PSI-05-093
   DocInfo := '';
   TmpSL := TStringList.Create;
@@ -1148,5 +1155,10 @@
     Result := GetDefaultReasonForRequest(Service + CSLT_PTR, Resolve);
     TmpSL.Assign(Result);
+    x := TmpSL.Text;
+    ExpandOrderObjects(x, HasObjects);
+    TmpSL.Text := x;
+    Responses.OrderContainsObjects := HasObjects;
     ExecuteTemplateOrBoilerPlate(TmpSL, cboService.ItemIEN , ltConsult, nil, 'Reason for Request: ' + cboService.DisplayText[cboService.ItemIndex], DocInfo);
+    if TmpSL.Text <> x then Responses.OrderContainsObjects := False;
     Result.Assign(TmpSL);
   finally
@@ -1284,5 +1296,5 @@
   //Except when Enter or Space is pressed. VK_LBUTTON activates OnClick in TORComboBoxes
   FcboServiceKeyDownStopClick := false;
-  if (Key <> VK_RETURN) and (Key <> VK_SPACE) and (Key <> VK_LBUTTON) then
+  if (Key <> VK_RETURN) {and (Key <> VK_SPACE)} and (Key <> VK_LBUTTON) then  //comment on this line is fix for CQ6789
     FcboServiceKeyDownStopClick := True
   else
@@ -1333,4 +1345,5 @@
      end;
   end;
+
   ProvDx.CodeInactive := False;
 end;
@@ -1387,4 +1400,10 @@
 end;
 
+procedure TfrmODCslt.FormClose(Sender: TObject; var Action: TCloseAction);
+begin
+  inherited;
+  frmFrame.pnlVisit.Enabled := true;
+end;
+
 end.
 
