Index: cprs/branches/foia-cprs/CPRS-Chart/Orders/uOrders.pas
===================================================================
--- cprs/branches/foia-cprs/CPRS-Chart/Orders/uOrders.pas	(revision 459)
+++ cprs/branches/foia-cprs/CPRS-Chart/Orders/uOrders.pas	(revision 460)
@@ -58,5 +58,5 @@
 procedure QuickOrderListEdit;
 function RefNumFor(AnOwner: TComponent): Integer;
-procedure PrintOrdersOnSignRelease(OrderList: TStringList; Nature: Char);
+procedure PrintOrdersOnSignRelease(OrderList: TStringList; Nature: Char; PrintLoc : Integer =0);
 procedure SetFontSize( FontSize: integer);
 procedure NextMove(var NMRec: TNextMoveRec; LastIndex: Integer; NewIndex: Integer);
@@ -74,7 +74,9 @@
 MedsDisp : Integer;
 ClinDisp : Integer; //IMO
+NurDisp  : Integer;
 IVDisp   : Integer;
 CsltDisp : Integer;
 ProcDisp : Integer;
+ImgDisp  : Integer;
 NonVADisp: Integer;
 MedsInDlgIen  : Integer;
@@ -94,9 +96,9 @@
 
 uses fODDiet, fODMisc, fODGen, fODMedIn, fODMedOut, fODText, fODConsult, fODProc, fODRad,
-     fODLab, fODMeds, fODMedIV, fODVitals, fODAuto, fODAllgy, fOMNavA, rCore, uCore, fFrame,
+     fODLab, fodBBank, fODMeds, fODMedIV, fODVitals, fODAuto, (*fODAllgy,*) fOMNavA, rCore, uCore, fFrame,
      fEncnt, fEffectDate, fOMVerify, fOrderSaveQuick, fOMSet, rMisc, uODBase, rODMeds,
      fLkUpLocation, fOrdersPrint, fOMAction, fARTAllgy, fOMHTML, fOrders, rODBase,
      fODChild, fMeds, rMeds, rPCE, frptBox, fODMedNVA, fODChangeUnreleasedRenew, rODAllergy,
-     UBAGlobals;
+     UBAGlobals, fClinicWardMeds, uTemplateFields;
 
 var
@@ -142,4 +144,7 @@
   TX_NO_QUICK   = 'This ordering dialog does not support quick orders.';
   TC_NO_QUICK   = 'Save/Edit Quick Orders';
+  TX_CANT_SAVE_QO = 'This order contains TIU objects, which may result in patient-specific' + CRLF +
+                    'information being included in the order.  For this reason, it may not' + CRLF +
+                    'be saved as a personal quick order for later reuse.';
   TX_NO_COPY    = CRLF + CRLF + '- cannot be copied.' + CRLF + CRLF + 'Reason: ';
   TC_NO_COPY    = 'Unable to Copy Order';
@@ -152,7 +157,7 @@
   STEP_FORWARD  = 1;
   STEP_BACK     = -1;
-  TX_NOINPT     = 'You can not place inpatient medication order on a clinic location for selected inpatient.';
+  TX_NOINPT     = ': You cannot place inpatient medication orders from a clinic location for selected patient.';
   TX_IMO_WARNING1 = 'You are ';
-  TX_IMO_WARNING2 = ' Clinic Medication orders. The New orders will be saved as Clinic Medication orders and will NOT be available in BCMA';
+  TX_IMO_WARNING2 = ' Clinic Orders. The New orders will be saved as Clinic Orders and MAY NOT be available in BCMA';
 
 
@@ -200,9 +205,10 @@
   OD_DIET:      DialogClass := TfrmODDiet;
   OD_LAB:       DialogClass := TfrmODLab;
