Index: cprs/trunk/CPRS-Chart/Orders/fODRad.pas
===================================================================
--- cprs/trunk/CPRS-Chart/Orders/fODRad.pas	(revision 456)
+++ cprs/trunk/CPRS-Chart/Orders/fODRad.pas	(revision 829)
@@ -6,5 +6,5 @@
   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
   Forms, Dialogs, StdCtrls, ORCtrls, fODBase, ORFn, ExtCtrls,
-  ComCtrls, uConst, ORDtTm;
+  ComCtrls, uConst, ORDtTm, VA508AccessibilityManager;
 
 type
@@ -22,6 +22,6 @@
     cboSubmit: TORComboBox;
     lstLastExam: TORListBox;
-    lblReason: TLabel;
-    memReason: TCaptionMemo;
+    lblHistory: TLabel;
+    memHistory: TCaptionMemo;
     lstSelectMod: TORListBox;
     lblSelectMod: TLabel;
@@ -46,4 +46,7 @@
     radPregnantNo: TRadioButton;
     radPregnantUnknown: TRadioButton;
+    lblReason: TLabel;
+    txtReason: TCaptionEdit;
+    pnlRightBase: TORAutoPanel;
     procedure cboProcedureNeedData(Sender: TObject;
               const StartFrom: string; Direction, InsertAt: Integer);
@@ -56,5 +59,5 @@
     procedure FormCreate(Sender: TObject);
     procedure cboImTypeChange(Sender: TObject);
