1 | unit fODMisc;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
---|
7 | fODBase, StdCtrls, ORCtrls, ORDtTm, ComCtrls, ExtCtrls, ORFn, uConst,
|
---|
8 | VA508AccessibilityManager, VA508AccessibilityRouter;
|
---|
9 |
|
---|
10 | type
|
---|
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 |
|
---|
33 | var
|
---|
34 | frmODMisc: TfrmODMisc;
|
---|
35 |
|
---|
36 | implementation
|
---|
37 |
|
---|
38 | {$R *.DFM}
|
---|
39 |
|
---|
40 | uses rODBase;
|
---|
41 |
|
---|
42 | const
|
---|
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 |
|
---|
48 | procedure TfrmODMisc.FormCreate(Sender: TObject);
|
---|
49 | begin
|
---|
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;
|
---|
59 | end;
|
---|
60 |
|
---|
61 | procedure TfrmODMisc.InitDialog;
|
---|
62 | begin
|
---|
63 | inherited;
|
---|
64 | cboCare.InitLongList('');
|
---|
65 | txtComment.Text := '';
|
---|
66 | end;
|
---|
67 |
|
---|
68 | procedure TfrmODMisc.SetupDialog(OrderAction: Integer; const ID: string);
|
---|
69 | begin
|
---|
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;
|
---|
82 | end;
|
---|
83 |
|
---|
84 | procedure TfrmODMisc.Validate(var AnErrMsg: string);
|
---|
85 | var
|
---|
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 |
|
---|
94 | begin
|
---|
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}
|
---|
105 | end;
|
---|
106 |
|
---|
107 | procedure TfrmODMisc.cboCareNeedData(Sender: TObject; const StartFrom: string;
|
---|
108 | Direction, InsertAt: Integer);
|
---|
109 | begin
|
---|
110 | inherited;
|
---|
111 | cboCare.ForDataUse(SubSetOfOrderItems(StartFrom, Direction, 'S.NURS'));
|
---|
112 | end;
|
---|
113 |
|
---|
114 | procedure TfrmODMisc.ControlChange(Sender: TObject);
|
---|
115 | begin
|
---|
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;
|
---|
124 | end;
|
---|
125 |
|
---|
126 | end.
|
---|