[456] | 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 |
|
---|
| 9 | type
|
---|
| 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 |
|
---|
| 32 | var
|
---|
| 33 | frmODMisc: TfrmODMisc;
|
---|
| 34 |
|
---|
| 35 | implementation
|
---|
| 36 |
|
---|
| 37 | {$R *.DFM}
|
---|
| 38 |
|
---|
| 39 | uses rODBase;
|
---|
| 40 |
|
---|
| 41 | const
|
---|
| 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 |
|
---|
| 47 | procedure TfrmODMisc.FormCreate(Sender: TObject);
|
---|
| 48 | begin
|
---|
| 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('');
|
---|
| 57 | end;
|
---|
| 58 |
|
---|
| 59 | procedure TfrmODMisc.InitDialog;
|
---|
| 60 | begin
|
---|
| 61 | inherited;
|
---|
| 62 | cboCare.InitLongList('');
|
---|
| 63 | txtComment.Text := '';
|
---|
| 64 | end;
|
---|
| 65 |
|
---|
| 66 | procedure TfrmODMisc.SetupDialog(OrderAction: Integer; const ID: string);
|
---|
| 67 | begin
|
---|
| 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;
|
---|
| 80 | end;
|
---|
| 81 |
|
---|
| 82 | procedure TfrmODMisc.Validate(var AnErrMsg: string);
|
---|
| 83 | var
|
---|
| 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 |
|
---|
| 92 | begin
|
---|
| 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}
|
---|
| 103 | end;
|
---|
| 104 |
|
---|
| 105 | procedure TfrmODMisc.cboCareNeedData(Sender: TObject; const StartFrom: string;
|
---|
| 106 | Direction, InsertAt: Integer);
|
---|
| 107 | begin
|
---|
| 108 | inherited;
|
---|
| 109 | cboCare.ForDataUse(SubSetOfOrderItems(StartFrom, Direction, 'S.NURS'));
|
---|
| 110 | end;
|
---|
| 111 |
|
---|
| 112 | procedure TfrmODMisc.ControlChange(Sender: TObject);
|
---|
| 113 | begin
|
---|
| 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;
|
---|
| 122 | end;
|
---|
| 123 |
|
---|
| 124 | end.
|
---|