-    procedure memReasonExit(Sender: TObject);
+    procedure memHistoryExit(Sender: TObject);
     procedure FormResize(Sender: TObject);
     procedure cboAvailModKeyDown(Sender: TObject; var Key: Word;
@@ -97,6 +100,10 @@
   TX_NO_PROC          = 'An Imaging Procedure must be specified.'    ;
   TX_NO_MODE          = 'A mode of transport must be selected.';
-  TX_NO_REASON        = 'A History & Reason for Exam must be entered.'  ;
-  TX_NO_DATE          = 'Unable to evaluate request date.' ;
+  TX_NO_REASON        = 'A Reason for Study must be entered.'  ;
+  TX_BAD_HISTORY      = 'An incomplete or invalid Clinical History has been entered.' + CRLF +
+                        'Please correct or clear.';
+  TX_NO_DATE          = 'A "Date Desired" must be specified.' ;
+  TX_BAD_DATE         = 'The "Date Desired" you have entered is invalid.';
+  TX_PAST_DATE        = '"Date Desired" must not be in the past.';
   TX_APPROVAL_REQUIRED= 'This procedure requires Radiologist approval.' ;
   TX_NO_SOURCE        = 'A source must be specified for Contract/Sharing/Research patients.';
@@ -131,5 +138,5 @@
     with cboImType do
       begin
-        Items.Assign(SubsetOfImagingTypes);
+        FastAssign(SubsetOfImagingTypes, cboImType.Items);
         for i := 0 to Items.Count-1 do
           if StrToIntDef(Piece(Items[i],U,4), 0) = DisplayGroup then ItemIndex := i;
@@ -151,5 +158,6 @@
     SetControl(cboSubmit,          'IMLOC', 1);
     SetControl(cboCategory,        'CLASS', 1);
-    SetControl(memReason,          'COMMENT', 1);
+    SetControl(txtReason,           'REASON', 1);
+    SetControl(memHistory,         'COMMENT', 1);
     SetControl(chkIsolation,       'YN', 1);
     SetControl(radPregnant,        'PREGNANT', 1);
@@ -214,5 +222,9 @@
    tmplst: TStringList;
 begin
-  if not FEditCopy then inherited;
+  if not FEditCopy then
+  begin
+    inherited;
+    if not ReasonForStudyCarryOn then txtReason.text := '';
+  end;
 
   FPreOpDate := '';
@@ -236,5 +248,5 @@
     if FRadCommonCombo.Items.Count>0 then cboProcedure.InsertSeparator;
 
-    calRequestDate.Text := 'TODAY';
+    //calRequestDate.Text := 'TODAY';     default removed per E3R #19834 - v27.10 - RV
     SetControl(cboAvailMod, 'Modifiers');
     SetControl(cboUrgency, 'Urgencies');
@@ -262,7 +274,7 @@
             tmplst := TStringList.Create;
             try
-              tmplst.Assign(cboSubmit.Items);
+              FastAssign(cboSubmit.Items, tmplst);
               SortByPiece(tmplst, U, 2);
-              cboSubmit.Items.Assign(tmplst);
+              FastAssign(tmplst, cboSubmit.Items);
             finally
               tmplst.Free;
@@ -299,4 +311,5 @@
   cboProcedure.InitLongList('') ;
   StatusText('');
+  
 end;
 
@@ -326,5 +339,6 @@
                                              else Responses.Update('YN',        1, '0'   , 'No');
   with calPreOp do if Length(Text) > 0       then Responses.Update('PREOP',     1, FPreOpDate, Text);
-  with memReason do if GetTextLen        > 0 then Responses.Update('COMMENT',   1, TX_WPTYPE, Text);
+  with txtReason  do if GetTextLen        > 0 then Responses.Update('REASON',    1, Text, Text);
+  with memHistory do if GetTextLen       > 0 then Responses.Update('COMMENT',   1, TX_WPTYPE, Text);
   with lstSelectMod do for i := 0 to Items.Count - 1 do
                                                   Responses.Update('MODIFIER',i+1, Piece(Items[i],U,1), Piece(Items[i],U,2));
@@ -380,7 +394,34 @@
         end ;
     end;
+
+  if Length(txtReason.Text) < 3 then
+    SetError(TX_NO_REASON)
+  else
+    begin
+      j := 0;
+      for i := 1 to Length(txtReason.Text) do
+        begin
+          if txtReason.Text[i] in ['A'..'Z','a'..'z','0'..'9'] then j := j + 1;
+          if not (txtReason.Text[i] in ['A'..'Z','a'..'z','0'..'9']) and (j > 0) then j := 0;
+          if j = 2 then break;
+        end;
+      if j < 2 then SetError(TX_NO_REASON);
+    end;
+
+  if Length(memHistory.Text) > 0 then
+  begin
+    j := 0;
+    for i := 1 to Length(memHistory.Text) do
+      begin
+        if memHistory.Text[i] in ['A'..'Z','a'..'z','0'..'9'] then j := j + 1;
+        if not (memHistory.Text[i] in ['A'..'Z','a'..'z','0'..'9']) and (j > 0) then j := 0;
+        if j = 2 then break;
+      end;
+    if j < 2 then SetError(TX_BAD_HISTORY);
+  end;
+
   with cboCategory do
     begin
-      AskLoc := True;
+      AskLoc := (ALocation = 0);
       if ((not Patient.Inpatient) and (Self.EvtType = 'A')) then
         AskLoc := False;
@@ -401,23 +442,16 @@
   if Length(cboTransport.Text) = 0 then SetError(TX_NO_MODE);
 
-  if Length(memReason.Text) < 2 then
-    SetError(TX_NO_REASON)
-  else
-    begin
-      j := 0;
-      for i := 1 to Length(memReason.Text) do
-        begin
-          if memReason.Text[i] in ['A'..'Z','a'..'z','0'..'9'] then j := j + 1;
-          if not (memReason.Text[i] in ['A'..'Z','a'..'z','0'..'9']) and (j > 0) then j := 0;
-          if j = 2 then break;
-        end;
-      if j < 2 then SetError(TX_NO_REASON);
-    end;
-
   with cboSubmit do
     if Enabled and (ItemIEN = 0)then SetError(TX_NO_IMAGING_LOCATION);
 
   with calRequestDate do
-    if FMDateTime = 0 then SetError(TX_NO_DATE);
+  begin
+    if FMDateTime = 0 then
+      SetError(TX_NO_DATE)
+    else if FMDateTime < 0 then
+      SetError(TX_BAD_DATE)
+    else if FMDateTime < FMToday then
+      SetError(TX_PAST_DATE);
+  end;
 
 end;
@@ -492,5 +526,5 @@
     ClearControl(lstSelectMod);
     ClearControl(lstLastExam);
-    //ClearControl(memReason);    {WPB-1298-30758}
+    //ClearControl(memHistory);    {WPB-1298-30758}
     Changing := False;
     if CharAt(ItemID, 1) = 'Q' then
@@ -513,5 +547,6 @@
     SetControl(cboTransport,       'MODE', 1);
     SetControl(cboCategory,        'CLASS', 1);
-    SetControl(memReason,          'COMMENT', 1);
+    SetControl(txtReason,           'REASON', 1);
+    SetControl(memHistory,         'COMMENT', 1);
     SetControl(chkIsolation,       'YN', 1);
     SetControl(radPregnant,        'PREGNANT', 1);
@@ -581,6 +616,6 @@
   AutoSizeDisabled := True;
   inherited;
-  memReason.Width := pnlHandR.ClientWidth;
-  memReason.Height := pnlHandR.ClientHeight - memReason.Top;
+  memHistory.Width := pnlHandR.ClientWidth;
+  memHistory.Height := pnlHandR.ClientHeight - memHistory.Top;
   FillerID := 'RA';                     // does 'on Display' order check **KCM**
   StatusText('Loading Dialog Definition');
@@ -590,5 +625,5 @@
   Responses.Dialog := 'RA OERR EXAM';              // loads formatting info
   StatusText('Loading Default Values');
-  cboImType.Items.Assign(SubsetOfImagingTypes);
+  FastAssign(SubsetOfImagingTypes, cboImType.Items);
   if Self.EvtID>0 then
     FEvtDelayDiv := GetEventDiv1(IntToStr(Self.EvtID));
@@ -600,5 +635,6 @@
   PreserveControl(cboCategory);
   PreserveControl(calPreOp);
-  PreserveControl(memReason);      {WPB-1298-30758}
+  PreserveControl(txtReason);
+  PreserveControl(memHistory);      {WPB-1298-30758}
   if (Patient.Sex <> 'F') then
   begin
@@ -619,5 +655,5 @@
 end;
 
-procedure TfrmODRad.memReasonExit(Sender: TObject);
+procedure TfrmODRad.memHistoryExit(Sender: TObject);
 var
   AStringList: TStringList;
@@ -626,7 +662,7 @@
   AStringList := TStringList.Create;
   try
-    AStringList.Assign(memReason.Lines);
+    FastAssign(memHistory.Lines, AStringList);
     LimitStringLength(AStringList, 74);
-    memReason.Lines.Assign(AstringList);
+    FastAssign(AstringList, memHistory.Lines);
     ControlChange(Self);
   finally
@@ -638,6 +674,6 @@
 begin
   inherited;
-  memReason.Width := pnlHandR.ClientWidth;
-  memReason.Height := pnlHandR.ClientHeight - memReason.Top;
+  memHistory.Width := pnlHandR.ClientWidth;
+  memHistory.Height := pnlHandR.ClientHeight - memHistory.Top;
 end;
 
