Index: cprs/branches/foia-cprs/CPRS-Chart/fReports.pas
===================================================================
--- cprs/branches/foia-cprs/CPRS-Chart/fReports.pas	(revision 459)
+++ cprs/branches/foia-cprs/CPRS-Chart/fReports.pas	(revision 460)
@@ -6,5 +6,5 @@
   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
   fHSplit, StdCtrls, ExtCtrls, ORCtrls, ComCtrls, Menus, uConst, ORDtTmRng,
-  OleCtrls, SHDocVw, Buttons, ClipBrd, rECS, Variants;
+  OleCtrls, SHDocVw, Buttons, ClipBrd, rECS, Variants, StrUtils;
 
 type
@@ -47,4 +47,11 @@
     tvProcedures: TORTreeView;
     lblProcTypeMsg: TOROffsetLabel;
+    pnlViews: TORAutoPanel;
+    chkDualViews: TCheckBox;
+    btnChangeView: TORAlignButton;
+    btnGraphSelections: TORAlignButton;
+    lblDateRange: TLabel;
+    lstDateRange: TORListBox;
+    pnlTopViews: TPanel;
     procedure lstQualifierClick(Sender: TObject);
     procedure GotoTop1Click(Sender: TObject);
@@ -59,5 +66,5 @@
     procedure TabControl1Change(Sender: TObject);
     procedure FormDestroy(Sender: TObject);
-    procedure GoRemote(Dest: TStringList; AItem: string; AQualifier, ARpc: string; AHSTag: string);
+    procedure GoRemote(Dest: TStringList; AItem: string; AQualifier, ARpc: string; AHSTag: string; AHDR: string);
     procedure lstHeadersClick(Sender: TObject);
     procedure Splitter1CanResize(Sender: TObject; var NewSize: Integer;
@@ -99,9 +106,14 @@
       var AllowCollapse: Boolean);                                                      
     procedure tvProceduresExpanding(Sender: TObject; Node: TTreeNode;                   
-      var AllowExpansion: Boolean);                                                     
+      var AllowExpansion: Boolean);
     procedure tvProceduresClick(Sender: TObject);                                       
     procedure tvProceduresChange(Sender: TObject; Node: TTreeNode);
     procedure tvProceduresKeyDown(Sender: TObject; var Key: Word;                       
-      Shift: TShiftState);                                                              
+      Shift: TShiftState);
+    procedure chkDualViewsClick(Sender: TObject);
+    procedure btnChangeViewClick(Sender: TObject);
+    procedure btnGraphSelectionsClick(Sender: TObject);
+    procedure lstDateRangeClick(Sender: TObject);
+    procedure sptHorzMoved(Sender: TObject);
 
   private
@@ -109,5 +121,6 @@
     procedure ProcessNotifications;
     procedure ShowTabControl;
-    //procedure UpdateRemoteStatus(aSiteID, aStatus: string);
+    procedure Graph(reportien: integer);
+    procedure GraphPanel(active: boolean);
 
   public
@@ -145,5 +158,4 @@
   ulvSelectOn: boolean;             //flag turned on when multiple items in lvReports control have been selected
   uListState: Integer;              //Checked state of list of Adhoc components Checked: Abbreviation, UnChecked: Name
-  uNoRemote: boolean;
   uECSReport: TECSReport;           //Event Capture Report, initiated in fFrame when Click Event Capture under Tools
   UpdatingLvReports: Boolean;       //Currently updating lvReports
@@ -155,5 +167,5 @@
 
 uses ORFn, rCore, rReports, fFrame, uCore, uReports, fReportsPrint,
-     fReportsAdhocComponent1, activex, mshtml, dShared;
+     fReportsAdhocComponent1, activex, mshtml, dShared, fGraphs, rGraphs;  //*****
 
 const
@@ -182,7 +194,10 @@
   uHTMLPatient: ANSIstring;
   uRptID: String;
+  uDirect: String;
   uEmptyImageList: TImageList;
   ColumnToSort: Integer;
   ColumnSortForward: Boolean;
+  GraphForm: TfrmGraphs;
+  GraphFormActive: boolean;
 
 procedure TfrmReports.ClearPtData;
@@ -200,4 +215,133 @@
   TabControl1.Visible := false;
   TabControl1.TabStop := false;
