Index: cprs/branches/foia-cprs/CPRS-Chart/fEncnt.pas
===================================================================
--- cprs/branches/foia-cprs/CPRS-Chart/fEncnt.pas	(revision 459)
+++ cprs/branches/foia-cprs/CPRS-Chart/fEncnt.pas	(revision 460)
@@ -23,11 +23,12 @@
     lblLocation: TLabel;
     txtLocation: TCaptionEdit;
+    dlgDateRange: TORDateRangeDlg;
+    cmdDateRange: TButton;
+    lblInstruct: TLabel;
+    Panel1: TPanel;
     pgeVisit: TPageControl;
     tabClinic: TTabSheet;
-    lblClinic: TLabel;
-    lblDateRange: TLabel;
     lstClinic: TORListBox;
     tabAdmit: TTabSheet;
-    lblAdmit: TLabel;
     lstAdmit: TORListBox;
     tabNewVisit: TTabSheet;
@@ -37,7 +38,9 @@
     ckbHistorical: TORCheckBox;
     cboNewVisit: TORComboBox;
-    dlgDateRange: TORDateRangeDlg;
-    cmdDateRange: TButton;
-    lblInstruct: TLabel;
+    Panel2: TPanel;
+    lblDateRange: TLabel;
+    lblClinic: TLabel;
+    Panel3: TPanel;
+    lblAdmit: TLabel;
     procedure FormCreate(Sender: TObject);
     procedure pgeVisitChange(Sender: TObject);
@@ -57,4 +60,6 @@
     procedure lstAdmitChange(Sender: TObject);
     procedure lstClinicChange(Sender: TObject);
+    procedure FormResize(Sender: TObject);
+    procedure FormShow(Sender: TObject);
   private
     CLINIC_TXT : String;
@@ -241,8 +246,14 @@
   inherited;
   cmdDateRange.Visible := pgeVisit.ActivePage = tabClinic;
-  if (pgeVisit.ActivePage = tabClinic) and (lstClinic.Items.Count = 0)
-    then ListApptAll(lstClinic.Items, Patient.DFN, FFromDate, FThruDate);
-  if (pgeVisit.ActivePage = tabAdmit)    and (lstAdmit.Items.Count = 0)
-    then ListAdmitAll(lstAdmit.Items, Patient.DFN);
+  if (pgeVisit.ActivePage = tabClinic) and (lstClinic.Items.Count = 0) then
+  begin
+    ListApptAll(lstClinic.Items, Patient.DFN, FFromDate, FThruDate);
+    ActiveControl := lstClinic;
+  end;
+  if (pgeVisit.ActivePage = tabAdmit)    and (lstAdmit.Items.Count = 0) then
+  begin
+    ListAdmitAll(lstAdmit.Items, Patient.DFN);
+    ActiveControl := lstAdmit;
+  end;
   if pgeVisit.ActivePage = tabNewVisit then
   begin
@@ -255,4 +266,5 @@
           cboNewVisit.InitLongList(uTIULocationName);
           cboNewVisit.SelectByIEN(uTIULocation);
+          cboNewVisitChange(Self);
         end
         else
@@ -264,7 +276,18 @@
         with calVisitDate do if FDateTime <> 0 then FMDateTime := FDateTime else Text := 'NOW';
         FFromSelf := False;
+        ActiveControl := cboNewVisit;
       end
-      else cboNewVisit.InitLongList('');
-      ckbHistorical.Checked := FVisitCategory = 'E';
+      else if FVisitCategory = 'E' then
+      begin
+        ckbHistorical.Checked := True;
+        ActiveControl := cboNewVisit;
+      end
+      else
+      begin
+        cboNewVisit.InitLongList('');
+        //ActiveControl := cboPtProvider;
+      end;
+      //ckbHistorical.Checked := FVisitCategory = 'E';
+      //ActiveControl := cboNewVisit;
     end; {if cboNewVisit}
   end; {if pgeVisit.ActivePage}
@@ -473,3 +496,45 @@
 end;
 
+procedure TfrmEncounter.FormResize(Sender: TObject);
+begin
+  //CQ7118
+  if cboPtProvider.Visible then
+     begin
+     cmdOK.Left := cboPtProvider.Left + cboPtProvider.Width + 1;
+     cmdCancel.Left := cboPtProvider.Left + cboPtProvider.Width + 1;
+     end
+  else
+     begin
+     cmdOK.Left := cmdDateRange.Left;
+     cmdCancel.Left := cmdDateRange.Left;
+     end;
+
+  cmdCancel.Top := cmdDateRange.Top - cmdCancel.Height - 10;
+  cmdOK.Top := cmdCancel.Top - cmdOK.Height - 1;
+
+  cmdCancel.Top := cmdOK.Top + cmdOK.Height + 1;
+  cmdCancel.Width := cmdOK.Width;
+  //end CQ7118
+end;
+
+procedure TfrmEncounter.FormShow(Sender: TObject);
+begin
+  //CQ7118
+  if cboPtProvider.Visible then
+     begin
+     cmdOK.Left := cboPtProvider.Left + cboPtProvider.Width + 1;
+     cmdCancel.Left := cboPtProvider.Left + cboPtProvider.Width + 1;
+     end
+  else
+     begin
+     cmdOK.Left := cmdDateRange.Left;
+     cmdCancel.Left := cmdDateRange.Left;
+     end;
+
+  cmdCancel.Top := cmdDateRange.Top - cmdCancel.Height - 10;
+  cmdOK.Top := cmdCancel.Top - cmdOK.Height - 1;
+  cmdCancel.Top := cmdOK.Top + cmdOK.Height + 1;
+  //end CQ7118
+end;
+
 end.
