Module

fAddlSigners

Path

C:\CPRS\CPRS30\fAddlSigners.pas

Last Modified

7/15/2014 3:26:36 PM

Units Used in Interface

Name Comments
fBase508Form -
fNoteProps -

Units Used in Implementation

Name Comments
fDCSumm -
rCore -
rPCE -
rTIU -
uConst -
uCore -

Classes

Name Comments
TfrmAddlSigners -

Procedures

Name Owner Declaration Scope Comments
btnAddSignersClick TfrmAddlSigners procedure btnAddSignersClick(Sender: TObject); Public/Published -
btnRemoveAllSignersClick TfrmAddlSigners procedure btnRemoveAllSignersClick(Sender: TObject); Public/Published -
btnRemoveSignersClick TfrmAddlSigners procedure btnRemoveSignersClick(Sender: TObject); Public/Published -
cboCosignerChange TfrmAddlSigners procedure cboCosignerChange(Sender: TObject); Public/Published -
cboCosignerExit TfrmAddlSigners procedure cboCosignerExit(Sender: TObject); Public/Published -
cboCosignerNeedData TfrmAddlSigners procedure cboCosignerNeedData(Sender: TObject; const StartFrom: String; Direction, InsertAt: Integer); Public/Published -
cboSrcListChange TfrmAddlSigners procedure cboSrcListChange(Sender: TObject); Public/Published -
cboSrcListKeyDown TfrmAddlSigners procedure cboSrcListKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); Public/Published -
cmdCancelClick TfrmAddlSigners procedure cmdCancelClick(Sender: TObject); Public/Published -
cmdOKClick TfrmAddlSigners procedure cmdOKClick(Sender: TObject); Public/Published -
DstListChange TfrmAddlSigners procedure DstListChange(Sender: TObject); Public/Published -
FormCreate TfrmAddlSigners procedure FormCreate(Sender: TObject); Public/Published -
FormDestroy TfrmAddlSigners procedure FormDestroy(Sender: TObject); Public/Published -
NewPersonNeedData TfrmAddlSigners procedure NewPersonNeedData(Sender: TObject; const StartFrom: String; Direction, InsertAt: Integer); Public/Published -
SelectAdditionalSigners - procedure SelectAdditionalSigners(FontSize, NoteIEN, SigAction: Integer; Exclusions: TStrings; var SignerList: TSignerList; TabID: integer; ARefDate: TFMDateTime) ; Interfaced Displays additional signer form for notes and returns a record of the selection

Functions

Name Owner Declaration Scope Comments
CosignerOK TfrmAddlSigners function CosignerOK: Boolean; Private -

Constants

Name Declaration Scope Comments
SG_ADDITIONAL 1 Interfaced -
SG_BOTH 3 Interfaced -
SG_COSIGNER 2 Interfaced -
TX_BAD_SIGNER 'Cannot select author, user, expected signer, or expected cosigner' Global -
TX_DUP_SIGNER 'You have already selected that additional signer' Global -
TX_NO_COSIGNER ' is not authorized to cosign this document.' Global -
TX_NO_COSIGNER_CAP 'Invalid Cosigner' Global -
TX_NO_DELETE 'A cosigner is required' Global -
TX_NO_DELETE_CAP 'No cosigner selected' Global -
TX_SIGNER_CAP 'Error adding signers' Global -
TX_SIGNER_TEXT 'Select signers or press Cancel.' Global -


Module Source

