[459] | 1 | unit fNoteBD;
|
---|
| 2 |
|
---|
| 3 | interface
|
---|
| 4 |
|
---|
| 5 | uses
|
---|
| 6 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ORFN,
|
---|
| 7 | StdCtrls, ExtCtrls, ORCtrls, ORDtTm, uTIU;
|
---|
| 8 |
|
---|
| 9 | type
|
---|
| 10 | TfrmNotesByDate = class(TForm)
|
---|
| 11 | pnlBase: TORAutoPanel;
|
---|
| 12 | lblBeginDate: TLabel;
|
---|
| 13 | calBeginDate: TORDateBox;
|
---|
| 14 | lblEndDate: TLabel;
|
---|
| 15 | calEndDate: TORDateBox;
|
---|
| 16 | radSort: TRadioGroup;
|
---|
| 17 | cmdOK: TButton;
|
---|
| 18 | cmdCancel: TButton;
|
---|
| 19 | procedure cmdOKClick(Sender: TObject);
|
---|
| 20 | procedure cmdCancelClick(Sender: TObject);
|
---|
| 21 | procedure calBeginDateKeyPress(Sender: TObject; var Key: Char);
|
---|
| 22 | procedure calEndDateKeyPress(Sender: TObject; var Key: Char);
|
---|
| 23 | private
|
---|
| 24 | FChanged: Boolean;
|
---|
| 25 | FBeginDate: string;
|
---|
| 26 | FFMBeginDate: TFMDateTime;
|
---|
| 27 | FEndDate: string;
|
---|
| 28 | FFMEndDate: TFMDateTime;
|
---|
| 29 | FAscending: Boolean;
|
---|
| 30 | end;
|
---|
| 31 |
|
---|
| 32 | TNoteDateRange = record
|
---|
| 33 | Changed: Boolean;
|
---|
| 34 | BeginDate: string;
|
---|
| 35 | FMBeginDate: TFMDateTime;
|
---|
| 36 | EndDate: string;
|
---|
| 37 | FMEndDate: TFMDateTime;
|
---|
| 38 | Ascending: Boolean;
|
---|
| 39 | end;
|
---|
| 40 |
|
---|
| 41 | procedure SelectNoteDateRange(FontSize: Integer; CurrentContext: TTIUContext; var NoteDateRange: TNoteDateRange);
|
---|
| 42 |
|
---|
| 43 | implementation
|
---|
| 44 |
|
---|
| 45 | {$R *.DFM}
|
---|
| 46 |
|
---|
| 47 | uses rCore, rTIU;
|
---|
| 48 |
|
---|
| 49 | const
|
---|
| 50 | TX_DATE_ERR = 'Enter valid beginning and ending dates or press Cancel.';
|
---|
| 51 | TX_DATE_ERR_CAP = 'Error in Date Range';
|
---|
| 52 |
|
---|
| 53 | procedure SelectNoteDateRange(FontSize: Integer; CurrentContext: TTIUContext; var NoteDateRange: TNoteDateRange);
|
---|
| 54 | { displays date range select form for progress notes and returns a record of the selection }
|
---|
| 55 | var
|
---|
| 56 | frmNotesByDate: TfrmNotesByDate;
|
---|
| 57 | W, H: Integer;
|
---|
| 58 | begin
|
---|
| 59 | frmNotesByDate := TfrmNotesByDate.Create(Application);
|
---|
| 60 | try
|
---|
| 61 | with frmNotesByDate do
|
---|
| 62 | begin
|
---|
| 63 | Font.Size := FontSize;
|
---|
| 64 | W := ClientWidth;
|
---|
| 65 | H := ClientHeight;
|
---|
| 66 | ResizeToFont(FontSize, W, H);
|
---|
| 67 | ClientWidth := W; pnlBase.Width := W;
|
---|
| 68 | ClientHeight := H; pnlBase.Height := W;
|
---|
| 69 | FChanged := False;
|
---|
| 70 | calBeginDate.Text := CurrentContext.BeginDate;
|
---|
| 71 | calEndDate.Text := CurrentContext.EndDate;
|
---|
| 72 | if calEndDate.Text = '' then calEndDate.Text := 'TODAY';
|
---|
| 73 | FAscending := CurrentContext.TreeAscending;
|
---|
| 74 | with radSort do if FAscending then ItemIndex := 0 else ItemIndex := 1;
|
---|
| 75 | ShowModal;
|
---|
| 76 | with NoteDateRange do
|
---|
| 77 | begin
|
---|
| 78 | Changed := FChanged;
|
---|
| 79 | BeginDate := FBeginDate;
|
---|
| 80 | FMBeginDate := FFMBeginDate;
|
---|
| 81 | EndDate := FEndDate;
|
---|
| 82 | FMEndDate := FFMEndDate;
|
---|
| 83 | Ascending := FAscending;
|
---|
| 84 | end; {with NoteDateRange}
|
---|
| 85 | end; {with frmNotesByDate}
|
---|
| 86 | finally
|
---|
| 87 | frmNotesByDate.Release;
|
---|
| 88 | end;
|
---|
| 89 | end;
|
---|
| 90 |
|
---|
| 91 | procedure TfrmNotesByDate.cmdOKClick(Sender: TObject);
|
---|
| 92 | var
|
---|
| 93 | bdate, edate: TFMDateTime;
|
---|
| 94 | begin
|
---|
| 95 | if calBeginDate.Text <> '' then
|
---|
| 96 | bdate := StrToFMDateTime(calBeginDate.Text)
|
---|
| 97 | else
|
---|
| 98 | bdate := 0 ;
|
---|
| 99 |
|
---|
| 100 | if calEndDate.Text <> '' then
|
---|
| 101 | edate := StrToFMDateTime(calEndDate.Text)
|
---|
| 102 | else
|
---|
| 103 | edate := 0 ;
|
---|
| 104 |
|
---|
| 105 | if (bdate <= edate) then
|
---|
| 106 | begin
|
---|
| 107 | FChanged := True;
|
---|
| 108 | FBeginDate := calBeginDate.Text;
|
---|
| 109 | FFMBeginDate := bdate;
|
---|
| 110 | FEndDate := calEndDate.Text;
|
---|
| 111 | FFMEndDate := edate;
|
---|
| 112 | FAscending := radSort.ItemIndex = 0;
|
---|
| 113 | end
|
---|
| 114 | else
|
---|
| 115 | begin
|
---|
| 116 | InfoBox(TX_DATE_ERR, TX_DATE_ERR_CAP, MB_OK or MB_ICONWARNING);
|
---|
| 117 | Exit;
|
---|
| 118 | end;
|
---|
| 119 | Close;
|
---|
| 120 | end;
|
---|
| 121 |
|
---|
| 122 | procedure TfrmNotesByDate.cmdCancelClick(Sender: TObject);
|
---|
| 123 | begin
|
---|
| 124 | Close;
|
---|
| 125 | end;
|
---|
| 126 |
|
---|
| 127 | procedure TfrmNotesByDate.calBeginDateKeyPress(Sender: TObject;
|
---|
| 128 | var Key: Char);
|
---|
| 129 | begin
|
---|
| 130 | if (Key = #13) then cmdOKClick(Self);
|
---|
| 131 | end;
|
---|
| 132 |
|
---|
| 133 | procedure TfrmNotesByDate.calEndDateKeyPress(Sender: TObject;
|
---|
| 134 | var Key: Char);
|
---|
| 135 | begin
|
---|
| 136 | if (Key = #13) then cmdOKClick(Self);
|
---|
| 137 | end;
|
---|
| 138 |
|
---|
| 139 | end.
|
---|