Index: cprs/branches/HealthSevak-CPRS/CPRS-Chart/Orders/fODGen.pas
===================================================================
--- cprs/branches/HealthSevak-CPRS/CPRS-Chart/Orders/fODGen.pas	(revision 1676)
+++ cprs/branches/HealthSevak-CPRS/CPRS-Chart/Orders/fODGen.pas	(revision 1693)
@@ -22,7 +22,10 @@
   TfrmODGen = class(TfrmODBase)
     sbxMain: TScrollBox;
+    lblOrderSig: TLabel;
+    VA508CompMemOrder: TVA508ComponentAccessibility;
     procedure FormCreate(Sender: TObject);
     procedure FormClose(Sender: TObject; var Action: TCloseAction);
     procedure cmdAcceptClick(Sender: TObject);
+    procedure VA508CompMemOrderStateQuery(Sender: TObject; var Text: string);
   private
     FilterOut: boolean;
@@ -35,14 +38,15 @@
       Direction, InsertAt: Integer);
     procedure PlaceControls;
-    procedure PlaceDateTime(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem);
-    procedure PlaceFreeText(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem);
+    procedure PlaceDateTime(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem; CurrentItemNumber: Integer);
+    procedure PlaceFreeText(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem; CurrentItemNumber: Integer);
     procedure PlaceHidden(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem);
-    procedure PlaceNumeric(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem);
-    procedure PlaceSetOfCodes(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem);
-    procedure PlaceYesNo(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem);
-    procedure PlaceLookup(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem);
-    procedure PlaceMemo(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem);
+    procedure PlaceNumeric(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem; CurrentItemNumber: Integer);
+    procedure PlaceSetOfCodes(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem; CurrentItemNumber: Integer);
+    procedure PlaceYesNo(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem; CurrentItemNumber: Integer);
+    procedure PlaceLookup(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem; CurrentItemNumber: Integer);
+    procedure PlaceMemo(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem; CurrentItemNumber: Integer);
     procedure PlaceLabel(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem);
     procedure TrimAllMemos;
+    function SetComponentName(Editor: TWinControl; Index: Integer; DialogCtrl: TDialogCtrl): Boolean;
   protected
     FFormCloseCalled : Boolean;
@@ -84,5 +88,5 @@
   IDs,TSstr, AttendStr: string;
 begin
-  FFormCloseCalled := false;
+  FFormCloseCalled := false;   
   inherited;
   FilterOut := True;
@@ -243,4 +247,11 @@
 end;
 
+procedure TfrmODGen.VA508CompMemOrderStateQuery(Sender: TObject;
+  var Text: string);
+begin
+  inherited;
+  Text := memOrder.Text;
+end;
+
 procedure TfrmODGen.Validate(var AnErrMsg: string);
 var
@@ -328,13 +339,13 @@
     DialogCtrl.Preserve := Length(DialogItem.EDefault) > 0;
     case DialogItem.DataType of
-    'D': PlaceDateTime(DialogCtrl, DialogItem);
-    'F': PlaceFreeText(DialogCtrl, DialogItem);
+    'D': PlaceDateTime(DialogCtrl, DialogItem, I);
+    'F': PlaceFreeText(DialogCtrl, DialogItem, i);
     'H': PlaceHidden(DialogCtrl, DialogItem);
-    'N': PlaceNumeric(DialogCtrl, DialogItem);
-    'P': PlaceLookup(DialogCtrl, DialogItem);
-    'R': PlaceDateTime(DialogCtrl, DialogItem);
-    'S': PlaceSetOfCodes(DialogCtrl, DialogItem);
-    'W': PlaceMemo(DialogCtrl, DialogItem);
-    'Y': PlaceYesNo(DialogCtrl, DialogItem);
+    'N': PlaceNumeric(DialogCtrl, DialogItem, i);
+    'P': PlaceLookup(DialogCtrl, DialogItem, i);
+    'R': PlaceDateTime(DialogCtrl, DialogItem, i);
+    'S': PlaceSetOfCodes(DialogCtrl, DialogItem, i);
+    'W': PlaceMemo(DialogCtrl, DialogItem, i);
+    'Y': PlaceYesNo(DialogCtrl, DialogItem, i);
     end;
     FDialogCtrlList.Add(DialogCtrl);
@@ -343,5 +354,5 @@
 end;
 
-procedure TfrmODGen.PlaceDateTime(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem);
+procedure TfrmODGen.PlaceDateTime(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem; CurrentItemNumber: Integer);
 const
   NUM_CHAR = 22;