1     unit fAddlSigners;
2     
3     interface
4     
5     uses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls, 
6       Buttons, ORCtrls, ORfn, ExtCtrls, fNoteProps, Dialogs, fBase508Form,
7       VA508AccessibilityManager;
8     
9     type
10      TfrmAddlSigners = class(TfrmBase508Form)
11        cmdOK: TButton;
12        cmdCancel: TButton;
13        cboSrcList: TORComboBox;
14        DstList: TORListBox;
15        SrcLabel: TLabel;
16        DstLabel: TLabel;
17        pnlBase: TPanel;
18        btnRemoveSigners: TButton;
19        lblAuthor: TOROffsetLabel;
20        cboCosigner: TORComboBox;
21        lblCosigner: TOROffsetLabel;
22        txtAuthor: TCaptionEdit;
23        pnlAdditional: TORAutoPanel;
24        pnlButtons: TORAutoPanel;
25        pnlTop: TORAutoPanel;
26        btnAddSigners: TButton;
27        btnRemoveAllSigners: TButton;
28        procedure btnAddSignersClick(Sender: TObject);
29        procedure NewPersonNeedData(Sender: TObject; const StartFrom: String;
30          Direction, InsertAt: Integer);
31        procedure cmdOKClick(Sender: TObject);
32        procedure cmdCancelClick(Sender: TObject);
33        procedure btnRemoveSignersClick(Sender: TObject);
34        procedure FormCreate(Sender: TObject);
35        procedure FormDestroy(Sender: TObject);
36        procedure cboCosignerChange(Sender: TObject);
37        procedure cboSrcListKeyDown(Sender: TObject; var Key: Word;
38          Shift: TShiftState);
39        procedure cboCosignerNeedData(Sender: TObject; const StartFrom: String;
40          Direction, InsertAt: Integer);
41        procedure cboCosignerExit(Sender: TObject);
42        procedure DstListChange(Sender: TObject);
43        procedure btnRemoveAllSignersClick(Sender: TObject);
44        procedure cboSrcListChange(Sender: TObject);
45      private
46        FSigners: TStringList ;
47        FCosigner: int64;
48        FExclusions: TStringList;
49        FSigAction: integer;
50        FChanged: Boolean;
51        FNoteIEN: integer;
52        FRefDate: TFMDateTime;
53        FToday: string;
54        FTabID: integer;
55        function CosignerOK: Boolean;
56        
57      end;
58    
59    TSignerList = record
60        Changed: Boolean;
61        Signers: TStringList ;
62        Cosigner: int64;
63      end;
64    
65    procedure SelectAdditionalSigners(FontSize, NoteIEN, SigAction: Integer; Exclusions: TStrings;
66              var SignerList: TSignerList; TabID: integer; ARefDate: TFMDateTime) ;
67    
68    const
69      SG_ADDITIONAL = 1;
70      SG_COSIGNER   = 2;
71      SG_BOTH       = 3;
72    
73    implementation
74    
75    {$R *.DFM}
76    
77    uses
78      rCore, uCore, rTIU, uConst, rPCE, fDCSumm;
79    
80    const
81      TX_SIGNER_CAP = 'Error adding signers';
82      TX_SIGNER_TEXT = 'Select signers or press Cancel.';
83      TX_BAD_SIGNER = 'Cannot select author, user, expected signer, or expected cosigner' ;
84      TX_DUP_SIGNER = 'You have already selected that additional signer';
85      TX_NO_COSIGNER = ' is not authorized to cosign this document.';
86      TX_NO_COSIGNER_CAP = 'Invalid Cosigner';
87      TX_NO_DELETE = 'A cosigner is required';
88      TX_NO_DELETE_CAP = 'No cosigner selected';
89    
90    
91    procedure SelectAdditionalSigners(FontSize, NoteIEN, SigAction: Integer; Exclusions: TStrings;
92              var SignerList: TSignerList; TabID: integer; ARefDate: TFMDateTime) ;
93    { displays additional signer form for notes and returns a record of the selection }
94    var
95      frmAddlSigners: TfrmAddlSigners;
96      W, H, i: Integer;
97    begin
98      frmAddlSigners := TfrmAddlSigners.Create(Application);
99      try
100       with frmAddlSigners do
101       begin
102         FTabID := TabID;
103         FSigAction := SigAction;
104         FNoteIEN := NoteIEN;
105         FRefDate := ARefDate;
106         FastAssign(Exclusions, FExclusions);
107         FToday := FloatToStr(FMToday);
108         if FSigAction = SG_COSIGNER then
109           begin
110             pnlAdditional.Visible := False;
111             Height := Height - pnlAdditional.Height;
112           end;
113         Font.Size := FontSize;
114         W := ClientWidth;
115         H := ClientHeight;
116         ResizeToFont(FontSize, W, H);
117         ClientWidth  := W; pnlBase.Width  := W;
118         ClientHeight := H; pnlBase.Height := H;
119         with FExclusions do for i := 0 to Count-1 do
120           begin
121             if Piece(Strings[i],U,3) = 'Author' then txtAuthor.Text := Piece(Strings[i], U, 2)
122             else if Piece(Strings[i],U,3) = 'Expected Cosigner' then
123               begin
124                 cboCosigner.Items.Add(Strings[i]);
125                 cboCosigner.ItemIndex := 0;
126               end
127             else
128             begin
129               DstList.Items.Add(Strings[i]);
130               btnRemoveAllSigners.Enabled := DstList.Items.Count > 0;
131             end;
132           end;
133   
134         if (SigAction = SG_COSIGNER) or (SigAction = SG_BOTH) then
135           begin
136             lblCosigner.Caption := 'Expected cosigner';
137             cboCosigner.Caption := 'Expected cosigner';
138             cboCosigner.Color := clWindow;
139             cboCosigner.Enabled := True;
140             cboCosigner.InitLongList('');
141           end;
142         if (SigAction = SG_ADDITIONAL) or (SigAction = SG_BOTH) then
143           cboSrcList.InitLongList('');
144         FChanged := False;
145         ShowModal;
146         with SignerList do
147           begin
148             Signers := TStringList.Create;
149             FastAssign(FSigners, Signers);
150             Cosigner := FCosigner;
151             Changed := FChanged ;
152           end ;
153       end; {with frmAddlSigners}
154     finally
155       frmAddlSigners.Release;
156     end;
157   end;
158   
159   procedure TfrmAddlSigners.NewPersonNeedData(Sender: TObject;
160     const StartFrom: String; Direction, InsertAt: Integer);
161   begin
162     TORComboBox(Sender).ForDataUse(SubSetOfPersons(StartFrom, Direction));
163   end;
164   
165   procedure TfrmAddlSigners.cmdCancelClick(Sender: TObject);
166   begin
167     Close;
168   end;
169   
170   procedure TfrmAddlSigners.cmdOKClick(Sender: TObject);
171   var
172     i: integer;
173   begin
174     FChanged := False;
175     if (FSigAction = SG_ADDITIONAL) and ((DstList.Items.Count = 0) and (FSigners.Count = 0)) then
176     begin
177       InfoBox(TX_SIGNER_TEXT, TX_SIGNER_CAP, MB_OK or MB_ICONWARNING);
178       Exit;
179     end;
180     if not CosignerOK then Exit;
181     FChanged := True;
182     FCosigner := cboCosigner.ItemIEN;
183     for i := 0 to DstList.Items.Count-1 do
184       begin
185         if fExclusions.IndexOf(DstList.Items[i]) < 0 then FSigners.Add(DstList.Items[i]);
186       end;
187     Close;
188   end;
189   
190   procedure TfrmAddlSigners.btnRemoveAllSignersClick(Sender: TObject);
191   begin
192     inherited;
193     DstList.SelectAll;
194     btnRemoveSignersClick(self);
195   end;
196   
197   procedure TfrmAddlSigners.btnRemoveSignersClick(Sender: TObject);
198   var
199     i,j: integer;
200   begin
201     with DstList do
202       begin
203         if ItemIndex = -1 then exit ;
204         for i := Items.Count-1 downto 0 do
205           if Selected[i] then
206             begin
207               j := FExclusions.IndexOf(Items[i]);
208               FSigners.Add(ORFn.Pieces(Items[i], U, 1, 2) + '^REMOVE');
209               if j > -1 then FExclusions.Delete(j);
210               Items.Delete(i) ;
211             end;
212       end;
213   end;
214   
215   procedure TfrmAddlSigners.btnAddSignersClick(Sender: TObject);
216   var
217     i: integer;
218   begin
219     if cboSrcList.ItemIndex = -1 then
220       exit;
221     if UserInactive(cboSrcList.ItemID) then
222       if (InfoBox(fNoteProps.TX_USER_INACTIVE, TC_INACTIVE_USER, MB_OKCANCEL)= IDCANCEL) then
223         exit;
224   
225     if (DstList.SelectByID(cboSrcList.ItemID) <> -1) then
226       begin
227         InfoBox(TX_DUP_SIGNER, TX_SIGNER_CAP, MB_OK or MB_ICONWARNING);
228         Exit;
229       end;
230     for i := 0 to FExclusions.Count-1 do
231       if (Piece(FExclusions.Strings[i],U,1) = cboSrcList.ItemID) then
232         begin
233           InfoBox(TX_BAD_SIGNER, TX_SIGNER_CAP, MB_OK or MB_ICONWARNING);
234           Exit;
235         end;
236     DstList.Items.Add(cboSrcList.Items[cboSrcList.Itemindex]) ;
237     btnRemoveSigners.Enabled := DstList.SelCount > 0;
238     btnRemoveAllSigners.Enabled := DstList.Items.Count > 0;
239   end;
240   
241   procedure TfrmAddlSigners.cboCosignerChange(Sender: TObject);
242   var
243     i: integer;
244   begin
245     with cboCosigner do
246     begin
247       if UserInactive(ItemID) then
248         if (InfoBox(fNoteProps.TX_USER_INACTIVE, TC_INACTIVE_USER, MB_OKCANCEL)= IDCANCEL) then exit;
249       if not CosignerOK then Exit;
250       i := DstList.SelectByID(ItemID);
251       if i > -1 then
252       begin
253         DstList.Items.Delete(i);
254         FSigners.Add(ORFn.Pieces(Items[ItemIndex], U, 1, 2) + '^REMOVE');
255       end;
256       for i := 0 to FExclusions.Count - 1 do
257         if (Piece(FExclusions.Strings[i],U,3) = 'Expected Cosigner') then
258           FExclusions.Strings[i] := ORFn.Pieces(Items[ItemIndex], U, 1, 2) + '^Expected Cosigner';
259     end;
260   end;
261   
262   procedure TfrmAddlSigners.FormCreate(Sender: TObject);
263   begin
264     FSigners := TStringList.Create;
265     FExclusions := TStringList.Create;
266   end;
267   
268   procedure TfrmAddlSigners.FormDestroy(Sender: TObject);
269   begin
270     FSigners.Free;
271     FExclusions.Free;
272   end;
273   
274   procedure TfrmAddlSigners.DstListChange(Sender: TObject);
275   begin
276     inherited;
277     if DstList.SelCount = 1 then
278       if Piece(DstList.Items[0], '^', 1) = '' then
279       begin
280         btnRemoveSigners.Enabled := false;
281         btnRemoveAllSigners.Enabled := false;
282         exit;
283       end;
284     btnRemoveSigners.Enabled := DstList.SelCount > 0;
285     btnRemoveAllSigners.Enabled := DstList.Items.Count > 0;
286   end;
287   
288   procedure TfrmAddlSigners.cboSrcListKeyDown(Sender: TObject; var Key: Word;
289     Shift: TShiftState);
290   begin
291     if Key = VK_RETURN then btnAddSignersClick(Self);
292   end;
293   
294   function TfrmAddlSigners.CosignerOK: Boolean;
295   begin
296     Result := False;
297     if not cboCosigner.Enabled then
298       begin
299         Result := True;
300         Exit;
301       end;
302     if cboCosigner.ItemIndex < 0 then
303       begin
304         InfoBox(TX_NO_DELETE, TX_NO_DELETE_CAP, MB_OK or MB_ICONWARNING);
305         Exit;
306       end;
307     case FTabID of
308       CT_NOTES, CT_CONSULTS:
309         if (not CanCosign(TitleForNote(FNoteIEN), 0, cboCosigner.ItemIEN, FRefDate)) then
310           begin
311             InfoBox(cboCosigner.Text + TX_NO_COSIGNER, TX_NO_COSIGNER_CAP, MB_OK or MB_ICONWARNING);
312             Exit;
313           end;
314       CT_DCSUMM:
315         if not IsUserAProvider(cboCosigner.ItemIEN, FMNow) then
316           begin
317             InfoBox(cboCosigner.Text + TX_NO_COSIGNER, TX_NO_COSIGNER_CAP, MB_OK or MB_ICONWARNING);
318             Exit;
319           end;
320     end;
321     Result := True;
322   end;
323   
324   procedure TfrmAddlSigners.cboCosignerNeedData(Sender: TObject;
325     const StartFrom: String; Direction, InsertAt: Integer);
326   begin
327     case FTabID of
328       CT_NOTES:     TORComboBox(Sender).ForDataUse(SubSetOfUsersWithClass(StartFrom, Direction, FToday));
329       CT_CONSULTS:  TORComboBox(Sender).ForDataUse(SubSetOfUsersWithClass(StartFrom, Direction, FToday));
330   
331       //CQ #17218 - Updated to properly filter co-signers - JCS
332       //CT_DCSUMM:    TORComboBox(Sender).ForDataUse(SubSetOfProviders(StartFrom, Direction));
333       CT_DCSUMM: (Sender as TORComboBox).ForDataUse(SubSetOfCosigners(StartFrom, Direction,
334           FMToday, 0, frmDCSumm.lstSumms.ItemIEN));
335     end;
336   end;
337   
338   procedure TfrmAddlSigners.cboCosignerExit(Sender: TObject);
339   begin
340     with cboCosigner do if Text = '' then ItemIndex := -1;
341   end;
342   
343   procedure TfrmAddlSigners.cboSrcListChange(Sender: TObject);
344   begin
345     inherited;
346     btnAddSigners.Enabled := CboSrcList.ItemIndex > -1;
347     if (DstList.SelectByID(cboSrcList.ItemID) <> -1) then
348       btnAddSigners.Enabled := false;
349   end;
350   
351   end.

