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/fGraphs.pas

    r830 r1679  
    33interface
    44
    5 uses                                               
     5uses
    66  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
    77  ExtCtrls, StdCtrls, ORCtrls, Menus, TeeProcs, TeEngine, Series, Chart, Math,
     
    244244      Shift: TShiftState; X, Y: Integer);
    245245    procedure splViewsTopMoved(Sender: TObject);
    246     procedure lstViewsBottomMouseDown(Sender: TObject; Button: TMouseButton;
    247       Shift: TShiftState; X, Y: Integer);
    248246
    249247  private
     
    286284    FSourcesDefault: TStrings;
    287285    FTHighTime, FTLowTime: Double;
    288     FTooManyItems: boolean;
    289286    FWarning: boolean;
    290287    FX, FY: integer;
     
    292289    FYMaxValue: Double;
    293290
    294     procedure AddOnLabGroups(aListBox: TORListBox; personien: integer);
     291    procedure AddOnLabGroups(aListBox: TORListBox; personien: int64);
    295292    procedure AdjustTimeframe;
    296293    procedure AllTypeDate(aType, aTypeName, firstline, secondline: string; aDate, aDate2: double);
     
    309306    procedure CheckProfile(var aProfile: string; var Updated: boolean);
    310307    procedure CheckToAddData(aListView: TListView; aSection, TypeToCheck: string);
    311     procedure CreateExcelPatientHeader(var HeaderList: TStringList; PageTitle, DateRange: string);
     308    procedure CreateExcelPatientHeader(var HeaderList: TStringList; PageTitle, Warning, DateRange: string);
    312309    procedure CreatePatientHeader(var HeaderList: TStringList; PageTitle, Warning, DateRange: string);
    313310    procedure DateRangeItems(oldestdate, newestdate: double; filenum: string);
     
    345342    procedure PainAdd(serBlank: TPointSeries);
    346343    procedure RefUnits(aItem, aSpec: string; var low, high, units: string);
    347     procedure ResetSpec(aList: TStrings; aItemNum, aNewItemNum, aNewItemName, aNewString: string);
    348344    procedure ResultValue(var resultstring, seriestitle: string; typenum, typeitem: string;
    349345      Sender: TCustomChart; aSeries: TChartSeries; ValueIndex, SeriesNum: Integer; var OKToUse: boolean);
     346    procedure SaveTestData(typeitem: string);
    350347    procedure SelCopy(aListView: TListView; aList: TStrings);
    351348    procedure SelReset(aList: TStrings; aListView: TListView);
     
    356353    procedure SizeTogether(onlylines, nolines, anylines: Boolean; aScroll: TScrollBox;
    357354      aChart: TChart; aPanel, aPanelBase: TPanel; portion: Double);
    358     procedure SpecCheck(var spec1, spec2, spec3, spec4: string; var singlespec: boolean);
    359     procedure SpecSet(var spec1, spec2, spec3, spec4: string; aItemType, aItemName: string);
     355    procedure SpecRefCheck(aItemType, aItemName: string; var singlespec: boolean);
     356    procedure SpecRefSet(aItemType, aItemName: string);
    360357    procedure SplitClick;
    361358    procedure SortListView;
     
    396393    function BPValue(aDateTime: TDateTime): string;
    397394    function DateRangeMultiItems(aOldDate, aNewDate: double; aMultiItem: string): boolean;
     395    function DatesInRange(EarlyDate, RecentDate, Date1, Date2: double): boolean;
    398396    function DCName(aDCien: string): string;
    399397    function ExpandTax(profile: string): string;
     
    440438  FHintWinActive: boolean;
    441439  FHintStop: boolean;
     440  uDateStart, uDateStop: double;
    442441
    443442implementation
     
    445444uses fGraphSettings, fGraphProfiles, fGraphData, fGraphOthers, rGraphs,
    446445  ComObj, ActiveX, ShellAPI, fFrame, uCore, rCore, uConst, fRptBox, fReports,
    447   uFormMonitor, VAUtils
    448   { TODO -oRV -cWVEHR Long Age : Changed to use long age }
    449   , rWVEHR;
    450 
     446  uFormMonitor, VAUtils;
    451447
    452448{$R *.DFM}
     
    531527  FTLowTime := BIG_NUMBER;
    532528  FWarning := false;
    533   FTooManyItems := false;
    534529  FX := 0; FY :=0;
    535530  FYMinValue := 0;
    536531  FYMaxValue := 0;
     532  uDateStart := 0;
     533  uDateStop  := 0;
    537534end;
    538535
     
    570567      if length(rptview1) > 0 then
    571568      begin
    572         //pcTop.ActivePage := tsTopViews;
    573         lstViewsTop.Tag := 0;
    574569        for i := 0 to lstViewsTop.Items.Count - 1 do
    575570        if Piece(lstViewsTop.Items[i], '^', 2) = rptview1 then
     
    578573          break;
    579574        end;
    580         if lstViewsTop.ItemIndex < 0 then
    581           lvwItemsTopClick(self);
    582575      end;
    583576      if length(rptview2) > 0 then
     
    585578        chkDualViews.Checked := true;
    586579        chkDualViewsClick(self);
    587         //pcBottom.ActivePage := tsBottomViews;
    588         lstViewsBottom.Tag := 0;
    589580        for i := 0 to lstViewsBottom.Items.Count - 1 do
    590581        if Piece(lstViewsBottom.Items[i], '^', 2) = rptview2 then
     
    593584          break;
    594585        end;
    595         if lstViewsBottom.ItemIndex < 0 then
    596           lvwItemsBottomClick(self);
    597586      end;
    598587    end;
    599     pnlMain.Tag := 0;
    600     cboDateRangeChange(self);
    601     exit;
    602588  end;
    603589  if lstViewsTop.ItemIndex > -1 then
     
    606592    lvwItemsTopClick(self);
    607593  if lstViewsBottom.ItemIndex > -1 then
    608     lstViewsbottomChange(self)
     594  begin
     595    lstViewsBottom.Tag := 0;     // **** reset to allow bottom graphs
     596    lstViewsbottomChange(self);
     597  end
    609598  else
    610599    lvwItemsBottomClick(self);
     600  if pnlMain.Tag > 0 then
     601  begin
     602    pnlMain.Tag := 0;
     603    cboDateRangeChange(self);
     604    if lstViewsTop.ItemIndex > -1 then
     605      lstViewsTopChange(self)
     606    else
     607      lvwItemsTopClick(self);
     608    if lstViewsBottom.ItemIndex > -1 then
     609      lstViewsbottomChange(self)
     610    else
     611      lvwItemsBottomClick(self);
     612  end;
    611613end;
    612614
     
    663665end;
    664666
    665 procedure TfrmGraphs.AddOnLabGroups(aListBox: TORListBox; personien: integer);
     667procedure TfrmGraphs.AddOnLabGroups(aListBox: TORListBox; personien: int64);
    666668var
    667669  i: integer;
     
    728730begin
    729731  if Patient.Inpatient then
    730      cboDateRange.SelectByID(GetDefaultInpatientDate)
     732     cboDateRange.SelectByID(FGraphSetting.DateRangeInpatient)
    731733  else
    732      cboDateRange.SelectByID(GetDefaultOutpatientDate);
     734     cboDateRange.SelectByID(FGraphSetting.DateRangeOutpatient);
    733735  if cboDateRange.ItemIndex < 0 then
    734736    cboDateRange.ItemIndex := cboDateRange.Items.Count - 1;
     
    902904    PreFixedDateRange := FixedDateRange;
    903905    MaxSelectMin := Max(Max(lvwItemsTop.SelCount, lvwItemsBottom.SelCount), 1);
    904     DateRangeOutpatient := FGraphSetting.DateRangeOutpatient;
    905906  end;
    906907  PreSources := TStringList.Create;
     
    11341135var
    11351136  i, j: integer;
    1136   filename, itemnum, itemstuff, mitemnum: string;
     1137  filename, iteminfo, itemnum, tempiteminfo, tempitemnum: string;
    11371138begin
    11381139  FastAssign(rpcDateItem(oldestdate, newestdate, filenum, Patient.DFN), GtslScratchTemp);
     
    11421143  for i := 0 to GtslScratchTemp.Count - 1 do
    11431144  begin
    1144     itemstuff := GtslScratchTemp[i];
    1145     itemnum := UpperCase(Piece(itemstuff, '^',2));
     1145    tempiteminfo := GtslScratchTemp[i];
     1146    tempitemnum := UpperCase(Piece(tempiteminfo, '^',2));
    11461147    for j := 0 to GtslItems.Count - 1 do
    1147     if (filenum = UpperCase(Piece(GtslItems[j], '^', 1))) and (itemnum = UpperCase(Piece(GtslItems[j], '^', 2))) then
    1148       UpdateView(filename, filenum, itemnum, GtslItems[j], lvwItemsTop);
    1149     if filenum = '63' then
    1150     for j := 0 to GtslMultiSpec.Count - 1 do
    1151     begin
    1152       mitemnum := Piece(GtslMultiSpec[j], '^', 2);
    1153       if itemnum = Piece(mitemnum, '.', 1) then
    1154         if DateRangeMultiItems(oldestdate, newestdate, mitemnum) then     //******** check specific date range
    1155           UpdateView(filename, filenum, mitemnum, GtslMultiSpec[j], lvwItemsTop);
     1148    begin
     1149      iteminfo := GtslItems[j];
     1150      if filenum = UpperCase(Piece(iteminfo, '^', 1)) then
     1151      begin
     1152        if tempitemnum = UpperCase(Piece(iteminfo, '^', 2)) then
     1153          UpdateView(filename, filenum, tempitemnum, iteminfo, lvwItemsTop)
     1154        else
     1155          if filenum = '63' then
     1156          begin
     1157            itemnum := UpperCase(Piece(iteminfo, '^', 2));
     1158            if tempitemnum = Piece(itemnum, '.', 1) then
     1159              if DateRangeMultiItems(oldestdate, newestdate, itemnum) then
     1160                UpdateView(filename, filenum, itemnum, iteminfo, lvwItemsTop);
     1161          end;
     1162      end;
    11561163    end;
    11571164  end;
     
    12021209          end;
    12031210    end;
     1211end;
     1212
     1213function TfrmGraphs.DatesInRange(EarlyDate, RecentDate, Date1, Date2: double): boolean;
     1214begin
     1215  Result := true;
     1216  if Date2 < 0 then   // instance
     1217  begin
     1218    if Date1 < EarlyDate then
     1219      Result := false
     1220    else if Date1 > RecentDate then
     1221      Result := false;
     1222  end
     1223  else                // durations
     1224  begin
     1225    if Date1 > RecentDate then
     1226      Result := false
     1227    else if Date2 < EarlyDate then
     1228      Result := false;
     1229  end;
    12041230end;
    12051231
     
    13711397end;
    13721398
     1399procedure TfrmGraphs.SaveTestData(typeitem: string);
     1400var
     1401  aType, aItem, aItemName: string;
     1402begin
     1403  aType := Piece(typeitem, '^', 1);
     1404  aItem := Piece(typeitem, '^', 2);
     1405  aItemName := MixedCase(ItemName(aType, aItem));
     1406  LabData(typeitem, aItemName, 'top', false);  // already have lab data
     1407  GtslScratchLab.Clear;
     1408end;
     1409
    13731410procedure TfrmGraphs.FastLab(aList: TStringList);
    13741411var
    1375   lastone: boolean;
    1376   i: integer;
    1377   aType, aItem, aItemName, typeitem, oldtypeitem, listline: string;
    1378 begin
    1379   if aList.Count < 1 then
     1412  i, lastnum: integer;
     1413  newtypeitem, oldtypeitem, listline: string;
     1414begin
     1415  lastnum := aList.Count - 1;
     1416  if lastnum < 0 then
    13801417    exit;
    13811418  GtslScratchLab.Clear;
    13821419  aList.Sort;
    1383   listline := aList[0];
    1384   oldtypeitem := Pieces(listline, '^', 1, 2);
    1385   GtslScratchLab.Add(listline);
    1386   for i := 1 to aList.Count - 1 do
    1387   begin
    1388     lastone := i = aList.Count - 1;
     1420  oldtypeitem := Pieces(aList[0], '^', 1, 2);
     1421  for i := 0 to lastnum do
     1422  begin
    13891423    listline := aList[i];
    1390     typeitem := Pieces(listline, '^', 1 , 2);
    1391     if (typeitem <> oldtypeitem) or lastone then
    1392     begin
    1393       if lastone then
    1394         oldtypeitem := typeitem;
    1395       aType := Piece(oldtypeitem, '^', 1);
    1396       aItem := Piece(oldtypeitem, '^', 2);
    1397       aItemName := MixedCase(ItemName(aType, aItem));
    1398       LabData(oldtypeitem, aItemName, 'top', false);  // already have lab data
    1399       GtslScratchLab.Clear;
    1400     end;
    1401     GtslScratchLab.Add(listline);
    1402     oldtypeitem := typeitem;
     1424    newtypeitem := Pieces(listline, '^', 1 , 2);
     1425    if lastnum = i then
     1426    begin
     1427      if newtypeitem <> oldtypeitem then
     1428      begin
     1429        SaveTestData(oldtypeitem);
     1430        oldtypeitem := newtypeitem;
     1431      end;
     1432      GtslScratchLab.Add(listline);
     1433      SaveTestData(oldtypeitem);
     1434    end
     1435    else if newtypeitem <> oldtypeitem then
     1436    begin
     1437      SaveTestData(oldtypeitem);
     1438      GtslScratchLab.Add(listline);
     1439      oldtypeitem := newtypeitem;
     1440    end
     1441    else
     1442      GtslScratchLab.Add(listline);
    14031443  end;
    14041444end;
     
    16671707  aChart := (Sender as TChart);
    16681708  if Not Assigned(FGraphSetting) then Exit;
    1669  
     1709
    16701710  if not FGraphSetting.VerticalZoom then
    16711711  begin
     
    18981938var
    18991939  i: integer;
    1900   checkdata, high, low, specimen, specnum, units: string;
     1940  checkdata, high, low, specimen, specnum, units, refrange: string;
    19011941begin
    19021942  if (filetype = '63') and (GtslData.Count > 0) then
     
    19091949        break;
    19101950    end;
    1911     specnum := Piece(checkdata, '^', 7);
     1951    refrange := Piece(checkdata, '^', 10);
    19121952    specimen := Piece(checkdata, '^', 8);
    1913     RefUnits(typeitem, specnum, low, high, units);
    1914     units := LowerCase(units);
     1953    if length(refrange) > 0  then
     1954    begin
     1955      low := Piece(refrange, '!', 1);
     1956      high := Piece(refrange, '!', 2);
     1957      units := Piece(checkdata, '^', 11);
     1958    end
     1959    else
     1960    begin
     1961      specnum := Piece(checkdata, '^', 7);
     1962      RefUnits(typeitem, specnum, low, high, units);
     1963      units := LowerCase(units);
     1964    end;
    19151965    if units = '' then units := '  ';
    19161966  end
     
    31903240  end;
    31913241
    3192 var
    3193   ok, topflag: boolean;
    3194   i, j, cnt: integer;
    3195   dtdata1, dtdata2, dtdate1, dtdate2: double;
    3196   StrForFooter, StrForHeader, aTitle, aDateRange, aCustomDateRange: String;
    3197   cdate, itemtype, item, itemtypename, itemname, typeitem, specnum: String;
    3198   datax, fmdate1, fmdate2, linestring: String;
    3199   aHeader: TStringList;
    3200   aGraphItem: TGraphItem;
    3201   aListItem: TListItem;
    3202   excelApp, workbook, worksheet: Variant;
    3203 begin
    3204   if (lvwItemsTop.SelCount = 0) and (lvwItemsBottom.SelCount = 0) then
    3205   begin
    3206     ShowMessage('No Items selected.');
    3207     exit;
    3208   end;
    3209   try
    3210     excelApp := CreateOleObject('Excel.Application');
    3211   except
    3212     raise Exception.Create('Cannot start MS Excel!');
    3213   end;
    3214   topflag := mnuPopGraphStayOnTop.Checked and mnuPopGraphStayOnTop.Enabled;
    3215   Screen.Cursor := crDefault;
    3216   aTitle := 'CPRS Graphing';
    3217   dtdate1 := FGraphSetting.FMStartDate; //DateTimeToFMDateTime(FGraphSetting.LowTime);
    3218   dtdate2 := FGraphSetting.FMStopDate; //DateTimeToFMDateTime(FGraphSetting.HighTime);
    3219   dtdate1 := FMDateTimeOffsetBy(dtdate1, 1);   // add a day to start
    3220   dtdate2 := dtdate2;
    3221 
    3222   if (length(cboDateRange.Text) < 25) and
    3223      (cboDateRange.Text <> 'All Results') and
    3224      (cboDateRange.Text <> 'Today') then
    3225     aDateRange :=  'Date Range: ' + cboDateRange.Text + '  Selected Items from ' +
    3226       FormatFMDateTime('mm/dd/yy', dtdate1) + ' to ' +
    3227       FormatFMDateTime('mm/dd/yy', dtdate2)
    3228   else
    3229     aDateRange :=  'Date Range: Selected Items from ' + cboDateRange.Text;
    3230   dtdate1 := DateTimeToFMDateTime(FGraphSetting.LowTime);
    3231   dtdate2 := DateTimeToFMDateTime(FGraphSetting.HighTime);
    3232   aCustomDateRange := cboDateRange.Items[cboDateRange.ItemIndex];
    3233   if Piece(aCustomDateRange, '^', 1) = '' then           // custom date range
    3234   begin
    3235     dtdate1 := strtofloat(Piece(aCustomDateRange, '^', 6));
    3236     dtdate2 := strtofloat(Piece(aCustomDateRange, '^', 7));
    3237   end;
    3238   aHeader := TStringList.Create;
    3239   CreateExcelPatientHeader(aHeader, aTitle, aDateRange);
    3240   StrForHeader := '';
    3241   for i := 0 to aHeader.Count - 1 do
    3242   begin
    3243     StrForHeader := StrForHeader + aHeader[i] + #13;
    3244   end;
    3245   if length(StrForHeader) > 250 then
    3246     StrForHeader := copy(StrForHeader, 1, 250) + #13;  // VB script in Excel is limited to 253
    3247   StrForFooter := aTitle + '                    *** WORK COPY ONLY ***                            '
    3248                 + 'Printed: ' + FormatDateTime('mmm dd, yyyy  hh:nn', Now) + #13
    3249                 + TXT_COPY_DISCLAIMER + #13;
    3250   excelApp.Visible := true;
    3251   workbook := excelApp.workbooks.add;
    3252   worksheet := workbook.worksheets.add;
    3253   worksheet.name := aTitle;
    3254   worksheet.PageSetup.PrintArea := '';
    3255   worksheet.PageSetup.TopMargin := 110;
    3256   worksheet.PageSetup.CenterHeader := StrForHeader;
    3257   worksheet.PageSetup.BottomMargin := 75;
    3258   worksheet.PageSetup.LeftFooter := StrForFooter;
    3259   worksheet.PageSetup.RightFooter := 'Page &P of &N';
    3260   worksheet.PageSetup.PrintTitleRows := '$1:$1';
    3261   worksheet.PageSetup.PrintTitleColumns := '$A:$F';
    3262   AddRow(worksheet, '1', 'Type', 'Item', 'Date', 'End Date', 'Value', 'Other');
    3263   cnt := 1;
    3264   aListItem := lvwItemsTop.Selected;
    3265   while aListItem <> nil do
    3266   begin
    3267     itemname := aListItem.Caption;
    3268     itemtypename := aListItem.SubItems[0];
    3269     aGraphItem := TGraphItem(aListItem.SubItems.Objects[3]);
    3270     typeitem := UpperCase(aGraphItem.Values);
    3271     if Piece(typeitem, '^', 1) = '63' then
    3272     begin
    3273       specnum := Piece(Piece(typeitem, '^', 2), '.', 2);
    3274       if length(specnum) > 0 then  // multispecimen
    3275         if specnum = '1' then
    3276           typeitem := Piece(typeitem, '.', 1)
    3277         else
    3278           typeitem := '';
    3279     end;
    3280     itemtype := Piece(typeitem, '^', 1);
    3281     item := Piece(typeitem, '^', 2);
    3282     for j := 0 to GtslData.Count - 1 do
    3283     begin
    3284       datax := GtslData[j];
    3285       if Piece(datax, '^', 1) = itemtype then
    3286         if Piece(datax, '^', 2) = item then
    3287         begin
    3288           dtdata1 := strtofloatdef(Piece(datax, '^', 3), -1);
    3289           fmdate1 := FormatFMDateTime('mm/dd/yy hh:nn', dtdata1);
    3290           if copy(fmdate1, length(fmdate1) - 5, length(fmdate1)) = ' 00:00' then
    3291             fmdate1 := copy(fmdate1, 1, length(fmdate1) - 5) + '     ';
    3292           cdate := Piece(datax, '^', 4);
    3293           if Piece(cdate, '.', 2) = '24' then cdate := Piece(cdate, '.', 1) + '.2359';
    3294           dtdata2 := strtofloatdef(cdate, -1);      // restrict to within date range
    3295           fmdate2 := FormatFMDateTime('mm/dd/yy hh:nn', dtdata2);
    3296           if copy(fmdate2, length(fmdate2) - 5, length(fmdate2)) = ' 00:00' then
    3297             fmdate2 := copy(fmdate2, 1, length(fmdate2) - 5) + '     ';
    3298           if dtdata2 > 0 then           
    3299             ok := (dtdata1 <= dtdate2) and (dtdata2 >= dtdate1) // overlap for durations
    3300           else
    3301             ok := (dtdata1 >= dtdate1) and (dtdata1 <= dtdate2); // inclusion for instances
    3302           if ok then
    3303           begin
    3304             cnt := cnt + 1;
    3305             linestring := inttostr(cnt);
    3306             AddRow(worksheet, linestring, itemtypename, itemname, fmdate1, fmdate2, Piece(datax, '^', 5), Piece(datax, '^', 8));
    3307           end;
    3308         end;
    3309     end;
    3310     aListItem := lvwItemsTop.GetNextItem(aListItem, sdAll, [isSelected]);
    3311   end;
    3312   if lvwItemsBottom.Items.Count > 0 then        //rewrite to combine
    3313   begin
    3314     cnt := cnt + 1;
    3315     linestring := inttostr(cnt);
    3316     AddRow(worksheet, linestring, '', '', '', '', '', '');
    3317     aListItem := lvwItemsBottom.Selected;
     3242  procedure FillData(aListView: TListView; worksheet: variant; var cnt: integer);
     3243  var
     3244    i: integer;
     3245    dtdata1, dtdata2: double;
     3246    itemtype, item, itemtypename, itemname, typeitem: String;
     3247    datax, fmdate1, fmdate2, linestring: String;
     3248    aGraphItem: TGraphItem;
     3249    aListItem: TListItem;
     3250  begin
     3251    aListItem := aListView.Selected;
    33183252    while aListItem <> nil do
    33193253    begin
     
    33223256      aGraphItem := TGraphItem(aListItem.SubItems.Objects[3]);
    33233257      typeitem := UpperCase(aGraphItem.Values);
    3324       if Piece(typeitem, '^', 1) = '63' then
    3325       begin
    3326         specnum := Piece(Piece(typeitem, '^', 2), '.', 2);
    3327         if length(specnum) > 0 then  // multispecimen
    3328           if specnum = '1' then
    3329             typeitem := Piece(typeitem, '.', 1)
    3330           else
    3331             typeitem := '';
    3332       end;
    33333258      itemtype := Piece(typeitem, '^', 1);
    33343259      item := Piece(typeitem, '^', 2);
    3335       for j := 0 to GtslData.Count - 1 do
     3260      for i := 0 to GtslData.Count - 1 do
    33363261      begin
    3337         datax := GtslData[j];
     3262        datax := GtslData[i];
    33383263        if Piece(datax, '^', 1) = itemtype then
    33393264          if Piece(datax, '^', 2) = item then
     
    33413266            dtdata1 := strtofloatdef(Piece(datax, '^', 3), -1);
    33423267            fmdate1 := FormatFMDateTime('mm/dd/yy hh:nn', dtdata1);
    3343             if copy(fmdate1, length(fmdate1) - 5, length(fmdate1)) = ' 00:00' then
    3344               fmdate1 := copy(fmdate1, 1, length(fmdate1) - 5) + '     ';
    3345             cdate := Piece(datax, '^', 4);
    3346             if Piece(cdate, '.', 2) = '24' then cdate := Piece(cdate, '.', 1) + '.2359';
    3347             dtdata2 := strtofloatdef(cdate, -1);
    3348             fmdate2 := FormatFMDateTime('mm/dd/yy hh:nn', dtdata2);
    3349             if copy(fmdate2, length(fmdate2) - 5, length(fmdate2)) = ' 00:00' then
    3350               fmdate2 := copy(fmdate2, 1, length(fmdate2) - 5) + '     ';
    3351             if dtdata2 > 0 then           
    3352               ok := (dtdata1 <= dtdate2) and (dtdata2 >= dtdate1) // overlap for durations
    3353             else
    3354               ok := (dtdata1 >= dtdate1) and (dtdata1 <= dtdate2); // inclusion for instances
    3355             if ok then
     3268            fmdate1 := StringReplace(fmdate1, ' 00:00', '', [rfReplaceAll]);
     3269            dtdata2 := strtofloatdef(Piece(datax, '^', 4), -1);
     3270            if DatesInRange(uDateStart, uDateStop, dtdata1, dtdata2) then
    33563271            begin
     3272              fmdate2 := FormatFMDateTime('mm/dd/yy hh:nn', dtdata2);
     3273              fmdate2 := StringReplace(fmdate2, ' 00:00', '', [rfReplaceAll]);
    33573274              cnt := cnt + 1;
    33583275              linestring := inttostr(cnt);
     
    33613278          end;
    33623279      end;
    3363       aListItem := lvwItemsBottom.GetNextItem(aListItem, sdAll, [isSelected]);
    3364     end;
     3280      aListItem := aListView.GetNextItem(aListItem, sdAll, [isSelected]);
     3281    end;
     3282  end;
     3283
     3284var
     3285  topflag: boolean;
     3286  i, cnt: integer;
     3287  StrForFooter, StrForHeader, ShortHeader, aTitle, aWarning, aDateRange: String;
     3288  linestring: String;
     3289  aHeader: TStringList;
     3290  excelApp, workbook, worksheet: Variant;
     3291begin
     3292  try
     3293    excelApp := CreateOleObject('Excel.Application');
     3294  except
     3295    raise Exception.Create('Cannot start MS Excel!');
     3296  end;
     3297  topflag := mnuPopGraphStayOnTop.Checked and mnuPopGraphStayOnTop.Enabled;
     3298  Screen.Cursor := crDefault;
     3299  aTitle := 'CPRS Graphing';
     3300  aWarning := pnlInfo.Caption;
     3301  aDateRange :=  'Date Range: ' + cboDateRange.Text + '  Selected Items from ' +
     3302      FormatDateTime('mm/dd/yy', FGraphSetting.LowTime) + ' to ' +
     3303      FormatDateTime('mm/dd/yy', FGraphSetting.HighTime);
     3304  aHeader := TStringList.Create;
     3305  CreateExcelPatientHeader(aHeader, aTitle, aWarning, aDateRange);
     3306  StrForHeader := '';
     3307  for i := 0 to aHeader.Count -1 do
     3308    if (length(StrForHeader) + length(aHeader[i])) < 250 then
     3309      StrForHeader := StrForHeader + aHeader[i] + #13;
     3310  ShortHeader := Patient.Name + '         ' + Patient.SSN + '          '
     3311         + Encounter.LocationName + '                            '
     3312         + FormatFMDateTime('mmm dd, yyyy', Patient.DOB) + ' (' + IntToStr(Patient.Age) + ')'
     3313         + #13 + TXT_COPY_DISCLAIMER;
     3314  StrForFooter := aTitle + '                    *** WORK COPY ONLY ***                            '
     3315                + 'Printed: ' + FormatDateTime('mmm dd, yyyy  hh:nn', Now) + #13;
     3316  excelApp.Visible := true;
     3317  workbook := excelApp.workbooks.add;
     3318  worksheet := workbook.worksheets.add;
     3319  worksheet.name := aTitle;
     3320  worksheet.PageSetup.PrintArea := '';
     3321  worksheet.PageSetup.TopMargin := 120;
     3322  worksheet.PageSetup.LeftFooter := StrForFooter;
     3323  worksheet.PageSetup.RightFooter := 'Page &P of &N';
     3324  AddRow(worksheet, '1', 'Type', 'Item', 'Date1', 'Date2', 'Value', 'Other');
     3325  cnt := 1;
     3326  FillData(lvwItemsTop, worksheet, cnt);
     3327  if lvwItemsBottom.Items.Count > 0 then
     3328  begin
     3329    cnt := cnt + 1;
     3330    linestring := inttostr(cnt);
     3331    AddRow(worksheet, linestring, '', '', '', '', '', '');
     3332    FillData(lvwItemsBottom, worksheet, cnt);
    33653333  end;
    33663334  worksheet.Range['A1', 'F' + LineString].Columns.AutoFit;
    33673335  worksheet.Range['A1', 'F' + LineString].Select;
    33683336  worksheet.Range['A1', 'F' + LineString].AutoFormat(12, true, true, true, true, true, true);
    3369 
     3337  if length(StrForHeader) > 250 then
     3338    worksheet.PageSetup.CenterHeader := ShortHeader           // large header does not work (excel errors when > 255 char)
     3339  else
     3340    worksheet.PageSetup.CenterHeader := StrForHeader;
    33703341  if topflag then
    33713342    mnuPopGraphStayOnTopClick(self);
     
    35753546  begin
    35763547    textvalue := ValueText(aChart, aSeries, aIndex);
     3548    textvalue := StringReplace(textvalue, ' 00:00', '', [rfReplaceAll]);
    35773549    dttm := Piece(textvalue, '^', 3);
    3578     if copy(textvalue, length(textvalue) - 5, length(textvalue)) = ' 00:00' then
    3579       dttm := Pieces(dttm, ' ', 1, 3);
    35803550    textvalue1 := Piece(textvalue, '^', 2) + '  ' + dttm;
    35813551    textvalue2 := Piece(textvalue, '^', 4) + '  ' + Piece(textvalue, '^', 5);
     
    36463616    //Assign(templist);
    36473617    if aDate <> aDate2 then
    3648       titlemsg := aTypeName + ' occurences for ' + FormatDateTime('mmm d, yyyy', aDate) +
     3618      titlemsg := aTypeName + ' occurrences for ' + FormatDateTime('mmm d, yyyy', aDate) +
    36493619        ' - ' + FormatDateTime('mmm d, yyyy', aDate2)
    36503620    else
    3651       titlemsg := aTypeName + ' occurences for ' + FormatDateTime('mmm d, yyyy', aDate);
     3621      titlemsg := aTypeName + ' occurrences for ' + FormatDateTime('mmm d, yyyy', aDate);
    36523622    Insert(0, firstline);
    36533623    Insert(1, secondline);
     
    36793649        dtdata1 := strtofloatdef(Piece(datax, '^', 3), -1);
    36803650        fmdate1 := FormatFMDateTime('mm/dd/yy hh:nn', dtdata1);
    3681         if copy(fmdate1, length(fmdate1) - 5, length(fmdate1)) = ' 00:00' then
    3682           fmdate1 := copy(fmdate1, 1, length(fmdate1) - 5) + '     ';
     3651        fmdate1 := StringReplace(fmdate1, ' 00:00', '', [rfReplaceAll]);
    36833652        dtdata2 := strtofloatdef(Piece(datax, '^', 4), -1);
    36843653        fmdate2 := FormatFMDateTime('mm/dd/yy hh:nn', dtdata2);
    3685         if copy(fmdate2, length(fmdate2) - 5, length(fmdate2)) = ' 00:00' then
    3686           fmdate2 := copy(fmdate2, 1, length(fmdate2) - 5) + '     ';
     3654        fmdate2 := StringReplace(fmdate2, ' 00:00', '', [rfReplaceAll]);
    36873655        if (dtdata2 > dt1) and (dtdata1 < dt2) then
    36883656        begin
     
    37673735          spacer := Copy(BIG_SPACES, 1, 40 - length(results));
    37683736          results := results + ' ' + spacer + Piece(textvalue, '^', 6);
    3769           if copy(results, length(results) - 5, length(results)) = ' 00:00' then
    3770             results := copy(results, 1, length(results) - 5);
     3737          results := StringReplace(results, ' 00:00', '', [rfReplaceAll]);
    37713738          tmpOtherList.Add(results);                 // item occurrence
    37723739        end;
     
    39943961    begin
    39953962      textvalue := ValueText(aChart, aSeries, tmp);
     3963      textvalue := StringReplace(textvalue, ' 00:00', '', [rfReplaceAll]);
    39963964      dttm := Piece(textvalue, '^', 3);
    3997       if copy(textvalue, length(textvalue) - 5, length(textvalue)) = ' 00:00' then
    3998         dttm := Pieces(dttm, ' ', 1, 3);
    39993965      textvalue1 := Piece(textvalue, '^', 2) + '  ' + dttm;
    40003966      textvalue2 := Piece(textvalue, '^', 4) + '  ' + Piece(textvalue, '^', 5);
     
    40634029  mnuPopGraphCopy.Enabled := mnuPopGraphSwap.Enabled;
    40644030  mnuPopGraphPrint.Enabled := mnuPopGraphSwap.Enabled;
    4065   mnuPopGraphExport.Enabled := mnuPopGraphSwap.Enabled;
    4066 
     4031 
    40674032  with pnlMain.Parent do
    40684033  if BorderWidth <> 1 then            // only do on float Graph
     
    42334198    tmpStr := Patient.Name + '   ' + Patient.SSN;
    42344199    tmpItem := tmpStr + StringOfChar(' ', 39 - Length(tmpStr)) + Encounter.LocationName;
    4235 { TODO -oRV -cWVEHR Long Age : Changed to use long age }
    4236     //tmpStr := FormatFMDateTime('mmm dd, yyyy', Patient.DOB) + ' (' + IntToStr(Patient.Age) + ')';
    4237     tmpStr := FormatFMDateTime('mmm dd, yyyy', Patient.DOB) + ' (' + GetPatientBriefAge(Patient.DFN) + ')';
    4238 {}
     4200    tmpStr := FormatFMDateTime('mmm dd, yyyy', Patient.DOB) + ' (' + IntToStr(Patient.Age) + ')';
    42394201    tmpItem := tmpItem + StringOfChar(' ', 74 - (Length(tmpItem) + Length(tmpStr))) + tmpStr;
    42404202    Add(tmpItem);
     
    42494211end;
    42504212
    4251 procedure TfrmGraphs.CreateExcelPatientHeader(var HeaderList: TStringList; PageTitle, DateRange: string);
     4213procedure TfrmGraphs.CreateExcelPatientHeader(var HeaderList: TStringList; PageTitle, Warning, DateRange: string);
    42524214// this procedure modified from rReports
    42534215var
    42544216  tmpItem: string;
    42554217begin
     4218  if Warning = TXT_INFO then Warning := '  ';
    42564219  with HeaderList do
    42574220  begin
     
    42634226             + FormatFMDateTime('mmm dd, yyyy', Patient.DOB) + ' (' + IntToStr(Patient.Age) + ')';
    42644227    Add(tmpItem);
    4265     //Add(TXT_COPY_DISCLAIMER);  // put on footer to avoid length problems
     4228    Add(TXT_COPY_DISCLAIMER);
    42664229    Add(DateRange);
     4230    Add(Warning);
    42674231  end;
    42684232end;
     
    44464410  HideGraphs(true);
    44474411  DateSteps(dateranges);
     4412  uDateStart := FGraphSetting.FMStartDate;
     4413  uDateStop  := FGraphSetting.FMStopDate;
    44484414  FilterListView(FGraphSetting.FMStartDate, FGraphSetting.FMStopDate);
    44494415  SelReset(GtslSelCopyTop, lvwItemsTop);
     
    48214787    pnlItemsBottomInfo.Tag := 1;
    48224788    lvwItemsBottom.ClearSelection;
    4823     if FTooManyItems then FTooManyItems := false
    4824     else
    4825     begin
    4826       ShowMsg('Too many items to graph');
    4827       FTooManyItems := true;  // flag so that warning will not be displayed twice
    4828     end;
     4789    ShowMsg('Too many items to graph');
    48294790    for i := 0 to GtslSelPrevBottomFloat.Count - 1 do
    48304791      lvwItemsBottom.Items[strtoint(GtslSelPrevBottomFloat[i])].Selected := true;
     
    51035064    if length(itempart) = 0 then break;
    51045065    if Pos('811.2~', itempart) = 0 then
    5105       newprofile := newprofile + itempart + '|'
     5066      newprofile := newprofile + '|'
    51065067    else
    51075068      taxonomies.Add(itempart);
     
    51375098begin
    51385099  Application.ProcessMessages;
    5139   GtslTemp.Clear;
    51405100  profiletype := Piece(aProfile, '^', 1);
    51415101  profilename := Piece(aProfile, '^', 2);
     
    52325192    else if aListView = lvwItemsBottom then
    52335193      lvwItemsBottom.ClearSelection;
    5234     if FTooManyItems then FTooManyItems := false
    5235     else
    5236     begin
    5237       ShowMsg('Too many items to graph');
    5238       FTooManyItems := true;  // flag so that warning will not be displayed twice
    5239     end;
    52405194  end;
    52415195  if aListView = lvwItemsTop then
     
    52455199end;
    52465200
    5247 procedure TfrmGraphs.SpecCheck(var spec1, spec2, spec3, spec4: string; var singlespec: boolean);
    5248 var
    5249   i: integer;
    5250   checkstring, datastring: string;
    5251 begin
    5252   singlespec := true;
    5253   spec1 := ''; spec2 := ''; spec3 := ''; spec4 := '';
    5254   GtslSpec1.Clear; GtslSpec2.Clear; GtslSpec3.Clear; GtslSpec4.Clear;
    5255   for i := 0 to GtslScratchLab.Count - 1 do
    5256   begin
    5257     datastring := GtslScratchLab[i];
    5258     checkstring := Pieces(datastring, '^', 1, 2) + '^' + Pieces(datastring, '^', 7, 8);
    5259     if length(spec1) = 0  then
    5260     begin
    5261       spec1 := checkstring;
    5262       GtslSpec1.Add(datastring)
    5263     end
    5264     else if spec1 = checkstring then
    5265       GtslSpec1.Add(datastring)
    5266     else if length(spec2) = 0 then
    5267     begin
    5268       singlespec := false;
    5269       spec2 := checkstring;
    5270       GtslSpec2.Add(datastring)
    5271     end
    5272     else if spec2 = checkstring then
    5273       GtslSpec2.Add(datastring)
    5274     else if length(spec3) = 0 then
    5275     begin
    5276       spec3 := checkstring;
    5277       GtslSpec3.Add(datastring)
    5278     end
    5279     else if spec3 = checkstring then
    5280       GtslSpec3.Add(datastring)
    5281     else
    5282     begin
    5283       spec4 := checkstring;
    5284       GtslSpec4.Add(datastring)
    5285     end;
    5286   end;
    5287 end;
    5288 
    5289 procedure TfrmGraphs.SpecSet(var spec1, spec2, spec3, spec4: string; aItemType, aItemName: string);
    5290 var
    5291   i: integer;
    5292   itemnum, newitemname, newitemnum, newstring: string;
    5293 begin
    5294   GtslMultiSpec.Clear;
    5295   itemnum := Piece(aItemType, '^', 2);
    5296   if length(spec1) > 0 then
    5297   begin
    5298     newitemnum := itemnum + '.1';
    5299     newitemname := aItemName + ' (' + LowerCase(Piece(spec1, '^', 4)) + ')';
    5300     for i := 0 to GtslItems.Count - 1 do
    5301     if aItemType = Pieces(GtslItems[i], '^', 1, 2) then
    5302     begin
    5303       newstring := GtslItems[i];
    5304       GtslItems.Delete(i);
    5305       break;
    5306     end;
    5307     for i := 0 to GtslData.Count - 1 do
    5308     if aItemType = Pieces(GtslData[i], '^', 1, 2) then
    5309       GtslData.Delete(i);
    5310     ResetSpec(GtslSpec1, itemnum, newitemnum, newitemname, newstring);
    5311   end;
    5312   if length(spec2) > 0 then
    5313   begin
    5314     newitemnum := itemnum + '.2';
    5315     newitemname := aItemName + ' (' + LowerCase(Piece(spec2, '^', 4)) + ')';
    5316     ResetSpec(GtslSpec2, itemnum, newitemnum, newitemname, newstring);
    5317   end;
    5318   if length(spec3) > 0 then
    5319   begin
    5320     newitemnum := itemnum + '.3';
    5321     newitemname := aItemName + ' (' + LowerCase(Piece(spec3, '^', 4)) + ')';
    5322     ResetSpec(GtslSpec3, itemnum, newitemnum, newitemname, newstring);
    5323   end;
    5324   if length(spec4) > 0 then
    5325   begin
    5326     newitemnum := itemnum + '.4';
    5327     newitemname := aItemName + ' (other)';     // not specific after 3 specimens (from same time)
    5328     ResetSpec(GtslSpec4, itemnum, newitemnum, newitemname, newstring);
    5329   end;
    5330 end;
    5331 
    53325201procedure TfrmGraphs.LabAdd(aListView: TListView; filename: string; aIndex, oldlisting: integer; selectlab: boolean);
    53335202var
     
    53395208  aListItem.SubItems.Add(filename);
    53405209  aListItem.SubItems.Add('');
    5341   aListItem.SubItems.Add('');
     5210  aListItem.SubItems.Add(Piece(GtslMultiSpec[aIndex], '^', 8));
    53425211  aGraphItem := TGraphItem.Create;
    53435212  aGraphItem.Values := GtslMultiSpec[aIndex];
     
    53745243  i, oldlisting: integer;
    53755244  filename: string;
    5376   spec1, spec2, spec3, spec4: string;
    53775245begin
    53785246  if getdata then
    53795247    FastAssign(rpcGetItemData(aItemType, FMTimeStamp, Patient.DFN), GtslScratchLab);
    5380   SpecCheck(spec1, spec2, spec3, spec4, singlespec);
     5248  SpecRefCheck(aItemType, aItemName, singlespec);
    53815249  if singlespec then
    53825250    FastAddStrings(GtslScratchLab, GtslData)
    53835251  else
    53845252  begin
    5385     SpecSet(spec1, spec2, spec3, spec4, aItemType, aItemName);
     5253    SpecRefSet(aItemType, aItemName);
    53865254    filename := FileNameX('63');
    53875255
     
    54085276  end;
    54095277end;
     5278
     5279// sort out for multiple spec or ref ranges
     5280procedure TfrmGraphs.SpecRefCheck(aItemType, aItemName: string; var singlespec: boolean);
     5281var
     5282  i: integer;
     5283  aitem, aspec, checkstring, datastring, refrange, low, high, units, srcheck, srcheck1: string;
     5284begin
     5285  GtslSpec1.Sorted := true;
     5286  GtslSpec1.Clear;
     5287  singlespec := true;
     5288  srcheck1 := '';
     5289  if GtslScratchLab.Count < 1 then exit;
     5290  for i := 0 to GtslScratchLab.Count - 1 do
     5291  begin
     5292    datastring := GtslScratchLab[i];
     5293    aitem := Piece(datastring, '^', 2);
     5294    aspec := Piece(datastring, '^', 7);
     5295    refrange := Piece(datastring, '^', 10);
     5296    units := Piece(datastring, '^', 11);
     5297    if length(refrange) = 0 then
     5298    begin
     5299      RefUnits(aitem, aspec, low, high, units);
     5300      refrange := low + '!' + high;
     5301      SetPiece(datastring, '^', 10, refrange);
     5302      SetPiece(datastring, '^', 11, units);
     5303    end;
     5304    srcheck := aitem + '^' + aspec + '^' + refrange + '^' + units;
     5305    checkstring := UpperCase(srcheck) + '^' + datastring;
     5306    GtslSpec1.Add(checkstring);
     5307    if i = 0 then srcheck1 := srcheck
     5308    else if srcheck1 <> srcheck then singlespec := false;
     5309  end;
     5310end;
     5311
     5312// for mutiple spec ranges replace data and items
     5313procedure TfrmGraphs.SpecRefSet(aItemType, aItemName: string);
     5314
     5315function MultiRef(aline: string): boolean;
     5316// check for multiple ref ranges on test/specimen
     5317var
     5318  i, cnt: integer;
     5319  listline, testspec, checkspec: string;
     5320begin
     5321  Result := false;
     5322  checkspec := Piece(aline, '^', 2);
     5323  cnt := 0;
     5324  for i := 0 to GtslSpec2.Count - 1 do
     5325  begin
     5326    listline := GtslSpec2[i];
     5327    testspec := Piece(listline, '^', 2);
     5328    if testspec = checkspec then cnt := cnt + 1;
     5329    if cnt > 1 then
     5330    begin
     5331      Result := true;
     5332      break;
     5333    end;
     5334  end;
     5335end;
     5336
     5337var
     5338  i, lastnum, cnt: integer;
     5339  newtsru, oldtsru, listline, newline, oldline, newtest, oldspec, refrange: string;
     5340  multispec: boolean;
     5341begin
     5342  lastnum := GtslSpec1.Count - 1;
     5343  if lastnum < 0 then
     5344    exit;
     5345  GtslSpec2.Clear; GtslSpec3.Clear; GtslSpec4.Clear;
     5346  GtslSpec1.Sort;
     5347  oldtsru := ''; newtest := '';
     5348  oldspec := Piece(GtslSpec1[0], '^', 2);
     5349  multispec := false;
     5350  cnt := 0;
     5351  for i := GtslSpec1.Count - 1 downto 0 do  // backwards to assure most recent item
     5352  begin
     5353    listline := GtslSpec1[i];
     5354    if Piece(listline, '^', 2) <> oldspec then multispec := true;
     5355    newtsru := Pieces(listline, '^', 1 , 4);
     5356    if newtsru <> oldtsru then
     5357    begin
     5358      cnt := cnt + 1;
     5359      newtest := Piece(listline, '^', 6) + '.' + inttostr(cnt);
     5360      SetPiece(listline, '^', 1, newtest);
     5361      GtslSpec2.Add(listline);
     5362      oldtsru := newtsru;
     5363    end;
     5364    newline := Pieces(listline, '^', 5, 15);
     5365    SetPiece(newline, '^', 2, newtest);
     5366    GtslSpec3.Add(newline);
     5367  end;
     5368  oldline := '';
     5369  for i := 0 to GtslItems.Count - 1 do
     5370  if aItemType = Pieces(GtslItems[i], '^', 1, 2) then
     5371  begin
     5372    oldline := GtslItems[i];
     5373    GtslItems.Delete(i);
     5374    break;
     5375  end;
     5376  for i := 0 to GtslSpec2.Count - 1 do
     5377  begin
     5378    listline := GtslSpec2[i];
     5379    newtest := Piece(oldline, '^', 4);
     5380    if multispec then
     5381      newtest := newtest + ' (' + LowerCase(Piece(listline, '^', 12)) + ')';
     5382    if MultiRef(listline) then
     5383    begin
     5384      refrange := Piece(listline, '^', 14);
     5385      newtest := newtest + ' ['
     5386               + Piece(refrange, '!', 1) + '-'
     5387               + Piece(refrange, '!', 2) + ']';
     5388    end;
     5389    newline := oldline;
     5390    SetPiece(newline, '^', 2, Piece(listline, '^', 1));
     5391    SetPiece(newline, '^', 4, newtest);
     5392    SetPiece(newline, '^', 6, Piece(listline, '^', 7));
     5393    SetPiece(newline, '^', 10, Piece(listline, '^', 14));
     5394    SetPiece(newline, '^', 11, Piece(listline, '^', 15));
     5395    GtslSpec4.Add(newline);
     5396  end;
     5397  FastAddStrings(GtslSpec4, GtslItems);
     5398  FastAddStrings(GtslSpec3, GtslData);
     5399  FastAssign(GtslSpec4, GtslMultiSpec);
     5400end;
     5401
     5402
    54105403
    54115404procedure TfrmGraphs.RefUnits(aItem, aSpec: string; var low, high, units: string);
     
    54985491    end;
    54995492  end;
    5500 end;
    5501 
    5502 procedure TfrmGraphs.ResetSpec(aList: TStrings; aItemNum, aNewItemNum, aNewItemName, aNewString: string);
    5503 var                                             //also add itemx
    5504   i: integer;
    5505   checkdate, newdate: double;
    5506   newestdate, newstring: string;
    5507 begin
    5508   GtslTemp.Clear;
    5509   newdate := 0;
    5510   for i := 0 to aList.Count - 1 do
    5511   begin
    5512     newstring := aList[i];
    5513     newestdate := FMCorrectedDate(Piece(newstring, '^', 3));
    5514     checkdate := strtofloatdef(newestdate, -BIG_NUMBER);
    5515     if checkdate > newdate then newdate := checkdate;
    5516     SetPiece(newstring, '^', 2, aNewItemNum);
    5517     GtslTemp.Add(newstring);
    5518   end;
    5519   FastAddStrings(GtslTemp, GtslData);
    5520   newestdate := floattostr(newdate);
    5521   SetPiece(aNewString, '^', 2, aNewItemNum);
    5522   SetPiece(aNewString, '^', 4, aNewItemName);
    5523   SetPiece(aNewString, '^', 6, newestdate);
    5524   GtslItems.Add(aNewString);
    5525   GtslMultiSpec.Add(aNewString);
    55265493end;
    55275494
     
    56395606var
    56405607  i: integer;
    5641   checktag, checkindex, checkseries, firstdatecheck, firsttext, nonstring: string;
     5608  checktag, checkindex, checkseries, firsttext, nonstring: string;
    56425609begin
    56435610  firsttext := MarkText;
     
    56495616    begin
    56505617      checkseries := inttostr(Sender.Tag - BIG_NUMBER);
    5651       firstdatecheck := floattostr(sender.XValue[ValueIndex]);
    56525618      checktag := inttostr(Sender.ParentChart.Tag);
    56535619      checkindex := inttostr(ValueIndex + 1);
     
    56765642  end
    56775643  else if Sender is TLineSeries then
    5678     MarkText := firsttext;   
     5644    MarkText := firsttext;
    56795645end;
    56805646
     
    57285694  displayheight, displaynum, i: integer;
    57295695begin
    5730   if Not Assigned(FGraphSetting) then Exit;
    57315696  ChartOnZoom(chartDatelineTop);
    57325697  with aScrollBox do
     
    60215986  if serLine.Title = 'Blood Pressure' then
    60225987    BPCheck(aChart, aFileType, serLine, serBPDiastolic, serBPMean);
    6023   for i:= 0 to GtslTemp.Count - 1 do
     5988  for i:= GtslTemp.Count - 1 downto 0 do         // go from oldest first
    60245989  begin
    60255990    checkdata := GtslTemp[i];
     
    65576522  hintformat := Piece(TypeString(Piece(Piece(astring, '^', 1), ' ', 1)), '^', 9);
    65586523  titlename := Piece(astring, '^', 2);
     6524  astring := StringReplace(astring, ' 00:00', '', [rfReplaceAll]);
    65596525  dttm := Piece(astring, '^', 3);
    6560   if copy(astring, length(astring) - 5, length(astring)) = ' 00:00' then
    6561     dttm := Pieces(dttm, ' ', 1, 3);
    65626526  itemname := Piece(astring, '^', 4);
    65636527  info := itemname + '~' + Piece(astring, '^', 5) + '~';
     
    69356899end;
    69366900
    6937 procedure TfrmGraphs.lstViewsBottomMouseDown(Sender: TObject;
    6938   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    6939 begin
    6940   //  for right mouse click make arrangements for view definition ****************
    6941 end;
    6942 
    69436901procedure TfrmGraphs.lvwItemsBottomChange(Sender: TObject; Item: TListItem;
    69446902  Change: TItemChange);
     
    69776935    pnlItemsTopInfo.Tag := 1;
    69786936    lvwItemsTop.ClearSelection;
    6979     if FTooManyItems then FTooManyItems := false
    6980     else
    6981     begin
    6982       ShowMsg('Too many items to graph');
    6983       FTooManyItems := true;  // flag so that warning will not be displayed twice
    6984     end;
     6937    ShowMsg('Too many items to graph');
    69856938    for i := 0 to GtslSelPrevTopFloat.Count - 1 do
    69866939      lvwItemsTop.Items[strtoint(GtslSelPrevTopFloat[i])].Selected := true;
Note: See TracChangeset for help on using the changeset viewer.