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;
|
---|
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 | end;
|
---|
59 |
|
---|
60 | procedure TfrmODMisc.InitDialog;
|
---|
61 | begin
|
---|
62 | inherited;
|
---|
63 | cboCare.InitLongList('');
|
---|
64 | txtComment.Text := '';
|
---|
65 | end;
|
---|
66 |
|
---|
67 | procedure TfrmODMisc.SetupDialog(OrderAction: Integer; const ID: string);
|
---|
68 | begin
|
---|
69 | inherited;
|
---|
70 | if OrderAction in [ORDER_COPY, ORDER_EDIT, ORDER_QUICK] then with Responses do
|
---|
71 | begin
|
---|
72 | Changing := True;
|
---|
73 | SetControl(cboCare, 'ORDERABLE', 1);
|
---|
74 | SetControl(txtComment, 'COMMENT', 1);
|
---|
75 | SetControl(calStart, 'START', 1);
|
---|
76 | SetControl(calStop, 'STOP', 1);
|
---|
77 | Changing := False;
|
---|
78 | ControlChange(Self);
|
---|
79 | SetFocusedControl(txtComment);
|
---|
80 | end;
|
---|
81 | end;
|
---|
82 |
|
---|
83 | procedure TfrmODMisc.Validate(var AnErrMsg: string);
|
---|
84 | var
|
---|
85 | ErrMsg: string;
|
---|
86 |
|
---|
87 | procedure SetError(const x: string);
|
---|
88 | begin
|
---|
89 | if Length(AnErrMsg) > 0 then AnErrMsg := AnErrMsg + CRLF;
|
---|
90 | AnErrMsg := AnErrMsg + x;
|
---|
91 | end;
|
---|
92 |
|
---|
93 | begin
|
---|
94 | if cboCare.ItemIEN <= 0 then SetError(TX_NO_CAREITEM);
|
---|
95 | calStart.Validate(ErrMsg);
|
---|
96 | if Length(ErrMsg) > 0 then SetError(TX_BAD_START);
|
---|
97 | with calStop do
|
---|
98 | begin
|
---|
99 | Validate(ErrMsg);
|
---|
100 | if Length(ErrMsg) > 0 then SetError(TX_BAD_STOP);
|
---|
101 | if (Length(Text) > 0) and (FMDateTime <= calStart.FMDateTime)
|
---|
102 | then SetError(TX_STOPSTART);
|
---|
103 | end; {with calStop}
|
---|
104 | end;
|
---|
105 |
|
---|
106 | procedure TfrmODMisc.cboCareNeedData(Sender: TObject; const StartFrom: string;
|
---|
107 | Direction, InsertAt: Integer);
|
---|
108 | begin
|
---|
109 | inherited;
|
---|
110 | cboCare.ForDataUse(SubSetOfOrderItems(StartFrom, Direction, 'S.NURS'));
|
---|
111 | end;
|
---|
112 |
|
---|
113 | procedure TfrmODMisc.ControlChange(Sender: TObject);
|
---|
114 | begin
|
---|
115 | inherited;
|
---|
116 | if Changing then Exit;
|
---|
117 | Responses.Clear;
|
---|
118 | with cboCare do if ItemIEN > 0 then Responses.Update('ORDERABLE', 1, ItemID, Text);
|
---|
119 | with txtComment do if Length(Text) > 0 then Responses.Update('COMMENT', 1, Text, Text);
|
---|
120 | with calStart do if Length(Text) > 0 then Responses.Update('START', 1, Text, Text);
|
---|
121 | with calStop do if Length(Text) > 0 then Responses.Update('STOP', 1, Text, Text);
|
---|
122 | memOrder.Text := Responses.OrderText;
|
---|
123 | end;
|
---|
124 |
|
---|
125 | end.
|
---|