+  OD_BB:        DialogClass := TfrmODBBank;
   OD_CONSULT:   DialogClass := TfrmODCslt;
   OD_PROCEDURE: DialogClass := TfrmODProc;
   OD_TEXTONLY:  DialogClass := TfrmODText;
   OD_VITALS:    DialogClass := TfrmODVitals;
-  OD_ALLERGY:   DialogClass := TfrmODAllergy;
+  //OD_ALLERGY:   DialogClass := TfrmODAllergy;
   OD_AUTOACK:   DialogClass := TfrmODAuto;
   else Exit;
@@ -391,7 +397,17 @@
       else
       begin
-        ResolvedDialog.DisplayGroup := InptDisp;
-        ResolvedDialog.DialogIEN    := MedsInDlgIen;
-        ResolvedDialog.FormID       := MedsInDlgFormId;
+        //AGP changes to handle IMO INV Dialog opening the unit dose dialog.
+        if (ResolvedDialog.DisplayGroup = ClinDisp) and (Resolveddialog.DialogIEN = MedsIVDlgIEN) and (ResolvedDialog.FormID = MedsIVDlgFormId) then
+          begin
+            ResolvedDialog.DisplayGroup := IVDisp;
+            ResolvedDialog.DialogIEN    := MedsIVDlgIen;
+            ResolvedDialog.FormID       := MedsIVDlgFormId;
+          end
+        else
+          begin
+            ResolvedDialog.DisplayGroup := InptDisp;
+            ResolvedDialog.DialogIEN    := MedsInDlgIen;
+            ResolvedDialog.FormID       := MedsInDlgFormId;
+          end;
         if Length(ResolvedDialog.ShowText)>0 then
           ResolvedDialog.QuickLevel   := 2;
@@ -452,6 +468,8 @@
   IVDisp   := DisplayGroupByName('IV RX');
   ClinDisp := DisplayGroupByName('C RX');
+  NurDisp  := DisplayGroupByName('NURS');
   CsltDisp := DisplayGroupByName('CSLT');
   ProcDisp := DisplayGroupByName('PROC');
+  ImgDisp  := DisplayGroupByName('XRAY');
   NonVADisp := DisplayGroupByName('NV RX');
   MedsInDlgIen  := DlgIENForName('PSJ OR PAT OE');
@@ -817,4 +835,5 @@
     ResolvedDialog.DisplayGroup := ClinDisp;
   ResetDialogProperties(AnID, AnEvent, ResolvedDialog);