Module Calls (2 levels)


fAddlSigners
 ├fNoteProps
 │ ├rTIU
 │ ├uConst
 │ ├uTIU
 │ ├fBase508Form
 │ ├uCore
 │ ├rCore
 │ ├rConsults
 │ ├uConsults
 │ ├rSurgery
 │ └fRptBox
 ├fBase508Form...
 ├rCore...
 ├rTIU...
 ├uConst
 ├rPCE
 │ ├uPCE
 │ ├UBACore
 │ ├rCore...
 │ ├uCore...
 │ ├uConst
 │ ├fEncounterFrame
 │ ├UBAGlobals
 │ └UBAConst
 └fDCSumm
   ├fHSplit
   ├uConst
   ├uPCE...
   ├fDrawers
   ├rDCSumm
   ├uDocTree
   ├uDCSumm
   ├uTIU
   ├fPrintList
   ├fFrame
   ├fEncnt
   ├rCore...
   ├uCore...
   ├fNoteBA
   ├fNoteBD
   ├fSignItem
   ├fEncounterFrame...
   ├rPCE...
   ├fNotePrt
   ├fAddlSigners...
   ├fNoteDR
   ├uSpell
   ├fTIUView
   ├fTemplateEditor
   ├rTIU...
   ├fDCSummProps
   ├fNotesBP
   ├fTemplateFieldEditor
   ├uTemplates
   ├fReminderDialog
   ├dShared
   ├rTemplates
   ├fIconLegend
   ├fNoteIDParents
   ├fTemplateDialog
   └uVA508CPRSCompatibility

Module Called-By (2 levels)


       fAddlSigners
           fNotes┤ 
         fFrame┤ │ 
     fPrintList┤ │ 
    fNoteSTStop┤ │ 
      fConsults┤ │ 
fReminderDialog┤ │ 
        fReview┘ │ 
     fConsults...┤ 
          fDCSumm┤ 
      fFrame...┤ │ 
  fPrintList...┤ │ 
     fReview...┤ │ 
fAddlSigners...┘ │ 
         fSurgery┘ 
      fFrame...┤   
     fReview...┘