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

Last change on this file since 1224 was 829, checked in by Kevin Toppenberg, 14 years ago

Upgrade to version 27

File size: 3.6 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;
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('');
58end;
59
60procedure TfrmODMisc.InitDialog;
61begin
62 inherited;
63 cboCare.InitLongList('');
64 txtComment.Text := '';
65end;
66
67procedure TfrmODMisc.SetupDialog(OrderAction: Integer; const ID: string);
68begin
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;
81end;
82
83procedure TfrmODMisc.Validate(var AnErrMsg: string);
84var
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
93begin
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}
104end;
105
106procedure TfrmODMisc.cboCareNeedData(Sender: TObject; const StartFrom: string;
107 Direction, InsertAt: Integer);
108begin
109 inherited;
110 cboCare.ForDataUse(SubSetOfOrderItems(StartFrom, Direction, 'S.NURS'));
111end;
112
113procedure TfrmODMisc.ControlChange(Sender: TObject);
114begin
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;
123end;
124
125end.
Note: See TracBrowser for help on using the repository browser.