Changeset 830 for cprs/trunk/CPRS-Chart/fGraphs.pas
- Timestamp:
- Jul 7, 2010, 4:51:54 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cprs/trunk/CPRS-Chart/fGraphs.pas
r456 r830 7 7 ExtCtrls, StdCtrls, ORCtrls, Menus, TeeProcs, TeEngine, Series, Chart, Math, 8 8 ComCtrls, GanttCh, ClipBrd, StrUtils, ORFn, ORDtTmRng, DateUtils, Printers, 9 OleServer, Variants, Word97, Word2000, ArrowCha, ORDtTm, uGraphs; 9 OleServer, Variants, Word2000, ArrowCha, ORDtTm, uGraphs, fBase508Form 10 {$IFDEF VER140} 11 ,Word97; 12 {$ELSE} 13 ,WordXP, VA508AccessibilityManager; 14 {$ENDIF} 10 15 11 16 type 12 TfrmGraphs = class(T Form)17 TfrmGraphs = class(TfrmBase508Form) 13 18 btnChangeSettings: TButton; 14 19 btnClose: TButton; … … 28 33 dlgDate: TORDateTimeDlg; 29 34 lblDateRange: TLabel; 30 lblViewsBottom: TOROffsetLabel; 31 lblViewsTop: TOROffsetLabel; 32 lstAllTypes: TListBox; 33 lstCheck: TListBox; 34 lstData: TListBox; 35 lstDrugClass: TListBox; 36 lstItems: TListBox; 37 lstItemsTemp: TListBox; 38 lstMultiSpec: TListBox; 39 lstNonNumeric: TListBox; 40 lstScratchLab: TListBox; 41 lstScratchSwap: TListBox; 42 lstScratchTemp: TListBox; 43 lstSelCopyBottom: TListBox; 44 lstSelCopyTop: TListBox; 45 lstSpec1: TListBox; 46 lstSpec2: TListBox; 47 lstSpec3: TListBox; 48 lstSpec4: TListBox; 49 lstTemp: TListBox; 50 lstTempCheck: TListBox; 51 lstTestSpec: TListBox; 52 lstTypes: TListBox; 53 lstViews: TListBox; 54 lstZoomHistory: TListBox; 55 lvwItemsBottom: TListView; 56 lvwItemsTop: TListView; 57 mnumedsasgantt: TMenuItem; 58 mnumedsasganttvertheight: TMenuItem; 35 memBottom: TMemo; 36 memTop: TMemo; 37 mnuGraphData: TMenuItem; 59 38 mnuPopGraph3D: TMenuItem; 60 39 mnuPopGraphClear: TMenuItem; … … 65 44 mnuPopGraphDualViews: TMenuItem; 66 45 mnuPopGraphGradient: TMenuItem; 46 mnuPopGraphExport: TMenuItem; 67 47 mnuPopGraphFixed: TMenuItem; 68 48 mnuPopGraphHints: TMenuItem; … … 82 62 mnuPopGraphToday: TMenuItem; 83 63 mnuPopGraphValues: TMenuItem; 64 mnuPopGraphValueMarks: TMenuItem; 84 65 mnuPopGraphVertical: TMenuItem; 85 66 mnuPopGraphZoomBack: TMenuItem; … … 92 73 pnlBottom: TPanel; 93 74 pnlBottomRightPad: TPanel; 94 pnlData: TPanel;95 75 pnlDatelineBottom: TPanel; 96 76 pnlDatelineBottomSpacer: TORAutoPanel; … … 117 97 splItemsBottom: TSplitter; 118 98 splItemsTop: TSplitter; 99 mnuTestCount: TMenuItem; 119 100 timHintPause: TTimer; 120 lstSelPrevTop: TListBox; 121 lstSelPrevBottom: TListBox; 122 lstComp: TListBox; 123 pnlViewsTopSpacer: TPanel; 124 cboViewsTop: TORComboBox; 125 pnlViewsTopSpacerRight: TPanel; 126 pnlViewsBottomSpacer: TPanel; 127 cboViewsBottom: TORComboBox; 128 pnlViewsBottomSpacerRight: TPanel; 129 testcount1: TMenuItem; 101 mnuMHasNumeric1: TMenuItem; 102 mnuStandardDeviations: TMenuItem; 103 mnuInverseValues: TMenuItem; 104 mnuFunctions1: TMenuItem; 105 pcTop: TPageControl; 106 tsTopItems: TTabSheet; 107 tsTopViews: TTabSheet; 108 tsTopCustom: TTabSheet; 109 lvwItemsTop: TListView; 110 pcBottom: TPageControl; 111 tsBottomItems: TTabSheet; 112 tsBottomViews: TTabSheet; 113 tsBottomCustom: TTabSheet; 114 lvwItemsBottom: TListView; 115 mnuCustom: TMenuItem; 116 lstViewsTop: TORListBox; 117 lstViewsBottom: TORListBox; 118 memViewsTop: TRichEdit; 119 splViewsTop: TSplitter; 120 memViewsBottom: TRichEdit; 121 splViewsBottom: TSplitter; 122 mnuPopGraphViewDefinition: TMenuItem; 123 mnutest: TMenuItem; 124 130 125 procedure FormCreate(Sender: TObject); 131 126 procedure FormShow(Sender: TObject); 132 127 procedure FormClose(Sender: TObject; var Action: TCloseAction); 128 procedure FormDestroy(Sender: TObject); 133 129 134 130 procedure btnCloseClick(Sender: TObject); … … 137 133 138 134 procedure chkDualViewsClick(Sender: TObject); 135 procedure chkItemsBottomClick(Sender: TObject); 136 procedure chkItemsBottomEnter(Sender: TObject); 139 137 procedure chkItemsTopClick(Sender: TObject); 140 procedure chkItemsBottomClick(Sender: TObject);141 142 procedure mnuMedsasganttClick(Sender: TObject);143 138 procedure mnuPopGraph3DClick(Sender: TObject); 144 139 procedure mnuPopGraphClearClick(Sender: TObject); 145 procedure mnuPopGraphCopyClick(Sender: TObject);146 140 procedure mnuPopGraphDatesClick(Sender: TObject); 147 141 procedure mnuPopGraphDetailsClick(Sender: TObject); 148 142 procedure mnuPopGraphDualViewsClick(Sender: TObject); 143 procedure mnuPopGraphExportClick(Sender: TObject); 149 144 procedure mnuPopGraphFixedClick(Sender: TObject); 150 145 procedure mnuPopGraphGradientClick(Sender: TObject); … … 163 158 procedure mnuPopGraphSwapClick(Sender: TObject); 164 159 procedure mnuPopGraphTodayClick(Sender: TObject); 160 procedure mnuPopGraphValueMarksClick(Sender: TObject); 165 161 procedure mnuPopGraphValuesClick(Sender: TObject); 166 162 procedure mnuPopGraphHorizontalClick(Sender: TObject); … … 172 168 procedure splItemsTopMoved(Sender: TObject); 173 169 174 procedure GetSize; 175 procedure SetSize; 176 170 procedure lvwItemsBottomChange(Sender: TObject; Item: TListItem; 171 Change: TItemChange); 177 172 procedure lvwItemsBottomClick(Sender: TObject); 178 173 procedure lvwItemsBottomColumnClick(Sender: TObject; Column: TListColumn); 179 174 procedure lvwItemsBottomCompare(Sender: TObject; Item1, 180 175 Item2: TListItem; Data: Integer; var Compare: Integer); 176 procedure lvwItemsTopChange(Sender: TObject; Item: TListItem; 177 Change: TItemChange); 181 178 procedure lvwItemsTopClick(Sender: TObject); 182 179 procedure lvwItemsTopColumnClick(Sender: TObject; Column: TListColumn); 183 180 procedure lvwItemsTopCompare(Sender: TObject; Item1, Item2: TListItem; 184 181 Data: Integer; var Compare: Integer); 182 procedure lvwItemsTopKeyDown(Sender: TObject; var Key: Word; 183 Shift: TShiftState); 185 184 186 185 procedure cboDateRangeChange(Sender: TObject); 187 procedure cboViewsBottomChange(Sender: TObject); 188 procedure cboViewsTopChange(Sender: TObject); 189 190 procedure pnlScrollTopBaseResize(Sender: TObject); 186 procedure cboDateRangeDropDown(Sender: TObject); 191 187 192 188 procedure chartBaseClickLegend(Sender: TCustomChart; … … 196 192 procedure chartBaseMouseDown(Sender: TObject; Button: TMouseButton; 197 193 Shift: TShiftState; X, Y: Integer); 194 procedure chartBaseMouseUp(Sender: TObject; Button: TMouseButton; 195 Shift: TShiftState; X, Y: Integer); 198 196 procedure chartBaseMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); 199 197 procedure serDatelineTopGetMarkText(Sender: TChartSeries; … … 202 200 procedure ChartOnUndoZoom(Sender: TObject); 203 201 procedure ChartOnZoom(Sender: TObject); 202 procedure DateSteps(dateranges: string); 204 203 procedure DisplayData(aSection: string); 204 procedure DisplayDataInfo(aScrollBox: TScrollBox; aMemo: TMemo); 205 procedure GraphSwap(bottomview, topview: integer); 206 procedure GraphSwitch(bottomview, topview: integer); 205 207 procedure HideDates(aChart: TChart); 208 procedure LabelClicks(aChart: TChart; aSeries: TChartSeries; lbutton: boolean; tmp: integer); 209 procedure MouseClicks(aChart: TChart; lbutton: boolean; X, Y: Integer); 210 procedure SeriesClicks(aChart: TChart; aSeries: TChartSeries; aIndex: integer; lbutton: boolean); 211 procedure SetupFields(settings: string); 206 212 procedure SourcesDefault; 207 213 procedure StayOnTop; 208 209 procedure timHintPauseTimer(Sender: TObject); 214 procedure FormatHint(var astring: string); 215 210 216 procedure ZoomUpdate; 211 217 procedure ZoomUpdateInfo(SmallTime, BigTime: TDateTime); 212 218 procedure ZoomTo(SmallTime, BigTime: TDateTime); 213 procedure lvwItemsTopChange(Sender: TObject; Item: TListItem; 214 Change: TItemChange); 215 procedure lvwItemsTopKeyDown(Sender: TObject; var Key: Word; 216 Shift: TShiftState); 217 procedure lvwItemsBottomChange(Sender: TObject; Item: TListItem; 218 Change: TItemChange); 219 procedure testcount1Click(Sender: TObject); 220 procedure cboDateRangeDropDown(Sender: TObject); 221 procedure cboViewsTopDropDown(Sender: TObject); 222 procedure cboViewsTopDropDownClose(Sender: TObject); 223 procedure cboViewsBottomDropDown(Sender: TObject); 224 procedure cboViewsBottomDropDownClose(Sender: TObject); 225 procedure FormDestroy(Sender: TObject); 219 220 procedure lvwItemsBottomEnter(Sender: TObject); 226 221 procedure lvwItemsTopEnter(Sender: TObject); 227 procedure lvwItemsBottomEnter(Sender: TObject); 228 procedure chkItemsBottomEnter(Sender: TObject); 229 procedure cboViewsBottomEnter(Sender: TObject); 222 223 procedure memBottomEnter(Sender: TObject); 224 procedure memBottomExit(Sender: TObject); 225 procedure memBottomKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); 226 procedure memTopEnter(Sender: TObject); 227 procedure memTopExit(Sender: TObject); 228 procedure memTopKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); 229 230 procedure pnlScrollTopBaseResize(Sender: TObject); 231 procedure timHintPauseTimer(Sender: TObject); 232 233 procedure GetSize; 234 procedure SetSize; 235 procedure mnuGraphDataClick(Sender: TObject); 236 procedure mnuCustomClick(Sender: TObject); 237 procedure lstViewsTopChange(Sender: TObject); 238 procedure lstViewsBottomChange(Sender: TObject); 239 procedure mnuMHasNumeric1Click(Sender: TObject); 240 procedure lstViewsTopEnter(Sender: TObject); 241 procedure lstViewsBottomEnter(Sender: TObject); 242 procedure mnuPopGraphViewDefinitionClick(Sender: TObject); 243 procedure lstViewsTopMouseDown(Sender: TObject; Button: TMouseButton; 244 Shift: TShiftState; X, Y: Integer); 245 procedure splViewsTopMoved(Sender: TObject); 246 procedure lstViewsBottomMouseDown(Sender: TObject; Button: TMouseButton; 247 Shift: TShiftState; X, Y: Integer); 230 248 231 249 private 232 { Private declarations }233 250 FBSortAscending: boolean; 234 251 FBSortCol: integer; … … 242 259 FBHighTime, FBLowTime: Double; 243 260 FCreate: boolean; 261 FDisplayFreeText: boolean; 262 FFastData: boolean; 263 FFastItems: boolean; 264 FFastLabs: boolean; 265 FFastTrack: boolean; 244 266 FFirstClick: boolean; 245 267 FFirstSwitch: boolean; 246 268 FGraphClick: TCustomChart; 247 269 FGraphSeries: TChartSeries; 248 FGraphValueIndex: integer;249 270 FGraphSetting: TGraphSetting; 250 271 FGraphType: char; 272 FGraphValueIndex: integer; 251 273 FItemsSortedTop: boolean; 252 274 FItemsSortedBottom: boolean; … … 254 276 FMTimestamp: string; 255 277 FMToday: TFMDateTime; 256 FMyProfiles, FProfiles: TStringList;257 278 FNonNumerics: boolean; // used with pnlItemsTop.Tag & pnlItemsBottom.Tag 258 279 FOnLegend: integer; 280 FOnMark: boolean; 259 281 FOnSeries: integer; 260 282 FOnValue: integer; … … 264 286 FSourcesDefault: TStrings; 265 287 FTHighTime, FTLowTime: Double; 288 FTooManyItems: boolean; 266 289 FWarning: boolean; 267 290 FX, FY: integer; … … 269 292 FYMaxValue: Double; 270 293 294 procedure AddOnLabGroups(aListBox: TORListBox; personien: integer); 271 295 procedure AdjustTimeframe; 272 296 procedure AllTypeDate(aType, aTypeName, firstline, secondline: string; aDate, aDate2: double); … … 275 299 procedure AutoSelect(aListView: TListView); 276 300 procedure BaseResize(aScrollBox: TScrollBox); 301 procedure BorderValue(var bordervalue: double; value: double); 277 302 procedure BottomAxis(aScrollBox: TScrollBox); 303 procedure BPAdd(itemvalue: string; adatetime: TDateTime; var fixeddatevalue: double; serLine, serBPDiastolic, serBPMean: TLineSeries); 304 procedure BPCheck(aChart: TChart; aFileType: string; serLine, serBPDiastolic, serBPMean: TLineSeries); 278 305 procedure ChangeStyle; 306 procedure ChartColor(aColor: TColor); 279 307 procedure ChartStyle(aChart: TChart); 308 procedure CheckMedNum(var typenum: string; aSeries: TChartSeries); 280 309 procedure CheckProfile(var aProfile: string; var Updated: boolean); 281 310 procedure CheckToAddData(aListView: TListView; aSection, TypeToCheck: string); 311 procedure CreateExcelPatientHeader(var HeaderList: TStringList; PageTitle, DateRange: string); 282 312 procedure CreatePatientHeader(var HeaderList: TStringList; PageTitle, Warning, DateRange: string); 283 313 procedure DateRangeItems(oldestdate, newestdate: double; filenum: string); 284 procedure UpdateView(filename, filenum, itemnum, aString: string; aListView: TListView);285 314 procedure DisplayType(itemtype, displayed: string); 315 procedure FastLab(aList: TStringList); 286 316 procedure FillViews; 287 317 procedure FilterListView(oldestdate, newestdate: double); 288 318 procedure FixedDates(var adatetime, adatetime1: TDateTime); 289 319 procedure GetData(aString: string); 320 procedure GraphBoundry(singlepoint: boolean); 321 procedure GraphFooter(aChart: TChart; datediff: integer; aDate: TDateTime); 290 322 procedure HideGraphs(action: boolean); 291 323 procedure HighLow(fmtime, fmtime1: string; aChart: TChart; var adatetime, adatetime1: TDateTime); 292 324 procedure InactivateHint; 325 procedure InfoMessage(aCaption: string; aColor: TColor; aVisible: boolean); 293 326 procedure ItemCheck(aListView: TListView; aItemName: string; 294 327 var aNum: integer; var aTypeItem: string); 328 procedure ItemDateRange(Sender: TCustomChart); 295 329 procedure ItemsClick(Sender: TObject; aListView, aOtherListView: TListView; 296 aCheckBox: TCheckBox; aComboBox: TORComboBox; aList: TListBox; aSection: string); 297 procedure ItemDateRange(Sender: TCustomChart); 298 procedure LabData(aItemType, aItemName, aSection: string); 330 aCheckBox: TCheckBox; aListBox: TORListBox; aList: TStrings; aSection: string); 331 procedure LabAdd(aListView: TListView; filename: string; aIndex, oldlisting: integer; selectlab: boolean); 332 procedure LabCheck(aListView: TListView; aItemType: string; var oldlisting: integer); 333 procedure LabData(aItemType, aItemName, aSection: string; getdata: boolean); 299 334 procedure LoadDateRange; 300 335 procedure LoadDisplayCheck(typeofitem: string; var updated: boolean); 301 336 procedure LoadType(itemtype, displayed: string); 302 337 procedure NextPointerStyle(aSeries: TChartSeries; aSerCnt: integer); 338 procedure NonNumSave(aChart: TChart; aTitle, aSection: string; adatetime: TDateTime; 339 var noncnt: integer; newcnt, aIndex: integer); 340 procedure NotifyApps(aList: TStrings); 341 procedure NumAdd(serLine: TLineSeries; value: double; adatetime: TDateTime; 342 var fixeddatevalue, hi, lo: double; var high, low: string); 303 343 procedure OneDayTypeDetails(aTypeItem: string); 344 procedure PadNonNum(aChart: TChart; aSection: string; var listofseries: string; var bmax, tmax: integer); 345 procedure PainAdd(serBlank: TPointSeries); 304 346 procedure RefUnits(aItem, aSpec: string; var low, high, units: string); 305 procedure ResetSpec(aListBox: TListBox; aItemNum, aNewItemNum, aNewItemName, aNewString: string); 306 procedure TempCheck(typeitem: string; var levelseq: double); 307 procedure SelCopy(aListView: TListView; aListBox: TListBox); 308 procedure SelReset(aListbox: TListBox; aListView: TListView); 347 procedure ResetSpec(aList: TStrings; aItemNum, aNewItemNum, aNewItemName, aNewString: string); 348 procedure ResultValue(var resultstring, seriestitle: string; typenum, typeitem: string; 349 Sender: TCustomChart; aSeries: TChartSeries; ValueIndex, SeriesNum: Integer; var OKToUse: boolean); 350 procedure SelCopy(aListView: TListView; aList: TStrings); 351 procedure SelReset(aList: TStrings; aListView: TListView); 309 352 procedure SelectItem(aListView: TListView; typeitem: string); 353 procedure SeriesForLabels(aChart: TChart; aID: string; pad: double); 310 354 procedure SetProfile(aProfile, aName: string; aListView: TListView); 311 355 procedure SizeDates(aChart: TChart; aSmallTime, aBigTime: TDateTime); 312 356 procedure SizeTogether(onlylines, nolines, anylines: Boolean; aScroll: TScrollBox; 313 357 aChart: TChart; aPanel, aPanelBase: TPanel; portion: Double); 314 procedure ViewsChange(aListView: TListView; aComboBox: TORComboBox; aSection: string); 315 358 procedure SpecCheck(var spec1, spec2, spec3, spec4: string; var singlespec: boolean); 359 procedure SpecSet(var spec1, spec2, spec3, spec4: string; aItemType, aItemName: string); 360 procedure SplitClick; 361 procedure SortListView; 362 procedure StackNonNum(astring: string; var offset, bmax, tmax: integer; var blabelon, tlabelon: boolean); 363 procedure TempCheck(typeitem: string; var levelseq: double); 364 procedure TempData(aStringList: TStringList; aType: string; dt1, dt2: double); 365 procedure UpdateView(filename, filenum, itemnum, aString: string; aListView: TListView); 366 procedure ValueDates(aSeries: TChartSeries; ValueIndex: Integer; var resultdate, otherdate: string); 367 procedure ViewsChange(aListView: TListView; aListBox: TORListBox; aSection: string); 368 369 procedure MakeSeparate(aScrollBox: TScrollBox; aListView: TListView; aPadPanel: TPanel; section: string); 370 procedure MakeSeparateItems(aScrollBox: TScrollBox; aListView: TListView; section: string); 371 procedure MakeTogether(aScrollBox: TScrollBox; aListView: TListView; aPadPanel: TPanel; section: string); 372 procedure MakeTogetherMaybe(aScrollBox: TScrollBox; aListView: TListView; aPadPanel: TPanel; section: string); 373 procedure MakeTogetherNoLines(aListView: TListView; section: string); 374 procedure MakeTogetherOnlyLines(aListView: TListView; section: string; aChart: TChart); 375 procedure MakeTogetherAnyLines(aListView: TListView; section: string; aChart: TChart); 376 377 procedure MakeChart(aChart: TChart; aScrollBox: TScrollBox); 378 procedure MakeComments(aChart: TChart); 316 379 procedure MakeDateline(section, aTitle, aFileType: string; aChart: TChart; graphtype: integer; 317 var bcnt, pcnt, gcnt, vcnt, acnt: integer); 318 procedure MakeSeparate(aScrollBox: TScrollBox; aListView: TListView; aPadPanel: TPanel; section: string); 319 procedure MakeTogether(aScrollBox: TScrollBox; aListView: TListView; aPadPanel: TPanel; section: string); 320 321 procedure MakeAGanttSeries(aChart: TChart; aTitle, aFileType: string; var aSerCnt: integer); 322 procedure MakeArrowSeries(aChart: TChart; aTitle, aFileType: string; var aSerCnt: integer); 380 var bcnt, pcnt, gcnt, vcnt: integer); 381 procedure MakeNonNumerics(aChart: TChart); 382 procedure MakeNonNumSeries(aChart: TChart; padvalue, highestvalue, lowestvalue: double; listofseries, section: string); 383 procedure MakeOtherSeries(aChart: TChart); 384 procedure MakeSeriesInfo(aChart: TChart; aSeries: TChartSeries; aTitle, aFileType: string; aSerCnt: integer); 385 procedure MakeSeriesPoint(aChart: TChart; aPointSeries: TPointSeries); 386 procedure MakeSeriesRef(aChart: TChart; aTest, aRef: TLineSeries; aTitle, aValue: string; aDate: double); 387 procedure MakeSeriesBP(aChart: TChart; aTest, aBP: TLineSeries; aFileType: string); 388 323 389 procedure MakeBarSeries(aChart: TChart; aTitle, aFileType: string; var aSerCnt: integer); 324 procedure Make GanttSeries(aChart: TChart; aTitle, aFileType: string; var aSerCnt: integer);325 procedure MakeLineSeries(aChart: TChart; aTitle, aFileType: string;var aSerCnt, aNonCnt: integer; multiline: boolean);326 procedure Make ManyGanttSeries(aChart: TChart; aTitle, aFileType: string; var aSerCnt: integer); // good one390 procedure MakeLineSeries(aChart: TChart; aTitle, aFileType, section: string; 391 var aSerCnt, aNonCnt: integer; multiline: boolean); 392 procedure MakeGanttSeries(aChart: TChart; aTitle, aFileType: string; var aSerCnt: integer); // good one 327 393 procedure MakePointSeries(aChart: TChart; aTitle, aFileType: string; var aSerCnt: integer); 328 394 procedure MakeVisitGanttSeries(aChart: TChart; aTitle, aFileType: string; var aSerCnt: integer); 329 procedure MakeWeightedArrowSeries(aChart: TChart; aTitle, aFileType: string; var aSerCnt: integer);330 procedure MakeWeightedGanttSeries(aChart: TChart; aTitle, aFileType: string; var aSerCnt: integer);331 395 332 396 function BPValue(aDateTime: TDateTime): string; … … 341 405 function ItemName(filenum, itemnum: string): string; 342 406 function NextColor(aCnt: integer): TColor; 343 function PortionSize(lcnt, pcnt, gcnt, vcnt, bcnt, acnt: integer): double; 407 function NonNumText(listnum, seriesnum, valueindex: integer): string; 408 function PadLeftEvent(aWidth: integer): integer; 409 function PadLeftNonNumeric(aWidth: integer): integer; 410 function PortionSize(lcnt, pcnt, gcnt, vcnt, bcnt: integer): double; 411 function ProfileName(aProfile, aName, aString: string): string; 344 412 function SelectRef(aRef: string): string; 413 function SingleLabTest(aListView: TListView): boolean; 345 414 function StdDev(value, high, low: double): double; 415 function TitleInfo(filetype, typeitem, caption: string): string; 346 416 function TypeIsDisplayed(itemtype: string): boolean; 347 417 function TypeIsLoaded(itemtype: string): boolean; 348 function Vfactor(aTitle: string): double; 349 function ValueText(Sender: TCustomChart; Series: TChartSeries; ValueIndex: Integer): string; 350 418 function TypeString(filenum: string): string; 419 function ValueText(Sender: TCustomChart; aSeries: TChartSeries; ValueIndex: Integer): string; 420 protected 421 procedure UpdateAccessabilityActions(var Actions: TAccessibilityActions); override; 351 422 public 352 { Public declarations }423 procedure DateDefaults; 353 424 procedure InitialData; 354 425 procedure Initialize; … … 356 427 procedure LoadListView(aList: TStrings); 357 428 procedure SourceContext; 429 procedure Switch; 430 procedure ViewDefinition(profile: string; amemo: TRichEdit); 358 431 procedure ViewSelections; 432 procedure DisplayFreeText(aChart: TChart); 359 433 procedure SetFontSize(FontSize: integer); 360 434 function FMToDateTime(FMDateTime: string): TDateTime; … … 369 443 implementation 370 444 371 uses fGraphSettings, fGraphProfiles, rGraphs, 372 ComObj, ActiveX, ShellAPI, fFrame, uCore, rCore, fRptBox, fReports, 373 uFormMonitor; 445 uses fGraphSettings, fGraphProfiles, fGraphData, fGraphOthers, rGraphs, 446 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 374 451 375 452 {$R *.DFM} … … 384 461 var 385 462 i: integer; 386 dfntype, listline, settings, settings1, t1, t2: string; 387 aList: TStrings; 388 begin 389 FMToday := DateTimeToFMDateTime(Date); 390 FHintWinActive := false; 391 FHintStop := false; 392 FNonNumerics := false; 393 FMouseDown := false; 394 FItemsSortedTop := false; 395 FItemsSortedBottom := false; 396 FRetainZoom := false; 397 FFirstClick := true; 398 FArrowKeys := false; 399 FCreate := true; 400 FGraphType := Char(32); 401 aList := TStringList.Create; 402 FastAssign(rpcGetGraphSettings, aList); 463 dfntype, listline, settings, settings1: string; 464 begin 403 465 btnClose.Tag := 0; 404 if aList.Count < 1 then 466 settings := GetCurrentSetting; 467 if (length(settings) < 1) then 405 468 begin 406 469 Screen.Cursor := crDefault; 407 showmessage('CPRS is not configured for graphing.');470 ShowMsg(TXT_NOGRAPHING); 408 471 btnClose.Tag := 1; 409 FreeAndNil(aList);410 472 Close; 411 473 Exit; 412 474 end; 413 t1 := aList[0]; t2 := aList[1]; // hint are current, t1 are personal, t2 public settings 414 if length(frmFrame.mnuToolsGraphing.Hint) > 0 then settings := frmFrame.mnuToolsGraphing.Hint 415 else if length(t1) > 0 then settings := t1 416 else settings := t2; 417 SetPiece(settings, '|', 8, Piece(t2, '|', 8)); //?????????? 418 frmFrame.mnuToolsGraphing.Hint := settings; 475 SetupFields(settings); 419 476 settings1 := Piece(settings, '|', 1); 420 FSources := TStringList.Create;421 FSourcesDefault := TStringList.Create;422 FMyProfiles := TStringList.Create;423 FProfiles := TStringList.Create;424 FYMinValue := 0;425 FYMaxValue := 0;426 FTHighTime := 0;427 FTLowTime := BIG_NUMBER;428 FBHighTime := 0;429 FBLowTime := BIG_NUMBER;430 477 pnlInfo.Caption := TXT_INFO; 431 FOnLegend := BIG_NUMBER;432 FOnSeries := BIG_NUMBER;433 FOnValue := BIG_NUMBER;434 FHintWin := THintWindow.Create(self);435 FHintWin.Color := clInfoBk;436 FHintWin.Canvas.Font.Color := clInfoBk;437 FX := 0; FY :=0;438 FastAssign(rpcGetTypes('0', false), lstAllTypes.Items);439 for i := 0 to lstAllTypes.Items.Count - 1 do440 begin441 listline := lstAllTypes.Items[i];442 dfntype := UpperCase(Piece(listline, '^', 1));443 SetPiece(listline, '^', 1, dfntype);444 lstAllTypes.Items[i] := listline;445 end;446 FGraphSetting := GraphSettingsInit(settings);447 478 for i := 0 to BIG_NUMBER do 448 479 begin … … 460 491 chartDatelineBottom.Gradient.StartColor := clWindow; 461 492 LoadDateRange; 462 chkItemsTop.Checked := true; 463 chkItemsBottom.Checked := true; 464 FastAssign(rpcGetTestSpec, lstTestSpec.Items); 493 //chkItemsTop.Checked := true; 494 //chkItemsBottom.Checked := true; 465 495 FillViews; 466 FreeAndNil(aList); 496 pcTop.ActivePage := tsTopItems; 497 pcBottom.ActivePage := tsBottomItems; 498 end; 499 500 procedure TfrmGraphs.SetupFields(settings: string); 501 begin 502 FArrowKeys := false; 503 FBHighTime := 0; 504 FBLowTime := BIG_NUMBER; 505 FCreate := true; 506 FDisplayFreeText := true; 507 FGraphType := Char(32); 508 FFirstClick := true; 509 FFirstSwitch := true; 510 FGraphSetting := GraphSettingsInit(settings); 511 FHintStop := false; 512 FHintWin := THintWindow.Create(self); 513 FHintWin.Color := clInfoBk; 514 FHintWin.Canvas.Font.Color := clInfoBk; 515 FHintWinActive := false; 516 FItemsSortedBottom := false; 517 FItemsSortedTop := false; 518 FMouseDown := false; 519 FMTimestamp := floattostr(FMNow); 520 FMToday := DateTimeToFMDateTime(Date); 521 FNonNumerics := false; 522 FOnLegend := BIG_NUMBER; 523 FOnMark := false; 524 FOnSeries := BIG_NUMBER; 525 FOnValue := BIG_NUMBER; 526 FPrevEvent := ''; 527 FRetainZoom := false; 528 FSources := TStringList.Create; 529 FSourcesDefault := TStringList.Create; 530 FTHighTime := 0; 531 FTLowTime := BIG_NUMBER; 532 FWarning := false; 533 FTooManyItems := false; 534 FX := 0; FY :=0; 535 FYMinValue := 0; 536 FYMaxValue := 0; 467 537 end; 468 538 … … 470 540 var 471 541 i: integer; 472 dfntype, listline, settings, settings1, t1, t2: string; 473 aList: TStrings; 474 begin 475 aList := TStringList.Create; 476 FastAssign(rpcGetGraphSettings, aList); 477 t1 := aList[0]; t2 := aList[1]; // t1 are personal, t2 public settings 478 if length(frmFrame.mnuToolsGraphing.Hint) > 0 then settings := frmFrame.mnuToolsGraphing.Hint 479 else if length(t1) > 0 then settings := t1 480 else settings := t2; 481 SetPiece(settings, '|', 8, Piece(t2, '|', 8)); 542 dfntype, listline, settings, settings1: string; 543 begin 544 settings := GetCurrentSetting; 482 545 settings1 := Piece(settings, '|', 1); 483 FGraphSetting := GraphSettingsInit(settings);484 546 for i := 0 to BIG_NUMBER do 485 547 begin … … 489 551 FSourcesDefault.Add(listline); 490 552 end; 491 FreeAndNil(aList);492 553 end; 493 554 494 555 procedure TfrmGraphs.Initialize; 495 var 556 var // from fFrame and fReports 496 557 i: integer; 497 558 rptview1, rptview2, rptviews: string; … … 499 560 InitialData; 500 561 SourceContext; 501 LoadListView( lstItems.Items);562 LoadListView(GtslItems); 502 563 if pnlMain.Tag > 0 then 503 564 begin … … 509 570 if length(rptview1) > 0 then 510 571 begin 511 for i := 0 to cboViewsTop.Items.Count - 1 do 512 if Piece(cboViewsTop.Items[i], '^', 2) = rptview1 then 572 //pcTop.ActivePage := tsTopViews; 573 lstViewsTop.Tag := 0; 574 for i := 0 to lstViewsTop.Items.Count - 1 do 575 if Piece(lstViewsTop.Items[i], '^', 2) = rptview1 then 513 576 begin 514 cboViewsTop.ItemIndex := i;577 lstViewsTop.ItemIndex := i; 515 578 break; 516 579 end; 580 if lstViewsTop.ItemIndex < 0 then 581 lvwItemsTopClick(self); 517 582 end; 518 583 if length(rptview2) > 0 then … … 520 585 chkDualViews.Checked := true; 521 586 chkDualViewsClick(self); 522 for i := 0 to cboViewsBottom.Items.Count - 1 do 523 if Piece(cboViewsBottom.Items[i], '^', 2) = rptview2 then 587 //pcBottom.ActivePage := tsBottomViews; 588 lstViewsBottom.Tag := 0; 589 for i := 0 to lstViewsBottom.Items.Count - 1 do 590 if Piece(lstViewsBottom.Items[i], '^', 2) = rptview2 then 524 591 begin 525 cboViewsBottom.ItemIndex := i;592 lstViewsBottom.ItemIndex := i; 526 593 break; 527 594 end; 595 if lstViewsBottom.ItemIndex < 0 then 596 lvwItemsBottomClick(self); 528 597 end; 529 598 end; 530 end; 531 if cboViewsTop.ItemIndex > -1 then 532 cboViewsTopChange(self) 599 pnlMain.Tag := 0; 600 cboDateRangeChange(self); 601 exit; 602 end; 603 if lstViewsTop.ItemIndex > -1 then 604 lstViewsTopChange(self) 533 605 else 534 606 lvwItemsTopClick(self); 535 if cboViewsBottom.ItemIndex > -1 then536 cboViewsbottomChange(self)607 if lstViewsBottom.ItemIndex > -1 then 608 lstViewsbottomChange(self) 537 609 else 538 610 lvwItemsBottomClick(self); 539 if pnlMain.Tag > 0 then540 begin541 pnlMain.Tag := 0;542 cboDateRangeChange(self);543 if cboViewsTop.ItemIndex > -1 then544 cboViewsTopChange(self)545 else546 lvwItemsTopClick(self);547 if cboViewsBottom.ItemIndex > -1 then548 cboViewsbottomChange(self)549 else550 lvwItemsBottomClick(self);551 end;552 611 end; 553 612 554 613 procedure TfrmGraphs.InitialRetain; 555 //var 556 //i: integer; 557 begin 558 {// 559 allview=false 560 fullview=false 561 noview=true 562 go thru items 563 if selected 564 if view 565 noview=false 566 else 567 allview=false 568 569 else 570 if view 571 allview=false 572 fullview=false 573 noview=false 574 else 575 // 576 if noview 577 // 578 if allview 579 // 580 if fullview 581 // 582 else //partial view 583 // 584 //} 614 begin 615 // from fFrame 585 616 end; 586 617 … … 588 619 var 589 620 i: integer; 590 begin 591 with cboViewsTop do 592 begin 593 Items.Clear; 594 Sorted := false; 595 lstTemp.Sorted := true; 596 FastAssign(rpcGetGraphProfiles('1', '0', 0), lstTemp.Items); 597 if lstTemp.Items.Count > 0 then 598 begin 599 for i := 0 to lstTemp.Items.Count - 1 do 600 Items.Add('-1^' + lstTemp.Items[i] + '^'); 601 end; 602 FastAssign(rpcGetGraphProfiles('1', '1', 0), lstTemp.Items); 603 if lstTemp.Items.Count > 0 then 604 begin 605 Items.Add(LLS_LINE); 606 for i := 0 to lstTemp.Items.Count - 1 do 607 Items.Add('-2^' + lstTemp.Items[i] + '^'); 608 end; 609 Items.Insert(0, '^<clear all selections>^0'); 610 Items.Insert(1, '^<select items>^0'); 611 end; 612 FastAssign(cboViewsTop.Items, cboViewsBottom.Items); 621 listline: string; 622 begin 623 lstViewsTop.Tag := BIG_NUMBER; 624 lstViewsBottom.Tag := BIG_NUMBER; 625 lstViewsTop.Sorted := false; 626 lstViewsBottom.Sorted := false; 627 lstViewsTop.Items.Clear; 628 lstViewsBottom.Items.Clear; 629 GtslViewPersonal.Sorted := true; 630 FastAssign(GetGraphProfiles('1', '0', 0, User.DUZ), GtslViewPersonal); 631 GtslViewPublic.Sorted := true; 632 FastAssign(GetGraphProfiles('1', '1', 0, 0), GtslViewPublic); 633 with lstViewsTop do 634 begin 635 if GtslViews.Count > 0 then 636 begin 637 if not ((GtslViews.Count = 1) and (Piece(GtslViews[0], '^', 1) = VIEW_CURRENT)) then 638 begin 639 Items.Add(LLS_FRONT + copy('Temporary Views' + LLS_BACK, 0, 60) + '^0'); 640 for i := 0 to GtslViews.Count - 1 do 641 begin 642 listline := GtslViews[i]; 643 if Piece(listline, '^', 1) <> VIEW_CURRENT then 644 Items.Add(VIEW_TEMPORARY + '^' + listline + '^'); 645 end; 646 end; 647 end; 648 if GtslViewPersonal.Count > 0 then 649 begin 650 Items.Add(LLS_FRONT + copy('Personal Views' + LLS_BACK, 0, 60) + '^0'); 651 for i := 0 to GtslViewPersonal.Count - 1 do 652 Items.Add(VIEW_PERSONAL + '^' + GtslViewPersonal[i] + '^'); 653 end; 654 if GtslViewPublic.Count > 0 then 655 begin 656 Items.Add(LLS_FRONT + copy('Public Views' + LLS_BACK, 0, 60) + '^0'); 657 for i := 0 to GtslViewPublic.Count - 1 do 658 Items.Add(VIEW_PUBLIC + '^' + GtslViewPublic[i] + '^'); 659 end; 660 AddOnLabGroups(lstViewsTop, 0); 661 end; 662 FastAssign(lstViewsTop.Items, lstViewsBottom.Items); 663 end; 664 665 procedure TfrmGraphs.AddOnLabGroups(aListBox: TORListBox; personien: integer); 666 var 667 i: integer; 668 begin 669 if personien < 1 then personien := User.DUZ; 670 FastAssign(rpcTestGroups(personien), GtslLabGroup); 671 GtslLabGroup.Sorted := true; 672 if GtslLabGroup.Count > 0 then 673 begin 674 aListBox.Items.Add(LLS_FRONT + copy('Lab Groups' + LLS_BACK, 0, 60) + '^0'); 675 for i := 0 to GtslLabGroup.Count - 1 do 676 aListBox.Items.Add(VIEW_LABS + '^' + Piece(GtslLabGroup[i], '^', 2) 677 + '^' + Piece(GtslLabGroup[i], '^', 1) + '^' + inttostr(personien)); 678 end; 613 679 end; 614 680 … … 646 712 end; 647 713 end; 648 if cboDateRange.ItemIndex < 0 then 649 cboDateRange.ItemIndex := cboDateRange.Items.Count - 1; 714 DateDefaults; 650 715 cboDateRangeChange(self); 651 716 lvwItemsTopClick(self); 652 717 if lvwItemsTop.Items.Count = 0 then 653 718 begin 654 cboViewsTop.ItemIndex := 0; 655 cboViewsTop.Text := ''; 656 end; 657 //else 658 // lvwItemsTop.SetFocus; 659 //chkItemsTop.SetFocus; 660 cboViewsTop.SetFocus; 661 //Perform(WM_NextDlgCtl, 0, 0); 719 lstViewsTop.ItemIndex := -1 720 end; 721 if not mnuPopGraphViewDefinition.Checked then 722 mnuPopGraphViewDefinitionClick(self); 723 tsTopCustom.TabVisible := false; 724 tsBottomCustom.TabVisible := false; 725 end; 726 727 procedure TfrmGraphs.DateDefaults; 728 begin 729 if Patient.Inpatient then 730 cboDateRange.SelectByID(GetDefaultInpatientDate) 731 else 732 cboDateRange.SelectByID(GetDefaultOutpatientDate); 733 if cboDateRange.ItemIndex < 0 then 734 cboDateRange.ItemIndex := cboDateRange.Items.Count - 1; 662 735 end; 663 736 664 737 procedure TfrmGraphs.FormClose(Sender: TObject; var Action: TCloseAction); 665 738 begin 739 if btnClose.Tag = 1 then 740 exit; 666 741 SetSize; 667 742 timHintPause.Enabled := false; … … 671 746 672 747 procedure TfrmGraphs.GetSize; 748 749 procedure SetWidth(aListView: TListView; v1, v2, v3, v4: integer); 750 begin 751 if v1 > 0 then aListView.Column[0].Width := v1; 752 if v2 > 0 then aListView.Column[1].Width := v2; 753 if v3 > 0 then aListView.Column[2].Width := v3; 754 if v4 > 0 then aListView.Column[3].Width := v4; 755 end; 756 757 procedure Layout(name, FR: string; v1, v2, v3, v4: integer); 758 begin // FR indicates Float or Report graph 759 if name = (FR + 'WIDTH') then 760 begin 761 if v1 > 0 then 762 begin 763 pnlItemsTop.Width := v1; 764 splItemsTopMoved(self); 765 end; 766 end 767 else if name = (FR + 'BOTTOM') then 768 begin 769 if v1 > 0 then 770 begin 771 chkDualViews.Checked := true; 772 chkDualViewsClick(self); 773 pnlBottom.Height := v1; 774 end; 775 end 776 else if name = (FR + 'COLUMN') then 777 SetWidth(lvwItemsTop, v1, v2, v3, v4) 778 else if name = (FR + 'BCOLUMN') then 779 SetWidth(lvwItemsBottom, v1, v2, v3, v4); 780 end; 781 782 673 783 var 674 784 i, v1, v2, v3, v4: integer; … … 697 807 else 698 808 begin 699 if v1 > 0 then Left := v1;700 if v2 > 0 then Top := v2;701 if v3 > 0 then Width := v3;809 if v1 > 0 then Left := v1; 810 if v2 > 0 then Top := v2; 811 if v3 > 0 then Width := v3; 702 812 if v4 > 0 then Height := v4; 703 813 end; 704 814 end 705 else if name = 'FWIDTH' then 706 begin 707 if v1 > 0 then 708 begin 709 pnlItemsTop.Width := v1; 710 splItemsTopMoved(self); 711 end; 712 end 713 else if name = 'FBOTTOM' then 714 begin 715 if v1 > 0 then 716 begin 717 chkDualViews.Checked := true; 718 chkDualViewsClick(self); 719 pnlBottom.Height := v1; 720 end; 721 end 722 else if name = 'FCOLUMN' then 723 begin 724 if v1 > 0 then lvwItemsTop.Column[0].Width := v1; 725 if v2 > 0 then lvwItemsTop.Column[1].Width := v2; 726 if v3 > 0 then lvwItemsTop.Column[2].Width := v3; 727 if v4 > 0 then lvwItemsTop.Column[3].Width := v4; 728 end 729 else if name = 'FBCOLUMN' then 730 begin 731 if v1 > 0 then lvwItemsBottom.Column[0].Width := v1; 732 if v2 > 0 then lvwItemsBottom.Column[1].Width := v2; 733 if v3 > 0 then lvwItemsBottom.Column[2].Width := v3; 734 if v4 > 0 then lvwItemsBottom.Column[3].Width := v4; 735 end; 815 else 816 Layout(name, 'F', v1, v2, v3, v4); 736 817 end 737 818 else 738 begin 739 if name = 'RWIDTH' then 740 begin 741 if v1 > 0 then 742 begin 743 pnlItemsTop.Width := v1; 744 splItemsTopMoved(self); 745 end; 746 end 747 else if name = 'RBOTTOM' then 748 begin 749 if v1 > 0 then 750 begin 751 pnlBottom.Height := v1; 752 splGraphsMoved(splGraphs); 753 end; 754 end 755 else if name = 'RCOLUMN' then 756 begin 757 if v1 > 0 then lvwItemsTop.Column[0].Width := v1; 758 if v2 > 0 then lvwItemsTop.Column[1].Width := v2; 759 if v3 > 0 then lvwItemsTop.Column[2].Width := v3; 760 if v4 > 0 then lvwItemsTop.Column[3].Width := v4; 761 end 762 else if name = 'RBCOLUMN' then 763 begin 764 if v1 > 0 then lvwItemsBottom.Column[0].Width := v1; 765 if v2 > 0 then lvwItemsBottom.Column[1].Width := v2; 766 if v3 > 0 then lvwItemsBottom.Column[2].Width := v3; 767 if v4 > 0 then lvwItemsBottom.Column[3].Width := v4; 768 end; 769 end; 819 Layout(name, 'R', v1, v2, v3, v4); 770 820 end; 771 821 end; … … 774 824 775 825 procedure TfrmGraphs.SetSize; 776 var 777 name, v1, v2, v3, v4: string; 826 827 procedure GetWidth(aListView: TListView; var v1, v2, v3, v4: string); 828 begin 829 v1 := inttostr(aListView.Column[0].Width); 830 v2 := inttostr(aListView.Column[1].Width); 831 v3 := inttostr(aListView.Column[2].Width); 832 v4 := inttostr(aListView.Column[3].Width); 833 end; 834 835 procedure Layout(aList: TStrings; FR, v1, v2, v3, v4: string); 836 begin // FR indicates Float or Report graph 837 v1 := inttostr(splItemsTop.Left); 838 aList.Add(FR + 'WIDTH^' + v1); 839 if chkDualViews.Checked then 840 v1 := inttostr(pnlBottom.Height) 841 else 842 v1 := '0'; 843 aList.Add(FR + 'BOTTOM^' + v1); 844 GetWidth(lvwItemsTop, v1, v2, v3, v4); 845 aList.Add(FR + 'COLUMN^' + v1 + ',' + v2 + ',' + v3 + ',' + v4); 846 GetWidth(lvwItemsBottom, v1, v2, v3, v4); 847 aList.Add(FR + 'BCOLUMN^' + v1 + ',' + v2 + ',' + v3 + ',' + v4); 848 end; 849 850 851 var 852 v1, v2, v3, v4: string; 853 //values: array[0..3] of string; 778 854 aList: TStrings; 779 855 begin … … 781 857 if FGraphType = GRAPH_FLOAT then 782 858 begin 783 name := 'FBOUNDS';784 859 v1 := inttostr(Left); 785 860 v2 := inttostr(Top); … … 787 862 v4 := inttostr(Height); 788 863 if WindowState = wsMaximized then 789 aList.Add( name + '^0,0,0,0')864 aList.Add('FBOUNDS^0,0,0,0') 790 865 else 791 aList.Add(name + '^' + v1 +',' + v2 +',' + v3 +',' + v4); 792 name := 'FWIDTH'; 793 v1 := inttostr(splItemsTop.Left); 794 aList.Add(name + '^' + v1); 795 name := 'FBOTTOM'; 796 if chkDualViews.Checked then 797 v1 := inttostr(pnlBottom.Height) 798 else 799 v1 := '0'; 800 aList.Add(name + '^' + v1); 801 name := 'FCOLUMN'; 802 v1 := inttostr(lvwItemsTop.Column[0].Width); 803 v2 := inttostr(lvwItemsTop.Column[1].Width); 804 v3 := inttostr(lvwItemsTop.Column[2].Width); 805 v4 := inttostr(lvwItemsTop.Column[3].Width); 806 aList.Add(name + '^' + v1 +',' + v2 +',' + v3 +',' + v4); 807 name := 'FBCOLUMN'; 808 v1 := inttostr(lvwItemsBottom.Column[0].Width); 809 v2 := inttostr(lvwItemsBottom.Column[1].Width); 810 v3 := inttostr(lvwItemsBottom.Column[2].Width); 811 v4 := inttostr(lvwItemsBottom.Column[3].Width); 812 aList.Add(name + '^' + v1 +',' + v2 +',' + v3 +',' + v4); 866 aList.Add('FBOUNDS^' + v1 + ',' + v2 + ',' + v3 + ',' + v4); 867 Layout(aList, 'F', v1, v2, v3, v4); 813 868 end 814 869 else 815 begin 816 name := 'RWIDTH'; 817 v1 := inttostr(splItemsTop.Left); 818 aList.Add(name + '^' + v1); 819 name := 'RBOTTOM'; 820 if chkDualViews.Checked then 821 v1 := inttostr(pnlBottom.Height) 822 else 823 v1 := '0'; 824 aList.Add(name + '^' + v1); 825 name := 'RCOLUMN'; 826 v1 := inttostr(lvwItemsTop.Column[0].Width); 827 v2 := inttostr(lvwItemsTop.Column[1].Width); 828 v3 := inttostr(lvwItemsTop.Column[2].Width); 829 v4 := inttostr(lvwItemsTop.Column[3].Width); 830 aList.Add(name + '^' + v1 +',' + v2 +',' + v3 +',' + v4); 831 name := 'RBCOLUMN'; 832 v1 := inttostr(lvwItemsBottom.Column[0].Width); 833 v2 := inttostr(lvwItemsBottom.Column[1].Width); 834 v3 := inttostr(lvwItemsBottom.Column[2].Width); 835 v4 := inttostr(lvwItemsBottom.Column[3].Width); 836 aList.Add(name + '^' + v1 +',' + v2 +',' + v3 +',' + v4); 837 end; 870 Layout(aList, 'R', v1, v2, v3, v4); 838 871 rpcSetGraphSizing(aList); 839 872 FreeAndNil(aList); … … 857 890 PreSources: TStrings; 858 891 begin 892 Application.ProcessMessages; 859 893 okbutton := false; 860 894 conv := btnChangeSettings.Tag; … … 868 902 PreFixedDateRange := FixedDateRange; 869 903 MaxSelectMin := Max(Max(lvwItemsTop.SelCount, lvwItemsBottom.SelCount), 1); 904 DateRangeOutpatient := FGraphSetting.DateRangeOutpatient; 870 905 end; 871 906 PreSources := TStringList.Create; 872 PreSources.Assign(FSources);907 FastAssign(FSources, PreSources); 873 908 DialogGraphSettings(Font.Size, okbutton, FGraphSetting, FSources, conv, aSettings); 874 909 if not okbutton then exit; 875 if length(aSettings) > 0 then frmFrame.mnuToolsGraphing.Hint := aSettings;910 if length(aSettings) > 0 then SetCurrentSetting(aSettings); 876 911 btnChangeSettings.Tag := conv; 877 pnlInfo.Font.Size := lblViewsTop.Font.Size; 878 SetFontSize(lblViewsTop.Font.Size); 879 pnlInfo.Visible := conv > 0; 880 if conv > 0 then 881 begin 882 pnlInfo.Caption := TXT_WARNING; 883 pnlInfo.Color := COLOR_WARNING; 884 end; 912 pnlInfo.Font.Size := chkItemsTop.Font.Size; 913 SetFontSize(chkItemsTop.Font.Size); 914 InfoMessage(TXT_WARNING, COLOR_WARNING, (conv > 0)); 885 915 pnlHeader.Visible := pnlInfo.Visible; 886 916 StayOnTop; … … 892 922 begin 893 923 FSources[i] := Pieces(sourcetype, '^', 2, 4); 894 filetype := Piece(FSources[i], '^', 1); 895 lstItems.Items.AddStrings(rpcGetItems(filetype, Patient.DFN)); 896 needtoupdate := true; 924 if not FFastItems then 925 begin 926 filetype := Piece(FSources[i], '^', 1); 927 FastAddStrings(rpcGetItems(filetype, Patient.DFN), GtslItems); 928 needtoupdate := true; 929 end; 897 930 end; 898 931 if not needtoupdate then … … 921 954 if lvwItemsTop.SelCount = 0 then 922 955 begin 923 cboViewsTop.ItemIndex := -1; 924 cboViewsTop.Text := ''; 956 lstViewsTop.ItemIndex := -1; 925 957 end; 926 958 if lvwItemsBottom.SelCount = 0 then 927 959 begin 928 cboViewsBottom.ItemIndex := -1; 929 cboViewsBottom.Text := ''; 960 lstViewsBottom.ItemIndex := -1; 930 961 end; 931 962 end; … … 957 988 lvwItemsTop.Items.Clear; 958 989 lvwItemsBottom.Items.Clear; 990 lvwItemsTop.Items.BeginUpdate; 991 lvwItemsBottom.Items.BeginUpdate; 959 992 lvwItemsTop.SortType := stNone; // if Sorting during load then potential error 960 993 lvwItemsBottom.SortType := stNone; // if Sorting during load then potential error … … 988 1021 FItemsSortedBottom := false; 989 1022 end; 1023 lvwItemsTop.Items.EndUpdate; 1024 lvwItemsBottom.Items.EndUpdate; 990 1025 end; 991 1026 992 1027 procedure TfrmGraphs.FilterListView(oldestdate, newestdate: double); 993 1028 var 994 colnum,i: integer;1029 i: integer; 995 1030 lastdate: double; 996 aProfile,filename, filenum, itemnum: string;1031 filename, filenum, itemnum: string; 997 1032 begin 998 1033 lvwItemsTop.Scroll(-BIG_NUMBER, -BIG_NUMBER); //faster to set scroll at top … … 1004 1039 if (cboDateRange.ItemIndex > 0) and (cboDateRange.ItemIndex < 9) then 1005 1040 begin 1006 with lvwItemsTop do1007 1041 if TypeIsDisplayed('405') then 1008 1042 DateRangeItems(oldestdate, newestdate, '405'); // does not matter for all results ****************** … … 1015 1049 if TypeIsDisplayed('9999911') then 1016 1050 DateRangeItems(oldestdate, newestdate, '9999911'); 1017 for i := 0 to lstItems.Items.Count - 1 do1018 begin 1019 filenum := UpperCase(Piece( lstItems.Items[i], '^', 1));1051 for i := 0 to GtslItems.Count - 1 do 1052 begin 1053 filenum := UpperCase(Piece(GtslItems[i], '^', 1)); 1020 1054 if filenum <> '405' then 1021 1055 if filenum <> '52' then 1022 1023 1024 1025 1026 1027 lastdate := strtofloatdef(Piece(lstItems.Items[i], '^', 6), -BIG_NUMBER);1028 1029 1030 1031 itemnum := Piece(lstItems.Items[i], '^', 2);1032 UpdateView(filename, filenum, itemnum, lstItems.Items[i], lvwItemsTop);1033 1034 1056 if filenum <> '55' then 1057 if filenum <> '55NVA' then 1058 if filenum <> '9999911' then 1059 if TypeIsDisplayed(filenum) then 1060 begin 1061 lastdate := strtofloatdef(Piece(GtslItems[i], '^', 6), -BIG_NUMBER); 1062 if (lastdate > oldestdate) and (lastdate < newestdate) then 1063 begin 1064 filename := FileNameX(filenum); 1065 itemnum := Piece(GtslItems[i], '^', 2); 1066 UpdateView(filename, filenum, itemnum, GtslItems[i], lvwItemsTop); 1067 end; 1068 end; 1035 1069 end; 1036 1070 end 1037 1071 else if (cboDateRange.ItemIndex = 0) or (cboDateRange.ItemIndex > 8) then 1038 1072 begin // manual date range selection 1039 for i := 0 to lstAllTypes.Items.Count - 1 do1040 begin 1041 filenum := Piece( lstAllTypes.Items[i], '^', 1);1073 for i := 0 to GtslAllTypes.Count - 1 do 1074 begin 1075 filenum := Piece(GtslAllTypes[i], '^', 1); 1042 1076 if TypeIsDisplayed(filenum) then 1043 1077 begin … … 1047 1081 end; 1048 1082 lvwItemsBottom.Items.Assign(lvwItemsTop.Items); 1083 SortListView; 1084 end; 1085 1086 procedure TfrmGraphs.SortListView; 1087 var 1088 colnum: integer; 1089 aProfile: string; 1090 begin 1049 1091 lvwItemsTop.SortType := stBoth; 1050 1092 lvwItemsBottom.SortType := stBoth; … … 1069 1111 FItemsSortedBottom := false; 1070 1112 end; 1071 if cboViewsTop.ItemIndex > 1 then // sort by view1072 begin 1073 aProfile := cboViewsTop.Items[cboViewsTop.ItemIndex];1113 if lstViewsTop.ItemIndex > 1 then // sort by view 1114 begin 1115 aProfile := lstViewsTop.Items[lstViewsTop.ItemIndex]; 1074 1116 AssignProfile(aProfile, 'top'); 1075 1117 if not FItemsSortedTop then lvwItemsTopColumnClick(lvwItemsTop, lvwItemsTop.Column[colnum]); … … 1078 1120 FItemsSortedTop := false; 1079 1121 end; 1080 if cboViewsBottom.ItemIndex > 1 then // sort by view1081 begin 1082 aProfile := cboViewsBottom.Items[cboViewsBottom.ItemIndex];1122 if lstViewsBottom.ItemIndex > 1 then // sort by view 1123 begin 1124 aProfile := lstViewsBottom.Items[lstViewsBottom.ItemIndex]; 1083 1125 AssignProfile(aProfile, 'bottom'); 1084 1126 if not FItemsSortedBottom then lvwItemsBottomColumnClick(lvwItemsBottom, lvwItemsBottom.Column[colnum]); … … 1094 1136 filename, itemnum, itemstuff, mitemnum: string; 1095 1137 begin 1096 FastAssign(rpcDateItem(oldestdate, newestdate, filenum, Patient.DFN), lstScratchTemp.Items);1138 FastAssign(rpcDateItem(oldestdate, newestdate, filenum, Patient.DFN), GtslScratchTemp); 1097 1139 filename := FileNameX(filenum); 1140 lvwItemsTop.Items.BeginUpdate; 1098 1141 with lvwItemsTop do 1099 for i := 0 to lstScratchTemp.Items.Count - 1 do1100 begin 1101 itemstuff := lstScratchTemp.Items[i];1142 for i := 0 to GtslScratchTemp.Count - 1 do 1143 begin 1144 itemstuff := GtslScratchTemp[i]; 1102 1145 itemnum := UpperCase(Piece(itemstuff, '^',2)); 1103 for j := 0 to lstItems.Items.Count - 1 do1104 if (filenum = UpperCase(Piece( lstItems.Items[j], '^', 1))) and (itemnum = UpperCase(Piece(lstItems.Items[j], '^', 2))) then1105 UpdateView(filename, filenum, itemnum, lstItems.Items[j], lvwItemsTop);1146 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); 1106 1149 if filenum = '63' then 1107 for j := 0 to lstMultiSpec.Items.Count - 1 do1108 begin 1109 mitemnum := Piece( lstMultiSpec.Items[j], '^', 2);1150 for j := 0 to GtslMultiSpec.Count - 1 do 1151 begin 1152 mitemnum := Piece(GtslMultiSpec[j], '^', 2); 1110 1153 if itemnum = Piece(mitemnum, '.', 1) then 1111 1154 if DateRangeMultiItems(oldestdate, newestdate, mitemnum) then //******** check specific date range 1112 UpdateView(filename, filenum, mitemnum, lstMultiSpec.Items[j], lvwItemsTop); 1113 end; 1114 end; 1155 UpdateView(filename, filenum, mitemnum, GtslMultiSpec[j], lvwItemsTop); 1156 end; 1157 end; 1158 lvwItemsTop.Items.EndUpdate; 1115 1159 end; 1116 1160 … … 1134 1178 aGraphItem := TGraphItem.Create; 1135 1179 aGraphItem.Values := itemqualifier; 1136 SubItems.AddObject(' info object', aGraphItem);1180 SubItems.AddObject('', aGraphItem); 1137 1181 end; 1138 1182 end; … … 1146 1190 Result := false; 1147 1191 fileitem := '63^' + aMultiItem; 1148 for i := 0 to lstData.Items.Count - 1 do1149 if Pieces( lstData.Items[i], '^', 1, 2) = fileitem then1150 begin 1151 checkdate := strtofloatdef(Piece( lstData.Items[i], '^', 3), BIG_NUMBER);1192 for i := 0 to GtslData.Count - 1 do 1193 if Pieces(GtslData[i], '^', 1, 2) = fileitem then 1194 begin 1195 checkdate := strtofloatdef(Piece(GtslData[i], '^', 3), BIG_NUMBER); 1152 1196 if checkdate <> BIG_NUMBER then 1153 1197 if checkdate >= aOldDate then … … 1166 1210 begin 1167 1211 Result := ''; 1168 with lstAllTypes do 1169 for i := 0 to Items.Count - 1 do 1170 begin 1171 typestring := Items[i]; 1212 for i := 0 to GtslAllTypes.Count - 1 do 1213 begin 1214 typestring := GtslAllTypes[i]; 1172 1215 if Piece(typestring, '^', 1) = filenum then 1173 1216 begin 1174 Result := Piece( Items[i], '^', 2);1217 Result := Piece(GtslAllTypes[i], '^', 2); 1175 1218 break; 1176 1219 end; … … 1178 1221 if Result = '' then 1179 1222 begin 1180 with lstAllTypes do 1181 for i := 0 to Items.Count - 1 do 1182 begin 1183 typestring := Items[i]; 1223 for i := 0 to GtslAllTypes.Count - 1 do 1224 begin 1225 typestring := GtslAllTypes[i]; 1184 1226 if lowercase(Piece(typestring, '^', 1)) = filenum then 1185 1227 begin 1186 Result := Piece(Items[i], '^', 2); 1228 Result := Piece(GtslAllTypes[i], '^', 2); 1229 break; 1230 end; 1231 end; 1232 end; 1233 end; 1234 1235 function TfrmGraphs.TypeString(filenum: string): string; 1236 var 1237 i: integer; 1238 typestring: string; 1239 begin 1240 Result := ''; 1241 for i := 0 to GtslAllTypes.Count - 1 do 1242 begin 1243 typestring := GtslAllTypes[i]; 1244 if Piece(typestring, '^', 1) = filenum then 1245 begin 1246 Result := typestring; 1247 break; 1248 end; 1249 end; 1250 if Result = '' then 1251 begin 1252 for i := 0 to GtslAllTypes.Count - 1 do 1253 begin 1254 typestring := GtslAllTypes[i]; 1255 if lowercase(Piece(typestring, '^', 1)) = filenum then 1256 begin 1257 Result := typestring; 1187 1258 break; 1188 1259 end; … … 1199 1270 filenum := UpperCase(filenum); 1200 1271 itemnum := UpperCase(itemnum); 1201 with lstItems do 1202 for i := 0 to Items.Count - 1 do 1203 begin 1204 typestring := UpperCase(Items[i]); 1272 for i := 0 to GtslItems.Count - 1 do 1273 begin 1274 typestring := UpperCase(GtslItems[i]); 1205 1275 if (Piece(typestring, '^', 1) = filenum) and 1206 1276 (Piece(typestring, '^', 2) = itemnum) then … … 1212 1282 end; 1213 1283 1284 procedure TfrmGraphs.Switch; 1285 var 1286 aList: TStringList; 1287 begin 1288 if FFastTrack then 1289 exit; 1290 aList := TStringList.Create; 1291 if not FFastItems then 1292 begin 1293 rpcFastItems(Patient.DFN, aList, FFastItems); // *** 1294 if FFastItems then 1295 begin 1296 FastAssign(aList, GtslItems); 1297 rpcFastData(Patient.DFN, aList, FFastData); // *** 1298 if FFastData then 1299 begin 1300 FastAssign(aList, GtslData); 1301 aList.Clear; 1302 rpcFastLabs(Patient.DFN, aList, FFastLabs); // *** 1303 if FFastLabs then 1304 FastLab(aList); 1305 FastAssign(GtslData, GtslCheck); 1306 end; 1307 end; 1308 end; 1309 if not FFastTrack then 1310 FFastTrack := FFastItems and FFastData and FFastLabs; 1311 if not FFastTrack then 1312 begin 1313 FFastItems := false; 1314 FFastData := false; 1315 FFastLabs := false; 1316 end; 1317 FreeAndNil(aList); 1318 end; 1319 1214 1320 procedure TfrmGraphs.InitialData; 1215 1321 var 1216 i , total: integer;1322 i: integer; 1217 1323 dfntype, listline: string; 1218 1324 begin 1219 total := pnlData.ControlCount - 1; 1220 with pnlData do 1221 for i:= 0 to total do 1222 if Controls[i] is TListBox then 1223 if Controls[i] <> lstAllTypes then 1224 if Controls[i] <> lstTestSpec then 1225 (Controls[i] as TListBox).Items.Clear; 1325 Application.ProcessMessages; 1326 FMTimestamp := floattostr(FMNow); 1226 1327 SourcesDefault; 1227 FSources.Assign(FSourcesDefault); 1228 btnChangeSettings.Tag :=0; 1229 btnClose.Tag := 0; 1230 cboViewsTop.Tag :=0; 1231 chartDatelineTop.Tag :=0; 1232 lvwItemsBottom.Tag :=0; 1233 lvwItemsTop.Tag :=0; 1234 pnlFooter.Parent.Tag :=0; 1235 pnlItemsBottom.Tag :=0; 1236 pnlItemsTop.Tag :=0; 1237 pnlTop.Tag :=0; 1238 scrlTop.Tag :=0; 1239 splGraphs.Tag :=0; 1240 cboViewsTop.ItemIndex := -1; 1241 cboViewsBottom.ItemIndex := -1; 1242 FastAssign(rpcGetTypes(Patient.DFN, false), lstTypes.Items); 1243 for i := 0 to lstTypes.Items.Count - 1 do 1244 begin 1245 dfntype := UpperCase(Piece(lstTypes.Items[i], '^', 1)); 1246 if TypeIsLoaded(dfntype) then 1247 lstItems.Items.AddStrings(rpcGetItems(dfntype, Patient.DFN)); 1248 listline := lstTypes.Items[i]; 1328 FastAssign(FSourcesDefault, FSources); 1329 for i := 0 to GtslTypes.Count - 1 do 1330 begin 1331 listline := GtslTypes[i]; 1249 1332 dfntype := UpperCase(Piece(listline, '^', 1)); 1250 1333 SetPiece(listline, '^', 1, dfntype); 1251 lstTypes.Items[i] := listline; 1252 end; 1253 lstTypes.Hint := Patient.DFN; // use to check for patient change 1254 FMTimestamp := floattostr(FMNow); 1334 GtslTypes[i] := listline; 1335 end; 1336 btnChangeSettings.Tag := 0; 1337 btnClose.Tag := 0; 1338 lstViewsTop.Tag := 0; 1339 chartDatelineTop.Tag := 0; 1340 lvwItemsBottom.Tag := 0; 1341 lvwItemsTop.Tag := 0; 1342 pnlFooter.Parent.Tag := 0; 1343 pnlItemsBottom.Tag := 0; 1344 pnlItemsTop.Tag := 0; 1345 pnlTop.Tag := 0; 1346 scrlTop.Tag := 0; 1347 splGraphs.Tag := 0; 1348 lstViewsTop.ItemIndex := -1; 1349 lstViewsBottom.ItemIndex := -1; 1350 frmGraphData.pnlData.Hint := Patient.DFN; // use to check for patient change 1255 1351 FPrevEvent := ''; 1256 1352 FWarning := false; 1257 1353 FFirstSwitch := true; 1354 Application.ProcessMessages; 1355 FFastData := false; 1356 FFastItems := false; 1357 FFastLabs := false; 1358 FFastTrack := false; 1359 if GraphTurboOn then 1360 Switch; 1361 //if not FFastItems then 1362 if GtslItems.Count = 0 then 1363 begin 1364 for i := 0 to GtslTypes.Count - 1 do 1365 begin 1366 dfntype := Piece(GtslTypes[i], '^', 1); 1367 if TypeIsLoaded(dfntype) then 1368 FastAddStrings(rpcGetItems(dfntype, Patient.DFN), GtslItems); 1369 end; 1370 end; 1371 end; 1372 1373 procedure TfrmGraphs.FastLab(aList: TStringList); 1374 var 1375 lastone: boolean; 1376 i: integer; 1377 aType, aItem, aItemName, typeitem, oldtypeitem, listline: string; 1378 begin 1379 if aList.Count < 1 then 1380 exit; 1381 GtslScratchLab.Clear; 1382 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; 1389 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; 1403 end; 1258 1404 end; 1259 1405 … … 1263 1409 filetype: string; 1264 1410 begin 1411 if FFastItems then 1412 begin 1413 Result := true; 1414 exit; 1415 end; 1265 1416 Result := false; 1266 1417 for i := 0 to FSources.Count - 1 do … … 1300 1451 with cboDateRange do 1301 1452 begin 1302 defaults := Items[Items.Count - 1]; 1453 defaults := Items[Items.Count - 1]; // ***** CHANGE TO DEFAULTS 1303 1454 defaultrange := Piece(defaults, '^', 1); 1304 1455 //get report views - param 1 and param 2 … … 1307 1458 //check if default range already exists 1308 1459 if strtointdef(defaultrange, BIG_NUMBER) = BIG_NUMBER then 1309 ItemIndex := Items.Count - 1; 1460 ItemIndex := Items.Count - 1 1461 else 1462 ItemIndex := strtoint(defaultrange); 1310 1463 end; 1311 1464 end; … … 1332 1485 filename := FileNameX(itemtype); 1333 1486 FSources.Add(itemtype + '^' + filename + '^' + displayed); 1334 lstItems.Items.AddStrings(rpcGetItems(itemtype, Patient.DFN));1487 FastAddStrings(rpcGetItems(itemtype, Patient.DFN), GtslItems); 1335 1488 end; 1336 1489 end; … … 1356 1509 procedure TfrmGraphs.DisplayData(aSection: string); 1357 1510 var 1511 i: integer; 1512 astring: string; 1358 1513 aChart: TChart; 1359 1514 aCheckBox: TCheckBox; … … 1361 1516 aDateline, aRightPad: TPanel; 1362 1517 aScrollBox: TScrollBox; 1518 aMemo: TMemo; 1363 1519 begin 1364 1520 FHintStop := true; 1365 SetFontSize( lblViewsTop.Font.Size);1521 SetFontSize(chkItemsTop.Font.Size); 1366 1522 if aSection = 'top' then 1367 1523 begin 1368 aListView := lvwItemsTop; 1369 aOtherListView := lvwItemsBottom; 1370 aDateline := pnlDatelineTop; 1371 aRightPad := pnlTopRightPad; 1372 aScrollBox := scrlTop; 1373 aChart := chartDatelineTop; 1374 aCheckBox := chkItemsTop; 1524 aListView := lvwItemsTop; aOtherListView := lvwItemsBottom; 1525 aDateline := pnlDatelineTop; aChart := chartDatelineTop; 1526 aRightPad := pnlTopRightPad; aScrollBox := scrlTop; 1527 aCheckBox := chkItemsTop; aMemo := memTop; 1375 1528 end 1376 1529 else 1377 1530 begin 1378 aListView := lvwItemsBottom; 1379 aOtherListView := lvwItemsTop; 1380 aDateline := pnlDatelineBottom; 1381 aRightPad := pnlBottomRightPad; 1382 aScrollBox := scrlBottom; 1383 aChart := chartDatelineBottom; 1384 aCheckBox := chkItemsBottom; 1531 aListView := lvwItemsBottom; aOtherListView := lvwItemsTop; 1532 aDateline := pnlDatelineBottom; aChart := chartDatelineBottom; 1533 aRightPad := pnlBottomRightPad; aScrollBox := scrlBottom; 1534 aCheckBox := chkItemsBottom; aMemo := memBottom; 1385 1535 end; 1386 1536 if aListView.SelCount < 1 then … … 1389 1539 begin 1390 1540 FFirstClick := true; 1391 while aScrollBox.ControlCount > 0 do 1392 aScrollBox.Controls[0].Free; 1541 while aScrollBox.ControlCount > 0 do aScrollBox.Controls[0].Free; 1393 1542 exit; 1394 1543 end; … … 1399 1548 if aOtherListView.SelCount > 0 then 1400 1549 if aOtherListView = lvwItemsTop then 1401 ItemsClick(self, lvwItemsTop, lvwItemsBottom, chkItemsTop, cboViewsTop, lstSelCopyTop, 'top')1550 ItemsClick(self, lvwItemsTop, lvwItemsBottom, chkItemsTop, lstViewsTop, GtslSelCopyTop, 'top') 1402 1551 else 1403 ItemsClick(self, lvwItemsBottom, lvwItemsTop, chkItemsBottom, cboViewsBottom, lstSelCopyBottom, 'bottom');1552 ItemsClick(self, lvwItemsBottom, lvwItemsTop, chkItemsBottom, lstViewsBottom, GtslSelCopyBottom, 'bottom'); 1404 1553 exit; 1405 1554 end; 1406 1555 aScrollBox.VertScrollBar.Visible := false; 1407 1556 aScrollBox.HorzScrollBar.Visible := false; 1557 amemo.Visible := false; 1408 1558 aChart.RemoveAllSeries; // this would leave bottom dateline visible on date change 1409 //chartDatelineTop.RemoveAllSeries; // do both 1410 //chartDatelineBottom.RemoveAllSeries; // do both 1411 lstNonNumeric.Items.Clear; 1559 for i := GtslNonNum.Count - 1 downto 0 do 1560 begin 1561 astring := GtslNonNum[i]; 1562 if Piece(astring, '^', 7) = aSection then 1563 GtslNonNum.Delete(i); 1564 end; 1412 1565 if aCheckBox.Checked then 1413 1566 MakeSeparate(aScrollBox, aListView, aRightPad, aSection) 1414 1567 else 1415 begin 1416 MakeTogether(aScrollBox, aListView, aRightPad, aSection); 1417 end; 1568 MakeTogetherMaybe(aScrollBox, aListView, aRightPad, aSection); 1569 DisplayDataInfo(aScrollBox, aMemo); 1570 end; 1571 1572 procedure TfrmGraphs.DisplayDataInfo(aScrollBox: TScrollBox; aMemo: TMemo); 1573 begin 1418 1574 ChangeStyle; 1419 pnlInfo.Font.Size := lblViewsTop.Font.Size;1575 pnlInfo.Font.Size := chkItemsTop.Font.Size; 1420 1576 if ((lvwItemsTop.SelCount > MAX_ITEM_DISCLAIMER) and (not chkItemsTop.Checked)) 1421 1577 or ((lvwItemsBottom.SelCount > MAX_ITEM_DISCLAIMER) and (not chkItemsBottom.Checked)) then 1422 begin 1423 pnlInfo.Caption := TXT_DISCLAIMER; 1424 pnlInfo.Color := COLOR_WARNING; 1425 pnlInfo.Visible := true; 1426 end 1578 InfoMessage(TXT_DISCLAIMER, COLOR_WARNING, true) 1427 1579 else 1428 1580 pnlInfo.Visible := false; 1429 1581 if btnChangeSettings.Tag > 0 then 1430 begin 1431 pnlInfo.Caption := TXT_WARNING; 1432 pnlInfo.Color := COLOR_WARNING; 1433 pnlInfo.Visible := true; 1434 end; 1435 //if copy(pnlInfo.Caption, 1, 7) = 'Warning' then 1582 InfoMessage(TXT_WARNING, COLOR_WARNING, true); 1436 1583 if FWarning then 1437 1584 pnlInfo.Visible := true; … … 1439 1586 aScrollBox.VertScrollBar.Visible := true; 1440 1587 aScrollBox.HorzScrollBar.Visible := false; 1588 if (aScrollBox.ControlCount > FGraphSetting.MaxGraphs) 1589 or (aScrollBox.Height < FGraphSetting.MinGraphHeight) then 1590 aMemo.Visible:= true; 1441 1591 end; 1442 1592 … … 1512 1662 BigTime, SmallTime: TDateTime; 1513 1663 ChildControl: TControl; 1664 aChart: TChart; 1514 1665 begin 1515 1666 if not (Sender is TChart) then exit; 1667 aChart := (Sender as TChart); 1668 if Not Assigned(FGraphSetting) then Exit; 1669 1516 1670 if not FGraphSetting.VerticalZoom then 1517 1671 begin 1518 1672 padding := 0; //(FYMaxValue - FYMinValue) * ((100 - ZOOM_PERCENT) * 0.01); 1519 (Sender as TChart).LeftAxis.Maximum := BIG_NUMBER; // avoid min>max error1520 (Sender as TChart).LeftAxis.Minimum := -BIG_NUMBER;1521 (Sender as TChart).LeftAxis.Maximum := FYMaxValue + padding; //padding 0?1522 (Sender as TChart).LeftAxis.Minimum := FYMinValue - padding; //padding 0?1523 end; 1524 SmallTime := (Sender as TChart).BottomAxis.Minimum;1525 BigTime := (Sender as TChart).BottomAxis.Maximum;1673 aChart.LeftAxis.Maximum := BIG_NUMBER; // avoid min>max error 1674 aChart.LeftAxis.Minimum := -BIG_NUMBER; 1675 aChart.LeftAxis.Maximum := FYMaxValue + padding; //padding 0? 1676 aChart.LeftAxis.Minimum := FYMinValue - padding; //padding 0? 1677 end; 1678 SmallTime := aChart.BottomAxis.Minimum; 1679 BigTime := aChart.BottomAxis.Maximum; 1526 1680 if BigTime < SmallTime then BigTime := SmallTime; // avoid min>max error 1527 1681 for i := 0 to scrlTop.ControlCount - 1 do … … 1537 1691 end; 1538 1692 SizeDates(chartDatelineBottom, SmallTime, BigTime); 1539 if FMouseDown and (Sender as TChart).Zoomed then1693 if FMouseDown and aChart.Zoomed then 1540 1694 begin 1541 1695 datehx := FloatToStr(SmallTime) + '^' + FloatToStr(BigTime); 1542 lstZoomHistory.Items.Add(datehx);1696 GtslZoomHistoryFloat.Add(datehx); 1543 1697 mnuPopGraphZoomBack.Enabled := true; 1544 1698 FMouseDown := false; … … 1553 1707 BigTime, SmallTime: TDateTime; 1554 1708 ChildControl: TControl; 1709 aChart: TChart; 1555 1710 begin 1556 1711 if not (Sender is TChart) then exit; 1712 aChart:= (Sender as TChart); 1557 1713 FRetainZoom := false; 1558 1714 mnuPopGraphZoomBack.Enabled := false; 1559 lstZoomHistory.Items.Clear;1715 GtslZoomHistoryFloat.Clear; 1560 1716 if not FGraphSetting.VerticalZoom then 1561 1717 begin 1562 1718 padding := 0; //(FYMaxValue - FYMinValue) * ((100 - ZOOM_PERCENT) * 0.01); 1563 (Sender as TChart).LeftAxis.Maximum := BIG_NUMBER; // avoid min>max error1564 (Sender as TChart).LeftAxis.Minimum := -BIG_NUMBER;1565 (Sender as TChart).LeftAxis.Maximum := FYMaxValue + padding; //padding 0?1566 (Sender as TChart).LeftAxis.Minimum := FYMinValue - padding; //padding 0?1567 end; 1568 SmallTime := (Sender as TChart).BottomAxis.Minimum;1569 BigTime := (Sender as TChart).BottomAxis.Maximum;1719 aChart.LeftAxis.Maximum := BIG_NUMBER; // avoid min>max error 1720 aChart.LeftAxis.Minimum := -BIG_NUMBER; 1721 aChart.LeftAxis.Maximum := FYMaxValue + padding; //padding 0? 1722 aChart.LeftAxis.Minimum := FYMinValue - padding; //padding 0? 1723 end; 1724 SmallTime := aChart.BottomAxis.Minimum; 1725 BigTime := aChart.BottomAxis.Maximum; 1570 1726 if BigTime < SmallTime then BigTime := SmallTime; // avoid min>max error 1571 1727 for i := 0 to scrlTop.ControlCount - 1 do … … 1584 1740 begin 1585 1741 FMouseDown := false; 1586 pnlInfo.Caption := ''; 1587 pnlInfo.Color := COLOR_INFO; 1588 pnlInfo.Visible := false; 1742 InfoMessage('', COLOR_INFO, false); 1589 1743 pnlHeader.Visible := false; 1590 1744 end; … … 1594 1748 var 1595 1749 datediff, yeardiff: integer; 1750 pad: double; 1596 1751 begin 1597 1752 with aChart.BottomAxis do … … 1617 1772 end; 1618 1773 end; 1774 GraphFooter(aChart, datediff, aSmallTime); 1775 pad := (aBigTime - aSmallTime) * 0.07; 1776 SeriesForLabels(aChart, 'serNonNumBottom', pad); 1777 SeriesForLabels(aChart, 'serNonNumTop', pad); 1778 if length(aChart.Hint) > 0 then SeriesForLabels(aChart, 'serComments', pad); 1779 end; 1780 1781 procedure TfrmGraphs.SeriesForLabels(aChart: TChart; aID: string; pad: double); 1782 var 1783 i: integer; 1784 aPointSeries: TPointSeries; 1785 max, min: double; 1786 begin 1787 for i := 0 to aChart.SeriesCount - 1 do 1788 begin 1789 if aChart.Series[i].Identifier = aID then 1790 begin 1791 aPointSeries := (aChart.Series[i] as TPointSeries); 1792 aPointSeries.Clear; 1793 if aID = 'serNonNumBottom' then 1794 begin 1795 min := aChart.LeftAxis.Minimum; 1796 if min > aChart.MinYValue(aChart.LeftAxis) then 1797 min := aChart.MinYValue(aChart.LeftAxis); 1798 if min < 0 then min := 0; 1799 aPointSeries.AddXY(aChart.BottomAxis.Minimum, min, '', clTeeColor) ; 1800 end 1801 else if aID = 'serNonNumTop' then 1802 begin 1803 max := aChart.LeftAxis.Maximum; 1804 if max < aChart.MaxYValue(aChart.LeftAxis) then 1805 max := aChart.MaxYValue(aChart.LeftAxis); 1806 aPointSeries.AddXY(aChart.BottomAxis.Minimum, max, '', clTeeColor) ; 1807 end 1808 else if aID = 'serComments' then 1809 begin 1810 min := aChart.MinYValue(aChart.LeftAxis); 1811 if aChart.SeriesCount = 2 then // only 1 series (besides comment) 1812 if aChart.Series[0].Count = 1 then // only 1 numeric 1813 min := min - 1; // force comment label to bottom 1814 if min < 0 then min := 0; 1815 aPointSeries.AddXY((aChart.BottomAxis.Maximum - pad), min, '', clTeeColor) ; 1816 end; 1817 aPointSeries.Marks.Visible := true; 1818 break; 1819 end; 1820 end; 1821 end; 1822 1823 procedure TfrmGraphs.GraphFooter(aChart: TChart; datediff: integer; aDate: TDateTime); 1824 begin 1619 1825 if datediff < 1 then 1620 1826 begin … … 1622 1828 begin 1623 1829 aChart.Foot.Text.Clear; 1624 aChart.Foot.Text.Insert(0, FormatDateTime('mmm d, yyyy', a SmallTime));1830 aChart.Foot.Text.Insert(0, FormatDateTime('mmm d, yyyy', aDate)); 1625 1831 aChart.Foot.Font.Color := clBtnText; 1626 1832 aChart.Foot.Visible := true; … … 1634 1840 TListView; aPadPanel: TPanel; section: string); 1635 1841 var 1636 acnt, bcnt, displayheight, displaynum, gcnt, graphtype, i, j, lcnt, ncnt, pcnt, vcnt: integer; 1637 aTitle, checkdata, filetype, high, low, specimen, specnum, typeitem, units: string; 1638 newchart: TChart; 1639 aGraphItem: TGraphItem; 1842 displayheight, displaynum, i: integer; 1640 1843 begin 1641 1844 FNonNumerics := false; … … 1654 1857 chartDatelineBottom.OnMouseMove := nil; 1655 1858 end; 1656 pcnt := 0; gcnt := 0; vcnt := 0; lcnt := 0; ncnt := 0; bcnt := 0; acnt := 0; 1657 for j := 0 to aListView.Items.Count - 1 do 1658 if aListView.Items[j].Selected then 1659 begin 1660 aGraphItem := TGraphItem(aListView.Items.Item[j].SubItems.Objects[3]); 1661 filetype := UpperCase(Piece(aGraphItem.Values, '^', 1)); 1662 typeitem := UpperCase(Piece(aGraphItem.Values, '^', 2)); 1663 graphtype := GraphTypeNum(filetype); //*****strtointdef(Piece(aListBox.Items[j], '^', 2), 1); 1664 if (filetype = '63') and (lstData.Items.Count > 0) then 1665 begin 1666 checkdata := ''; 1667 for i := 0 to lstData.Items.Count - 1 do 1668 begin 1669 checkdata := lstData.Items[i]; 1670 if (Piece(checkdata, '^', 1) = '63') and (Piece(checkdata, '^', 2) = typeitem) then 1671 break; 1672 end; 1673 specnum := Piece(checkdata, '^', 7); 1674 specimen := Piece(checkdata, '^', 8); 1675 RefUnits(typeitem, specnum, low, high, units); 1676 units := LowerCase(units); 1677 if units = '' then units := ' '; 1678 end 1679 else 1680 begin 1681 specimen := ''; low := ''; high := ''; units := ''; 1682 end; 1683 aTitle := filetype + '^' + typeitem + '^' + aListView.Items[j].Caption + '^' + 1684 specimen + '^' + low + '^' + high + '^' + units; 1685 newchart := TChart.Create(self); 1686 with newchart do 1687 begin 1688 Parent := aScrollBox; 1689 View3D := false; 1690 height := 170; 1691 Align := alBottom; 1692 Align := alTop; 1693 AllowPanning := pmNone; 1694 Legend.LegendStyle := lsSeries; 1695 Legend.ShadowSize := 1; 1696 Legend.Color := clCream; 1697 Legend.VertMargin := 0; 1698 Legend.Alignment := laTop; 1699 Legend.Visible := true; 1700 Gradient.EndColor := clGradientActiveCaption; 1701 //SetPiece(aTitle, '^', 3, 'zzzz: ' + Piece(aTitle, '^', 3)); // test prefix 1702 if (graphtype = 1) and (btnChangeSettings.Tag = 1) then 1703 LeftAxis.Title.Caption := 'StdDev' 1704 else if (graphtype = 1) and (btnChangeSettings.Tag = 2) then 1705 begin 1706 LeftAxis.Title.Caption := '1/' + units; 1707 SetPiece(aTitle, '^', 3, 'Inverse ' + Piece(aTitle, '^', 3)); 1708 end 1709 else 1710 LeftAxis.Title.Caption := units; 1711 if graphtype <> 1 then 1712 begin 1713 LeftAxis.Visible := false; 1714 MarginLeft := round((50 / (pnlScrollTopBase.Width + 1)) * 100); // ************* marginleft is a % 1715 end; 1716 BottomAxis.ExactDateTime := true; 1717 BottomAxis.Increment := DateTimeStep[dtOneMinute]; 1718 HideDates(newchart); 1719 BevelOuter := bvNone; 1720 OnZoom := ChartOnZoom; 1721 OnUndoZoom := ChartOnUndoZoom; 1722 OnClickSeries := chartBaseClickSeries; 1723 OnClickLegend := chartBaseClickLegend; 1724 OnDblClick := mnuPopGraphDetailsClick; 1725 OnMouseDown := chartBaseMouseDown; 1726 if FGraphSetting.Hints then //***** 1727 OnMouseMove := chartBaseMouseMove 1728 else 1729 OnMouseMove := nil; 1730 end; 1731 splGraphs.Tag := 1; // show ref ranges 1732 if graphtype = 4 then graphtype := 2; // change points to be bars 1733 case graphtype of 1734 1: MakeLineSeries(newchart, aTitle, filetype, lcnt, ncnt, false); 1735 2: MakeBarSeries(newchart, aTitle, filetype, bcnt); 1736 3: MakeVisitGanttSeries(newchart, aTitle, filetype, vcnt); 1737 4: MakePointSeries(newchart, aTitle, filetype, pcnt); 1738 5: MakeArrowSeries(newchart, aTitle, filetype, acnt); 1739 6: MakeGanttSeries(newchart, aTitle, filetype, gcnt); 1740 7: MakeAGanttSeries(newchart, aTitle, filetype, gcnt); 1741 8: MakeManyGanttSeries(newchart, aTitle, filetype, gcnt); 1742 9: MakeWeightedArrowSeries(newchart, aTitle, filetype, acnt); 1743 10: MakeWeightedGanttSeries(newchart, aTitle, filetype, gcnt); 1744 end; 1745 end; 1859 MakeSeparateItems(aScrollBox, aListView, section); 1746 1860 if section = 'top' then 1747 1861 begin … … 1773 1887 Controls[i].height := displayheight; 1774 1888 end; 1775 if (FGraphSetting.HighTime = FGraphSetting.LowTime)1776 or (lcnt = 1) or (pcnt = 1) or (bcnt = 1) or (vcnt = 1) then1777 begin1778 FGraphSetting.HighTime := FGraphSetting.HighTime + 1;1779 FGraphSetting.LowTime := FGraphSetting.LowTime - 1;1780 end;1781 1889 AdjustTimeframe; 1782 1890 if chartDatelineTop.Visible then chartDatelineTop.ZoomPercent(ZOOM_PERCENT); … … 1787 1895 end; 1788 1896 1897 function TfrmGraphs.TitleInfo(filetype, typeitem, caption: string): string; 1898 var 1899 i: integer; 1900 checkdata, high, low, specimen, specnum, units: string; 1901 begin 1902 if (filetype = '63') and (GtslData.Count > 0) then 1903 begin 1904 checkdata := ''; 1905 for i := 0 to GtslData.Count - 1 do 1906 begin 1907 checkdata := GtslData[i]; 1908 if (Piece(checkdata, '^', 1) = '63') and (Piece(checkdata, '^', 2) = typeitem) then 1909 break; 1910 end; 1911 specnum := Piece(checkdata, '^', 7); 1912 specimen := Piece(checkdata, '^', 8); 1913 RefUnits(typeitem, specnum, low, high, units); 1914 units := LowerCase(units); 1915 if units = '' then units := ' '; 1916 end 1917 else 1918 begin 1919 specimen := ''; low := ''; high := ''; units := ''; 1920 end; 1921 Result := filetype + '^' + typeitem + '^' + caption + '^' + 1922 specimen + '^' + low + '^' + high + '^' + units + '^'; 1923 end; 1924 1925 procedure TfrmGraphs.MakeSeparateItems(aScrollBox: TScrollBox; aListView: TListView; section: string); 1926 var 1927 bcnt, gcnt, graphtype, lcnt, ncnt, pcnt, vcnt: integer; 1928 aTitle, filetype, typeitem: string; 1929 newchart: TChart; 1930 aGraphItem: TGraphItem; 1931 aListItem: TListItem; 1932 begin 1933 pcnt := 0; gcnt := 0; vcnt := 0; lcnt := 0; ncnt := 0; bcnt := 0; 1934 aListItem := aListView.Selected; 1935 while aListItem <> nil do 1936 begin 1937 aGraphItem := TGraphItem(aListItem.SubItems.Objects[3]); 1938 filetype := UpperCase(Piece(aGraphItem.Values, '^', 1)); 1939 typeitem := UpperCase(Piece(aGraphItem.Values, '^', 2)); 1940 graphtype := GraphTypeNum(filetype); //*****strtointdef(Piece(aListBox.Items[j], '^', 2), 1); 1941 aTitle := TitleInfo(filetype, typeitem, aListItem.Caption); 1942 newchart := TChart.Create(self); 1943 newchart.Tag := GtslNonNum.Count; 1944 MakeChart(newchart, aScrollBox); 1945 with newchart do 1946 begin 1947 Height := 170; 1948 Align := alBottom; 1949 Align := alTop; 1950 Tag := aListItem.Index; 1951 //SetPiece(aTitle, '^', 3, 'zzzz: ' + Piece(aTitle, '^', 3)); // test prefix 1952 if (graphtype = 1) and (btnChangeSettings.Tag = 1) then 1953 LeftAxis.Title.Caption := 'StdDev' 1954 else if (graphtype = 1) and (btnChangeSettings.Tag = 2) then 1955 begin 1956 LeftAxis.Title.Caption := '1/' + Piece(aTitle, '^', 7); 1957 SetPiece(aTitle, '^', 3, 'Inverse ' + Piece(aTitle, '^', 3)); 1958 end 1959 else 1960 LeftAxis.Title.Caption := Piece(aTitle, '^', 7); 1961 if graphtype <> 1 then 1962 begin 1963 LeftAxis.Visible := false; 1964 MarginLeft := PadLeftEvent(pnlScrollTopBase.Width); 1965 //MarginLeft := round((65 / (pnlScrollTopBase.Width + 1)) * 100); // ************* marginleft is a % 1966 end; 1967 end; 1968 splGraphs.Tag := 1; // show ref ranges 1969 if graphtype = 4 then graphtype := 2; // change points to be bars 1970 case graphtype of 1971 1: MakeLineSeries(newchart, aTitle, filetype, section, lcnt, ncnt, false); 1972 2: MakeBarSeries(newchart, aTitle, filetype, bcnt); 1973 3: MakeVisitGanttSeries(newchart, aTitle, filetype, vcnt); 1974 4: MakePointSeries(newchart, aTitle, filetype, pcnt); 1975 8: MakeGanttSeries(newchart, aTitle, filetype, gcnt); 1976 end; 1977 MakeOtherSeries(newchart); 1978 aListItem := aListView.GetNextItem(aListItem, sdAll, [isSelected]); 1979 end; 1980 if (FGraphSetting.HighTime = FGraphSetting.LowTime) 1981 or (lcnt = 1) or (pcnt = 1) or (bcnt = 1) or (vcnt = 1) then 1982 begin 1983 FGraphSetting.HighTime := FGraphSetting.HighTime + 1; 1984 FGraphSetting.LowTime := FGraphSetting.LowTime - 1; 1985 end; 1986 end; 1987 1988 function TfrmGraphs.PadLeftEvent(aWidth: integer): integer; 1989 begin 1990 if aWidth < 50 then 1991 Result := 10 1992 else if aWidth < 100 then 1993 Result := 36 1994 else if aWidth < 200 then 1995 Result := 28 1996 else if aWidth < 220 then 1997 Result := 24 1998 else if aWidth < 240 then 1999 Result := 23 2000 else if aWidth < 270 then 2001 Result := 21 2002 else if aWidth < 300 then 2003 Result := 18 2004 else if aWidth < 400 then 2005 Result := 14 2006 else if aWidth < 500 then 2007 Result := 11 2008 else if aWidth < 600 then 2009 Result := 10 2010 else if aWidth < 700 then 2011 Result := 9 2012 else if aWidth < 800 then 2013 Result := 8 2014 else if aWidth < 900 then 2015 Result := 7 2016 else if aWidth < 1000 then 2017 Result := 6 2018 else 2019 Result := 5; 2020 end; 2021 2022 function TfrmGraphs.PadLeftNonNumeric(aWidth: integer): integer; 2023 begin 2024 if aWidth < 50 then 2025 Result := 10 2026 else if aWidth < 100 then 2027 Result := 36 2028 else if aWidth < 200 then 2029 Result := 16 2030 else if aWidth < 220 then 2031 Result := 14 2032 else if aWidth < 240 then 2033 Result := 12 2034 else if aWidth < 270 then 2035 Result := 10 2036 else if aWidth < 300 then 2037 Result := 9 2038 else if aWidth < 400 then 2039 Result := 8 2040 else if aWidth < 500 then 2041 Result := 7 2042 else if aWidth < 600 then 2043 Result := 6 2044 else 2045 Result := 5; 2046 end; 2047 2048 procedure TfrmGraphs.MakeTogetherMaybe(aScrollBox: TScrollBox; aListView: 2049 TListView; aPadPanel: TPanel; section: string); 2050 var 2051 filetype: string; 2052 aGraphItem: TGraphItem; 2053 aListItem: TListItem; 2054 begin 2055 FNonNumerics := false; 2056 if section = 'top' then pnlItemsTop.Tag := 0 else pnlItemsBottom.Tag := 0; 2057 if aListView.SelCount = 1 then // one lab test - make separate 2058 begin 2059 aListItem := aListView.Selected; 2060 aGraphItem := TGraphItem(aListItem.SubItems.Objects[3]); 2061 filetype := UpperCase(Piece(aGraphItem.Values, '^', 1)); 2062 if (filetype = '63') or (filetype = '120.5') then 2063 begin 2064 MakeSeparate(aScrollBox, aListView, aPadPanel, section); 2065 exit; 2066 end; 2067 end; 2068 MakeTogether(aScrollBox, aListView, aPadPanel, section); 2069 end; 2070 1789 2071 procedure TfrmGraphs.MakeTogether(aScrollBox: TScrollBox; aListView: 1790 2072 TListView; aPadPanel: TPanel; section: string); 1791 2073 var 1792 anylines, nolines, onlylines, single labtest: boolean;1793 acnt, bcnt, cnt, gcnt, graphtype, i, j, lcnt, ncnt, pcnt, vcnt: integer;2074 anylines, nolines, onlylines, singlepoint: boolean; 2075 bcnt, gcnt, graphtype, lcnt, pcnt, vcnt: integer; 1794 2076 portion: double; 1795 aTitle, checkdata, filetype, high, low, specimen, specnum, typeitem, units: string;2077 filetype, typeitem: string; 1796 2078 newchart: TChart; 1797 2079 aGraphItem: TGraphItem; 1798 begin 1799 pcnt := 0; gcnt := 0; lcnt := 0; ncnt := 0; bcnt := 0; acnt := 0; 2080 aListItem: TListItem; 2081 begin 2082 pcnt := 0; gcnt := 0; lcnt := 0; bcnt := 0; vcnt := 0; 1800 2083 onlylines := true; 1801 2084 anylines := false; … … 1803 2086 FNonNumerics := false; 1804 2087 if section = 'top' then pnlItemsTop.Tag := 0 else pnlItemsBottom.Tag := 0; 1805 if FGraphSetting.Hints then //****** 1806 begin 1807 chartDatelineTop.OnMouseMove := chartBaseMouseMove; 1808 chartDatelineBottom.OnMouseMove := chartBaseMouseMove; 1809 end 1810 else 1811 begin 1812 chartDatelineTop.OnMouseMove := nil; 1813 chartDatelineBottom.OnMouseMove := nil; 1814 end; 1815 for j := 0 to aListView.Items.Count - 1 do 1816 if aListView.Items[j].Selected then 1817 begin 1818 aGraphItem := TGraphItem(aListView.Items.Item[j].SubItems.Objects[3]); 2088 aListItem := aListView.Selected; 2089 while aListItem <> nil do 2090 begin 2091 aGraphItem := TGraphItem(aListItem.SubItems.Objects[3]); 1819 2092 filetype := UpperCase(Piece(aGraphItem.Values, '^', 1)); 1820 2093 typeitem := UpperCase(Piece(aGraphItem.Values, '^', 2)); 1821 if aListView.SelCount = 1 then // one lab test - make separate1822 begin1823 if filetype = '63' then1824 begin1825 MakeSeparate(aScrollBox, aListView, aPadPanel, section);1826 exit;1827 end;1828 end;1829 2094 graphtype := GraphTypeNum(filetype); 1830 2095 case graphtype of … … 1833 2098 3: vcnt := vcnt + 1; 1834 2099 4: pcnt := pcnt + 1; 1835 5: acnt := acnt + 1;1836 6: gcnt := gcnt + 1;1837 7: gcnt := gcnt + 1;1838 2100 8: gcnt := gcnt + 1; 1839 9: acnt := acnt + 1;1840 2101 end; 1841 2102 if graphtype = 1 then … … 1846 2107 else 1847 2108 onlylines := false; 2109 aListItem := aListView.GetNextItem(aListItem, sdAll, [isSelected]); 1848 2110 end; 1849 2111 if section = 'top' then … … 1851 2113 else 1852 2114 chkItemsBottom.Checked := false; 1853 lstTempCheck.Items.Clear; 1854 while aScrollBox.ControlCount > 0 do 1855 aScrollBox.Controls[0].Free; 2115 GtslTempCheck.Clear; 2116 while aScrollBox.ControlCount > 0 do aScrollBox.Controls[0].Free; 1856 2117 newchart := TChart.Create(self); // whynot use base? 2118 MakeChart(newchart, aScrollBox); 1857 2119 with newchart do // if a single line graph do lab stuff (ref range, units) **************************************** 1858 2120 begin 1859 Parent := aScrollBox;1860 View3D := false;1861 Chart3DPercent := 10;1862 AllowPanning := pmNone;1863 2121 Align := alClient; 1864 Gradient.EndColor := clGradientActiveCaption;1865 Legend.LegendStyle := lsSeries;1866 Legend.ShadowSize := 1;1867 Legend.Color := clCream;1868 Legend.VertMargin := 0;1869 Legend.Alignment := laTop;1870 Legend.Visible := true;1871 2122 LeftAxis.Title.Caption := ' '; 1872 BottomAxis.ExactDateTime := true;1873 BottomAxis.Increment := DateTimeStep[dtOneMinute];1874 HideDates(newchart);1875 BevelOuter := bvNone;1876 OnZoom := ChartOnZoom;1877 OnUndoZoom := ChartOnUndoZoom;1878 OnClickSeries := chartBaseClickSeries;1879 OnClickLegend := chartBaseClickLegend;1880 OnDblClick := mnuPopGraphDetailsClick;1881 OnMouseDown := chartBaseMouseDown;1882 if FGraphSetting.Hints then //******1883 OnMouseMove := chartBaseMouseMove1884 else1885 OnMouseMove := nil;1886 Visible := false;1887 2123 end; 1888 2124 aPadPanel.Visible := true; 1889 portion := PortionSize(lcnt, pcnt, gcnt, vcnt, bcnt , acnt);2125 portion := PortionSize(lcnt, pcnt, gcnt, vcnt, bcnt); 1890 2126 if section = 'top' then 1891 2127 SizeTogether(onlylines, nolines, anylines, scrlTop, newchart, … … 1897 2133 else splGraphs.Tag := 0; 1898 2134 1899 if nolines then 1900 begin 1901 pcnt := 0; gcnt := 0; vcnt := 0; bcnt := 0; acnt := 0; 1902 for j := 0 to aListView.Items.Count - 1 do 1903 if aListView.Items[j].Selected then 1904 begin 1905 aGraphItem := TGraphItem(aListView.Items.Item[j].SubItems.Objects[3]); 1906 filetype := Piece(aGraphItem.Values, '^', 1); 1907 typeitem := Piece(aGraphItem.Values, '^', 2); 1908 aTitle := filetype + '^' + typeitem + '^' + aListView.Items[j].Caption + '^'; 1909 graphtype := GraphTypeNum(filetype); 1910 if section = 'top' then 1911 MakeDateline(section, aTitle, filetype, chartDatelineTop, graphtype, bcnt, pcnt, gcnt, vcnt, acnt) 1912 else 1913 MakeDateline(section, aTitle, filetype, chartDatelineBottom, graphtype, bcnt, pcnt, gcnt, vcnt, acnt); 1914 end; 1915 if section = 'top' then 1916 begin 1917 scrlTop.Align := alTop; 1918 scrlTop.Height := 1; //pnlScrollTopBase.Height div 4; 1919 pnlDatelineTop.Align := alClient; 1920 pnlDatelineTop.Visible := true; 1921 end 1922 else 1923 begin 1924 scrlBottom.Align := alTop; 1925 scrlBottom.Height := 1; //pnlScrollBottomBase.Height div 4; 1926 pnlDatelineBottom.Align := alClient; 1927 pnlDatelineBottom.Visible := true; 1928 end; 1929 end 1930 else if onlylines then 1931 begin 1932 lcnt := 0; 1933 for j := 0 to aListView.Items.Count - 1 do 1934 if aListView.Items[j].Selected then 1935 begin 1936 aGraphItem := TGraphItem(aListView.Items.Item[j].SubItems.Objects[3]); 1937 filetype := Piece(aGraphItem.Values, '^', 1); 1938 typeitem := Piece(aGraphItem.Values, '^', 2); 1939 if (filetype = '63') and (lstData.Items.Count > 0) then //*********** 1940 begin 1941 checkdata := ''; 1942 for i := 0 to lstData.Items.Count - 1 do 1943 begin 1944 checkdata := lstData.Items[i]; 1945 if (Piece(checkdata, '^', 1) = '63') and (Piece(checkdata, '^', 2) = typeitem) then 1946 break; 1947 end; 1948 specnum := Piece(checkdata, '^', 7); 1949 specimen := Piece(checkdata, '^', 8); 1950 RefUnits(typeitem, specnum, low, high, units); 1951 units := LowerCase(units); 1952 if units = '' then units := ' '; 1953 end 1954 else 1955 begin 1956 specimen := ''; low := ''; high := ''; units := ''; 1957 end; 1958 aTitle := filetype + '^' + typeitem + '^' + aListView.Items[j].Caption + '^' + 1959 specimen + '^' + low + '^' + high + '^' + units; 1960 MakeLineSeries(newchart, aTitle, filetype, lcnt, ncnt, true) 1961 end; 1962 if section = 'top' then 1963 begin 1964 pnlDatelineTop.Align := alBottom; 1965 pnlDatelineTop.Height := 5; 1966 scrlTop.Align := alClient; 1967 pnlDatelineTop.Visible := false; 1968 end 1969 else 1970 begin 1971 pnlDatelineBottom.Align := alBottom; 1972 pnlDatelineBottom.Height := 5; 1973 scrlBottom.Align := alClient; 1974 pnlDatelineBottom.Visible := false; 1975 end; 1976 with newchart do 1977 begin 1978 if btnChangeSettings.Tag = 1 then 1979 LeftAxis.Title.Caption := 'StdDev'; 1980 Visible := true; 1981 end; 1982 end 1983 else if anylines then 1984 begin 1985 pcnt := 0; gcnt := 0; vcnt := 0; lcnt := 0; ncnt := 0; bcnt := 0; acnt := 0; 1986 cnt := 0; 1987 for j := 0 to aListView.Items.Count - 1 do 1988 if aListView.Items[j].Selected then 1989 begin 1990 aGraphItem := TGraphItem(aListView.Items.Item[j].SubItems.Objects[3]); 1991 filetype := Piece(aGraphItem.Values, '^', 1); 1992 if filetype = '120.5' then 1993 begin 1994 cnt := BIG_NUMBER; 1995 break; 1996 end; 1997 if filetype = '63' then 1998 cnt := cnt + 1; 1999 if cnt > 1 then 2000 break; 2001 end; 2002 singlelabtest := cnt = 1; 2003 for j := 0 to aListView.Items.Count - 1 do 2004 if aListView.Items[j].Selected then 2005 begin 2006 aGraphItem := TGraphItem(aListView.Items.Item[j].SubItems.Objects[3]); 2007 filetype := Piece(aGraphItem.Values, '^', 1); 2008 typeitem := Piece(aGraphItem.Values, '^', 2); 2009 if (filetype = '63') and (lstData.Items.Count > 0) then //*********** 2010 begin 2011 checkdata := ''; 2012 for i := 0 to lstData.Items.Count - 1 do 2013 begin 2014 checkdata := lstData.Items[i]; 2015 if (Piece(checkdata, '^', 1) = '63') and (Piece(checkdata, '^', 2) = typeitem) then 2016 break; 2017 end; 2018 specnum := Piece(checkdata, '^', 7); 2019 specimen := Piece(checkdata, '^', 8); 2020 RefUnits(typeitem, specnum, low, high, units); 2021 units := LowerCase(units); 2022 if units = '' then units := ' '; 2023 end 2024 else 2025 begin 2026 specimen := ''; low := ''; high := ''; units := ''; 2027 end; 2028 aTitle := filetype + '^' + typeitem + '^' + aListView.Items[j].Caption + '^' + 2029 specimen + '^' + low + '^' + high + '^' + units; 2030 graphtype := GraphTypeNum(filetype); 2031 if graphtype = 1 then 2032 begin 2033 if btnChangeSettings.Tag = 1 then 2034 newchart.LeftAxis.Title.Caption := 'StdDev' 2035 else 2036 newchart.LeftAxis.Title.Caption := units; 2037 if singlelabtest then 2038 splGraphs.Tag := 1 2039 else 2040 splGraphs.Tag := 0; 2041 MakeLineSeries(newchart, aTitle, filetype, lcnt, ncnt, true); 2042 end 2043 else if section = 'top' then 2044 MakeDateline(section, aTitle, filetype, chartDatelineTop, graphtype, bcnt, pcnt, gcnt, vcnt, acnt) 2045 else 2046 MakeDateline(section, aTitle, filetype, chartDatelineBottom, graphtype, bcnt, pcnt, gcnt, vcnt, acnt); 2047 end; 2048 if section = 'top' then 2049 begin 2050 scrlTop.Align := alTop; 2051 pnlDatelineTop.Align := alBottom; 2052 pnlDatelineTop.Height := pnlScrollTopBase.Height div 2; 2053 scrlTop.Align := alClient; 2054 pnlDatelineTop.Visible := true; 2055 end 2056 else 2057 begin 2058 scrlBottom.Align := alTop; 2059 pnlDatelineBottom.Align := alBottom; 2060 pnlDatelineBottom.Height := pnlScrollBottomBase.Height div 2; 2061 scrlBottom.Align := alClient; 2062 pnlDatelineBottom.Visible := true; 2063 end; 2064 with newchart do 2065 begin 2066 if btnChangeSettings.Tag = 1 then 2067 LeftAxis.Title.Caption := 'StdDev'; 2068 Visible := true; 2069 end; 2070 end; 2135 if nolines then MakeTogetherNoLines(aListView, section) 2136 else if onlylines then MakeTogetherOnlyLines(aListView, section, newchart) 2137 else if anylines then MakeTogetherAnyLines(aListView, section, newchart); 2138 MakeOtherSeries(newchart); 2139 2140 singlepoint := (lcnt = 1) or (pcnt = 1) or (bcnt = 1) or (vcnt = 1); 2141 GraphBoundry(singlepoint); 2142 if FNonNumerics then 2143 if section = 'top' then pnlItemsTop.Tag := 1 2144 else pnlItemsBottom.Tag := 1; 2145 end; 2146 2147 procedure TfrmGraphs.GraphBoundry(singlepoint: boolean); 2148 begin 2071 2149 if (FGraphSetting.HighTime = FGraphSetting.LowTime) 2072 or (lcnt = 1) or (pcnt = 1) or (bcnt = 1) or (acnt = 1) or (vcnt = 1)then2150 or singlepoint then 2073 2151 begin 2074 2152 FGraphSetting.HighTime := FGraphSetting.HighTime + 1; … … 2079 2157 chartDatelineBottom.LeftAxis.Maximum := chartDatelineBottom.LeftAxis.Maximum + 0.5; 2080 2158 end; 2159 if FGraphSetting.Hints then 2160 begin 2161 chartDatelineTop.OnMouseMove := chartBaseMouseMove; 2162 chartDatelineBottom.OnMouseMove := chartBaseMouseMove; 2163 end 2164 else 2165 begin 2166 chartDatelineTop.OnMouseMove := nil; 2167 chartDatelineBottom.OnMouseMove := nil; 2168 end; 2081 2169 AdjustTimeframe; 2082 2170 if chartDatelineTop.Visible then chartDatelineTop.ZoomPercent(ZOOM_PERCENT); 2083 2171 if chartDatelineBottom.Visible then chartDatelineBottom.ZoomPercent(ZOOM_PERCENT); 2084 if FNonNumerics then 2085 if section = 'top' then pnlItemsTop.Tag := 1 2086 else pnlItemsBottom.Tag := 1; 2087 end; 2088 2089 function TfrmGraphs.PortionSize(lcnt, pcnt, gcnt, vcnt, bcnt, acnt: integer): double; 2172 end; 2173 2174 procedure TfrmGraphs.MakeTogetherNoLines(aListView: TListView; section: string); 2175 var 2176 bcnt, gcnt, graphtype, pcnt, vcnt: integer; 2177 aTitle, filetype, typeitem: string; 2178 aGraphItem: TGraphItem; 2179 aListItem: TListItem; 2180 begin 2181 pcnt := 0; gcnt := 0; vcnt := 0; bcnt := 0; 2182 aListItem := aListView.Selected; 2183 while aListItem <> nil do 2184 begin 2185 aGraphItem := TGraphItem(aListItem.SubItems.Objects[3]); 2186 filetype := Piece(aGraphItem.Values, '^', 1); 2187 typeitem := Piece(aGraphItem.Values, '^', 2); 2188 aTitle := filetype + '^' + typeitem + '^' + aListItem.Caption + '^'; 2189 graphtype := GraphTypeNum(filetype); 2190 if section = 'top' then 2191 MakeDateline(section, aTitle, filetype, chartDatelineTop, graphtype, bcnt, pcnt, gcnt, vcnt) 2192 else 2193 MakeDateline(section, aTitle, filetype, chartDatelineBottom, graphtype, bcnt, pcnt, gcnt, vcnt); 2194 aListItem := aListView.GetNextItem(aListItem, sdAll, [isSelected]); 2195 end; 2196 if section = 'top' then 2197 begin 2198 scrlTop.Align := alTop; 2199 scrlTop.Height := 1; //pnlScrollTopBase.Height div 4; 2200 pnlDatelineTop.Align := alClient; 2201 pnlDatelineTop.Visible := true; 2202 end 2203 else 2204 begin 2205 scrlBottom.Align := alTop; 2206 scrlBottom.Height := 1; //pnlScrollBottomBase.Height div 4; 2207 pnlDatelineBottom.Align := alClient; 2208 pnlDatelineBottom.Visible := true; 2209 end; 2210 end; 2211 2212 procedure TfrmGraphs.MakeTogetherOnlyLines(aListView: TListView; section: string; aChart: TChart); 2213 var 2214 lcnt, ncnt: integer; 2215 aTitle, filetype, typeitem: string; 2216 aGraphItem: TGraphItem; 2217 aListItem: TListItem; 2218 begin 2219 lcnt := 0; 2220 aListItem := aListView.Selected; 2221 while aListItem <> nil do 2222 begin 2223 aGraphItem := TGraphItem(aListItem.SubItems.Objects[3]); 2224 filetype := Piece(aGraphItem.Values, '^', 1); 2225 typeitem := Piece(aGraphItem.Values, '^', 2); 2226 aTitle := TitleInfo(filetype, typeitem, aListItem.Caption); 2227 MakeLineSeries(aChart, aTitle, filetype, section, lcnt, ncnt, true); 2228 if FDisplayFreeText = true then DisplayFreeText(aChart); 2229 aListItem := aListView.GetNextItem(aListItem, sdAll, [isSelected]); 2230 end; 2231 if section = 'top' then 2232 begin 2233 pnlDatelineTop.Align := alBottom; 2234 pnlDatelineTop.Height := 5; 2235 scrlTop.Align := alClient; 2236 pnlDatelineTop.Visible := false; 2237 end 2238 else 2239 begin 2240 pnlDatelineBottom.Align := alBottom; 2241 pnlDatelineBottom.Height := 5; 2242 scrlBottom.Align := alClient; 2243 pnlDatelineBottom.Visible := false; 2244 end; 2245 with aChart do 2246 begin 2247 if btnChangeSettings.Tag = 1 then 2248 LeftAxis.Title.Caption := 'StdDev'; 2249 Visible := true; 2250 end; 2251 end; 2252 2253 procedure TfrmGraphs.MakeTogetherAnyLines(aListView: TListView; section: string; aChart: TChart); 2254 var 2255 singletest: boolean; 2256 bcnt, gcnt, graphtype, lcnt, ncnt, pcnt, vcnt: integer; 2257 aTitle, filetype, typeitem: string; 2258 aGraphItem: TGraphItem; 2259 aListItem: TListItem; 2260 begin 2261 singletest := SingleLabTest(aListView); 2262 pcnt := 0; gcnt := 0; vcnt := 0; lcnt := 0; bcnt := 0; 2263 aListItem := aListView.Selected; 2264 while aListItem <> nil do 2265 begin 2266 aGraphItem := TGraphItem(aListItem.SubItems.Objects[3]); 2267 filetype := Piece(aGraphItem.Values, '^', 1); 2268 typeitem := Piece(aGraphItem.Values, '^', 2); 2269 aTitle := TitleInfo(filetype, typeitem, aListItem.Caption); 2270 graphtype := GraphTypeNum(filetype); 2271 if graphtype = 1 then 2272 begin 2273 if btnChangeSettings.Tag = 1 then 2274 aChart.LeftAxis.Title.Caption := 'StdDev' 2275 else 2276 aChart.LeftAxis.Title.Caption := Piece(aTitle, '^', 7); 2277 if singletest then 2278 splGraphs.Tag := 1 2279 else 2280 splGraphs.Tag := 0; 2281 MakeLineSeries(aChart, aTitle, filetype, section, lcnt, ncnt, true); 2282 if FDisplayFreeText = true then DisplayFreeText(aChart); 2283 end 2284 else if section = 'top' then 2285 MakeDateline(section, aTitle, filetype, chartDatelineTop, graphtype, bcnt, pcnt, gcnt, vcnt) 2286 else 2287 MakeDateline(section, aTitle, filetype, chartDatelineBottom, graphtype, bcnt, pcnt, gcnt, vcnt); 2288 aListItem := aListView.GetNextItem(aListItem, sdAll, [isSelected]); 2289 end; 2290 if section = 'top' then 2291 begin 2292 scrlTop.Align := alTop; 2293 pnlDatelineTop.Align := alBottom; 2294 pnlDatelineTop.Height := pnlScrollTopBase.Height div 2; 2295 scrlTop.Align := alClient; 2296 pnlDatelineTop.Visible := true; 2297 end 2298 else 2299 begin 2300 scrlBottom.Align := alTop; 2301 pnlDatelineBottom.Align := alBottom; 2302 pnlDatelineBottom.Height := pnlScrollBottomBase.Height div 2; 2303 scrlBottom.Align := alClient; 2304 pnlDatelineBottom.Visible := true; 2305 end; 2306 with aChart do 2307 begin 2308 if btnChangeSettings.Tag = 1 then 2309 LeftAxis.Title.Caption := 'StdDev'; 2310 Visible := true; 2311 end; 2312 end; 2313 2314 function TfrmGraphs.SingleLabTest(aListView: TListView): boolean; 2315 var 2316 cnt: integer; 2317 filetype: string; 2318 aGraphItem: TGraphItem; 2319 aListItem: TListItem; 2320 begin 2321 cnt := 0; 2322 aListItem := aListView.Selected; 2323 while aListItem <> nil do 2324 begin 2325 aGraphItem := TGraphItem(aListItem.SubItems.Objects[3]); 2326 filetype := Piece(aGraphItem.Values, '^', 1); 2327 if filetype = '120.5' then 2328 begin 2329 cnt := BIG_NUMBER; 2330 break; 2331 end; 2332 if filetype = '63' then 2333 cnt := cnt + 1; 2334 if cnt > 1 then 2335 break; 2336 aListItem := aListView.GetNextItem(aListItem, sdAll, [isSelected]); 2337 end; 2338 Result := (cnt = 1); 2339 end; 2340 2341 procedure TfrmGraphs.MakeChart(aChart: TChart; aScrollBox: TScrollBox); 2342 begin 2343 with aChart do 2344 begin 2345 Parent := aScrollBox; 2346 View3D := false; 2347 Chart3DPercent := 10; 2348 AllowPanning := pmNone; 2349 Gradient.EndColor := clGradientActiveCaption; 2350 Gradient.StartColor := clWindow; 2351 Legend.LegendStyle := lsSeries; 2352 Legend.ShadowSize := 1; 2353 Legend.Color := clCream; 2354 Legend.VertMargin := 0; 2355 Legend.Alignment := laTop; 2356 Legend.Visible := true; 2357 BottomAxis.ExactDateTime := true; 2358 BottomAxis.Increment := DateTimeStep[dtOneMinute]; 2359 HideDates(aChart); 2360 BevelOuter := bvNone; 2361 OnZoom := ChartOnZoom; 2362 OnUndoZoom := ChartOnUndoZoom; 2363 OnClickSeries := chartBaseClickSeries; 2364 OnClickLegend := chartBaseClickLegend; 2365 OnDblClick := mnuPopGraphDetailsClick; 2366 OnMouseDown := chartBaseMouseDown; 2367 OnMouseUp := chartBaseMouseUp; 2368 if FGraphSetting.Hints then 2369 OnMouseMove := chartBaseMouseMove 2370 else 2371 OnMouseMove := nil; 2372 end; 2373 end; 2374 2375 procedure TfrmGraphs.MakeSeriesInfo(aChart: TChart; aSeries: TChartSeries; aTitle, aFileType: string; aSerCnt: integer); 2376 begin 2377 with aSeries do 2378 begin 2379 Active := true; 2380 ParentChart := aChart; 2381 Title := Piece(aTitle, '^', 3); 2382 GetData(aTitle); 2383 Identifier := aFileType; 2384 SeriesColor := NextColor(aSerCnt); 2385 ColorEachPoint := false; 2386 ShowInLegend := true; 2387 Marks.Style := smsLabel; 2388 Marks.BackColor := clInfoBk; 2389 Marks.Frame.Visible := true; 2390 Marks.Visible := false; 2391 OnGetMarkText := serDatelineTop.OnGetMarkText; 2392 XValues.DateTime := True; 2393 GetHorizAxis.ExactDateTime := True; 2394 GetHorizAxis.Increment := DateTimeStep[dtOneMinute]; 2395 end; 2396 end; 2397 2398 procedure TfrmGraphs.MakeSeriesPoint(aChart: TChart; aPointSeries: TPointSeries); 2399 begin 2400 with aPointSeries do 2401 begin 2402 Active := true; 2403 ParentChart := aChart; 2404 Title := ''; 2405 Identifier := ''; 2406 SeriesColor := aChart.Color; 2407 ColorEachPoint := false; 2408 ShowInLegend := false; 2409 Marks.Style := smsLabel; 2410 Marks.BackColor := clInfoBk; 2411 Marks.Frame.Visible := true; 2412 Marks.Visible := false; 2413 OnGetMarkText := serDatelineTop.OnGetMarkText; 2414 XValues.DateTime := true; 2415 Pointer.Visible := true; 2416 Pointer.InflateMargins := true; 2417 Pointer.Style := psSmallDot; 2418 Pointer.Pen.Visible := true; 2419 end; 2420 end; 2421 2422 procedure TfrmGraphs.MakeSeriesRef(aChart: TChart; aTest, aRef: TLineSeries; aTitle, aValue: string; aDate: double); 2423 var 2424 value: double; 2425 begin 2426 with aRef do 2427 begin 2428 Active := true; 2429 ParentChart := aChart; 2430 XValues.DateTime := True; 2431 Pointer.Visible := false; 2432 Pointer.InflateMargins := true; 2433 OnGetMarkText := serDatelineTop.OnGetMarkText; 2434 ColorEachPoint := false; 2435 Title := aTitle + aValue; 2436 Pointer.Style := psCircle; 2437 SeriesColor := clTeeColor; //aTest.SeriesColor; // clBtnShadow; // 2438 Marks.Visible := false; 2439 LinePen.Visible := true; 2440 LinePen.Width := 1; 2441 LinePen.Style := psDash; //does not show when width <> 1 2442 end; 2443 value := strtofloatdef(aValue, -BIG_NUMBER); 2444 if value <> -BIG_NUMBER then 2445 begin 2446 aRef.AddXY(IncDay(FGraphSetting.LowTime, -1), value, '', clTeeColor); 2447 aRef.AddXY(IncDay(FGraphSetting.HighTime, 1), value, '', clTeeColor); 2448 BorderValue(aDate, value); 2449 end; 2450 end; 2451 2452 procedure TfrmGraphs.MakeSeriesBP(aChart: TChart; aTest, aBP: TLineSeries; aFileType: string); 2453 begin 2454 with aBP do 2455 begin 2456 ParentChart := aChart; 2457 Title := 'Blood Pressure'; 2458 XValues.DateTime := true; 2459 Pointer.Style := aTest.Pointer.Style; 2460 ShowInLegend := false; //**** 2461 Identifier := aFileType; 2462 Pointer.Visible := true; 2463 Pointer.InflateMargins := true; 2464 ColorEachPoint := false; 2465 SeriesColor := aTest.SeriesColor; 2466 Marks.BackColor := clInfoBk; 2467 end; 2468 end; 2469 2470 procedure TfrmGraphs.MakeOtherSeries(aChart: TChart); 2471 begin 2472 if GtslNonNum.Count > 0 then 2473 begin 2474 MakeNonNumerics(aChart); 2475 if FDisplayFreeText = true then DisplayFreeText(aChart); 2476 end; 2477 if length(aChart.Hint) > 0 then 2478 begin 2479 MakeComments(aChart); 2480 end; 2481 end; 2482 2483 procedure TfrmGraphs.MakeComments(aChart: TChart); 2484 var 2485 serComment: TPointSeries; 2486 begin 2487 serComment := TPointSeries.Create(aChart); 2488 MakeSeriesPoint(aChart, serComment); 2489 with serComment do 2490 begin 2491 Identifier := 'serComments'; 2492 Title := TXT_COMMENTS; 2493 SeriesColor := clTeeColor; 2494 Marks.ArrowLength := -24; 2495 Marks.Visible := true; 2496 end; 2497 end; 2498 2499 procedure TfrmGraphs.MakeNonNumerics(aChart: TChart); 2500 var 2501 nonnumericonly, nonnumsection: boolean; 2502 i, bmax, tmax: integer; 2503 padvalue, highestvalue, lowestvalue, diffvalue: double; 2504 astring, listofseries, section: string; 2505 serBlank: TPointSeries; 2506 begin 2507 if aChart.Parent = scrlBottom then section := 'bottom' 2508 else section := 'top'; 2509 nonnumericonly := true; 2510 for i := 0 to aChart.SeriesCount - 1 do 2511 begin 2512 if (aChart.Series[i] is TLineSeries) then 2513 if aChart.Series[i].Count > 0 then 2514 begin 2515 nonnumericonly := false; 2516 break; 2517 end; 2518 end; 2519 PadNonNum(aChart, section, listofseries, bmax, tmax); 2520 if bmax = 0 then bmax := 1; 2521 if tmax = 0 then tmax := 1; 2522 if nonnumericonly then 2523 begin 2524 highestvalue := 1; 2525 lowestvalue := 0; 2526 end 2527 else 2528 begin 2529 highestvalue := aChart.MaxYValue(aChart.LeftAxis); 2530 lowestvalue := aChart.MinYValue(aChart.LeftAxis); 2531 end; 2532 diffvalue := highestvalue - lowestvalue; 2533 if diffvalue = 0 then 2534 padvalue := highestvalue / 2 2535 else 2536 padvalue := POINT_PADDING * diffvalue; 2537 highestvalue := highestvalue + (tmax * padvalue); 2538 lowestvalue := lowestvalue - (bmax * padvalue); 2539 if not (aChart.MinYValue(aChart.LeftAxis) < 0) then 2540 begin 2541 if highestvalue < 0 then highestvalue := 0; 2542 if lowestvalue < 0 then lowestvalue := 0; 2543 end; 2544 if lowestvalue > highestvalue then 2545 lowestvalue := highestvalue; 2546 aChart.LeftAxis.Maximum := highestvalue; 2547 aChart.LeftAxis.Minimum := lowestvalue; 2548 nonnumsection := false; 2549 for i := 0 to GtslNonNum.Count - 1 do 2550 begin 2551 astring := GtslNonNum[i]; 2552 if Piece(astring, '^', 7) = section then 2553 begin 2554 nonnumsection := true; 2555 break; 2556 end; 2557 end; 2558 if nonnumericonly and nonnumsection then 2559 begin 2560 serBlank := TPointSeries.Create(aChart); 2561 MakeSeriesPoint(aChart, serBlank); 2562 with serBlank do 2563 begin 2564 AddXY(aChart.BottomAxis.Minimum, highestvalue, '', aChart.Color); 2565 AddXY(aChart.BottomAxis.Minimum, lowestvalue, '', aChart.Color); 2566 end; 2567 aChart.LeftAxis.Labels := false; 2568 aChart.MarginLeft := PadLeftNonNumeric(pnlScrollTopBase.Width); 2569 //aChart.MarginLeft := round((40 / (pnlScrollTopBase.Width + 1)) * 100); // ************* marginleft is a % 2570 ChartOnUndoZoom(aChart); 2571 end; 2572 MakeNonNumSeries(aChart, padvalue, highestvalue, lowestvalue, listofseries, section); 2573 end; 2574 2575 procedure TfrmGraphs.MakeNonNumSeries(aChart: TChart; padvalue, highestvalue, lowestvalue: double; listofseries, section: string); 2576 var 2577 asernum, i, j, originalindex, linenum, offset: integer; 2578 nonvalue, graphvalue: double; 2579 avalue, line: string; 2580 adatetime: TDateTime; 2581 serPoint: TPointSeries; 2582 begin 2583 for j := 2 to BIG_NUMBER do 2584 begin 2585 line := Piece(listofseries, '^' , j); 2586 if length(line) < 1 then break; 2587 linenum := strtointdef(line, -BIG_NUMBER); 2588 if linenum = -BIG_NUMBER then break; 2589 serPoint := TPointSeries.Create(aChart); 2590 MakeSeriesPoint(aChart, serPoint); 2591 with serPoint do 2592 begin 2593 serPoint.Title := '(non-numeric)'; 2594 serPoint.Identifier := (aChart.Series[linenum] as TCustomSeries).Title; 2595 serPoint.Pointer.Style := (aChart.Series[linenum] as TCustomSeries).Pointer.Style; 2596 serPoint.SeriesColor := (aChart.Series[linenum] as TCustomSeries).SeriesColor; 2597 serPoint.Tag := BIG_NUMBER + linenum; 2598 end; 2599 for i := 0 to GtslNonNum.Count - 1 do 2600 begin 2601 avalue := GtslNonNum[i]; 2602 if Piece(avalue, '^', 7) = section then 2603 begin 2604 originalindex := strtointdef(Piece(avalue, '^', 3), 0); 2605 if originalindex = linenum then 2606 begin 2607 adatetime := strtofloatdef(Piece(avalue, '^', 1), -BIG_NUMBER); 2608 asernum := aChart.Tag; 2609 if adatetime = -BIG_NUMBER then break; 2610 if asernum = strtointdef(Piece(avalue, '^', 2), -BIG_NUMBER) then 2611 begin 2612 offset := strtointdef(Piece(avalue, '^', 5), 1); 2613 graphvalue := padvalue * offset; 2614 if copy(Piece(avalue, '^', 13), 0, 1) = '>' then 2615 nonvalue := highestvalue 2616 else 2617 nonvalue := lowestvalue; 2618 nonvalue := nonvalue + graphvalue; 2619 with serPoint do 2620 begin 2621 Hint := Piece(avalue, '^', 9); 2622 AddXY(adatetime, nonvalue, '', serPoint.SeriesColor); 2623 end; 2624 end; 2625 end; 2626 end; 2627 end; 2628 end; 2629 end; 2630 2631 procedure TfrmGraphs.StackNonNum(astring: string; var offset, bmax, tmax: integer; var blabelon, tlabelon: boolean); 2632 var 2633 inlist: boolean; 2634 i, lastnum, plusminus: integer; 2635 checktime, lasttime, avalue: string; 2636 begin 2637 inlist := false; 2638 offset := 0; 2639 checktime := Piece(astring, '^', 1); 2640 if length(checktime) < 4 then exit; 2641 if copy(Piece(astring, '^', 13), 0, 1) = '>' then 2642 begin 2643 checktime := checktime + ';t'; // top values will stack downwards 2644 plusminus := -1; 2645 tlabelon := true; 2646 end 2647 else 2648 begin 2649 checktime := checktime + ';b'; // bottom values will stack upwards 2650 plusminus := 1; 2651 blabelon := true; 2652 end; 2653 for i := 0 to GtslNonNumDates.Count - 1 do 2654 begin 2655 avalue := GtslNonNumDates[i]; 2656 lasttime := Piece(avalue, '^' , 1); 2657 if checktime = lasttime then 2658 begin 2659 lastnum := strtointdef(Piece(avalue, '^', 2), 0); 2660 offset := lastnum + 1; 2661 if offset > 0 then bmax := bmax + 1 2662 else tmax := tmax + 1; 2663 GtslNonNumDates[i] := checktime + '^' + inttostr(offset * plusminus); 2664 inlist := true; 2665 break; 2666 end; 2667 end; 2668 if not inlist then 2669 GtslNonNumDates.Add(checktime + '^' + inttostr(offset * plusminus)); 2670 end; 2671 2672 procedure TfrmGraphs.PadNonNum(aChart: TChart; aSection: string; var listofseries: string; var bmax, tmax: integer); 2673 var 2674 blabelon, tlabelon: boolean; 2675 i, offset: integer; 2676 charttag, newtime, lasttime, astring, avalue, newseries: string; 2677 serNonNumBottom, serNonNumTop: TPointSeries; 2678 begin 2679 GtslNonNumDates.Clear; 2680 listofseries := '^'; 2681 blabelon := false; tlabelon := false; 2682 bmax := 0; tmax := 0; 2683 lasttime := ''; 2684 for i := 0 to GtslNonNum.Count - 1 do 2685 begin 2686 astring := GtslNonNum[i]; 2687 if Piece(astring, '^', 7) = aSection then 2688 begin 2689 charttag := Piece(astring, '^', 2); 2690 if charttag = inttostr(aChart.Tag) then 2691 begin 2692 newtime := Piece(astring, '^', 1); 2693 avalue := Piece(astring, '^', 13); 2694 newseries := '^' + Piece(astring, '^', 3) + '^'; 2695 if Pos(newseries, listofseries) = 0 then 2696 listofseries := listofseries + Piece(astring, '^', 3) + '^'; 2697 StackNonNum(astring, offset, bmax, tmax, blabelon, tlabelon); 2698 SetPiece(astring, '^', 5, inttostr(offset)); 2699 GtslNonNum[i] := astring; 2700 end; 2701 end; 2702 end; 2703 if blabelon then 2704 begin 2705 serNonNumBottom := TPointSeries.Create(aChart); 2706 MakeSeriesPoint(aChart, serNonNumBottom); 2707 with serNonNumBottom do 2708 begin 2709 Identifier := 'serNonNumBottom'; 2710 Title := TXT_NONNUMERICS; 2711 Marks.ArrowLength := -11; 2712 Marks.Visible := true; 2713 end; 2714 end; 2715 if tlabelon then 2716 begin 2717 serNonNumTop := TPointSeries.Create(aChart); 2718 MakeSeriesPoint(aChart, serNonNumTop); 2719 with serNonNumTop do 2720 begin 2721 Identifier := 'serNonNumTop'; 2722 Title := TXT_NONNUMERICS; 2723 Marks.ArrowLength := -11; 2724 Marks.Visible := true; 2725 end; 2726 end; 2727 end; 2728 2729 function TfrmGraphs.PortionSize(lcnt, pcnt, gcnt, vcnt, bcnt: integer): double; 2090 2730 var 2091 2731 etotal, evalue, dvalue, value: double; 2092 2732 begin 2093 dvalue := (gcnt + vcnt + acnt);2733 dvalue := (gcnt + vcnt); 2094 2734 evalue := (pcnt + bcnt) / 2; 2095 2735 etotal := dvalue + evalue; … … 2108 2748 2109 2749 procedure TfrmGraphs.MakeDateline(section, aTitle, aFileType: string; aChart: TChart; graphtype: integer; 2110 var bcnt, pcnt, gcnt, vcnt , acnt: integer);2750 var bcnt, pcnt, gcnt, vcnt: integer); 2111 2751 begin 2112 2752 aChart.LeftAxis.Automatic := true; … … 2117 2757 3: MakeVisitGanttSeries(aChart, aTitle, aFileType, vcnt); 2118 2758 4: MakePointSeries(aChart, aTitle, aFileType, pcnt); 2119 5: MakeArrowSeries(aChart, aTitle, aFileType, acnt); 2120 6: MakeGanttSeries(aChart, aTitle, aFileType, gcnt); 2121 7: MakeAGanttSeries(aChart, aTitle, aFileType, gcnt); 2122 8: MakeManyGanttSeries(aChart, aTitle, aFileType, gcnt); 2123 9: MakeWeightedArrowSeries(aChart, aTitle, aFileType, acnt); 2124 10: MakeWeightedGanttSeries(aChart, aTitle, aFileType, gcnt); 2759 8: MakeGanttSeries(aChart, aTitle, aFileType, gcnt); 2125 2760 end; 2126 2761 end; … … 2158 2793 aChart.LeftAxis.Title.Caption := 'StdDev'; 2159 2794 end; 2160 end;2161 2162 function TfrmGraphs.Vfactor(aTitle: string): double; // returns first numbers in string2163 var2164 firstnum: boolean;2165 i: integer;2166 vfactor: string;2167 begin2168 vfactor := '';2169 firstnum := false;2170 for i := 0 to length(aTitle) - 1 do2171 if IsDelimiter('1234567890.', aTitle, i) then2172 begin2173 vfactor := vfactor + aTitle[i];2174 firstnum := true;2175 end2176 else2177 if firstnum = true then break;2178 Result := strtofloatdef(vfactor, 1);2179 2795 end; 2180 2796 … … 2210 2826 var 2211 2827 tempcheck: boolean; 2212 bottomview, i, j, topview: integer; 2213 typeitem: string; 2828 bottomview, topview: integer; 2214 2829 aGraphItem: TGraphItem; 2830 aListItem: TListItem; 2215 2831 begin 2216 2832 FFirstClick := true; 2217 2833 if (lvwItemsTop.SelCount = 0) and (lvwItemsBottom.SelCount = 0) then exit; 2218 topview := cboViewsTop.ItemIndex;2219 bottomview := cboViewsBottom.ItemIndex;2834 topview := lstViewsTop.ItemIndex; 2835 bottomview := lstViewsBottom.ItemIndex; 2220 2836 HideGraphs(true); 2221 2837 with chkDualViews do … … 2229 2845 chkItemsBottom.Checked := tempcheck; 2230 2846 pnlBottom.Height := pnlMain.Height - pnlBottom.Height; 2231 lstScratchSwap.Items.Clear;2847 GtslScratchSwap.Clear; 2232 2848 if topview < 1 then 2233 with lvwItemsTop do 2234 for i := 0 to Items.Count - 1 do 2235 if Items[i].Selected then 2236 begin 2237 aGraphItem := TGraphItem(Items.Item[i].SubItems.Objects[3]); 2238 lstScratchSwap.Items.Add(aGraphItem.Values); 2239 end; 2849 begin 2850 aListItem := lvwItemsTop.Selected; 2851 while aListItem <> nil do 2852 begin 2853 aGraphItem := TGraphItem(aListItem.SubItems.Objects[3]); 2854 GtslScratchSwap.Add(aGraphItem.Values); 2855 aListItem := lvwItemsTop.GetNextItem(aListItem, sdAll, [isSelected]); 2856 end; 2857 end; 2858 GraphSwap(bottomview, topview); 2859 GtslScratchSwap.Clear; 2860 HideGraphs(false); 2861 end; 2862 2863 procedure TfrmGraphs.GraphSwap(bottomview, topview: integer); 2864 var 2865 tempcheck: boolean; 2866 begin 2867 FFirstClick := true; 2868 if (lvwItemsTop.SelCount = 0) and (lvwItemsBottom.SelCount = 0) then exit; 2869 topview := lstViewsTop.ItemIndex; 2870 bottomview := lstViewsBottom.ItemIndex; 2871 HideGraphs(true); 2872 with chkDualViews do 2873 if not Checked then 2874 begin 2875 Checked := true; 2876 Click; 2877 end; 2878 tempcheck := chkItemsTop.Checked; 2879 chkItemsTop.Checked := chkItemsBottom.Checked; 2880 chkItemsBottom.Checked := tempcheck; 2881 pnlBottom.Height := pnlMain.Height - pnlBottom.Height; 2882 GtslScratchSwap.Clear; 2883 GraphSwitch(bottomview, topview); 2884 HideGraphs(false); 2885 end; 2886 2887 procedure TfrmGraphs.GraphSwitch(bottomview, topview: integer); 2888 var 2889 i, j: integer; 2890 typeitem: string; 2891 aGraphItem: TGraphItem; 2892 aListItem: TListItem; 2893 begin 2894 GtslScratchSwap.Clear; 2895 if topview < 1 then 2896 begin 2897 aListItem := lvwItemsTop.Selected; 2898 while aListItem <> nil do 2899 begin 2900 aGraphItem := TGraphItem(aListItem.SubItems.Objects[3]); 2901 GtslScratchSwap.Add(aGraphItem.Values); 2902 aListItem := lvwItemsTop.GetNextItem(aListItem, sdAll, [isSelected]); 2903 end; 2904 end; 2240 2905 if bottomview > 0 then 2241 2906 begin 2242 cboViewsTop.ItemIndex := bottomview;2243 cboViewsTopChange(self);2907 lstViewsTop.ItemIndex := bottomview; 2908 lstViewsTopChange(self); 2244 2909 end 2245 2910 else 2246 2911 begin 2247 cboViewsTop.ItemIndex := -1; 2248 cboViewsTop.Text := ''; 2912 lstViewsTop.ItemIndex := -1; 2249 2913 lvwItemsTop.ClearSelection; 2250 with lvwItemsBottom do 2251 for i := 0 to Items.Count - 1 do 2252 if Items[i].Selected then 2253 begin 2254 aGraphItem := TGraphItem(Items.Item[i].SubItems.Objects[3]); 2914 aListItem := lvwItemsBottom.Selected; 2915 while aListItem <> nil do 2916 begin 2917 aGraphItem := TGraphItem(aListItem.SubItems.Objects[3]); 2255 2918 typeitem := Pieces(aGraphItem.Values, '^', 1, 2); 2256 2919 for j := 0 to lvwItemsTop.Items.Count - 1 do … … 2263 2926 end; 2264 2927 end; 2928 aListItem := lvwItemsBottom.GetNextItem(aListItem, sdAll, [isSelected]); 2265 2929 end; 2266 2930 lvwItemsTopClick(self); … … 2268 2932 if topview > 0 then 2269 2933 begin 2270 cboViewsBottom.ItemIndex := topview;2271 cboViewsBottomChange(self);2934 lstViewsBottom.ItemIndex := topview; 2935 lstViewsBottomChange(self); 2272 2936 end 2273 2937 else 2274 2938 begin 2275 cboViewsBottom.ItemIndex := -1; 2276 cboViewsBottom.Text := ''; 2939 lstViewsBottom.ItemIndex := -1; 2277 2940 lvwItemsBottom.ClearSelection; 2278 with lstScratchSwap do 2279 for i := 0 to Items.Count - 1 do 2941 for i := 0 to GtslScratchSwap.Count - 1 do 2280 2942 for j := 0 to lvwItemsBottom.Items.Count - 1 do 2281 2943 begin 2282 2944 aGraphItem := TGraphItem(lvwItemsBottom.Items.Item[j].SubItems.Objects[3]); 2283 if aGraphItem.Values = Items[i] then2945 if aGraphItem.Values = GtslScratchSwap[i] then 2284 2946 begin 2285 2947 lvwItemsBottom.Items[j].Selected := true; … … 2289 2951 lvwItemsBottomClick(self); 2290 2952 end; 2291 lstScratchSwap.Items.Clear; 2292 HideGraphs(false); 2953 GtslScratchSwap.Clear; 2293 2954 end; 2294 2955 2295 2956 procedure TfrmGraphs.mnuPopGraphSplitClick(Sender: TObject); 2296 var2297 i: integer;2298 typeitem, typenum: string;2299 aGraphItem: TGraphItem;2300 2957 begin 2301 2958 FFirstClick := true; … … 2308 2965 Click; 2309 2966 end; 2310 with cboViewsTop do2967 with lstViewsTop do 2311 2968 if ItemIndex > -1 then 2312 2969 begin 2313 2970 ItemIndex := -1; 2314 Text := ''; 2315 end; 2316 with cboViewsBottom do 2971 end; 2972 with lstViewsBottom do 2317 2973 if ItemIndex > -1 then 2318 2974 begin 2319 2975 ItemIndex := -1; 2320 Text := ''; 2321 end; 2976 end; 2977 SplitClick; 2978 end; 2979 2980 procedure TfrmGraphs.SplitClick; 2981 2982 procedure SplitGraphs(aListView: TListView); 2983 var 2984 typeitem: string; 2985 aGraphItem: TGraphItem; 2986 aListItem: TListItem; 2987 begin 2988 aListItem := lvwItemsTop.Selected; 2989 while aListItem <> nil do 2990 begin 2991 aGraphItem := TGraphItem(aListItem.SubItems.Objects[3]); 2992 typeitem := Pieces(aGraphItem.Values, '^', 1, 2); 2993 GtslScratchSwap.Add(typeitem); 2994 aListItem := lvwItemsTop.GetNextItem(aListItem, sdAll, [isSelected]); 2995 end; 2996 end; 2997 2998 var 2999 i: integer; 3000 typeitem, typenum: string; 3001 begin 2322 3002 chkItemsTop.Checked := true; 2323 3003 chkItemsBottom.Checked := false; 2324 3004 pnlBottom.Height := pnlMain.Height - pnlBottom.Height; 2325 lstScratchSwap.Items.Clear; 2326 with lvwItemsTop do 2327 for i := 0 to Items.Count - 1 do 2328 if Items[i].Selected then 2329 begin 2330 aGraphItem := TGraphItem(Items.Item[i].SubItems.Objects[3]); 2331 typeitem := Pieces(aGraphItem.Values, '^', 1, 2); 2332 lstScratchSwap.Items.Add(typeitem); 2333 end; 2334 with lvwItemsBottom do 2335 for i := 0 to Items.Count - 1 do 2336 if Items[i].Selected then 2337 begin 2338 aGraphItem := TGraphItem(Items.Item[i].SubItems.Objects[3]); 2339 typeitem := Pieces(aGraphItem.Values, '^', 1, 2); 2340 lstScratchSwap.Items.Add(typeitem); 2341 end; 3005 GtslScratchSwap.Clear; 3006 SplitGraphs(lvwItemsTop); 3007 SplitGraphs(lvwItemsBottom); 2342 3008 lvwItemsTop.ClearSelection; 2343 3009 lvwItemsBottom.ClearSelection; 2344 with lstScratchSwap do 2345 for i := 0 to Items.Count - 1 do 2346 begin 2347 typeitem := Items[i]; 2348 typenum := Piece(typeitem, '^', 1); 2349 if (typenum = '63') or (typenum = '120.5') then 2350 SelectItem(lvwItemsTop, typeitem) 2351 else 2352 SelectItem(lvwItemsBottom, typeitem); 2353 end; 3010 for i := 0 to GtslScratchSwap.Count - 1 do 3011 begin 3012 typeitem := GtslScratchSwap[i]; 3013 typenum := Piece(typeitem, '^', 1); 3014 if (typenum = '63') or (typenum = '120.5') then 3015 SelectItem(lvwItemsTop, typeitem) 3016 else 3017 SelectItem(lvwItemsBottom, typeitem); 3018 end; 2354 3019 lvwItemsTopClick(self); 2355 3020 lvwItemsBottomClick(self); 2356 lstScratchSwap.Items.Clear;3021 GtslScratchSwap.Clear; 2357 3022 HideGraphs(false); 2358 3023 end; … … 2382 3047 with FGraphSetting do View3D := not View3D; 2383 3048 ChangeStyle; 3049 end; 3050 3051 procedure TfrmGraphs.mnuPopGraphValueMarksClick(Sender: TObject); 3052 var 3053 i: integer; 3054 begin 3055 if (FGraphSeries is TPointSeries) and not (FGraphSeries is TGanttSeries) then 3056 begin 3057 if (FGraphSeries as TPointSeries).Pointer.Style = psSmallDot then exit; // keep non-numeric label unchanged 3058 if Piece(FGraphSeries.Title, '^', 1) = '(non-numeric)' then 3059 begin 3060 FGraphSeries.Marks.Visible := not FGraphSeries.Marks.Visible; 3061 for i := 0 to FGraphClick.SeriesCount - 1 do 3062 begin 3063 if FGraphClick.Series[i].Title = FGraphSeries.Identifier then 3064 begin 3065 FGraphClick.Series[i].Marks.Visible := FGraphSeries.Marks.Visible; 3066 if FGraphSeries.Title <> 'Blood Pressure' then break; 3067 end; 3068 end; 3069 end; 3070 end 3071 else if chartDatelineTop.Tag = 1 then // series 3072 begin 3073 FGraphSeries.Marks.Visible := not FGraphSeries.Marks.Visible; 3074 for i := 0 to FGraphClick.SeriesCount - 1 do 3075 begin 3076 if (FGraphClick.Series[i].Identifier = FGraphSeries.Title) 3077 or (FGraphClick.Series[i].Title = FGraphSeries.Title) then 3078 begin 3079 FGraphClick.Series[i].Marks.Visible := FGraphSeries.Marks.Visible; 3080 if FGraphSeries.Title <> 'Blood Pressure' then break; 3081 end; 3082 end; 3083 end; 2384 3084 end; 2385 3085 … … 2425 3125 end; 2426 3126 ChangeStyle; 2427 // redisplay if nonnumericonly graph exists3127 // ???redisplay if nonnumericonly graph exists 2428 3128 if pnlItemsTop.Tag = 1 then lvwItemsTopClick(self); 2429 3129 if pnlItemsBottom.Tag = 1 then lvwItemsBottomClick(self); … … 2450 3150 end; 2451 3151 3152 procedure TfrmGraphs.mnuPopGraphViewDefinitionClick(Sender: TObject); 3153 begin 3154 mnuPopGraphViewDefinition.Checked := not mnuPopGraphViewDefinition.Checked; 3155 if mnuPopGraphViewDefinition.Checked then 3156 begin 3157 memViewsTop.Height := (tsTopViews.Height div 3) + 1; 3158 memViewsBottom.Height := (tsBottomViews.Height div 3) + 1; 3159 end 3160 else 3161 begin 3162 memViewsTop.Height := 1; 3163 memViewsBottom.Height := 1; 3164 end; 3165 end; 3166 2452 3167 procedure TfrmGraphs.mnuPopGraphDatesClick(Sender: TObject); 2453 3168 begin … … 2460 3175 chkDualViews.Checked := not chkDualViews.Checked; 2461 3176 chkDualViewsClick(self); 3177 end; 3178 3179 procedure TfrmGraphs.mnuPopGraphExportClick(Sender: TObject); 3180 3181 procedure AddRow(worksheet: variant; 3182 linestring, typename, itemname, date1, date2, result, other: string); 3183 begin 3184 worksheet.range('A' + linestring) := typename; 3185 worksheet.range('B' + linestring) := itemname; 3186 worksheet.range('C' + linestring) := date1; 3187 worksheet.range('D' + linestring) := date2; 3188 worksheet.range('E' + linestring) := result; 3189 worksheet.range('F' + linestring) := other; 3190 end; 3191 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; 3318 while aListItem <> nil do 3319 begin 3320 itemname := aListItem.Caption; 3321 itemtypename := aListItem.SubItems[0]; 3322 aGraphItem := TGraphItem(aListItem.SubItems.Objects[3]); 3323 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; 3333 itemtype := Piece(typeitem, '^', 1); 3334 item := Piece(typeitem, '^', 2); 3335 for j := 0 to GtslData.Count - 1 do 3336 begin 3337 datax := GtslData[j]; 3338 if Piece(datax, '^', 1) = itemtype then 3339 if Piece(datax, '^', 2) = item then 3340 begin 3341 dtdata1 := strtofloatdef(Piece(datax, '^', 3), -1); 3342 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 3356 begin 3357 cnt := cnt + 1; 3358 linestring := inttostr(cnt); 3359 AddRow(worksheet, linestring, itemtypename, itemname, fmdate1, fmdate2, Piece(datax, '^', 5), Piece(datax, '^', 8)); 3360 end; 3361 end; 3362 end; 3363 aListItem := lvwItemsBottom.GetNextItem(aListItem, sdAll, [isSelected]); 3364 end; 3365 end; 3366 worksheet.Range['A1', 'F' + LineString].Columns.AutoFit; 3367 worksheet.Range['A1', 'F' + LineString].Select; 3368 worksheet.Range['A1', 'F' + LineString].AutoFormat(12, true, true, true, true, true, true); 3369 3370 if topflag then 3371 mnuPopGraphStayOnTopClick(self); 3372 Screen.Cursor := crDefault; 2462 3373 end; 2463 3374 … … 2499 3410 with FGraphSetting do Legend := not Legend; 2500 3411 ChangeStyle; 3412 end; 3413 3414 procedure TfrmGraphs.ChartColor(aColor: TColor); 3415 begin 3416 chartDatelineTop.Color := aColor; 3417 chartDatelineTop.Legend.Color := aColor; 3418 pnlDatelineTopSpacer.Color := aColor; 3419 scrlTop.Color := aColor; 3420 pnlTopRightPad.Color := aColor; 3421 pnlScrollTopBase.Color := aColor; 3422 pnlBlankTop.Color := aColor; 3423 chartDatelineBottom.Color := aColor; 3424 chartDatelineBottom.Legend.Color := aColor; 3425 pnlDatelineBottomSpacer.Color := aColor; 3426 scrlBottom.Color := aColor; 3427 pnlBottomRightPad.Color := aColor; 3428 pnlScrollBottomBase.Color := aColor; 3429 pnlBlankBottom.Color := aColor; 2501 3430 end; 2502 3431 … … 2538 3467 if Series[j] is TPointSeries then 2539 3468 with (Series[j] as TPointSeries) do 3469 if Pointer.Style <> psSmallDot then // keep non-numeric label unchanged 2540 3470 begin 2541 3471 Marks.Visible := FGraphSetting.Values; 2542 3472 LinePen.Visible := FGraphSetting.Lines; 3473 if Title = '(non-numeric)' then Marks.Visible := FDisplayFreeText; 2543 3474 end; 2544 3475 if Series[j] is TBarSeries then … … 2585 3516 ChartStyle(chartDateLineBottom); 2586 3517 if FGraphSetting.ClearBackground then 2587 begin 2588 chartDatelineTop.Color := ClearColor; 2589 chartDatelineTop.Legend.Color := ClearColor; 2590 pnlDatelineTopSpacer.Color := ClearColor; 2591 scrlTop.Color := ClearColor; 2592 pnlTopRightPad.Color := ClearColor; 2593 pnlScrollTopBase.Color := ClearColor; 2594 pnlBlankTop.Color := ClearColor; 2595 chartDatelineBottom.Color := ClearColor; 2596 chartDatelineBottom.Legend.Color := ClearColor; 2597 pnlDatelineBottomSpacer.Color := ClearColor; 2598 scrlBottom.Color := ClearColor; 2599 pnlBottomRightPad.Color := ClearColor; 2600 pnlScrollBottomBase.Color := ClearColor; 2601 pnlBlankBottom.Color := ClearColor; 2602 end 3518 ChartColor(ClearColor) 2603 3519 else 2604 begin 2605 chartDatelineTop.Color := OriginalColor; 2606 chartDatelineTop.Legend.Color := clCream; 2607 pnlDatelineTopSpacer.Color := OriginalColor; 2608 scrlTop.Color := OriginalColor; 2609 pnlTopRightPad.Color := OriginalColor; 2610 pnlScrollTopBase.Color := OriginalColor; 2611 pnlBlankTop.Color := OriginalColor; 2612 chartDatelineBottom.Color := OriginalColor; 2613 chartDatelineBottom.Legend.Color := clCream; 2614 pnlDatelineBottomSpacer.Color := OriginalColor; 2615 scrlBottom.Color := OriginalColor; 2616 pnlBottomRightPad.Color := OriginalColor; 2617 pnlScrollBottomBase.Color := OriginalColor; 2618 pnlBlankBottom.Color := OriginalColor; 2619 end; 3520 ChartColor(OriginalColor); 2620 3521 mnuPopGraphLines.Checked := FGraphSetting.Lines; 2621 3522 mnuPopGraph3D.Checked := FGraphSetting.View3D; … … 2636 3537 ValueIndex: Integer; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); 2637 3538 var 2638 dttm, seriestitle, textvalue, textvalue1, textvalue2, typename, typenum: string; 2639 begin 3539 lbutton: boolean; 3540 begin 3541 if FOnMark then // action already taken by mousedown on a mark 3542 begin 3543 FOnMark := false; 3544 exit; 3545 end; 3546 FOnMark := false; 2640 3547 timHintPause.Enabled := false; 2641 3548 InactivateHint; … … 2654 3561 FDate2 := FDate1; 2655 3562 end; 2656 seriestitle := Series.Title; 2657 if Button <> mbRight then 2658 begin 2659 textvalue := ValueText(Sender, Series, ValueIndex); 3563 lbutton := Button <> mbRight; 3564 SeriesClicks(Sender as TChart, Series, ValueIndex, lbutton); 3565 FMouseDown := false; 3566 end; 3567 3568 3569 procedure TfrmGraphs.SeriesClicks(aChart: TChart; aSeries: TChartSeries; aIndex: integer; lbutton: boolean); 3570 var 3571 originalindex: integer; 3572 dttm, seriestitle, showing, textvalue, textvalue1, textvalue2, typename, typenum: string; 3573 begin 3574 if lbutton then 3575 begin 3576 textvalue := ValueText(aChart, aSeries, aIndex); 2660 3577 dttm := Piece(textvalue, '^', 3); 2661 3578 if copy(textvalue, length(textvalue) - 5, length(textvalue)) = ' 00:00' then … … 2669 3586 else 2670 3587 begin 3588 seriestitle := Piece(aSeries.Title, '^', 1); 3589 if seriestitle = '(non-numeric)' then 3590 begin 3591 originalindex := strtointdef(Piece(GtslNonNum[aIndex], '^', 3), 0); 3592 seriestitle := Piece(aChart.Series[originalindex].Title, '^', 1); 3593 end; 2671 3594 mnuPopGraphIsolate.Enabled := true; 2672 3595 if pnlTop.Tag = 1 then … … 2676 3599 scrlTop.Hint := 'Details - for ' + seriestitle + ' for ' + 2677 3600 FormatDateTime('mmm d, yyyy h:nn am/pm', FDate1); 2678 scrlTop.Tag := ValueIndex + 1;3601 scrlTop.Tag := aIndex + 1; 2679 3602 mnuPopGraphIsolate.Hint := seriestitle; 2680 3603 mnuPopGraphRemove.Enabled := true; 2681 3604 mnuPopGraphRemove.Caption := 'Remove - ' + seriestitle; 2682 3605 mnuPopGraphDetails.Caption := 'Details - ' + seriestitle; 2683 end; 2684 FMouseDown := false; 3606 if FGraphSeries.Marks.Visible then showing := ' - turn off' else showing := ' - turn on'; 3607 mnuPopGraphValueMarks.Caption := 'Values - ' + seriestitle + showing; 3608 mnuPopGraphValueMarks.Enabled := true; 3609 end; 2685 3610 end; 2686 3611 … … 2688 3613 var 2689 3614 i: integer; 2690 d ttm, datax, datex1, datex2, fmdate1, fmdate2, newdata, newline, oldline, spacer, titlemsg: string;2691 dt1, dt2 , dtdata, dtdata1, dtdata2: double;3615 datex1, datex2, newline, oldline, spacer, titlemsg: string; 3616 dt1, dt2: double; 2692 3617 tmpOtherList, templist: TStringList; 2693 3618 begin … … 2704 3629 dt2 := strtofloatdef(datex2, BIG_NUMBER); 2705 3630 CheckToAddData(lvwItemsTop, 'top', aType); // if type is not loaded - load data 2706 for i := 0 to lstData.Items.Count - 1 do 2707 begin 2708 datax := lstData.Items[i]; 3631 TempData(tmpOtherList, aType, dt1, dt2); 3632 with tmpOtherList do 3633 begin 3634 Sort; 3635 for i := Count - 1 downto 0 do 3636 begin 3637 newline := ''; 3638 oldline := tmpOtherList[i]; 3639 newline := Piece(oldline, '^', 4) + ' ' + Piece(oldline, '^', 5); 3640 spacer := Copy(BIG_SPACES, 1, 40 - length(newline)); 3641 newline := newline + spacer + ' ' + Piece(oldline, '^', 3); 3642 templist.Add(newline); 3643 end; 3644 Clear; 3645 FastAssign(templist, tmpOtherList); 3646 //Assign(templist); 3647 if aDate <> aDate2 then 3648 titlemsg := aTypeName + ' occurences for ' + FormatDateTime('mmm d, yyyy', aDate) + 3649 ' - ' + FormatDateTime('mmm d, yyyy', aDate2) 3650 else 3651 titlemsg := aTypeName + ' occurences for ' + FormatDateTime('mmm d, yyyy', aDate); 3652 Insert(0, firstline); 3653 Insert(1, secondline); 3654 Insert(2, ''); 3655 Insert(3, 'All ' + titlemsg + ':'); 3656 Insert(4, ''); 3657 Insert(0, TXT_REPORT_DISCLAIMER); 3658 Insert(1, ''); 3659 ReportBox(tmpOtherList, titlemsg, true); 3660 end; 3661 tmpOtherList.Free; 3662 templist.Free; 3663 Screen.Cursor := crDefault; 3664 end; 3665 3666 procedure TfrmGraphs.TempData(aStringList: TStringList; aType: string; dt1, dt2: double); 3667 var 3668 i: integer; 3669 dttm, datax, fmdate1, fmdate2, newdata: string; 3670 dtdata, dtdata1, dtdata2: double; 3671 begin 3672 for i := 0 to GtslData.Count - 1 do 3673 begin 3674 datax := GtslData[i]; 2709 3675 if Piece(datax, '^', 1) = aType then 2710 3676 begin … … 2727 3693 ItemName(aType, Piece(datax, '^', 2)) + '^' + 2728 3694 Piece(datax, '^', 5); 2729 tmpOtherList.Add(MixedCase(newdata));3695 aStringList.Add(MixedCase(newdata)); 2730 3696 end; 2731 3697 end … … 2744 3710 dttm + '^' + 2745 3711 ItemName(aType, Piece(datax, '^', 2)); 2746 tmpOtherList.Add(MixedCase(newdata));3712 aStringList.Add(MixedCase(newdata)); 2747 3713 end; 2748 3714 end; 2749 3715 end; 2750 3716 end; 2751 with tmpOtherList do 2752 begin 2753 Sort; 2754 for i := Count - 1 downto 0 do 2755 begin 2756 newline := ''; 2757 oldline := tmpOtherList[i]; 2758 newline := Piece(oldline, '^', 4) + ' ' + 2759 Piece(oldline, '^', 5); 2760 spacer := Copy(BIG_SPACES, 1, 40 - length(newline)); 2761 newline := newline + spacer + ' ' + 2762 Piece(oldline, '^', 3); 2763 templist.Add(newline); 2764 end; 2765 Clear; 2766 Assign(templist); 2767 if aDate <> aDate2 then 2768 titlemsg := aTypeName + ' occurences for ' + FormatDateTime('mmm d, yyyy', aDate) + 2769 ' - ' + FormatDateTime('mmm d, yyyy', aDate2) 2770 else 2771 titlemsg := aTypeName + ' occurences for ' + FormatDateTime('mmm d, yyyy', aDate); 2772 Insert(0, firstline); 2773 Insert(1, secondline); 2774 Insert(2, ''); 2775 Insert(3, 'All ' + titlemsg + ':'); 2776 Insert(4, ''); 2777 Insert(0, TXT_REPORT_DISCLAIMER); 2778 Insert(1, ''); 2779 ReportBox(tmpOtherList, titlemsg, true); 2780 end; 2781 tmpOtherList.Free; 2782 templist.Free; 2783 Screen.Cursor := crDefault; 2784 end; 2785 3717 end; 2786 3718 2787 3719 procedure TfrmGraphs.ItemDateRange(Sender: TCustomChart); … … 2819 3751 seriestitle := Sender.Series[i].Title; 2820 3752 if seriestitle = 'Blood Pressure' then 2821 if bpnotdone = false then ok := false;3753 if not bpnotdone then ok := false; 2822 3754 if ok then 2823 3755 begin … … 2859 3791 aGraphItem: TGraphItem; 2860 3792 aListView, aOtherListView: TListView; 3793 aListItem: TListItem; 2861 3794 begin 2862 3795 FFirstClick := true; 2863 cboViewsTop.ItemIndex := -1; 2864 cboViewsTop.Text := ''; 2865 cboViewsBottom.ItemIndex := -1; 2866 cboViewsBottom.Text := ''; 3796 lstViewsTop.ItemIndex := -1; 3797 lstViewsBottom.ItemIndex := -1; 2867 3798 if pnlTop.Tag = 1 then 2868 3799 begin 2869 aListView := lvwItemsTop; 2870 aOtherListView := lvwItemsBottom; 2871 aSection := 'top'; 2872 aOtherSection := 'bottom'; 3800 aListView := lvwItemsTop; aOtherListView := lvwItemsBottom; 3801 aSection := 'top'; aOtherSection := 'bottom'; 2873 3802 end 2874 3803 else 2875 3804 begin 2876 aListView := lvwItemsBottom; 2877 aOtherListView := lvwItemsTop; 2878 aSection := 'bottom'; 2879 aOtherSection := 'top'; 3805 aListView := lvwItemsBottom; aOtherListView := lvwItemsTop; 3806 aSection := 'bottom'; aOtherSection := 'top'; 2880 3807 end; 2881 3808 if aListView.SelCount = 0 then exit; 2882 3809 if StripHotKey(mnuPopGraphIsolate.Caption) = ('Move all selections to ' + aOtherSection) then 2883 3810 begin 2884 with aListView do 2885 for i := 0 to Items.Count - 1 do 2886 if Items[i].Selected then 2887 begin 2888 aGraphItem := TGraphItem(Items.Item[i].SubItems.Objects[3]); 3811 aListItem := aListView.Selected; 3812 while aListItem <> nil do 3813 begin 3814 aGraphItem := TGraphItem(aListItem.SubItems.Objects[3]); 2889 3815 typeitem := Pieces(aGraphItem.Values, '^', 1, 2); 2890 3816 for j := 0 to aOtherListView.Items.Count - 1 do … … 2894 3820 aOtherListView.Items[j].Selected := true; 2895 3821 end; 2896 Items[i].Selected := false; 2897 end; 2898 with chkDualViews do 2899 if not Checked then 2900 begin 2901 Checked := true; 2902 Click; 2903 end; 2904 ChangeStyle; 2905 DisplayData(aSection); 2906 DisplayData(aOtherSection); 3822 aListItem.Selected := false; 3823 aListItem := aListView.GetNextItem(aListItem, sdAll, [isSelected]); 3824 end; 2907 3825 end 2908 3826 else … … 2917 3835 end; 2918 3836 aListView.Items[selnum].Selected := false; 2919 with chkDualViews do2920 if not Checked then2921 begin2922 Checked := true;2923 Click;2924 end;2925 ChangeStyle;2926 DisplayData(aSection);2927 DisplayData(aOtherSection);2928 end;3837 end; 3838 with chkDualViews do 3839 if not Checked then 3840 begin 3841 Checked := true; 3842 Click; 3843 end; 3844 ChangeStyle; 3845 DisplayData(aSection); 3846 DisplayData(aOtherSection); 2929 3847 mnuPopGraphIsolate.Enabled := false; 2930 3848 end; … … 2967 3885 procedure TfrmGraphs.chartBaseMouseDown(Sender: TObject; Button: TMouseButton; 2968 3886 Shift: TShiftState; X, Y: Integer); 3887 var 3888 lbutton: boolean; 2969 3889 begin 2970 3890 FHintStop := true; … … 2984 3904 mnuPopGraphIsolate.Caption := 'Move all selections to bottom'; 2985 3905 mnuPopGraphRemove.Caption := 'Remove all selections from top'; 3906 if memTop.Visible then 3907 memTop.SetFocus; 2986 3908 end 2987 3909 else … … 2989 3911 mnuPopGraphIsolate.Caption := 'Move all selections to top'; 2990 3912 mnuPopGraphRemove.Caption := 'Remove all selections from bottom'; 2991 end; 2992 If Button = mbLeft then 3913 if memBottom.Visible then 3914 memBottom.SetFocus; 3915 end; 3916 if Button = mbLeft then 2993 3917 FMouseDown := true; 3918 lbutton := Button <> mbRight; 3919 MouseClicks(Sender as TChart, lbutton, X, Y); 3920 end; 3921 3922 procedure TfrmGraphs.MouseClicks(aChart: TChart; lbutton: boolean; X, Y: Integer); 3923 var 3924 i, tmp: integer; 3925 aSeries: TChartSeries; 3926 begin 3927 tmp := -1; 3928 for i := 0 to aChart.SeriesCount - 1 do 3929 if aChart.Series[i].Marks.Visible then 3930 begin 3931 tmp := aChart.Series[i].Marks.Clicked(X, Y); 3932 if tmp <> -1 then break; 3933 end; 3934 if tmp <> -1 then 3935 begin 3936 FOnMark := true; 3937 aSeries := aChart.Series[i]; 3938 FGraphClick := aChart; 3939 FGraphSeries := aSeries; 3940 FGraphValueIndex := tmp; 3941 chartDateLineTop.Tag := 1; // indicates a series click 3942 if (aSeries is TGanttSeries) then 3943 begin 3944 FDate1 := (aSeries as TGanttSeries).StartValues[tmp]; 3945 FDate2 := (aSeries as TGanttSeries).EndValues[tmp]; 3946 end 3947 else 3948 begin 3949 FDate1 := aSeries.XValue[tmp]; 3950 FDate2 := FDate1; 3951 end; 3952 LabelClicks(aChart, aSeries, lbutton, tmp); 3953 FMouseDown := false; 3954 aChart.AllowZoom := false; 3955 end; 3956 end; 3957 3958 procedure TfrmGraphs.LabelClicks(aChart: TChart; aSeries: TChartSeries; lbutton: boolean; tmp: integer); 3959 var 3960 firstnon, toggle: boolean; 3961 i, originalindex: integer; 3962 dttm, seriestitle, showing, textvalue, textvalue1, textvalue2, typename, typenum: string; 3963 begin 3964 seriestitle := Piece(aSeries.Title, '^', 1); 3965 if seriestitle = '(non-numeric)' then 3966 begin 3967 originalindex := strtointdef(Piece(GtslNonNum[tmp], '^', 3), 0); 3968 seriestitle := Piece(aChart.Series[originalindex].Title, '^', 1); 3969 end; 3970 if (seriestitle = TXT_COMMENTS) and lbutton then 3971 begin 3972 chartDatelineTop.Tag := 0; 3973 mnuPopGraphDetailsClick(self); 3974 end 3975 else if (seriestitle = TXT_NONNUMERICS) and lbutton then 3976 begin 3977 if (aSeries.Identifier = 'serNonNumBottom') or (aSeries.Identifier = 'serNonNumTop') then 3978 begin 3979 firstnon := true; 3980 toggle := false; 3981 for i := 0 to aChart.SeriesCount - 1 do 3982 if Piece(aChart.Series[i].Title, '^', 1) = '(non-numeric)' then 3983 begin 3984 if firstnon then 3985 begin 3986 toggle := not aChart.Series[i].Marks.Visible; 3987 firstnon := false; 3988 end; 3989 aChart.Series[i].Marks.Visible := toggle; 3990 end; 3991 end; 3992 end 3993 else if lbutton and (seriestitle <> TXT_NONNUMERICS) then 3994 begin 3995 textvalue := ValueText(aChart, aSeries, tmp); 3996 dttm := Piece(textvalue, '^', 3); 3997 if copy(textvalue, length(textvalue) - 5, length(textvalue)) = ' 00:00' then 3998 dttm := Pieces(dttm, ' ', 1, 3); 3999 textvalue1 := Piece(textvalue, '^', 2) + ' ' + dttm; 4000 textvalue2 := Piece(textvalue, '^', 4) + ' ' + Piece(textvalue, '^', 5); 4001 typenum := trim(Piece(textvalue, '^', 1)); 4002 typename := Piece(textvalue, '^', 2); 4003 AllTypeDate(typenum, typename, textvalue1, textvalue2, FDate1, FDate2); 4004 end 4005 else if (Piece(aSeries.Title, '^', 1) <> TXT_NONNUMERICS) 4006 and (Piece(aSeries.Title, '^', 1) <> TXT_COMMENTS) then 4007 begin 4008 mnuPopGraphIsolate.Enabled := true; 4009 if pnlTop.Tag = 1 then 4010 mnuPopGraphIsolate.Caption := 'Move - ' + seriestitle + ' - from Top to Bottom' 4011 else 4012 mnuPopGraphIsolate.Caption := 'Move - ' + seriestitle + ' - from Bottom to Top'; 4013 scrlTop.Hint := 'Details - for ' + seriestitle + ' for ' + 4014 FormatDateTime('mmm d, yyyy h:nn am/pm', FDate1); 4015 scrlTop.Tag := tmp + 1; 4016 mnuPopGraphIsolate.Hint := seriestitle; 4017 mnuPopGraphRemove.Enabled := true; 4018 mnuPopGraphRemove.Caption := 'Remove - ' + seriestitle; 4019 mnuPopGraphDetails.Caption := 'Details - ' + seriestitle; 4020 if FGraphSeries.Marks.Visible then showing := ' - turn off' else showing := ' - turn on'; 4021 mnuPopGraphValueMarks.Caption := 'Values - ' + seriestitle + showing; 4022 mnuPopGraphValueMarks.Enabled := true; 4023 end; 2994 4024 end; 2995 4025 … … 3016 4046 mnuPopGraphDetails.Caption := 'Details...'; 3017 4047 mnuPopGraphDetails.Enabled := (lvwItemsTop.SelCount > 0) or (lvwItemsBottom.SelCount > 0); 4048 mnuPopGraphValueMarks.Caption := 'Values - '; 4049 mnuPopGraphValueMarks.Enabled := false; 3018 4050 end 3019 4051 else … … 3022 4054 mnuPopGraphRemove.Enabled := true; 3023 4055 mnuPopGraphDetails.Enabled := true; 3024 end; 4056 if chartDatelineTop.Tag <> -1 then 4057 mnuPopGraphValueMarks.Enabled := true; 4058 end; 4059 {mnuPopGraphViewDefinition.Enabled := (pcTop.ActivePageIndex = 1) 4060 or (pcBottom.ActivePageIndex = 1);} 3025 4061 mnuPopGraphSwap.Enabled := (lvwItemsTop.SelCount > 0) or (lvwItemsBottom.SelCount > 0); 3026 4062 mnuPopGraphReset.Enabled := mnuPopGraphSwap.Enabled; 3027 4063 mnuPopGraphCopy.Enabled := mnuPopGraphSwap.Enabled; 3028 4064 mnuPopGraphPrint.Enabled := mnuPopGraphSwap.Enabled; 3029 4065 mnuPopGraphExport.Enabled := mnuPopGraphSwap.Enabled; 4066 3030 4067 with pnlMain.Parent do 3031 4068 if BorderWidth <> 1 then // only do on float Graph … … 3037 4074 procedure TfrmGraphs.mnuPopGraphDetailsClick(Sender: TObject); 3038 4075 var 3039 aGraphItem: TGraphItem;3040 4076 tmpList: TStringList; 3041 4077 date1, date2: TFMDateTime; 3042 4078 teststring, typeitem, textvalue, textvalue1, textvalue2, typenum, typename: string; 3043 i, selnum: integer; 4079 selnum: integer; 4080 aGraphItem: TGraphItem; 4081 aListView: TListView; 4082 aListItem: TListItem; 3044 4083 begin 3045 4084 if chartDatelineTop.Tag = 1 then // series … … 3076 4115 tmpList := TStringList.Create; 3077 4116 if pnlTop.Tag = 1 then 3078 for i := 0 to lvwItemsTop.Items.Count - 1 do 3079 begin 3080 if lvwItemsTop.Items[i].Selected then 3081 begin 3082 aGraphItem := TGraphItem(lvwItemsTop.Items.Item[i].SubItems.Objects[3]); //get file^ien match 3083 teststring := aGraphItem.Values; 3084 tmpList.Add(teststring); 3085 end; 3086 end 4117 aListView := lvwItemsTop 3087 4118 else 3088 for i := 0 to lvwItemsBottom.Items.Count - 1 do3089 begin3090 if lvwItemsBottom.Items[i].Selected then3091 3092 aGraphItem := TGraphItem(lvwItemsBottom.Items.Item[i].SubItems.Objects[3]);//get file^ien match3093 3094 3095 end;4119 aListView := lvwItemsBottom; 4120 aListItem := aListView.Selected; 4121 while aListItem <> nil do 4122 begin 4123 aGraphItem := TGraphItem(aListItem.SubItems.Objects[3]); //get file^ien match 4124 teststring := aGraphItem.Values; 4125 tmpList.Add(teststring); 4126 aListItem := aListView.GetNextItem(aListItem, sdAll, [isSelected]); 3096 4127 end; 3097 4128 if tmpList.Count > 0 then … … 3100 4131 end; 3101 4132 FMouseDown := false; 4133 if (Sender is TChart) then 4134 (Sender as TChart).AllowZoom := false; 3102 4135 end; 3103 4136 3104 4137 procedure TfrmGraphs.AllDetails(aDate1, aDate2: TFMDateTime; aTempList: TStrings); 3105 4138 var 3106 TypeList: TStringList;3107 4139 i: integer; 3108 4140 detailsok: boolean; 3109 4141 testnum, teststring, testtype: string; 3110 begin 3111 detailsok := true; 4142 ztmpList: TStringList; 4143 TypeList: TStringList; 4144 begin 4145 //ShowMsg('This funtionality is currently unavailable.'); 4146 //exit; // ****************** temporary 11-4-07 3112 4147 TypeList := TStringList.Create; 4148 detailsok := true; 3113 4149 for i := 0 to aTempList.Count -1 do 3114 4150 begin … … 3127 4163 end; 3128 4164 if detailsok then 3129 ReportBox(rpcDetailSelected(Patient.DFN, aDate1, aDate2, TypeList, true), 'Graph results on ' + Patient.Name, True) 4165 begin 4166 ztmpList := TStringList.Create; 4167 try 4168 FastAssign(rpcDetailSelected(Patient.DFN, aDate1, aDate2, TypeList, true), ztmpList); 4169 NotifyApps(ztmpList); 4170 ReportBox(ztmpList, 'Graph results on ' + Patient.Name, True); 4171 finally 4172 ztmpList.Free; 4173 end; 4174 end 3130 4175 else 3131 4176 ItemDateRange(FGraphClick); … … 3149 4194 titleitem := ItemName(Piece(aTypeItem, '^', 1), Piece(aTypeItem, '^', 2)); 3150 4195 rpcDetailDay(tmpList, Patient.DFN, date1, date2, aTypeItem, true); 4196 NotifyApps(tmpList); 3151 4197 ReportBox(tmpList, titletype + ': ' + titleitem + ' on ' + Patient.Name + ' for ' + FormatFMDateTime('mmm d, yyyy', date1), True); 3152 4198 tmpList.Free; 3153 4199 end; 3154 4200 3155 procedure TfrmGraphs. mnuPopGraphCopyClick(Sender: TObject);4201 procedure TfrmGraphs.NotifyApps(aList: TStrings); 3156 4202 var 3157 4203 i: integer; 3158 StrForFooter, StrForHeader, aTitle, aWarning, aDateRange: String; 3159 aHeader: TStringList; 3160 wrdApp, wrdDoc: Variant; 3161 ChildControl: TControl; 3162 begin 3163 try 3164 wrdApp := CreateOleObject('Word.Application'); 3165 except 3166 raise Exception.Create('Cannot start MS Word!'); 3167 end; 3168 Screen.Cursor := crHourGlass; 3169 aTitle := 'CPRS Graphing'; 3170 aWarning := pnlInfo.Caption; 3171 aDateRange := 'Date Range: ' + cboDateRange.Text + ' Selected Items from ' + 3172 FormatDateTime('mm/dd/yy', FGraphSetting.LowTime) + ' to ' + 3173 FormatDateTime('mm/dd/yy', FGraphSetting.HighTime); 3174 aHeader := TStringList.Create; 3175 CreatePatientHeader(aHeader, aTitle, aWarning, aDateRange); 3176 StrForHeader := ''; 3177 for i := 0 to aHeader.Count -1 do 3178 StrForHeader := StrForHeader + aHeader[i] + Chr(13); 3179 StrForFooter := aTitle + ' - *** WORK COPY ONLY ***' + Chr(13); 3180 wrdApp.Visible := False; 3181 wrdApp.Documents.Add; 3182 wrdDoc := wrdApp.Documents.Item(1); 3183 wrdDoc := wrdDoc.Sections.Item(1); 3184 wrdDoc := wrdDoc.Headers.Item(1).Range; 3185 wrdDoc.Font.Name := 'Courier New'; 3186 wrdDoc.Font.Size := 9; 3187 wrdDoc.Text := StrForHeader; 3188 wrdDoc := wrdApp.Documents.Item(1); 3189 wrdDoc := wrdDoc.Sections.Item(1); 3190 wrdDoc := wrdDoc.Footers.Item(1); 3191 wrdDoc.Range.Font.Name := 'Courier New'; 3192 wrdDoc.Range.Font.Size := 9; 3193 wrdDoc.Range.Text := StrForFooter; 3194 wrdDoc.PageNumbers.Add; 3195 wrdDoc := wrdApp.Documents.Item(1); 3196 wrdDoc.Range.Font.Name := 'Courier New'; 3197 wrdDoc.Range.Font.Size := 9; 3198 wrdDoc.Range.Text := StrForHeader; 3199 wrdDoc.Range.InsertParagraphAfter; 3200 for i := 0 to scrlTop.ControlCount - 1 do // goes from top to bottom 3201 begin 3202 ChildControl := scrlTop.Controls[i]; 3203 if (ChildControl as TChart).Visible then 3204 begin 3205 (ChildControl as TChart).CopyToClipboardBitmap; 3206 wrdDoc.Range.InsertParagraphAfter; 3207 wrdDoc.Paragraphs.Last.Range.Paste; 3208 end; 3209 end; 3210 if (chartDatelineTop.SeriesCount > 0) and (not chkItemsTop.Checked) then 3211 begin 3212 chartDatelineTop.CopyToClipboardBitmap; 3213 wrdDoc.Range.InsertParagraphAfter; 3214 wrdDoc.Paragraphs.Last.Range.Paste; 3215 end; 3216 wrdDoc.Range.InsertParagraphAfter; 3217 wrdDoc.Paragraphs.Last.Range.Text := ' '; 3218 for i := 0 to scrlBottom.ControlCount - 1 do 3219 begin 3220 ChildControl := scrlBottom.Controls[i]; 3221 if (ChildControl as TChart).Visible then 3222 begin 3223 (ChildControl as TChart).CopyToClipboardBitmap; 3224 wrdDoc.Range.InsertParagraphAfter; 3225 wrdDoc.Paragraphs.Last.Range.Paste; 3226 end; 3227 end; 3228 if (chartDatelineBottom.SeriesCount > 0) and (chkDualViews.Checked) 3229 and (not chkItemsBottom.Checked) then 3230 begin 3231 chartDatelineBottom.CopyToClipboardBitmap; 3232 wrdDoc.Range.InsertParagraphAfter; 3233 wrdDoc.Paragraphs.Last.Range.Paste; 3234 end; 3235 wrdDoc.Range.WholeStory; 3236 wrdDoc.Range.Copy; 3237 wrdDoc.Close(false); 3238 wrdApp.DisplayAlerts := false; 3239 wrdApp.Quit; 3240 wrdApp := Unassigned; // releases variant 3241 aHeader.Free; 3242 Screen.Cursor := crDefault; 4204 info, aID, aTag: string; 4205 begin 4206 for i := aList.Count - 1 downto 0 do 4207 begin 4208 info := aList[i]; 4209 if Piece(info, '^', 1 ) = '~~~' then 4210 begin 4211 aList.Delete(i); 4212 if length(Piece(info, '^', 11)) > 0 then 4213 begin 4214 aID := ''; 4215 aTag := 'SUR' + '^'; 4216 //NotifyOtherApps(NAE_REPORT, aTag + aID); 4217 end; 4218 end; 4219 end; 3243 4220 end; 3244 4221 … … 3250 4227 if Warning = TXT_INFO then Warning := ' '; 3251 4228 with HeaderList do 3252 begin 3253 Add(' '); 3254 Add(StringOfChar(' ', (74 - Length(PageTitle)) div 2) + PageTitle); 3255 Add(' '); 3256 tmpStr := Patient.Name + ' ' + Patient.SSN; 3257 tmpItem := tmpStr + StringOfChar(' ', 39 - Length(tmpStr)) + Encounter.LocationName; 3258 tmpStr := FormatFMDateTime('mmm dd, yyyy', Patient.DOB) + ' (' + IntToStr(Patient.Age) + ')'; 3259 tmpItem := tmpItem + StringOfChar(' ', 74 - (Length(tmpItem) + Length(tmpStr))) + tmpStr; 3260 Add(tmpItem); 3261 Add(StringOfChar('=', 74)); 3262 Add('*** WORK COPY ONLY ***' + StringOfChar(' ', 24) + 'Printed: ' 3263 + FormatFMDateTime('mmm dd, yyyy hh:nn', FMNow)); 3264 Add(TXT_COPY_DISCLAIMER); 3265 Add(StringOfChar(' ', (74 - Length(DateRange)) div 2) + DateRange); 3266 Add(StringOfChar(' ', (74 - Length(Warning)) div 2) + Warning); 3267 Add(' '); 3268 end; 4229 begin 4230 Add(' '); 4231 Add(StringOfChar(' ', (74 - Length(PageTitle)) div 2) + PageTitle); 4232 Add(' '); 4233 tmpStr := Patient.Name + ' ' + Patient.SSN; 4234 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 {} 4239 tmpItem := tmpItem + StringOfChar(' ', 74 - (Length(tmpItem) + Length(tmpStr))) + tmpStr; 4240 Add(tmpItem); 4241 Add(StringOfChar('=', 74)); 4242 Add(' *** WORK COPY ONLY *** ' + StringOfChar(' ', 24) + 'Printed: ' 4243 + FormatFMDateTime('mmm dd, yyyy hh:nn', FMNow)); 4244 Add(' ' + TXT_COPY_DISCLAIMER); 4245 Add(StringOfChar(' ', (74 - Length(DateRange)) div 2) + DateRange); 4246 Add(StringOfChar(' ', (74 - Length(Warning)) div 2) + Warning); 4247 Add(' '); 4248 end; 4249 end; 4250 4251 procedure TfrmGraphs.CreateExcelPatientHeader(var HeaderList: TStringList; PageTitle, DateRange: string); 4252 // this procedure modified from rReports 4253 var 4254 tmpItem: string; 4255 begin 4256 with HeaderList do 4257 begin 4258 Add(' '); 4259 Add(PageTitle); 4260 Add(' '); 4261 tmpItem := Patient.Name + ' ' + Patient.SSN + ' ' 4262 + Encounter.LocationName + ' ' 4263 + FormatFMDateTime('mmm dd, yyyy', Patient.DOB) + ' (' + IntToStr(Patient.Age) + ')'; 4264 Add(tmpItem); 4265 //Add(TXT_COPY_DISCLAIMER); // put on footer to avoid length problems 4266 Add(DateRange); 4267 end; 3269 4268 end; 3270 4269 … … 3275 4274 aDate, aDate1: double; 3276 4275 begin 3277 lstTemp.Items.Clear;4276 GtslTemp.Clear; 3278 4277 itemid := UpperCase(Pieces(aString, '^', 1, 2)); 3279 with lstData do 3280 for i := Items.Count - 1 downto 0 do 3281 if itemid = UpperCase(Pieces(Items[i], '^', 1, 2)) then 3282 begin 3283 itemdata := Items[i]; 4278 for i := GtslData.Count - 1 downto 0 do 4279 if itemid = UpperCase(Pieces(GtslData[i], '^', 1, 2)) then 4280 begin 4281 itemdata := GtslData[i]; 3284 4282 filenum := Piece(itemdata, '^', 1); 3285 4283 if (filenum = '52') or (filenum = '55') or (filenum = '55NVA') … … 3289 4287 aDate1 := strtofloat(FMCorrectedDate(Piece(itemdata, '^', 4))); 3290 4288 if (aDate < FGraphSetting.FMStopDate) and (aDate > FGraphSetting.FMStartDate) then 3291 lstTemp.Items.Add(Items[i])4289 GtslTemp.Add(GtslData[i]) 3292 4290 else if (aDate < FGraphSetting.FMStopDate) and (aDate1 > FGraphSetting.FMStartDate) then 3293 lstTemp.Items.Add(Items[i])4291 GtslTemp.Add(GtslData[i]) 3294 4292 else if (aDate < FGraphSetting.FMStartDate) and (aDate1 > FGraphSetting.FMStopDate) then 3295 lstTemp.Items.Add(Items[i]);4293 GtslTemp.Add(GtslData[i]); 3296 4294 end 3297 4295 else if Piece(itemdata, '^', 3) <> '' then … … 3300 4298 if (aDate < FGraphSetting.FMStopDate) and (aDate > FGraphSetting.FMStartDate) then 3301 4299 if Copy(itemdata, 1, 4) = '63MI' then 3302 lstTemp.Items.Add(Pieces(Items[i], '^', 1, 4))4300 GtslTemp.Add(Pieces(GtslData[i], '^', 1, 4)) 3303 4301 else if Copy(itemdata, 1, 4) = '63AP' then 3304 lstTemp.Items.Add(Pieces(Items[i], '^', 1, 4))3305 //else lstTemp.Items.Add(Pieces(Items[i], '^', 1, 5)); // add in non micro, ap3306 else lstTemp.Items.Add(Items[i]); // add in non micro, ap4302 GtslTemp.Add(Pieces(GtslData[i], '^', 1, 4)) 4303 //else GtslTemp.Add(Pieces(Items[i], '^', 1, 5)); // add in non micro, ap 4304 else GtslTemp.Add(GtslData[i]); // add in non micro, ap 3307 4305 end; 3308 4306 end; … … 3328 4326 Result := 4; 3329 4327 if (aType = '52') or (aType = '55') or (aType = '55NVA') or (aType = '9999911') then 3330 if mnuMedsasgantt.Checked then Result := 8 3331 else if mnuMedsasganttvertheight.Checked then Result := 3 3332 else Result := 8 4328 Result := 8 3333 4329 else 3334 for i := 0 to lstAllTypes.Items.Count - 1 do3335 if aType = Piece( lstAllTypes.Items[i], '^', 1) then3336 begin 3337 Result := strtointdef(Piece( lstAllTypes.Items[i], '^', 3), 4);4330 for i := 0 to GtslAllTypes.Count - 1 do 4331 if aType = Piece(GtslAllTypes[i], '^', 1) then 4332 begin 4333 Result := strtointdef(Piece(GtslAllTypes[i], '^', 3), 4); 3338 4334 break; 3339 4335 end; … … 3343 4339 var 3344 4340 i: integer; 4341 astring: string; 3345 4342 begin 3346 4343 Result := false; 3347 for i := 0 to lstTypes.Items.Count - 1 do 3348 if Piece(lstTypes.Items[i], '^', 1) = aType then 3349 begin 3350 Result := length(Piece(lstTypes.Items[i], '^', 8)) > 0; 3351 break; 4344 for i := 0 to GtslTypes.Count - 1 do 4345 begin 4346 astring := GtslTypes[i]; 4347 if Piece(astring, '^', 1) = aType then 4348 begin 4349 Result := length(Piece(astring, '^', 8)) > 0; 4350 break; 4351 end; 3352 4352 end; 3353 4353 end; … … 3361 4361 done := false; 3362 4362 j := 0; 3363 with lstTempCheck do3364 4363 while not done do 3365 4364 begin 3366 if Items.Count = j then done := true3367 else if Items[j] = typeitem then4365 if GtslTempCheck.Count = j then done := true 4366 else if GtslTempCheck[j] = typeitem then 3368 4367 begin 3369 4368 previous := true; … … 3375 4374 if not previous then 3376 4375 begin 3377 lstTempCheck.Items.Add(UpperCase(typeitem));3378 levelseq := lstTempCheck.Items.Count;4376 GtslTempCheck.Add(UpperCase(typeitem)); 4377 levelseq := GtslTempCheck.Count; 3379 4378 end; 3380 4379 end; … … 3384 4383 i: integer; 3385 4384 begin 3386 if lstDrugClass.Items.Count < 1 then3387 FastAssign(rpcClass('50.605'), lstDrugClass.Items);4385 if GtslDrugClass.Count < 1 then 4386 FastAssign(rpcClass('50.605'), GtslDrugClass); 3388 4387 Result := ''; 3389 for i := 0 to lstDrugClass.Items.Count - 1 do3390 if Piece( lstDrugClass.Items[i], '^', 2) = aDCien then3391 begin 3392 Result := 'Drug - ' + Piece( lstDrugClass.Items[i], '^', 3);4388 for i := 0 to GtslDrugClass.Count - 1 do 4389 if Piece(GtslDrugClass[i], '^', 2) = aDCien then 4390 begin 4391 Result := 'Drug - ' + Piece(GtslDrugClass[i], '^', 3); 3393 4392 break; 3394 4393 end; … … 3409 4408 end; 3410 4409 4410 procedure TfrmGraphs.splViewsTopMoved(Sender: TObject); 4411 begin 4412 mnuPopGraphViewDefinition.Checked := (memViewsTop.Height > 5) 4413 or (memViewsBottom.Height > 5); 4414 end; 4415 3411 4416 procedure TfrmGraphs.cboDateRangeChange(Sender: TObject); 3412 4417 var 3413 datetag: integer; 3414 endofday: double; 3415 dateranges, manualstart, manualstop: string; 3416 begin 3417 endofday := FMDateTimeOffsetBy(FMToday, 1); 3418 SelCopy(lvwItemsTop, lstSelCopyTop); 3419 SelCopy(lvwItemsBottom, lstSelCopyBottom); 4418 dateranges: string; 4419 begin 4420 SelCopy(lvwItemsTop, GtslSelCopyTop); 4421 SelCopy(lvwItemsBottom, GtslSelCopyBottom); 3420 4422 dateranges := ''; 3421 4423 if (cboDateRange.ItemID = 'S') then … … 3443 4445 end; 3444 4446 HideGraphs(true); 4447 DateSteps(dateranges); 4448 FilterListView(FGraphSetting.FMStartDate, FGraphSetting.FMStopDate); 4449 SelReset(GtslSelCopyTop, lvwItemsTop); 4450 SelReset(GtslSelCopyBottom, lvwItemsBottom); 4451 DisplayData('top'); 4452 DisplayData('bottom'); 4453 if lstViewsTop.ItemIndex > 1 then lstViewsTopChange(self); 4454 if lstViewsBottom.ItemIndex > 1 then lstViewsBottomChange(self); 4455 HideGraphs(false); 4456 end; 4457 4458 procedure TfrmGraphs.DateSteps(dateranges: string); 4459 var 4460 datetag: integer; 4461 endofday: double; 4462 manualstart, manualstop: string; 4463 begin 4464 endofday := FMDateTimeOffsetBy(FMToday, 1); 3445 4465 datetag := cboDateRange.ItemIEN; 4466 FGraphSetting.FMStopDate := endofday; 3446 4467 with FGraphSetting do 3447 4468 case datetag of … … 3464 4485 end; 3465 4486 end; 3466 1: begin 3467 FMStartDate := FMToday; 3468 FMStopDate := endofday; 3469 end; 3470 2: begin 3471 FMStartDate := FMDateTimeOffsetBy(FMToday, -7); 3472 FMStopDate := endofday; 3473 end; 3474 3: begin 3475 FMStartDate := FMDateTimeOffsetBy(FMToday, -14); 3476 FMStopDate := endofday; 3477 end; 3478 4: begin 3479 FMStartDate := FMDateTimeOffsetBy(FMToday, -30); 3480 FMStopDate := endofday; 3481 end; 3482 5: begin 3483 FMStartDate := FMDateTimeOffsetBy(FMToday, -183); 3484 FMStopDate := endofday; 3485 end; 3486 6: begin 3487 FMStartDate := FMDateTimeOffsetBy(FMToday, -365); 3488 FMStopDate := endofday; 3489 end; 3490 7: begin 3491 FMStartDate := FMDateTimeOffsetBy(FMToday, -730); 3492 FMStopDate := endofday; 3493 end; 3494 8: begin 3495 FMStartDate := FM_START_DATE; // earliest recorded values 3496 FMStopDate := endofday; 3497 end; 4487 1: FMStartDate := FMToday; 4488 2: FMStartDate := FMDateTimeOffsetBy(FMToday, -7); 4489 3: FMStartDate := FMDateTimeOffsetBy(FMToday, -14); 4490 4: FMStartDate := FMDateTimeOffsetBy(FMToday, -30); 4491 5: FMStartDate := FMDateTimeOffsetBy(FMToday, -183); 4492 6: FMStartDate := FMDateTimeOffsetBy(FMToday, -365); 4493 7: FMStartDate := FMDateTimeOffsetBy(FMToday, -730); 4494 8: FMStartDate := FM_START_DATE; // earliest recorded values 3498 4495 else 3499 4496 begin … … 3512 4509 end; 3513 4510 end; 3514 FilterListView(FGraphSetting.FMStartDate, FGraphSetting.FMStopDate);3515 SelReset(lstSelCopyTop, lvwItemsTop);3516 SelReset(lstSelCopyBottom, lvwItemsBottom);3517 DisplayData('top');3518 DisplayData('bottom');3519 if cboViewsTop.ItemIndex > 1 then cboViewsTopChange(self);3520 if cboViewsBottom.ItemIndex > 1 then cboViewsBottomChange(self);3521 HideGraphs(false);3522 4511 end; 3523 4512 … … 3609 4598 var 3610 4599 actionOK, checkaction: boolean; 3611 counter , i, listnum: integer;3612 profile, profilestring, section, selections, specnum, typeitem : string;4600 counter: integer; 4601 profile, profilestring, section, selections, specnum, typeitem, seltext: string; 3613 4602 aGraphItem: TGraphItem; 4603 aListItem: TListItem; 3614 4604 begin 3615 4605 selections := ''; 3616 for i := 0 to lvwItemsTop.Items.Count - 1 do 3617 if lvwItemsTop.Items[i].Selected then 3618 begin 3619 aGraphItem := TGraphItem(lvwItemsTop.Items.Item[i].SubItems.Objects[3]); 4606 seltext := ''; 4607 aListItem := lvwItemsTop.Selected; 4608 while aListItem <> nil do 4609 begin 4610 aGraphItem := TGraphItem(aListItem.SubItems.Objects[3]); 3620 4611 typeitem := UpperCase(aGraphItem.Values); 3621 4612 if Piece(typeitem, '^', 1) = '63' then 3622 4613 begin 3623 4614 specnum := Piece(Piece(typeitem, '^', 2), '.', 2); 3624 if length(specnum) > 0 then // mul ispecimen4615 if length(specnum) > 0 then // multispecimen 3625 4616 if specnum = '1' then typeitem := Piece(typeitem, '.', 1) 3626 4617 else typeitem := ''; 3627 4618 end; 3628 4619 if length(typeitem) > 0 then 3629 selections := selections + Piece(typeitem, '^', 1) + '~' + Piece(typeitem, '^', 2) +'~|'; 3630 end; 3631 checkaction := chkDualViews.Checked; 4620 selections := selections + Piece(typeitem, '^', 1) + '~' + Piece(typeitem, '^', 2) + '~|'; 4621 aListItem := lvwItemsTop.GetNextItem(aListItem, sdAll, [isSelected]); 4622 end; 4623 checkaction := false; 3632 4624 actionOK := false; 3633 4625 profile := '*'; 3634 counter := cboViewsTop.Tag;3635 // load lstItems with all patient items and pass to Define View ????3636 DialogGraphProfiles( Font.Size,actionOK, checkaction, FGraphSetting,4626 counter := lstViewsTop.Tag; 4627 // load GtslItems with all patient items and pass to Define View ???? 4628 DialogGraphProfiles(actionOK, checkaction, FGraphSetting, 3637 4629 profile, profilestring, section, Patient.DFN, counter, selections); 3638 4630 if (not actionOK) then exit; 3639 4631 FillViews; 3640 4632 if (section = 'niether') then exit; 3641 cboViewsTop.Tag := counter; 3642 3643 lstViews.Items.Add(profilestring); 3644 listnum := lstViews.Items.Count + 1; 3645 for i := 0 to lstViews.Items.Count - 1 do 3646 begin 3647 profilestring := lstViews.Items[i]; 3648 cboViewsTop.Items.Insert(i + 2, profilestring); 3649 cboViewsBottom.Items.Insert(i + 2, profilestring); 3650 end; 4633 lstViewsTop.Tag := counter; 3651 4634 if (section = 'bottom') or (section = 'both') then 3652 lvwItemsBottom.Tag := listnum;4635 lvwItemsBottom.Tag := counter; 3653 4636 if (section = 'top') or (section = 'both') then 3654 lvwItemsTop.Tag := listnum;4637 lvwItemsTop.Tag := counter; 3655 4638 ViewSelections; 4639 end; 4640 4641 procedure TfrmGraphs.DisplayFreeText(aChart: TChart); 4642 var 4643 i: integer; 4644 begin 4645 for i := 0 to aChart.SeriesCount - 1 do 4646 if (Piece(aChart.Series[i].Title, '^', 1) = '(non-numeric)') then 4647 aChart.Series[i].Marks.Visible := true; 3656 4648 end; 3657 4649 … … 3664 4656 if (Tag = 0) and (length(lvwItemsBottom.Hint) > 0) then 3665 4657 begin 3666 for i := 0 to cboViewsBottom.Items.Count - 1 do4658 for i := 0 to lstViewsBottom.Items.Count - 1 do 3667 4659 begin 3668 showmessage(cboViewsBottom.Items[i]);3669 if lvwItemsBottom.Hint = Piece( cboViewsBottom.Items[i], '^', 2) then4660 ShowMsg(lstViewsBottom.Items[i]); 4661 if lvwItemsBottom.Hint = Piece(lstViewsBottom.Items[i], '^', 2) then 3670 4662 begin 3671 4663 Tag := i; … … 3682 4674 end; 3683 4675 ClearSelection; 3684 cboViewsBottom.ItemIndex := Tag;4676 lstViewsBottom.ItemIndex := Tag; 3685 4677 Tag := 0; 3686 4678 Hint := ''; 3687 cboViewsBottomChange(self);4679 lstViewsBottomChange(lstViewsBottom); 3688 4680 end; 3689 4681 end; … … 3691 4683 begin 3692 4684 if (Tag = 0) and (length(lvwItemsTop.Hint) > 0) then 3693 begin 3694 for i := 0 to cboViewsTop.Items.Count - 1 do 3695 begin 3696 if lvwItemsTop.Hint = Piece(cboViewsTop.Items[i], '^', 2) then 4685 for i := 0 to lstViewsTop.Items.Count - 1 do 4686 if lvwItemsTop.Hint = Piece(lstViewsTop.Items[i], '^', 2) then 3697 4687 begin 3698 4688 Tag := i; 3699 4689 break; 3700 4690 end; 3701 end;3702 end;3703 4691 if Tag > 0 then 3704 4692 begin 3705 4693 ClearSelection; 3706 cboViewsTop.ItemIndex := Tag;4694 lstViewsTop.ItemIndex := Tag; 3707 4695 Tag := 0; 3708 4696 Hint := ''; 3709 cboViewsTopChange(self);4697 lstViewsTopChange(lstViewsTop); 3710 4698 end; 3711 4699 end; … … 3713 4701 3714 4702 procedure TfrmGraphs.ItemsClick(Sender: TObject; aListView, aOtherListView: TListView; 3715 aCheckBox: TCheckBox; a ComboBox: TORComboBox; aList: TListBox; aSection: string);3716 begin 3717 FRetainZoom := ( lstZoomHistory.Count > 0);4703 aCheckBox: TCheckBox; aListBox: TORListBox; aList: TStrings; aSection: string); 4704 begin 4705 FRetainZoom := (GtslZoomHistoryFloat.Count > 0); 3718 4706 FWarning := false; 3719 4707 Screen.Cursor := crHourGlass; … … 3721 4709 if Sender = aListView then 3722 4710 begin 3723 aComboBox.ItemIndex := -1; 3724 aComboBox.Text := ''; 4711 aListBox.Tag := BIG_NUMBER; // avoids recurssion 4712 aListBox.ItemIndex := -1; 4713 aListBox.ClearSelection; 3725 4714 end; 3726 4715 if (Sender is TListView) then // clear out selcopy list 3727 aList. Items.Clear;4716 aList.Clear; 3728 4717 if aOtherListView.SelCount < 1 then 3729 4718 begin … … 3755 4744 if (aListView.SelCount = 1) and (aOtherListView.SelCount = 0) then 3756 4745 begin 3757 lstZoomHistory.Items.Clear;4746 GtslZoomHistoryFloat.Clear; 3758 4747 FRetainZoom := false; 3759 4748 mnuPopGraphZoomBack.Enabled := false; 3760 4749 end 3761 else if FRetainZoom and ( lstZoomHistory.Count > 0) then4750 else if FRetainZoom and (GtslZoomHistoryFloat.Count > 0) then 3762 4751 ZoomUpdate; 3763 4752 HideGraphs(false); … … 3774 4763 aGraphItem: TGraphItem; 3775 4764 begin 4765 if FFastTrack then 4766 exit; 4767 Application.ProcessMessages; 3776 4768 TypeToCheck := UpperCase(TypeToCheck); 3777 4769 if (TypeToCheck = 'SELECT') and (lvwItemsTop.SelCount = 0) … … 3794 4786 done := false; 3795 4787 j := 0; 3796 with lstCheck do3797 4788 while not done do 3798 4789 begin 3799 if Items.Count = j then done := true3800 else if lstCheck.Items[j]= typeitem then4790 if GtslCheck.Count = j then done := true 4791 else if Pieces(GtslCheck[j], '^', 1, 2) = typeitem then 3801 4792 begin 3802 4793 previous := true; … … 3807 4798 if not previous then 3808 4799 begin 3809 lstCheck.Items.Add(typeitem);4800 GtslCheck.Add(typeitem); 3810 4801 itemname := aListView.Items[i].Caption; 3811 4802 if Piece(typeitem, '^', 1) = '63' then 3812 LabData(typeitem, itemname, aSection )4803 LabData(typeitem, itemname, aSection, true) // need to get lab data 3813 4804 else 3814 lstData.Items.AddStrings(rpcGetItemData(typeitem, FMTimeStamp, Patient.DFN));4805 FastAddStrings(rpcGetItemData(typeitem, FMTimeStamp, Patient.DFN), GtslData); 3815 4806 end; 3816 4807 end; … … 3818 4809 end; 3819 4810 3820 procedure TfrmGraphs.lvwItems TopClick(Sender: TObject);4811 procedure TfrmGraphs.lvwItemsBottomClick(Sender: TObject); 3821 4812 var 3822 4813 i: integer; 3823 4814 begin 3824 4815 FFirstClick := true; 3825 with FGraphSetting do 3826 if lvwItemsTop.SelCount > MaxSelect then 3827 begin 3828 pnlItemsTopInfo.Tag := 1; 3829 lvwItemsTop.ClearSelection; 3830 showmessage('Too many items to graph'); 3831 for i := 0 to lstSelPrevTop.Items.Count - 1 do 3832 lvwItemsTop.Items[strtoint(lstSelPrevTop.Items[i])].Selected := true; 3833 pnlItemsTopInfo.Tag := 0; 3834 end 3835 else 3836 begin 3837 lstSelPrevTop.Clear; 3838 for i := 0 to lvwItemsTop.Items.Count - 1 do 3839 if lvwItemsTop.Items[i].Selected then lstSelPrevTop.Items.Add(inttostr(i)); 3840 ItemsClick(Sender, lvwItemsTop, lvwItemsBottom, chkItemsTop, cboViewsTop, lstSelCopyTop, 'top'); 3841 end; 3842 end; 3843 3844 procedure TfrmGraphs.lvwItemsBottomClick(Sender: TObject); 3845 var 3846 i: integer; 3847 begin 3848 FFirstClick := true; 3849 with FGraphSetting do 3850 if lvwItemsBottom.SelCount > MaxSelect then 4816 if not FFastTrack then 4817 if GraphTurboOn then 4818 Switch; 4819 if lvwItemsBottom.SelCount > FGraphSetting.MaxSelect then 3851 4820 begin 3852 4821 pnlItemsBottomInfo.Tag := 1; 3853 4822 lvwItemsBottom.ClearSelection; 3854 showmessage('Too many items to graph'); 3855 for i := 0 to lstSelPrevBottom.Items.Count - 1 do 3856 lvwItemsBottom.Items[strtoint(lstSelPrevBottom.Items[i])].Selected := true; 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; 4829 for i := 0 to GtslSelPrevBottomFloat.Count - 1 do 4830 lvwItemsBottom.Items[strtoint(GtslSelPrevBottomFloat[i])].Selected := true; 3857 4831 pnlItemsBottomInfo.Tag := 0; 3858 4832 end 3859 4833 else 3860 4834 begin 3861 lstSelPrevBottom.Clear;4835 GtslSelPrevBottomFloat.Clear; 3862 4836 for i := 0 to lvwItemsBottom.Items.Count - 1 do 3863 if lvwItemsBottom.Items[i].Selected then lstSelPrevBottom.Items.Add(inttostr(i));3864 ItemsClick(Sender, lvwItemsBottom, lvwItemsTop, chkItemsBottom, cboViewsBottom, lstSelCopyBottom, 'bottom');3865 end;3866 end;3867 3868 procedure TfrmGraphs.SelCopy(aListView: TListView; aListBox: TListBox); 3869 var 3870 i: integer; 4837 if lvwItemsBottom.Items[i].Selected then 4838 GtslSelPrevBottomFloat.Add(inttostr(i)); 4839 ItemsClick(Sender, lvwItemsBottom, lvwItemsTop, chkItemsBottom, lstViewsBottom, GtslSelCopyBottom, 'bottom'); 4840 end; 4841 end; 4842 4843 procedure TfrmGraphs.SelCopy(aListView: TListView; aList: TStrings); 4844 var 3871 4845 aGraphItem: TGraphItem; 4846 aListItem: TListItem; 3872 4847 begin 3873 4848 if aListView.Items.Count > 0 then 3874 4849 begin 3875 for i := 0 to aListView.Items.Count - 1 do 3876 if aListView.Items[i].Selected then 3877 begin 3878 aGraphItem := TGraphItem(aListView.Items.Item[i].SubItems.Objects[3]); //get file^ien match 3879 aListBox.Items.Add(aGraphItem.Values); 3880 end; 3881 end; 3882 end; 3883 3884 procedure TfrmGraphs.SelReset(aListbox: TListBox; aListView: TListView); 4850 aListItem := aListView.Selected; 4851 while aListItem <> nil do 4852 begin 4853 aGraphItem := TGraphItem(aListItem.SubItems.Objects[3]); //get file^ien match 4854 aList.Add(aGraphItem.Values); 4855 aListItem := aListView.GetNextItem(aListItem, sdAll, [isSelected]); 4856 end; 4857 end; 4858 end; 4859 4860 procedure TfrmGraphs.SelReset(aList: TStrings; aListView: TListView); 3885 4861 var 3886 4862 i, j: integer; … … 3892 4868 aGraphItem := TGraphItem(aListView.Items.Item[i].SubItems.Objects[3]); //get file^ien match 3893 4869 typeitem := UpperCase(Pieces(aGraphItem.Values, '^', 1, 3)); 3894 for j := 0 to aList Box.Items.Count - 1 do3895 begin 3896 itemtype := UpperCase(Pieces(aList Box.Items[j], '^', 1, 3));4870 for j := 0 to aList.Count - 1 do 4871 begin 4872 itemtype := UpperCase(Pieces(aList[j], '^', 1, 3)); 3897 4873 if itemtype = typeitem then 3898 4874 begin … … 3904 4880 end; 3905 4881 3906 procedure TfrmGraphs.ViewsChange(aListView: TListView; a ComboBox: TORComboBox; aSection: string);4882 procedure TfrmGraphs.ViewsChange(aListView: TListView; aListBox: TORListBox; aSection: string); 3907 4883 var 3908 4884 Updated: boolean; … … 3911 4887 timHintPause.Enabled := false; 3912 4888 InactivateHint; 3913 if aComboBox.ItemIndex = -1 then exit; // or clear graph *************************** 3914 if aComboBox.ItemIndex = 0 then // <clear all selections> 3915 begin 3916 aComboBox.Text := ''; 4889 if aListBox.ItemIndex = -1 then exit; // or clear graph *************************** 4890 if aListBox.Tag = BIG_NUMBER then // avoids recurssion 4891 exit; 4892 if pos(LLS_FRONT, aListBox.Items[aListBox.ItemIndex]) > 0 then // <clear all selections> 4893 begin 4894 if aListBox.Tag = BIG_NUMBER then // avoids recurssion 4895 exit; 3917 4896 aListView.ClearSelection; 3918 4897 if aSection = 'top' then … … 3920 4899 FTHighTime := 0; 3921 4900 FTLowTime := BIG_NUMBER; 4901 memViewsTop.Lines.Clear; 4902 memViewsTop.Lines[0] := TXT_VIEW_DEFINITION; 3922 4903 end 3923 4904 else … … 3925 4906 FBHighTime := 0; 3926 4907 FBLowTime := BIG_NUMBER; 4908 memViewsBottom.Lines.Clear; 4909 memViewsBottom.Lines[0] := TXT_VIEW_DEFINITION; 3927 4910 end; 3928 4911 DisplayData(aSection); 4912 aListBox.Tag := 0; // reset 3929 4913 exit; 3930 4914 end; 3931 if aComboBox.ItemIndex = 1 then // <make selections>3932 begin3933 btnGraphSelectionsClick(self);3934 if aComboBox.ItemIndex = -1 then3935 aComboBox.Text := '';3936 exit;3937 end; // view selected3938 4915 aListView.ClearSelection; 3939 4916 Updated := false; 3940 aProfile := aComboBox.Items[aComboBox.ItemIndex]; 3941 if (length(Piece(aProfile, '^', 3)) = 0) or (length(Piece(aProfile, '^', 1)) = 0) then //or <custom> 4917 aProfile := aListBox.Items[aListBox.ItemIndex]; 4918 if (length(Piece(aProfile, '^', 3)) = 0) or (length(Piece(aProfile, '^', 1)) = 0) or 4919 (Piece(aProfile, '^', 1) = VIEW_LABS) then //or <custom> 3942 4920 CheckProfile(aProfile, Updated); 3943 aComboBox.Text := Piece(aProfile, '^', 2);3944 4921 if Updated then 3945 4922 cboDateRangeChange(self); 3946 4923 if aSection = 'top' then 3947 4924 begin 4925 ViewDefinition(aProfile, memViewsTop); 3948 4926 AssignProfile(aProfile, 'top'); 3949 4927 if not FItemsSortedTop then … … 3957 4935 else 3958 4936 begin 4937 ViewDefinition(aProfile, memViewsBottom); 3959 4938 AssignProfile(aProfile, 'bottom'); 3960 4939 if not FItemsSortedBottom then … … 3971 4950 end; 3972 4951 3973 procedure TfrmGraphs.cboViewsTopChange(Sender: TObject);3974 begin3975 ViewsChange(lvwItemsTop, cboViewsTop, 'top');3976 end;3977 3978 procedure TfrmGraphs.cboViewsBottomChange(Sender: TObject);3979 begin3980 ViewsChange(lvwItemsBottom, cboViewsBottom, 'bottom');3981 end;3982 3983 4952 procedure TfrmGraphs.AssignProfile(aProfile, aSection: string); 3984 4953 var … … 3996 4965 procedure TfrmGraphs.SetProfile(aProfile, aName: string; aListView: TListView); 3997 4966 var 3998 i, j: integer; 4967 i: integer; 4968 itemstring: string; 4969 aGraphItem: TGraphItem; 4970 begin 4971 aListView.Items.BeginUpdate; 4972 if aProfile = '0' then 4973 for i := 0 to aListView.Items.Count - 1 do 4974 aListView.Items[i].SubItems[1] := '' 4975 else 4976 for i := 0 to aListView.Items.Count - 1 do 4977 begin 4978 aGraphItem := TGraphItem(aListView.Items.Item[i].SubItems.Objects[3]); //get file^ien match 4979 itemstring := aGraphItem.Values; 4980 aListView.Items[i].SubItems[1] := ProfileName(aProfile, aName, itemstring); 4981 end; 4982 aListView.Items.EndUpdate; 4983 end; 4984 4985 function TfrmGraphs.ProfileName(aProfile, aName, aString: string): string; 4986 var 4987 j: integer; 3999 4988 dcnm, itemdrugclass, itempart, itempart1, itempart2, itemnums: string; 4000 itemstring, itemstring1, itemstringnums, profname: string; 4001 aGraphItem: TGraphItem; 4002 begin 4003 if aProfile = '0' then 4004 for i := 0 to aListView.Items.Count - 1 do 4005 aListView.Items[i].SubItems[1] := '' 4006 else 4007 for i := 0 to aListView.Items.Count - 1 do 4008 begin 4009 profname := ''; 4010 aGraphItem := TGraphItem(aListView.Items.Item[i].SubItems.Objects[3]); //get file^ien match 4011 itemstring := aGraphItem.Values; 4012 itemstring1 := UpperCase(Piece(itemstring, '^', 1)); 4013 itemdrugclass := Piece(itemstring, '^', 6); 4014 itemstringnums := UpperCase(Pieces(itemstring, '^', 1, 2)); 4015 for j := 1 to BIG_NUMBER do 4016 begin 4017 itempart := Piece(aProfile, '|', j); 4018 if itempart = '' then break; 4019 itempart1 := Piece(itempart, '~', 1); 4020 itempart2 := Piece(itempart, '~', 2); 4021 itemnums := itempart1 + '^' + itempart2; 4022 if (itempart1 = '50.605') and (length(itemdrugclass) > 0) then 4989 itemstring1, itemstringnums: string; 4990 begin 4991 Result := ''; 4992 itemstring1 := UpperCase(Piece(aString, '^', 1)); 4993 itemdrugclass := Piece(aString, '^', 6); 4994 itemstringnums := UpperCase(Pieces(aString, '^', 1, 2)); 4995 for j := 1 to BIG_NUMBER do 4996 begin 4997 itempart := Piece(aProfile, '|', j); 4998 if itempart = '' then 4999 break; 5000 itempart1 := Piece(itempart, '~', 1); 5001 itempart2 := Piece(itempart, '~', 2); 5002 itemnums := itempart1 + '^' + itempart2; 5003 if (itempart1 = '50.605') and (length(itemdrugclass) > 0) then 5004 begin 5005 dcnm := DCName(itempart2); 5006 if dcnm = itemdrugclass then 4023 5007 begin 4024 dcnm := DCName(itempart2); 4025 if dcnm = itemdrugclass then 4026 begin 4027 profname := aName; 4028 break; 4029 end; 4030 end 4031 else if itempart1 = '63' then 4032 begin 4033 if itemnums = Piece(itemstringnums, '.', 1) then 4034 begin 4035 profname := aName; 4036 break; 4037 end; 4038 end 4039 else 4040 begin 4041 if itemnums = itemstringnums then 4042 begin 4043 profname := aName; 4044 break; 4045 end; 4046 end; 4047 if (itempart1 = '0') and (itempart2 = itemstring1) then 4048 begin 4049 profname := aName; 4050 break; 4051 end 4052 else if (itempart1 = '0') and (length(Piece(itempart2, ';', 2)) > 0) then // subtypes 4053 if copy(itempart2, 1, length(itemstring1)) = Piece(itempart2, ';', 1) then 4054 if Piece(itempart2, ';', 2) = UpperCase(Piece(Piece(itemstring, '^', 2), ';', 2)) then 4055 begin 4056 profname := aName; 5008 Result := aName; 4057 5009 break; 4058 5010 end; 4059 end; 4060 aListView.Items[i].SubItems[1] := profname; 5011 end 5012 else if itempart1 = '63' then 5013 begin 5014 if itemnums = Piece(itemstringnums, '.', 1) then 5015 begin 5016 Result := aName; 5017 break; 5018 end; 5019 end 5020 else 5021 begin 5022 if itemnums = itemstringnums then 5023 begin 5024 Result := aName; 5025 break; 5026 end; 5027 end; 5028 if (itempart1 = '0') and (itempart2 = itemstring1) then 5029 begin 5030 Result := aName; 5031 break; 5032 end 5033 else if (itempart1 = '0') and (length(Piece(itempart2, ';', 2)) > 0) then // subtypes 5034 if copy(itempart2, 1, length(itemstring1)) = Piece(itempart2, ';', 1) then 5035 if Piece(itempart2, ';', 2) = UpperCase(Piece(Piece(aString, '^', 2), ';', 2)) then 5036 begin 5037 Result := aName; 5038 break; 5039 end; 5040 end; 5041 end; 5042 5043 procedure TfrmGraphs.ViewDefinition(profile: string; amemo: TRichEdit); 5044 var 5045 i, defnum: integer; 5046 vname, vdef, vlist, vtype, vnum: string; 5047 begin 5048 vtype := Piece(profile, '^', 1); 5049 defnum := strtointdef(vtype, BIG_NUMBER); 5050 vname := Piece(profile, '^', 2); 5051 case defnum of 5052 -1: vdef := 'Personal View'; 5053 -2: vdef := 'Public View'; 5054 -3: vdef := 'Lab Group'; 5055 else vdef := 'Temporary View'; 5056 end; 5057 amemo.Clear; 5058 amemo.Lines.Add(vname + ' [' + vdef + ']:'); 5059 if vdef = 'Temporary View' then 5060 begin 5061 for i := 4 to BIG_NUMBER do 5062 begin 5063 vlist := Piece(profile, '^', i); 5064 if vlist = '' then break; 5065 amemo.Lines.Add(' ' + vlist); 5066 end; 5067 end 5068 else 5069 begin 5070 vnum := ''; 5071 for i := 0 to GtslAllViews.Count - 1 do 5072 begin 5073 vlist := GtslAllViews[i]; 5074 if Piece(vlist, '^', 4) = vname then 5075 if Piece(vlist, '^', 1) = vtype then 5076 if Piece(vlist, '^', 2) = 'V' then 5077 vnum := Piece(vlist, '^', 3); 5078 if vnum <> '' then 5079 if Piece(vlist, '^', 2) = 'C' then 5080 if Piece(vlist, '^', 3) = vnum then 5081 amemo.Lines.Add(' ' + Piece(vlist, '^', 4)); 5082 end; 4061 5083 end; 4062 5084 end; … … 4081 5103 if length(itempart) = 0 then break; 4082 5104 if Pos('811.2~', itempart) = 0 then 4083 newprofile := newprofile + '|'5105 newprofile := newprofile + itempart + '|' 4084 5106 else 4085 5107 taxonomies.Add(itempart); … … 4114 5136 itempart, itempart1, itempart2, profile, profilename, profiletype, xprofile: string; 4115 5137 begin 5138 Application.ProcessMessages; 5139 GtslTemp.Clear; 4116 5140 profiletype := Piece(aProfile, '^', 1); 4117 5141 profilename := Piece(aProfile, '^', 2); 4118 if profiletype = '-2' then 4119 FastAssign(rpcGetGraphProfiles(UpperCase(profilename), '1', 0), lstTemp.Items) 4120 else if profiletype = '-1' then 4121 FastAssign(rpcGetGraphProfiles(UpperCase(profilename), '0', 0), lstTemp.Items); 5142 if profiletype = VIEW_PUBLIC then 5143 FastAssign(GetGraphProfiles(UpperCase(profilename), '1', 0, 0), GtslTemp) 5144 else if profiletype = VIEW_PERSONAL then 5145 FastAssign(GetGraphProfiles(UpperCase(profilename), '0', 0, User.DUZ), GtslTemp) 5146 else if profiletype = VIEW_LABS then 5147 begin 5148 FastAssign(GetATestGroup(strtoint(Piece(aProfile, '^', 3)), strtoint(Piece(aProfile, '^', 4))), GtslTemp); 5149 aProfile := VIEW_LABS + '^' + Piece(aProfile, '^', 2) + '^'; 5150 for i := 0 to GtslTemp.Count - 1 do 5151 aProfile := aProfile + '63~' + Piece(GtslTemp[i], '^', 1) + '~|'; 5152 GtslTemp.Clear; 5153 end; 4122 5154 if profiletype <> '' then 4123 5155 begin 4124 for i := 0 to lstTemp.Items.Count - 1 do4125 aProfile := aProfile + lstTemp.Items[i];4126 lstTemp.Items.Clear;5156 for i := 0 to GtslTemp.Count - 1 do 5157 aProfile := aProfile + GtslTemp[i]; 5158 GtslTemp.Clear; 4127 5159 end; 4128 5160 Updated := false; … … 4152 5184 LoadDisplayCheck('52', Updated); 4153 5185 LoadDisplayCheck('55', Updated); 4154 //LoadDisplayCheck('55NVAE', Updated); // nonvameds as events are not being used4155 5186 LoadDisplayCheck('55NVA', Updated); 4156 5187 LoadDisplayCheck('53.79', Updated); … … 4163 5194 procedure TfrmGraphs.LoadDisplayCheck(typeofitem: string; var Updated: boolean); 4164 5195 begin 5196 if FFastTrack then 5197 begin 5198 exit; 5199 end; 4165 5200 if not TypeIsLoaded(typeofitem) then 4166 5201 begin … … 4197 5232 else if aListView = lvwItemsBottom then 4198 5233 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; 4199 5240 end; 4200 5241 if aListView = lvwItemsTop then … … 4204 5245 end; 4205 5246 4206 procedure TfrmGraphs.LabData(aItemType, aItemName, aSection: string); 4207 var 4208 singlespec: boolean; 4209 i, oldlisting: integer; 4210 checkitem, checkstring, datastring, filename, itemnum, newitemname, newitemnum, newstring: string; 4211 spec1, spec2, spec3, spec4: string; 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 5332 procedure TfrmGraphs.LabAdd(aListView: TListView; filename: string; aIndex, oldlisting: integer; selectlab: boolean); 5333 var 4212 5334 aGraphItem: TGraphItem; 4213 5335 aListItem: TListItem; 4214 5336 begin 4215 singlespec := true; 4216 spec1 := ''; spec2 := ''; spec3 := ''; spec4 := ''; 4217 lstSpec1.Items.Clear; lstSpec2.Items.Clear; lstSpec3.Items.Clear; lstSpec4.Items.Clear; 4218 FastAssign(rpcGetItemData(aItemType, FMTimeStamp, Patient.DFN), lstScratchLab.Items); 4219 for i := 0 to lstScratchLab.Items.Count - 1 do 4220 begin 4221 datastring := lstScratchLab.Items[i]; 4222 checkstring := Pieces(datastring, '^', 1, 2) + '^' + Pieces(datastring, '^', 7, 8); 4223 if length(spec1) = 0 then 4224 begin 4225 spec1 := checkstring; 4226 lstSpec1.Items.Add(datastring) 4227 end 4228 else if spec1 = checkstring then 4229 lstSpec1.Items.Add(datastring) 4230 else if length(spec2) = 0 then 4231 begin 4232 singlespec := false; 4233 spec2 := checkstring; 4234 lstSpec2.Items.Add(datastring) 4235 end 4236 else if spec2 = checkstring then 4237 lstSpec2.Items.Add(datastring) 4238 else if length(spec3) = 0 then 4239 begin 4240 spec3 := checkstring; 4241 lstSpec3.Items.Add(datastring) 4242 end 4243 else if spec3 = checkstring then 4244 lstSpec3.Items.Add(datastring) 4245 else 4246 begin 4247 spec4 := checkstring; 4248 lstSpec4.Items.Add(datastring) 4249 end; 4250 end; 5337 aListItem := aListView.Items.Insert(oldlisting); 5338 aListItem.Caption := Piece(GtslMultiSpec[aIndex], '^', 4); 5339 aListItem.SubItems.Add(filename); 5340 aListItem.SubItems.Add(''); 5341 aListItem.SubItems.Add(''); 5342 aGraphItem := TGraphItem.Create; 5343 aGraphItem.Values := GtslMultiSpec[aIndex]; 5344 aListItem.SubItems.AddObject('', aGraphItem); 5345 if selectlab then 5346 if not FFastLabs then 5347 aListView.Items[oldlisting].Selected := true; 5348 end; 5349 5350 procedure TfrmGraphs.LabCheck(aListView: TListView; aItemType: string; var oldlisting: integer); 5351 var 5352 i: integer; 5353 checkitem: string; 5354 aGraphItem: TGraphItem; 5355 begin 5356 oldlisting := 0; 5357 aListView.SortType := stNone; // avoids out of bounds error 5358 for i := 0 to aListView.Items.Count - 1 do 5359 begin 5360 aGraphItem := TGraphItem(aListView.Items.Item[i].SubItems.Objects[3]); //get file^ien match 5361 checkitem := Pieces(aGraphItem.Values, '^', 1, 2); 5362 if aItemType = checkitem then 5363 begin 5364 oldlisting := i; 5365 aListView.Items.Delete(i); 5366 break; 5367 end; 5368 end; 5369 end; 5370 5371 procedure TfrmGraphs.LabData(aItemType, aItemName, aSection: string; getdata: boolean); 5372 var 5373 singlespec, selectlab: boolean; 5374 i, oldlisting: integer; 5375 filename: string; 5376 spec1, spec2, spec3, spec4: string; 5377 begin 5378 if getdata then 5379 FastAssign(rpcGetItemData(aItemType, FMTimeStamp, Patient.DFN), GtslScratchLab); 5380 SpecCheck(spec1, spec2, spec3, spec4, singlespec); 4251 5381 if singlespec then 4252 lstData.Items.AddStrings(lstScratchLab.Items)5382 FastAddStrings(GtslScratchLab, GtslData) 4253 5383 else 4254 5384 begin 4255 lstMultiSpec.Items.Clear; 4256 itemnum := Piece(aItemType, '^', 2); 4257 if length(spec1) > 0 then 4258 begin 4259 newitemnum := itemnum + '.1'; 4260 newitemname := aItemName + ' (' + LowerCase(Piece(spec1, '^', 4)) + ')'; 4261 for i := 0 to lstItems.Items.Count - 1 do 4262 if aItemType = Pieces(lstItems.Items[i], '^', 1, 2) then 4263 begin 4264 newstring := lstItems.Items[i]; 4265 lstItems.Items.Delete(i); 4266 break; 4267 end; 4268 for i := 0 to lstData.Items.Count - 1 do 4269 if aItemType = Pieces(lstData.Items[i], '^', 1, 2) then 4270 lstData.Items.Delete(i); 4271 ResetSpec(lstSpec1, itemnum, newitemnum, newitemname, newstring); 4272 end; 4273 if length(spec2) > 0 then 4274 begin 4275 newitemnum := itemnum + '.2'; 4276 newitemname := aItemName + ' (' + LowerCase(Piece(spec2, '^', 4)) + ')'; 4277 ResetSpec(lstSpec2, itemnum, newitemnum, newitemname, newstring); 4278 end; 4279 if length(spec3) > 0 then 4280 begin 4281 newitemnum := itemnum + '.3'; 4282 newitemname := aItemName + ' (' + LowerCase(Piece(spec3, '^', 4)) + ')'; 4283 ResetSpec(lstSpec3, itemnum, newitemnum, newitemname, newstring); 4284 end; 4285 if length(spec4) > 0 then 4286 begin 4287 newitemnum := itemnum + '.4'; 4288 newitemname := aItemName + ' (other)'; // not specific after 3 specimens (from same time) 4289 ResetSpec(lstSpec4, itemnum, newitemnum, newitemname, newstring); 4290 end; 4291 oldlisting := 0; 4292 lvwItemsTop.SortType := stNone; // avoids out of bounds error 4293 for i := 0 to lvwItemsTop.Items.Count - 1 do 4294 begin 4295 aGraphItem := TGraphItem(lvwItemsTop.Items.Item[i].SubItems.Objects[3]); //get file^ien match 4296 checkitem := Pieces(aGraphItem.Values, '^', 1, 2); 4297 if aItemType = checkitem then 4298 begin 4299 oldlisting := i; 4300 lvwItemsTop.Items.Delete(i); 4301 break; 4302 end; 4303 end; 5385 SpecSet(spec1, spec2, spec3, spec4, aItemType, aItemName); 4304 5386 filename := FileNameX('63'); 4305 for i := 0 to lstMultiSpec.Items.Count - 1 do 4306 begin 4307 lstCheck.Items.Add(UpperCase(Pieces(lstMultiSpec.Items[i], '^', 1, 2))); 4308 if (FGraphSetting.FMStartDate = FM_START_DATE) 4309 or DateRangeMultiItems(FGraphSetting.FMStartDate, FGraphSetting.FMStopDate, Piece(lstMultiSpec.Items[i], '^', 2)) then 4310 begin 4311 with lvwItemsTop do 4312 aListItem := Items.Insert(oldlisting); 4313 aListItem.Caption := Piece(lstMultiSpec.Items[i], '^', 4); 4314 aListItem.SubItems.Add(filename); 4315 aListItem.SubItems.Add(''); 4316 aListItem.SubItems.Add(''); 4317 aGraphItem := TGraphItem.Create; 4318 aGraphItem.Values := lstMultiSpec.Items[i]; 4319 aListItem.SubItems.AddObject('info object', aGraphItem); 4320 if aSection = 'top' then lvwItemsTop.Items[oldlisting].Selected := true; 4321 end; 5387 5388 LabCheck(lvwItemsTop, aItemType, oldlisting); 5389 selectlab := aSection = 'top'; 5390 lvwItemsTop.Items.BeginUpdate; 5391 for i := 0 to GtslMultiSpec.Count - 1 do 5392 begin 5393 GtslCheck.Add(UpperCase(Pieces(GtslMultiSpec[i], '^', 1, 2))); 5394 if (FGraphSetting.FMStartDate = FM_START_DATE) or 5395 DateRangeMultiItems(FGraphSetting.FMStartDate, FGraphSetting.FMStopDate, Piece(GtslMultiSpec[i], '^', 2)) then 5396 LabAdd(lvwItemsTop, filename, i, oldlisting, selectlab); 4322 5397 end; 4323 5398 lvwItemsTop.SortType := stBoth; 4324 oldlisting := 0; 4325 lvwItemsBottom.SortType := stNone; // avoids out of bounds error 4326 for i := 0 to lvwItemsBottom.Items.Count - 1 do 4327 begin 4328 aGraphItem := TGraphItem(lvwItemsBottom.Items.Item[i].SubItems.Objects[3]); //get file^ien match 4329 checkitem := Pieces(aGraphItem.Values, '^', 1, 2); 4330 if aItemType = checkitem then 4331 begin 4332 oldlisting := i; 4333 lvwItemsBottom.Items.Delete(i); 4334 break; 4335 end; 4336 end; 4337 for i := 0 to lstMultiSpec.Items.Count - 1 do 4338 begin 4339 aListItem := lvwItemsBottom.Items.Insert(oldlisting); 4340 aListItem.Caption := Piece(lstMultiSpec.Items[i], '^', 4); 4341 aListItem.SubItems.Add(filename); 4342 aListItem.SubItems.Add(''); 4343 aListItem.SubItems.Add(''); 4344 aGraphItem := TGraphItem.Create; 4345 aGraphItem.Values := lstMultiSpec.Items[i]; 4346 aListItem.SubItems.AddObject('info object', aGraphItem); 4347 if aSection = 'bottom' then lvwItemsBottom.Items[oldlisting].Selected := true; 4348 end; 5399 lvwItemsTop.Items.EndUpdate; 5400 5401 LabCheck(lvwItemsBottom, aItemType, oldlisting); 5402 selectlab := aSection = 'bottom'; 5403 lvwItemsBottom.Items.BeginUpdate; 5404 for i := 0 to GtslMultiSpec.Count - 1 do 5405 LabAdd(lvwItemsBottom, filename, i, oldlisting, selectlab); 4349 5406 lvwItemsBottom.SortType := stBoth; 5407 lvwItemsBottom.Items.EndUpdate; 4350 5408 end; 4351 5409 end; … … 4364 5422 end; 4365 5423 itemspec := aItem + '^' + aSpec; 4366 for i := 0 to lstTestSpec.Items.Count - 1 do4367 if itemspec = Pieces( lstTestSpec.Items[i], '^', 1, 2) then4368 begin 4369 specstring := lstTestSpec.Items[i];5424 for i := 0 to GtslTestSpec.Count - 1 do 5425 if itemspec = Pieces(GtslTestSpec[i], '^', 1, 2) then 5426 begin 5427 specstring := GtslTestSpec[i]; 4370 5428 low := Piece(specstring, '^', 3); 4371 5429 high := Piece(specstring, '^', 4); … … 4442 5500 end; 4443 5501 4444 procedure TfrmGraphs.ResetSpec(aList Box: TListBox; aItemNum, aNewItemNum, aNewItemName, aNewString: string);5502 procedure TfrmGraphs.ResetSpec(aList: TStrings; aItemNum, aNewItemNum, aNewItemName, aNewString: string); 4445 5503 var //also add itemx 4446 5504 i: integer; … … 4448 5506 newestdate, newstring: string; 4449 5507 begin 4450 lstTemp.Items.Clear;5508 GtslTemp.Clear; 4451 5509 newdate := 0; 4452 for i := 0 to aList Box.Items.Count - 1 do4453 begin 4454 newstring := aList Box.Items[i];5510 for i := 0 to aList.Count - 1 do 5511 begin 5512 newstring := aList[i]; 4455 5513 newestdate := FMCorrectedDate(Piece(newstring, '^', 3)); 4456 5514 checkdate := strtofloatdef(newestdate, -BIG_NUMBER); 4457 5515 if checkdate > newdate then newdate := checkdate; 4458 5516 SetPiece(newstring, '^', 2, aNewItemNum); 4459 lstTemp.Items.Add(newstring);4460 end; 4461 lstData.Items.AddStrings(lstTemp.Items);5517 GtslTemp.Add(newstring); 5518 end; 5519 FastAddStrings(GtslTemp, GtslData); 4462 5520 newestdate := floattostr(newdate); 4463 5521 SetPiece(aNewString, '^', 2, aNewItemNum); 4464 5522 SetPiece(aNewString, '^', 4, aNewItemName); 4465 5523 SetPiece(aNewString, '^', 6, newestdate); 4466 lstItems.Items.Add(aNewString);4467 lstMultiSpec.Items.Add(aNewString);5524 GtslItems.Add(aNewString); 5525 GtslMultiSpec.Add(aNewString); 4468 5526 end; 4469 5527 … … 4492 5550 mnuPopGraphRemove.Caption := 'Remove - ' + seriestitle; 4493 5551 mnuPopGraphDetails.Caption := 'Details - ' + seriestitle; 5552 mnuPopGraphValueMarks.Caption := 'Values - '; 5553 mnuPopGraphValueMarks.Enabled := false; 4494 5554 end 4495 5555 else … … 4511 5571 mnuPopGraphRemove.Caption := 'Remove - ' + seriestitle; 4512 5572 mnuPopGraphDetails.Caption := 'Details - ' + seriestitle; 5573 mnuPopGraphValueMarks.Caption := 'Values - '; 5574 mnuPopGraphValueMarks.Enabled := false; 4513 5575 end 4514 5576 else … … 4530 5592 fmdatetime := datetimetofmdatetime(aDateTime); 4531 5593 fmstring := floattostr(fmdatetime); 4532 for i := 0 to lstData.Items.Count - 1 do4533 begin 4534 datastring := lstData.Items[i];5594 for i := 0 to GtslData.Count - 1 do 5595 begin 5596 datastring := GtslData[i]; 4535 5597 if Pieces(datastring, '^', 1, 2) = '120.5^1' then //********** get item # for bp instead of 1 4536 5598 begin … … 4547 5609 end; 4548 5610 4549 procedure TfrmGraphs.mnuMedsasganttClick(Sender: TObject); 4550 begin 4551 (Sender as TMenuItem).Checked := true; 4552 lvwItemsTopClick(self); 4553 lvwItemsBottomClick(self); 5611 procedure TfrmGraphs.mnuCustomClick(Sender: TObject); 5612 begin 5613 mnuCustom.Checked := not mnuCustom.Checked; 5614 tsTopCustom.TabVisible := mnuCustom.Checked; 5615 tsBottomCustom.TabVisible := mnuCustom.Checked; 5616 end; 5617 5618 procedure TfrmGraphs.mnuGraphDataClick(Sender: TObject); 5619 begin 5620 frmGraphData.Show; 5621 end; 5622 5623 procedure TfrmGraphs.mnuMHasNumeric1Click(Sender: TObject); 5624 begin 5625 DialogGraphOthers(1); 4554 5626 end; 4555 5627 … … 4557 5629 begin 4558 5630 FFirstClick := true; 4559 lstZoomHistory.Items.Clear;5631 GtslZoomHistoryFloat.Clear; 4560 5632 FRetainZoom := false; 4561 5633 mnuPopGraphZoomBack.Enabled := false; … … 4566 5638 ValueIndex: Integer; var MarkText: String); 4567 5639 var 4568 cnt, i: integer; 4569 checktag, nonstring: string; 4570 begin // ********* listing one series' values is ok but no multiple ??? 5640 i: integer; 5641 checktag, checkindex, checkseries, firstdatecheck, firsttext, nonstring: string; 5642 begin 5643 firsttext := MarkText; 4571 5644 MarkText := Sender.Title; 4572 if Copy(MarkText, 1, 4) = 'Ref ' then 4573 MarkText := ''; 4574 if Sender.Title = '(non-numeric)' then 5645 if Copy(MarkText, 1, 4) = 'Ref ' then MarkText := '' 5646 else if Piece(Sender.Title, '^', 1) = '(non-numeric)' then 4575 5647 begin 4576 5648 if Sender.Tag > 0 then 4577 5649 begin 4578 checktag := inttostr(Sender.Tag); 4579 cnt := -1; 4580 for i := 0 to lstNonNumeric.Items.Count - 1 do 5650 checkseries := inttostr(Sender.Tag - BIG_NUMBER); 5651 firstdatecheck := floattostr(sender.XValue[ValueIndex]); 5652 checktag := inttostr(Sender.ParentChart.Tag); 5653 checkindex := inttostr(ValueIndex + 1); 5654 for i := 0 to GtslNonNum.Count - 1 do 4581 5655 begin 4582 nonstring := lstNonNumeric.Items[i];4583 if checktag = Piece(nonstring, '^', 3)then5656 nonstring := GtslNonNum[i]; 5657 if checktag = '0' then 4584 5658 begin 4585 cnt := cnt + 1; 4586 if cnt = ValueIndex then 5659 if checkseries = Piece(nonstring, '^', 3) then 5660 if Piece(nonstring, '^', 4) = checkindex then 5661 begin 5662 MarkText := Piece(nonstring, '^', 13); 5663 end; 5664 end 5665 else if checktag = Piece(nonstring, '^', 2) then 5666 begin 5667 if checkseries = Piece(nonstring, '^', 3) then 5668 if Piece(nonstring, '^', 4) = checkindex then 4587 5669 begin 4588 MarkText := Piece(nonstring, '^', 2);5670 MarkText := Piece(nonstring, '^', 13); 4589 5671 break; 4590 5672 end; 4591 5673 end; 4592 5674 end; 4593 if MarkText = '(non-numeric)' then4594 beep;4595 end;4596 end;5675 end; 5676 end 5677 else if Sender is TLineSeries then 5678 MarkText := firsttext; 4597 5679 end; 4598 5680 4599 5681 procedure TfrmGraphs.mnuPopGraphRemoveClick(Sender: TObject); 4600 5682 var 4601 i,selnum: integer;5683 selnum: integer; 4602 5684 aSection, typeitem: string; 4603 a ComboBox: TORComboBox;5685 aListBox: TORListBox; 4604 5686 aListView: TListView; 4605 5687 begin … … 4607 5689 if pnlTop.Tag = 1 then 4608 5690 begin 4609 a ComboBox := cboViewsTop;5691 aListBox := lstViewsTop; 4610 5692 aListView := lvwItemsTop; 4611 5693 aSection := 'top'; … … 4613 5695 else 4614 5696 begin 4615 a ComboBox := cboViewsBottom;5697 aListBox := lstViewsBottom; 4616 5698 aListView := lvwItemsBottom; 4617 5699 aSection := 'bottom'; 4618 5700 end; 4619 aComboBox.ItemIndex := -1; 4620 aComboBox.Text := ''; 5701 aListBox.ItemIndex := -1; 4621 5702 if aListView.SelCount = 0 then exit; 4622 5703 if StripHotKey(mnuPopGraphRemove.Caption) = ('Remove all selections from ' + aSection) then 4623 begin 4624 with aListView do 4625 for i := 0 to Items.Count - 1 do 4626 if Items[i].Selected then 4627 begin 4628 Items[i].Selected := false; 4629 end; 4630 DisplayData('top'); 4631 DisplayData('bottom'); 4632 end 5704 aListView.Selected := nil 4633 5705 else 4634 5706 begin … … 4636 5708 if selnum = -1 then exit; 4637 5709 aListView.Items[selnum].Selected := false; 4638 DisplayData('top');4639 DisplayData('bottom');4640 end;5710 end; 5711 DisplayData('top'); 5712 DisplayData('bottom'); 4641 5713 mnuPopGraphRemove.Enabled := false; 4642 5714 mnuPopGraphResetClick(self); … … 4656 5728 displayheight, displaynum, i: integer; 4657 5729 begin 5730 if Not Assigned(FGraphSetting) then Exit; 4658 5731 ChartOnZoom(chartDatelineTop); 4659 5732 with aScrollBox do … … 4816 5889 end; 4817 5890 5891 procedure TfrmGraphs.BorderValue(var bordervalue: double; value: double); 5892 begin 5893 if FGraphSetting.FixedDateRange then 5894 if bordervalue = -BIG_NUMBER then 5895 bordervalue := value; 5896 end; 5897 5898 procedure TfrmGraphs.BPAdd(itemvalue: string; adatetime: TDateTime; var fixeddatevalue: double; serLine, serBPDiastolic, serBPMean: TLineSeries); 5899 var 5900 value: double; 5901 valueD, valueM, valueS: string; 5902 begin 5903 valueS := Piece(itemvalue, '/', 1); 5904 valueD := Piece(itemvalue, '/', 2); 5905 valueM := Piece(itemvalue, '/', 3); 5906 value := strtofloatdef(valueS, -BIG_NUMBER); 5907 if value <> -BIG_NUMBER then 5908 serLine.AddXY(adatetime, value, '', clTeeColor); 5909 value := strtofloatdef(valueD, -BIG_NUMBER); 5910 if value <> -BIG_NUMBER then 5911 serBPDiastolic.AddXY(adatetime, value, '', clTeeColor); 5912 value := strtofloatdef(valueM, -BIG_NUMBER); 5913 if value <> -BIG_NUMBER then 5914 begin 5915 serBPMean.AddXY(adatetime, value, '', clTeeColor); 5916 serBPMean.Active := true; 5917 end; 5918 BorderValue(fixeddatevalue, 100); 5919 end; 5920 5921 procedure TfrmGraphs.BPCheck(aChart: TChart; aFileType: string; serLine, serBPDiastolic, serBPMean: TLineSeries); 5922 begin 5923 MakeSeriesBP(aChart, serLine, serBPDiastolic, aFileType); 5924 MakeSeriesBP(aChart, serLine, serBPMean, aFileType); 5925 serBPDiastolic.Active := true; 5926 serBPMean.Active := false; 5927 end; 5928 5929 procedure TfrmGraphs.PainAdd(serBlank: TPointSeries); 5930 begin 5931 begin 5932 serBlank.Active := true; 5933 serBlank.Pointer.Pen.Visible := false; 5934 serBlank.AddXY(IncDay(FGraphSetting.LowTime, -1), 0, '', pnlScrollTopBase.Color); 5935 serBlank.AddXY(IncDay(FGraphSetting.LowTime, -1), 10, '', pnlScrollTopBase.Color); 5936 end; 5937 end; 5938 5939 procedure TfrmGraphs.NumAdd(serLine: TLineSeries; value: double; adatetime: TDateTime; 5940 var fixeddatevalue, hi, lo: double; var high, low: string); 5941 begin 5942 if (btnChangeSettings.Tag = 1) and (hi <> -BIG_NUMBER) and (lo <> -BIG_NUMBER) then 5943 begin // standard deviation 5944 value := StdDev(value, hi, lo); 5945 serLine.AddXY(adatetime, value, '', clTeeColor); 5946 high := '2'; low := '-2'; 5947 BorderValue(fixeddatevalue, 0); 5948 //splGraphs.Tag := 1; // show ref range 5949 end // inverse value 5950 else if btnChangeSettings.Tag = 2 then 5951 begin 5952 value := InvVal(value); 5953 serLine.AddXY(adatetime, value, '', clTeeColor); 5954 high := '2'; low := '0'; 5955 BorderValue(fixeddatevalue, 0); 5956 splGraphs.Tag := 0; // do not show ref range 5957 end 5958 else 5959 begin // numeric value 5960 serLine.AddXY(adatetime, value, '', clTeeColor); 5961 BorderValue(fixeddatevalue, value); 5962 end; 5963 end; 5964 5965 procedure TfrmGraphs.NonNumSave(aChart: TChart; aTitle, aSection: string; adatetime: TDateTime; 5966 var noncnt: integer; newcnt, aIndex: integer); 5967 var 5968 astring: string; 5969 begin 5970 noncnt := noncnt + 1; 5971 astring := floattostr(adatetime) + '^' + inttostr(aChart.Tag) + '^' 5972 + inttostr(newcnt) + '^' + inttostr(noncnt) + '^^' + aTitle + '^' 5973 + aSection + '^^' + GtslTemp[aIndex]; 5974 GtslNonNum.Add(astring); 5975 end; 5976 4818 5977 //**************************************************************************** 4819 5978 4820 procedure TfrmGraphs.MakeLineSeries(aChart: TChart; aTitle, aFileType: string; var aSerCnt, aNonCnt: integer; multiline: boolean); 4821 4822 procedure BorderValue(var bordervalue: double; value: double); 4823 begin 4824 if FGraphSetting.FixedDateRange then 4825 if bordervalue = -BIG_NUMBER then 4826 bordervalue := value; 4827 end; 4828 4829 var 4830 estimate, firstcnt, i, noncnt: integer; 4831 value, fixeddatevalue, hi, highestvalue, highvalue, lo, nonvalue: double; 4832 checkdata, fmtime, itemvalue, valueD, valueM, valueS: string; 4833 high, low, specimen: string; 5979 procedure TfrmGraphs.MakeLineSeries(aChart: TChart; aTitle, aFileType, section: string; 5980 var aSerCnt, aNonCnt: integer; multiline: boolean); 5981 var 5982 i, noncnt, newcnt: integer; 5983 value, fixeddatevalue, hi, lo: double; 5984 checkdata, fmtime, itemvalue: string; 5985 high, low, specimen, comments: string; 4834 5986 adatetime, adatetime1: TDateTime; 4835 5987 afixeddate, afixeddate1: TDateTime; 4836 ser 1, ser2, ser3, serLow, serHigh: TLineSeries;4837 serBlank , serPoint: TPointSeries;5988 serLine, serBPDiastolic, serBPMean, serLow, serHigh: TLineSeries; 5989 serBlank: TPointSeries; 4838 5990 begin 4839 5991 fixeddatevalue := -BIG_NUMBER; 4840 highestvalue := aChart.MaxYValue(aChart.LeftAxis); 4841 if highestvalue < 1 then highestvalue := 1; 4842 firstcnt := lstNonNumeric.Items.Count; 4843 noncnt := firstcnt; 5992 noncnt := 0; //GtslNonNum.Count; 4844 5993 aChart.LeftAxis.LabelsFont.Color := aChart.BottomAxis.LabelsFont.Color; 4845 5994 aSerCnt := aSerCnt + 1; 4846 ser1 := TLineSeries.Create(aChart);4847 ser2 := TLineSeries.Create(aChart);4848 ser3 := TLineSeries.Create(aChart);4849 serPoint := TPointSeries.Create(aChart);4850 serBlank := TPointSeries.Create(aChart);4851 serLow := TLineSeries.Create(aChart);4852 serHigh := TLineSeries.Create(aChart);4853 5995 specimen := LowerCase(Piece(aTitle, '^', 4)); 4854 low := Piece(aTitle, '^', 5); // collect non numeric - graph as events5996 low := Piece(aTitle, '^', 5); 4855 5997 high := Piece(aTitle, '^', 6); 4856 5998 lo := strtofloatdef(low, -BIG_NUMBER); 4857 5999 hi := strtofloatdef(high, -BIG_NUMBER); 6000 serLine := TLineSeries.Create(aChart); 6001 newcnt := aChart.SeriesCount; 6002 serBPDiastolic := TLineSeries.Create(aChart); 6003 serBPMean := TLineSeries.Create(aChart); 6004 serLow := TLineSeries.Create(aChart); 4858 6005 serLow.Active := false; 6006 serHigh := TLineSeries.Create(aChart); 4859 6007 serHigh.Active := false; 4860 ser Point.Active := false;6008 serBlank := TPointSeries.Create(aChart); 4861 6009 serBlank.Active := false; 4862 with ser1 do 4863 begin 6010 with serLine do 6011 begin 6012 MakeSeriesInfo(aChart, serLine, aTitle, aFileType, aSerCnt); 4864 6013 LinePen.Visible := FGraphSetting.Lines; 4865 ParentChart := aChart;4866 Title := Piece(aTitle, '^', 3);4867 6014 if (length(specimen) > 0) and (not ansicontainsstr(Title, specimen)) then 4868 6015 Title := Title + ' (' + specimen + ')'; 4869 XValues.DateTime := True;4870 NextPointerStyle(ser1, aSerCnt);4871 Identifier := aFileType;4872 6016 Pointer.Visible := true; 4873 6017 Pointer.InflateMargins := true; 4874 GetData(aTitle); 4875 ColorEachPoint := false; 4876 SeriesColor := NextColor(aSerCnt); 4877 Marks.BackColor := clInfoBk; 4878 if ser1.Title = 'Blood Pressure' then 4879 begin 4880 ser1.Title := 'Blood Pressure'; 4881 with ser2 do 6018 NextPointerStyle(serLine, aSerCnt); 6019 Tag := newcnt; 6020 end; 6021 if serLine.Title = 'Blood Pressure' then 6022 BPCheck(aChart, aFileType, serLine, serBPDiastolic, serBPMean); 6023 for i:= 0 to GtslTemp.Count - 1 do 6024 begin 6025 checkdata := GtslTemp[i]; 6026 fmtime := FMCorrectedDate(Piece(checkdata, '^', 3)); 6027 if IsFMDateTime(fmtime) then 6028 begin 6029 HighLow(fmtime, '', aChart, adatetime, adatetime1); 6030 comments := Piece(checkdata, '^', 9); 6031 if strtointdef(comments, -1) > 0 then aChart.Hint := comments; // for any occurrence 6032 itemvalue := Piece(checkdata, '^', 5); 6033 itemvalue := trim(itemvalue); 6034 itemvalue := StringReplace(itemvalue, ',', '', [rfReplaceAll]); 6035 if serLine.Title = 'Blood Pressure' then 6036 BPAdd(itemvalue, adatetime, fixeddatevalue, serLine, serBPDiastolic, serBPMean) 6037 else 4882 6038 begin 4883 ParentChart := aChart; 4884 Title := 'Blood Pressure'; 4885 XValues.DateTime := true; 4886 Pointer.Style := ser1.Pointer.Style; 4887 ShowInLegend := false; //**** 4888 Identifier := aFileType; 4889 Pointer.Visible := true; 4890 Pointer.InflateMargins := true; 4891 ColorEachPoint := false; 4892 SeriesColor := ser1.SeriesColor; 4893 Marks.BackColor := clInfoBk; 4894 Active := true; 6039 value := strtofloatdef(itemvalue, -BIG_NUMBER); 6040 if value <> -BIG_NUMBER then 6041 NumAdd(serLine, value, adatetime, fixeddatevalue, hi, lo, high, low) 6042 else 6043 NonNumSave(aChart, serLine.Title, section, adatetime, noncnt, newcnt, i); 4895 6044 end; 4896 with ser3 do 4897 begin 4898 ParentChart := aChart; 4899 Title := 'Blood Pressure'; 4900 XValues.DateTime := true; 4901 Pointer.Style := ser1.Pointer.Style; 4902 ShowInLegend := false; //**** 4903 Identifier := aFileType; 4904 Pointer.Visible := true; 4905 Pointer.InflateMargins := true; 4906 ColorEachPoint := false; 4907 SeriesColor := ser1.SeriesColor; 4908 Marks.BackColor := clInfoBk; 4909 Active := false; 4910 end; 4911 end 4912 else 4913 begin 4914 ser2.Active := false; 4915 ser3.Active := false; 4916 end; 4917 highvalue := 0; 4918 with lstTemp do 4919 for i:= 0 to Items.Count - 1 do 4920 begin 4921 checkdata := lstTemp.Items[i]; 4922 fmtime := FMCorrectedDate(Piece(Items[i], '^', 3)); 4923 if IsFMDateTime(fmtime) then 4924 begin 4925 HighLow(fmtime, '', aChart, adatetime, adatetime1); 4926 itemvalue := Piece(Items[i], '^', 5); 4927 itemvalue := trim(itemvalue); 4928 itemvalue := StringReplace(itemvalue, ',', '', [rfReplaceAll]); 4929 if ser1.Title = 'Blood Pressure' then 4930 begin 4931 valueS := Piece(itemvalue, '/', 1); 4932 valueD := Piece(itemvalue, '/', 2); 4933 valueM := Piece(itemvalue, '/', 3); 4934 value := strtofloatdef(valueS, -BIG_NUMBER); 4935 if value <> -BIG_NUMBER then 4936 ser1.AddXY(adatetime, value, '', clTeeColor); 4937 value := strtofloatdef(valueD, -BIG_NUMBER); 4938 if value <> -BIG_NUMBER then 4939 ser2.AddXY(adatetime, value, '', clTeeColor); 4940 value := strtofloatdef(valueM, -BIG_NUMBER); 4941 if value <> -BIG_NUMBER then 4942 begin 4943 ser3.AddXY(adatetime, value, '', clTeeColor); 4944 ser3.Active := true; 4945 end; 4946 BorderValue(fixeddatevalue, 100); 4947 end 4948 else 4949 begin 4950 value := strtofloatdef(itemvalue, -BIG_NUMBER); 4951 if value <> -BIG_NUMBER then 4952 begin 4953 if (btnChangeSettings.Tag = 1) and (hi <> -BIG_NUMBER) and (lo <> -BIG_NUMBER) then 4954 begin 4955 value := StdDev(value, hi, lo); 4956 ser1.AddXY(adatetime, value, '', clTeeColor); 4957 high := '2'; low := '-2'; 4958 BorderValue(fixeddatevalue, 0); 4959 //splGraphs.Tag := 1; // show ref range 4960 end 4961 else if btnChangeSettings.Tag = 2 then 4962 begin 4963 value := InvVal(value); 4964 ser1.AddXY(adatetime, value, '', clTeeColor); 4965 high := '2'; low := '0'; 4966 BorderValue(fixeddatevalue, 0); 4967 splGraphs.Tag := 0; // do not show ref range 4968 end 4969 else 4970 begin 4971 ser1.AddXY(adatetime, value, '', clTeeColor); 4972 if value > highvalue then 4973 highvalue := value; 4974 BorderValue(fixeddatevalue, value); 4975 end; 4976 end 4977 else 4978 begin 4979 noncnt := noncnt + 1; 4980 lstNonNumeric.Items.Add(floattostr(adatetime) + '^' + 4981 itemvalue + '^' + inttostr(aNonCnt + 1)); 4982 end; 4983 end; 4984 end; 4985 end; 4986 if (length(low) > 0) and (splGraphs.Tag = 1) then 4987 begin 4988 with serLow do 4989 begin 4990 Active := true; 4991 ParentChart := aChart; 4992 XValues.DateTime := True; 4993 Pointer.Visible := false; 4994 Pointer.InflateMargins := true; 4995 OnGetMarkText := serDatelineTop.OnGetMarkText; 4996 ColorEachPoint := false; 4997 Title := 'Ref Low ' + low; 4998 Pointer.Style := psCircle; 4999 SeriesColor := ser1.SeriesColor; //clBtnShadow ; //clTeeColor; 5000 Marks.Visible := false; 5001 LinePen.Visible := true; 5002 LinePen.Width := 2; 5003 LinePen.Style := psDash; //does not show when width <> 1 5004 end; 5005 value := strtofloatdef(low, -BIG_NUMBER); 5006 if value <> -BIG_NUMBER then 5007 begin 5008 serLow.AddXY(IncDay(FGraphSetting.LowTime, -1), value, '', clTeeColor); 5009 serLow.AddXY(IncDay(FGraphSetting.HighTime, 1), value, '', clTeeColor); 5010 BorderValue(fixeddatevalue, value); 5011 end; 5012 end; 5013 if (length(high) > 0) and (splGraphs.Tag = 1) then 5014 begin 5015 with serHigh do 5016 begin 5017 Active := true; 5018 ParentChart := aChart; 5019 XValues.DateTime := True; 5020 Pointer.Visible := false; 5021 Pointer.InflateMargins := true; 5022 OnGetMarkText := serDatelineTop.OnGetMarkText; 5023 ColorEachPoint := false; 5024 Title := 'Ref High ' + high; 5025 Pointer.Style := psCircle; 5026 SeriesColor := ser1.SeriesColor; // clBtnShadow; //clTeeColor; 5027 Marks.Visible := false; 5028 LinePen.Visible := true; 5029 LinePen.Width := 2; 5030 LinePen.Style := psDash; //does not show when width <> 1 5031 end; 5032 value := strtofloatdef(high, -BIG_NUMBER); 5033 if value <> -BIG_NUMBER then 5034 begin 5035 serHigh.AddXY(IncDay(FGraphSetting.LowTime, -1), value, '', clTeeColor); 5036 serHigh.AddXY(IncDay(FGraphSetting.HighTime, 1), value, '', clTeeColor); 5037 BorderValue(fixeddatevalue, value); 5038 end; 5039 end; 5040 splGraphs.Tag := 0; 5041 if noncnt > firstcnt then 5042 begin 5043 if aChart.Height < 10 then estimate := pnlMain.Height div 2 5044 else estimate := aChart.Height; 5045 aNonCnt := aNonCnt + 1; // use nonnumeric count to offset position 5046 nonvalue := (aNonCnt * (10 / (estimate + 1)) * highestvalue); 5047 with serBlank do 5048 begin 5049 Active := true; 5050 ParentChart := aChart; 5051 XValues.DateTime := True; 5052 Pointer.Visible := true; 5053 Pointer.InflateMargins := true; 5054 OnGetMarkText := serDatelineTop.OnGetMarkText; 5055 ColorEachPoint := false; 5056 Title := ''; 5057 Pointer.Style := psSmallDot; 5058 SeriesColor := aChart.Color; 5059 Marks.Visible := false; 5060 ShowInLegend := false; 5061 end; 5062 with serPoint do 5063 begin 5064 Active := true; 5065 ParentChart := aChart; 5066 XValues.DateTime := True; 5067 Pointer.Visible := true; 5068 Pointer.InflateMargins := true; 5069 OnGetMarkText := serDatelineTop.OnGetMarkText; 5070 ColorEachPoint := false; 5071 Title := '(non-numeric)'; 5072 Hint := aTitle; 5073 Tag := aNonCnt; 5074 Pointer.Style := ser1.Pointer.Style; 5075 SeriesColor := ser1.SeriesColor; 5076 Marks.BackColor := clInfoBk; 5077 ShowInLegend := false; 5078 end; 5079 for i := 0 to lstNonNumeric.Items.Count - 1 do 5080 begin 5081 if Piece(lstNonNumeric.Items[i], '^',3) = inttostr(aNonCnt) then 5082 if highvalue = 0 then 5083 begin 5084 adatetime := strtofloatdef(Piece(lstNonNumeric.Items[i], '^', 1), -BIG_NUMBER); 5085 if adatetime <> -BIG_NUMBER then 5086 begin 5087 serBlank.Pointer.Pen.Visible := false; 5088 serBlank.AddXY(adatetime, 1, '', pnlScrollTopBase.Color); 5089 break; 5090 end; 5091 end; 5092 end; 5093 for i := 0 to lstNonNumeric.Items.Count - 1 do 5094 if Piece(lstNonNumeric.Items[i], '^',3) = inttostr(aNonCnt) then 5095 begin 5096 adatetime := strtofloatdef(Piece(lstNonNumeric.Items[i], '^', 1), -BIG_NUMBER); 5097 if adatetime <> -BIG_NUMBER then 5098 begin 5099 serPoint.Pointer.Pen.Visible := true; 5100 serPoint.AddXY(adatetime, nonvalue, '', ser1.SeriesColor); 5101 BorderValue(fixeddatevalue, nonvalue); 5102 end; 5103 end; 5104 if highvalue = 0 then 5105 begin 5106 aChart.LeftAxis.LabelsFont.Color := pnlScrollTopBase.Color; 5107 FNonNumerics := true; 5108 end; 5109 end; 5110 if ser1.Title = 'Pain' then 5111 begin 5112 if not serBlank.Active then 5113 with serBlank do 5114 begin 5115 Active := true; 5116 ParentChart := aChart; 5117 XValues.DateTime := True; 5118 Pointer.Visible := true; 5119 Pointer.InflateMargins := true; 5120 OnGetMarkText := serDatelineTop.OnGetMarkText; 5121 ColorEachPoint := false; 5122 Title := ''; 5123 Pointer.Style := psSmallDot; 5124 SeriesColor := aChart.Color; 5125 Marks.Visible := false; 5126 ShowInLegend := false; 5127 end; 5128 serBlank.Pointer.Pen.Visible := false; 5129 serBlank.AddXY(IncDay(FGraphSetting.LowTime, -1), 0, '', pnlScrollTopBase.Color); 5130 serBlank.AddXY(IncDay(FGraphSetting.LowTime, -1), 10, '', pnlScrollTopBase.Color); 5131 end; 5132 if multiline then 5133 begin 5134 // do nothing for now 5135 end; 5136 if fixeddatevalue <> -BIG_NUMBER then 5137 begin 5138 if not serBlank.Active then 5139 with serBlank do 5140 begin 5141 Active := true; 5142 ParentChart := aChart; 5143 XValues.DateTime := True; 5144 Pointer.Visible := true; 5145 Pointer.InflateMargins := true; 5146 OnGetMarkText := serDatelineTop.OnGetMarkText; 5147 ColorEachPoint := false; 5148 Title := ''; 5149 Pointer.Style := psSmallDot; 5150 SeriesColor := aChart.Color; 5151 Marks.Visible := false; 5152 ShowInLegend := false; 5153 end; 5154 FixedDates(afixeddate, afixeddate1); 5155 serBlank.Pointer.Pen.Visible := false; 5156 serBlank.AddXY(afixeddate, fixeddatevalue, '', aChart.Color); 5157 serBlank.AddXY(afixeddate1, fixeddatevalue, '', aChart.Color); 5158 end; 5159 GetHorizAxis.ExactDateTime := True; 5160 GetHorizAxis.Increment := DateTimeStep[dtOneMinute]; 6045 end; 6046 end; 6047 if (length(low) > 0) and (splGraphs.Tag = 1) then 6048 MakeSeriesRef(aChart, serLine, serLow, 'Ref Low ', low, fixeddatevalue); 6049 if (length(high) > 0) and (splGraphs.Tag = 1) then 6050 MakeSeriesRef(aChart, serLine, serHigh, 'Ref High ', high, fixeddatevalue); 6051 splGraphs.Tag := 0; 6052 MakeSeriesPoint(aChart, serBlank); 6053 if serLine.Title = 'Pain' then 6054 PainAdd(serBlank); 6055 if multiline then 6056 begin 6057 // do nothing for now 6058 end; 6059 if fixeddatevalue <> -BIG_NUMBER then 6060 begin 6061 serBlank.Active := true; 6062 serBlank.Pointer.Pen.Visible := false; 6063 FixedDates(afixeddate, afixeddate1); 6064 serBlank.AddXY(afixeddate, fixeddatevalue, '', aChart.Color); 6065 serBlank.AddXY(afixeddate1, fixeddatevalue, '', aChart.Color); 5161 6066 end; 5162 6067 end; … … 5168 6073 fmtime: string; 5169 6074 adatetime, adatetime1: TDateTime; 5170 ser 1: TPointSeries;6075 serPoint: TPointSeries; 5171 6076 begin 5172 6077 aSerCnt := aSerCnt + 1; 5173 ser1 := TPointSeries.Create(aChart); 5174 with ser1 do 5175 begin 5176 ParentChart := aChart; 5177 Title := Piece(aTitle, '^', 3); 5178 OnGetMarkText := serDatelineTop.OnGetMarkText; 5179 XValues.DateTime := True; 5180 NextPointerStyle(ser1, aSerCnt); 6078 serPoint := TPointSeries.Create(aChart); 6079 MakeSeriesInfo(aChart, serPoint, aTitle, aFileType, aSerCnt); 6080 with serPoint do 6081 begin 6082 NextPointerStyle(serPoint, aSerCnt); 6083 Pointer.Visible := true; 6084 Pointer.InflateMargins := true; 6085 Pointer.Style := psSmallDot; 6086 Pointer.Pen.Visible := true; 5181 6087 Pointer.VertSize := 10; 5182 6088 Pointer.HorizSize := 2; 5183 Identifier := aFileType; 5184 Pointer.Visible := true; 5185 GetData(aTitle); 5186 ColorEachPoint := false; 5187 SeriesColor := NextColor(aSerCnt); 5188 Marks.BackColor := clInfoBk; 5189 with lstTemp do 5190 for i := 0 to lstTemp.Items.Count - 1 do 5191 begin 5192 fmtime := FMCorrectedDate(Piece(Items[i], '^', 3)); 6089 for i := 0 to GtslTemp.Count - 1 do 6090 begin 6091 fmtime := FMCorrectedDate(Piece(GtslTemp[i], '^', 3)); 5193 6092 if IsFMDateTime(fmtime) then 5194 6093 begin 5195 6094 HighLow(fmtime, '', aChart, adatetime, adatetime1); 5196 value := strtofloatdef(Piece( Items[i], '^', 5), -BIG_NUMBER);6095 value := strtofloatdef(Piece(GtslTemp[i], '^', 5), -BIG_NUMBER); 5197 6096 if value = -BIG_NUMBER then 5198 6097 begin 5199 6098 value := aSerCnt; 5200 TempCheck(Pieces( Items[i], '^', 1, 2), value);6099 TempCheck(Pieces(GtslTemp[i], '^', 1, 2), value); 5201 6100 end; 5202 ser 1.AddXY(adatetime, value, '', clTeeColor);6101 serPoint.AddXY(adatetime, value, '', clTeeColor); 5203 6102 end; 5204 6103 end; 5205 GetHorizAxis.ExactDateTime := True;5206 GetHorizAxis.Increment := DateTimeStep[dtOneMinute];5207 6104 end; 5208 6105 end; … … 5215 6112 adatetime, adatetime1: TDateTime; 5216 6113 afixeddate, afixeddate1: TDateTime; 5217 ser 1: TBarSeries;6114 serBar: TBarSeries; 5218 6115 serBlank: TPointSeries; 5219 6116 begin 5220 6117 aSerCnt := aSerCnt + 1; 5221 ser1 := TBarSeries.Create(aChart);5222 6118 serBlank := TPointSeries.Create(aChart); 5223 with serBlank do 5224 begin 5225 Active := true; 5226 ParentChart := aChart; 5227 XValues.DateTime := True; 5228 Pointer.Visible := true; 5229 Pointer.InflateMargins := false; 5230 ColorEachPoint := false; 5231 Title := ''; 5232 Pointer.Style := psSmallDot; 5233 OnGetMarkText := serDatelineTop.OnGetMarkText; 5234 SeriesColor := aChart.Color; 5235 Marks.BackColor := clInfoBk; 5236 ShowInLegend := false; 5237 end; 5238 with ser1 do 5239 begin 5240 ParentChart := aChart; 5241 Title := Piece(aTitle, '^', 3); 5242 XValues.DateTime := True; 6119 MakeSeriesPoint(aChart, serBlank); 6120 serBar := TBarSeries.Create(aChart); 6121 MakeSeriesInfo(aChart, serBar, aTitle, aFileType, aSerCnt); 6122 with serBar do 6123 begin 5243 6124 YOrigin := 0; 5244 Identifier := aFileType;5245 Marks.Visible := false;5246 OnGetMarkText := serDatelineTop.OnGetMarkText;5247 6125 CustomBarWidth := 7; 5248 Marks.Style := smsLabel; 5249 GetData(aTitle); 5250 ColorEachPoint := false; 5251 SeriesColor := NextColor(aSerCnt); 5252 Marks.BackColor := clInfoBk; 5253 NextPointerStyle(ser1, aSerCnt); 5254 with lstTemp do 5255 for i:= 0 to Items.Count - 1 do 5256 begin 5257 fmtime := FMCorrectedDate(Piece(Items[i], '^', 3)); 6126 NextPointerStyle(serBar, aSerCnt); 6127 for i:= 0 to GtslTemp.Count - 1 do 6128 begin 6129 fmtime := FMCorrectedDate(Piece(GtslTemp[i], '^', 3)); 5258 6130 if IsFMDateTime(fmtime) then 5259 6131 begin … … 5263 6135 if copy((FPrevEvent + '00'), 1, 12) = copy(fmtime, 1, 12) then // same time occurrence 5264 6136 begin 5265 pnlInfo.Caption := TXT_WARNING_SAME_TIME; 5266 pnlInfo.Color := COLOR_WARNING; 5267 pnlInfo.Visible := true; 6137 InfoMessage(TXT_WARNING_SAME_TIME, COLOR_WARNING, true); 5268 6138 pnlHeader.Visible := true; 5269 6139 FWarning := true; 5270 6140 end; 5271 6141 if value <> -BIG_NUMBER then 5272 ser 1.AddXY(adatetime, value, '', clTeeColor);6142 serBar.AddXY(adatetime, value, '', clTeeColor); 5273 6143 FPrevEvent := copy(fmtime, 1, 10); 5274 6144 if i = 0 then … … 5285 6155 end; 5286 6156 end; 5287 GetHorizAxis.ExactDateTime := True; 5288 GetHorizAxis.Increment := DateTimeStep[dtOneMinute]; 5289 end; 5290 end; 5291 5292 procedure TfrmGraphs.MakeManyGanttSeries(aChart: TChart; aTitle, aFileType: string; var aSerCnt: integer); 6157 end; 6158 end; 6159 6160 procedure TfrmGraphs.MakeGanttSeries(aChart: TChart; aTitle, aFileType: string; var aSerCnt: integer); 5293 6161 var 5294 6162 i, value: integer; … … 5296 6164 adatetime, adatetime1: TDateTime; 5297 6165 afixeddate, afixeddate1: TDateTime; 5298 gantt: TGanttSeries;6166 serGantt: TGanttSeries; 5299 6167 serBlank: TPointSeries; 5300 6168 begin 5301 6169 aSerCnt := aSerCnt + 1; 5302 gantt := TGanttSeries.Create(aChart);5303 6170 serBlank := TPointSeries.Create(aChart); 5304 with serBlank do 5305 begin 5306 Active := true; 5307 ParentChart := aChart; 5308 XValues.DateTime := True; 5309 Pointer.Visible := true; 5310 Pointer.InflateMargins := false; 5311 ColorEachPoint := false; 5312 Title := ''; 5313 Pointer.Style := psSmallDot; 5314 OnGetMarkText := serDatelineTop.OnGetMarkText; 5315 SeriesColor := aChart.Color; 5316 Marks.BackColor := clInfoBk; 5317 ShowInLegend := false; 5318 end; 5319 with gantt do 5320 begin 5321 ParentChart := aChart; 5322 Title := Piece(aTitle, '^', 3); 5323 Marks.Style := smsLabel; 5324 OnGetMarkText := serDatelineTop.OnGetMarkText; 6171 MakeSeriesPoint(aChart, serBlank); 6172 serGantt := TGanttSeries.Create(aChart); 6173 MakeSeriesInfo(aChart, serGantt, aTitle, aFileType, aSerCnt); 6174 with serGantt do 6175 begin 5325 6176 if Piece(aTitle, '^', 1) = '55' then // make inpatient meds smaller to identify 5326 6177 Pointer.VertSize := RX_HEIGHT_IN … … 5331 6182 else 5332 6183 Pointer.VertSize := RX_HEIGHT_OUT; 5333 GetData(aTitle);5334 ColorEachPoint := false;5335 SeriesColor := NextColor(aSerCnt);5336 Identifier := aFileType;5337 Marks.BackColor := clInfoBk;5338 6184 value := round(((aSerCnt mod NUM_COLORS) / NUM_COLORS) * 80) + 20 + aSerCnt; 5339 6185 if aFileType <> '9999911' then 5340 6186 if aChart <> chartDatelineTop then 5341 6187 if aChart <> chartDatelineBottom then 5342 value := value - 26; 5343 with lstTemp do 5344 for i := 0 to lstTemp.Items.Count - 1 do 5345 begin 5346 fmtime := FMCorrectedDate(Piece(Items[i], '^', 3)); 5347 fmtime1 := FMCorrectedDate(Piece(Items[i], '^', 4)); 6188 value := value - 26; 6189 for i := 0 to GtslTemp.Count - 1 do 6190 begin 6191 fmtime := FMCorrectedDate(Piece(GtslTemp[i], '^', 3)); 6192 fmtime1 := FMCorrectedDate(Piece(GtslTemp[i], '^', 4)); 5348 6193 if IsFMDateTime(fmtime) and IsFMDateTime(fmtime1) then 5349 6194 begin … … 5365 6210 end; 5366 6211 end; 5367 GetHorizAxis.ExactDateTime := True;5368 GetHorizAxis.Increment := DateTimeStep[dtOneMinute];5369 6212 end; 5370 6213 end; … … 5377 6220 adatetime, adatetime1: TDateTime; 5378 6221 afixeddate, afixeddate1: TDateTime; 5379 gantt: TGanttSeries;6222 serGantt: TGanttSeries; 5380 6223 serBlank: TPointSeries; 5381 6224 begin 5382 6225 aSerCnt := aSerCnt + 1; 5383 gantt := TGanttSeries.Create(aChart);5384 6226 serBlank := TPointSeries.Create(aChart); 5385 with serBlank do 5386 begin 5387 Active := true; 5388 ParentChart := aChart; 5389 XValues.DateTime := True; 5390 Pointer.Visible := true; 5391 Pointer.InflateMargins := false; 5392 ColorEachPoint := false; 5393 Title := ''; 5394 Pointer.Style := psSmallDot; 5395 OnGetMarkText := serDatelineTop.OnGetMarkText; 5396 SeriesColor := aChart.Color; 5397 Marks.Visible := false; 5398 ShowInLegend := false; 5399 end; 5400 with gantt do 5401 begin 5402 ParentChart := aChart; 5403 Title := Piece(aTitle, '^', 3); 5404 Marks.Style := smsLabel; 5405 OnGetMarkText := serDatelineTop.OnGetMarkText; 6227 MakeSeriesPoint(aChart, serBlank); 6228 serGantt := TGanttSeries.Create(aChart); 6229 MakeSeriesInfo(aChart, serGantt, aTitle, aFileType, aSerCnt); 6230 with serGantt do 6231 begin 5406 6232 if Piece(aTitle, '^', 1) = '405' then // make admit smaller to identify 5407 6233 Pointer.VertSize := NUM_COLORS + 3 … … 5410 6236 else 5411 6237 Pointer.VertSize := NUM_COLORS + (aSerCnt mod NUM_COLORS) + 10; 5412 GetData(aTitle);5413 ColorEachPoint := false;5414 SeriesColor := NextColor(aSerCnt);5415 Identifier := aFileType;5416 Marks.BackColor := clInfoBk;5417 6238 value := aSerCnt div NUM_COLORS; 5418 with lstTemp do 5419 for i:= 0 to Items.Count - 1 do 5420 begin 5421 fmtime := FMCorrectedDate(Piece(Items[i], '^', 3)); 5422 fmtime1 := FMCorrectedDate(Piece(Items[i], '^', 4)); 6239 for i:= 0 to GtslTemp.Count - 1 do 6240 begin 6241 fmtime := FMCorrectedDate(Piece(GtslTemp[i], '^', 3)); 6242 fmtime1 := FMCorrectedDate(Piece(GtslTemp[i], '^', 4)); 5423 6243 if IsFMDateTime(fmtime) and IsFMDateTime(fmtime1) then 5424 6244 begin … … 5438 6258 end; 5439 6259 end; 5440 GetHorizAxis.ExactDateTime := True;5441 GetHorizAxis.Increment := DateTimeStep[dtOneMinute];5442 end;5443 end;5444 5445 procedure TfrmGraphs.MakeWeightedGanttSeries(aChart: TChart; aTitle, aFileType: string; var aSerCnt: integer);5446 var5447 i: integer;5448 value: double;5449 fmtime, fmtime1: string;5450 gantt: TGanttSeries;5451 adatetime, adatetime1: TDateTime;5452 begin5453 aSerCnt := aSerCnt + 1;5454 gantt := TGanttSeries.Create(aChart);5455 with gantt do5456 begin5457 ParentChart := aChart;5458 Title := Piece(aTitle, '^', 3);5459 Marks.Style := smsLabel;5460 OnGetMarkText := serDatelineTop.OnGetMarkText;5461 value := NUM_COLORS;5462 GetData(aTitle);5463 ColorEachPoint := false;5464 SeriesColor := NextColor(aSerCnt);5465 Identifier := aFileType;5466 Marks.BackColor := clInfoBk;5467 with lstTemp do5468 for i:= 0 to Items.Count - 1 do5469 begin5470 fmtime := FMCorrectedDate(Piece(Items[i], '^', 3));5471 fmtime1 := FMCorrectedDate(Piece(Items[i], '^', 4));5472 if IsFMDateTime(fmtime) and IsFMDateTime(fmtime1) then5473 begin5474 HighLow(fmtime, fmtime1, aChart, adatetime, adatetime1);5475 value := Vfactor(Piece(aTitle, '^', 3));5476 AddGantt(adatetime, adatetime1, 1, '');5477 value := value + (value / 2);5478 end;5479 end;5480 Pointer.VertSize := round(value);5481 GetHorizAxis.ExactDateTime := True;5482 GetHorizAxis.Increment := DateTimeStep[dtOneMinute];5483 end;5484 end;5485 5486 procedure TfrmGraphs.MakeArrowSeries(aChart: TChart; aTitle, aFileType: string; var aSerCnt: integer);5487 var5488 i: integer;5489 value: double;5490 fmtime, fmtime1: string;5491 arrows: TArrowSeries;5492 adatetime, adatetime1: TDateTime;5493 begin5494 aSerCnt := aSerCnt + 1;5495 arrows := TArrowSeries.Create(aChart);5496 with arrows do5497 begin5498 ParentChart := aChart;5499 Title := Piece(aTitle, '^', 3);5500 Clear;5501 ArrowWidth := 12;5502 ArrowHeight := 9;5503 StartXValues.DateTime := true;5504 EndXValues.DateTime := true;5505 Marks.Style := smsLabel;5506 OnGetMarkText := serDatelineTop.OnGetMarkText;5507 Pointer.Visible := false;5508 Pointer.VertSize := 17; //pnlTop.Height; //******* for meds5509 Pointer.HorizSize := 24;5510 Pointer.InflateMargins := true;5511 GetData(aTitle);5512 ColorEachPoint := false;5513 SeriesColor := NextColor(aSerCnt);5514 Identifier := aFileType;5515 Marks.BackColor := clInfoBk;5516 with lstTemp do5517 for i:= 0 to Items.Count - 1 do5518 begin5519 fmtime := FMCorrectedDate(Piece(Items[i], '^', 3));5520 fmtime1 := FMCorrectedDate(Piece(Items[i], '^', 4));5521 if IsFMDateTime(fmtime) and IsFMDateTime(fmtime1) then5522 begin5523 HighLow(fmtime, fmtime1, aChart, adatetime, adatetime1);5524 value := strtofloatdef(Piece(Items[i], '^', 5), -BIG_NUMBER);5525 if value = -BIG_NUMBER then5526 TempCheck(Pieces(Items[i], '^', 1, 2), value);5527 AddArrow(adatetime, value, adatetime1, value, '', SeriesColor);5528 end;5529 end;5530 GetHorizAxis.ExactDateTime := True;5531 GetHorizAxis.Increment := DateTimeStep[dtOneMinute];5532 end;5533 end;5534 5535 procedure TfrmGraphs.MakeWeightedArrowSeries(aChart: TChart; aTitle, aFileType: string; var aSerCnt: integer);5536 var5537 i: integer;5538 value: double;5539 fmtime, fmtime1: string;5540 adatetime, adatetime1: TDateTime;5541 arrows: TArrowSeries;5542 begin5543 aSerCnt := aSerCnt + 1;5544 arrows := TArrowSeries.Create(aChart);5545 with arrows do5546 begin5547 ParentChart := aChart;5548 Title := Piece(aTitle, '^', 3);5549 Clear;5550 ArrowWidth := 12;5551 ArrowHeight := 9;5552 StartXValues.DateTime := true;5553 EndXValues.DateTime := true;5554 Marks.Style := smsLabel;5555 OnGetMarkText := serDatelineTop.OnGetMarkText;5556 Pointer.Visible := false;5557 Pointer.VertSize := 17; //pnlTop.Height; //******* for meds5558 Pointer.HorizSize := 24;5559 Pointer.InflateMargins := true;5560 GetData(aTitle);5561 ColorEachPoint := false;5562 SeriesColor := NextColor(aSerCnt);5563 Identifier := aFileType;5564 Marks.BackColor := clInfoBk;5565 with lstTemp do5566 for i:= 0 to Items.Count - 1 do5567 begin5568 fmtime := FMCorrectedDate(Piece(Items[i], '^', 3));5569 fmtime1 := FMCorrectedDate(Piece(Items[i], '^', 4));5570 if IsFMDateTime(fmtime) and IsFMDateTime(fmtime1) then5571 begin5572 HighLow(fmtime, fmtime1, aChart, adatetime, adatetime1);5573 value := strtofloatdef(Piece(Items[i], '^', 5), -BIG_NUMBER);5574 if value = -BIG_NUMBER then5575 TempCheck(Pieces(Items[i], '^', 1, 2), value);5576 AddArrow(adatetime, value, adatetime1, value, '', SeriesColor);5577 end;5578 end;5579 value := Vfactor(Piece(aTitle, '^', 3));5580 if value < 1 then value := 1;5581 Pointer.HorizSize := round(value);5582 GetHorizAxis.ExactDateTime := True;5583 GetHorizAxis.Increment := DateTimeStep[dtOneMinute];5584 end;5585 end;5586 5587 procedure TfrmGraphs.MakeGanttSeries(aChart: TChart; aTitle, aFileType: string; var aSerCnt: integer);5588 var5589 i: integer;5590 value: double;5591 fmtime, fmtime1: string;5592 adatetime, adatetime1: TDateTime;5593 gantt: TGanttSeries;5594 begin5595 aSerCnt := aSerCnt + 1;5596 gantt := TGanttSeries.Create(aChart);5597 with gantt do5598 begin5599 ParentChart := aChart;5600 Title := Piece(aTitle, '^', 3);5601 Marks.Style := smsLabel;5602 OnGetMarkText := serDatelineTop.OnGetMarkText;5603 Pointer.VertSize := pnlTop.Height; //******* like vertical bars5604 GetData(aTitle);5605 ColorEachPoint := false;5606 SeriesColor := NextColor(aSerCnt);5607 Identifier := aFileType;5608 Marks.BackColor := clInfoBk;5609 with lstTemp do5610 for i:= 0 to Items.Count - 1 do5611 begin5612 fmtime := FMCorrectedDate(Piece(Items[i], '^', 3));5613 fmtime1 := FMCorrectedDate(Piece(Items[i], '^', 4));5614 if IsFMDateTime(fmtime) and IsFMDateTime(fmtime1) then5615 begin5616 HighLow(fmtime, fmtime1, aChart, adatetime, adatetime1);5617 value := strtofloatdef(Piece(Items[i], '^', 5), -BIG_NUMBER);5618 if value = -BIG_NUMBER then5619 TempCheck(Pieces(Items[i], '^', 1, 2), value);5620 AddGantt(adatetime, adatetime1, 1, '');5621 end;5622 end;5623 GetHorizAxis.ExactDateTime := True;5624 GetHorizAxis.Increment := DateTimeStep[dtOneMinute];5625 end;5626 end;5627 5628 procedure TfrmGraphs.MakeAGanttSeries(aChart: TChart; aTitle, aFileType: string; var aSerCnt: integer);5629 var5630 i: integer;5631 value: double;5632 fmtime, fmtime1: string;5633 gantt: TGanttSeries;5634 adatetime, adatetime1: TDateTime;5635 begin5636 aSerCnt := aSerCnt + 1;5637 if aChart = chartDatelineTop then5638 gantt := serDatelineTop5639 else5640 gantt := serDatelineBottom;5641 with gantt do5642 begin5643 ParentChart := aChart;5644 Active := true;5645 Title := Piece(aTitle, '^', 3);5646 Marks.Style := smsLabel;5647 OnGetMarkText := serDatelineTop.OnGetMarkText;5648 //Pointer.VertSize := pnlTop.Height; //******* for meds5649 GetData(aTitle);5650 Identifier := aFileType;5651 ColorEachPoint := True;5652 with lstTemp do5653 for i:= 0 to Items.Count - 1 do5654 begin5655 fmtime := FMCorrectedDate(Piece(Items[i], '^', 3));5656 fmtime1 := FMCorrectedDate(Piece(Items[i], '^', 4));5657 if IsFMDateTime(fmtime) and IsFMDateTime(fmtime1) then5658 begin5659 HighLow(fmtime, fmtime1, aChart, adatetime, adatetime1);5660 value := strtofloatdef(Piece(Items[i], '^', 5), -BIG_NUMBER);5661 if value = -BIG_NUMBER then5662 TempCheck(Pieces(Items[i], '^', 1, 2), value);5663 AddGantt(adatetime, adatetime1, aSerCnt, '');5664 end;5665 end;5666 GetHorizAxis.ExactDateTime := True;5667 GetHorizAxis.Increment := DateTimeStep[dtOneMinute];5668 6260 end; 5669 6261 end; … … 5675 6267 end; 5676 6268 5677 function TfrmGraphs.ValueText(Sender: TCustomChart; Series: TChartSeries; ValueIndex: Integer): string; 6269 function TfrmGraphs.NonNumText(listnum , seriesnum, valueindex: integer): string; 6270 var 6271 ok: boolean; 6272 i: integer; 6273 nonvalue, date1, resultdate, otherdate: string; 6274 datestart: double; 6275 charttag, filename, typeitemname, filenum, itemnum, specimen, seriescheck, value: string; 6276 begin 6277 ok := false; 6278 seriescheck := inttostr(seriesnum - BIG_NUMBER); 6279 charttag := inttostr(listnum); 6280 for i := 0 to GtslNonNum.Count - 1 do 6281 begin 6282 nonvalue := GtslNonNum[i]; 6283 if Piece(nonvalue, '^', 2) = charttag then 6284 if Piece(nonvalue, '^', 3) = seriescheck then 6285 if Piece(nonvalue, '^', 4) = inttostr(valueindex + 1) then 6286 begin 6287 ok := true; 6288 break; 6289 end; 6290 end; 6291 if not ok then 6292 begin 6293 Result := ''; 6294 exit; 6295 end; 6296 date1 := Piece(nonvalue, '^', 1); 6297 filenum := Piece(nonvalue, '^', 9); 6298 itemnum := Piece(nonvalue, '^', 10); 6299 value := Piece(nonvalue, '^', 13); 6300 specimen := Piece(nonvalue, '^', 16); 6301 filename := FileNameX(filenum); 6302 typeitemname := MixedCase(ItemName(filenum, itemnum)); 6303 if length(specimen) > 0 then 6304 typeitemname := typeitemname + ' (' + LowerCase(specimen) + ')'; 6305 datestart := strtofloat(date1); 6306 resultdate := FormatDateTime('mmm d, yyyy h:nn am/pm', datestart); 6307 otherdate := FormatDateTime('mm/dd/yy hh:nn', datestart); 6308 Result := filenum + '^' +filename + '^' + resultdate + '^' 6309 + typeitemname + '^' + value + '^' + otherdate; 6310 end; 6311 6312 function TfrmGraphs.ValueText(Sender: TCustomChart; aSeries: TChartSeries; ValueIndex: Integer): string; 5678 6313 var // type#^typename^formatdate^itemname^result^date 5679 i, offset, SeriesNum, selnum: integer; 5680 dateend, datestart: double; 5681 astring, datecheck, filetype, fmdatecheck, item, otherdate, partitem: string; 5682 resultdate, results, seriestitle, typeitem, typename, typenum: string; 5683 begin 6314 OKToUse: boolean; 6315 i, SeriesNum, selnum, chartnum: integer; 6316 filetype, otherdate: string; 6317 resultdate, resultstring, seriestitle, typeitem, typename, typenum: string; 6318 begin 6319 Result := ''; 5684 6320 SeriesNum := -1; 5685 for i := 0 to Sender.SeriesCount -1 do 5686 if Sender.Series[i] = Series then 5687 begin 5688 SeriesNum := i; 5689 filetype := Sender.Series[i].Identifier; 5690 break; 5691 end; 5692 seriestitle := Sender.Series[SeriesNum].Title; 5693 if (seriestitle = '') and (SeriesNum < (Series.Count - 1)) then 5694 if Sender.Series[SeriesNum + 1].Title = '(non-numeric)' then 5695 begin 5696 SeriesNum := SeriesNum + 1; 5697 seriestitle := '(non-numeric)'; 5698 end; 5699 Result := ''; 5700 if seriestitle <> '(non-numeric)' then 5701 begin 5702 ItemCheck(lvwItemsTop, seriestitle, selnum, typeitem); 5703 typeitem := UpperCase(typeitem); 5704 end 5705 else 5706 begin 5707 selnum := 1; 5708 typeitem := '63'; 5709 offset := 2; // 2 series before 5710 if (copy(Sender.Series[SeriesNum - offset].Title, 1, 4) = 'Ref ') then 5711 if SeriesNum - 4 > -1 then 5712 offset := 4 // if ref ranges 5713 else if SeriesNum - 3 > -1 then 5714 offset := 3; // if ref ranges 5715 seriestitle := Sender.Series[SeriesNum - offset].Title + ' ' + seriestitle; 5716 end; 6321 for i := 0 to Sender.SeriesCount - 1 do 6322 if Sender.Series[i] = aSeries then 6323 begin 6324 SeriesNum := i; 6325 filetype := Sender.Series[i].Identifier; 6326 break; 6327 end; 6328 if SeriesNum = -1 then 6329 begin 6330 Result := ''; 6331 exit; 6332 end; 6333 chartnum := Sender.Tag; 6334 seriestitle := Piece(Sender.Series[SeriesNum].Title, '^', 1); 6335 if seriestitle = '(non-numeric)' then 6336 begin 6337 Result := NonNumText(chartnum, (aSeries as TChartSeries).Tag, ValueIndex); 6338 exit; 6339 end; 6340 ItemCheck(lvwItemsTop, seriestitle, selnum, typeitem); 6341 typeitem := UpperCase(typeitem); 5717 6342 if selnum < 0 then 5718 6343 begin … … 5726 6351 typeitem := typenum + '^' + Piece(typeitem, '^', 2); 5727 6352 end; 5728 if typenum = '55' then 5729 begin 5730 if Series is TGanttSeries then 5731 if (Series as TGanttSeries).Pointer.VertSize <> RX_HEIGHT_IN then 5732 if (Series as TGanttSeries).Pointer.VertSize <> RX_HEIGHT_NVA then 5733 typenum := '52' 5734 else typenum := '55NVA'; 5735 end 5736 else if typenum = '55NVA' then 5737 begin 5738 if Series is TGanttSeries then 5739 if (Series as TGanttSeries).Pointer.VertSize <> RX_HEIGHT_NVA then 5740 if (Series as TGanttSeries).Pointer.VertSize <> RX_HEIGHT_OUT then 5741 typenum := '55' 5742 else typenum := '52'; 5743 end 5744 else if typenum = '52' then 5745 begin 5746 if Series is TGanttSeries then 5747 if (Series as TGanttSeries).Pointer.VertSize <> RX_HEIGHT_OUT then 5748 if (Series as TGanttSeries).Pointer.VertSize <> RX_HEIGHT_NVA then 5749 typenum := '55' 5750 else typenum := '55NVA'; 5751 end; 6353 CheckMedNum(typenum, aSeries); 5752 6354 typename := FileNameX(typenum); 5753 6355 if ValueIndex < 0 then … … 5760 6362 else if Copy(typename, length(typename), 1) = 's' then 5761 6363 typename := Copy(typename, 1, length(typename) - 1); 5762 if (Series is TGanttSeries) then 5763 begin 5764 datestart := (Series as TGanttSeries).StartValues[ValueIndex]; 5765 dateend := (Series as TGanttSeries).EndValues[ValueIndex]; 6364 ValueDates(aSeries, ValueIndex, resultdate, otherdate); 6365 ResultValue(resultstring, seriestitle, typenum, typeitem, Sender, aSeries, ValueIndex, SeriesNum, OKToUse); 6366 if not OKToUse then 6367 Result := '' 6368 else 6369 Result := typenum + ' ^' + typename + '^' + resultdate + '^' + 6370 seriestitle + '^' + resultstring + '^' + otherdate; 6371 end; 6372 6373 procedure TfrmGraphs.ValueDates(aSeries: TChartSeries; ValueIndex: Integer; var resultdate, otherdate: string); 6374 var 6375 dateend, datestart: double; 6376 begin 6377 if (aSeries is TGanttSeries) then 6378 begin 6379 datestart := (aSeries as TGanttSeries).StartValues[ValueIndex]; 6380 dateend := (aSeries as TGanttSeries).EndValues[ValueIndex]; 5766 6381 end 5767 6382 else 5768 6383 begin 5769 datestart := Series.XValue[ValueIndex];6384 datestart := aSeries.XValue[ValueIndex]; 5770 6385 dateend := datestart; 5771 6386 end; … … 5782 6397 otherdate := FormatDateTime('mm/dd/yy hh:nn', datestart); 5783 6398 end; 5784 results := ''; 6399 end; 6400 6401 procedure TfrmGraphs.CheckMedNum(var typenum: string; aSeries: TChartSeries); 6402 begin 6403 if typenum = '55' then 6404 begin 6405 if aSeries is TGanttSeries then 6406 if (aSeries as TGanttSeries).Pointer.VertSize <> RX_HEIGHT_IN then 6407 if (aSeries as TGanttSeries).Pointer.VertSize <> RX_HEIGHT_NVA then 6408 typenum := '52' 6409 else typenum := '55NVA'; 6410 end 6411 else if typenum = '55NVA' then 6412 begin 6413 if aSeries is TGanttSeries then 6414 if (aSeries as TGanttSeries).Pointer.VertSize <> RX_HEIGHT_NVA then 6415 if (aSeries as TGanttSeries).Pointer.VertSize <> RX_HEIGHT_OUT then 6416 typenum := '55' 6417 else typenum := '52'; 6418 end 6419 else if typenum = '52' then 6420 begin 6421 if aSeries is TGanttSeries then 6422 if (aSeries as TGanttSeries).Pointer.VertSize <> RX_HEIGHT_OUT then 6423 if (aSeries as TGanttSeries).Pointer.VertSize <> RX_HEIGHT_NVA then 6424 typenum := '55' 6425 else typenum := '55NVA'; 6426 end; 6427 end; 6428 6429 procedure TfrmGraphs.ResultValue(var resultstring, seriestitle: string; typenum, typeitem: string; 6430 Sender: TCustomChart; aSeries: TChartSeries; ValueIndex, SeriesNum: Integer; var OKToUse: boolean); 6431 var 6432 i: integer; 6433 item, partitem, fmdatecheck, astring, datecheck: string; 6434 begin 6435 resultstring := ''; 6436 OKToUse := true; 5785 6437 if typenum = '63' then 5786 6438 begin 5787 if Series is TLineSeries then 5788 if (Series as TLineSeries).LinePen.Style = psDash then 5789 exit; // serHigh or serLow 5790 if Series is TPointSeries then 5791 if (Series as TPointSeries).Pointer.Style = psSmallDot then 5792 exit; // serBlank 6439 if aSeries is TLineSeries then 6440 if (aSeries as TLineSeries).LinePen.Style = psDash then 6441 begin 6442 OKToUse := false; 6443 exit; // serHigh or serLow 6444 end; 6445 if aSeries is TPointSeries then 6446 if (aSeries as TPointSeries).Pointer.Style = psSmallDot then 6447 begin 6448 OKToUse := false; 6449 exit; // serBlank 6450 end; 5793 6451 if copy(seriestitle, length(seriestitle) - 12, length(seriestitle)) = '(non-numeric)' then 5794 6452 begin 5795 6453 seriestitle := copy(seriestitle, 1, length(seriestitle) - 13); 5796 serDatelineTopGetMarkText(Sender.Series[SeriesNum], ValueIndex, results );6454 serDatelineTopGetMarkText(Sender.Series[SeriesNum], ValueIndex, resultstring); 5797 6455 end 5798 6456 else 5799 results := floattostr(Series.YValue[ValueIndex]);6457 resultstring := floattostr(aSeries.YValue[ValueIndex]); 5800 6458 end 5801 6459 else if typenum <> '120.5' then … … 5805 6463 //if (partitem = 'M;A;') then //or (partitem = 'M;T;') then tb antibiotic on 1st piece 5806 6464 begin 5807 fmdatecheck := floattostr(DateTimeToFMDateTime( Series.XValue[ValueIndex]));5808 for i := 0 to lstData.Items.Count - 1 do6465 fmdatecheck := floattostr(DateTimeToFMDateTime(aSeries.XValue[ValueIndex])); 6466 for i := 0 to GtslData.Count - 1 do 5809 6467 begin 5810 astring := lstData.Items[i];6468 astring := GtslData[i]; 5811 6469 if item = Piece(astring, '^', 2) then 5812 6470 begin … … 5816 6474 if datecheck = fmdatecheck then 5817 6475 begin 5818 results := MixedCase(Piece(astring, '^', 5));6476 resultstring := MixedCase(Pieces(astring, '^', 5, 6)) + '^' + Piece(astring, '^', 7); 5819 6477 break; 5820 6478 end; … … 5826 6484 begin 5827 6485 if seriestitle = 'Blood Pressure' then 5828 results := BPValue(Series.XValue[ValueIndex])6486 resultstring := BPValue(aSeries.XValue[ValueIndex]) 5829 6487 else 5830 results := floattostr(Series.YValue[ValueIndex]); 5831 end; 5832 Result := typenum + ' ^' + typename + '^' + resultdate + '^' + 5833 seriestitle + '^' + results + '^' + otherdate; 6488 resultstring := floattostr(aSeries.YValue[ValueIndex]); 6489 end; 5834 6490 end; 5835 6491 5836 6492 procedure TfrmGraphs.chartBaseMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); 5837 6493 var 5838 ClickedLegend, Clicked Value, j: Integer;6494 ClickedLegend, ClickedMark, ClickedValue, j: Integer; 5839 6495 itemname: string; 5840 6496 NewPt: TPoint; … … 5845 6501 FActiveGraph := (Sender as TChart); 5846 6502 NewPt := Mouse.CursorPos; 5847 ClickedValue := -1;5848 6503 ClickedLegend := -1; 6504 ClickedMark := -1; 6505 ClickedValue := -1; 5849 6506 if FHintWinActive then exit; 5850 6507 with FActiveGraph do … … 5858 6515 ClickedValue := Clicked(FX, FY); 5859 6516 if ClickedValue > -1 then break; 6517 ClickedMark := Marks.Clicked(FX, FY); 6518 if ClickedMark > -1 then break; 5860 6519 ClickedLegend := Legend.Clicked(FX, FY); 5861 6520 if ClickedLegend > -1 then break; 5862 6521 end; 5863 6522 end; 5864 if ClickedValue > -1then6523 if (ClickedValue > -1) or (ClickedMark > -1) then 5865 6524 begin 5866 6525 FHintStop := false; … … 5883 6542 end; 5884 6543 6544 procedure TfrmGraphs.chartBaseMouseUp(Sender: TObject; Button: TMouseButton; 6545 Shift: TShiftState; X, Y: Integer); 6546 begin 6547 (Sender as TChart).AllowZoom := FGraphSetting.HorizontalZoom; // avoids cursor rectangle from appearing 6548 end; 6549 6550 procedure TfrmGraphs.FormatHint(var astring: string); 6551 var 6552 i, j: integer; 6553 titlename, dttm, itemname, info, slice, text, value, newinfo, hintslice, hintformat: string; 6554 begin 6555 // hint format: slice|slice|slice| ... 6556 // where | is linebreak and slice is [text] value~[text] value~[text] value~ ... 6557 hintformat := Piece(TypeString(Piece(Piece(astring, '^', 1), ' ', 1)), '^', 9); 6558 titlename := Piece(astring, '^', 2); 6559 dttm := Piece(astring, '^', 3); 6560 if copy(astring, length(astring) - 5, length(astring)) = ' 00:00' then 6561 dttm := Pieces(dttm, ' ', 1, 3); 6562 itemname := Piece(astring, '^', 4); 6563 info := itemname + '~' + Piece(astring, '^', 5) + '~'; 6564 newinfo := ''; 6565 for i := 1 to BIG_NUMBER do 6566 begin 6567 hintslice := Piece(hintformat, '|', i); 6568 slice := Piece(info, '|', i); 6569 for j := 1 to BIG_NUMBER do 6570 begin 6571 text := Piece(hintslice, '~', j); 6572 value := Piece(info, '~', j); 6573 newinfo := newinfo + text + ' ' + value; 6574 //if Piece(hintslice, '~', j + 1) = '' then 6575 // break; . 6576 6577 if Pos('~', hintslice) = length(hintslice) then 6578 break; 6579 if Piece(slice, '~', j + 1) = '' then 6580 break; 6581 end; 6582 if Piece(hintslice, '|', i + 1) = '' then 6583 break; 6584 if length(Piece(hintformat, '|', i + 1)) > 0 then 6585 newinfo := newinfo + #13; 6586 if Piece(hintformat, '|', i + 1) = '' then 6587 break; 6588 end; 6589 astring := titlename + ' ' + dttm + #13 + newinfo; //itemname + ' ' + newinfo; 6590 end; 6591 5885 6592 procedure TfrmGraphs.timHintPauseTimer(Sender: TObject); 6593 6594 function TitleOK(aTitle: string): boolean; 6595 begin 6596 Result := false; 6597 if Copy(aTitle, 1, 7)= 'Ref Low' then exit 6598 else if Copy(aTitle, 1, 8)= 'Ref High' then exit 6599 else if aTitle = TXT_COMMENTS then exit 6600 else if aTitle = TXT_NONNUMERICS then exit; 6601 Result := true; 6602 end; 6603 5886 6604 var 5887 6605 ClickedValue, j: Integer; 5888 dttm, itemname,textvalue: string;6606 textvalue: string; 5889 6607 Rct: TRect; 5890 6608 begin … … 5897 6615 if FHintStop then break; 5898 6616 ClickedValue := Clicked(FX, FY); 6617 if ClickedValue = -1 then ClickedValue := Marks.Clicked(FX, FY); 5899 6618 if ClickedValue > -1 then break; 5900 6619 end; … … 5910 6629 if FHintWinActive then 5911 6630 InactivateHint; 5912 itemname := Series[j].Title; 5913 if Copy(itemname, 1, 7)= 'Ref Low' then exit; 5914 if Copy(itemname, 1, 8)= 'Ref High' then exit; 6631 if not TitleOK(Series[j].Title) then 6632 exit; 5915 6633 FOnSeries := j; 5916 6634 FOnValue := ClickedValue; 5917 6635 textvalue := ValueText(FActiveGraph, Series[j], ClickedValue); 5918 dttm := Piece(textvalue, '^', 3); 5919 //if copy(textvalue, length(textvalue) - 5, length(textvalue)) = ' 00:00' then 5920 // dttm := Pieces(dttm, ' ', 1, 3); 5921 textvalue := Piece(textvalue, '^', 2) + ' ' + dttm + 5922 #13 + Piece(textvalue, '^', 4) + ' ' + Piece(textvalue, '^', 5); 6636 FormatHint(textvalue); 5923 6637 Rct := FHintWin.CalcHintRect(Screen.Width, textvalue, nil); 5924 6638 OffsetRect(Rct, FX, FY + 20); … … 6005 6719 end; 6006 6720 6721 procedure TfrmGraphs.InfoMessage(aCaption: string; aColor: TColor; aVisible: boolean); 6722 begin 6723 pnlInfo.Caption := aCaption; 6724 pnlInfo.Color := aColor; 6725 pnlInfo.Visible := aVisible; 6726 end; 6727 6007 6728 procedure TfrmGraphs.mnuPopGraphZoomBackClick(Sender: TObject); 6008 6729 begin 6009 6730 FFirstClick := true; 6010 with lstZoomHistory do 6011 begin 6012 Items.Delete(Count - 1); 6013 if Count = 0 then mnuPopGraphResetClick(self) 6014 else ZoomUpdate; 6015 end; 6731 GtslZoomHistoryFloat.Delete(GtslZoomHistoryFloat.Count - 1); 6732 if GtslZoomHistoryFloat.Count = 0 then mnuPopGraphResetClick(self) 6733 else ZoomUpdate; 6016 6734 end; 6017 6735 … … 6021 6739 BigTime, SmallTime: TDateTime; 6022 6740 begin 6023 lastzoom := lstZoomHistory.Items[lstZoomHistory.Count - 1];6741 lastzoom := GtslZoomHistoryFloat[GtslZoomHistoryFloat.Count - 1]; 6024 6742 SmallTime := StrToFloat(Piece(lastzoom, '^', 1)); 6025 6743 BigTime := StrToFloat(Piece(lastzoom, '^', 2)); … … 6029 6747 6030 6748 procedure TfrmGraphs.ZoomUpdateInfo(SmallTime, BigTime: TDateTime); 6031 begin 6032 pnlInfo.Caption := TXT_ZOOMED; 6033 pnlInfo.Color := COLOR_ZOOM; 6034 pnlInfo.Caption := pnlInfo.Caption + FormatDateTime('mmm d, yyyy h:nn am/pm', SmallTime); 6035 pnlInfo.Caption := pnlInfo.Caption + ' to ' + FormatDateTime('mmm d, yyyy h:nn am/pm', BigTime) + '.'; 6036 pnlInfo.Visible := true; 6749 var 6750 aString: string; 6751 begin 6752 aString := TXT_ZOOMED 6753 + FormatDateTime('mmm d, yyyy h:nn am/pm', SmallTime) 6754 + ' to ' + FormatDateTime('mmm d, yyyy h:nn am/pm', BigTime) + '.'; 6755 InfoMessage(aString, COLOR_ZOOM, true); 6037 6756 pnlHeader.Visible := true; 6038 6757 end; … … 6061 6780 topflag: boolean; 6062 6781 i, count: integer; 6063 StrForFooter, StrForHeader, aTitle, aWarning, aDateRange : String;6782 StrForFooter, StrForHeader, aTitle, aWarning, aDateRange, aAction: String; 6064 6783 aHeader: TStringList; 6065 6784 wrdApp, wrdDoc, wrdPrintDlg: Variant; 6066 6785 ChildControl: TControl; 6067 6786 begin 6068 topflag := mnuPopGraphStayOnTop.Checked and mnuPopGraphStayOnTop.Enabled;6069 6787 try 6070 6788 wrdApp := CreateOleObject('Word.Application'); … … 6072 6790 raise Exception.Create('Cannot start MS Word!'); 6073 6791 end; 6792 if Sender = mnuPopGraphPrint then 6793 aAction := 'PRINT' 6794 else 6795 aAction := 'COPY'; 6796 topflag := mnuPopGraphStayOnTop.Checked and mnuPopGraphStayOnTop.Enabled; 6074 6797 Screen.Cursor := crDefault; 6075 6798 aTitle := 'CPRS Graphing'; … … 6100 6823 wrdDoc.PageNumbers.Add; 6101 6824 wrdDoc := wrdApp.Documents.Item(1); 6825 if aAction = 'COPY' then 6826 begin 6827 wrdDoc.Range.Font.Name := 'Courier New'; 6828 wrdDoc.Range.Font.Size := 9; 6829 wrdDoc.Range.Text := StrForHeader; 6830 end; 6102 6831 wrdDoc.Range.InsertParagraphAfter; 6103 6832 for i := 0 to scrlTop.ControlCount - 1 do // goes from top to bottom … … 6136 6865 wrdDoc.Paragraphs.Last.Range.Paste; 6137 6866 end; 6138 wrdPrintDlg := wrdApp.Dialogs.item(wdDialogFilePrint); 6139 Screen.Cursor := crDefault; 6140 Application.ProcessMessages; 6141 if topflag then 6142 mnuPopGraphStayOnTopClick(self); 6143 wrdPrintDlg.Show; 6144 wrdApp.Visible := false; 6145 Screen.Cursor := crHourGlass; 6146 Application.ProcessMessages; 6147 Sleep(5000); 6148 count := 0; 6149 while (wrdApp.Application.BackgroundPrintingStatus > 0) do 6150 begin 6151 Sleep(1000); 6867 if aAction = 'PRINT' then 6868 begin 6869 wrdPrintDlg := wrdApp.Dialogs.item(wdDialogFilePrint); 6870 Screen.Cursor := crDefault; 6152 6871 Application.ProcessMessages; 6153 count := count + 1; 6154 if count > 3 then break; 6872 if topflag then 6873 mnuPopGraphStayOnTopClick(self); 6874 wrdPrintDlg.Show; 6875 wrdApp.Visible := false; 6876 Screen.Cursor := crHourGlass; 6877 Application.ProcessMessages; 6878 Sleep(5000); 6879 count := 0; 6880 while (wrdApp.Application.BackgroundPrintingStatus > 0) do 6881 begin 6882 Sleep(1000); 6883 Application.ProcessMessages; 6884 count := count + 1; 6885 if count > 3 then break; 6886 end; 6887 end; 6888 if aAction = 'COPY' then 6889 begin 6890 wrdDoc.Range.WholeStory; 6891 wrdDoc.Range.Copy; 6155 6892 end; 6156 6893 wrdApp.DisplayAlerts := false; … … 6161 6898 Application.ProcessMessages; 6162 6899 if topflag then 6163 mnuPopGraphStayOnTopClick(self); 6900 if aAction = 'PRINT' then 6901 mnuPopGraphStayOnTopClick(self); 6164 6902 Screen.Cursor := crDefault; 6903 end; 6904 6905 procedure TfrmGraphs.lstViewsTopChange(Sender: TObject); 6906 begin 6907 Screen.Cursor := crHourGlass; 6908 ViewsChange(lvwItemsTop, lstViewsTop, 'top'); 6909 Screen.Cursor := crDefault; 6910 end; 6911 6912 procedure TfrmGraphs.lstViewsTopEnter(Sender: TObject); 6913 begin 6914 if Sender = lstViewsTop then 6915 lstViewsTop.Tag := 0; // reset 6916 end; 6917 6918 procedure TfrmGraphs.lstViewsTopMouseDown(Sender: TObject; Button: TMouseButton; 6919 Shift: TShiftState; X, Y: Integer); 6920 begin 6921 // for right mouse click make arrangements for view definition **************** 6922 end; 6923 6924 procedure TfrmGraphs.lstViewsBottomChange(Sender: TObject); 6925 begin 6926 Screen.Cursor := crHourGlass; 6927 ViewsChange(lvwItemsBottom, lstViewsBottom, 'bottom'); 6928 Screen.Cursor := crDefault; 6929 end; 6930 6931 procedure TfrmGraphs.lstViewsBottomEnter(Sender: TObject); 6932 begin 6933 if Sender = lstViewsBottom then 6934 lstViewsBottom.Tag := 0; // reset 6935 end; 6936 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 6943 procedure TfrmGraphs.lvwItemsBottomChange(Sender: TObject; Item: TListItem; 6944 Change: TItemChange); 6945 begin 6946 if FArrowKeys then 6947 if lvwItemsBottom.SelCount > 0 then 6948 begin 6949 if pnlItemsBottomInfo.Tag <> 1 then 6950 lvwItemsBottomClick(self); 6951 FArrowKeys := false; 6952 end; 6165 6953 end; 6166 6954 … … 6168 6956 Change: TItemChange); 6169 6957 begin 6170 if FArrowKeys and (lvwItemsTop.SelCount > 0) then 6171 begin 6172 if pnlItemsTopInfo.Tag <> 1 then 6173 lvwItemsTopClick(self); 6174 FArrowKeys := false; 6175 end; 6176 end; 6177 6178 procedure TfrmGraphs.lvwItemsBottomChange(Sender: TObject; Item: TListItem; 6179 Change: TItemChange); 6180 begin 6181 if FArrowKeys and (lvwItemsBottom.SelCount > 0) then 6182 begin 6183 if pnlItemsBottomInfo.Tag <> 1 then 6184 lvwItemsBottomClick(self); 6185 FArrowKeys := false; 6186 end; 6958 if FArrowKeys then 6959 if lvwItemsTop.SelCount > 0 then 6960 begin 6961 if pnlItemsTopInfo.Tag <> 1 then 6962 lvwItemsTopClick(self); 6963 FArrowKeys := false; 6964 end; 6965 end; 6966 6967 procedure TfrmGraphs.lvwItemsTopClick(Sender: TObject); 6968 var 6969 i: integer; 6970 begin 6971 FFirstClick := true; 6972 if not FFastTrack then 6973 if GraphTurboOn then 6974 Switch; 6975 if lvwItemsTop.SelCount > FGraphSetting.MaxSelect then 6976 begin 6977 pnlItemsTopInfo.Tag := 1; 6978 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; 6985 for i := 0 to GtslSelPrevTopFloat.Count - 1 do 6986 lvwItemsTop.Items[strtoint(GtslSelPrevTopFloat[i])].Selected := true; 6987 pnlItemsTopInfo.Tag := 0; 6988 end 6989 else 6990 begin 6991 GtslSelPrevTopFloat.Clear; 6992 for i := 0 to lvwItemsTop.Items.Count - 1 do 6993 if lvwItemsTop.Items[i].Selected then 6994 GtslSelPrevTopFloat.Add(inttostr(i)); 6995 ItemsClick(Sender, lvwItemsTop, lvwItemsBottom, chkItemsTop, lstViewsTop, GtslSelCopyTop, 'top'); 6996 end; 6997 end; 6998 6999 procedure TfrmGraphs.lvwItemsTopEnter(Sender: TObject); 7000 begin 7001 if lvwItemsTop.SelCount = 0 then 7002 if lvwItemsTop.Items.Count > 0 then 7003 lvwItemsTop.Items[0].Focused := true; 6187 7004 end; 6188 7005 … … 6192 7009 if Key in [VK_PRIOR, VK_NEXT, VK_UP, VK_DOWN] then 6193 7010 FArrowKeys := true; 6194 end;6195 6196 procedure TfrmGraphs.testcount1Click(Sender: TObject);6197 6198 function boxcount(aListBox: TListBox): string;6199 var6200 i, ccnt: integer;6201 begin6202 Result := '';6203 ccnt := 0;6204 for i := 0 to aListBox.Items.Count - 1 do6205 ccnt := ccnt + length(aListBox.Items[i]);6206 Result := inttostr(aListBox.Items.Count) + ';' + inttostr(ccnt);6207 end;6208 6209 var6210 i, lines, total: integer;6211 aString: string;6212 begin6213 lines := 0;6214 total := 0;6215 with pnlData do6216 for i:= 0 to pnlData.ControlCount - 1 do6217 if Controls[i] is TListBox then6218 begin6219 aString := boxcount(Controls[i] as TListBox);6220 lines := lines + strtointdef(Piece(aString, ';', 1), 0);6221 total := total + strtointdef(Piece(aString, ';', 2), 0);6222 end;6223 aString := boxcount(lstTypes) + '^' + boxcount(lstItems) + '^' + boxcount(lstData)6224 + ' lines: ' + inttostr(lines) + ' total: ' + inttostr(total);6225 showmessage(aString);6226 7011 end; 6227 7012 … … 6238 7023 with FGraphSetting do FixedDateRange := not FixedDateRange; 6239 7024 ChangeStyle; 6240 end;6241 6242 //***************** these are used to fix dropdown when large fonts6243 6244 procedure TfrmGraphs.cboViewsTopDropDown(Sender: TObject);6245 begin6246 cboViewsTop.Align := alNone;6247 end;6248 6249 procedure TfrmGraphs.cboViewsTopDropDownClose(Sender: TObject);6250 begin6251 cboViewsTop.Align := alClient;6252 end;6253 6254 procedure TfrmGraphs.cboViewsBottomDropDown(Sender: TObject);6255 begin6256 cboViewsBottom.Align := alNone;6257 end;6258 6259 procedure TfrmGraphs.cboViewsBottomDropDownClose(Sender: TObject);6260 begin6261 cboViewsBottom.Align := alClient;6262 7025 end; 6263 7026 … … 6289 7052 end; 6290 7053 6291 procedure TfrmGraphs.lvwItemsTopEnter(Sender: TObject);6292 begin6293 if lvwItemsTop.SelCount = 0 then6294 if lvwItemsTop.Items.Count > 0 then6295 lvwItemsTop.Items[0].Focused := true;6296 end;6297 6298 7054 procedure TfrmGraphs.chkItemsBottomEnter(Sender: TObject); 6299 7055 begin … … 6305 7061 end; 6306 7062 6307 procedure TfrmGraphs.cboViewsBottomEnter(Sender: TObject);6308 begin6309 if not chkDualViews.Checked then6310 SelectNext(ActiveControl as TWinControl, True, True);6311 end;6312 6313 7063 procedure TfrmGraphs.lvwItemsBottomEnter(Sender: TObject); 6314 7064 begin … … 6320 7070 end; 6321 7071 7072 procedure TfrmGraphs.UpdateAccessabilityActions(var Actions: TAccessibilityActions); 7073 begin 7074 Actions := Actions - [aaColorConversion]; 7075 end; 7076 7077 procedure TfrmGraphs.memTopEnter(Sender: TObject); 7078 begin 7079 memTop.Color := clBtnShadow; 7080 end; 7081 7082 procedure TfrmGraphs.memTopExit(Sender: TObject); 7083 begin 7084 memTop.Color := clBtnFace; 7085 end; 7086 7087 procedure TfrmGraphs.memBottomEnter(Sender: TObject); 7088 begin 7089 memBottom.Color := clBtnShadow; 7090 end; 7091 7092 procedure TfrmGraphs.memBottomExit(Sender: TObject); 7093 begin 7094 memBottom.Color := clBtnFace; 7095 end; 7096 7097 procedure TfrmGraphs.memTopKeyDown(Sender: TObject; var Key: Word; 7098 Shift: TShiftState); 7099 begin 7100 case Key of 7101 VK_UP: SendMessage(scrlTop.Handle, WM_VSCROLL, SB_LINEUP, 0); 7102 VK_PRIOR: SendMessage(scrlTop.Handle, WM_VSCROLL, SB_PAGEUP, 0); 7103 VK_NEXT: SendMessage(scrlTop.Handle, WM_VSCROLL, SB_PAGEDOWN, 0); 7104 VK_DOWN: SendMessage(scrlTop.Handle, WM_VSCROLL, SB_LINEDOWN, 0); 7105 VK_HOME: SendMessage(scrlTop.Handle, WM_VSCROLL, SB_TOP, 0); 7106 VK_END: SendMessage(scrlTop.Handle, WM_VSCROLL, SB_BOTTOM, 0); 7107 end; 7108 end; 7109 7110 procedure TfrmGraphs.memBottomKeyDown(Sender: TObject; var Key: Word; 7111 Shift: TShiftState); 7112 begin 7113 case Key of 7114 VK_UP: SendMessage(scrlBottom.Handle, WM_VSCROLL, SB_LINEUP, 0); 7115 VK_PRIOR: SendMessage(scrlBottom.Handle, WM_VSCROLL, SB_PAGEUP, 0); 7116 VK_NEXT: SendMessage(scrlBottom.Handle, WM_VSCROLL, SB_PAGEDOWN, 0); 7117 VK_DOWN: SendMessage(scrlBottom.Handle, WM_VSCROLL, SB_LINEDOWN, 0); 7118 VK_HOME: SendMessage(scrlBottom.Handle, WM_VSCROLL, SB_TOP, 0); 7119 VK_END: SendMessage(scrlBottom.Handle, WM_VSCROLL, SB_BOTTOM, 0); 7120 end; 7121 end; 7122 6322 7123 initialization 6323 7124 CoInitialize (nil);
Note:
See TracChangeset
for help on using the changeset viewer.