Index: cprs/branches/HealthSevak-CPRS/CPRS-Chart/fARTAllgy.pas
===================================================================
--- cprs/branches/HealthSevak-CPRS/CPRS-Chart/fARTAllgy.pas	(revision 1676)
+++ cprs/branches/HealthSevak-CPRS/CPRS-Chart/fARTAllgy.pas	(revision 1693)
@@ -1,4 +1,4 @@
 unit fARTAllgy;
-
+  
 interface
 
@@ -21,5 +21,5 @@
     lblAgent: TOROffsetLabel;
     lstAllergy: TORListBox;
-    btnAgent: TSpeedButton;
+    btnAgent1: TSpeedButton;
     lblOriginator: TOROffsetLabel;
     cboOriginator: TORComboBox;
@@ -33,5 +33,4 @@
     calVerifyDate: TORDateBox;
     lblVerifyDate: TOROffsetLabel;
-    dlgReactionDateTime: TORDateTimeDlg;
     Bevel1: TBevel;
     lblSymptoms: TOROffsetLabel;
@@ -39,5 +38,4 @@
     lblSelectedSymptoms: TOROffsetLabel;
     lstSelectedSymptoms: TORListBox;
-    btnDateTime: TButton;
     btnRemove: TButton;
     grpObsHist: TRadioGroup;
@@ -60,6 +58,14 @@
     lblNatureOfReaction: TOROffsetLabel;
     btnSevHelp: TORAlignButton;
-    procedure btnAgentClick(Sender: TObject);
-    procedure FormCreate(Sender: TObject); 
+    VA508ComponentAccessibility1: TVA508ComponentAccessibility;
+    VA508ComponentAccessibility2: TVA508ComponentAccessibility;
+    origlbl508: TVA508StaticText;
+    origdtlbl508: TVA508StaticText;
+    SymptomDateBox: TORDateBox;
+    btnAgent: TButton;
+    VA508ComponentAccessibility3: TVA508ComponentAccessibility;
+    NoAllergylbl508: TVA508StaticText;
+    procedure btnAgent1Click(Sender: TObject);
+    procedure FormCreate(Sender: TObject);
     procedure cboOriginatorNeedData(Sender: TObject; const StartFrom: String;
       Direction, InsertAt: Integer);
@@ -77,5 +83,4 @@
     procedure btnRemoveClick(Sender: TObject);
     procedure lstAllergyClick(Sender: TObject);