+  if (GraphForm <> nil) and GraphFormActive then
+  with GraphForm do
+  begin
+    GraphForm.SendToBack;
+    Initialize;
+    DisplayData('top');
+    DisplayData('bottom');
+    lstCheck.Items.Clear;
+    GraphFormActive := false;
+  end;
+  begin
+  end;
+end;
+
+procedure TfrmReports.Graph(reportien: integer);
+begin
+  if GraphForm = nil then
+  begin
+    GraphForm := TfrmGraphs.Create(self);
+    try
+      with GraphForm do
+      begin
+        if btnClose.Tag = 1 then
+          Exit;
+        Parent := pnlRight;
+        Align := alClient;
+        pnlFooter.Tag := 1;   //suppresses bottom of graph form
+        pnlBottom.Height := 1;
+        pnlMain.BevelInner := bvLowered;
+        pnlMain.BevelOuter := bvRaised;
+        pnlMain.Tag := reportien;
+        Initialize;
+        ResizeAnchoredFormToFont(GraphForm);
+        Show;
+        DisplayData('top');
+        DisplayData('bottom');
+        lstCheck.Items.Clear;
+        GraphPanel(true);
+        lstTypes.Hint := Patient.DFN;
+        BringToFront;
+      end;
+    finally
+      if GraphForm.btnClose.Tag = 1 then
+      begin
+        GraphFormActive := false;
+        GraphForm.Free;
+        GraphForm := nil;
+      end
+      else
+        GraphFormActive := true;
+    end;
+  end
+  else if GraphForm.btnClose.Tag = 1 then
+    Exit
+  else if GraphFormActive and (GraphForm.lstTypes.Hint = Patient.DFN) then
+  begin   // displaying same patient
+    if Tag <> reportien then
+    with GraphForm do
+    begin  // new report
+      pnlMain.Tag := reportien;
+      Initialize;
+      //DisplayData('top');
+      //DisplayData('bottom');
+      lstCheck.Items.Clear;
+      GraphPanel(true);
+      BringToFront;
+    end;
+    //no action
+  end
+  else if GraphForm.lstTypes.Hint = Patient.DFN then
+  begin   // same patient, bring back graph
+    GraphPanel(true);
+    BringToFront;
+    GraphFormActive := true;
+  end
+  else
+  with GraphForm do
+  begin  // new patient
+    pnlMain.Tag := reportien;
+    Initialize;
+    DisplayData('top');
+    DisplayData('bottom');
+    lstCheck.Items.Clear;
+    lstTypes.Hint := Patient.DFN;
+    GraphPanel(true);
+    BringToFront;
+    GraphFormActive := true;
+  end;
+end;
+
+procedure TfrmReports.GraphPanel(active: boolean);
+var
+  aQualifier, aStartTime, aStopTime: string;
+begin
+  if active then
+  begin
+    pnlLeftBottom.Height := pnlLeft.Height div 2;
+    pnlViews.Height := pnlLeftBottom.Height;
+    if pnlLeft.Height < 200 then
+      pnlTopViews.Height := 3
+    else
+      pnlTopViews.Height := 80;
+    lblQualifier.Visible := false;
+    lstQualifier.Visible := false;
+    pnlViews.Visible := true;
+    if lstDateRange.Tag = 0 then
+    begin
+      lstDateRange.Tag := 1;
+      aQualifier  :=  PReportTreeObject(tvReports.Selected.Data)^.Qualifier;
+      aStartTime  :=  Piece(aQualifier,';',1);
+      aStopTime   :=  Piece(aQualifier,';',2);
+      GraphForm.cboDateRange.Items.Add(
+        '^' + aStartTime + ' to ' + aStopTime +'^^^' + aStartTime + ';' +  aStopTime +
+        '^' + floattostr(strtofmdatetime(aStartTime)) + '^' + floattostr(strtofmdatetime(aStopTime)));
+      lstDateRange.Items := GraphForm.cboDateRange.Items;
+      //lstDateRange.ItemIndex := lstDateRange.Items.Count - 1;
+      lstDateRange.ItemIndex := lstDateRange.Items.Count - 2;      //set to all results till fixed
+      lstDateRangeClick(self);
+    end;
+    pnlLeftBottom.Visible := true;
+    splitter1.Visible := true;
+  end
+  else
+  begin
+    lblQualifier.Visible := true;
+    lstQualifier.Visible := true;
+    pnlViews.Visible := false;
+    pnlLeftBottom.Height := lblHeaders.Height + lblQualifier.Height + 90;
+  end;
 end;
 
@@ -249,4 +393,18 @@
         end;
     end;
+  if (uReportType = 'G') and GraphFormActive then
+    with GraphForm do
+    begin
+      if (lvwItemsTop.SelCount < 1) and (lvwItemsBottom.SelCount < 1) then
+        begin
+          InfoBox('There are no items graphed.', 'No Items to Print', MB_OK);
+          Exit;
+        end
+      else
+        begin
+          mnuPopGraphPrintClick(mnuPopGraphPrint);
+          Exit;
+        end;
+    end;
   if uQualifierType = QT_DATERANGE then
     begin      //      = 2
@@ -272,5 +430,4 @@
   uUpdateStat := false;
   ulvSelectOn := false;
-  uNoRemote := false;
   uListState := GetAdhocLookup();
   memText.SelStart := 0;
@@ -285,5 +442,6 @@
                   //the preferred method would be to use headers and footers
                   //so this is just an interim solution.
-  pnlLeftBottom.Visible := False;       
+  if not GraphFormActive then
+    pnlLeftBottom.Visible := False;
   if InitPage then
     begin
@@ -325,5 +483,5 @@
                         begin
                         lstQualifier.Clear;
-                        tvProcedures.Items.Clear;             
+                        tvProcedures.Items.Clear;
                         lblProcTypeMsg.Visible := FALSE;      
                         lvReports.SmallImages := uEmptyImageList;
@@ -338,5 +496,5 @@
                         end;
     CC_NOTIFICATION:  ProcessNotifications;
-  end;
+  end;  
 end;
 
@@ -373,5 +531,5 @@
   uHTMLDoc := '';
   WebBrowser1.Navigate('about:blank');
-  tvProcedures.Items.Clear;             
+  tvProcedures.Items.Clear;
   lblProcTypeMsg.Visible := FALSE;      
   lvReports.SmallImages := uEmptyImageList;
@@ -406,9 +564,9 @@
         begin
           if addgrandchild = true then
-            currentNode := tvReports.Items.AddChildObject(grandParentNode,Piece(x,'^',3),MakeReportTreeObject(Pieces(x,'^',2,14)))
+            currentNode := tvReports.Items.AddChildObject(grandParentNode,Piece(x,'^',3),MakeReportTreeObject(Pieces(x,'^',2,15)))
           else
             if addchild = true then
               begin
-                currentNode := tvReports.Items.AddChildObject(parentNode,Piece(x,'^',3),MakeReportTreeObject(Pieces(x,'^',2,14)));
+                currentNode := tvReports.Items.AddChildObject(parentNode,Piece(x,'^',3),MakeReportTreeObject(Pieces(x,'^',2,15)));
                 addgrandchild := true;
                 grandParentNode := currentNode;
@@ -416,5 +574,5 @@
             else
               begin
-                currentNode := tvReports.Items.AddObject(currentNode,Piece(x,'^',3),MakeReportTreeObject(Pieces(x,'^',2,14)));
+                currentNode := tvReports.Items.AddObject(currentNode,Piece(x,'^',3),MakeReportTreeObject(Pieces(x,'^',2,15)));
                 parentNode := currentNode;
                 addchild := true;
@@ -425,5 +583,4 @@
           begin
             currentNode := tvReports.Items.AddObject(currentNode,Piece(x,'^',2),MakeReportTreeObject(x));
-            //addchild := true;
             parentNode := currentNode;
           end
@@ -460,5 +617,5 @@
   aTmpAray: TStringList;
   aColCtr, aCurCol, aCurRow, aColID: integer;
-  x,c,aSite: string;
+  x,y,z,c,aSite: string;
   ListItem: TListItem;
 begin
@@ -466,5 +623,4 @@
   aErr := 0;
   ListItem := nil;
-  //RowObjects.Clear;
   case uQualifierType of
     QT_HSCOMPONENT:
@@ -536,5 +692,19 @@
                                 if piece(uColumns.Strings[aCurCol],'^',4) = '1' then
                                   c := c + '...';
