Index: cprs/trunk/CPRS-Chart/fMeds.pas
===================================================================
--- cprs/trunk/CPRS-Chart/fMeds.pas	(revision 830)
+++ cprs/trunk/CPRS-Chart/fMeds.pas	(revision 1679)
@@ -1,3 +1,3 @@
-unit fMeds;
+                                                                       unit fMeds;
 
 {$OPTIMIZATION OFF}                              // REMOVE AFTER UNIT IS DEBUGGED
@@ -89,4 +89,5 @@
     pnlView: TPanel;
     txtView: TVA508StaticText;
+    mnuActUnhold: TMenuItem;
     procedure mnuChartTabClick(Sender: TObject);
     procedure FormCreate(Sender: TObject);
@@ -157,4 +158,5 @@
     procedure SortbyDrugalphabeticallystatusactivestatusrecentexpired1Click(
       Sender: TObject);
+    procedure mnuActUnholdClick(Sender: TObject);
   private
     FIterating: Boolean;
@@ -238,5 +240,5 @@
 implementation
 
-uses uCore, rCore, fFrame, fRptBox, uOrders, fODBase, fOrdersDC, fOrdersHold,
+uses uCore, rCore, fFrame, fRptBox, uOrders, fODBase, fOrdersDC, fOrdersHold, fOrdersUnhold,
      fOrdersRenew, fOMNavA, fOrdersRefill, fMedCopy, fOrders, fODChild, rODBase, 
      StrUtils, fActivateDeactivate, VA2006Utils, VA508AccessibilityRouter,
@@ -268,5 +270,7 @@
   TC_NO_RENEW   = 'Unable to Renew Order';
   TX_NO_HOLD    = CRLF + CRLF + '- cannot be placed on hold.' + CRLF + CRLF + 'Reason:  ';
-  TC_NO_HOLD    = 'Unable to Hold';
+  TC_NO_HOLD    = 'Unable to Hold';  
+  TX_NO_UNHOLD  = CRLF + CRLF + '- cannot be released from hold.' + CRLF + CRLF + 'Reason: ';
+  TC_NO_UNHOLD  = 'Unable to Release from Hold';
   TX_NO_COPY    = CRLF + CRLF + '- cannot be copied.' + CRLF + CRLF + 'Reason: ';
   TC_NO_COPY    = 'Unable to Copy Order';
@@ -729,21 +733,22 @@
 procedure TfrmMeds.RefreshMedLists;
 var
-  i,view: Integer;
+  i, view: Integer;
   AMed: TMedListRec;
-begin
+  DateRange: string;
+begin
+  if frmFrame.TimedOut then Exit;  
   lstMedsIn.Clear;
   lstMedsOut.Clear;
   lstMedsNonVA.Clear;
+  DateRange := '';
   StatusText('Retrieving active medications...');
   view := self.FSortView;
   //AGP Fix for CQ 10410 added view arguement to control Meds Tab sort criteria
-  LoadActiveMedLists(uMedListIn, uMedListOut, uMedListNonVA, view);
-  if view <> self.FSortView then
-    begin
+  LoadActiveMedLists(uMedListIn, uMedListOut, uMedListNonVA, view, DateRange);
       self.FSortView := view;
       if view = 1 then
         begin
           self.SortbyStatusthenLocation1.Checked := True;
-          SetViewCaption(SortbyStatusthenLocation1.Caption);
+          SetViewCaption(SortbyStatusthenLocation1.Caption + ' ' + DateRange);
           self.SortbyClinicOrderthenStatusthenStopDate1.Checked := False;
           self.SortbyDrugalphabeticallystatusactivestatusrecentexpired1.checked := false;
@@ -753,5 +758,5 @@
           self.SortbyStatusthenLocation1.Checked := False;
           self.SortbyClinicOrderthenStatusthenStopDate1.Checked := True;
-          SetViewCaption(SortbyClinicOrderthenStatusthenStopDate1.Caption);
+          SetViewCaption(SortbyClinicOrderthenStatusthenStopDate1.Caption + ' ' + DateRange);
           self.SortbyDrugalphabeticallystatusactivestatusrecentexpired1.Checked := false;
         end
@@ -761,7 +766,6 @@
           self.SortbyClinicOrderthenStatusthenStopDate1.Checked := false;
           self.SortbyDrugalphabeticallystatusactivestatusrecentexpired1.Checked := true;
-          SetViewCaption(SortbyDrugalphabeticallystatusactivestatusrecentexpired1.Caption);
-        end
-    end;
+          SetViewCaption(SortbyDrugalphabeticallystatusactivestatusrecentexpired1.Caption + ' ' + DateRange);
+        end;
   uPharmacyOrdersIn.Clear;
   uPharmacyOrdersOut.Clear;
@@ -808,4 +812,6 @@
     else if Abbreviation = 'DL' then result := 'Deleted'
     else if Abbreviation = 'DC' then result := 'DC'
+    else if Abbreviation = 'UH' then result := 'Unhold'
+         
     else result := Abbreviation;
   end;
@@ -1147,5 +1153,4 @@
       if ExecuteDCOrders(SelectedList,DelEvt) then
       begin
-        if frmFrame.TimedOut = true then  exit;
         ResetSelectedForList(ActiveList);
         SynchListToOrders(ActiveList, SelectedList);
@@ -1181,5 +1186,4 @@
       if ExecuteHoldOrders(SelectedList) then
       begin
