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

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

Initial Upload of Official WV CPRS 1.0.26.76

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