-                                ListItem.SubItems.Add(c);
+                                z := piece(c,'^',1);
+                                y := copy(c, (pos('^', c)), 9999);
+                                if pos('^',y) > 0 then
+                                  begin
+                                    while pos('^',y) > 0 do
+                                      begin
+                                        y := copy(y, (pos('^', y)+1), 9999);
+                                        z := z + '^' + y;
+                                      end;
+                                        ListItem.SubItems.Add(z);
+                                  end
+                                else
+                                  begin
+                                    ListItem.SubItems.Add(y);
+                                  end;
                               end;
                             RowObjects.Add(aSite, IntToStr(aCurRow) + ':' + IntToStr(aCurCol), uColumns.Strings[aCurCol], aTmpAray);
@@ -548,5 +718,21 @@
                       if aColID = aCurCol then
                         begin
-                          aTmpAray.Add(piece(x,'^',2));
+                          z := '';
+                          y := piece(x,'^',2);
+                          if length(y) > 0 then z := y;
+                          y := copy(x, (pos('^', x)+1), 9999);
+                          if pos('^',y) > 0 then
+                            begin
+                              while pos('^',y) > 0 do
+                                begin
+                                  y := copy(y, (pos('^', y)+1), 9999);
+                                  z := z + '^' + y;
+                                end;
+                              aTmpAray.Add(z);
+                            end
+                          else
+                            begin
+                              aTmpAray.Add(y);
+                            end;
                           continue;
                         end;
@@ -572,5 +758,12 @@
                     aCurCol := aColID;
                     Inc(aColCtr);
-                    aTmpAray.Add(piece(x,'^',2));
+                    y := '';
+                    for k := 2 to 10 do
+                      if length(piece(x,'^',k)) > 0 then
+                        begin
+                          if length(y) > 0 then y := y + '^' + piece(x,'^',k)
+                          else y := y + piece(x,'^',k);
+                        end;
+                    aTmpAray.Add(y);
                     if aColCtr > 0 then
                       while aColCtr < aCurCol do
@@ -632,5 +825,5 @@
 var
   MoreID: String;  //Restores MaxOcc value
-  aRemote: string;
+  aRemote, aHDR: string;
   i: integer;
 begin
@@ -643,12 +836,10 @@
   MoreID := ';' + Piece(uQualifier,';',3);
   aRemote :=  piece(uRemoteType,'^',1);
+  aHDR := piece(uRemoteType,'^',7);
   SetPiece(uRemoteType,'^',5,lstQualifier.ItemID);
   uHSComponents.Clear;
   uHSAll.Clear;
-  memText.Lines.Clear;
-  tvProcedures.Items.Clear;             
-  lblProcTypeMsg.Visible := FALSE;      
-  lvReports.SmallImages := uEmptyImageList;
-  lvReports.Items.Clear;
+  tvProcedures.Items.Clear;
+  lblProcTypeMsg.Visible := FALSE;
   uHTMLDoc := '';
   if uReportType = 'H' then
@@ -675,5 +866,8 @@
    TRemoteSite(RemoteSites.SiteList.Items[i]).ReportClear;
   uRemoteCount := 0;
-  DisplayHeading(lstQualifier.ItemID + MoreID);
+  if aHDR = '1' then
+    DisplayHeading(lstQualifier.ItemID)
+  else
+    DisplayHeading(lstQualifier.ItemID + MoreID);
   if lstQualifier.ItemID = 'ds' then
     begin
@@ -728,5 +922,4 @@
   StatusText('Retrieving ' + lblTitle.Caption + '...');
   Screen.Cursor := crHourGlass;
-  memText.Lines.Clear;
   uReportInstruction := #13#10 + 'Retrieving data...';
   memText.Lines.Add(uReportInstruction);
@@ -738,16 +931,20 @@
   case uQualifierType of
       QT_HSCOMPONENT:
-        begin      //      = 5
-          if (length(piece(uHState,';',2)) > 0) then //and (chkText.Checked = false) then
+        begin     //      = 5
+          lvReports.SmallImages := uEmptyImageList;
+          lvReports.Items.Clear;
+          memText.Lines.Clear;
+          RowObjects.Clear;
+          if ((aRemote = '1') or (aRemote = '2')) then
+            GoRemote(uRemoteReportData, uRptID, lstQualifier.ItemID + MoreID, uReportRPC, uHState, aHDR);
+          if (length(piece(uHState,';',2)) > 0) then
             begin
-              LoadReportText(uLocalReportData, uRptID, lstQualifier.ItemID + MoreID, uReportRPC, uHState);
-              memText.Lines.Clear;
-              //memText.Lines.Assign(uLocalReportData);
-              RowObjects.Clear;
+              if not(aRemote = '2') then
+                LoadReportText(uLocalReportData, uRptID, lstQualifier.ItemID + MoreID, uReportRPC, uHState);
               LoadListView(uLocalReportData);
             end
           else
             begin
-              if aRemote = '1' then
+              if ((aRemote = '1') or (aRemote = '2')) then
                 ShowTabControl;
               pnlRightMiddle.Visible := false;
@@ -764,35 +961,38 @@
                 end;
             end;
-          if (aRemote = '1') and (uNoRemote = false) then
-            GoRemote(uRemoteReportData, uRptID, lstQualifier.ItemID + MoreID, uReportRPC, uHState);
         end;
       QT_HSWPCOMPONENT:
         begin      //      = 6
+          lvReports.SmallImages := uEmptyImageList;
+          lvReports.Items.Clear;
+          RowObjects.Clear;
+          memText.Lines.Clear;
+          if ((aRemote = '1') or (aRemote = '2'))  then
+            begin
+              Screen.Cursor := crDefault;
+              GoRemote(uRemoteReportData, uRptID, lstQualifier.ItemID + MoreID, uReportRPC, uHState, aHDR);
+            end;
           if (length(piece(uHState,';',2)) > 0) then
             begin
-              LoadReportText(uLocalReportData, uRptID, lstQualifier.ItemID + MoreID, uReportRPC, uHState);
-              memText.Lines.Clear;
-              //memText.Lines.Assign(uLocalReportData);
-              RowObjects.Clear;
+              if not(aRemote = '2') then
+                LoadReportText(uLocalReportData, uRptID, lstQualifier.ItemID + MoreID, uReportRPC, uHState);
               LoadListView(uLocalReportData);
             end
           else
             begin
-              if aRemote = '1' then
+              if ((aRemote = '1') or (aRemote = '2')) then
                 ShowTabControl;
               pnlRightMiddle.Visible := false;
-              LoadReportText(uLocalReportData, uRptID, lstQualifier.ItemID + MoreID, uReportRPC, uHState);
-              if uLocalReportData.Count < 1 then
+              if not (aRemote = '2') then
                 begin
