source: cprs/branches/tmg-cprs/CPRS-Chart/fVitals.pas@ 454

Last change on this file since 454 was 453, checked in by Kevin Toppenberg, 16 years ago

Initial upload of TMG-CPRS 1.0.26.69

File size: 28.1 KB
RevLine 
[453]1//kt -- Modified with SourceScanner on 8/17/2007
2{Modifications
3Date: 4/1/98 RAB/ISL
4Description: Added procedure SelectVital(FontSize:integer; idx: integer)
5 To be able to pass the row index into the form. This will enable the vital
6 entry form to open the apropriate line on this form (If this screen is opened
7 by the vital entry screen)
8
9Date: 4/9/98 RAB/ISL
10Descriotion: Added button and click event to call vital entry screen.
11
12Date: 4/9/98 RAB/ISL
13Descriotion: if Idx passed into procedure SelectVital is '99' then the botton to
14 call the vital entry screen will be disabled.
15
16Date: 4/23/98
17By: Robert Bott
18Description: Set position of form to poScreenCenter.
19Date: 4/23/98
20By: Robert Bott
21Description: Forced an update after returning from vital entry form.
22
23//Modifed: 6/23/98
24//By: Robert Bott
25//Location: ISL
26//Description of Mod:
27// Moved code that verifies valid provider and visit from fvit into fVitals.
28// now found in procedure TfrmVitals.btnEnterVitalsClick(Sender: TObject);
29// formerly in procedure TfrmVit.FormActivate(Sender: TObject);
30
31}
32
33unit fVitals;
34
35interface
36
37uses
38 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
39 StdCtrls, ORCtrls, TeEngine, Series, TeeProcs, Chart, ExtCtrls, Grids,
40 Buttons, ORNet, ORFn, uConst, Menus, ORDtTmRng
41 , ComCtrls
42 , uVitals, DKLang
43 ; {*KCM*}
44
45type
46 TfrmVitals = class(TForm)
47 pnlTop: TPanel;
48 chtChart: TChart;
49 serTest: TLineSeries;
50 pnlLeft: TORAutoPanel;
51 lstDates: TORListBox;
52 pnlBottom: TPanel;
53 grdVitals: TCaptionStringGrid;
54 pnlButtons: TPanel;
55 lstVitals: TCaptionListBox;
56 serTestX: TLineSeries;
57 serTime: TPointSeries;
58 lblNoResults: TStaticText;
59 serTestY: TLineSeries;
60 pnlLeftClient: TORAutoPanel;
61 chkValues: TCheckBox;
62 chk3D: TCheckBox;
63 chkZoom: TCheckBox;
64 pnlEnterVitals: TPanel;
65 btnEnterVitals: TButton;
66 popChart: TPopupMenu;
67 popValues: TMenuItem;
68 pop3D: TMenuItem;
69 popZoom: TMenuItem;
70 popZoomBack: TMenuItem;
71 N1: TMenuItem;
72 popCopy: TMenuItem;
73 N2: TMenuItem;
74 popDetails: TMenuItem;
75 calVitalsRange: TORDateRangeDlg;
76 N3: TMenuItem;
77 popPrint: TMenuItem;
78 dlgWinPrint: TPrintDialog;
79 DKLanguageController1: TDKLanguageController;
80 procedure lstDatesClick(Sender: TObject);
81 procedure FormCreate(Sender: TObject);
82 procedure FormDestroy(Sender: TObject);
83 procedure lstVitalsClick(Sender: TObject);
84 procedure grdVitalsSelectCell(Sender: TObject; Col, Row: Integer;
85 var CanSelect: Boolean);
86 procedure chkZoomClick(Sender: TObject);
87 procedure chk3DClick(Sender: TObject);
88 procedure chkValuesClick(Sender: TObject);
89 procedure FormShow(Sender: TObject);
90 procedure pnlEnterVitalsResize(Sender: TObject);
91 procedure btnEnterVitalsClick(Sender: TObject);
92 procedure chtChartUndoZoom(Sender: TObject);
93 procedure popValuesClick(Sender: TObject);
94 procedure pop3DClick(Sender: TObject);
95 procedure popZoomClick(Sender: TObject);
96 procedure popZoomBackClick(Sender: TObject);
97 procedure popCopyClick(Sender: TObject);
98 procedure popDetailsClick(Sender: TObject);
99 procedure chtChartClickSeries(Sender: TCustomChart;
100 Series: TChartSeries; ValueIndex: Integer; Button: TMouseButton;
101 Shift: TShiftState; X, Y: Integer);
102 procedure chtChartMouseDown(Sender: TObject; Button: TMouseButton;
103 Shift: TShiftState; X, Y: Integer);
104 procedure chtChartClickLegend(Sender: TCustomChart;
105 Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
106 procedure popChartPopup(Sender: TObject);
107 procedure popPrintClick(Sender: TObject);
108 procedure BeginEndDates(var ADate1, ADate2: TFMDateTime; var ADaysBack: integer);
109 procedure FormKeyUp(Sender: TObject; var Key: Word;
110 Shift: TShiftState);
111 private
112 { Private declarations }
113 procedure VGrid(griddata: TStrings);
114 procedure WorksheetChart(test: string; aitems: TStrings);
115 procedure GetStartStop(var start, stop: string; aitems: TStrings);
116 public
117 { Public declarations }
118 function FMToDateTime(FMDateTime: string): TDateTime;
119 end;
120
121
122var
123 frmVitals: TfrmVitals;
124 tmpGrid: TStringList;
125 uDate1, uDate2: Tdatetime;
126
127procedure SelectVital(FontSize:integer; idx: integer);
128procedure SelectVitals(VitalType: String);
129function VitalsGrid(const patient: string; date1, date2: TFMDateTime; restrictdates: integer; tests: TStrings): TStrings; //*DFN*
130function VitalsMemo(const patient: string; date1, date2: TFMDateTime; tests: TStrings): TStrings; //*DFN*
131
132implementation
133
134uses fCover, uCore, rCore, fVit, fFrame, fEncnt, fVisit, fRptBox, rReports,
135 uAccessibleStringGrid, uInit;
136
137const
138 ZOOM_PERCENT = 99; // padding for inflating margins
139
140{$R *.DFM}
141
142
143procedure SelectVital(FontSize:integer; idx: integer);
144var
145 frmVitals: TfrmVitals;
146begin
147 frmVitals := TfrmVitals.Create(Application);
148 try
149 ResizeAnchoredFormToFont(frmVitals);
150 with frmVitals do
151 begin
152 if idx <= lstvitals.items.count then lstVitals.ItemIndex := idx
153 else lstVitals.ItemIndex := 0;
154
155 if idx = 99 then
156 btnEnterVitals.enabled := False;
157 ShowModal;
158 end;
159
160 finally
161 frmVitals.Release;
162 end;
163end;
164
165function getVitalsStartDate : String;
166begin
167 result := '';
168 if Patient.Inpatient then
169 result := FormatDateTime('mm/dd/yy',Now - 7)
170 else
171 result := FormatDateTime('mm/dd/yy',IncMonth(Now,-6));
172end;
173
174procedure SelectVitals(VitalType: String);
175var
176 VLPtVitals : TGMV_VitalsViewForm;
177 GMV_FName,
178 GMV_LibName: String;
179begin
180 { Availble Forms:
181 GMV_FName :='GMV_VitalsEnterDLG';
182 GMV_FName :='GMV_VitalsEnterForm';
183 GMV_FName :='GMV_VitalsViewForm';
184 GMV_FName :='GMV_VitalsViewDLG';
185 }
186 GMV_FName :='GMV_VitalsViewDLG';
187 GMV_LibName :='GMV_VitalsViewEnter.dll';
188 GMV_LibName := GetProgramFilesPath + SHARE_DIR + GMV_LibName;
189 VitalsDLLHandle := LoadLibrary(PChar(GMV_LibName));
190 // UpdateTimeOutInterval(5000);
191 if VitalsDLLHandle <> 0 then
192 begin
193 @VLPtVitals := GetProcAddress(VitalsDLLHandle,PChar(GMV_FName));
194 if assigned(VLPtVitals) then
195 VLPtVitals(RPCBrokerV,Patient.DFN,FloatToStr(Encounter.Location),
196 getVitalsStartDate(),FormatDateTime('mm/dd/yy',Now),
197 GMV_APP_SIGNATURE,
198 GMV_CONTEXT,GMV_CONTEXT,
199 Patient.Name,
200 frmFrame.lblPtSSN.Caption + ' ' + frmFrame.lblPtAge.Caption,
201 Encounter.LocationName +U+ VitalType)
202 else
203// MessageDLG('Can''t find function "'+GMV_FName+'".',mtError,[mbok],0); <-- original line. //kt 8/17/2007
204 MessageDLG(DKLangConstW('fVitals_Canxxt_find_function_x')+GMV_FName+'".',mtError,[mbok],0); //kt added 8/17/2007
205 end
206 else
207// MessageDLG('Can''t find library "'+GMV_LibName+'".',mtError,[mbok],0); <-- original line. //kt 8/17/2007
208 MessageDLG(DKLangConstW('fVitals_Canxxt_find_library_x')+GMV_LibName+'".',mtError,[mbok],0); //kt added 8/17/2007
209 @VLPtVitals := nil;
210 FreeLibrary(VitalsDLLHandle);
211 if DLLForceClose then
212 frmFrame.Close; // Fix for CQ: 7535
213end;
214
215(*
216procedure SelectVitals(FontSize: Integer);
217var
218 frmVitals: TfrmVitals;
219 firstchar: string;
220 i: integer;
221begin
222 frmVitals := TfrmVitals.Create(Application);
223 try
224 ResizeAnchoredFormToFont(frmVitals);
225 with frmVitals do
226 begin
227 with frmCover do
228 for i := ComponentCount - 1 downto 0 do
229 begin
230 if Components[i] is TORListBox then
231 begin
232 case Components[i].Tag of
233 70:
234 if (Components[i] as TORListBox).ItemIndex > -1 then
235 begin
236 // changed to look at 2 chars so pain & pulse not confused {*KCM*}
237 firstchar := UpperCase(Copy(Piece((Components[i] as TORListBox).Items[(Components[i] as TORListBox).ItemIndex], '^', 2), 1, 2));
238 if firstchar = 'T' then
239 lstVitals.ItemIndex := 0
240 else if firstchar = 'P' then
241 lstVitals.ItemIndex := 1
242 else if firstchar = 'R' then
243 lstVitals.ItemIndex := 2
244 else if firstchar = 'BP' then
245 lstVitals.ItemIndex := 3
246 else if firstchar = 'HT' then
247 lstVitals.ItemIndex := 4
248 else if firstchar = 'WT' then
249 lstVitals.ItemIndex := 5
250 else if firstchar = 'PN' then
251 lstVitals.ItemIndex := 6;
252 end
253 else
254 begin
255 firstchar := '';
256 lstVitals.ItemIndex := 0;
257 end;
258 end;
259 end;
260 end;
261 ShowModal;
262 end;
263 finally
264 frmVitals.Release;
265 end;
266end;
267 *)
268procedure TfrmVitals.VGrid(griddata: TStrings);
269var
270 testcnt, datecnt, datacnt, linecnt, x, y, i: integer;
271begin
272 testcnt := strtoint(Piece(griddata[0], '^', 1));
273 datecnt := strtoint(Piece(griddata[0], '^', 2));
274 datacnt := strtoint(Piece(griddata[0], '^', 3));
275 linecnt := testcnt + datecnt + datacnt;
276 with grdVitals do
277 begin
278 if datecnt = 0 then ColCount := 1 else ColCount := datecnt;
279 if testcnt = 0 then RowCount := 2 else RowCount := testcnt + 1;
280 DefaultColWidth := 80;
281 FixedCols := 0;
282 FixedRows := 1;
283 for y := 0 to RowCount - 1 do
284 for x := 0 to ColCount - 1 do
285 Cells[x, y] := '';
286 if datecnt = 0 then
287 begin
288// Cells[1, 0] := 'no results'; <-- original line. //kt 8/17/2007
289 Cells[1, 0] := DKLangConstW('fVitals_no_results'); //kt added 8/17/2007
290 for x := 1 to RowCount - 1 do
291 Cells[x, 1] := '';
292 end;
293 for i := testcnt + 1 to testcnt + datecnt do
294 begin
295 Cells[i - testcnt - 1, 0] := FormatFMDateTime('mm/dd/yy hh:nn',MakeFMDateTime(Piece(griddata[i], '^', 2)));
296 end;
297 for i := testcnt + datecnt + 1 to linecnt do
298 begin
299 x := strtoint(Piece(griddata[i], '^', 1));
300 y := strtoint(Piece(griddata[i], '^', 2));
301 Cells[x - 1, y] := Piece(griddata[i], '^', 3);
302 end;
303 end;
304end;
305
306function VitalsGrid(const patient: string; date1, date2: TFMDateTime; restrictdates: integer; tests: TStrings): TStrings; //*DFN*
307begin
308 CallV('GMV ORQQVI1 GRID', [patient, date1, date2, restrictdates, tests]);
309 Result := RPCBrokerV.Results;
310end;
311
312function VitalsMemo(const patient: string; date1, date2: TFMDateTime; tests: TStrings): TStrings; //*DFN*
313begin
314 CallV('GMV ORQQVI1 DETAIL', [patient, date1, date2, 0, tests]);
315 Result := RPCBrokerV.Results;
316end;
317
318procedure TfrmVitals.lstDatesClick(Sender: TObject);
319var
320 daysback, vindex: integer;
321 date1, date2: TFMDateTime;
322 today: TDateTime;
323begin
324 if (lstDates.ItemID = 'S') then
325 begin
326 with calVitalsRange do
327 begin
328 if Execute then
329 begin
330 lstDates.ItemIndex := lstDates.Items.Add(RelativeStart + ';' +
331// RelativeStop + U + TextOfStart + ' to ' + TextOfStop); <-- original line. //kt 8/17/2007
332 RelativeStop + U + TextOfStart + DKLangConstW('fVitals_to') + TextOfStop); //kt added 8/17/2007
333 end
334 else
335 lstDates.ItemIndex := -1;
336 end;
337 end;
338 today := FMToDateTime(floattostr(FMToday));
339 if lstDates.ItemIEN > 0 then
340 begin
341 daysback := lstDates.ItemIEN;
342 date1 := FMToday + 0.2359;
343 If daysback = 1 then
344 date2 := DateTimeToFMDateTime(today)
345 Else
346 date2 := DateTimeToFMDateTime(today - daysback);
347 end
348 else
349 BeginEndDates(date1,date2,daysback);
350 //date1 := date1 + 0.2359;
351 tmpGrid.Assign(VitalsGrid(Patient.DFN, date1, date2, 0, lstVitals.Items));
352 vindex := lstVitals.ItemIndex;
353 VGrid(tmpGrid);
354 lstVitals.ItemIndex := vindex;
355 lstVitalsClick(self);
356 chtChart.BottomAxis.Automatic := true; //***********
357 chkZoom.Checked := false;
358 chtChart.UndoZoom;
359 if lstVitals.ItemIndex > -1 then
360 begin
361 WorksheetChart(inttostr(lstVitals.ItemIndex + 1), tmpGrid);
362 if (serTest.Count > 1) and not chkZoom.Checked then
363 begin
364 chtChart.UndoZoom;
365 chtChart.ZoomPercent(ZOOM_PERCENT);
366 end;
367 end;
368end;
369
370procedure TfrmVitals.FormCreate(Sender: TObject);
371begin
372 grdVitals.Color := ReadOnlyColor;
373 tmpGrid := TStringList.Create;
374 if Patient.Inpatient then lstDates.ItemIndex := 1 else lstDates.ItemIndex := 4;
375 SerTest.GetHorizAxis.ExactDateTime := true;
376 SerTest.GetHorizAxis.Increment := DateTimeStep[dtOneMinute];
377 TAccessibleStringGrid.WrapControl(grdVitals);
378end;
379
380procedure TfrmVitals.FormDestroy(Sender: TObject);
381begin
382 tmpGrid.free;
383 TAccessibleStringGrid.UnwrapControl(grdVitals);
384end;
385
386function TfrmVitals.FMToDateTime(FMDateTime: string): TDateTime;
387var
388 x, Year: string;
389begin
390 { Note: TDateTime cannot store month only or year only dates }
391 x := FMDateTime + '0000000';
392 if Length(x) > 12 then x := Copy(x, 1, 12);
393 if StrToInt(Copy(x, 9, 4)) > 2359 then x := Copy(x,1,7) + '.2359';
394 Year := IntToStr(17 + StrToInt(Copy(x,1,1))) + Copy(x,2,2);
395 x := Copy(x,4,2) + '/' + Copy(x,6,2) + '/' + Year + ' ' + Copy(x,9,2) + ':' + Copy(x,11,2);
396 Result := StrToDateTime(x);
397end;
398
399procedure TfrmVitals.lstVitalsClick(Sender: TObject);
400begin
401 with grdVitals do
402 begin
403 Row := lstVitals.ItemIndex + 1;
404 Col := grdVitals.ColCount - 1;
405 end;
406end;
407
408procedure TfrmVitals.WorksheetChart(test: string; aitems: TStrings);
409
410function OkFloatValue(value: string): boolean;
411var
412 i, j: integer;
413 first, second: string;
414begin
415 Result := false;
416 i := strtointdef(value, -99999);
417 if i <> -99999 then Result := true
418 else if pos(Pieces(value, '.', 2, 3), '.') > 0 then Result := false
419 else
420 begin
421 first := Piece(value, '.', 1);
422 second := Piece(value, '.', 2);
423 if length(second) > 0 then
424 begin
425 i := strtointdef(first, -99999);
426 j := strtointdef(second, -99999);
427 if (i <> -99999) and (j <> -99999) then Result := true;
428 end
429 else
430 begin
431 i :=strtointdef(first, -99999);
432 if i <> -99999 then Result := true;
433 end;
434 end;
435end;
436
437var
438 datevalue, oldstart, oldend: TDateTime;
439 labvalue, labvalue1, labvalue2, labvalue3: double;
440 i, numtest, numcol, numvalues, valuecount: integer;
441 high, start, stop, value, value1, value2, value3, testcheck, units, testname, testnum, testorder: string;
442begin
443
444
445 valuecount := 0;
446 testnum := Piece(test, '^', 1);
447 testname := lstVitals.Items[strtoint(testnum) - 1];
448 numtest := strtoint(Piece(aitems[0], '^', 1));
449 numcol := strtoint(Piece(aitems[0], '^', 2));
450 numvalues := strtoint(Piece(aitems[0], '^', 3));
451 if numvalues = 0 then
452 chtChart.Visible := false
453 else
454 begin
455 chtChart.Visible := true;
456 serTest.Clear; serTestX.Clear; serTime.Clear;
457 if numtest > 0 then
458 begin
459 for i := 1 to numtest do
460 if testnum = Piece(aitems[i], '^', 1) then
461 begin
462 testorder := inttostr(i);
463 break;
464 end;
465 GetStartStop(start, stop, aitems);
466 chtChart.Legend.Color := grdVitals.Color;
467 chtChart.Title.Font.Size := MainFontSize;
468 chtChart.LeftAxis.Title.Caption := units;
469 serTest.Title := Piece(test, '^', 2);
470 testcheck := testorder;
471 high := '0';
472// if testname = 'Blood Pressure' then <-- original line. //kt 8/17/2007
473 if testname = DKLangConstW('fVitals_Blood_Pressure') then //kt added 8/17/2007
474 begin
475 serTestY.Active := false;
476 for i := numtest + numcol + 1 to numtest + numcol + numvalues do
477 if Piece(aitems[i], '^', 2) = testcheck then
478 begin
479 serTestX.Active := true;
480 serTestX.Marks.Visible := chkValues.Checked;
481 serTestY.Marks.Visible := chkValues.Checked;
482 value := Piece(aitems[i], '^', 3);
483 value1 := Piece(value, '/', 1);
484 value2 := Piece(value, '/', 2);
485 value3 := Piece(value, '/', 3);
486 if OkFloatValue(value1) and OKFloatValue(value2) then
487 begin
488 high := value1;
489 labvalue1 := strtofloat(value1);
490 labvalue2 := strtofloat(value2);
491 datevalue := FMToDateTime(Piece(aitems[numtest + strtoint(Piece(aitems[i], '^', 1))], '^', 2));
492 serTest.AddXY(datevalue, labvalue1, '', clTeeColor);
493 serTestX.AddXY(datevalue, labvalue2, '', clTeeColor);
494 inc(valuecount);
495 if OKFloatValue(value3) then
496 begin
497 labvalue3 := strtofloat(value3);
498 serTestY.AddXY(datevalue, labvalue3, '', clTeeColor);
499 serTestY.Active := true;
500 end;
501 end;
502 end;
503// serTest.Title := 'Systolic'; <-- original line. //kt 8/17/2007
504 serTest.Title := DKLangConstW('fVitals_Systolic'); //kt added 8/17/2007
505// serTestX.Title := 'Diastolic'; <-- original line. //kt 8/17/2007
506 serTestX.Title := DKLangConstW('fVitals_Diastolic'); //kt added 8/17/2007
507 end // blood pressure
508 else
509 begin
510 for i := numtest + numcol + 1 to numtest + numcol + numvalues do
511 if Piece(aitems[i], '^', 2) = testcheck then
512 begin
513 serTestX.Active := false;
514 serTestY.Active := false;
515 value := Piece(aitems[i], '^', 3);
516 if OkFloatValue(value) then
517 begin
518 high := value;
519 labvalue := strtofloat(value);
520 datevalue := FMToDateTime(Piece(aitems[numtest + strtoint(Piece(aitems[i], '^', 1))], '^', 2));
521 serTest.AddXY(datevalue, labvalue, '', clTeeColor);
522 inc(valuecount);
523 end;
524 end;
525 serTest.Title := lstVitals.Items[lstVitals.ItemIndex];
526 end; // not blood pressure
527 serTime.AddXY(FMToDateTime(start), strtofloat(high), '',clTeeColor);
528 serTime.AddXY(FMToDateTime(stop), strtofloat(high), '',clTeeColor);
529 end; // numtest > 0
530 if chkZoom.Checked and chtChart.Visible then
531 begin
532 oldstart := chtChart.BottomAxis.Minimum;
533 oldend := chtChart.BottomAxis.Maximum;
534 chtChart.UndoZoom;
535 chtChart.BottomAxis.Automatic := false;
536 chtChart.BottomAxis.Minimum := oldstart;
537 chtChart.BottomAxis.Maximum := oldend;
538 end
539 else
540 begin
541 chtChart.BottomAxis.Automatic := true;
542 end;
543 if valuecount = 0 then chtChart.Visible := false;
544 end; // numvalues not 0
545end;
546
547procedure TfrmVitals.GetStartStop(var start, stop: string; aitems: TStrings);
548var
549 numtest, numcol: integer;
550begin
551 numtest := strtoint(Piece(aitems[0], '^', 1));
552 numcol := strtoint(Piece(aitems[0], '^', 2));
553 start := Piece(aitems[numtest + 1], '^', 2);
554 stop := Piece(aitems[numtest + numcol], '^', 2);
555end;
556
557procedure TfrmVitals.grdVitalsSelectCell(Sender: TObject; Col,
558 Row: Integer; var CanSelect: Boolean);
559begin
560 lstVitals.ItemIndex := Row - 1;
561 if lstVitals.ItemIndex > -1 then
562 begin
563 WorksheetChart(inttostr(lstVitals.ItemIndex + 1), tmpGrid);
564 if (serTest.Count > 1) and not chkZoom.Checked then
565 begin
566 chtChart.UndoZoom;
567 chtChart.ZoomPercent(ZOOM_PERCENT);
568 end;
569 end;
570end;
571
572procedure TfrmVitals.chkZoomClick(Sender: TObject);
573begin
574 chtChart.AllowZoom := chkZoom.Checked;
575 chtChart.AnimatedZoom := chkZoom.Checked;
576 if not chkZoom.Checked then
577 begin
578 chtChart.UndoZoom;
579 if serTest.Count > 1 then chtChart.ZoomPercent(ZOOM_PERCENT);
580 end;
581end;
582
583procedure TfrmVitals.chk3DClick(Sender: TObject);
584begin
585 chtChart.View3D := chk3D.Checked;
586end;
587
588procedure TfrmVitals.chkValuesClick(Sender: TObject);
589begin
590 serTest.Marks.Visible := chkValues.Checked;
591 if serTestX.Active then serTestX.Marks.Visible := chkValues.Checked;
592 if serTestY.Active then serTestY.Marks.Visible := chkValues.Checked;
593end;
594
595procedure TfrmVitals.FormShow(Sender: TObject);
596begin
597 lstDatesClick(self);
598end;
599
600
601
602
603procedure TfrmVitals.pnlEnterVitalsResize(Sender: TObject);
604begin
605 btnEnterVitals.top := pnlEnterVitals.top;
606 btnEnterVitals.left := pnlEnterVitals.left;
607 btnEnterVitals.height := pnlEnterVitals.height;
608 btnEnterVitals.width := pnlEnterVitals.width;
609end;
610
611procedure TfrmVitals.btnEnterVitalsClick(Sender: TObject);
612begin
613 If Encounter.location > 0.0 then //if it has been assigned.
614 uVitalLocation := Encounter.Location
615 else
616 begin
617 //assign location
618 if Encounter.NeedVisit then
619 begin
620 UpdateVisit(Font.Size);
621 frmFrame.DisplayEncounterText;
622 end;
623 if Encounter.NeedVisit and (not frmFrame.CCOWDrivedChange) then
624 begin
625 InfoBox(TX_NEED_VISIT, TX_NO_VISIT, MB_OK or MB_ICONWARNING);
626 exit; {RAB 6/23/98}
627 end
628 else
629 uVitalLocation := Encounter.Location;
630 end;
631
632 if (not encounter.needvisit) then
633 try
634 Application.CreateForm(TfrmVit, frmVit);
635 frmvit.showmodal;
636 //refresh vital info
637 lstDatesClick(self);
638 finally
639 frmvit.release;
640 end;
641end;
642
643procedure TfrmVitals.chtChartUndoZoom(Sender: TObject);
644begin
645 chtChart.BottomAxis.Automatic := true;
646end;
647
648procedure TfrmVitals.popValuesClick(Sender: TObject);
649begin
650 chkValues.Checked := not chkValues.Checked;
651 chkValuesClick(self);
652end;
653
654procedure TfrmVitals.pop3DClick(Sender: TObject);
655begin
656 chk3D.Checked := not chk3D.Checked;
657 chk3DClick(self);
658end;
659
660procedure TfrmVitals.popZoomClick(Sender: TObject);
661begin
662 chkZoom.Checked := not chkZoom.Checked;
663 chkZoomClick(self);
664end;
665
666procedure TfrmVitals.popZoomBackClick(Sender: TObject);
667begin
668 chtChart.UndoZoom;
669end;
670
671procedure TfrmVitals.popCopyClick(Sender: TObject);
672begin
673 chtChart.CopyToClipboardBitmap;
674end;
675
676procedure TfrmVitals.popDetailsClick(Sender: TObject);
677var
678 tmpList: TStringList;
679 date1, date2: TFMDateTime;
680 strdate1, strdate2: string;
681begin
682 inherited;
683 Screen.Cursor := crHourGlass;
684 if chtChart.Tag > 0 then
685 begin
686 strdate1 := FormatDateTime('mm/dd/yyyy', uDate1);
687 strdate2 := FormatDateTime('mm/dd/yyyy', uDate2);
688 uDate1 := StrToDateTime(strdate1);
689 uDate2 := StrToDateTime(strdate2);
690 date1 := DateTimeToFMDateTime(uDate1 + 1);
691 date2 := DateTimeToFMDateTime(uDate2);
692// StatusText('Retrieving data for ' + FormatDateTime('dddd, mmmm d, yyyy', uDate2) + '...'); <-- original line. //kt 8/17/2007
693 StatusText(DKLangConstW('fVitals_Retrieving_data_for')+' ' + FormatDateTime('dddd, mmmm d, yyyy', uDate2) + '...'); //kt added 8/17/2007
694// ReportBox(VitalsMemo(Patient.DFN, date1, date2, lstVitals.Items), 'Vitals on ' + Patient.Name + ' for ' + FormatDateTime('dddd, mmmm d, yyyy', uDate2), True); <-- original line. //kt 8/17/2007
695 ReportBox(VitalsMemo(Patient.DFN, date1, date2, lstVitals.Items), DKLangConstW('fVitals_Vitals_on')+' ' + Patient.Name + DKLangConstW('fVitals_for')+' ' + FormatDateTime('dddd, mmmm d, yyyy', uDate2), True); //kt added 8/17/2007
696 end
697 else
698 begin
699 date1 := DateTimeToFMDateTime(chtChart.BottomAxis.Maximum);
700 date2 := DateTimeToFMDateTime(chtChart.BottomAxis.Minimum);
701 tmpList := TStringList.Create;
702 try
703 tmpList.Add(lstVitals.Items[lstVitals.ItemIndex]);
704// if serTest.Title = 'Systolic' then <-- original line. //kt 8/17/2007
705 if serTest.Title = DKLangConstW('fVitals_Systolic') then //kt added 8/17/2007
706// StatusText('Retrieving data for Blood Pressure...') <-- original line. //kt 8/17/2007
707 StatusText(DKLangConstW('fVitals_Retrieving_data_for_Blood_Pressurexxx')) //kt added 8/17/2007
708 else
709// StatusText('Retrieving data for ' + serTest.Title + '...'); <-- original line. //kt 8/17/2007
710 StatusText(DKLangConstW('fVitals_Retrieving_data_for') + serTest.Title + '...'); //kt added 8/17/2007
711// ReportBox(VitalsMemo(Patient.DFN, date1, date2, tmpList), serTest.Title + ' results on ' + Patient.Name, True); <-- original line. //kt 8/17/2007
712 ReportBox(VitalsMemo(Patient.DFN, date1, date2, tmpList), serTest.Title + DKLangConstW('fVitals_results_on') + Patient.Name, True); //kt added 8/17/2007
713 finally
714 tmpList.Free;
715 end;
716 end;
717 Screen.Cursor := crDefault;
718 StatusText('');
719end;
720
721procedure TfrmVitals.chtChartClickSeries(Sender: TCustomChart;
722 Series: TChartSeries; ValueIndex: Integer; Button: TMouseButton;
723 Shift: TShiftState; X, Y: Integer);
724begin
725 uDate1 := Series.XValue[ValueIndex];
726 uDate2 := uDate1;
727// chtChart.Hint := 'Details - Vitals for ' + FormatDateTime('dddd, mmmm d, yyyy', Series.XValue[ValueIndex]) + '...'; <-- original line. //kt 8/17/2007
728 chtChart.Hint := DKLangConstW('fVitals_Details_x_Vitals_for')+' ' + FormatDateTime('dddd, mmmm d, yyyy', Series.XValue[ValueIndex]) + '...'; //kt added 8/17/2007
729 chtChart.Tag := ValueIndex + 1;
730 if Button <> mbRight then popDetailsClick(self);
731end;
732
733procedure TfrmVitals.chtChartMouseDown(Sender: TObject;
734 Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
735begin
736 chtChart.Hint := '';
737 chtChart.Tag := 0;
738end;
739
740procedure TfrmVitals.chtChartClickLegend(Sender: TCustomChart;
741 Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
742begin
743//if serTest.Title = 'Systolic' then <-- original line. //kt 8/17/2007
744 if serTest.Title = DKLangConstW('fVitals_Systolic') then //kt added 8/17/2007
745// chtChart.Hint := 'Details - for Blood Pressure...' <-- original line. //kt 8/17/2007
746 chtChart.Hint := DKLangConstW('fVitals_Details_x_for_Blood_Pressurexxx') //kt added 8/17/2007
747 else
748// chtChart.Hint := 'Details - for ' + serTest.Title + '...'; <-- original line. //kt 8/17/2007
749 chtChart.Hint := DKLangConstW('fVitals_Details_x_for') + serTest.Title + '...'; //kt added 8/17/2007
750 chtChart.Tag := 0;
751 if Button <> mbRight then popDetailsClick(self);
752end;
753
754procedure TfrmVitals.popChartPopup(Sender: TObject);
755begin
756 popValues.Checked := chkValues.Checked;
757 pop3D.Checked := chk3D.Checked;
758 popZoom.Checked := chkZoom.Checked;
759 popZoomBack.Enabled := popZoom.Checked and not chtChart.BottomAxis.Automatic;;
760 if chtChart.Hint <> '' then
761 begin
762 popDetails.Caption := chtChart.Hint;
763 popDetails.Enabled := true;
764 end
765 else
766 begin
767// popDetails.Caption := 'Details...'; <-- original line. //kt 8/17/2007
768 popDetails.Caption := DKLangConstW('fVitals_Detailsxxx'); //kt added 8/17/2007
769 popDetails.Enabled := false;
770 end;
771end;
772
773procedure TfrmVitals.popPrintClick(Sender: TObject);
774var
775 GraphTitle: string;
776begin
777 GraphTitle := lstVitals.Items[lstVitals.ItemIndex] +
778 ' - ' +
779 lstDates.DisplayText[lstDates.ItemIndex];
780 if dlgWinPrint.Execute then PrintGraph(chtChart, GraphTitle);
781end;
782
783procedure TfrmVitals.BeginEndDates(var ADate1, ADate2: TFMDateTime; var ADaysBack: integer);
784var
785 datetemp: TFMDateTime;
786 today, datetime1, datetime2: TDateTime;
787 relativedate: string;
788begin
789 today := FMToDateTime(floattostr(FMToday));
790 relativedate := Piece(lstDates.ItemID, ';', 1);
791 relativedate := Piece(relativedate, '-', 2);
792 ADaysBack := strtointdef(relativedate, 0);
793 ADate1 := DateTimeToFMDateTime(today - ADaysBack);
794 relativedate := Piece(lstDates.ItemID, ';', 2);
795 if StrToIntDef(Piece(relativedate, '+', 2), 0) > 0 then
796 begin
797 relativedate := Piece(relativedate, '+', 2);
798 ADaysBack := strtointdef(relativedate, 0);
799 ADate2 := DateTimeToFMDateTime(today + ADaysBack + 1);
800 end
801 else
802 begin
803 relativedate := Piece(relativedate, '-', 2);
804 ADaysBack := strtointdef(relativedate, 0);
805 ADate2 := DateTimeToFMDateTime(today - ADaysBack);
806 end;
807 datetime1 := FMDateTimeToDateTime(ADate1);
808 datetime2 := FMDateTimeToDateTime(ADate2);
809 if datetime1 < datetime2 then // reorder dates, if needed
810 begin
811 datetemp := ADate1;
812 ADate1 := ADate2;
813 ADate2 := datetemp
814 end;
815 ADate1 := ADate1 + 0.2359;
816end;
817
818procedure TfrmVitals.FormKeyUp(Sender: TObject; var Key: Word;
819 Shift: TShiftState);
820begin
821 if Key = VK_ESCAPE then
822 begin
823 Key := 0;
824 Close;
825 end;
826end;
827
828end.
Note: See TracBrowser for help on using the repository browser.