| 1 | unit fNoteCPFields;
|
---|
| 2 |
|
---|
| 3 | interface
|
---|
| 4 |
|
---|
| 5 | uses
|
---|
| 6 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
---|
| 7 | fAutoSz, StdCtrls, ORCtrls, ORFn, ORDtTm, VA508AccessibilityManager;
|
---|
| 8 |
|
---|
| 9 | type
|
---|
| 10 | TfrmNoteCPFields = class(TfrmAutoSz)
|
---|
| 11 | lblAuthor: TLabel;
|
---|
| 12 | cboAuthor: TORComboBox;
|
---|
| 13 | lblProcSummCode: TOROffsetLabel;
|
---|
| 14 | cboProcSummCode: TORComboBox;
|
---|
| 15 | lblProcDateTime: TOROffsetLabel;
|
---|
| 16 | calProcDateTime: TORDateBox;
|
---|
| 17 | cmdOK: TButton;
|
---|
| 18 | cmdCancel: TButton;
|
---|
| 19 | procedure cmdCancelClick(Sender: TObject);
|
---|
| 20 | procedure FormCreate(Sender: TObject);
|
---|
| 21 | procedure cmdOKClick(Sender: TObject);
|
---|
| 22 | procedure cboAuthorNeedData(Sender: TObject; const StartFrom: String;
|
---|
| 23 | Direction, InsertAt: Integer);
|
---|
| 24 | private
|
---|
| 25 | FAuthor: int64;
|
---|
| 26 | FProcSummCode: integer;
|
---|
| 27 | FProcDateTime: TFMDateTime;
|
---|
| 28 | FCPStatusFlag: integer;
|
---|
| 29 | FOKPressed: Boolean;
|
---|
| 30 | procedure ValidateFields(var ErrMsg: string);
|
---|
| 31 | end;
|
---|
| 32 |
|
---|
| 33 | const
|
---|
| 34 | TC_REQ_FIELDS = 'Required Information';
|
---|
| 35 | TX_REQ_AUTHOR = CRLF + 'The author of the note must be identified.';
|
---|
| 36 | TX_NO_FUTURE = CRLF + 'A reference date/time in the future is not allowed.';
|
---|
| 37 | TX_REQ_PROCSUMMCODE = CRLF + 'A procedure summary code for this procedure must be entered.';
|
---|
| 38 | TX_REQ_PROCDATETIME = CRLF + 'A valid date/time for the procedure must be entered.';
|
---|
| 39 | TX_INVALID_PROCDATETIME = CRLF + 'If entered, the date/time for the procedure must be in a valid format.';
|
---|
| 40 | TX_NO_PROC_FUTURE = CRLF + 'A procedure date/time in the future is not allowed.';
|
---|
| 41 | TX_REQ_CANCEL = 'You will be required to enter these fields before the note can be saved or signed.' + CRLF +
|
---|
| 42 | 'Click the "Change" button to enter this information at any time while editing.';
|
---|
| 43 |
|
---|
| 44 | procedure EnterClinProcFields(ACPStatusFlag: integer; ErrMsg: string; var AProcSummCode: integer; var AProcDate: TFMDateTime; var AnAuthor: int64);
|
---|
| 45 |
|
---|
| 46 | implementation
|
---|
| 47 |
|
---|
| 48 | {$R *.DFM}
|
---|
| 49 |
|
---|
| 50 | uses rCore, uConst, uConsults, uCore;
|
---|
| 51 |
|
---|
| 52 | procedure EnterClinProcFields(ACPStatusFlag: integer; ErrMsg: string; var AProcSummCode: integer; var AProcDate: TFMDateTime; var AnAuthor: int64);
|
---|
| 53 | var
|
---|
| 54 | frmNoteCPFields: TfrmNoteCPFields;
|
---|
| 55 | begin
|
---|
| 56 | frmNoteCPFields := TfrmNoteCPFields.Create(Application);
|
---|
| 57 | with frmNoteCPFields do
|
---|
| 58 | try
|
---|
| 59 | ResizeFormToFont(TForm(frmNoteCPFields));
|
---|
| 60 | FCPStatusFlag := ACPStatusFlag;
|
---|
| 61 | FProcSummCode := AProcSummCode;
|
---|
| 62 | FProcDateTime := AProcDate;
|
---|
| 63 | cboProcSummCode.SelectByIEN(AProcSummCode);
|
---|
| 64 | calProcDateTime.FMDateTime := AProcDate;
|
---|
| 65 | ShowModal;
|
---|
| 66 | if FOKPressed then
|
---|
| 67 | begin
|
---|
| 68 | AnAuthor := FAuthor;
|
---|
| 69 | AProcSummCode := FProcSummCode;
|
---|
| 70 | AProcDate := FProcDateTime;
|
---|
| 71 | end;
|
---|
| 72 | finally
|
---|
| 73 | Release;
|
---|
| 74 | end;
|
---|
| 75 | end;
|
---|
| 76 |
|
---|
| 77 | procedure TfrmNoteCPFields.FormCreate(Sender: TObject);
|
---|
| 78 | begin
|
---|
| 79 | inherited;
|
---|
| 80 | FOKPressed := False;
|
---|
| 81 | cboAuthor.InitLongList(User.Name);
|
---|
| 82 | cboAuthor.SelectByIEN(User.DUZ);
|
---|
| 83 | end;
|
---|
| 84 |
|
---|
| 85 | procedure TfrmNoteCPFields.cmdOKClick(Sender: TObject);
|
---|
| 86 | var
|
---|
| 87 | ErrMsg: string;
|
---|
| 88 | begin
|
---|
| 89 | inherited;
|
---|
| 90 | ValidateFields(ErrMsg);
|
---|
| 91 | if ShowMsgOn(Length(ErrMsg) > 0, ErrMsg, TC_REQ_FIELDS)
|
---|
| 92 | then Exit
|
---|
| 93 | else
|
---|
| 94 | begin
|
---|
| 95 | FOKPressed := True;
|
---|
| 96 | ModalResult := mrOK;
|
---|
| 97 | end;
|
---|
| 98 | end;
|
---|
| 99 |
|
---|
| 100 | procedure TfrmNoteCPFields.ValidateFields(var ErrMsg: string);
|
---|
| 101 | begin
|
---|
| 102 | if cboAuthor.ItemIEN = 0 then ErrMsg := ErrMsg + TX_REQ_AUTHOR else FAuthor := cboAuthor.ItemIEN;
|
---|
| 103 | if (FCPStatusFlag = CP_INSTR_INCOMPLETE) then
|
---|
| 104 | begin
|
---|
| 105 | if cboProcSummCode.ItemIEN = 0 then ErrMsg := ErrMsg + TX_REQ_PROCSUMMCODE
|
---|
| 106 | else FProcSummCode := cboProcSummCode.ItemIEN;
|
---|
| 107 | if not calProcDateTime.IsValid then ErrMsg := ErrMsg + TX_REQ_PROCDATETIME
|
---|
| 108 | else if calProcDateTime.IsValid and (calProcDateTime.FMDateTime > FMNow) then ErrMsg := ErrMsg + TX_NO_PROC_FUTURE
|
---|
| 109 | else FProcDateTime := calProcDateTime.FMDateTime;
|
---|
| 110 | end
|
---|
| 111 | else
|
---|
| 112 | begin
|
---|
| 113 | FProcSummCode := cboProcSummCode.ItemIEN;
|
---|
| 114 | if (calProcDateTime.FMDateTime > 0) then
|
---|
| 115 | begin
|
---|
| 116 | if (not calProcDateTime.IsValid) then ErrMsg := ErrMsg + TX_INVALID_PROCDATETIME
|
---|
| 117 | else if calProcDateTime.IsValid and (calProcDateTime.FMDateTime > FMNow) then ErrMsg := ErrMsg + TX_NO_PROC_FUTURE
|
---|
| 118 | else FProcDateTime := calProcDateTime.FMDateTime;
|
---|
| 119 | end;
|
---|
| 120 | end;
|
---|
| 121 | end;
|
---|
| 122 |
|
---|
| 123 | procedure TfrmNoteCPFields.cmdCancelClick(Sender: TObject);
|
---|
| 124 | var
|
---|
| 125 | ErrMsg: string;
|
---|
| 126 | begin
|
---|
| 127 | inherited;
|
---|
| 128 | ValidateFields(ErrMsg);
|
---|
| 129 | if ErrMsg <> '' then
|
---|
| 130 | InfoBox(TX_REQ_CANCEL, TC_REQ_FIELDS, MB_OK or MB_ICONWARNING);
|
---|
| 131 | FOKPressed := False;
|
---|
| 132 | Close;
|
---|
| 133 | end;
|
---|
| 134 |
|
---|
| 135 | procedure TfrmNoteCPFields.cboAuthorNeedData(Sender: TObject;
|
---|
| 136 | const StartFrom: String; Direction, InsertAt: Integer);
|
---|
| 137 | begin
|
---|
| 138 | (Sender as TORComboBox).ForDataUse(SubSetOfPersons(StartFrom, Direction));
|
---|
| 139 | end;
|
---|
| 140 |
|
---|
| 141 | end.
|
---|