-                  uReportInstruction := '<No Report Available>';
-                  memText.Lines.Add(uReportInstruction);
-                end
-              else
-                QuickCopy(uLocalReportData,memText);
-            end;
-          if (aRemote = '1') and (uNoRemote = false) then
-            begin
-              Screen.Cursor := crDefault;
-              GoRemote(uRemoteReportData, uRptID, lstQualifier.ItemID + MoreID, uReportRPC, uHState);
+                  LoadReportText(uLocalReportData, uRptID, lstQualifier.ItemID + MoreID, uReportRPC, uHState);
+                  if uLocalReportData.Count < 1 then
+                    begin
+                      uReportInstruction := '<No Report Available>';
+                      memText.Lines.Add(uReportInstruction);
+                    end
+                  else
+                    QuickCopy(uLocalReportData,memText);
+                end;
             end;
         end
@@ -800,6 +1000,6 @@
         begin
           Screen.Cursor := crDefault;
-          GoRemote(uRemoteReportData, uRptID, lstQualifier.ItemID + MoreID, uReportRPC, uHState);
-          if Pos('ECS',Piece(uRptID,':',1))>0 then  
+          GoRemote(uRemoteReportData, uRptID, lstQualifier.ItemID + MoreID, uReportRPC, uHState, aHDR);
+          if Pos('ECS',Piece(uRptID,':',1))>0 then
           begin
             if Pos('OR_ECS1',uRptID)>0 then
@@ -951,4 +1151,5 @@
   RowObjects := TRowObject.Create;
   uRemoteCount := 0;
+  GraphFormActive := false;
 end;
 
@@ -969,5 +1170,4 @@
             break;
           end;
-      //if not Found then i := -1;
     end;
 
@@ -975,5 +1175,5 @@
 
   case Notifications.Followup of
-    NF_IMAGING_RESULTS, NF_ABNORMAL_IMAGING_RESULTS, NF_IMAGING_RESULTS_AMENDED: 
+    NF_IMAGING_RESULTS, NF_ABNORMAL_IMAGING_RESULTS, NF_IMAGING_RESULTS_AMENDED:
       begin
         tvReports.Selected := tvReports.Items[i];
@@ -1095,5 +1295,5 @@
   i,j,fail: integer;
   r0,aSite: String;
-
+  aHDR, aID, aRet: String;
 begin
   inherited;
@@ -1111,16 +1311,20 @@
             if piece(r0,'^',1) = '1' then
               begin
+                aHDR := piece(TRemoteSite(Items[i]).CurrentReportQuery, '^', 13);
+                aID := piece(piece(TRemoteSite(Items[i]).CurrentReportQuery, '^', 2),':',1);
+                if aHDR = '1' then
+                  begin
+                    ModifyHDRData(aRet, TRemoteSite(Items[i]).RemoteHandle ,aID);
+                  end;
+                GetRemoteData(TRemoteSite(Items[i]).Data, TRemoteSite(Items[i]).RemoteHandle,Items[i]);
                 RemoteReports.Add(TRemoteSite(Items[i]).CurrentReportQuery,
                   TRemoteSite(Items[i]).RemoteHandle);
-                GetRemoteData(TRemoteSite(Items[i]).Data,
-                  TRemoteSite(Items[i]).RemoteHandle,Items[i]);
                 TRemoteSite(Items[i]).RemoteHandle := '';
                 TabControl1.OnChange(nil);
-                if (length(piece(uHState,';',2)) > 0) then //and (chkText.Checked = false) then
+                if (length(piece(uHState,';',2)) > 0) then
                   begin
                     uRemoteReportData.Clear;
                     QuickCopy(TRemoteSite(Items[i]).Data,uRemoteReportData);
                     fail := 0;
-                    //LoadListView(uRemoteReportData);
                     if uRemoteReportData.Count > 0 then
                       begin
@@ -1143,5 +1347,5 @@
               begin
                 uRemoteCount := uRemoteCount + 1;
-                if uRemoteCount > (90 * Count) then
+                if uRemoteCount > 90 then
                   begin
                     TRemoteSite(Items[i]).RemoteHandle := '';
@@ -1279,10 +1483,10 @@
 end;
 
-procedure TfrmReports.GoRemote(Dest: TStringList; AItem: string; AQualifier, ARpc: string; AHSTag: string);
+procedure TfrmReports.GoRemote(Dest: TStringList; AItem: string; AQualifier, ARpc: string; AHSTag: string; AHDR: string);
 var
   i, j: integer;
   LocalHandle, Query, Report: string;
   HSType, DaysBack, ExamID, MaxOcc: string;
-  Alpha, Omega: double;
+  Alpha, Omega, Trans: double;
 begin
   HSType := '';
@@ -1291,22 +1495,75 @@
   Alpha := 0;
   Omega := 0;
+  if UseVistaWeb then
+    begin
+      if AHDR = '1' then
+        InfoBox('You must use VistaWeb to view this report. To use RDV Classic, change your default setting.',
+                'Use VistaWeb for HDR data', MB_OK);
+      Exit;
+    end;
+  if AHDR = '1' then
+    begin
+      if HDRActive = '0' then
+        begin
+          InfoBox('The HDR is currently inactive.' + CRLF + 'Unable to retrieve HDR data at this time.', 'HDR Error', MB_OK);
+          Exit;
+        end;
+      if (Piece(AItem, ':', 1) = 'OR_VWAL') or (Piece(AItem, ':', 1) = 'OR_VWRX') then
+        AQualifier := 'T-75000;T+75000;99999';
+      if (Piece(AItem, ':', 1) = 'OR_VWVS') and (CharAt(AQualifier, 1) = ';') then
+        AQualifier := 'T-75000;T+75000;99999';
+    end;
+  if CharAt(AQualifier, 1) = 'd' then
+    begin
+      DaysBack := Copy(AQualifier, 2, Length(AQualifier));
+      AQualifier := ('T-' + Piece(DaysBack,';',1) + ';T;' + Pieces(AQualifier,';',2,3));
+      DaysBack := '';
+    end;
   if CharAt(AQualifier, 1) = 'T' then
     begin
+      if Piece(AQualifier,';',1) = 'T-0' then SetPiece(AQualifier,';',1,'T');
+      if (Piece(Aqualifier,';',1) = 'T') and (Piece(Aqualifier,';',2) = 'T')
+        then SetPiece(AQualifier,';',2,'T+1');
       Alpha := StrToFMDateTime(Piece(AQualifier,';',1));
       Omega := StrToFMDateTime(Piece(AQualifier,';',2));