-    procedure btnDateTimeClick(Sender: TObject);
     procedure cboSymptomsMouseClick(Sender: TObject);
     procedure cboSymptomsKeyDown(Sender: TObject; var Key: Word;
@@ -90,4 +95,26 @@
     procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
     procedure btnSevHelpClick(Sender: TObject);
+    procedure VA508ComponentAccessibility1StateQuery(Sender: TObject;
+      var Text: string);
+    procedure VA508ComponentAccessibility2ValueQuery(Sender: TObject;
+      var Text: string);
+    procedure VA508ComponentAccessibility2StateQuery(Sender: TObject;
+      var Text: string);
+    procedure VA508ComponentAccessibility2ItemInstructionsQuery(Sender: TObject;
+      var Text: string);
+    procedure VA508ComponentAccessibility2ItemQuery(Sender: TObject;
+      var Item: TObject);
+    procedure VA508ComponentAccessibility2InstructionsQuery(Sender: TObject;
+      var Text: string);
+    procedure VA508ComponentAccessibility2ComponentNameQuery(Sender: TObject;
+      var Text: string);
+    procedure VA508ComponentAccessibility2CaptionQuery(Sender: TObject;
+      var Text: string);
+    procedure SymptomDateBoxExit(Sender: TObject);
+    procedure SymptomDateBoxDateDialogClosed(Sender: TObject);
+    procedure calObservedDateExit(Sender: TObject);
+    procedure VA508ComponentAccessibility3StateQuery(Sender: TObject;
+      var Text: string);
+    procedure memErrCmtsExit(Sender: TObject);
   private
     FLastAllergyID: string;
@@ -96,4 +123,5 @@
     FChanged: Boolean;
     FOldHintPause : integer;
+    procedure SetDate;
   protected
     procedure EnableDisableControls(EnabledStatus: boolean);
@@ -106,13 +134,15 @@
   end;
 
-function EnterEditAllergy(AllergyIEN: integer; AddNew, MarkAsEnteredInError: boolean): boolean;
+function EnterEditAllergy(AllergyIEN: integer; AddNew, MarkAsEnteredInError: boolean; AnOwner: TComponent = nil; ARefNum: Integer = -1): boolean;
 function MarkEnteredInError(AllergyIEN: integer): boolean;
 function EnterNKAForPatient: boolean;
 
 var
+  frmARTAllergy: TfrmARTAllergy;
   AllergyList: TStringList;
   OldRec, NewRec: TAllergyRec;
   Defaults: TStringList;
   Changing: Boolean;
+  FAbort: Boolean;
   uAddingNew: boolean = FALSE;
   uEditing: Boolean = FALSE;
@@ -126,5 +156,5 @@
 
 uses
-  rODBase, uCore, rCore, rCover, fAllgyFind, fPtCWAD, fRptBox;
+  rODBase, uCore, rCore, rCover, fCover, fAllgyFind, fPtCWAD, fRptBox, VA508AccessibilityRouter;
 
 const
@@ -183,14 +213,21 @@
 end;
 
-function EnterEditAllergy(AllergyIEN: integer; AddNew, MarkAsEnteredInError: boolean): boolean;
-var
-  frmARTAllergy: TfrmARTAllergy;
+function EnterEditAllergy(AllergyIEN: integer; AddNew, MarkAsEnteredInError: boolean; AnOwner: TComponent = nil; ARefNum: Integer = -1): boolean;
+var
   Allergy: string;
-begin
+begin      
+  Result := False;
+  if AnOwner = nil then AnOwner := Application;
+  
+  if frmARTAllergy <> nil then
+  begin
+    InfoBox('You are already entering/editing an Allergy.', 'Information', MB_OK);
+    exit;
+  end;
   uAddingNew := AddNew;
   uEditing := (not AddNew) and (not MarkAsEnteredInError);
   uEnteredInError := MarkAsEnteredInError;
-  Result := False;
-  frmARTAllergy := TfrmARTAllergy.Create(Application);
+  frmARTAllergy := TfrmARTAllergy.Create(AnOwner);
+  if ARefNum <> -1 then frmARTAllergy.RefNum := ARefNum;
   if frmARTAllergy.AbortAction then exit;
   with frmARTAllergy do
@@ -228,4 +265,5 @@
               ckNoKnownAllergies.Checked := True;
               Result := EnterNKAForPatient;
+              frmARTAllergy.Close;
               Exit;
             end
@@ -253,12 +291,15 @@
         Exit;
       end;
-      ShowModal;
+
+      origlbl508.Caption := 'Originator. Read Only. Value is ' + cboOriginator.SelText;
+      origdtlbl508.Caption := 'Origination Date. Read Only. Value is '+ calOriginated.Text;
+      Show;
       Result := FChanged;
     finally
-      uAddingNew := FALSE;
-      uEditing := FALSE;
-      uEnteredInError := FALSE;
-      uUserCanVerify := FALSE;
-      frmARTAllergy.Release;
+//      uAddingNew := FALSE;
+//      uEditing := FALSE;
+//      uEnteredInError := FALSE;
+//      uUserCanVerify := FALSE;
+      //frmARTAllergy.Release;
     end;
 end;
@@ -268,4 +309,5 @@
   inherited;       // what to do here?  How to set up dialog defaults without order dialog to supply prompts?
   Changing := True;
+  FAbort := True;
   AbortAction := False;
   AllergyList := TStringList.Create;
@@ -289,5 +331,6 @@
   StatusText('Initializing Long List');
   ExtractItems(cboSymptoms.Items, Defaults, 'Top Ten');
-  cboSymptoms.InsertSeparator;
+  if ScreenReaderSystemActive then cboSymptoms.Items.Add('^----Separator for end of Top Ten signs and symptoms------')
+  else cboSymptoms.InsertSeparator;
   cboSymptoms.InitLongList('');
   cboOriginator.InitLongList(User.Name) ;
@@ -306,4 +349,5 @@
 var
   Allergy: string;
+  i: Integer;
   //ErrMsg: string;
 begin
@@ -344,13 +388,28 @@
   ckChartMarked.Checked := ckChartMarked.Checked or uAddingNew;
   ListAllergies(AllergyList);
+  for i:=0 to grpObsHist.ControlCount -1 do
+  TWinControl(grpObsHist.Controls[i]).TabStop := true;
   with AllergyList do
     if Count > 0 then
       begin
         if (Piece(Strings[0], U, 1) = '') and (Piece(Strings[0], U, 2) <> 'No Known Allergies') then
-          ckNoKnownAllergies.Enabled := True
+          begin
+            ckNoKnownAllergies.Enabled := True;
+            //TDP - CQ#19731 make sure NoAllergylbl508 is not enabled or visible if
+            //      ckNoKnownAllergies is enabled
+            NoAllergylbl508.Enabled := False;
+            NoAllergylbl508.Visible := False;
+          end
         else
           begin
             ckNoKnownAllergies.Enabled := False;
             btnCurrent.Enabled := True;
+            //TDP - CQ#19731 make sure NoAllergylbl508 is enabled and visible if
+            //      ckNoKnownAllergies is disabled
+            if ScreenReaderSystemActive then
+              begin
+                NoAllergylbl508.Enabled := True;
+                NoAllergylbl508.Visible := True;
+              end;
           end;
       end
@@ -359,4 +418,8 @@
         btnCurrent.Enabled := False;
         ckNoKnownAllergies.Enabled := True;
+        //TDP - CQ#19731 make sure NoAllergylbl508 is not enabled or visible if
+        //      ckNoKnownAllergies is enabled
+        NoAllergylbl508.Enabled := False;
+        NoAllergylbl508.Visible := False;
       end;
   if (not uEditing) and (not uEnteredInError) and (not uAddingNew) then
@@ -387,4 +450,39 @@
   Changing := False;
   ControlChange(lstAllergy);
+  origlbl508.Visible := False;
+  origdtlbl508.Visible := False;
+  if ScreenReaderSystemActive then
+    begin
+      origlbl508.Enabled := True;
+      origdtlbl508.Enabled := True;
+      origlbl508.Visible := True;
+      origdtlbl508.Visible := True;
+//    cboOriginator.Enabled := True;
+//    calOriginated.Enabled := True;
+//    calOriginated.ReadOnly := True;
+    end;
+end;
+
+procedure TfrmARTAllergy.SetDate;
+var
+  x: string;
+begin
+  Changing := True;
+  with lstSelectedSymptoms do
+    begin
+      if (Items.Count = 0) or (ItemIndex = -1) or (not SymptomDateBox.IsValid) then exit;
+
+      if SymptomDateBox.FMDateTime > FMNow then
+        InfoBox(TX_NO_FUTURE_DATES, TX_CAP_FUTURE, MB_OK)
+      else
+        begin
+          x := Items[ItemIndex];
+          x := ORFn.Pieces(x, U, 1, 2) + U + FloatToStr(SymptomDateBox.FMDateTime) + U +
+                            FormatFMDateTime('mmm dd,yyyy@hh:nn', SymptomDateBox.FMDateTime);
+          Items[ItemIndex] := x;
+        end;
+    end;
+  Changing := False;
+  ControlChange(SymptomDateBox);
 end;
 
@@ -437,4 +535,71 @@
       Changing := False;
     end;
+
+end;
+
+procedure TfrmARTAllergy.VA508ComponentAccessibility1StateQuery(Sender: TObject;
+  var Text: string);
+begin
+  inherited;
+Text := 'Comments ' + memComments.Text;
+end;
+
+procedure TfrmARTAllergy.VA508ComponentAccessibility2CaptionQuery(
+  Sender: TObject; var Text: string);
+begin
+  inherited;
+
+ Text := 'Causative Agent';
+end;
+
+procedure TfrmARTAllergy.VA508ComponentAccessibility2ComponentNameQuery(
+  Sender: TObject; var Text: string);
+begin
+  inherited;
+
+ Text := 'List Box';
+end;
+
+procedure TfrmARTAllergy.VA508ComponentAccessibility2InstructionsQuery(
+  Sender: TObject; var Text: string);
+begin
+  //inherited;
+
+ Text := 'Read Only';
+end;
+
+procedure TfrmARTAllergy.VA508ComponentAccessibility2ItemInstructionsQuery(
+  Sender: TObject; var Text: string);
+begin
+  //inherited;
+  Text := ' ';
+end;
+
+procedure TfrmARTAllergy.VA508ComponentAccessibility2ItemQuery(Sender: TObject;
+  var Item: TObject);
+begin
+  inherited;
+ Text := ' ';
+end;
+
+procedure TfrmARTAllergy.VA508ComponentAccessibility2StateQuery(Sender: TObject;
+  var Text: string);
+begin
+//  inherited;
+  Text := ' ';
+end;
+
+procedure TfrmARTAllergy.VA508ComponentAccessibility2ValueQuery(Sender: TObject;
+  var Text: string);
+begin
+  inherited;
+  Text := Piece(lstAllergy.Items[0],U,2);
+end;
+
+procedure TfrmARTAllergy.VA508ComponentAccessibility3StateQuery(Sender: TObject;
+  var Text: string);
+begin
+  inherited;
+  Text := memErrCmts.Text;
 end;
 
@@ -524,4 +689,13 @@
 end;
 
+procedure TfrmARTAllergy.calObservedDateExit(Sender: TObject);
+var
+  x: string;
+begin
+  inherited;
+  calObservedDate.Validate(x);
+  calObservedDate.FMDateTime := calObservedDate.FMDateTime;
+end;
+
 procedure TfrmARTAllergy.cboOriginatorNeedData(Sender: TObject;
   const StartFrom: string; Direction, InsertAt: Integer);
@@ -542,5 +716,5 @@
   inherited;
   Changing := True;
-  cboSeverity.ItemIndex := -1;
+  cboSeverity.ItemIndex := 1;
   case grpObsHist.ItemIndex of
     0:  begin
@@ -700,5 +874,33 @@
 end;
 
-procedure TfrmARTAllergy.btnAgentClick(Sender: TObject);
+procedure TfrmARTAllergy.memErrCmtsExit(Sender: TObject);
+var
+  AStringList: TStringList;
+begin
+  inherited;
+  AStringList := TStringList.Create;
+  try
+    QuickCopy(memErrCmts, AStringList);
+    LimitStringLength(AStringList, 74);
+    QuickCopy(AstringList, memErrCmts);
+    ControlChange(Self);
+  finally
+    AStringList.Free;
+  end;
+end;
+
+procedure TfrmARTAllergy.SymptomDateBoxDateDialogClosed(Sender: TObject);
+begin
+  inherited;
+  SetDate;
+end;
+
+procedure TfrmARTAllergy.SymptomDateBoxExit(Sender: TObject);
+begin
+  inherited;
+  SetDate;
+end;
+
+procedure TfrmARTAllergy.btnAgent1Click(Sender: TObject);
 var
   Allergy: string;
@@ -756,4 +958,12 @@
   uDeletedSymptoms.Free;
   AllergyList.Free;
+  frmARTAllergy := NIL;
+
+  uAddingNew := FALSE;
+  uEditing := FALSE;
+  uEnteredInError := FALSE;
+  uUserCanVerify := FALSE;
+  frmCover.UpdateAllergiesList;
+  
   inherited;
 end;
@@ -796,5 +1006,5 @@
    lstAllergy.Enabled              := EnabledStatus;
    cboSymptoms.Enabled             := EnabledStatus;
-   btnDateTime.Enabled             := EnabledStatus;
+   SymptomDateBox.Enabled          := EnabledStatus;
 end;
 
@@ -812,4 +1022,5 @@
           begin
             FChanged := False;
+            FAbort := False;
             Close;
             Exit;
@@ -824,4 +1035,5 @@
           Application.ProcessMessages;
         end;
+      FAbort := False;
       Close;
     end;
@@ -883,34 +1095,4 @@
 end;
 
-procedure TfrmARTAllergy.btnDateTimeClick(Sender: TObject);
-var
-  AFMDateTime: TFMDateTime;
-  x: string;
-begin
-  inherited;
-  Changing := True;
-  with lstSelectedSymptoms do
-    begin
-      if (Items.Count = 0) or (ItemIndex = -1) then exit;
-      AFMDateTime := MakeFMDateTime(Piece(Items[ItemIndex], U, 3));
-      if AFMDateTime > 0 then
-        dlgReactionDateTime.FMDateTime := AFMDateTime
-      else
-        dlgReactionDateTime.FMDateTime := FMNow;
-      if not dlgReactionDateTime.Execute then exit;
-      if dlgReactionDateTime.FMDateTime > FMNow then
-        InfoBox(TX_NO_FUTURE_DATES, TX_CAP_FUTURE, MB_OK)
-      else
-        begin
-          x := Items[ItemIndex];
-          x := ORFn.Pieces(x, U, 1, 2) + U + FloatToStr(dlgReactionDateTime.FMDateTime) + U +
-                            FormatFMDateTime('mmm dd,yyyy@hh:nn', dlgReactionDateTime.FMDateTime);
-          Items[ItemIndex] := x;
-        end;
-    end;
-  Changing := False;
-  ControlChange(btnDateTime);
-end;
-
 procedure TfrmARTAllergy.cboSymptomsMouseClick(Sender: TObject);
 const
@@ -984,12 +1166,19 @@
 
 procedure TfrmARTAllergy.lstSelectedSymptomsChange(Sender: TObject);
+var
+  AFMDateTime: TFMDateTime;
 begin
   inherited;
   with lstSelectedSymptoms do
     begin
-      btnDateTime.Enabled := (ItemIndex <> -1);
-      btnRemove.Enabled := btnDateTime.Enabled;
-    end;
-  //ControlChange(Self);
+      SymptomDateBox.Enabled := (ItemIndex <> -1);
+      btnRemove.Enabled := (ItemIndex <> -1);
+
+      if SymptomDateBox.Enabled then begin
+        AFMDateTime := MakeFMDateTime(Piece(Items[ItemIndex], U, 3));
+        if AFMDateTime > 0 then
+          SymptomDateBox.FMDateTime := AFMDateTime
+      end;
+    end;
 end;
 
@@ -1083,4 +1272,5 @@
 begin
   inherited;
+  Release;
   uEditing := False;
   uEnteredInError := False;
@@ -1088,4 +1278,5 @@
   Application.HintHidePause := FOldHintPause;
   Action  := caFree;
+                  
 end;
 
@@ -1094,4 +1285,12 @@
 begin
   inherited;
+  if FAbort and frmARTAllergy.Visible then
+  begin
+    if InfoBox('Are you sure you want to cancel Entering/Editing this allergy?', 'Exiting Allergy Enter/Edit form', MB_YESNO) = ID_NO then
+    begin
+    CanClose := false;
+    exit;
+    end;
+  end;
   if AbortAction then exit;
 end;