-        if frmFrame.TimedOut = true then  exit;
         AddSelectedToChanges(SelectedList);
         ResetSelectedForList(ActiveList);
@@ -1188,5 +1192,5 @@
     end;
   finally
-    if frmFrame.TimedOut = false then ActiveList.SetFocus;
+    ActiveList.SetFocus;
     FIterating := False;
     SelectedList.Free;
@@ -1226,5 +1230,4 @@
       if ExecuteRenewOrders(SelectedList) then
       begin
-        if frmFrame.TimedOut = true then  exit;
         AddSelectedToChanges(SelectedList);
         ResetSelectedForList(ActiveList);
@@ -1233,5 +1236,35 @@
    end;
   finally
-    if frmFrame.TimedOut = false then ActiveList.SetFocus;
+    ActiveList.SetFocus;
+    FIterating := False;
+    SelectedList.Free;
+    UnlockIfAble;
+  end;
+end;
+
+procedure TfrmMeds.mnuActUnholdClick(Sender: TObject);
+var    
+  ActiveList: TListBox;
+  SelectedList: TList;
+begin
+  inherited;
+  ActiveList := ListSelected(TX_NOSEL);
+  if ActiveList = nil then Exit;
+  if not AuthorizedUser then Exit;
+  if not EncounterPresent then Exit;
+  if not LockedForOrdering then Exit;
+  SelectedList := TList.Create;
+  try
+    if CheckMedStatus(ActiveList) = True then Exit;
+    ValidateSelected(ActiveList, OA_UNHOLD, TX_NO_UNHOLD, TC_NO_UNHOLD);  // validate release hold action
+    MakeSelectedList(ActiveList, SelectedList);                           // build list of selected orders
+    if ExecuteUnholdOrders(SelectedList) then
+    begin
+      AddSelectedToChanges(SelectedList);   
+      ResetSelectedForList(ActiveList);
+      SynchListToOrders(ActiveList, SelectedList);
+    end;
+  finally  
+    ActiveList.SetFocus;
     FIterating := False;
     SelectedList.Free;
@@ -1268,5 +1301,4 @@
     if not ShowMsgOn(ChangeIFNList.Count = 0, TX_NOSEL, TC_NOSEL)
       then ChangeOrders(ChangeIFNList, DelayEvent);
-    if frmFrame.TimedOut = true then  exit;
     SynchListToOrders(ActiveList, SelectedList);    // rehighlights
     Activelist.SetFocus;
@@ -1282,5 +1314,5 @@
 const
   CP_TXT = 'copied';
-  XF_TXT = 'transfered';
+  XF_TXT = 'transferred';
 var
   i: Integer;
@@ -1420,5 +1452,4 @@
       end;
     end;
-    if frmFrame.TimedOut = true then  exit;
     SynchListToOrders(ActiveList, SelectedList);    // rehighlights
     if IsTransferAction then
@@ -1430,5 +1461,5 @@
     frmOrders.PtEvtCompleted(TempEvent.PtEventIFN,TempEvent.EventName,True);
   finally
-    if frmFrame.TimedOut = false then  ActiveList.SetFocus;
+    ActiveList.SetFocus;
     FActionOnMedsTab := False;
     uAutoAC := False;
@@ -1489,5 +1520,4 @@
       if ExecuteRefillOrders(SelectedList) then
       begin
-        if frmFrame.TimedOut = true then  exit;
         ResetSelectedForList(ActiveList);
         SynchListToOrders(ActiveList, SelectedList);
@@ -1495,5 +1525,5 @@
     end;
   finally
-    if frmFrame.TimedOut = false then ActiveList.SetFocus;
+    ActiveList.SetFocus;
     FIterating := False;
     SelectedList.Free;
@@ -1590,5 +1620,5 @@
         if (AnOrder.DGroup = ClinDisp) then                          //imo
         begin
-          x := AnOrder.Text +  #13#10 + 'Clinic medication orders can not be transfered';
+          x := AnOrder.Text +  #13#10 + 'Clinic medication orders can not be transferred';
           if ShowMsgOn(Length(x) > 0, x, 'Unable to transfer.') then
           begin
@@ -2150,8 +2180,4 @@
   inherited;
   self.FSortView := 1;
-  self.SortbyStatusthenLocation1.Checked := True;
-  SetViewCaption(SortbyStatusthenLocation1.Caption);
-  self.SortbyClinicOrderthenStatusthenStopDate1.Checked := False;
-  self.SortbyDrugalphabeticallystatusactivestatusrecentexpired1.Checked := false;
   self.RefreshMedLists;
 end;
@@ -2162,8 +2188,4 @@
   inherited;
   self.FSortView := 2;
-  self.SortbyStatusthenLocation1.Checked := False;
-  self.SortbyClinicOrderthenStatusthenStopDate1.Checked := True;
-  SetViewCaption(SortbyClinicOrderthenStatusthenStopDate1.Caption);
-  self.SortbyDrugalphabeticallystatusactivestatusrecentexpired1.Checked := false;
   self.RefreshMedLists;
 end;
@@ -2174,8 +2196,4 @@
   inherited;
   self.FSortView := 3;
-  self.SortbyStatusthenLocation1.Checked := False;
-  self.SortbyClinicOrderthenStatusthenStopDate1.Checked := false;
-  self.SortbyDrugalphabeticallystatusactivestatusrecentexpired1.Checked := true;
-  SetViewCaption(SortbyDrugalphabeticallystatusactivestatusrecentexpired1.Caption);
   self.RefreshMedLists;
 end;