+      if Alpha > Omega then
+        begin
+          Trans := Omega;
+          Omega := Alpha;
+          Alpha := Trans;
+        end;
       MaxOcc := Piece(AQualifier,';',3);
       SetPiece(AHSTag,';',4,MaxOcc);
     end;
-  if CharAt(AQualifier, 1) = 'd' then DaysBack := Copy(AQualifier, 2, Length(AQualifier));
   if CharAt(AQualifier, 1) = 'h' then HSType   := Copy(AQualifier, 2, Length(AQualifier));
   if CharAt(AQualifier, 1) = 'i' then ExamID   := Copy(AQualifier, 2, Length(AQualifier));
   with RemoteSites.SiteList do for i := 0 to Count - 1 do
+    begin
+    if (AHDR='1') and (LeftStr(TRemoteSite(Items[i]).SiteID, 5) = '200HD') then
+      begin
+        TRemoteSite(Items[i]).Selected := true;
+        frmFrame.lstCIRNLocations.Checked[i+2] := true;
+      end;
     if TRemoteSite(Items[i]).Selected then
       begin
         TRemoteSite(Items[i]).ReportClear;
+        if (LeftStr(TRemoteSite(Items[i]).SiteID, 5) = '200HD') and not(AHDR = '1') then
+          begin
+            TRemoteSite(Items[i]).QueryStatus := '1^Not Included';
+            UpdateRemoteStatus(TRemoteSite(Items[i]).SiteID, 'NOT INCLUDED');
+            TabControl1.OnChange(nil);
+            continue;
+          end;
+        if (AHDR = '1') and not(LeftStr(TRemoteSite(Items[i]).SiteID, 5) = '200HD') then
+          begin
+            TRemoteSite(Items[i]).QueryStatus := '1^Not Included';
+            UpdateRemoteStatus(TRemoteSite(Items[i]).SiteID, 'NOT INCLUDED');
+            TabControl1.OnChange(nil);
+            continue;
+          end;
         TRemoteSite(Items[i]).CurrentReportQuery := 'Report' + Patient.DFN + ';'
           + Patient.ICN + '^' + AItem + '^^^' + ARpc + '^' + HSType +
-          '^' + DaysBack + '^' + ExamID + '^' + DateToStr(Alpha) + '^' +
-          DateToStr(Omega) + '^' + TRemoteSite(Items[i]).SiteID + '^' + AHSTag;
+          '^' + DaysBack + '^' + ExamID + '^' + FloatToStr(Alpha) + '^' +
+          FloatToStr(Omega) + '^' + TRemoteSite(Items[i]).SiteID + '^' + AHSTag + '^' + AHDR;
         LocalHandle := '';
         Query := TRemoteSite(Items[i]).CurrentReportQuery;
@@ -1333,21 +1590,47 @@
         else
           begin
-            RemoteQuery(Dest, AItem, HSType, Daysback, ExamID, Alpha, Omega, TRemoteSite(Items[i]).SiteID, ARpc, AHSTag);
-            if Dest[0] = '' then
+            if uDirect = '1' then
               begin
-                TRemoteSite(Items[i]).QueryStatus := '-1^Communication error';
-                UpdateRemoteStatus(TRemoteSite(Items[i]).SiteID,'Communication error');
+                StatusText('Retrieving reports from ' + TRemoteSite(Items[i]).SiteName + '...');
+                TRemoteSite(Items[i]).QueryStatus := '1^Direct Call';
+                UpdateRemoteStatus(TRemoteSite(Items[i]).SiteID, 'Direct Call');
+                DirectQuery(Dest, AItem, HSType, Daysback, ExamID, Alpha, Omega, TRemoteSite(Items[i]).SiteID, ARpc, AHSTag);
+                if Copy(Dest[0],1,2) = '-1' then
+                  begin
+                    TRemoteSite(Items[i]).QueryStatus := '-1^Communication error';
+                    UpdateRemoteStatus(TRemoteSite(Items[i]).SiteID,'Communication error');
+                  end
+                else
+                  begin
+                    QuickCopy(Dest,TRemoteSite(Items[i]).Data);
+                    TRemoteSite(Items[i]).RemoteHandle := '';
+                    TRemoteSite(Items[i]).QueryStatus := '1^Done';
+                    UpdateRemoteStatus(TRemoteSite(Items[i]).SiteID, 'Done');
+                    TabControl1.OnChange(nil);
+                    if (length(piece(uHState,';',2)) > 0) then
+                      LoadListView(TRemoteSite(Items[i]).Data);
+                  end;
+                StatusText('');
               end
             else
               begin
-                TRemoteSite(Items[i]).RemoteHandle := Dest[0];
-                TRemoteSite(Items[i]).QueryStatus := '0^initialization...';
-                UpdateRemoteStatus(TRemoteSite(Items[i]).SiteID, 'initialization');
-                Timer1.Enabled := True;
-                StatusText('Retrieving reports from '
-                  + TRemoteSite(Items[i]).SiteName + '...');
+                RemoteQuery(Dest, AItem, HSType, Daysback, ExamID, Alpha, Omega, TRemoteSite(Items[i]).SiteID, ARpc, AHSTag);
+                if Dest[0] = '' then
+                  begin
+                    TRemoteSite(Items[i]).QueryStatus := '-1^Communication error';
+                    UpdateRemoteStatus(TRemoteSite(Items[i]).SiteID,'Communication error');
+                  end
+                else
+                  begin
+                    TRemoteSite(Items[i]).RemoteHandle := Dest[0];
+                    TRemoteSite(Items[i]).QueryStatus := '0^initialization...';
+                    UpdateRemoteStatus(TRemoteSite(Items[i]).SiteID, 'initialization');
+                    Timer1.Enabled := True;
+                    StatusText('Retrieving reports from ' + TRemoteSite(Items[i]).SiteName + '...');
+                  end;
               end;
           end;
       end;
+    end;
 end;
 
@@ -1377,4 +1660,5 @@
   uEmptyImageList.Free;
   uECSReport.Free;
+  if GraphForm <> nil then GraphForm.Release;
 end;
 
@@ -1471,5 +1755,5 @@
   aHeading, aReportType, aRPC, aQualifier, aStartTime, aStopTime, aMax, aRptCode, aRemote, aCategory, aSortOrder, aDaysBack, x: string;
   aIFN: integer;
