source: cprs/branches/foia-cprs/CPRS-Chart/fvit.pas@ 1482

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

Adding foia-cprs branch

File size: 15.0 KB
Line 
1{///////////////////////////////////////////////////////
2//Description: This form has been copied form the vital entry tab in fPCEEdit
3// It is intended to be used for vital entry off of the cover sheet in CPRS and
4// posibly being ported to a separate application from CPRS that only does Vital entry.
5//
6//Created: April 1998
7//Author: Robert Bott
8//Location: ISL
9//
10//To Do List:
11// needs to be modified to use the application font settings.
12
13////////////////////////////////////////////////////////
14//Modifed: 4/21/98
15//By: Robert Bott
16//Location: ISL
17//Description of Mod: Modified this unit to use only the Date/time entered
18// rather than the encounter.datetime.
19//
20//Modifed: 5/06/98
21//By: Robert Bott
22//Location: ISL
23//Description of Mod: removed DateStrToFMDateTimeStr function and added
24// TOTDateBox to allow the date/time to be edited.
25//
26//Modifed: 6/15/98
27//By: Robert Bott
28//Location: ISL
29//Description of Mod: moved line of code to change caption from formCreate event
30// to formShow event. This prevents an error occuring at that line if there is
31// not a broker connection.
32
33//Modifed: 6/23/98
34//By: Robert Bott
35//Location: ISL
36//Description of Mod:
37// Moved code that verifies valid provider and visit from fvit into fVitals.
38// now found in procedure TfrmVitals.btnEnterVitalsClick(Sender: TObject);
39// formerly in procedure TfrmVit.FormActivate(Sender: TObject);
40
41//Modifed: 9/18/98
42//By: Robert Bott
43//Location: ISL
44//Description of Mod:
45// changed procedure TfrmVit.cmdOKClick to display the error message returned
46// from ValAndStoreVitals.
47
48//Modifed: 12/10/98
49//By: Robert Bott
50//Location: ISL
51//Description of Mod:
52// Changed oredr of display and entry to Temp, Pulse, Resp, B/P, HT, WT
53
54//Modifed: 6/29/99
55//By: Robert Bott
56//Location: ISL
57//Description of Mod:
58// Changed AssignVitals finction to round conversions before storing them.
59
60///////////////////////////////////////////////////////////////////////////////}
61
62unit fvit;
63
64interface
65
66uses
67 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
68 ExtCtrls, fAutoSz,StdCtrls, ORFn, ORCtrls, rvitals, ORDtTm;
69
70
71type
72 TfrmVit = class(TfrmAutoSz)
73 pnlmain: TPanel;
74 lblDate: TStaticText;
75 lblDateBP: TStaticText;
76 lblDateTemp: TStaticText;
77 lblDateResp: TStaticText;
78 lblDatePulse: TStaticText;
79 lblDateHeight: TStaticText;
80 lblDateWeight: TStaticText;
81 lblLstMeas: TStaticText;
82 lbllastBP: TStaticText;
83 lblLastTemp: TStaticText;
84 lblLastResp: TStaticText;
85 lblLastPulse: TStaticText;
86 lblLastHeight: TStaticText;
87 lblLastWeight: TStaticText;
88 txtMeasBP: TCaptionEdit;
89 cboTemp: TCaptionComboBox;
90 txtMeasTemp: TCaptionEdit;
91 txtMeasResp: TCaptionEdit;
92 txtMeasPulse: TCaptionEdit;
93 txtMeasHt: TCaptionEdit;
94 cboHeight: TCaptionComboBox;
95 txtMeasWt: TCaptionEdit;
96 cboWeight: TCaptionComboBox;
97 lblVitPointer: TOROffsetLabel;
98 cmdOK: TButton;
99 cmdCancel: TButton;
100 lblVital: TStaticText;
101 lblVitBP: TStaticText;
102 lnlVitTemp: TStaticText;
103 lblVitResp: TStaticText;
104 lblVitPulse: TStaticText;
105 lblVitHeight: TStaticText;
106 lblVitWeight: TStaticText;
107 txtMeasDate: TORDateBox;
108 lblDatePain: TStaticText;
109 lblLastPain: TStaticText;
110 lblVitPain: TStaticText;
111 cboPain: TORComboBox;
112 procedure FormKeyPress(Sender: TObject; var Key: Char);
113 procedure txtMeasBPExit(Sender: TObject);
114 procedure cboTempChange(Sender: TObject);
115 procedure cboTempExit(Sender: TObject);
116 procedure txtMeasRespExit(Sender: TObject);
117 procedure txtMeasPulseExit(Sender: TObject);
118 procedure cboHeightChange(Sender: TObject);
119 procedure cboHeightExit(Sender: TObject);
120 procedure cboWeightChange(Sender: TObject);
121 procedure cboWeightExit(Sender: TObject);
122 procedure FormCreate(Sender: TObject);
123 procedure FormDestroy(Sender: TObject);
124 procedure cmdCancelClick(Sender: TObject);
125 procedure cmdOKClick(Sender: TObject);
126 procedure lbllastClick(Sender: TObject);
127 procedure FormShow(Sender: TObject);
128 procedure FormActivate(Sender: TObject);
129 procedure cboPainChange(Sender: TObject);
130 procedure SetVitPointer(Sender: TObject);
131 procedure txtMeasTempExit(Sender: TObject);
132 procedure txtMeasHtExit(Sender: TObject);
133 procedure txtMeasWtExit(Sender: TObject);
134
135 private
136 { Private declarations }
137 procedure InitVitalPanel;
138 procedure PopulateLastVital;
139 function GetVitHTRate: String;
140 procedure AssignVitals;
141 procedure CheckVitalUnit(AWinControl: TWinControl);
142 public
143 { Public declarations }
144 end;
145
146const
147 TX_NEED_VISIT = 'A visit or location is required before entering vital signs.';
148 TX_NO_VISIT = 'Insufficient Visit Information';
149 TX_NEED_PROVIDER = 'A valid provider must be selected before entering vital signs.';
150 TX_NO_PROVIDER = 'Undefined Provider';
151
152var
153 frmVit: TfrmVit;
154 uVitalLocation: Real;
155 //uVitalNew: TStringlist;
156
157implementation
158
159{$R *.DFM}
160
161uses UCore, rCore, rPCE, fPCELex, fPCEOther, fVitals,fVisit, fFrame, fEncnt,
162 uVitals;
163
164var
165 uVitalOld: TStringlist;
166 uVitalNew: TStringlist;
167 UcboVitChanging: Boolean = False;
168
169
170{Start of code for Vital Page--------------------------------------------------}
171procedure TfrmVit.FormKeyPress(Sender: TObject; var Key: Char);
172{capture return key press if on the vital screen}
173begin
174 inherited;
175 if (ActiveControl.tag IN ([TAG_VITTEMP,TAG_VITPULSE,TAG_VITRESP,
176 TAG_VITBP,TAG_VITHEIGHT,TAG_VITWEIGHT,TAG_VITTEMPUNIT,TAG_VITHTUNIT,TAG_VITWTUNIT,TAG_VITPAIN,TAG_VITDATE]))then
177 begin
178 if Key = #13 then
179 begin
180 Key := #0;
181
182 if (activeControl.Tag = TAG_VITPAIN) then cmdOK.setfocus
183 else
184 begin
185 Perform(WM_NEXTDLGCTL,0,0);
186 SetVitPointer(Sender);
187 end;
188 end;
189 end;
190
191end;
192
193procedure TfrmVit.InitVitalPanel;
194begin
195 lblDate.font.Style := [fsBold];
196 lblDateBP.font.Style := [fsBold];
197 lblDateTemp.font.Style := [fsBold];
198 lblDateResp.font.Style := [fsBold];
199 lblDatePulse.font.Style := [fsBold];
200 lblDateHeight.font.Style := [fsBold];
201 lblDateWeight.font.Style := [fsBold];
202 lblDatePain.font.style := [fsBold]; {*RAB*}
203 lblLstMeas.font.Style := [fsBold];
204 lblLastBP.font.Style := [fsBold];
205 lblLastTemp.font.Style := [fsBold];
206 lblLastResp.font.Style := [fsBold];
207 lblLastPulse.font.Style := [fsBold];
208 lblLastHeight.font.Style := [fsBold];
209 lblLastWeight.font.Style := [fsBold];
210 lblLastPain.font.style := [fsBold]; {*RAB*}
211 lblVital.font.Style := [fsbold];
212
213
214 UcboVitChanging := true; //prevents entering code in CheckVitalUnit
215 try
216 InitPainCombo(cboPain);
217 cboTemp.Text := cboTemp.Items[0];
218 cboHeight.Text := cboHeight.Items[0];
219 cboWeight.Text := cboWeight.Items[0];
220 finally
221 UcboVitchanging := False; //prevents entering code in CheckVitalUnit
222 end;
223
224 txtMeasDate.Text := FormatFMDateTime('mmm dd,yy@hh:nn', FMNOW);
225
226 if (UvitalOld.text = '') then
227 PopulateLastVital;
228end;
229
230
231
232procedure TfrmVit.PopulateLastVital;
233var
234 i: integer;
235begin
236 GetLastVital(uVitalOld,Patient.DFN);
237 //populate labels from UVitalOld;
238 with UVitalOld do
239 for i := 0 to count-1 do
240 begin
241 if piece(strings[i],U,2) = 'T' then
242 begin
243 lblLastTemp.Caption := piece(strings[i],U,3);
244 lblDateTemp.Caption := FormatFMDateTime('mmm dd,yy',
245 StrToFloat(piece(strings[i],U,4)));
246 end;
247 if piece(strings[i],U,2) = 'P' then
248 begin
249 lblLastPulse.Caption := piece(strings[i],U,3);
250 lblDatePulse.Caption := FormatFMDateTime('mmm dd,yy',
251 StrToFloat(piece(strings[i],U,4)));
252 end;
253 if piece(strings[i],U,2) = 'R' then
254 begin
255 lblLastResp.Caption := piece(strings[i],U,3);
256 lblDateResp.Caption := FormatFMDateTime('mmm dd,yy',
257 StrToFloat(piece(strings[i],U,4)));
258 end;
259 if piece(strings[i],U,2) = 'BP' then
260 begin
261 lblLastBP.Caption := piece(strings[i],U,3);
262 lblDateBP.Caption := FormatFMDateTime('mmm dd,yy',
263 StrToFloat(piece(strings[i],U,4)));
264 end;
265 if piece(strings[i],U,2) = 'HT' then
266 begin
267 lblLastHeight.Caption := piece(strings[i],U,3);
268 lblDateHeight.Caption := FormatFMDateTime('mmm dd,yy',
269 StrToFloat(piece(strings[i],U,4)));
270 end;
271 if piece(strings[i],U,2) = 'WT' then
272 begin
273 lblLastWeight.Caption := piece(strings[i],U,3);
274 lblDateWeight.Caption := FormatFMDateTime('mmm dd,yy',
275 StrToFloat(piece(strings[i],U,4)));
276 end;
277 if piece(strings[i],U,2) = 'PN' then {*RAB*}
278 begin
279 lblLastPain.Caption := piece(strings[i],U,3); {*RAB*}
280 lblDatePain.Caption := FormatFMDateTime('mmm dd,yy', {*RAB*}
281 StrToFloat(piece(strings[i],U,4))); {*RAB*}
282
283 end;
284 end;
285
286end;
287
288
289
290function TfrmVit.GetVitHTRate: String;
291begin
292 Result := ConvertHeight2Inches(txtMeasHT.Text);
293 txtMeasHT.text := Result;
294end;
295
296//procedure: procedure TFrmVit.AssignVitals;
297//Modifed: 10/02/98
298//By: Robert Bott
299//Location: ISL
300//Description of Mod:
301// If encounter.provider is not defined (=0) then use User.DUZ to store vitals.
302procedure TFrmVit.AssignVitals;
303begin
304 AssignVitals2List(uVitalNew, txtMeasDate.FMDateTime, FloatToStr(uVitalLocation),
305 txtMeasBP.text, txtMeasTemp.text, cboTemp.text,
306 txtMeasResp.text, txtMeasPulse.text, GetVitHTRate, cboHeight.text,
307 txtMeasWT.text, cboWeight.text, cboPain.ItemID);
308end;
309
310procedure TfrmVit.cboTempChange(Sender: TObject);
311begin
312 inherited;
313 if not (cbotemp.droppeddown) then
314 CheckVitalUnit(cboTemp);
315end;
316
317
318procedure TFrmVit.CheckVitalUnit(AWinControl: TWinControl);
319var
320 len,i: integer;
321 found: boolean;
322 comp: string; //substring for comparing
323 temp: string;
324begin
325 if (UcboVitchanging = true) then exit;
326
327 UcboVitChanging := true;
328 try
329 with AWinControl as TComboBox do
330 begin
331 found := False;
332 temp := (AWinControl as TComboBox).text;
333 while (found = false) and (Length(temp) > 0) do
334 begin
335 i := 0;
336 while (found = false) and (length(items[i]) > 0) do
337 begin
338 len := length(temp);
339 //match text to string
340 comp := copy(items[i],0,len);
341 if (CompareText(comp,temp) = 0) then
342 begin
343 found := true;
344 (AWinControl as TComboBox).Text := '';
345 (AWinControl as TComboBox).text := items[i];
346
347 end;
348 inc(i);
349 end;
350 if (found = false) then Delete(temp,1,1);
351 end;
352 if (found = False) then
353 begin
354 (AWinControl as TComboBox).Text := '';
355 end;
356 end;
357 finally
358 UcboVitChanging := false;
359 end;
360end;
361
362
363procedure TfrmVit.cboHeightChange(Sender: TObject);
364begin
365 inherited;
366 CheckVitalUnit(cboHeight);
367end;
368
369procedure TfrmVit.cboWeightChange(Sender: TObject);
370begin
371 inherited;
372 CheckVitalUnit(cboWeight);
373end;
374
375procedure TfrmVit.txtMeasBPExit(Sender: TObject);
376begin
377 inherited;
378 if VitalInvalid(txtMeasBP) then
379 txtMeasBP.SetFocus;
380end;
381
382procedure TfrmVit.cboTempExit(Sender: TObject);
383begin
384 inherited;
385 if(ActiveControl <> txtMeasTemp) then
386 begin
387 if VitalInvalid(txtMeasTemp, cboTemp) then
388 txtMeasTemp.SetFocus;
389 end;
390end;
391
392procedure TfrmVit.txtMeasRespExit(Sender: TObject);
393begin
394 inherited;
395 if VitalInvalid(txtMeasResp) then
396 txtMeasResp.SetFocus;
397end;
398
399procedure TfrmVit.txtMeasPulseExit(Sender: TObject);
400begin
401 inherited;
402 if VitalInvalid(txtMeasPulse) then
403 txtMeasPulse.SetFocus;
404end;
405
406procedure TfrmVit.cboHeightExit(Sender: TObject);
407begin
408 inherited;
409 if(ActiveControl <> txtMeasHt) then
410 begin
411 if VitalInvalid(txtMeasHt, cboHeight, GetVitHTRate) then
412 txtMeasHt.SetFocus;
413 end;
414end;
415
416procedure TfrmVit.cboWeightExit(Sender: TObject);
417begin
418 inherited;
419 if(ActiveControl <> txtMeasWt) then
420 begin
421 if VitalInvalid(txtMeasWt, cboWeight) then
422 txtMeasWt.SetFocus;
423 end;
424end;
425
426procedure TfrmVit.FormCreate(Sender: TObject);
427
428begin
429 inherited;
430 //uVisitType := TPCEProc.create;
431 uVitalOld := TStringList.create;
432 uVitalNew := TStringList.create;
433 ResizeAnchoredFormToFont(self);
434end;
435
436
437
438procedure TfrmVit.FormDestroy(Sender: TObject);
439
440begin
441 inherited;
442 //uVisitType.Free;
443 uVitalOld.Free;
444 uVitalNew.free;
445end;
446
447
448
449procedure TfrmVit.cmdCancelClick(Sender: TObject);
450begin
451 inherited;
452 close();
453end;
454
455procedure TfrmVit.cmdOKClick(Sender: TObject);
456var
457 StoreMessage: string;
458begin
459 inherited;
460 // do validation for vitals & anything else here
461 AssignVitals;
462
463 //store vitals
464 StoreMessage := ValAndStoreVitals(UVitalNew);
465 if (Storemessage <> 'True') then
466 begin
467 showmessage(storemessage);
468 exit;
469 end;
470 close();
471end;
472
473procedure TfrmVit.lbllastClick(Sender: TObject);
474begin
475 inherited;
476 //
477 try
478 frmVitals.Show;
479 except
480 with sender as tLabel do
481 SelectVital(self.Font.Size, tag);
482 end; //end of try
483end;
484
485
486procedure TfrmVit.FormShow(Sender: TObject);
487begin
488 inherited;
489 frmVit.caption := 'Vital entry for - '+ patient.name; {RAB 6/15/98}
490end;
491
492procedure TfrmVit.FormActivate(Sender: TObject);
493begin
494 inherited;
495 InitVitalPanel;
496 txtMeasTemp.setfocus; //added 3/30/99 after changing tab order.
497 //The date is now first in tab order, but it shouldn't default there.
498
499end;
500
501
502procedure TfrmVit.cboPainChange(Sender: TObject);
503begin
504 inherited;
505 CheckVitalUnit(cboPain);
506end;
507
508procedure TfrmVit.SetVitPointer(Sender: TObject);
509begin
510 if ActiveControl.tag in ([TAG_VITTEMP, TAG_VITPULSE, TAG_VITRESP, TAG_VITBP, TAG_VITHEIGHT,
511 TAG_VITWEIGHT]) then
512 begin
513 // move pointer to some height and five pixels to right of edit box.
514 lblVitPointer.Top := ActiveControl.Top+((ActiveControl.height ) div
515 (lblVitPointer.height ));
516
517 if ActiveControl = txtMeasTemp then
518 lblVitPointer.left := (cboTemp.left + cboTemp.Width)
519 else if ActiveControl = txtMeasHT then
520 lblVitPointer.left := (cboHeight.left + cboHeight.Width)
521 else if ActiveControl = txtMeasWT then
522 lblVitPointer.left := (cboWeight.left + cboWeight.Width)
523 else
524 lblVitPointer.left := (ActiveControl.left + ActiveControl.Width);
525
526 end;
527end;
528
529procedure TfrmVit.txtMeasTempExit(Sender: TObject);
530begin
531 if(ActiveControl <> cboTemp) then
532 begin
533 if VitalInvalid(txtMeasTemp, cboTemp) then
534 txtMeasTemp.SetFocus;
535 end;
536end;
537
538procedure TfrmVit.txtMeasHtExit(Sender: TObject);
539begin
540 if(ActiveControl <> cboHeight) then
541 begin
542 if VitalInvalid(txtMeasHt, cboHeight, GetVitHTRate) then
543 txtMeasHt.SetFocus;
544 end;
545end;
546
547procedure TfrmVit.txtMeasWtExit(Sender: TObject);
548begin
549 if(ActiveControl <> cboWeight) then
550 begin
551 if VitalInvalid(txtMeasWt, cboWeight) then
552 txtMeasWt.SetFocus;
553 end;
554end;
555
556end.
Note: See TracBrowser for help on using the repository browser.