@@ -354,4 +365,6 @@
     TORDateBox(Editor).DateOnly := Pos('T', DialogItem.Domain) = 0;
     with TORDateBox(Editor) do RequireTime := (not DateOnly) and (Pos('R', DialogItem.Domain) > 0); //v26.48 - RV  PSI-05-002
+    SetComponentName(Editor, CurrentItemNumber, DialogCtrl);
+  //  TORDateBox(Editor).Name := DialogCtrl.ID + IntToStr(CurrentItemNumber);
     TORDateBox(Editor).Text := DialogItem.EDefault;
     TORDateBox(Editor).Hint := DialogItem.HelpText;
@@ -364,5 +377,5 @@
 end;
 
-procedure TfrmODGen.PlaceFreeText(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem);
+procedure TfrmODGen.PlaceFreeText(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem; CurrentItemNumber: Integer);
 begin
   with DialogCtrl do
@@ -374,4 +387,6 @@
                      HT_FRAME * FCharHt);
     TEdit(Editor).MaxLength := StrToIntDef(Piece(DialogItem.Domain, ':', 2), 0);
+    SetComponentName(Editor, CurrentItemNumber, DialogCtrl);
+  //  TCaptionEdit(Editor).Name := DialogCtrl.ID + IntToStr(CurrentItemNumber);
     TEdit(Editor).Text := DialogItem.EDefault;
     TEdit(Editor).Hint := DialogItem.HelpText;
@@ -384,5 +399,5 @@
 end;
 
-procedure TfrmODGen.PlaceNumeric(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem);
+procedure TfrmODGen.PlaceNumeric(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem; CurrentItemNumber: Integer);
 const
   NUM_CHAR = 16;
@@ -394,4 +409,6 @@
     Editor.SetBounds(FEditorLeft, FEditorTop, NUM_CHAR * FCharWd, HT_FRAME * FCharHt);
     TEdit(Editor).MaxLength := NUM_CHAR;
+    SetComponentName(Editor, CurrentItemNumber, DialogCtrl);
+   // TCaptionEdit(Editor).Name := DialogCtrl.ID + IntToStr(CurrentItemNumber);
     TEdit(Editor).Text := DialogItem.EDefault;
     TEdit(Editor).Hint := DialogItem.HelpText + '|' + DialogItem.Domain;
@@ -404,5 +421,5 @@
 end;
 
-procedure TfrmODGen.PlaceSetOfCodes(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem);
+procedure TfrmODGen.PlaceSetOfCodes(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem; CurrentItemNumber: Integer);
 const
   NUM_CHAR = 32;
@@ -417,4 +434,6 @@
     TORComboBox(Editor).ListItemsOnly := True;
     TORComboBox(Editor).Pieces := '2';
+    SetComponentName(Editor, CurrentItemNumber, DialogCtrl);
+  //  TORComboBox(Editor).Name := DialogCtrl.ID + IntToStr(CurrentItemNumber);
     Editor.SetBounds(FEditorLeft, FEditorTop, NUM_CHAR * FCharWd, HT_FRAME * FCharHt);
     x := DialogItem.Domain;
@@ -427,5 +446,5 @@
     TORComboBox(Editor).SelectByID(DialogItem.IDefault);
     //TORComboBox(Editor).Text := DialogItem.EDefault;
-    TORComboBox(Editor).Hint := DialogItem.HelpText;
+    TORComboBox(Editor).RpcCall := DialogItem.HelpText;
     if Length(DialogItem.HelpText) > 0 then TORComboBox(Editor).ShowHint := True;
     TORComboBox(Editor).OnChange := ControlChange;
@@ -435,5 +454,5 @@
 end;
 
-procedure TfrmODGen.PlaceYesNo(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem);
+procedure TfrmODGen.PlaceYesNo(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem; CurrentItemNumber: Integer);
 const
   NUM_CHAR = 9;
@@ -446,4 +465,6 @@
     TORComboBox(Editor).ListItemsOnly := True;
     TORComboBox(Editor).Pieces := '2';
+    SetComponentName(Editor, CurrentItemNumber, DialogCtrl);
+    //TORComboBox(Editor).Name := DialogCtrl.ID + IntToStr(CurrentItemNumber);
     Editor.SetBounds(FEditorLeft, FEditorTop, NUM_CHAR * FCharWd, HT_FRAME * FCharHt);
     TORComboBox(Editor).Items.Add('0^No');
@@ -451,5 +472,5 @@
     TORComboBox(Editor).SelectByID(DialogItem.IDefault);
     //TORComboBox(Editor).Text := DialogItem.EDefault;