-  aID, aHSTag, aRadParam, aColChange: string;
+  aID, aHSTag, aRadParam, aColChange, aDirect, aHDR, aQualifierID: string;
   CurrentParentNode, CurrentNode: TTreeNode;
 begin
@@ -1488,10 +1772,13 @@
   aCategory   :=  PReportTreeObject(tvReports.Selected.Data)^.Category;
   aSortOrder  :=  PReportTreeObject(tvReports.Selected.Data)^.SortOrder;
-  aDaysBack  :=  PReportTreeObject(tvReports.Selected.Data)^.MaxDaysBack;
+  aDaysBack   :=  PReportTreeObject(tvReports.Selected.Data)^.MaxDaysBack;
   aIFN        :=  StrToIntDef(PReportTreeObject(tvReports.Selected.Data)^.IFN,0);
+  aDirect     :=  PReportTreeObject(tvReports.Selected.Data)^.Direct;
+  aHDR        :=  PReportTreeObject(tvReports.Selected.Data)^.HDR;
   aStartTime  :=  Piece(aQualifier,';',1);
   aStopTime   :=  Piece(aQualifier,';',2);
   aMax        :=  Piece(aQualifier,';',3);
   aRptCode    :=  Piece(aQualifier,';',4);
+  aQualifierID:= '';
   if length(uColChange) > 0 then
     begin
@@ -1514,13 +1801,10 @@
   uReportRPC := aRPC;
   uRptID := aID;
+  uDirect := aDirect;
   uReportType := aReportType;
   uQualifier := aQualifier;
   uSortOrder := aSortOrder;
-  uRemoteType := aRemote + '^' + aReportType + '^' + IntToStr(aIFN) + '^' + aHeading + '^' + aRptCode + '^' + aDaysBack;
-  //edtMax.Text := aMax;
-  {if chkText.Checked = true then
-    aHState := aHSTag
-  else
-    aHState := Pieces(aHSTag,';',1,2); }
+  uRemoteType := aRemote + '^' + aReportType + '^' + IntToStr(aIFN) + '^' + aHeading + '^' + aRptCode + '^' + aDaysBack + '^' + aHDR;
+  pnlRightTop.Height := lblTitle.Height;  // see below
   RedrawSuspend(tvReports.Handle);
   RedrawSuspend(memText.Handle);
@@ -1530,9 +1814,8 @@
   TabControl1.TabStop := false;
   sptHorzRight.Visible := false;
-  pnlRightTop.Height := lblTitle.Height;
-  lblProcTypeMsg.Visible := FALSE;         
+  lblProcTypeMsg.Visible := FALSE;
   pnlRightMiddle.Visible := false;
-  pnlProcedures.Visible := FALSE;          
-  if aRemote = '1' then
+  pnlProcedures.Visible := FALSE;
+  if (aRemote = '1') or (aRemote = '2') then
     if not(uReportType = 'V') then
       if TabControl1.Tabs.Count > 1 then
@@ -1543,8 +1826,6 @@
         end;
   StatusText('');
-  //**
   uHTMLDoc := '';
   WebBrowser1.Navigate('about:blank');
-  //**
   memText.Lines.Clear;
   memText.Parent := pnlRightBottom;
@@ -1558,8 +1839,8 @@
   lvReports.Columns.Clear;
   uHSComponents.Clear;
+  DisplayHeading('');
   if uReportType = 'H' then
     begin
       pnlRightMiddle.Visible := false;
-      //lvReports.Visible := false;
       pnlRightBottom.Visible := true;
       WebBrowser1.Visible := true;
@@ -1577,5 +1858,4 @@
             RedrawSuspend(lvReports.Handle);
             Items.BeginUpdate;
-            //Align := alTop;
             ViewStyle := vsReport;
             ColumnHeaders(uColumns, IntToStr(aIFN));
@@ -1598,5 +1878,5 @@
                   else
                     uNewColumn.Width := ColumnHeaderWidth;  //ColumnTextWidth for width of text
-                if (i = 0) and ((aRemote <> '1') or (TabControl1.Tabs.Count < 2)) then
+                if (i = 0) and (((aRemote <> '2') and (aRemote <> '1')) or ((TabControl1.Tabs.Count < 2) and (not (aHDR = '1')))) then
                   uNewColumn.Width := 0;
               end;
@@ -1641,4 +1921,13 @@
     end;
   Screen.Cursor := crHourGlass;
+  if (GraphForm <> nil) and (aReportType <> 'G') then
+  begin
+    GraphForm.SendToBack;
+    GraphPanel(false);
+    GraphFormActive := false;
+  end;
+  if aReportType = 'G' then
+    Graph(aIFN)
+  else
   if aReportType = 'M' then
     begin
@@ -1652,4 +1941,5 @@
         QT_OTHER:
           begin      //      = 0
+            memText.Lines.Clear;
             If copy(aRptCode,1,2) = 'h0' then  //HS Adhoc
               begin
@@ -1666,5 +1956,4 @@
                     TRemoteSite(RemoteSites.SiteList[j]).LabClear;
                   end;
-                memText.Clear;
                 uHTMLDoc := '';
                 if WebBrowser1.Visible = true then WebBrowser1.Navigate('about:blank');
@@ -1692,5 +1981,5 @@
                 splitter1.Visible := false;
                 StatusText('Retrieving ' + tvReports.Selected.Text + '...');
-                GoRemote(uRemoteReportData, aID, aRptCode, aRPC, uHState);
+                GoRemote(uRemoteReportData, aID, aRptCode, aRPC, uHState, aHDR);
                 uReportInstruction := #13#10 + 'Retrieving data...';
                 TabControl1.OnChange(nil);
@@ -1714,7 +2003,7 @@
                 begin
                   lstQualifier.ItemIndex := lstQualifier.Items.Add(aStartTime + ';' + aStopTime + '^' + aStartTime + ' to ' + aStopTime);
-                  uNoRemote := true;
+                  lvReports.SmallImages := uEmptyImageList;
+                  lvReports.Items.Clear;
                   lstQualifierClick(self);
-                  uNoRemote := false;
                 end
               else
@@ -1738,6 +2027,6 @@
                 ViewStyle := vsReport;
                 SmallImages := dmodShared.imgImages;
-                CurrentParentNode := nil;       
-                CurrentNode := nil;             
+                CurrentParentNode := nil;
+                CurrentNode := nil;
                 for i := 0 to uLocalReportData.Count - 1 do
                   begin