+ {* AGP CHANGE 26.20 Remove restriction to allowed for ordering of inpatient medication for an inpatient from an outpatient location
    //jd imo change
    if (ResolvedDialog.DisplayGroup = InptDisp) and (Patient.Inpatient) and (AnEvent.EventIFN < 1) then
@@ -826,5 +845,5 @@
      end;
    end;
-   //jd imo change end
+   //jd imo change end  *}
    if (ResolvedDialog.DisplayGroup = InptDisp) or
       (ResolvedDialog.DisplayGroup = OutptDisp) or
@@ -865,4 +884,5 @@
     if NSSchedule then ResolvedDialog.QuickLevel := 0;
   end;
+  with ResolvedDialog do if (QuickLevel = QL_VERIFY) and (HasTemplateField(ShowText)) then QuickLevel := QL_DIALOG;
   with ResolvedDialog do
   begin
@@ -1003,5 +1023,4 @@
                        begin
                        ShowModal;
-                       //Application.ProcessMessages;
                        Result := uOrderDialog.AcceptOK;
                        uOrderDialog.Destroy;
@@ -1010,5 +1029,4 @@
                        begin
                        Show;
-                       //Application.ProcessMessages;
                        Result := True;
                        end;
@@ -1050,5 +1068,12 @@
   OrdList: TList;
   theOrder: TOrder;
-begin
+ // i: integer;
+begin
+ // if Assigned(OrdList) then
+ // begin
+ //    for i := 0 to pred(OrdList.Count) do
+ //       TObject(OrdList[i]).Free;
+  //   UBAGlobals.tempDxList := nil;
+ // end;
   OrdList := TList.Create;
   theOrder := TOrder.Create;
@@ -1057,4 +1082,5 @@
   RetrieveOrderFields(OrdList, 0, 0);
   Result := TOrder(OrdList.Items[0]).Text;
+  if Assigned(OrdList) then OrdList.Free; //CQ:7554
 end;
 
@@ -1349,5 +1375,5 @@
         param2 := FieldsForEditRenewOrder.StopTime;
       end;
-       UBAGlobals.SourceOrderID := AList[i]; //hds6265 added
+      UBAGlobals.SourceOrderID := AList[i]; //hds6265 added
       ExecuteChangeRenewedOrder(AList[i], param1, param2, txtOrder);
       AnOrder := TOrder.Create;
@@ -1393,5 +1419,5 @@
 var
   i: Integer;
-  xx,xy: string;
+  xx: string;
   IsIMOOD,ForIVAlso: boolean;
 begin
@@ -1602,4 +1628,9 @@
       Exit;
     end;
+    if Responses.OrderContainsObjects then
+    begin
+      InfoBox(TX_CANT_SAVE_QO, TC_NO_QUICK, MB_ICONERROR or MB_OK);
+      Exit;
+    end;
     SaveAsQuickOrder(Responses);
   end;
@@ -1639,5 +1670,5 @@
 
 
-procedure PrintOrdersOnSignRelease(OrderList: TStringList; Nature: Char);
+procedure PrintOrdersOnSignRelease(OrderList: TStringList; Nature: Char; PrintLoc : Integer =0);
 const
   TX_NEW_LOC1   = 'The patient''s location has changed to ';
@@ -1652,11 +1683,15 @@
   PrintIt: Boolean;
 begin
-  CurrentLocationForPatient(Patient.DFN, ALocation, AName, ASvc);
-  if (ALocation > 0) and (ALocation <> Encounter.Location) then
-  begin
-    Encounter.Location := ALocation;
-    if InfoBox(TX_NEW_LOC1 + AName + TX_NEW_LOC2, TC_NEW_LOC, MB_YESNO) = IDYES
-      then Encounter.Location := ALocation;
-  end;
+  if PrintLoc = 0 then
+    begin
+      CurrentLocationForPatient(Patient.DFN, ALocation, AName, ASvc);
+      if (ALocation > 0) and (ALocation <> Encounter.Location) then
+        begin
+          if InfoBox(TX_NEW_LOC1 + AName + TX_NEW_LOC2, TC_NEW_LOC, MB_YESNO) = IDYES
+          then Encounter.Location := ALocation;
+        end;
+    end
+  else
+    Encounter.Location := PrintLoc;
   if Encounter.Location = 0
     then Encounter.Location := CommonLocationForOrders(OrderList);
@@ -1747,5 +1782,5 @@
         if CharAt(AnID,1) = 'X' then actName := 'change';
         if CharAt(AnID,1) = 'C' then actName := 'copy';
-        x := 'You can not ' + actName + ' the clinical medication order.';
+        x := 'You cannot ' + actName + ' the clinical medication order.';
         x := RetrieveOrderText(Copy(AnID, 2, Length(AnID))) + #13#13#10 + x;
         UnlockOrder(Copy(AnID, 2, Length(AnID)));
@@ -1774,5 +1809,5 @@
       if (not AllowActionOnIMO(AnEventType)) then
       begin
-        x := 'You can not renew the the clinical medication order.';
+        x := 'You cannot renew the clinical medication order.';
         x := RetrieveOrderText(Piece(AnID,'^',2)) + #13#13#10 + x;
         UnlockOrder(Piece(AnID,'^',2));
@@ -1809,3 +1844,4 @@
   OriginalMedsInHeight    := 0;
   OriginalNonVAMedsHeight := 0;
+
 end.
