Ignore:
Timestamp:
May 7, 2015, 12:34:29 PM (9 years ago)
Author:
healthsevak
Message:

Updating the working copy to CPRS version 28

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cprs/trunk/CPRS-Chart/fLabs.pas

    r830 r1679  
    11unit fLabs;
    22
    3 interface
     3interface                                     
    44
    55uses
     
    2222
    2323  TfrmLabs = class(TfrmHSplit)
    24     PopupMenu1: TPopupMenu;
    25     GotoTop1: TMenuItem;
    26     GotoBottom1: TMenuItem;
    27     FreezeText1: TMenuItem;
    28     UnfreezeText1: TMenuItem;
    2924    popChart: TPopupMenu;
    3025    popValues: TMenuItem;
     
    6156    chkGraphZoom: TCheckBox;
    6257    pnlButtons: TORAutoPanel;
    63     lblOld: TOROffsetLabel;
    64     lblPrev: TOROffsetLabel;
    65     lblNext: TOROffsetLabel;
    66     lblRecent: TOROffsetLabel;
    6758    lblMostRecent: TLabel;
    68     lblCollection: TLabel;
    6959    lblDate: TVA508StaticText;
    7060    cmdNext: TButton;
     
    7262    cmdRecent: TButton;
    7363    cmdOld: TButton;
    74     TabControl1: TTabControl;
    7564    grdLab: TCaptionStringGrid;
    7665    pnlChart: TPanel;
     
    8271    serTest: TLineSeries;
    8372    pnlRightTopHeader: TPanel;
    84     lblHeading: TOROffsetLabel;
    85     lblTitle: TOROffsetLabel;
    8673    PopupMenu2: TPopupMenu;
    8774    Print1: TMenuItem;
     
    9279    Copy2: TMenuItem;
    9380    SelectAll2: TMenuItem;
    94     MenuItem1: TMenuItem;
    95     MenuItem2: TMenuItem;
    96     MenuItem3: TMenuItem;
    97     MenuItem4: TMenuItem;
     81    GoToTop1: TMenuItem;
     82    GoToBottom1: TMenuItem;
     83    FreezeText1: TMenuItem;
     84    UnFreezeText1: TMenuItem;
    9885    sptHorzRight: TSplitter;
    9986    pnlFooter: TORAutoPanel;
     
    117104    bvlOtherTests: TBevel;
    118105    cmdOtherTests: TButton;
     106    TabControl1: TTabControl;
     107    pnlRightTopHeaderTop: TPanel;
     108    lblHeading: TOROffsetLabel;
    119109    chkMaxFreq: TCheckBox;
     110    lblTitle: TOROffsetLabel;
     111    Label1: TLabel;
     112    lblSample: TLabel;
     113    Label2: TLabel;
    120114    procedure FormCreate(Sender: TObject);
    121115    procedure DisplayHeading(aRanges: string);
     
    143137    procedure FreezeText1Click(Sender: TObject);
    144138    procedure UnfreezeText1Click(Sender: TObject);
    145     procedure PopupMenu1Popup(Sender: TObject);
    146139    procedure chkZoomClick(Sender: TObject);
    147140    procedure chtChartUndoZoom(Sender: TObject);
     
    198191    procedure SelectAll2Click(Sender: TObject);
    199192    procedure chkMaxFreqClick(Sender: TObject);
    200     procedure sptHorzRightMoved(Sender: TObject);
     193    procedure PopupMenu3Popup(Sender: TObject);
     194    procedure grdLabTopLeftChanged(Sender: TObject);
    201195  private
    202196    { Private declarations }
     
    219213    procedure GoRemote(Dest: TStringList; AItem: string; AQualifier, ARpc: string; AHSTag: string; AHDR: string; aFHIE: string);
    220214    procedure ShowTabControl;
     215    procedure HideTabControl;
    221216    procedure ChkBrowser;
    222217    procedure CommonComponentVisible(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12: Boolean);
     
    235230  frmLabs: TfrmLabs;
    236231  uFormat: integer;
    237   uPrevReportNode: TTreeNode; 
     232  uPrevReportNode: TTreeNode;
    238233  uDate1, uDate2: Tdatetime;
    239234  tmpGrid: TStringList;
     
    241236  uLabRemoteReportData: TStringList; //Storage for Remote lab query
    242237  uUpdateStat: boolean;              //flag turned on when remote status is being updated
    243   uScreenSplitMoved: boolean;        //set if user moves the sptHorzRight Bar
    244238  uScreenSplitLoc: Integer;          //location of user changed split - sptHorzRight Bar
    245239  uTreeStrings: TStrings;
     
    266260uses uCore, rLabs, rCore, rCover, rOrders, fLabPrint, fFrame, fRptBox, Printers, fReportsPrint,
    267261     clipbrd, rReports, rGraphs, activex, mshtml, VA508AccessibilityRouter, uReports,
    268      VAUtils
    269      { TODO -oRV -cWVEHR Long Age : Changed to use long age }
    270      , rWVEHR;
    271 
     262  VAUtils;
    272263
    273264const
     
    405396begin
    406397  inherited;
     398  LabRowObjects := TLabRowObject.Create;
    407399  PageID := CT_LABS;
    408400  uFrozen := False;
    409   uScreenSplitMoved := False;
    410401  aList := TStringList.Create;
    411402  FastAssign(rpcGetGraphSettings, aList);
     
    424415  uPrevReportNode := tvReports.Items.GetFirstNode;
    425416  tvReports.Selected := uPrevReportNode;
    426   if Patient.Inpatient then lstDates.ItemIndex := 2 else lstDates.ItemIndex := 5;
     417  if Patient.Inpatient then lstDates.ItemIndex := 2 else lstDates.ItemIndex := 4;
    427418  lblSingleTest.Caption := '';
    428419  lblSpecimen.Caption := '';
     
    490481  uLabRemoteReportData.Clear;
    491482  TabControl1.Tabs.Clear;
    492   TabControl1.Visible := false;
     483  HideTabControl;
    493484  tmpGrid.Clear;
    494485  lvReports.SmallImages := uEmptyImageList;
     
    506497var
    507498  i: integer;
     499  {OrigSelection: integer;
     500  OrigDateIEN: Int64;
     501  OrigDateItemID: Variant;
     502  OrigReportCat: TTreeNode; }
    508503begin
    509504  inherited DisplayPage;
     
    517512                  + '<TD nowrap><B>Patient: ' + Patient.Name + '</B></TD>'
    518513                  + '<TD nowrap><B>' + Patient.SSN + '</B></TD>'
    519 { TODO -oRV -cWVEHR Long Age : Changed to use long age }
    520                   //+ '<TD nowrap><B>Age: ' + IntToStr(Patient.Age) + '</B></TD>'
    521                   + '<TD nowrap><B>Age: ' + GetPatientBriefAge(Patient.DFN) + '</B></TD>'
    522 {}
     514                  + '<TD nowrap><B>Age: ' + IntToStr(Patient.Age) + '</B></TD>'
    523515                  + '</TR></TABLE></DIV><HR>';
    524516                  //the preferred method would be to use headers and footers
     
    535527  begin
    536528    uColChange := '';
    537     if Patient.Inpatient then lstDates.ItemIndex := 2 else lstDates.ItemIndex := 5;
     529    if Patient.Inpatient then lstDates.ItemIndex := 2 else lstDates.ItemIndex := 4;
    538530    tvReports.Selected := tvReports.Items.GetFirstNode;
    539531    tvReportsClick(self);
     
    571563    CC_INIT_PATIENT:  if not InitPatient then
    572564      begin
    573         if Patient.Inpatient then lstDates.ItemIndex := 2 else lstDates.ItemIndex := 5;
     565        if Patient.Inpatient then lstDates.ItemIndex := 2 else lstDates.ItemIndex := 4;
    574566        tvReports.Selected := tvReports.Items.GetFirstNode;
    575567        tvReportsClick(self);
     
    590582      end;
    591583    CC_NOTIFICATION:  ProcessNotifications;
     584
     585    //This corrects the reload of the labs when switching back to the tab.
     586    {This code was causing the processing of Lab notifications to display
     587     the wrong set of labs for a given notification the 1st notification
     588     after selecting/switching patients.  Upon checking the problem that
     589     this code was trying to solve, we found that the problem no longer
     590     exists, which may be a result of subsequent changes for similar
     591     issues found during development/testing of V28 (CQ 18267, 18268)
     592     CC_CLICK: if not InitPatient then
     593      begin
     594        //Clear our local variables
     595        OrigReportCat := nil;
     596        OrigDateIEN := -1;
     597        OrigSelection := -1;
     598        OrigDateItemID := '';
     599
     600        //What was last selected before they switched tabs.
     601        if tvReports.Selected <> nil then OrigReportCat := tvReports.Selected;
     602        if lstDates.ItemIEN > 0 then OrigDateIEN := lstDates.ItemIEN;
     603        if lvReports.Selected <> nil then OrigSelection := lvReports.Selected.Index;
     604        if lstQualifier.ItemID <> '' then OrigDateItemID := lstQualifier.ItemID;
     605
     606        //Load the tree and select the last selected
     607        if OrigReportCat <> nil then begin
     608         tvReports.Select(OrigReportCat);
     609         tvReportsClick(self);
     610        end;
     611
     612        //Did they click on a date (lstDates box)
     613        if OrigDateIEN > -1 then begin
     614          lstDates.SelectByIEN(OrigDateIEN);
     615          lstDatesClick(self);
     616        end;
     617
     618        //Did they click on a date (lstQualifier)
     619        if OrigDateItemID <> '' then begin
     620          lstQualifier.SelectByID(OrigDateItemID);
     621          lstQualifierClick(self);
     622        end;
     623
     624        //Did they click on a lab
     625        if OrigSelection > -1 then begin
     626         lvReports.Selected := lvReports.Items[OrigSelection];
     627         lvReportsSelectItem(self, lvReports.Selected, true);
     628        end;
     629      end; }
    592630  end;
    593631end;
     
    695733                                  end;
    696734                              end;
    697                             RowObjects.Add(aSite, IntToStr(aCurRow) + ':' + IntToStr(aCurCol), uColumns.Strings[aCurCol], aTmpAray);
     735                            LabRowObjects.Add(aSite, IntToStr(aCurRow) + ':' + IntToStr(aCurCol), uColumns.Strings[aCurCol], aTmpAray);
    698736                            aTmpAray.Clear;
    699737                          end;
     
    740778                            ListItem.SubItems.Add(c);
    741779                          end;
    742                         RowObjects.Add(aSite, IntToStr(aCurRow) + ':' + IntToStr(aCurCol), uColumns.Strings[aCurCol], aTmpAray);
     780                        LabRowObjects.Add(aSite, IntToStr(aCurRow) + ':' + IntToStr(aCurCol), uColumns.Strings[aCurCol], aTmpAray);
    743781                        aTmpAray.Clear;
    744782                      end;
     
    776814                        ListItem.SubItems.Add(c);
    777815                      end;
    778                     RowObjects.Add(aSite, IntToStr(aCurRow) + ':' + IntToStr(aCurCol), uColumns.Strings[aCurCol], aTmpAray);
     816                    LabRowObjects.Add(aSite, IntToStr(aCurRow) + ':' + IntToStr(aCurCol), uColumns.Strings[aCurCol], aTmpAray);
    779817                    aTmpAray.Clear;
    780818                  end;
     
    815853              end;
    816854            DaysBack := Copy(aRanges, 2, Length(aRanges));
     855            if DaysBack = '' then DaysBack := '7';
    817856            if DaysBack = '0' then
    818857              aRanges := 'T' + ';T'
    819858            else
    820               aRanges := 'T-' + DaysBack + ';T';
     859              if Copy(aRanges, 2, 1) = 'T' then
     860                aRanges := DaysBack + ';T'
     861              else
     862                aRanges := 'T-' + DaysBack + ';T';
    821863          end;
    822864        if length(piece(aRanges,';',1)) > 0 then
     
    844886        end;
    845887      end;
    846     if piece(uRemoteType, '^', 9) = '1' then x := x + ' <<ONLY REMOTE DOD DATA INCLUDED IN REPORT>>';
     888    if piece(uRemoteType, '^', 9) = '1' then x := x + ' <<ONLY REMOTE DATA INCLUDED IN REPORT>>';
    847889    Caption := x;
    848890  end;
     
    12351277  var
    12361278  MoreID: String;  //Restores MaxOcc value
    1237   aRemote, aHDR, aFHIE: string;
     1279  aRemote, aHDR, aFHIE, aMax: string;
    12381280  i: integer;
    12391281  tmpList: TStringList;
     
    12871329      SetPiece(uQualifier,';',3,'');
    12881330    end;
     1331  aMax := piece(uQualifier,';',3);
     1332  if (CharAt(lstQualifier.ItemID,1) = 'd')
     1333    and (length(aMax)>0)
     1334    and (StrToInt(aMax)<101) then
     1335      MoreID := ';101';
    12891336  aRemote :=  piece(uRemoteType,'^',1);
    12901337  aHDR := piece(uRemoteType,'^',7);
     
    13851432          lvReports.Items.Clear;
    13861433          memLab.Lines.Clear;
    1387           RowObjects.Clear;
     1434          LabRowObjects.Clear;
    13881435          if ((aRemote = '1') or (aRemote = '2')) then
    13891436            GoRemote(uRemoteReportData, 'L:' + uRptID, lstQualifier.ItemID + MoreID, uReportRPC, uHState, aHDR, aFHIE);
     
    14161463          lvReports.SmallImages := uEmptyImageList;
    14171464          lvReports.Items.Clear;
    1418           RowObjects.Clear;
     1465          LabRowObjects.Clear;
    14191466          memLab.Lines.Clear;
    14201467          if ((aRemote = '1') or (aRemote = '2'))  then
     
    16411688          uHTMLDoc := uHTMLPatient + uLocalReportData.Text;
    16421689        WebBrowser1.Navigate('about:blank');
    1643       end;               }
     1690      end;
     1691               }
    16441692end;
    16451693
     
    17111759      uLabRemoteReportData.Clear;
    17121760      StatusText('Retrieving data for cumulative report...');
    1713       GoRemoteOld(uLabRemoteReportData,0,2,'',uReportRPC,'',IntToStr(daysback),'',date1,date2);
     1761      GoRemoteOld(uLabRemoteReportData,21,2,'',uReportRPC,'',IntToStr(daysback),'',date1,date2);
    17141762      TabControl1.OnChange(nil);
    17151763      Cumulative(uLabLocalReportData, Patient.DFN, daysback, date1, date2, uReportRPC);
     
    17281776      uLabRemoteReportData.Clear;
    17291777      StatusText('Retrieving data for interim report...');
    1730       GoRemoteOld(uLabRemoteReportData,0,3,'',uReportRPC,'','','',date1,date2);
     1778      GoRemoteOld(uLabRemoteReportData,3,3,'',uReportRPC,'','','',date1,date2);
    17311779      TabControl1.OnChange(nil);
    17321780      Interim(uLabLocalReportData, Patient.DFN, date1, date2, uReportRPC);
     
    18331881      uLabRemoteReportData.Clear;
    18341882      StatusText('Retrieving microbiology data...');
    1835       GoRemoteOld(uLabRemoteReportData,0,4,'',uReportRPC,'','','',date1,date2);
     1883      GoRemoteOld(uLabRemoteReportData,4,4,'',uReportRPC,'','','',date1,date2);
    18361884      TabControl1.OnChange(nil);
    18371885      Micro(uLabLocalReportData, Patient.DFN, date1, date2, uReportRPC);
     
    19291977end;
    19301978
     1979procedure TfrmLabs.grdLabTopLeftChanged(Sender: TObject);
     1980var
     1981  i: integer;
     1982begin
     1983  inherited;
     1984  if piece(uRptID,':',1) ='1' then
     1985    begin
     1986      for i := 2 to grdLab.RowCount do
     1987        grdLab.Cells[0,i] := '';
     1988      if not(grdLab.TopRow = 1) then
     1989        grdLab.Cells[0,grdLab.TopRow] := lblDate.Caption;
     1990    end;
     1991end;
     1992
    19311993procedure TfrmLabs.HGrid(griddata: TStrings);
    19321994var
     
    20592121      end;
    20602122      //------------------------------------------------------------------------------------------
    2061       Cells[i - testcnt, 1] := MixedCase(Piece(griddata[i + offset], '^', 4));
     2123      Cells[i - testcnt, 1] := MixedCase(Piece(griddata[i + offset], '^', 4)) + ' ' + Piece(griddata[i + offset], '^', 5);
    20622124    end;
    20632125    for i := testcnt + datecnt + 1 to linecnt do
     
    21092171  uLocalReportData.Free;
    21102172  uRemoteReportData.Free;
     2173  LabRowObjects.Free;
    21112174end;
    21122175
     
    21192182  begin
    21202183    if testcnt = 0 then RowCount := 3 else RowCount := testcnt + 1;
    2121     ColCount := 5;
     2184    ColCount := 6;
    21222185    DefaultColWidth := agrid.Width div ColCount - 2;
    2123     ColWidths[0] := agrid.Width div 4;
    2124     ColWidths[4] := agrid.Width div 4;
    2125     ColWidths[2] := agrid.Width div 9;
    2126     ColWidths[3] := agrid.Width div 6;
    2127     ColWidths[1] := agrid.Width - ColWidths[0] - ColWidths[2] - ColWidths[3] - ColWidths[4] - 8;
     2186    ColWidths[0] := 120;               //agrid.Width div 6;
     2187    ColWidths[1] := agrid.Width div 4; //5
     2188    ColWidths[5] := agrid.Width div 7; //5
     2189    ColWidths[3] := agrid.Width div 14;//12
     2190    ColWidths[4] := agrid.Width div 12;//9
     2191    ColWidths[2] := agrid.Width div 5; //agrid.Width - ColWidths[0] - ColWidths[1] - ColWidths[3] - ColWidths[4] - 8;
    21282192    FixedCols := 0;
    21292193    FixedRows := 1;
     
    21312195      for x := 0 to ColCount - 1 do
    21322196        Cells[x, y] := '';
    2133     Cells[0, 0] := 'Test';
    2134     Cells[1, 0] := 'Result';
    2135     Cells[2, 0] := 'Flag';
    2136     Cells[3, 0] := 'Units';
    2137     Cells[4, 0] := 'Ref Range';
     2197    Cells[0, 0] := 'Collection Date/Time';
     2198    Cells[1, 0] := 'Test';
     2199    Cells[2, 0] := 'Result / Status';
     2200    Cells[3, 0] := 'Flag';
     2201    Cells[4, 0] := 'Units';
     2202    Cells[5, 0] := 'Ref Range';
    21382203    for i := 1 to testcnt do
    21392204    begin
    2140       Cells[0, i] := Piece(aitems[i], '^', 2);
    2141       Cells[1, i] := Piece(aitems[i], '^', 3);
    2142       Cells[2, i] := Piece(aitems[i], '^', 4);
    2143       Cells[3, i] := Piece(aitems[i], '^', 5);
    2144       Cells[4, i] := Piece(aitems[i], '^', 6);
     2205      if i = 1 then Cells[0, i] := lblDate.Caption
     2206      else Cells[0, i] := '';
     2207      Cells[1, i] := Piece(aitems[i], '^', 2);
     2208      Cells[2, i] := Piece(aitems[i], '^', 3);
     2209      Cells[3, i] := Piece(aitems[i], '^', 4);
     2210      Cells[4, i] := Piece(aitems[i], '^', 5);
     2211      Cells[5, i] := Piece(aitems[i], '^', 6);
    21452212    end;
    21462213  end;
     
    21672234  tmpList: TStringList;
    21682235  nexton, prevon: boolean;
    2169   newest, oldest, DisplayDate: string;
     2236  newest, oldest, DisplayDate, aCollection, aSpecimen, aX: string;
     2237  i,ix: integer;
    21702238begin
    21712239  tmpList := TStringList.Create;
    21722240  GetNewestOldest(Patient.DFN, newest, oldest);  //****** PATCH
    2173   nexton := true;
    21742241  prevon := true;
     2242  aCollection := '';
     2243  aSpecimen := '';
     2244  aX := '';
     2245  lblSample.Caption := '';
     2246  lblSample.Color := clBtnFace;
    21752247  try
    21762248    FastAssign(InterimGrid(Patient.DFN, adatetime, direction, uFormat), tmpList);
     
    22132285      if (not prevon) and (uFormat = 2) then
    22142286        prevon := true;
     2287      if Piece(tmpList[0], '^', 2) = 'CH' then
     2288        begin
     2289          lblSample.Caption := 'Specimen: ' + Piece(tmpList[0], '^', 5);
     2290          lblSample.Color := clWindow;
     2291        end;
     2292      if Piece(tmpList[0], '^', 2) = 'MI' then
     2293        begin
     2294          for i  := 0 to tmpList.Count - 1 do
     2295            begin
     2296              if i > 5 then break;
     2297              if ansiContainsStr(tmpList[i],'Collection sample:') then
     2298                begin
     2299                  ix := 0;
     2300                  if length(piece(tmpList[i], ':',2)) > 0 then
     2301                    begin
     2302                      ix := Length(piece(tmpList[i], ':',2));
     2303                      if ix > 15 then ix := ix - 15;
     2304                    end;
     2305                  aCollection := '  Sample: ' + LeftStr(piece(tmpList[i], ':',2),ix);
     2306                end;
     2307            end;
     2308          for i  := 0 to tmpList.Count - 1 do
     2309            begin
     2310              if i > 5 then break;
     2311              if ansiContainsStr(tmpList[i],'Site/Specimen:') then
     2312                begin
     2313                  aSpecimen := 'Specimen: ' + piece(tmpList[i], ':', 2);
     2314                end;
     2315            end;
     2316          aX := aSpecimen + aCollection;
     2317          if Length(aX) > 0 then
     2318            begin
     2319              lblSample.Caption := aX;
     2320              lblSample.Color := clWindow;
     2321            end;
     2322        end;
    22152323    end
    22162324    else
     
    22182326      lblDateFloat.Caption := '';
    22192327      lblDate.Caption := '';
     2328      nexton := false;
     2329      prevon := false;
    22202330    end;
    22212331    cmdNext.Enabled := nexton;
    22222332    cmdRecent.Enabled := nexton;
    2223     lblNext.Enabled := nexton;
    2224     lblRecent.Enabled := nexton;
    22252333    cmdPrev.Enabled := prevon;
    22262334    cmdOld.Enabled := prevon;
    2227     lblPrev.Enabled := prevon;
    2228     lblOld.Enabled := prevon;
    22292335    if cmdOld.Enabled and cmdRecent.Enabled then
    22302336      lblMostRecent.Visible := false
     
    22332339      lblMostRecent.Visible := true;
    22342340      if (not cmdOld.Enabled) and (not cmdRecent.Enabled) then
    2235         lblMostRecent.Caption := 'No Lab Results'
     2341        lblMostRecent.Caption := 'No Lab Data'
    22362342      else if cmdOld.Enabled then
    2237         lblMostRecent.Caption := 'Most Recent Lab Result'
     2343        lblMostRecent.Caption := 'Most Recent Lab Data'
    22382344      else
    2239         lblMostRecent.Caption := 'Oldest Lab Result';
     2345        lblMostRecent.Caption := 'Oldest Lab Data';
    22402346    end;
    22412347    if tmpList.Count > 0 then
     
    22452351        FillGrid(grdLab, tmpList);
    22462352        FillComments(memLab, tmpList);
    2247         if uScreenSplitMoved = false then
    2248           begin
    2249             pnlRightTop.Height := pnlRight.Height - (pnlRight.Height div 5);
    2250             uScreenSplitLoc := sptHorzRight.Top;
    2251           end
    2252         else
    2253           pnlRightTop.Height := uScreenSplitLoc;
     2353        pnlRightTop.Height := pnlRight.Height - (pnlRight.Height div 5);
     2354        sptHorzRight.Top := pnlRightTop.Height;
     2355        uScreenSplitLoc := sptHorzRight.Top;
    22542356        pnlRightBottom.Height := pnlLeft.Height div 5;
    22552357        memLab.Height := pnlLeft.Height div 5;
     
    22782380        pnlFooter.Visible := false;
    22792381        sptHorzRight.Visible := true;
    2280         pnlRightTop.Height := pnlHeader.Height + TabControl1.Height;
     2382        TabControl1.Visible := false;
     2383        pnlRightTop.Height := pnlHeader.Height;
    22812384        memLab.Height := pnlRight.Height - (lblHeading.Height + lblTitle.Height + pnlHeader.Height);
    22822385        pnlRightTop.Visible := true;
     
    23892492  if numtest > 0 then
    23902493  begin
    2391   for i := 1 to numtest do
    2392     if testnum = Piece(aitems[i], '^', 2) then
    2393     begin
    2394       testorder := inttostr(i);
    2395       break;
    2396     end;
    2397   GetStartStop(start, stop, aitems);
    2398   if OKFloatValue(high) then
    2399   begin
    2400     serHigh.AddXY(FMToDateTime(start), strtofloat(high), '',clTeeColor);
    2401     serHigh.AddXY(FMToDateTime(stop), strtofloat(high), '',clTeeColor);
    2402   end;
    2403   if OKFloatValue(low) then
    2404   begin
    2405     serLow.AddXY(FMToDateTime(start), strtofloat(low), '',clTeeColor);
    2406     serLow.AddXY(FMToDateTime(stop), strtofloat(low), '',clTeeColor);
    2407   end;
    2408   numspec := Piece(specimen, '^', 1);
    2409   chtChart.Legend.Color := grdLab.Color;
    2410   chtChart.Title.Font.Size := MainFontSize;
    2411   chtChart.LeftAxis.Title.Caption := units;
    2412   serTest.Title := Piece(test, '^', 2);
    2413   serHigh.Title := 'Ref High ' + high;
    2414   serLow.Title := 'Ref Low ' + low;
    2415   testcheck := testorder;
    2416   for i := numtest + numcol + 1 to numtest + numcol + numvalues do
    2417     if Piece(aitems[i], '^', 2) = testcheck then
    2418       if Piece(aitems[numtest + strtoint(Piece(aitems[i], '^', 1))], '^', 3) = numspec then
     2494    for i := 1 to numtest do
     2495      if testnum = Piece(aitems[i], '^', 2) then
    24192496      begin
    2420         value := Piece(aitems[i], '^', 3);
    2421         if OkFloatValue(value) then
     2497        testorder := inttostr(i);
     2498        break;
     2499      end;
     2500    GetStartStop(start, stop, aitems);
     2501    if OKFloatValue(high) then
     2502    begin
     2503      serHigh.AddXY(FMToDateTime(start), strtofloat(high), '',clTeeColor);
     2504      serHigh.AddXY(FMToDateTime(stop), strtofloat(high), '',clTeeColor);
     2505    end;
     2506    if OKFloatValue(low) then
     2507    begin
     2508      serLow.AddXY(FMToDateTime(start), strtofloat(low), '',clTeeColor);
     2509      serLow.AddXY(FMToDateTime(stop), strtofloat(low), '',clTeeColor);
     2510    end;
     2511    numspec := Piece(specimen, '^', 1);
     2512    chtChart.Legend.Color := grdLab.Color;
     2513    chtChart.Title.Font.Size := MainFontSize;
     2514    chtChart.LeftAxis.Title.Caption := units;
     2515    serTest.Title := Piece(test, '^', 2);
     2516    serHigh.Title := 'Ref High ' + high;
     2517    serLow.Title := 'Ref Low ' + low;
     2518    testcheck := testorder;
     2519    for i := numtest + numcol + 1 to numtest + numcol + numvalues do
     2520      if Piece(aitems[i], '^', 2) = testcheck then
     2521        if Piece(aitems[numtest + strtoint(Piece(aitems[i], '^', 1))], '^', 3) = numspec then
    24222522        begin
    2423           labvalue := strtofloat(value);
    2424           datevalue := FMToDateTime(Piece(aitems[numtest + strtoint(Piece(aitems[i], '^', 1))], '^', 2));
    2425           serTest.AddXY(datevalue, labvalue, '', clTeeColor);
    2426           inc(valuecount);
     2523          value := Piece(aitems[i], '^', 3);
     2524          if OkFloatValue(value) then
     2525          begin
     2526            labvalue := strtofloat(value);
     2527            datevalue := FMToDateTime(Piece(aitems[numtest + strtoint(Piece(aitems[i], '^', 1))], '^', 2));
     2528            serTest.AddXY(datevalue, labvalue, '', clTeeColor);
     2529            inc(valuecount);
     2530          end;
    24272531        end;
    2428       end;
    24292532  end;
    24302533  if valuecount = 0 then
     
    29803083                        begin
    29813084                          aSID := Items[i].SubItems[0];
    2982                           for j := 0 to RowObjects.ColumnList.Count - 1 do
    2983                             if piece(aSID,':',1) = piece(TCellObject(RowObjects.ColumnList[j]).Handle,':',1) then
    2984                               if Item.Caption = (piece(TCellObject(RowObjects.ColumnList[j]).Site,';',1)) then
    2985                                 if (TCellObject(RowObjects.ColumnList[j]).Data.Count > 0) and
    2986                                   (TCellObject(RowObjects.ColumnList[j]).Include = '1') then
     3085                          for j := 0 to LabRowObjects.ColumnList.Count - 1 do
     3086                            if piece(aSID,':',1) = piece(TCellObject(LabRowObjects.ColumnList[j]).Handle,':',1) then
     3087                              if Item.Caption = (piece(TCellObject(LabRowObjects.ColumnList[j]).Site,';',1)) then
     3088                                if (TCellObject(LabRowObjects.ColumnList[j]).Data.Count > 0) and
     3089                                  (TCellObject(LabRowObjects.ColumnList[j]).Include = '1') then
    29873090                                  begin
    29883091                                    aWPFlag := true;
    2989                                     MemLab.Lines.Add(TCellObject(RowObjects.ColumnList[j]).Name);
    2990                                     FastAssign(TCellObject(RowObjects.ColumnList[j]).Data, aBasket);
     3092                                    MemLab.Lines.Add(TCellObject(LabRowObjects.ColumnList[j]).Name);
     3093                                    FastAssign(TCellObject(LabRowObjects.ColumnList[j]).Data, aBasket);
    29913094                                    for k := 0 to aBasket.Count - 1 do
    2992                                       MemLab.Lines.Add('  ' + aBasket[k]);
     3095                                      MemLab.Lines.Add(' ' + aBasket[k]);
    29933096                                  end;
    29943097                          if aWPFlag = true then
     
    30013104                aBasket.Clear;
    30023105                aWPFlag := false;
    3003                 for i := 0 to RowObjects.ColumnList.Count - 1 do
    3004                   if piece(aID,':',1) = piece(TCellObject(RowObjects.ColumnList[i]).Handle,':',1) then
    3005                     if Item.Caption = (piece(TCellObject(RowObjects.ColumnList[i]).Site,';',1)) then
    3006                       if (TCellObject(RowObjects.ColumnList[i]).Data.Count > 0) and
    3007                         (TCellObject(RowObjects.ColumnList[i]).Include = '1') then
     3106                for i := 0 to LabRowObjects.ColumnList.Count - 1 do
     3107                  if piece(aID,':',1) = piece(TCellObject(LabRowObjects.ColumnList[i]).Handle,':',1) then
     3108                    if Item.Caption = (piece(TCellObject(LabRowObjects.ColumnList[i]).Site,';',1)) then
     3109                      if (TCellObject(LabRowObjects.ColumnList[i]).Data.Count > 0) and
     3110                        (TCellObject(LabRowObjects.ColumnList[i]).Include = '1') then
    30083111                        begin
    30093112                          aWPFlag := true;
    3010                           MemLab.Lines.Add(TCellObject(RowObjects.ColumnList[i]).Name);
    3011                           FastAssign(TCellObject(RowObjects.ColumnList[i]).Data, aBasket);
     3113                          MemLab.Lines.Add(TCellObject(LabRowObjects.ColumnList[i]).Name);
     3114                          FastAssign(TCellObject(LabRowObjects.ColumnList[i]).Data, aBasket);
    30123115                          for j := 0 to aBasket.Count - 1 do
    3013                             MemLab.Lines.Add('  ' + aBasket[j]);
     3116                            MemLab.Lines.Add(' ' + aBasket[j]);
    30143117                        end;
    30153118                if aWPFlag = true then
     
    31203223begin
    31213224  inherited;
    3122 with memLab do
    3123   begin
    3124     SetFocus;
    3125     SelStart :=0;
    3126     SelLength :=0;
    3127   end;
     3225  SendMessage(memLab.Handle, WM_VSCROLL, SB_TOP, 0);
     3226  {GoToTop1.Enabled := false;
     3227  GoToBottom1.Enabled := true; }
    31283228end;
    31293229
    31303230procedure TfrmLabs.GotoBottom1Click(Sender: TObject);
    3131 var
    3132   I,CharCount : Integer;
    31333231begin
    31343232  Inherited;
    3135   CharCount :=0;
    3136   with memLab do
    3137   begin
    3138     for I := 0 to lines.count-1 do
    3139       CharCount := CharCount + Length(Lines[I]) + 2;
    3140     SetFocus;
    3141     SelStart := CharCount;
    3142     SelLength :=0;
    3143   end;
     3233  SendMessage(memLab.Handle, WM_VSCROLL, SB_BOTTOM, 0);
     3234  {GoToTop1.Enabled := true;
     3235  GoToBottom1.Enabled := false; }
    31443236end;
    31453237
     
    31773269end;
    31783270
    3179 procedure TfrmLabs.PopupMenu1Popup(Sender: TObject);
     3271procedure TfrmLabs.PopupMenu3Popup(Sender: TObject);
    31803272begin
    31813273 inherited;
     
    31913283  If Memo1.Visible Then
    31923284    UnFreezeText1.Enabled := True;
    3193   If memLab.SelStart > 0 then
     3285  {If memLab.SelStart > 0 then
    31943286    GotoTop1.Enabled := True
    31953287  Else
     
    31993291    GotoBottom1.Enabled := True
    32003292  Else
    3201     GotoBottom1.Enabled := False;
     3293    GotoBottom1.Enabled := False; }
    32023294  {case lstReports.ItemIEN of
    32033295    1: FreezeText1.Enabled := False;
     
    32333325  if StrToIntDef(OrderIFN,0) > 0 then
    32343326   begin
    3235     //the following if condition & clause resolves CQ 16405 & 17076 - a mixture of two different patient's lab results in one display.
     3327    //the following if condition & clause resolves CQ 16405 & 17076 - a mixture of two different patient's lab results in one display (TC).
    32363328    if (AnsiContainsStr(tvReports.Selected.Text, 'Microbiology')) or (AnsiContainsStr(tvReports.Selected.Text, 'Anatomic Pathology'))
    32373329    or (AnsiContainsStr(tvReports.Selected.Text, 'Cytology')) or (AnsiContainsStr(tvReports.Selected.Text, 'Electron Microscopy'))
    32383330    or (AnsiContainsStr(tvReports.Selected.Text, 'Surgical Pathology')) and (lvReports.Visible = TRUE) then
    32393331       begin
    3240          tvReports.Selected := tvReports.TopItem;
    32413332         lvReports.Visible := FALSE;
    3242          DisplayHeading('');
    32433333       end;
     3334    tvReports.Selected := tvReports.TopItem;    //moved here to fix the conflicting lab results caption header that is displayed with the alert message text.
     3335    DisplayHeading('');    //fixes part B of CQ #17548 - CPRS v28.1 (TC)
    32443336    lstDates.ItemIndex      := -1;
    32453337    Memo1.Visible           := false;
     
    32703362   else
    32713363   begin
    3272      if Patient.Inpatient then lstDates.ItemIndex := 2 else lstDates.ItemIndex := 5;
     3364     if Patient.Inpatient then lstDates.ItemIndex := 2 else lstDates.ItemIndex := 4;
    32733365     tvReports.Selected := tvReports.Items.GetFirstNode;
    32743366     tvReportsClick(self);
     
    35183610procedure TfrmLabs.Timer1Timer(Sender: TObject);
    35193611var
    3520   i,j: integer;
     3612  i,j,fail: integer;
    35213613  r0: String;
    35223614begin
     
    35263618    for i := 0 to Count - 1 do
    35273619      if TRemoteSite(Items[i]).Selected then
     3620       begin
    35283621        if Length(TRemoteSite(Items[i]).LabRemoteHandle) > 0 then
    35293622          begin
    35303623            r0 := GetRemoteStatus(TRemoteSite(Items[i]).LabRemoteHandle);
    35313624            TRemoteSite(Items[i]).LabQueryStatus := r0; //r0='1^Done' if no errors
     3625            UpdateRemoteStatus(TRemoteSite(Items[i]).SiteID, piece(r0,'^',2));
    35323626            if piece(r0,'^',1) = '1' then
    35333627              begin
     3628                GetRemoteData(TRemoteSite(Items[i]).LabData,
     3629                  TRemoteSite(Items[i]).LabRemoteHandle,Items[i]);
    35343630                RemoteReports.Add(TRemoteSite(Items[i]).CurrentLabQuery,
    35353631                  TRemoteSite(Items[i]).LabRemoteHandle);
    3536                 GetRemoteData(TRemoteSite(Items[i]).LabData,
    3537                   TRemoteSite(Items[i]).LabRemoteHandle,Items[i]);
    35383632                TRemoteSite(Items[i]).LabRemoteHandle := '';
    35393633                TabControl1.OnChange(nil);
     3634                if (length(piece(uHState,';',2)) > 0) then
     3635                  begin
     3636                    uRemoteReportData.Clear;
     3637                    QuickCopy(TRemoteSite(Items[i]).LabData,uRemoteReportData);
     3638                    fail := 0;
     3639                    if uRemoteReportData.Count > 0 then
     3640                      begin
     3641                        if uRemoteReportData[0] = 'Report not available at this time.' then
     3642                          begin
     3643                            fail := 1;
     3644                            UpdateRemoteStatus(TRemoteSite(Items[i]).SiteID,'Report not available');
     3645                          end;
     3646                        if piece(uRemoteReportData[0],'^',1) = '-1' then
     3647                          begin
     3648                            fail := 1;
     3649                            UpdateRemoteStatus(TRemoteSite(Items[i]).SiteID,'Communication failure');
     3650                          end;
     3651                        if fail = 0 then
     3652                          LoadListView(uRemoteReportData);
     3653                      end;
     3654                  end;
    35403655              end
    35413656            else
    35423657              begin
    35433658                uRemoteCount := uRemoteCount + 1;
    3544                 if uRemoteCount > 60 then //5 minute limit
     3659                if uRemoteCount > 90 then //~7 minute limit
    35453660                  begin
    3546                     Timer1.Enabled := False;
     3661                    TRemoteSite(Items[i]).LabRemoteHandle := '';
    35473662                    TRemoteSite(Items[i]).LabQueryStatus := '-1^Timed out';
    35483663                    UpdateRemoteStatus(TRemoteSite(Items[i]).SiteID, 'Timed out');
     
    35543669                    + TRemoteSite(Items[i]).SiteName + '...');
    35553670              end;
    3556             Timer1.Interval := 5000;
     3671            Timer1.Interval := 10000;
    35573672          end;
     3673       end;
    35583674     if Timer1.Enabled = True then
    35593675       begin
    35603676         j := 0;
    35613677         for i := 0 to Count -1 do
    3562            if Length(TRemoteSite(Items[i]).LabRemoteHandle) > 0 then
    3563              j := 1;
     3678           begin
     3679             if Length(TRemoteSite(Items[i]).LabRemoteHandle) > 0 then
     3680               begin
     3681                 j := 1;
     3682                 break;
     3683               end;
     3684           end;
    35643685         if j = 0 then  //Shutdown timer if all sites have been processed
    35653686           begin
     
    35703691         for i := 0 to Count -1 do
    35713692           if TRemoteSite(Items[i]).Selected = true then
    3572              j := 1;
     3693             begin
     3694               j := 1;
     3695               break;
     3696             end;
    35733697         if j = 0 then  //Shutdown timer if user has de-selected all sites
    35743698           begin
     
    35843708var
    35853709  i: integer;
    3586   ListItem: TListItem;
    35873710  aHeading, aReportType, aRPC, aQualifier, aStartTime, aStopTime, aMax, aRptCode, aRemote, aCategory, aSortOrder, aDaysBack, x, x1, x2: string;
    35883711  aIFN, aOldID: integer;
    3589   aID, aHSTag, aRadParam, aColChange, aDirect, aHDR, aFHIE, aFHIEONLY, aQualifierID: string;
    3590   CurrentParentNode, CurrentNode: TTreeNode;
    3591 begin
    3592   inherited;
     3712  aID, aHSTag, aColChange, aDirect, aHDR, aFHIE, aFHIEONLY, aQualifierID: string;
     3713  CurrentNode: TTreeNode;
     3714begin
     3715  inherited;
     3716  if (Length(lblHeading.Caption) > 0) and (Length(frmFrame.stsArea.Panels.Items[1].Text) > 0) then
     3717    begin                                           //ProcessNotfications post-cleanup and clearing of notification message text
     3718      lblHeading.Caption := '';                     //in the header and status bar display when clicking to view lab results.
     3719      frmFrame.stsArea.Panels.Items[1].Text := '';
     3720    end;
    35933721  lvReports.Hint := 'To sort, click on column headers|';
    35943722  tvReports.TopItem := tvReports.Selected;
     
    36383766  uReportRPC := aRPC;
    36393767  uRptID := aID;
     3768  uLabRepID := aID;
    36403769  uDirect := aDirect;
    36413770  uReportType := aReportType;
     
    36483777  uHState := aHSTag;
    36493778  Timer1.Enabled := False;
    3650   TabControl1.Visible := false;
    3651   TabControl1.TabStop := false;
     3779  HideTabControl;
    36523780  sptHorzRight.Visible := true;
    36533781  lvReports.Visible := false;
    36543782  if (aRemote = '1') or (aRemote = '2') then
    36553783    if not(uReportType = 'V') then
    3656       if TabControl1.Tabs.Count > 1 then
    3657         begin
    3658           TabControl1.Visible := true;
    3659           TabControl1.TabStop := true;
    3660           pnlRightTop.Height := lblTitle.Height + TabControl1.Height;
    3661         end;
     3784      ShowTabControl;
    36623785  StatusText('');
    36633786  uHTMLDoc := '';
     
    36693792  lvReports.Items.Clear;
    36703793  lvReports.Columns.Clear;
    3671   lblHeading.Caption := '';  //clears Notification text to reduce confusion with lblTitle.Caption.
    36723794  DisplayHeading('');
    36733795  if uReportType = 'H' then
     
    37383860      end;
    37393861  uLocalReportData.Clear;
    3740   RowObjects.Clear;
     3862  LabRowObjects.Clear;
    37413863  uRemoteReportData.Clear;
    37423864  lstHeaders.Visible := false;
     
    38353957                     uPrevReportNode := tvReports.Selected;
    38363958                    end
    3837                     else tvReports.Selected := uPrevReportNode;
     3959                    else
     3960                      begin
     3961                        uPrevReportNode := tvReports.Items.GetFirstNode;
     3962                        tvReports.Selected := uPrevReportNode;
     3963                        tvReportsClick(self);
     3964                      end;
    38383965                  end
    38393966            else if aID = '5:WORKSHEET' then
     
    38643991                     //chkZoom.Checked := false;
    38653992                     //chkZoomClick(self);
    3866                      lstDatesClick(self);
     3993                     //lstDatesClick(self);
    38673994                     //lstQualifierClick(self);
    38683995                     cmdOtherTests.SetFocus;
    38693996                     cmdOtherTests.Default := true;
    38703997                     uPrevReportNode := tvReports.Selected;
     3998                     if lstDates.ItemIndex = -1 then
     3999                      if Patient.Inpatient then lstDates.ItemIndex := 2
     4000                      else lstDates.ItemIndex := 4;
     4001                     //for i := 1 to lstDates.Count - 1 do  //Sets default date range to next item > 1 Month (which should be 6 months)
     4002                      //if strToInt(piece(lstDates.Items[i],'^',1)) > 31 then
     4003                        //begin
     4004                          //lstDates.ItemIndex := i;
     4005                          //break;
     4006                        //end;
     4007                     lstDatesClick(self);
    38714008                     if ScreenReaderSystemActive then
    38724009                       grdLab.SetFocus;
    38734010                    end
    3874                     else tvReports.Selected := uPrevReportNode;
     4011                    else
     4012                      begin
     4013                        uPrevReportNode := tvReports.Items.GetFirstNode;
     4014                        tvReports.Selected := uPrevReportNode;
     4015                        tvReportsClick(self);
     4016                      end;
    38754017                  end
    38764018
     
    39434085                     end
    39444086                     else
    3945                        tvReports.Selected := uPrevReportNode;
     4087                       tvReports.Selected := uPrevReportNode; 
    39464088                    end;
    39474089                  end
     
    39574099                    sptHorzRight.Visible := false;
    39584100                    pnlRightTop.Height := lblHeading.Height;
     4101                    if ((aRemote = '1') or (aRemote = '2')) then
     4102                      ShowTabControl;
     4103                    pnlRightTopHeader.Align := alTop;
    39594104                    pnlRightTop.Align := alTop;
     4105                    TabControl1.Align := alTop;
    39604106                    pnlRightBottom.Align := alclient;
    39614107                    sptHorzRight.Visible := true;
    39624108                    pnlRightBottom.Visible := true;
    39634109                    lvReports.Visible := false;
    3964                     memLab.Height := pnlRight.Height - (lblHeading.Height + lblTitle.Height);
    39654110                    memLab.Align := alClient;
     4111                    if lstDates.ItemIndex = -1 then
     4112                      if Patient.Inpatient then lstDates.ItemIndex := 2
     4113                      else lstDates.ItemIndex := 4;
     4114                    {for i := 1 to lstDates.Count - 1 do  //Sets default date range to next item > 1 Month (which should be 6 months)
     4115                      if strToInt(piece(lstDates.Items[i],'^',1)) > 31 then
     4116                        begin
     4117                          lstDates.ItemIndex := i;
     4118                          break;
     4119                        end;  }
    39664120                    FormResize(self);
    39674121                    aOldID := 1;
     
    39844138                          CommonComponentVisible(false,false,false,false,false,false,false,false,false,false,false,false);
    39854139                          StatusText('Retrieving data...');
    3986                           GoRemoteOld(uLabRemoteReportData,0,aOldID,'',uReportRPC,'0','9999','1',0,0);
     4140                          GoRemoteOld(uLabRemoteReportData,StrToInt(Piece(aID,':',1)),aOldID,'',uReportRPC,'0','9999','1',0,0);
    39874141                          //GoRemote(uRemoteReportData, aID, aRptCode, aRPC, uHState, aHDR, aFHIE);
    39884142                          TabControl1.OnChange(nil);
     
    40114165                          lstHeaders.Clear;
    40124166                          StatusText('Retrieving data...');
    4013                           GoRemoteOld(uLabRemoteReportData,0,aOldID,'',uReportRPC,'0','9999','1',0,0);
     4167                          GoRemoteOld(uLabRemoteReportData,StrToInt(Piece(aID,':',1)),aOldID,'',uReportRPC,'0','9999','1',0,0);
    40144168                          //GoRemote(uRemoteReportData, aID, aRptCode, aRPC, uHState, aHDR, aFHIE);
    40154169                          TabControl1.OnChange(nil);
     
    40984252            lvReports.SmallImages := uEmptyImageList;
    40994253            lvReports.Items.Clear;
    4100             RowObjects.Clear;
     4254            LabRowObjects.Clear;
    41014255            memLab.Lines.Clear;
    41024256            if (length(piece(aHSTag,';',2)) > 0) then
     
    41884342        QT_HSWPCOMPONENT:
    41894343          begin      //      = 6
    4190             if uScreenSplitMoved = false then
    4191               begin
    4192                 pnlRightTop.Height := pnlRight.Height - (pnlRight.Height div 2);
    4193                 uScreenSplitLoc := sptHorzRight.Top;
    4194               end
    4195             else
    4196               pnlRightTop.Height := uScreenSplitLoc;
     4344            pnlRightTop.Height := pnlRight.Height - (pnlRight.Height div 2);
     4345            sptHorzRight.top := pnlRightTop.Height;
     4346            uScreenSplitLoc := sptHorzRight.Top;
    41974347            pnlLeftBottom.Visible := false;
    41984348            splitter1.Visible := false;
     
    42054355            memLab.Visible := true;
    42064356            TabControl1.OnChange(nil);
    4207             RowObjects.Clear;
     4357            LabRowObjects.Clear;
    42084358            memLab.Lines.Clear;
    42094359            lvReports.SmallImages := uEmptyImageList;
    42104360            lvReports.Items.Clear;
     4361            memLab.Repaint;
    42114362            if (length(piece(aHSTag,';',2)) > 0) then
    42124363              begin
     
    44564607      begin
    44574608        TRemoteSite(Items[i]).Selected := true;
    4458         frmFrame.lstCIRNLocations.Checked[i+2] := true;
     4609        frmFrame.lstCIRNLocations.Checked[i+1] := true;
    44594610      end;
    44604611    if TRemoteSite(Items[i]).Selected then
     
    44634614        if (LeftStr(TRemoteSite(Items[i]).SiteID, 5) = '200HD') and not(AHDR = '1') then
    44644615          begin
    4465             TRemoteSite(Items[i]).QueryStatus := '1^Not Included';
     4616            TRemoteSite(Items[i]).LabQueryStatus := '1^Not Included';
    44664617            UpdateRemoteStatus(TRemoteSite(Items[i]).SiteID, 'NOT INCLUDED');
    4467             TRemoteSite(Items[i]).RemoteHandle := '';
    4468             TRemoteSite(Items[i]).QueryStatus := '1^Done';
     4618            TRemoteSite(Items[i]).LabRemoteHandle := '';
     4619            TRemoteSite(Items[i]).LabQueryStatus := '1^Done';
    44694620            if uQualifierType = 6 then seq := '1^';
    44704621            TRemoteSite(Items[i]).Data.Add(seq + TRemoteSite(Items[i]).SiteName);
     
    44784629        if (AHDR = '1') and not(LeftStr(TRemoteSite(Items[i]).SiteID, 5) = '200HD') then
    44794630          begin
    4480             TRemoteSite(Items[i]).QueryStatus := '1^Not Included';
     4631            TRemoteSite(Items[i]).LabQueryStatus := '1^Not Included';
    44814632            UpdateRemoteStatus(TRemoteSite(Items[i]).SiteID, 'NOT INCLUDED');
    4482             TRemoteSite(Items[i]).RemoteHandle := '';
    4483             TRemoteSite(Items[i]).QueryStatus := '1^Done';
     4633            TRemoteSite(Items[i]).LabRemoteHandle := '';
     4634            TRemoteSite(Items[i]).LabQueryStatus := '1^Done';
    44844635            if uQualifierType = 6 then seq := '1^';
    44854636            TRemoteSite(Items[i]).Data.Add(seq + TRemoteSite(Items[i]).SiteName);
     
    44934644        if (LeftStr(TRemoteSite(Items[i]).SiteID, 5) = '200') and not(aFHIE = '1') then
    44944645          begin
    4495             TRemoteSite(Items[i]).QueryStatus := '1^Not Included';
     4646            TRemoteSite(Items[i]).LabQueryStatus := '1^Not Included';
    44964647            UpdateRemoteStatus(TRemoteSite(Items[i]).SiteID, 'NOT INCLUDED');
    4497             TRemoteSite(Items[i]).RemoteHandle := '';
    4498             TRemoteSite(Items[i]).QueryStatus := '1^Done';
     4648            TRemoteSite(Items[i]).LabRemoteHandle := '';
     4649            TRemoteSite(Items[i]).LabQueryStatus := '1^Done';
    44994650            if uQualifierType = 6 then seq := '1^';
    45004651            TRemoteSite(Items[i]).Data.Add(seq + TRemoteSite(Items[i]).SiteName);
     
    45254676            begin
    45264677              GetRemoteData(TRemoteSite(Items[i]).Data,LocalHandle,Items[i]);
    4527               TRemoteSite(Items[i]).RemoteHandle := '';
    4528               TRemoteSite(Items[i]).QueryStatus := '1^Done';
     4678              TRemoteSite(Items[i]).LabRemoteHandle := '';
     4679              TRemoteSite(Items[i]).LabQueryStatus := '1^Done';
    45294680              UpdateRemoteStatus(TRemoteSite(Items[i]).SiteID, 'Done');
    45304681              TabControl1.OnChange(nil);
     
    45374688              begin
    45384689                StatusText('Retrieving reports from ' + TRemoteSite(Items[i]).SiteName + '...');
    4539                 TRemoteSite(Items[i]).QueryStatus := '1^Direct Call';
     4690                TRemoteSite(Items[i]).LabQueryStatus := '1^Direct Call';
    45404691                UpdateRemoteStatus(TRemoteSite(Items[i]).SiteID, 'Direct Call');
    45414692                DirectQuery(Dest, AItem, HSType, Daysback, ExamID, Alpha, Omega, TRemoteSite(Items[i]).SiteID, ARpc, AHSTag);
    45424693                if Copy(Dest[0],1,2) = '-1' then
    45434694                  begin
    4544                     TRemoteSite(Items[i]).QueryStatus := '-1^Communication error';
     4695                    TRemoteSite(Items[i]).LabQueryStatus := '-1^Communication error';
    45454696                    UpdateRemoteStatus(TRemoteSite(Items[i]).SiteID,'Communication error');
    45464697                    if uQualifierType = 6 then seq := '1^';
     
    45554706                  begin
    45564707                    QuickCopy(Dest,TRemoteSite(Items[i]).Data);
    4557                     TRemoteSite(Items[i]).RemoteHandle := '';
    4558                     TRemoteSite(Items[i]).QueryStatus := '1^Done';
     4708                    TRemoteSite(Items[i]).LabRemoteHandle := '';
     4709                    TRemoteSite(Items[i]).LabQueryStatus := '1^Done';
    45594710                    UpdateRemoteStatus(TRemoteSite(Items[i]).SiteID, 'Done');
    45604711                    TabControl1.OnChange(nil);
     
    45694720                if Dest[0] = '' then
    45704721                  begin
    4571                     TRemoteSite(Items[i]).QueryStatus := '-1^Communication error';
     4722                    TRemoteSite(Items[i]).LabQueryStatus := '-1^Communication error';
    45724723                    UpdateRemoteStatus(TRemoteSite(Items[i]).SiteID,'Communication error');
    45734724                    if uQualifierType = 6 then seq := '1^';
     
    45814732                else
    45824733                  begin
    4583                     TRemoteSite(Items[i]).RemoteHandle := Dest[0];
    4584                     TRemoteSite(Items[i]).QueryStatus := '0^initialization...';
     4734                    TRemoteSite(Items[i]).LabRemoteHandle := Dest[0];
     4735                    TRemoteSite(Items[i]).LabQueryStatus := '0^initialization...';
    45854736                    UpdateRemoteStatus(TRemoteSite(Items[i]).SiteID, 'initialization');
    45864737                    Timer1.Enabled := True;
     
    45974748var
    45984749  i,j: integer;
    4599   LocalHandle, Report, Query, seq: String;
     4750  LocalHandle, Report, Query: String;
    46004751begin
    46014752  { AReportID := 1  Generic report   RemoteLabReports
     
    46034754                 3  Interim          RemoteLabInterim
    46044755                 4  Microbioloby     RemoteLabMicro }
    4605 seq := '';
     4756
    46064757  with RemoteSites.SiteList do
    46074758    for i := 0 to Count - 1 do
     
    46184769           if (LeftStr(TRemoteSite(Items[i]).SiteID, 5) = '200') then
    46194770          begin
    4620             TRemoteSite(Items[i]).QueryStatus := '1^Not Included';
     4771            TRemoteSite(Items[i]).LabQueryStatus := '1^Not Included';
    46214772            UpdateRemoteStatus(TRemoteSite(Items[i]).SiteID, 'NOT INCLUDED');
    46224773            TabControl1.OnChange(nil);
     
    46244775          end;
    46254776          TRemoteSite(Items[i]).CurrentLabQuery := 'Lab' + Patient.DFN + ';' + Patient.ICN +
    4626             '^' + IntToStr(AItem) + '^' + 'L:' + IntToStr(AReportID) + '^^' + ARpc + '^' + AHSType +
     4777            '^' + 'L:' + IntToStr(AItem) + '^' + IntToStr(AReportID) + '^^' + ARpc + '^' + AHSType +
    46274778            '^' + ADaysBack + '^' + ASection + '^' + DateToStr(ADate1) + '^' + DateToStr(ADate2) + '^' +
    46284779            TRemoteSite(Items[i]).SiteID;
     
    46514802              case AReportID of
    46524803              1: begin
    4653                    RemoteLabReports(Dest, Patient.DFN + ';' + Patient.ICN, IntToStr(AItem),
     4804                   RemoteLabReports(Dest, Patient.DFN + ';' + Patient.ICN, 'L:' + IntToStr(AItem),
    46544805                     AHSType, ADaysBack, ASection, ADate1, ADate2,
    46554806                     TRemoteSite(Items[i]).SiteID, ARpc);
     
    46684819                 end;
    46694820              else begin
    4670                      RemoteLab(Dest, Patient.DFN + ';' + Patient.ICN, IntToStr(AItem),
     4821                     RemoteLab(Dest, Patient.DFN + ';' + Patient.ICN, 'L:' + IntToStr(AItem),
    46714822                     AHSType, ADaysBack, ASection, ADate1, ADate2,
    46724823                     TRemoteSite(Items[i]).SiteID, ARpc);
     
    46984849begin
    46994850  inherited;
    4700   memLab.Lines.Clear;
     4851  if (uQualifiertype <> 6) or (length(piece(uHState,';',2)) < 1) then
     4852    memLab.Lines.Clear;
    47014853  lstHeaders.Items.Clear;
    4702   with TabControl1 do
     4854  if (length(piece(uHState,';',2)) = 0) then with TabControl1 do
    47034855    begin
    47044856      memLab.Lines.BeginUpdate;
     
    47144866                  for i := 1 to TRemoteSite(Tabs.Objects[TabIndex]).LabData.Count - 1 do
    47154867                    if hook = true then
    4716                       memLab.Lines.Add(TRemoteSite(Tabs.Objects[TabIndex]).LabData[i])
     4868                        memLab.Lines.Add(TRemoteSite(Tabs.Objects[TabIndex]).LabData[i])
    47174869                    else
    47184870                      begin
     
    47304882            memLab.Lines.Add('Remote data transmission error: ' + Piece(aStatus,'^',2));
    47314883          if Piece(aStatus,'^',1) = '0' then
    4732             memLab.Lines.Add('Transmission in progress: ' + Piece(aStatus,'^',2));
     4884            memLab.Lines.Add('Retrieving data... ' + Piece(aStatus,'^',2));
    47334885          if Piece(aStatus,'^',1) = '' then
    4734             memLab.Lines.Add('Select a report...');
     4886            memLab.Lines.Add(uReportInstruction);
    47354887        end
    47364888      else
     
    47524904              end
    47534905            else
    4754               QuickCopy(uLabLocalReportData,memLab);
     4906              if tvReports.Selected.Text = 'Imaging (local only)' then
     4907                   memLab.Lines.clear
     4908              else
     4909                QuickCopy(uLabLocalReportData,memLab);
    47554910            memLab.Lines.Insert(0,' ');
    47564911            memLab.Lines.Delete(0);
    4757           end;
     4912          end
     4913        else
     4914          memLab.Lines.Add(uReportInstruction);
    47584915      memLab.SelStart := 0;
    47594916      memLab.Lines.EndUpdate;
     
    47994956procedure TfrmLabs.CommonComponentVisible(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12: Boolean);
    48004957begin
     4958  //Clear the last date selection
     4959  //if not A4 then lstDates.ItemIndex := -1;
     4960  lstDates.Caption := lblDates.Caption;
     4961  lstHeaders.Caption := lblHeaders.Caption;
     4962  if A4 or A2 or A12 then
     4963    begin
     4964      pnlLefTop.Height := (frmLabs.Height div 2);
     4965      pnlLeftBottom.Visible := true;
     4966      Splitter1.Visible := true;
     4967    end
     4968    else
     4969    begin
     4970      pnlLefTop.Height := frmLabs.Height;
     4971      pnlLeftBottom.Visible := false;
     4972      Splitter1.Visible := false;
     4973    end;
    48014974  lstDates.Visible := false;    // turned off to realign correctly
    48024975  lblDates.Visible := false;
     
    48194992  pnlFooter.Visible := A9;
    48204993  lvReports.Visible := A10;
    4821   sptHorzRight.Visible := A10;
     4994  sptHorzRight.Visible := true;
    48224995  if A4 and A1 and (lblDates.Top < lblHeaders.Top) then
    4823   begin
    4824     lblDates.Caption := 'Headings';  // swithes captions if not aligned
    4825     lblHeaders.Caption := 'Date Range';
    4826   end
    4827   else
    4828   begin
    4829     lblDates.Caption := 'Date Range';
    4830     lblHeaders.Caption := 'Headings';
    4831   end;
    4832   lstDates.Caption := lblDates.Caption;
    4833   lstHeaders.Caption := lblHeaders.Caption;
    4834   if A4 or A2 or A12 then
    4835     begin
    4836       pnlLeftBottom.Visible := true;
    4837       Splitter1.Visible := true;
    4838     end;
     4996    begin
     4997      lblDates.Caption := 'Headings';  // swithes captions if not aligned
     4998      lblHeaders.Caption := 'Date Range';
     4999    end
     5000    else
     5001    begin
     5002      lblDates.Caption := 'Date Range';
     5003      lblHeaders.Caption := 'Headings';
     5004    end;
     5005  frmLabs.Realign;
    48395006end;
    48405007
     
    48455012      TabControl1.Visible := true;
    48465013      TabControl1.TabStop := true;
    4847       pnlRightTop.Height := lblTitle.Height + TabControl1.Height;
    4848     end;
     5014      pnlRightTopHeader.Height := pnlRightTopHeaderTop.Height + TabControl1.Height;
     5015    end;
     5016end;
     5017
     5018procedure TfrmLabs.HideTabControl;
     5019begin
     5020      TabControl1.Visible := false;
     5021      TabControl1.TabStop := false;
     5022      pnlRightTopHeader.Height := pnlRightTopHeaderTop.Height;
    48495023end;
    48505024
     
    48615035begin
    48625036  inherited;
    4863   if NewSize < 10 then
    4864       Newsize := 10;
    4865 end;
    4866 
    4867 procedure TfrmLabs.sptHorzRightMoved(Sender: TObject);
    4868 begin
    4869   inherited;
    4870   uScreenSplitMoved := true;
    4871   uScreenSplitLoc := sptHorzRight.Top;
     5037  if NewSize < 5 then
     5038      Newsize := 5;
    48725039end;
    48735040
Note: See TracChangeset for help on using the changeset viewer.