@@ -1754,12 +2043,12 @@
                             ListItem.SubItemImages[1] := IMG_NO_IMAGES;
                       end;
-                    LoadProceduresTreeView(uLocalReportData[i], CurrentParentNode, CurrentNode);         
+                    LoadProceduresTreeView(uLocalReportData[i], CurrentParentNode, CurrentNode);
                     if CurrentNode <> nil then
                        PProcTreeObj(CurrentNode.Data)^.Associate := lvReports.Items.IndexOf(ListItem);
                   end;
-                if tvProcedures.Items.Count > 0 then                            
+                if tvProcedures.Items.Count > 0 then
                    tvProcedures.Selected := tvProcedures.Items.GetFirstNode;
-                lblProcTypeMsg.Visible := TRUE;                                 
-                pnlRightTop.Height := lblTitle.Height + lblProcTypeMsg.Height;  
+                lblProcTypeMsg.Visible := TRUE;
+                pnlRightTop.Height := lblTitle.Height + lblProcTypeMsg.Height;
                 pnlLeftBottom.Visible := FALSE;
                 pnlProcedures.Visible := TRUE;
@@ -1824,20 +2113,30 @@
             StatusText('Retrieving ' + tvReports.Selected.Text + '...');
             uReportInstruction := #13#10 + 'Retrieving data...';
+            lvReports.SmallImages := uEmptyImageList;
+            lvReports.Items.Clear;
+            RowObjects.Clear;
+            memText.Lines.Clear;
             if (length(piece(aHSTag,';',2)) > 0) then
               begin
                 if aCategory <> '0' then
                   begin
-
                     ListReportDateRanges(lstQualifier.Items);
-                    if lstQualifier.ItemID = '' then
+                    aQualifierID := lstQualifier.ItemID;
+                    if aQualifierID = '' then
                       begin
-                        lstQualifier.ItemIndex := lstQualifier.Items.Add(aStartTime + ';' + aStopTime + '^' + aStartTime + ' to ' + aStopTime);
-                        uNoRemote := true;
+                        if aHDR = '1' then
+                          lstQualifier.ItemIndex := lstQualifier.Items.Add('T-75000' + ';' + 'T+75000' + '^' + 'T-75000' + ' to ' + 'T+75000')
+                        else
+                          if length(aStartTime) > 0 then lstQualifier.ItemIndex := lstQualifier.Items.Add(aStartTime + ';' + aStopTime + '^' + aStartTime + ' to ' + aStopTime);
                         lstQualifierClick(self);
-                        uNoRemote := false;
                       end
                     else
-                      lstQualifier.Items.Add(aStartTime + ';' + aStopTime + '^' + aStartTime + ' to ' + aStopTime);
-
+                      begin
+                        GoRemote(uRemoteReportData, aID, aQualifier, aRPC, uHState, aHDR);
+                        if aHDR = '1' then
+                          lstQualifier.ItemIndex := lstQualifier.Items.Add('T-75000' + ';' + 'T+75000' + '^' + 'T-75000' + ' to ' + 'T+75000')
+                        else
+                          if length(aStartTime) > 0 then lstQualifier.ItemIndex := lstQualifier.Items.Add(aStartTime + ';' + aStopTime + '^' + aStartTime + ' to ' + aStopTime);
+                      end;
                     lblQualifier.Caption := 'Date Range';
                     pnlLeftBottom.Visible := true;
@@ -1846,18 +2145,20 @@
                 else
                   begin
-                    LoadReportText(uLocalReportData, aID, aQualifier, aRPC, uHState);
-                    memText.Lines.Clear;
-                    //memText.Lines.Assign(uLocalReportData);
-                    RowObjects.Clear;
-                    LoadListView(uLocalReportData);
+                    if not (aRemote = '2' ) then
+                      GoRemote(uRemoteReportData, aID, aQualifier, aRPC, uHState, aHDR);
+                      begin
+                        LoadReportText(uLocalReportData, aID, aQualifier, aRPC, uHState);
+                        LoadListView(uLocalReportData);
+                      end;
                   end;
               end
             else
               begin
-                if aRemote = '1' then
+                if (aRemote = '1') or (aRemote = '2') then
                   if TabControl1.Tabs.Count > 1 then
                     ShowTabControl;
                 sptHorzRight.Visible := false;
                 pnlRightMiddle.Visible := false;
+                GoRemote(uRemoteReportData, aID, aQualifier, aRPC, uHState, aHDR);
                 LoadReportText(uLocalReportData, aID, aQualifier, aRPC, uHState);
                 if uLocalReportData.Count < 1 then
@@ -1871,12 +2172,9 @@
                 if aCategory <> '0' then
                   begin
-
                     ListReportDateRanges(lstQualifier.Items);
                     if lstQualifier.ItemID = '' then
                       begin
                         lstQualifier.ItemIndex := lstQualifier.Items.Add(aStartTime + ';' + aStopTime + '^' + aStartTime + ' to ' + aStopTime);
-                        uNoRemote := true;
                         lstQualifierClick(self);
-                        uNoRemote := false;
                       end
                     else
@@ -1889,6 +2187,4 @@
                 else
                   begin
-                    memText.Lines.Clear;
-                    //memText.Lines.Assign(uLocalReportData);
                     if uLocalReportData.Count < 1 then
                       begin
@@ -1904,5 +2200,4 @@
               end;
             StatusText('');
-            GoRemote(uRemoteReportData, aID, aQualifier, aRPC, uHState);
           end;
         QT_HSWPCOMPONENT:
@@ -1914,20 +2209,30 @@
             uReportInstruction := #13#10 + 'Retrieving data...';
             TabControl1.OnChange(nil);
+            RowObjects.Clear;
+            memText.Lines.Clear;
+            lvReports.SmallImages := uEmptyImageList;
+            lvReports.Items.Clear;
             if (length(piece(aHSTag,';',2)) > 0) then
               begin
                 if aCategory <> '0' then
                   begin
-
                     ListReportDateRanges(lstQualifier.Items);
-                    if lstQualifier.ItemID = '' then
+                    aQualifierID := lstQualifier.ItemID;
+                    if aQualifierID = '' then
                       begin
