source: cprs/branches/foia-cprs/CPRS-Chart/fNoteCPFields.pas@ 1059

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

Adding foia-cprs branch

File size: 4.7 KB
Line 
1unit fNoteCPFields;
2
3interface
4
5uses
6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
7 fAutoSz, StdCtrls, ORCtrls, ORFn, ORDtTm;
8
9type
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
33const
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
44procedure EnterClinProcFields(ACPStatusFlag: integer; ErrMsg: string; var AProcSummCode: integer; var AProcDate: TFMDateTime; var AnAuthor: int64);
45
46implementation
47
48{$R *.DFM}
49
50uses rCore, uConst, uConsults, uCore;
51
52procedure EnterClinProcFields(ACPStatusFlag: integer; ErrMsg: string; var AProcSummCode: integer; var AProcDate: TFMDateTime; var AnAuthor: int64);
53var
54 frmNoteCPFields: TfrmNoteCPFields;
55begin
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;
75end;
76
77procedure TfrmNoteCPFields.FormCreate(Sender: TObject);
78begin
79 inherited;
80 FOKPressed := False;
81 cboAuthor.InitLongList(User.Name);
82 cboAuthor.SelectByIEN(User.DUZ);
83end;
84
85procedure TfrmNoteCPFields.cmdOKClick(Sender: TObject);
86var
87 ErrMsg: string;
88begin
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;
98end;
99
100procedure TfrmNoteCPFields.ValidateFields(var ErrMsg: string);
101begin
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;
121end;
122
123procedure TfrmNoteCPFields.cmdCancelClick(Sender: TObject);
124var
125 ErrMsg: string;
126begin
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;
133end;
134
135procedure TfrmNoteCPFields.cboAuthorNeedData(Sender: TObject;
136 const StartFrom: String; Direction, InsertAt: Integer);
137begin
138 (Sender as TORComboBox).ForDataUse(SubSetOfPersons(StartFrom, Direction));
139end;
140
141end.
Note: See TracBrowser for help on using the repository browser.