-    TORComboBox(Editor).Hint := DialogItem.HelpText;
+    TORComboBox(Editor).RpcCall := DialogItem.HelpText;
     if Length(DialogItem.HelpText) > 0 then TORComboBox(Editor).ShowHint := True;
     TORComboBox(Editor).OnChange := ControlChange;
@@ -459,5 +480,5 @@
 end;
 
-procedure TfrmODGen.PlaceLookup(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem);
+procedure TfrmODGen.PlaceLookup(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem; CurrentItemNumber: Integer);
 const
   NUM_CHAR = 32;
@@ -482,6 +503,8 @@
     TORComboBox(Editor).Pieces := '2';
     TORComboBox(Editor).LongList := True;
+     SetComponentName(Editor, CurrentItemNumber, DialogCtrl);
+   // TORComboBox(Editor).Name := DialogCtrl.ID + IntToStr(CurrentItemNumber);
     // 2nd bar piece of hint is not visible, hide xref, global ref, & screen code in tab pieces
-    TORComboBox(Editor).Hint := DialogItem.HelpText + '|' + XRef + #9 + GblRef + #9 +
+    TORComboBox(Editor).RpcCall := DialogItem.HelpText + '|' + XRef + #9 + GblRef + #9 +
                                 DialogItem.ScreenRef;
     if ( compareText(TsID,DialogItem.Id)=0 ) or (compareText(TSDomain,DialogItem.Domain)=0)then
@@ -538,5 +561,5 @@
 begin
   inherited;
-  XRef := Piece(TORComboBox(Sender).Hint, '|', 2);
+  XRef := Piece(TORComboBox(Sender).RpcCall, '|', 2);
   GblRef    := Piece(XRef, #9, 2);
   ScreenRef := Piece(XRef, #9, 3);
@@ -545,5 +568,5 @@
 end;
 
-procedure TfrmODGen.PlaceMemo(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem);
+procedure TfrmODGen.PlaceMemo(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem; CurrentItemNumber: Integer);
 const
   NUM_LINES = 3;
@@ -556,4 +579,6 @@
                      sbxMain.Width - FEditorLeft - WD_MARGIN - GetSystemMetrics(SM_CXVSCROLL),
                      (FCharHt * NUM_LINES) + HT_FRAME);
+    SetComponentName(Editor, CurrentItemNumber, DialogCtrl);
+   // TCaptionMemo(Editor).Name := DialogCtrl.ID + IntToStr(CurrentItemNumber);
     TMemo(Editor).Text := DialogItem.EDefault;
     TMemo(Editor).Hint := DialogItem.HelpText;
@@ -574,4 +599,6 @@
 
 procedure TfrmODGen.PlaceLabel(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem);
+var
+  ht: integer;
 begin
   with DialogCtrl do
@@ -580,6 +607,9 @@
     Prompt.Parent := sbxMain;
     Prompt.Caption := DialogItem.Prompt;
+    ht := Prompt.Height;   // CQ#15849
+    if ht < FCharHt then
+      ht := FCharHt;
     Prompt.AutoSize := False;
-    Prompt.SetBounds(WD_MARGIN, FEditorTop + HT_LBLOFF, FLabelWd, FCharHt);
+    Prompt.SetBounds(WD_MARGIN, FEditorTop + HT_LBLOFF, FLabelWd, ht);
     Prompt.Alignment := taRightJustify;
     Prompt.Visible := True;
@@ -604,6 +634,6 @@
 begin
   inherited;
+  TrimAllMemos;
   Application.ProcessMessages;
-  TrimAllMemos;
 end;
 
@@ -632,4 +662,29 @@
 end;
 
+function TfrmODGen.SetComponentName(Editor: TWinControl; Index: Integer; DialogCtrl: TDialogCtrl): Boolean;
+Var
+ I: Integer;
+ SaveName: String;
+begin
+ //strip all non alphanumeric characters to create the save name
+ SaveName := '';
+ //Check for blank id
+ if DialogCtrl.ID = '' then DialogCtrl.ID := 'EMPTY';
+
+ for i := 1 to length(DialogCtrl.ID) do begin
+   if (DialogCtrl.ID[i] in ['A'..'Z']) or (DialogCtrl.ID[i] in ['a'..'z']) or (DialogCtrl.ID[i] in ['0'..'9']) then
+    SaveName := SaveName + DialogCtrl.ID[i];
+ end;
+ SaveName := SaveName + '_' + IntToStr(Index);
+
+ //extra backup - make sure that the component name doesn't already exist
+ //Now set up the component name
+ try
+  Editor.Name := SaveName;
+ except
+  Editor.Name := SaveName + '_' + IntToStr(Index);
+ end;
+end;
+
 end.
 