-                        lstQualifier.ItemIndex := lstQualifier.Items.Add(aStartTime + ';' + aStopTime + '^' + aStartTime + ' to ' + aStopTime);
-                        uNoRemote := true;
+                        if aHDR = '1' then
+                          lstQualifier.ItemIndex := lstQualifier.Items.Add('T-75000' + ';' + 'T+75000' + '^' + 'T-75000' + ' to ' + 'T+75000')
+                        else
+                          if length(aStartTime) > 0 then lstQualifier.ItemIndex := lstQualifier.Items.Add(aStartTime + ';' + aStopTime + '^' + aStartTime + ' to ' + aStopTime);
                         lstQualifierClick(self);
-                        uNoRemote := false;
                       end
                     else
-                      lstQualifier.Items.Add(aStartTime + ';' + aStopTime + '^' + aStartTime + ' to ' + aStopTime);
-
+                      begin
+                        GoRemote(uRemoteReportData, aID, aQualifier, aRPC, uHState, aHDR);
+                        if aHDR = '1' then
+                          lstQualifier.ItemIndex := lstQualifier.Items.Add('T-75000' + ';' + 'T+75000' + '^' + 'T-75000' + ' to ' + 'T+75000')
+                        else
+                          if length(aStartTime) > 0 then lstQualifier.ItemIndex := lstQualifier.Items.Add(aStartTime + ';' + aStopTime + '^' + aStartTime + ' to ' + aStopTime);
+                      end;
                     lblQualifier.Caption := 'Date Range';
                     pnlLeftBottom.Visible := true;
@@ -1936,17 +2241,19 @@
                 else
                   begin
-                    LoadReportText(uLocalReportData, aID, aQualifier, aRPC, uHState);
-                    memText.Lines.Clear;
-                    //memText.Lines.Assign(uLocalReportData);
-                    RowObjects.Clear;
-                    LoadListView(uLocalReportData);
+                    GoRemote(uRemoteReportData, aID, aQualifier, aRPC, uHState, aHDR);
+                    if not (aRemote = '2' ) then
+                      begin
+                        LoadReportText(uLocalReportData, aID, aQualifier, aRPC, uHState);
+                        LoadListView(uLocalReportData);
+                      end;
                   end;
               end
             else
               begin
-                if aRemote = '1' then
+                if (aRemote = '1') or (aRemote = '2') then
                   ShowTabControl;
                 sptHorzRight.Visible := false;
                 pnlRightMiddle.Visible := false;
+                GoRemote(uRemoteReportData, aID, aQualifier, aRPC, uHState, aHDR);
                 LoadReportText(uLocalReportData, aID, aQualifier, aRPC, uHState);
                 if uLocalReportData.Count < 1 then
@@ -1965,7 +2272,5 @@
                       begin
                         lstQualifier.ItemIndex := lstQualifier.Items.Add(aStartTime + ';' + aStopTime + '^' + aStartTime + ' to ' + aStopTime);
-                        uNoRemote := true;
                         lstQualifierClick(self);
-                        uNoRemote := false;
                       end
                     else
@@ -1978,12 +2283,8 @@
                 else
                   begin
-                    memText.Lines.Clear;
-                    //memText.Lines.Assign(uLocalReportData);
-                    RowObjects.Clear;
                     LoadListView(uLocalReportData);
                   end;
               end;
             StatusText('');
-            GoRemote(uRemoteReportData, aID, aQualifier, aRPC, uHState);
           end;
         QT_PROCEDURES:
@@ -2056,5 +2357,5 @@
             splitter1.Visible := false;
             StatusText('Retrieving ' + tvReports.Selected.Text + '...');
-            GoRemote(uRemoteReportData, aID, aRptCode, aRPC, uHState);
+            GoRemote(uRemoteReportData, aID, aRptCode, aRPC, uHState, aHDR);
             uReportInstruction := #13#10 + 'Retrieving data...';
             TabControl1.OnChange(nil);
@@ -2074,9 +2375,10 @@
       end;
     end;
-  if aCategory <> '0' then
-      DisplayHeading(uQualifier)
-  else
-    DisplayHeading('');
-    
+  if not (aHDR = '1') then
+    if aCategory <> '0' then
+        DisplayHeading(uQualifier)
+    else
+      DisplayHeading('');
+
   SendMessage(tvReports.Handle, WM_HSCROLL, SB_THUMBTRACK, 0);
   RedrawActivate(tvReports.Handle);
@@ -2086,5 +2388,5 @@
       WebBrowser1.BringToFront;
     end
-  else
+  else if not GraphFormActive then
     begin
       memText.Visible := true;
@@ -2092,4 +2394,15 @@
       memText.BringToFront;
       RedrawActivate(memText.Handle);
+    end
+  else
+    begin
+      GraphPanel(true);
+      with GraphForm do
+      begin
+        lstDateRange.Items := cboDateRange.Items;
+        lstDateRange.ItemIndex := cboDateRange.ItemIndex;
+        ViewSelections;
+        BringToFront;
+      end;
     end;
   Screen.Cursor := crDefault;
@@ -2712,3 +3025,49 @@
 end;
 
+procedure TfrmReports.chkDualViewsClick(Sender: TObject);
+begin
+  inherited;
+  if (GraphForm <> nil) and GraphFormActive then
+    GraphForm.chkDualViews.Checked := chkDualViews.Checked;
+end;
+
+procedure TfrmReports.btnChangeViewClick(Sender: TObject);
+begin
+  inherited;
+  if (GraphForm <> nil) and GraphFormActive then
+  begin
+    GraphForm.btnChangeSettingsClick(GraphForm);
+    chkDualViews.Checked := GraphForm.chkDualViews.Checked;
+  end;
+end;
+
+procedure TfrmReports.btnGraphSelectionsClick(Sender: TObject);
+begin
+  inherited;
+  if (GraphForm <> nil) and GraphFormActive then
+  begin
+    GraphForm.btnGraphSelectionsClick(GraphForm);
+    chkDualViews.Checked := GraphForm.chkDualViews.Checked;
+  end;
+end;
+
+procedure TfrmReports.lstDateRangeClick(Sender: TObject);
+begin
+  inherited;
+  if (GraphForm <> nil) then
+  begin
+    GraphForm.cboDateRange.ItemIndex := lstDateRange.ItemIndex;
+    GraphForm.cboDateRangeChange(self);
+    lstDateRange.Items.Assign(GraphForm.cboDateRange.Items);
+    lstDateRange.ItemIndex := GraphForm.cboDateRange.ItemIndex;
+    //Exit;
+  end;
+end;
+
+procedure TfrmReports.sptHorzMoved(Sender: TObject);
+begin
+  inherited;
+  pnlTopViews.Height := 80;
+end;
+
 end.
