source: cprs/trunk/CPRS-Chart/Orders/fODMisc.pas@ 1800

Last change on this file since 1800 was 1679, checked in by healthsevak, 10 years ago

Updating the working copy to CPRS version 28

File size: 3.7 KB
Line 
1unit fODMisc;
2
3interface
4
5uses
6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
7 fODBase, StdCtrls, ORCtrls, ORDtTm, ComCtrls, ExtCtrls, ORFn, uConst,
8 VA508AccessibilityManager, VA508AccessibilityRouter;
9
10type
11 TfrmODMisc = class(TfrmODBase)
12 cboCare: TORComboBox;
13 lblStart: TLabel;
14 calStart: TORDateBox;
15 lblStop: TLabel;
16 calStop: TORDateBox;
17 lblCare: TLabel;
18 lblComment: TLabel;
19 txtComment: TCaptionEdit;
20 procedure ControlChange(Sender: TObject);
21 procedure FormCreate(Sender: TObject);
22 procedure cboCareNeedData(Sender: TObject; const StartFrom: String;
23 Direction, InsertAt: Integer);
24 private
25 { }
26 protected
27 procedure InitDialog; override;
28 procedure Validate(var AnErrMsg: string); override;
29 public
30 procedure SetupDialog(OrderAction: Integer; const ID: string); override;
31 end;
32
33var
34 frmODMisc: TfrmODMisc;
35
36implementation
37
38{$R *.DFM}
39
40uses rODBase;
41
42const
43 TX_NO_CAREITEM = 'A patient care item must be selected.';
44 TX_BAD_START = 'The start date is not valid.';
45 TX_BAD_STOP = 'The stop date is not valid.';
46 TX_STOPSTART = 'The stop date must be after the start date.';
47
48procedure TfrmODMisc.FormCreate(Sender: TObject);
49begin
50 inherited;
51 FillerID := 'OR'; // does 'on Display' order check **KCM**
52 StatusText('Loading Dialog Definition');
53 Responses.Dialog := 'OR GXMISC GENERAL'; // loads formatting info
54 StatusText('Loading Default Values');
55 //CtrlInits.LoadDefaults(ODForMisc); // there are no defaults for OR GXMISC
56 InitDialog;
57 StatusText('');
58 if ScreenReaderSystemActive then memOrder.TabStop := true;
59end;
60
61procedure TfrmODMisc.InitDialog;
62begin
63 inherited;
64 cboCare.InitLongList('');
65 txtComment.Text := '';
66end;
67
68procedure TfrmODMisc.SetupDialog(OrderAction: Integer; const ID: string);
69begin
70 inherited;
71 if OrderAction in [ORDER_COPY, ORDER_EDIT, ORDER_QUICK] then with Responses do
72 begin
73 Changing := True;
74 SetControl(cboCare, 'ORDERABLE', 1);
75 SetControl(txtComment, 'COMMENT', 1);
76 SetControl(calStart, 'START', 1);
77 SetControl(calStop, 'STOP', 1);
78 Changing := False;
79 ControlChange(Self);
80 if not ScreenReaderSystemActive then SetFocusedControl(txtComment);
81 end;
82end;
83
84procedure TfrmODMisc.Validate(var AnErrMsg: string);
85var
86 ErrMsg: string;
87
88 procedure SetError(const x: string);
89 begin
90 if Length(AnErrMsg) > 0 then AnErrMsg := AnErrMsg + CRLF;
91 AnErrMsg := AnErrMsg + x;
92 end;
93
94begin
95 if cboCare.ItemIEN <= 0 then SetError(TX_NO_CAREITEM);
96 calStart.Validate(ErrMsg);
97 if Length(ErrMsg) > 0 then SetError(TX_BAD_START);
98 with calStop do
99 begin
100 Validate(ErrMsg);
101 if Length(ErrMsg) > 0 then SetError(TX_BAD_STOP);
102 if (Length(Text) > 0) and (FMDateTime <= calStart.FMDateTime)
103 then SetError(TX_STOPSTART);
104 end; {with calStop}
105end;
106
107procedure TfrmODMisc.cboCareNeedData(Sender: TObject; const StartFrom: string;
108 Direction, InsertAt: Integer);
109begin
110 inherited;
111 cboCare.ForDataUse(SubSetOfOrderItems(StartFrom, Direction, 'S.NURS'));
112end;
113
114procedure TfrmODMisc.ControlChange(Sender: TObject);
115begin
116 inherited;
117 if Changing then Exit;
118 Responses.Clear;
119 with cboCare do if ItemIEN > 0 then Responses.Update('ORDERABLE', 1, ItemID, Text);
120 with txtComment do if Length(Text) > 0 then Responses.Update('COMMENT', 1, Text, Text);
121 with calStart do if Length(Text) > 0 then Responses.Update('START', 1, Text, Text);
122 with calStop do if Length(Text) > 0 then Responses.Update('STOP', 1, Text, Text);
123 memOrder.Text := Responses.OrderText;
124end;
125
126end.
Note: See TracBrowser for help on using the repository browser.