Module

fOrdersSign

Path

C:\CPRS\CPRS30\Orders\fOrdersSign.pas

Last Modified

7/15/2014 3:26:42 PM

Comments

.$define debug

Units Used in Interface

Name Comments
fAutoSz -
fBase508Form -
fCSRemaining -
fPrintLocation -
mCoPayDesc -
rODMeds -
UBAConst -
UBACore -
UBAGlobals -
UBAMessages -
uConsults -
XuDsigS -

Units Used in Implementation

Name Comments
fBALocalDiagnoses -
fClinicWardMeds -
fFrame -
fODConsult -
fOrders -
fOrdersPrint -
fPCELex -
fRptBox -
rCore -
rODLab -
rOrders -
rPCE -
uConst -
uCore -
uOrders -
uSignItems -

Classes

Name Comments
TfrmSignOrders -

Procedures

Name Owner Declaration Scope Comments
buOrdersDiagnosisClick TfrmSignOrders procedure buOrdersDiagnosisClick(Sender: TObject); Public/Published
Begin BillingAware
   New BA Button....
clstCSOrdersClick TfrmSignOrders procedure clstCSOrdersClick(Sender: TObject); Public/Published
If grid item is an order-able item, then enable the Diagnosis button
 else disable the Diagnosis button.
clstCSOrdersClickCheck TfrmSignOrders procedure clstCSOrdersClickCheck(Sender: TObject); Public/Published -
clstCSOrdersDrawItem TfrmSignOrders procedure clstCSOrdersDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); Public/Published
Begin BillingAware
End BillingAware
clstCSOrdersMeasureItem TfrmSignOrders procedure clstCSOrdersMeasureItem(Control: TWinControl; Index: Integer; var AHeight: Integer); Public/Published -
clstOrdersClick TfrmSignOrders procedure clstOrdersClick(Sender: TObject); Public/Published
If grid item is an order-able item, then enable the Diagnosis button
 else disable the Diagnosis button.
clstOrdersClickCheck TfrmSignOrders procedure clstOrdersClickCheck(Sender: TObject); Public/Published -
clstOrdersDrawItem TfrmSignOrders procedure clstOrdersDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); Public/Published
Begin BillingAware
End BillingAware
clstOrdersKeyUp TfrmSignOrders procedure clstOrdersKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); Public/Published -
clstOrdersMeasureItem TfrmSignOrders procedure clstOrdersMeasureItem(Control: TWinControl; Index: Integer; var AHeight: Integer); Public/Published -
clstOrdersMouseDown TfrmSignOrders procedure clstOrdersMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); Public/Published - Open copy/paste popup menu.
clstOrdersMouseMove TfrmSignOrders procedure clstOrdersMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); Public/Published
Begin BillingAware
End BillingAware
cmdCancelClick TfrmSignOrders procedure cmdCancelClick(Sender: TObject); Public/Published -
cmdOKClick TfrmSignOrders procedure cmdOKClick(Sender: TObject); Public/Published -
Copy1Click TfrmSignOrders procedure Copy1Click(Sender: TObject); Public/Published - Copy contents of the 'source' order for copy/paste operation
Exit1Click TfrmSignOrders procedure Exit1Click(Sender: TObject); Public/Published -
FormatListForScreenReader TfrmSignOrders procedure FormatListForScreenReader; Private -
FormCreate TfrmSignOrders procedure FormCreate(Sender: TObject); Public/Published -
FormDestroy TfrmSignOrders procedure FormDestroy(Sender: TObject); Public/Published -
FormKeyDown TfrmSignOrders procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); Public/Published -
FormMouseMove TfrmSignOrders procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); Public/Published -
FormPaint TfrmSignOrders procedure FormPaint(Sender: TObject); Public/Published -
FormResize TfrmSignOrders procedure FormResize(Sender: TObject); Public/Published -
FormShow TfrmSignOrders procedure FormShow(Sender: TObject); Public/Published -
fraCoPayLabel23Enter TfrmSignOrders procedure fraCoPayLabel23Enter(Sender: TObject); Public/Published -
fraCoPayLabel23Exit TfrmSignOrders procedure fraCoPayLabel23Exit(Sender: TObject); Public/Published -
fraCoPaylblHNCMouseMove TfrmSignOrders procedure fraCoPaylblHNCMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); Public/Published -
Log2File - procedure Log2File( crypto: tCryptography) ; Local -
Paste1Click TfrmSignOrders procedure Paste1Click(Sender: TObject); Public/Published - Populate 'target' orders of a copy/paste operation with contents of 'source' order
SetCheckBoxStatus TfrmSignOrders procedure SetCheckBoxStatus(thisOrderID: string); Public - Set the current GRID checkboxes status
SetItemTextToState TfrmSignOrders procedure SetItemTextToState; Private -
ShowTreatmentFactorHints TfrmSignOrders procedure ShowTreatmentFactorHints(var pHintText: string; var pCompName: TVA508StaticText); Private
508
BILLING AWARE Procedure

 508
updateAllChilds - procedure updateAllChilds(CheckedStatus: boolean; ParentOrderId: string); Local -
updateAllChilds - procedure updateAllChilds(CheckedStatus: boolean; ParentOrderId: string); Local -

Functions

Name Owner Declaration Scope Comments
AnyItemsAreChecked TfrmSignOrders function AnyItemsAreChecked: Boolean; Private -
CSItemsAreChecked TfrmSignOrders function CSItemsAreChecked: Boolean; Private Return true if any items in the Review List are checked for applying signature
DigitalSign - function DigitalSign: Boolean; Local -
ExecuteSignOrders - {Forward} function ExecuteSignOrders(SelectedList: TList): Boolean; Interfaced
End BillingAware

Forward} function ExecuteSignOrders(SelectedList: TList): Boolean;
ChangeItem: TChangeItem;
FindOrderText - function FindOrderText(const AnID: string): string; Local ChangeItem: TChangeItem;
GetCheckBoxStatus TfrmSignOrders function GetCheckBoxStatus(sourceOrderID : string) : string; overload; Public
PASS IN ORDER ID - NOT GRID INDEX

- Obtain checkbox status for selected order - BY ORDER ID
GetNumberOfSelectedOrders TfrmSignOrders function GetNumberOfSelectedOrders : byte; Private - Return the number of orders in clstOrders that are currently selected.
IsSignatureRequired TfrmSignOrders function IsSignatureRequired:boolean; Public/Published -
ItemsAreChecked TfrmSignOrders function ItemsAreChecked: Boolean; Private Return true if any items in the Review List are checked for applying signature
nonDCCSItemsAreChecked TfrmSignOrders function nonDCCSItemsAreChecked: Boolean; Private Return true if any items in the Review List are checked for applying signature
Piece2end - function Piece2end (s,del: string): string; Local -
SignNotRequired - function SignNotRequired: Boolean; Local -

Global Variables

Name Type Declaration Comments
ARect TRect ARect: TRect; -
arRect arRect: TarRect; -
chkBoxStatus UnicodeString chkBoxStatus: string; -
CopyBuffer TBADxRecord CopyBuffer: TBADxRecord; -
copyOrderID UnicodeString copyOrderID: string; -
crypto tCryptography crypto: tCryptography; -
FOSTFhintWindow Simple (unknown) FOSTFhintWindow: THintWindow; -
FOSTFHintWndActive Boolean FOSTFHintWndActive: boolean; -
frmSignOrders TfrmSignOrders frmSignOrders: TfrmSignOrders; Begin BillingAware
j ShortInt j: shortint; -
ProvDx ProvDx: TProvisionalDiagnosis; -
rectIndex Integer rectIndex: Integer; -
srcDx UnicodeString srcDx: string; -
srcIndex Integer srcIndex: integer; -
srcOrderID UnicodeString srcOrderID: string; -
targetOrderID UnicodeString targetOrderID: string; -
tempBillableList TStringList tempBillableList :TStringList; -
tempCSList TList tempCSList : TList; -
tempList TList tempList : TList; -
tempOrderList TStringList tempOrderList: TStringList; -
tempStrList TStringList tempStrList: TStringList; -
thisRect TRect thisRect: TRect; -

Constants

Name Declaration Scope Comments
TC_SAVERR 'Error Saving Order' Global -
TX_SAVERR1 'The error, ' Global -
TX_SAVERR2 ', occurred while trying to save:' + CRLF + CRLF Global -


Module Source

1     unit fOrdersSign;
2     
3     {.$define debug}
4     
5     interface
6     
7     uses
8       Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
9       fAutoSz, StdCtrls, StrUtils, ORFn, ORNet, ORCtrls, AppEvnts, mCoPayDesc, XuDsigS,
10      ComCtrls, CheckLst, ExtCtrls, uConsults, UBAGlobals,UBACore, UBAMessages, UBAConst,
11      Menus, ORClasses, fBase508Form, fPrintLocation, fCSRemaining, VA508AccessibilityManager,
12      rODMeds;
13    
14    type
15      TfrmSignOrders = class(TfrmBase508Form)
16        laDiagnosis: TLabel;
17        gbdxLookup: TGroupBox;
18        buOrdersDiagnosis: TButton;
19        poBACopyPaste: TPopupMenu;
20        Copy1: TMenuItem;
21        Paste1: TMenuItem; 
22        Diagnosis1: TMenuItem;
23        Exit1: TMenuItem;
24        fraCoPay: TfraCoPayDesc;
25        pnlDEAText: TPanel;
26        lblDEAText: TStaticText;
27        pnlProvInfo: TPanel;
28        lblProvInfo: TLabel;
29        pnlOrderList: TPanel;
30        lblOrderList: TStaticText;
31        clstOrders: TCaptionCheckListBox;
32        pnlCSOrderList: TPanel;
33        lblCSOrderList: TStaticText;
34        lblSmartCardNeeded: TStaticText;
35        clstCSOrders: TCaptionCheckListBox;
36        pnlEsig: TPanel;
37        lblESCode: TLabel;
38        txtESCode: TCaptionEdit;
39        cmdOK: TButton;
40        cmdCancel: TButton;
41        pnlCombined: TORAutoPanel;
42        pnlTop: TPanel;
43        procedure FormCreate(Sender: TObject);
44        procedure cmdOKClick(Sender: TObject);
45        procedure cmdCancelClick(Sender: TObject);
46        procedure FormDestroy(Sender: TObject);
47        procedure clstOrdersDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
48        procedure clstOrdersMeasureItem(Control: TWinControl; Index: Integer; var AHeight: Integer);
49        procedure clstOrdersClickCheck(Sender: TObject);
50        procedure clstOrdersMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
51        procedure FormShow(Sender: TObject);
52        procedure buOrdersDiagnosisClick(Sender: TObject);
53        function IsSignatureRequired:boolean;
54        procedure Exit1Click(Sender: TObject);
55        procedure Copy1Click(Sender: TObject);
56        procedure Paste1Click(Sender: TObject); 
57        procedure clstOrdersMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
58        procedure clstOrdersClick(Sender: TObject);
59        procedure FormKeyDown(Sender: TObject; var Key: Word;
60          Shift: TShiftState);
61        procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
62          Y: Integer); 
63        procedure fraCoPaylblHNCMouseMove(Sender: TObject; Shift: TShiftState;
64          X, Y: Integer);
65        procedure fraCoPayLabel23Enter(Sender: TObject);
66        procedure fraCoPayLabel23Exit(Sender: TObject);
67        procedure clstOrdersKeyUp(Sender: TObject; var Key: Word;
68          Shift: TShiftState);
69        procedure FormResize(Sender: TObject);
70        procedure clstCSOrdersClick(Sender: TObject);
71        procedure clstCSOrdersClickCheck(Sender: TObject);
72        procedure clstCSOrdersMeasureItem(Control: TWinControl; Index: Integer;
73          var AHeight: Integer);
74        procedure clstCSOrdersDrawItem(Control: TWinControl; Index: Integer;
75          Rect: TRect; State: TOwnerDrawState);
76        procedure FormPaint(Sender: TObject);
77      private
78        OKPressed: Boolean;
79        ESCode: string;
80        FLastHintItem: integer;
81        FOldHintPause: integer;
82        FOldHintHidePause: integer;
83        function ItemsAreChecked: Boolean;
84        function CSItemsAreChecked: Boolean;
85        function nonDCCSItemsAreChecked: Boolean;
86        function AnyItemsAreChecked: Boolean;
87        function GetNumberOfSelectedOrders : byte;
88        procedure ShowTreatmentFactorHints(var pHintText: string; var pCompName: TVA508StaticText); // 508
89        procedure SetItemTextToState;
90        procedure FormatListForScreenReader;
91      public
92        procedure SetCheckBoxStatus(thisOrderID: string);
93        function GetCheckBoxStatus(sourceOrderID : string) : string; overload;
94        
95    end;
96    
97    {Begin BillingAware}
98        TarRect = array[MIN_RECT..MAX_RECT] of TRect;
99    
100     var
101       thisRect: TRect;
102       j: shortint;
103       ARect: TRect;
104       arRect: TarRect;
105       ProvDx:  TProvisionalDiagnosis;
106       FOSTFHintWndActive: boolean;
107       FOSTFhintWindow: THintWindow;
108       tempList : TList;
109       tempCSList : TList;
110   
111   {End BillingAware}
112   
113   {Forward} function ExecuteSignOrders(SelectedList: TList): Boolean;
114   
115   var
116     crypto: tCryptography;
117     rectIndex: Integer;
118   
119     {Begin BillingAware}
120       frmSignOrders: TfrmSignOrders;
121       chkBoxStatus: string;
122       srcOrderID: string;
123       targetOrderID: string;
124       tempStrList: TStringList;
125       srcDx: string;
126       tempBillableList :TStringList;
127       tempOrderList: TStringList;
128       copyOrderID: string;
129       srcIndex: integer;
130       CopyBuffer: TBADxRecord;
131     {End BillingAware}
132   
133   implementation
134   
135   {$R *.DFM}
136   
137   uses
138     Hash, rCore, rOrders, uConst, fOrdersPrint, uCore, uOrders, uSignItems, fOrders,
139     fPCELex, rPCE, fODConsult, fBALocalDiagnoses, fClinicWardMeds, fFrame, rODLab, fRptBox,
140     VAUtils;
141   
142   const
143     TX_SAVERR1 = 'The error, ';
144     TX_SAVERR2 = ', occurred while trying to save:' + CRLF + CRLF;
145     TC_SAVERR  = 'Error Saving Order';
146   
147   function TfrmSignOrders.GetNumberOfSelectedOrders : byte;
148   {
149    - Return the number of orders in clstOrders that are currently selected.
150   }
151   var
152     i: integer;
153     numSelected: byte;
154   begin
155     Result := 0;
156     if BILLING_AWARE then
157        begin
158         numSelected := 0;
159   
160           try
161               for i := 0 to fOrdersSign.frmSignOrders.clstOrders.Items.Count-1 do
162                   if (fOrdersSign.frmSignOrders.clstOrders.Selected[i]) then
163                      Inc(numSelected);
164           except
165              on EListError do
166                 begin
167                 {$ifdef debug}Show508Message('EListError in frmSignOrders.GetNumberOfSelectedOrders()');{$endif}
168                 raise;
169                 end;
170           end;
171   
172         Result := numSelected;
173        end;
174   end;
175   
176   procedure TfrmSignOrders.SetCheckBoxStatus(thisOrderID: string);
177   {
178    - Set the current GRID checkboxes status
179   }
180   begin
181     if BILLING_AWARE then
182        begin
183           uSignItems.uSigItems.SetSigItems(clstOrders, thisOrderID);
184        end;
185   end;
186   
187   function TfrmSignOrders.GetCheckBoxStatus(sourceOrderID: string) : string;  //PASS IN ORDER ID - NOT GRID INDEX
188   {
189   - Obtain checkbox status for selected order - BY ORDER ID
190   }
191   var
192     itemsList: TStringList;
193     i: smallint;
194     thisOrderID: string;
195   begin
196     Result := '';
197     itemsList := TStringList.Create;
198     itemsList.Clear;
199     itemsList := uSigItems.GetSigItems; //Get FItems list
200     if BILLING_AWARE then
201        begin
202           try
203              for i := 0 to itemsList.Count-1 do
204                 begin
205                 thisOrderID := Piece(itemsList[i],'^',1); //get the order ID
206                 if thisOrderID = sourceOrderID then   //compare to order ID of source order
207                    begin
208                    Result := Piece(itemsList[i],U,4);  //return TF status'
209                    Break;
210                    end;
211                 end;
212           except
213              on EListError do
214                 begin
215                 {$ifdef debug}Show508Message('EListError in frmSignOrders.GetCheckBoxStatus()');{$endif}
216                 raise;
217                 end;
218           end;
219        end;
220   end;
221   
222   function ExecuteSignOrders(SelectedList: TList): Boolean;
223   const
224     VERT_SPACING = 6;
225   
226   var
227     i, k, cidx,cnt, theSts, WardIEN: Integer;
228     ShrinkHeight,oheight,newheight{,TotalSH},temph1,temph2,oltemptop,csoltemptop,deatemptop,esigtemptop,oltemph,csoltemph,deatemph,esigtemph: integer;
229     SignList: TStringList;
230     CSSignList: TStringList;
231     Obj: TOrder;
232     DigSigErr, DigStoreErr, ContainsIMOOrders, DoNotPrint, t1, t2,t3: Boolean;
233     x, SigData, SigUser, SigDrugSch, SigDEA: string;
234     cSignature, cHashData, cCrlUrl, cErr, WardName: string;
235     UsrAltName, IssuanceDate, PatientName, PatientAddress, DetoxNumber, ProviderName, ProviderAddress: string;
236     DrugName, Quantity, Directions: string;
237     OrderText, ASvc: string;
238     PrintLoc: Integer;
239     AList, ClinicList, OrderPrintList, WardList: TStringList;
240     EncLocName, EncLocText: string;
241     EncLocIEN: integer;
242     EncDT: TFMDateTime;
243     EncVC: Char;
244     CSSelectedList: TList;
245     CSOrder,PINRetrieved : boolean;
246     PINResult : TPINResult;
247     PINLock : string;
248     DEACheck: string;
249     //ChangeItem: TChangeItem;
250   
251     function FindOrderText(const AnID: string): string;
252     var
253       i: Integer;
254     begin
255       Result := '';
256       fOrdersSign.tempList := SelectedList;
257       fOrdersSign.tempCSList := CSSelectedList;
258       with SelectedList do for i := 0 to Count - 1 do
259         with TOrder(Items[i]) do if ID = AnID then
260         begin
261           Result := Text;
262           Break;
263         end;
264       with CSSelectedList do for i := 0 to Count - 1 do
265         with TOrder(Items[i]) do if ID = AnID then
266         begin
267           Result := Text;
268           Break;
269         end;
270     end;
271   
272     function SignNotRequired: Boolean;
273     var
274       i: Integer;
275     begin
276       Result := True;
277       tempList := SelectedList;
278       tempCSList := CSSelectedList;
279       with SelectedList do for i := 0 to Pred(Count) do
280       begin
281         with TOrder(Items[i]) do if Signature <> OSS_NOT_REQUIRE then Result := False;
282       end;
283   //    with CSSelectedList do for i := 0 to Pred(Count) do
284   //    begin
285   //      with TOrder(Items[i]) do if Signature <> OSS_NOT_REQUIRE then Result := False;
286   //    end;
287     end;
288   
289     function DigitalSign: Boolean;
290     var
291       i: Integer;
292     begin
293       Result := False;
294   
295       with SelectedList do for i := 0 to Pred(Count) do
296       begin
297         with TOrder(Items[i]) do if Copy(DigSigReq,1,1) = '2' then Result := True;
298       end;
299       with CSSelectedList do for i := 0 to Pred(Count) do
300       begin
301         with TOrder(Items[i]) do if Copy(DigSigReq,1,1) = '2' then Result := True;
302       end;
303     end;
304   
305     function Piece2end (s,del: string): string;
306     var
307       i: Integer;
308     begin
309       i := Pos(del,s);
310       Result := copy(s,i+1,length(s));
311     end;
312   
313     procedure Log2File(  crypto: tCryptography) ;
314     var
315       f: TextFile;
316     begin
317       AssignFile(f,'c:\PKISignError\hashLog.txt');
318       if not(FileExists('c:\PKISignError\hashLog.txt')) then
319       begin
320         ReWrite(f) ;
321         Write(f,'cprs 29 hash log' + CRLF + CRLF);
322         CloseFile(f);
323       end;
324   
325       Append(f);
326       WriteLn(f, '==============' + crypto.OrderNumber + CRLF +
327                         'UsrName: "' + crypto.UsrName + '"' + CRLF +
328                         'UsrAltName: "' + crypto.UsrAltName + '"' + CRLF +
329                         'IssuanceDate: "' + crypto.IssuanceDate + '"' + CRLF +
330                         'PatientName: "' + crypto.PatientName + '"' + CRLF +
331                         'PatientAddress: "' + crypto.PatientAddress + '"' + CRLF +
332                         'DrugName: "' + crypto.DrugName + '"' + CRLF +
333                         'ProviderName: "' + crypto.ProviderName + '"' + CRLF +
334                         'ProviderAddress: "' + crypto.ProviderAddress + '"' + CRLF +
335                         'IssuanceDate: "' + crypto.IssuanceDate + '"' + CRLF +
336                         'Quantity: "' + crypto.Quantity + '"' + CRLF +
337                         'Directions: "' + crypto.Directions + '"' + CRLF +
338                         'DetoxNumber: "' + crypto.DetoxNumber + '"' + CRLF +
339                         'DeaNumber: "' + crypto.DeaNumber + '"' + CRLF +
340                         'OrderNumber: "' + crypto.OrderNumber + '"' + CRLF +
341                         CRLF);
342       CloseFile(f);
343     end;
344   
345   begin
346   //  DigSigErr := True;
347     CSSelectedList := SelectedList;
348     Result := False;
349     PrintLoc := 0;
350     EncLocIEN := 0;
351     DoNotPrint := False;
352     if BILLING_AWARE then
353     begin
354        tempOrderList := TStringList.Create;
355        tempOrderList.Clear;
356     end;
357     frmSignOrders := TfrmSignOrders.Create(Application);
358   
359     CallV('ORDEA DEATEXT', []);
360     frmSignOrders.lblDEAText.Caption := '';
361     for i := 0 to RPCBrokerV.Results.Count -1 do
362        frmSignOrders.lblDEAText.Caption := frmSignOrders.lblDEAText.Caption + ' ' + RPCBrokerV.Results.Strings[i];
363   
364     CallV('ORDEA SIGINFO', [Patient.DFN, User.DUZ]);
365     frmSignOrders.lblProvInfo.Caption := '';
366     for i := 0 to RPCBrokerV.Results.Count -1 do
367        frmSignOrders.lblProvInfo.Caption := frmSignOrders.lblProvInfo.Caption + #13#10 + RPCBrokerV.Results.Strings[i];
368     try
369   //    ResizeAnchoredFormToFont(frmSignOrders);
370       SigItems.ResetOrders;
371       SigItemsCS.ResetOrders;
372       with SelectedList do for i := 0 to Count - 1 do
373         begin
374           obj := TOrder(Items[i]);
375           if ((obj.IsControlledSubstance=false) or IsPendingHold(Obj.ID)) then
376             begin
377               cidx := frmSignOrders.clstOrders.Items.AddObject(Obj.Text,Obj);
378               SigItems.Add(CH_ORD,Obj.ID, cidx);
379               if BILLING_AWARE then
380                 tempOrderList.Add(Obj.ID);
381               frmSignOrders.clstOrders.Checked[cidx] := TRUE;
382   
383               if (TOrder(Items[i]).DGroupName) = NonVAMedGroup then
384                 frmSignOrders.clstOrders.State[cidx] := cbGrayed ;
385             end;
386         end;
387       with CSSelectedList do for i := 0 to Count - 1 do
388         begin
389           obj := TOrder(Items[i]);
390           if (obj.IsControlledSubstance and obj.IsOrderPendDC) then
391           begin
392             cidx := frmSignOrders.clstOrders.Items.AddObject(Obj.Text,Obj);
393             SigItems.Add(CH_ORD,Obj.ID, cidx);
394             if BILLING_AWARE then
395               tempOrderList.Add(Obj.ID);
396             frmSignOrders.clstOrders.Checked[cidx] := TRUE;
397   
398             if (TOrder(Items[i]).DGroupName) = NonVAMedGroup then
399               frmSignOrders.clstOrders.State[cidx] := cbGrayed ;
400           end
401           else if (obj.IsControlledSubstance and not(IsPendingHold(Obj.ID))) then
402             begin
403               DEACheck := DEACheckFailedAtSignature(GetOrderableIen(Piece(obj.ID,';',1)),False);
404               if not(DEACheck='0') then ShowMsg('You are not authorized to Digitally Sign order: '+CRLF+obj.Text)
405               else
406               begin
407                 cidx := frmSignOrders.clstCSOrders.Items.AddObject(Obj.Text,Obj);
408                 SigItemsCS.Add(CH_ORD,Obj.ID, cidx);
409                 if BILLING_AWARE then
410                   tempOrderList.Add(Obj.ID);
411                 if TOrder(Items[i]).IsOrderPendDC then frmSignOrders.clstCSOrders.Checked[cidx] := TRUE
412                 else frmSignOrders.clstCSOrders.Checked[cidx] := FALSE;
413   
414                 if (TOrder(Items[i]).DGroupName) = NonVAMedGroup then
415                   frmSignOrders.clstCSOrders.State[cidx] := cbGrayed ;
416                 end;
417             end;
418         end;
419   
420       if frmSignOrders.clstCSOrders.Count>0 then
421       begin
422         if not(GetPKISite) then
423         begin
424           ShowMsg('Digital Signing of Controlled Substances is currently disabled for your site.');
425           if frmSignOrders.clstOrders.Count>0 then
426           begin
427             frmSignOrders.clstCSOrders.Clear;
428             SigItemsCS.ResetOrders;
429           end
430           else Exit;
431         end;
432         if not(GetPKIUse ) then
433         begin
434           ShowMsg('You are not currently permitted to digitally sign Controlled Substances.');
435           if frmSignOrders.clstOrders.Count>0 then
436           begin
437             frmSignOrders.clstCSOrders.Clear;
438             SigItemsCS.ResetOrders;
439           end
440           else Exit;
441         end;
442       end;
443       
444       
445   
446       SigItems.ClearDrawItems;
447       SigItems.ClearFcb;
448       SigItemsCS.ClearDrawItems;
449       SigItemsCS.ClearFcb;
450       t1 := SigItems.UpdateListBox(frmSignOrders.clstOrders);
451       t2 := SigItemsCS.UpdateListBox(frmSignOrders.clstCSOrders);
452       if t1 or t2 then
453         frmSignOrders.fraCoPay.Visible := TRUE
454       else
455         begin
456         {Begin BillingAware}
457           if  BILLING_AWARE then
458              frmSignOrders.gbDxLookup.Visible := FALSE;
459          {End BillingAware}
460         end;
461       if SignNotRequired then
462         begin
463           frmSignOrders.lblESCode.Visible := False;
464           frmSignOrders.txtESCode.Visible := False;
465         end;
466       if BILLING_AWARE then
467       begin
468        //  build list of orders that are not billable based on order type
469           UBAGlobals.NonBillableOrderList := rpcNonBillableOrders(tempOrderList);
470       end;
471   
472   
473   
474   
475       with frmSignOrders do
476       begin
477         lblDeaText.Visible := TRUE;
478         txtEScode.Text := '';
479         if ((clstOrders.Count = 0) and (clstCSOrders.Count = 0)) then  Exit;
480         pnlProvInfo.Height := lblProvInfo.Height+5+lblProvInfo.Top;
481   //      TotalSH := 0;
482   
483         if clstCSOrders.Count = 0 then
484         begin      
485           oheight := pnlOrderList.height;
486           pnlProvInfo.Visible := False;
487           if fraCoPay.Visible = FALSE then
488           begin
489             pnlTop.Visible := False;
490           end;
491           lblDeaText.Visible := False;   
492           pnlCSOrderlist.Visible := False;
493           pnlOrderlist.Align := alClient; 
494           newheight := Height - pnlOrderList.height + oheight;
495           if newheight < Constraints.MinHeight then Constraints.MinHeight := newheight;
496           Height := newheight;
497         end
498         else if clstOrders.Count = 0 then
499         begin   
500           oheight := pnlCSOrderList.height;
501           pnlOrderlist.Visible := False;
502           pnlCSOrderlist.Align := alClient;  
503           newheight := Height - pnlCSOrderlist.height + oheight;
504           if newheight < Constraints.MinHeight then Constraints.MinHeight := newheight;
505           Height := newheight;
506           txtESCode.Visible := FALSE;
507           lblESCode.Visible := FALSE;
508   
509         end
510         else if fraCoPay.Visible = FALSE then
511         begin
512           fraCoPay.Visible := TRUE;
513           ShrinkHeight := fraCoPay.Height - pnlProvInfo.Height;
514           fraCoPay.Visible := FALSE;
515   
516   		    pnlTop.Height := pnlTop.Height - ShrinkHeight;
517           pnlCombined.Top := pnlCombined.Top - ShrinkHeight; 
518   		    pnlCombined.Height := pnlCombined.Height + ShrinkHeight;
519   
520         end;
521         
522   
523   
524         lblDEAText.Visible := FALSE;
525         lblSmartCardNeeded.Visible := FALSE;
526       end;
527       if frmSignOrders.AnyItemsAreChecked then
528       begin
529         frmSignOrders.lblESCode.Visible := frmSignOrders.IsSignatureRequired;
530         frmSignOrders.txtESCode.Visible := frmSignOrders.IsSignatureRequired
531       end ;
532       if frmSignOrders.txtESCode.Visible then  frmSignOrders.ActiveControl := frmSignOrders.txtESCode;
533       
534        frmSignOrders.ShowModal;
535         if frmSignOrders.OKPressed then
536         begin
537           PINResult := prOK;
538           Result := True;
539           SignList := TStringList.Create;
540           CSSignList := TStringList.Create;
541           ClinicList := TStringList.Create;
542           OrderPrintList := TStringList.Create;
543           WardList := TStringList.Create;
544           ContainsIMOOrders := false;
545           try
546             with SelectedList do for i := 0 to Count - 1 do with TOrder(Items[i]) do
547             begin     
548               CSOrder := False;
549               cErr := '';
550               cidx := frmSignOrders.clstOrders.Items.IndexOfObject(TOrder(Items[i]));
551               if cidx<0 then
552               begin
553                 cidx := frmSignOrders.clstCSOrders.Items.IndexOfObject(TOrder(Items[i]));
554                 CSOrder := True;
555               end;
556   
557   
558               if (cidx > -1 ) and (CSOrder=False) and (cErr = '') then
559                 begin
560                   if TOrder(Items[i]).DGroupName = NonVAMedGroup  then  frmSignOrders.clstOrders.Checked[cidx] := True;    //Non VA MEDS
561                   if frmSignOrders.clstOrders.Checked[cidx] then
562                   begin
563                     UpdateOrderDGIfNeeded(ID);
564                     SignList.Add(ID + U + SS_ESIGNED + U + RS_RELEASE + U + NO_PROVIDER);
565                     BAOrderList.Add(TOrder(Items[i]).ID);
566                   end;
567                 end;
568   
569   
570               if (cidx > -1) and (CSOrder) and (cErr = '') then
571                 begin
572                   if frmSignOrders.clstCSOrders.Checked[cidx] then
573                   begin
574                     if IsOrderPendDC then
575                     begin
576                       UpdateOrderDGIfNeeded(ID);
577                       SignList.Add(ID + U + SS_DIGSIG + U + RS_RELEASE + U + NO_PROVIDER);
578                       BAOrderList.Add(TOrder(Items[i]).ID);
579                     end
580                     else
581                     begin
582   //                    UpdateOrderDGIfNeeded(ID);
583                       CSSignList.Add(ID + U + SS_DIGSIG + U + RS_RELEASE + U + NO_PROVIDER);
584   //                    BAOrderList.Add(TOrder(Items[i]).ID);
585                     end;
586                   end;
587                 end;
588             end;
589   
590             if CSSignList.Count > 0 then
591             begin
592             LastPINvalue := '';
593             //isXuDSigSLogging := true;
594             PINRetrieved := False;
595             //get altusername
596             UsrAltName := sCallV('XUS PKI GET UPN', []);
597             //if SAN is blank then attempt to retrieve from card to set it
598             if UsrAltName='' then
599             begin
600               UsrAltName := SetSAN(fOrdersSign.frmSignOrders);
601               if not(UsrAltName='')  then
602                 PINRetrieved := True;
603             end;
604             //if still blank then cancel digital signing
605             if UsrAltName='' then   
606               PINResult := prCancel
607             else if not(PINRetrieved) then
608               try
609                 PINLock := sCallV('ORDEA PINLKCHK', []);
610                 if PINLock = '1' then 
611                   PINResult := prLocked
612                 else 
613                   PINResult := checkPINValue(fOrdersSign.frmSignOrders);
614               except
615                 PINResult := prError;
616               end;
617   
618             if PINResult = PRError then 
619               ShowMsg('Problem getting PIN.  Cannot Digitally Sign.')
620             else if PINResult = prLocked then begin
621               if PINLock = '0' then sCallV('ORDEA PINLKSET', []);
622               ShowMsg('Card has been locked.  Cannot Digitally Sign.')
623             end else if PINResult=prCancel then 
624               ShowMsg('Digital Signing has been cancelled.')
625             else begin
626               try
627                 crypto := tCryptography.Create;
628                 //call rpc to get hash fields other than drug info
629                 CallV('ORDEA HASHINFO', [Patient.DFN, User.DUZ]);
630                 for i := 0 to RPCBrokerV.Results.Count -1 do
631                 begin
632                   if Piece(RPCBrokerV.Results.Strings[i],':',1) = 'IssuanceDate' then IssuanceDate := Piece2end(RPCBrokerV.Results.Strings[i],':');
633                   if Piece(RPCBrokerV.Results.Strings[i],':',1) = 'PatientName' then PatientName := Piece2end(RPCBrokerV.Results.Strings[i],':');
634                   if Piece(RPCBrokerV.Results.Strings[i],':',1) = 'PatientAddress' then PatientAddress := Piece2end(RPCBrokerV.Results.Strings[i],':');
635                   if Piece(RPCBrokerV.Results.Strings[i],':',1) = 'DetoxNumber' then DetoxNumber := Piece2end(RPCBrokerV.Results.Strings[i],':');
636                   if Piece(RPCBrokerV.Results.Strings[i],':',1) = 'ProviderName' then ProviderName := Piece2end(RPCBrokerV.Results.Strings[i],':');
637                   if Piece(RPCBrokerV.Results.Strings[i],':',1) = 'ProviderAddress' then ProviderAddress := Piece2end(RPCBrokerV.Results.Strings[i],':');
638                   if Piece(RPCBrokerV.Results.Strings[i],':',1) = 'DeaNumber' then SigDEA := Piece2end(RPCBrokerV.Results.Strings[i],':');
639                 end;
640   
641                 for i := 0 to CSSignList.Count - 1 do
642                 begin
643                   CallV('ORDEA ORDHINFO', [Piece(Piece(CSSignList.strings[i],U,1),';',1)]);
644                   DrugName := '';
645                   Quantity := '';
646                   Directions := '';
647                   for k := 0 to RPCBrokerV.Results.Count -1 do
648                   begin
649                     if Piece(RPCBrokerV.Results.Strings[k],':',1) = 'DrugName' then DrugName := Piece2end(RPCBrokerV.Results.Strings[k],':');
650                     if Piece(RPCBrokerV.Results.Strings[k],':',1) = 'Quantity' then Quantity := Piece2end(RPCBrokerV.Results.Strings[k],':');
651                     if Piece(RPCBrokerV.Results.Strings[k],':',1) = 'Directions' then Directions := Piece(Piece2end(RPCBrokerV.Results.Strings[k],':'),U,1);
652                   end;
653                   try
654                     crypto.Reset;
655                     crypto.isDEAsig := true;
656                     crypto.UsrName := User.Name;
657                     crypto.UsrAltName := UsrAltName;
658                     crypto.IssuanceDate :=  IssuanceDate;
659                     crypto.PatientName :=   PatientName;
660                     crypto.PatientAddress :=  PatientAddress;
661                     crypto.DrugName :=     DrugName;
662                     crypto.Quantity :=   Quantity;
663                     crypto.Directions :=  Directions;
664                     crypto.DetoxNumber :=  ''; //DetoxNumber;  don't include detox in hash calc
665                     crypto.ProviderName :=  ProviderName;
666                     crypto.ProviderAddress :=  ProviderAddress;
667                     crypto.DeaNumber :=      SigDEA;
668                     crypto.OrderNumber := Piece(Piece(CSSignList.strings[i],U,1),';',1);
669   
670                     if false then Log2File(crypto);
671   
672                     if crypto.SignData = true then
673                     begin
674                       cSignature := crypto.SignatureStr;
675                       cHashData := crypto.HashStr;
676                       cCrlUrl := crypto.CrlUrl;
677                     end
678                     else
679                     begin
680                       ShowMsg('Could not digitally sign. An error has occurred: Hash generation failed'+CRLF+CRLF+crypto.Reason);
681                       DigStoreErr := true;
682                     end;
683   
684                   except
685                     on  E: Exception do
686                       begin
687                         ShowMsg('Could not digitally sign. An error has occurred: '+ E.Message);
688                         DigStoreErr := true;
689                       end;
690                   end;
691   
692                   if DigStoreErr then
693                    //messages shown above
694                   else
695                   begin
696                     cErr := '';
697                     StoreDigitalSig(Piece(CSSignList.Strings[i],U,1), cHashData, User.DUZ, cSignature, cCrlUrl, Patient.DFN, cErr);
698                     if cErr = '' then
699                     begin
700                       UpdateOrderDGIfNeeded(Piece(CSSignList.Strings[i],U,1));
701                       SignList.Add(CSSignList.Strings[i]);
702                       BAOrderList.Add(Piece(CSSignList.Strings[i],U,1));
703                     end;
704                   end;
705                 end;
706               finally
707                   if not(crypto=nil) then
708                   begin
709                     crypto.Free;
710                     crypto := nil;
711                   end;
712                 end;
713               end;
714             end;
715             StatusText('Sending Orders to Service(s)...');
716             if SignList.Count > 0 then
717             begin
718               //hds7591  Clinic/Ward movement.  Patient Admission IMO
719               if not frmFrame.TimedOut then
720               begin
721                 if (Patient.Inpatient = True) and (Encounter.Location <> Patient.Location) then
722                 begin
723                   EncLocName := Encounter.LocationName;
724                   EncLocIEN  := Encounter.Location;
725                   EncLocText := Encounter.LocationText;
726                   EncDT := Encounter.DateTime;
727                   EncVC := Encounter.VisitCategory;
728                   for i := 0 to SelectedList.Count - 1 do
729                   begin
730                     CSOrder := False;
731                     cidx := frmSignOrders.clstOrders.Items.IndexOfObject(TOrder(SelectedList.Items[i]));
732                     //selected order isn't from non-CS list -> check CS List
733                     if cidx = -1 then
734                     begin
735                       cidx := frmSignOrders.clstCSOrders.Items.IndexOfObject(TOrder(SelectedList.Items[i]));
736                       //selected order found in CS List -> CSOrder := True
737                       if cidx <> -1 then
738                         CSOrder := True;
739                     end;
740                     if ((CSOrder=False) and (frmSignOrders.clstOrders.Checked[cidx]=False)) or (CSOrder and (frmSignOrders.clstCSOrders.Checked[cidx]=False)) then continue;
741                     if TOrder(SelectedList.Items[i]).DGroupName = 'Clinic Orders' then ContainsIMOOrders := true;
742                     if TOrder(SelectedList.Items[i]).DGroupName = '' then continue;
743                     if (Pos('DC', TOrder(SelectedList.Items[i]).ActionOn) > 0) or
744                        (TOrder(SelectedList.Items[i]).IsOrderPendDC = true) then
745                     begin
746                       WardList.Add(TOrder(SelectedList.Items[i]).ID);
747                       Continue;
748                     end;
749                     //ChangeItem := Changes.Locate(20,TOrder(SelectedList.Items[i]).ID);
750                     //if ChangeItem = nil then continue;
751                     //if ChangeItem.Delay = true then continue;
752                     if TOrder(SelectedList.Items[i]).IsDelayOrder = true then Continue;
753                     OrderPrintList.Add(TOrder(SelectedList.Items[i]).ID + ':' + TOrder(SelectedList.Items[i]).Text);
754                   end;
755                   if OrderPrintList.Count > 0 then
756                   begin
757                     frmPrintLocation.PrintLocation(OrderPrintList, EncLocIEN, EncLocName, EncLocText, EncDT, EncVC, ClinicList,
758                                                    WardList, WardIen,WardName, ContainsIMOOrders, true);
759                     //fframe.frmFrame.OrderPrintForm := false;
760                   end
761                   else if (clinicList.count = 0) and (wardList.Count = 0) then
762                     DoNotPrint := True;
763                   if (WardIEN = 0) and (WardName = '') then
764                     CurrentLocationForPatient(Patient.DFN, WardIEN, WardName, ASvc);
765                 end;
766               end;
767               uCore.TempEncounterLoc := 0;
768               uCore.TempEncounterLocName := '';
769               //hds7591  Clinic/Ward movement  Patient Admission IMO
770   
771               SigItems.SaveSettings; // Save CoPay FIRST!
772               SigItemsCS.SaveSettings;
773               SendOrders(SignList, frmSignOrders.ESCode);
774             end;
775   
776             //CQ #15813 Modified code to look for error string mentioned in CQ and change strings to conts - JCS
777             //CQ #15813 Adjusted code to handle error message properly - TDP
778               with SignList do if Count > 0 then for i := 0 to Count - 1 do
779               begin
780                 if Pos('E', Piece(SignList[i], U, 2)) > 0 then
781                   begin
782                     OrderText := FindOrderText(Piece(SignList[i], U, 1));
783                     if Piece(SignList[i],U,4) = TX_SAVERR_PHARM_ORD_NUM_SEARCH_STRING then
784                     InfoBox(TX_SAVERR1 + Piece(SignList[i], U, 4) + TX_SAVERR2 + OrderText + CRLF + CRLF +
785                           TX_SAVERR_PHARM_ORD_NUM, TC_SAVERR, MB_OK)
786                     else if AnsiContainsStr(Piece(SignList[i],U,4), TX_SAVERR_IMAGING_PROC_SEARCH_STRING) then
787                     InfoBox(TX_SAVERR1 + Piece(SignList[i], U, 4) + TX_SAVERR2 + OrderText + CRLF + CRLF +
788                           TX_SAVERR_IMAGING_PROC, TC_SAVERR, MB_OK)
789                     else
790                     InfoBox(TX_SAVERR1 + Piece(SignList[i], U, 4) + TX_SAVERR2 + OrderText,
791                           TC_SAVERR, MB_OK);
792                   end;
793                 if Pos('R', Piece(SignList[i], U, 2)) > 0 then
794                   NotifyOtherApps(NAE_ORDER, 'RL' + U + Piece(SignList[i], U, 1));
795               end;
796             StatusText('');
797             for cnt := SignList.Count - 1 downto 0 do
798             begin
799                 if Pos('E', Piece(SignList[cnt], U, 2)) > 0 then
800                 begin
801                   SignList.Delete(cnt);
802                   Continue;
803                 end;
804                 theSts := GetOrderStatus(Piece(SignList[cnt],U,1));
805                 if theSts = 10 then  SignList.Delete(cnt);  //signed delayed order should not be printed.
806             end;
807             //  CQ 10226, PSI-05-048 - advise of auto-change from LC to WC on lab orders
808             AList := TStringList.Create;
809             try
810               CheckForChangeFromLCtoWCOnRelease(AList, Encounter.Location, SignList);
811               if AList.Text <> '' then
812                 ReportBox(AList, 'Changed Orders', TRUE);
813             finally
814               AList.Free;
815             end;
816             if(ClinicList.Count > 0) or (WardList.count > 0) then
817                 PrintOrdersOnSignReleaseMult(SignList, CLinicList, WardList, NO_PROVIDER, EncLocIEN, WardIEN, EncLocName, wardName)
818               else if DoNotPrint = False then PrintOrdersOnSignRelease(SignList, NO_PROVIDER, PrintLoc);
819           finally
820             CSRemaining(frmSignOrders.clstOrders.items,frmSignOrders.clstCSOrders.items);
821             LastPINvalue := '';
822             SignList.Free;
823             OrderPrintList.free;
824             WardList.free;
825             ClinicList.free;
826           end;
827         end; {if frmSignOrders.OKPressed}
828     finally
829       frmSignOrders.Free;
830   
831       with SelectedList do for i := 0 to Count - 1 do UnlockOrder(TOrder(Items[i]).ID);
832     end;
833       if not(crypto=nil) then
834       begin
835         crypto.Free;
836         crypto := nil;
837       end;
838   end;
839   
840   procedure TfrmSignOrders.FormCreate(Sender: TObject);
841   begin
842     inherited;
843     FLastHintItem := -1;
844     OKPressed := False;
845     FOldHintPause := Application.HintPause;
846     Application.HintPause := 250;
847     FOldHintHidePause := Application.HintHidePause;
848     Application.HintHidePause := 30000;
849     tempList := TList.Create;
850     tempCSList := TList.Create;
851   
852     {Begin BillingAware}
853     //This is the DIAGNOSIS label above the Dx column
854     if  BILLING_AWARE then
855         begin
856           clstOrders.Height := 228;
857           clstOrders.Top :=  (gbdxLookup.top + 65);
858           gbDxLookup.Visible := TRUE;
859           lblOrderList.Top := (gbdxLookup.Top +  gbdxLookup.Height);
860           laDiagnosis.Top :=  lblOrderList.Top;
861           laDiagnosis.Left := 270;
862           laDiagnosis.Visible := TRUE;
863           rectIndex := 0;
864         end
865      else
866         begin
867   //         lblOrderList.Top := 158;
868   //         lblOrderList.Left := 8;
869        end;
870    {End BillingAware}
871   
872   end;
873   
874   function TfrmSignOrders.IsSignatureRequired:boolean;
875   var
876      i: Integer;
877   begin
878       Result := FALSE;
879   //
880   //    with tempList do for i := 0 to Pred(Count) do
881   //    begin
882   //      if frmSignOrders.clstOrders.Checked[i] then
883   //      begin
884   //      with TOrder(Items[i]) do if Signature <> OSS_NOT_REQUIRE then
885   //         Result := TRUE;
886   //      end;
887   //    end;
888       with frmSignOrders.clstOrders do for i := 0 to Items.Count-1 do
889       begin
890         if frmSignOrders.clstOrders.Checked[i] then
891         begin
892         with TOrder(Items[i]) do if Signature <> OSS_NOT_REQUIRE then
893            Result := TRUE;
894         end;
895       end; 
896       with frmSignOrders.clstCSOrders do for i := 0 to Items.Count-1 do
897       begin
898         if frmSignOrders.clstCSOrders.Checked[i] then
899         begin
900         with TOrder(Items[i]) do if Signature <> OSS_NOT_REQUIRE then
901            Result := TRUE;
902         end;
903       end;
904   end;
905   
906   procedure TfrmSignOrders.cmdOKClick(Sender: TObject);
907   const
908     TX_NO_CODE  = 'An electronic signature code must be entered to sign orders.';
909     TC_NO_CODE  = 'Electronic Signature Code Required';
910     TX_BAD_CODE = 'The electronic signature code entered is not valid.';
911     TC_BAD_CODE = 'Invalid Electronic Signature Code';
912     TC_NO_DX   =  'Incomplete Diagnosis Entry';
913     TX_NO_DX   = 'A Diagnosis must be selected prior to signing any of the following order types:'
914                   + CRLF + 'Lab, Radiology, Outpatient Medications, Prosthetics.';
915   begin
916     inherited;
917   
918     if txtESCode.Visible and (Length(txtESCode.Text) = 0) then
919     begin
920       InfoBox(TX_NO_CODE, TC_NO_CODE, MB_OK);
921       Exit;
922     end;
923   
924     if txtESCode.Visible and not ValidESCode(txtESCode.Text) then
925     begin
926       InfoBox(TX_BAD_CODE, TC_BAD_CODE, MB_OK);
927       txtESCode.SetFocus;
928       txtESCode.SelectAll;
929       Exit;
930     end;
931   
932   {Begin BillingAware}
933     if  BILLING_AWARE then
934     begin
935       if SigItems.OK2SaveSettings then
936      
937         if Not UBACore.BADxEntered then   //  if Dx have been entered and OK is pressed
938            begin                     // billing data will be saved. otherwise error message!
939               InfoBox(TX_NO_DX, 'Sign Orders', MB_OK);
940               Exit;
941            end;
942       end;
943   {End BillingAware}
944   
945     if not SigItems.OK2SaveSettings or not SigItemsCS.OK2SaveSettings then
946     begin
947       InfoBox(TX_Order_Error, 'Sign Orders', MB_OK);
948       Exit;
949     end;
950   
951     if txtESCode.Visible then
952        ESCode := Encrypt(txtESCode.Text) else ESCode := '';
953        
954     OKPressed := True;
955     Close;
956   end;
957   
958   procedure TfrmSignOrders.cmdCancelClick(Sender: TObject);
959   begin
960     inherited;
961     Close;
962   //  CSRemaining(frmSignOrders.clstOrders.items,frmSignOrders.clstCSOrders.items);
963   end;
964   
965   procedure TfrmSignOrders.FormDestroy(Sender: TObject);
966   begin
967     inherited;
968     Application.HintPause := FOldHintPause;
969     Application.HintHidePause := FOldHintHidePause;
970     Crypto := nil;  //PKI object destroy
971   end;
972   
973   procedure TfrmSignOrders.clstOrdersDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
974   var
975   {Begin BillingAware}
976     str: String;
977     tempID: string;
978     thisRec: UBAGlobals.TBADxRecord;
979    {End BillingAware}
980   
981     X: string;
982     ARect: TRect;
983   begin
984     inherited;
985     X := '';
986     ARect := Rect;
987   
988   {Begin BillingAware}
989     if  BILLING_AWARE then
990     begin
991        with clstOrders do
992        begin
993          if Index < Items.Count then
994          begin
995             Canvas.FillRect(ARect);
996             Canvas.Pen.Color := Get508CompliantColor(clSilver);
997             Canvas.MoveTo(ARect.Left, ARect.Bottom);
998             Canvas.LineTo(ARect.Right, ARect.Bottom);
999             x := FilteredString(Items[Index]);
1000            ARect.Right := ARect.Right - 50;    //50 to 40
1001            //Vertical column line
1002            Canvas.MoveTo(ARect.Right, Rect.Top);
1003            Canvas.LineTo(ARect.Right, Rect.Bottom);
1004            //Adjust position of 'Diagnosis' column label for font size
1005            laDiagnosis.Left := ARect.Right + 14;
1006            if uSignItems.GetAllBtnLeftPos > 0 then
1007               laDiagnosis.left := uSignItems.GetAllBtnLeftPos - (laDiagnosis.Width +5);
1008                // ARect.Right below controls the right-hand side of the Dx Column
1009                // Adjust ARect.Right in conjunction with procedure uSignItems.TSigItems.lbDrawItem(), because the
1010                // two rectangles overlap each other.
1011             if  BILLING_AWARE then
1012             begin
1013                arRect[Index] := Classes.Rect(ARect.Right+2, ARect.Top, ARect.Right + 108, ARect.Bottom);
1014                Canvas.FillRect(arRect[Index]);
1015             end;
1016  
1017                //Win32 API - This call to DrawText draws the text of the ORDER - not the diagnosis code
1018                 DrawText(Canvas.handle, PChar(x), Length(x), ARect, DT_LEFT or DT_NOPREFIX or DT_WORDBREAK);
1019         if  BILLING_AWARE then
1020           begin
1021               if Assigned(UBAGlobals.tempDxList) then
1022                  begin
1023                     tempID := TOrder(clstOrders.Items.Objects[Index]).ID;
1024  
1025                  if UBAGlobals.tempDxNodeExists(tempID) then
1026                      begin
1027                         thisRec := TBADxRecord.Create;
1028                         UBAGlobals.GetBADxListForOrder(thisRec, tempID);
1029                         str := Piece(thisRec.FBADxCode,'^',1);
1030                         {v25 BA}
1031                         str := Piece(str,':',1);
1032                         DrawText(Canvas.handle, PChar(str), Length(str), arRect[Index], DT_LEFT or DT_NOPREFIX or DT_WORDBREAK);
1033                         if Not UBACore.IsOrderBillable(tempID) then
1034                         begin
1035                              Canvas.Font.Color := clBlue;
1036                              DrawText(Canvas.handle, PChar(NOT_APPLICABLE), Length(NOT_APPLICABLE), {Length(str),} arRect[Index], DT_LEFT or DT_NOPREFIX or DT_WORDBREAK);
1037                         end;
1038                      end
1039                   else
1040                      begin
1041                        //   determine if order is billable, if NOT then insert NA in Dx field
1042                       if Not UBACore.IsOrderBillable(tempID) then
1043                          begin
1044                              Canvas.Font.Color := clBlue;
1045                              DrawText(Canvas.handle, PChar(NOT_APPLICABLE), Length(NOT_APPLICABLE), {Length(str),} arRect[Index], DT_LEFT or DT_NOPREFIX or DT_WORDBREAK);
1046                          end;
1047                      end;
1048                  end;
1049              end;
1050  
1051          end;
1052         end;
1053    end
1054    else
1055       begin
1056          X := '';
1057          ARect := Rect;
1058          with clstOrders do
1059             begin
1060               if Index < Items.Count then
1061                  begin
1062                    Canvas.FillRect(ARect);
1063                    Canvas.Pen.Color := Get508CompliantColor(clSilver);
1064                    Canvas.MoveTo(ARect.Left, ARect.Bottom - 1);
1065                    Canvas.LineTo(ARect.Right, ARect.Bottom - 1);
1066                    X := FilteredString(Items[Index]);
1067                    DrawText(Canvas.handle, PChar(x), Length(x), ARect, DT_LEFT or DT_NOPREFIX or DT_WORDBREAK);
1068                  end;
1069             end;
1070       end;
1071  {End BillingAware}
1072  end;
1073  
1074  procedure TfrmSignOrders.clstOrdersMeasureItem(Control: TWinControl;
1075    Index: Integer; var AHeight: Integer);
1076  var
1077    X: string;
1078    ARect: TRect;
1079  begin
1080    inherited;
1081    AHeight := SigItemHeight;
1082    with clstOrders do if Index < Items.Count then
1083    begin
1084      ARect := ItemRect(Index);
1085      Canvas.FillRect(ARect);
1086      x := FilteredString(Items[Index]);
1087      AHeight := WrappedTextHeightByFont(Canvas, Font, x, ARect);
1088      if AHeight > 255 then AHeight := 255;
1089      //-------------------
1090      {Bug fix-HDS00001627}
1091      //if AHeight <  13 then AHeight := 13; {ORIG}
1092      if AHeight <  13 then AHeight := 15;
1093      //-------------------
1094    end;
1095  end;
1096  
1097  procedure TfrmSignOrders.clstOrdersClickCheck(Sender: TObject);
1098  
1099     procedure updateAllChilds(CheckedStatus: boolean; ParentOrderId: string);
1100     var
1101       idx: integer;
1102     begin
1103       for idx := 0 to clstOrders.Items.Count - 1 do
1104          if TOrder(clstOrders.Items.Objects[idx]).ParentID = ParentOrderId then
1105          begin
1106             if clstOrders.Checked[idx] <> CheckedStatus then
1107             begin
1108                clstOrders.Checked[idx] := CheckedStatus;
1109                SigItems.EnableSettings(idx, clstOrders.checked[Idx]);
1110             end;
1111          end;
1112     end;
1113  
1114  begin
1115    with clstOrders do
1116    begin
1117      if Length(TOrder(Items.Objects[ItemIndex]).ParentID)>0 then
1118      begin
1119        SigItems.EnableSettings(ItemIndex, checked[ItemIndex]);
1120        updateAllChilds(checked[ItemIndex],TOrder(Items.Objects[ItemIndex]).ParentID);
1121      end else
1122        SigItems.EnableSettings(ItemIndex, checked[ItemIndex]);
1123    end;
1124    if ItemsAreChecked then
1125    begin
1126       lblESCode.Visible := IsSignatureRequired;
1127       txtESCode.Visible := IsSignatureRequired
1128    end
1129    else
1130    begin
1131      lblESCode.Visible := ItemsAreChecked or CSItemsAreChecked;
1132      txtESCode.Visible := ItemsAreChecked or CSItemsAreChecked;
1133    end;
1134  
1135    if txtESCode.Visible then txtESCode.SetFocus;
1136    
1137  end;
1138  
1139  function TfrmSignOrders.ItemsAreChecked: Boolean;
1140  { return true if any items in the Review List are checked for applying signature }
1141  var
1142    i: Integer;
1143  begin
1144    Result := False;
1145  
1146    with clstOrders do
1147       for i := 0 to Items.Count - 1 do
1148          if Checked[i] then
1149             begin
1150               Result := True;
1151               break;
1152             end;
1153  end;
1154  
1155  function TfrmSignOrders.CSItemsAreChecked: Boolean;
1156  { return true if any items in the Review List are checked for applying signature }
1157  var
1158    i: Integer;
1159  begin
1160    Result := False;
1161  
1162    with clstCSOrders do
1163       for i := 0 to Items.Count - 1 do
1164          if Checked[i] then
1165             begin
1166               Result := True;
1167               break;
1168             end;
1169  end;
1170  
1171  function TfrmSignOrders.nonDCCSItemsAreChecked: Boolean;
1172  { return true if any items in the Review List are checked for applying signature }
1173  var
1174    i: Integer;
1175  begin
1176    Result := False;
1177  
1178    with clstCSOrders do
1179       for i := 0 to Items.Count - 1 do
1180          if Checked[i] then
1181             begin
1182               if not TOrder(clstCSOrders.Items.Objects[i]).IsOrderPendDC then
1183               begin
1184                 Result := True;
1185                 break;
1186               end;
1187             end;
1188  end;
1189  
1190  function TfrmSignOrders.AnyItemsAreChecked: Boolean;
1191  begin
1192    Result := ItemsAreChecked or CSItemsAreChecked;
1193  end;
1194  
1195  procedure TfrmSignOrders.clstOrdersMouseMove(Sender: TObject;
1196    Shift: TShiftState; X, Y: Integer);
1197  var
1198    Itm: integer;
1199  {Begin BillingAware}
1200    thisRec: UBAGlobals.TBADxRecord;
1201    i: smallint;
1202    thisOrderID: string;
1203  {End BillingAware}
1204  begin
1205    inherited;
1206    Itm := clstOrders.ItemAtPos(Point(X, Y), TRUE);
1207    if (Itm >= 0) then
1208    begin
1209      if (Itm <> FLastHintItem) then
1210      begin
1211        Application.CancelHint;
1212     {Begin BillingAware}
1213      if  BILLING_AWARE then
1214      begin
1215         //Billing Awareness 'flyover' hint includes Dx code(s) when Dx code(s) have been assigned to an order
1216             thisOrderID := TChangeItem(fOrdersSign.frmSignOrders.clstOrders.Items.Objects[Itm]).ID;
1217  
1218             if UBAGlobals.tempDxNodeExists(thisOrderID) then
1219                   begin
1220                   if Assigned(tempDxList) then
1221                   try
1222                        for i := 0 to (tempDxList.Count - 1) do
1223                           begin
1224                             thisRec := TBADxRecord(tempDxList.Items[i]);
1225  
1226                            if Assigned(thisRec) then
1227                              if (thisRec.FOrderID = thisOrderID) then
1228                                  begin
1229                                  with thisRec do
1230                                     begin
1231                                        FBADxCode := StringReplace(thisrec.FBADxCode,'^',':',[rfReplaceAll]);
1232                                        FBASecDx1 := StringReplace(thisrec.FBASecDx1,'^',':',[rfReplaceAll]);
1233                                        FBASecDx2 := StringReplace(thisrec.FBASecDx2,'^',':',[rfReplaceAll]);;
1234                                        FBASecDx3 := StringReplace(thisrec.FBASecDx3,'^',':',[rfReplaceAll]);
1235                                     end;
1236  
1237                                  clstOrders.Hint := TrimRight(clstOrders.Items[Itm] + #13 +
1238                                                               thisRec.FBADxCode + #13 + thisRec.FBASecDx1 + #13 + thisRec.FBASecDx2 + #13 + thisRec.FBASecDx3);
1239                                  end
1240                            end
1241                   except
1242                      on EListError do
1243                         begin
1244                         {$ifdef debug}Show508Message('EListError in frmSignOrders.clstOrdersMouseMove()');{$endif}
1245                         raise;
1246                         end;
1247                   end;
1248  
1249                   end
1250             else
1251                 clstOrders.Hint := TrimRight(clstOrders.Items[Itm]);
1252    end;
1253    {End BillingAware}
1254      FLastHintItem := Itm;
1255      Application.ActivateHint(Point(X, Y));
1256     end;
1257    end
1258    else
1259    begin
1260      clstOrders.Hint := '';
1261      FLastHintItem := -1;
1262      Application.CancelHint;
1263    end;
1264  end;
1265  
1266  procedure TfrmSignOrders.FormShow(Sender: TObject);
1267  begin
1268  {Begin BillingAware}
1269  
1270  //  if (clstOrders.Top + clstOrders.Height) > (lblESCode.Top - 4) then
1271  //      clstOrders.Height := lblESCode.Top - clstOrders.Top - 4;
1272  
1273    //INITIALIZATIONS
1274    Paste1.Enabled := false;
1275    fOrdersSign.srcOrderID := '';
1276    fOrdersSign.srcDx := '';
1277    if txtESCode.Visible then
1278       frmSignOrders.txtESCode.SetFocus;
1279  
1280      if  BILLING_AWARE then
1281         begin
1282           //List to contain loading OrderID's
1283          if not Assigned(UBAGlobals.OrderIDList) then
1284             UBAGlobals.OrderIDList := TStringList.Create;
1285  
1286          if  BILLING_AWARE then
1287          begin
1288             clstOrders.Multiselect := true;
1289             clstCSOrders.Multiselect := true;
1290          end;
1291  
1292           with fraCoPay do
1293             begin
1294              lblSC2.Caption := 'Service &Connected Condition';
1295              lblCV2.Caption := 'Combat &Vet (Combat Related)';
1296              lblAO2.Caption := 'Agent &Orange Exposure';
1297              lblIR2.Caption := 'Ionizing &Radiation Exposure';
1298              lblSWAC2.Caption := '&Environmental Contaminants';
1299              lblMST2.Caption := '&MST';
1300              lblHNC2.Caption := '&Head and/or Neck Cancer';
1301              lblSHAD2.Caption := 'Shi&pboard Hazard and Defense';
1302              lblSC2.ShowAccelChar := true;
1303              lblCV2.ShowAccelChar := true;
1304              lblAO2.ShowAccelChar := true;
1305              lblIR2.ShowAccelChar := true;
1306              lblSWAC2.ShowAccelChar := true;
1307              lblMST2.ShowAccelChar := true;
1308              lblHNC2.ShowAccelChar := true;
1309              lblSHAD2.ShowAccelChar := true;
1310             end;
1311          end;  //BILLING_AWARE
1312  
1313    clstOrders.TabOrder := 0; //CQ5057
1314    FormatListForScreenReader;
1315  
1316    //CQ5172
1317    if clstOrders.Count = 1 then
1318    begin
1319       clstOrders.Selected[0] := true;
1320       buOrdersDiagnosis.Enabled := True;
1321       Diagnosis1.Enabled := True;
1322       // if number of orders is 1 and order is billable select order and disable diagnosis button
1323       if NOT UBACore.IsOrderBillable(TChangeItem(fOrdersSign.frmSignOrders.clstOrders.Items.Objects[0]).ID) then
1324       begin
1325          buOrdersDiagnosis.Enabled := False;
1326          Diagnosis1.Enabled := False;
1327          clstOrders.Selected[0] := False;
1328       end
1329       else
1330          if Piece(TChangeItem(fOrdersSign.frmSignOrders.clstOrders.Items.Objects[0]).ID,';',2) = DISCONTINUED_ORDER then
1331          begin
1332             buOrdersDiagnosis.Enabled := False;
1333             Diagnosis1.Enabled := False;
1334          end;
1335    end;
1336   //end CQ5172
1337  end;
1338  
1339   {Begin BillingAware}
1340   //   New BA Button....
1341  procedure TfrmSignOrders.buOrdersDiagnosisClick(Sender: TObject);
1342  var
1343    i: smallint;
1344    thisOrderID: string;
1345    match: boolean;
1346    allBlank: boolean;
1347    numSelected: smallint;
1348  begin
1349  {Begin BillingAware}
1350  
1351    match := false;
1352    allBlank := false;
1353    if Assigned (orderIDList) then orderIDList.Clear;
1354    if Assigned(UBAGlobals.PLFactorsIndexes) then UBAGlobals.PLFactorsIndexes.Clear;
1355    if Assigned (BAtmpOrderList) then BAtmpOrderList.Clear;
1356  
1357     try
1358       // User has selected no orders to sign
1359          for i := 0 to fOrdersSign.frmSignOrders.clstOrders.Items.Count-1 do
1360             begin
1361              if (fOrdersSign.frmSignOrders.clstOrders.Selected[i]) then
1362                 begin
1363                 thisOrderID := TChangeItem(fOrdersSign.frmSignOrders.clstOrders.Items.Objects[i]).ID;
1364                 orderIDList.Add(thisOrderID);
1365                 {BAV25 Code}
1366                 BAtmpOrderList.Add(TOrder(fOrdersSign.frmSignOrders.clstOrders.Items.Objects[i]).TEXT);
1367                 // stringlist holding index and stsFactors
1368                 UBAGlobals.PLFactorsIndexes.Add(IntToStr(i)+ U + GetCheckBoxStatus(thisOrderID) );  // store indexes and flags of selected orders
1369                 {BAV25 Code}
1370                 // Test for blank Dx on current grid item
1371                  if not (tempDxNodeExists(thisOrderID)) then
1372                     if Assigned(UBAGlobals.globalDxRec) then
1373                     InitializeNewDxRec(UBAGlobals.globalDxRec);
1374                 if (tempDxNodeExists(thisOrderID)) then
1375                 begin
1376                     // Create UBAGlobals.globalDxRec with loaded fields
1377                    if not Assigned(UBAGlobals.globalDxRec) then
1378                       begin
1379                          UBAGlobals.globalDxRec := UBAGlobals.TBADxRecord.Create;
1380                          InitializeNewDxRec(UBAGlobals.globalDxRec);
1381                          GetBADxListForOrder(UBAGlobals.globalDxRec, thisOrderID);
1382                       end
1383                   else
1384                      GetBADxListForOrder(UBAGlobals.globalDxRec, thisOrderID);
1385  
1386                   {$ifdef debug}
1387                   with UBAGlobals.globalDxRec do
1388                      //Show508Message('globalDxRec:'+#13+FOrderID+#13+FBADxCode+#13+FBASecDx1+#13+FBASecDx2+#13+FBASecDx3);
1389                   {$endif}
1390                    end;
1391             end; //if
1392          end; //for
1393       except
1394          on E: Exception  do
1395             ShowMsg(E.ClassName+' error raised, with message : '+E.Message);
1396     end;
1397  
1398    numSelected  := CountSelectedOrders(UBAConst.F_ORDERS_SIGN);
1399    
1400    if numSelected = 0 then
1401       begin
1402       ShowMsg(UBAMessages.BA_NO_ORDERS_SELECTED);
1403       Exit;
1404       end
1405    else
1406       if numSelected = 1 then
1407          match := true;
1408  
1409    if (UBAGlobals.CompareOrderDx(UBAConst.F_ORDERS_SIGN)) then
1410       match := true;
1411  
1412  
1413    if UBAGlobals.AllSelectedDxBlank(UBAConst.F_ORDERS_SIGN) then
1414       allBlank := true;
1415  
1416    if ((match and allBlank) or (match and (not allBlank))) then  // All selected are blank or matching-not-blank
1417          frmBALocalDiagnoses.Enter(UBAConst.F_ORDERS_SIGN, orderIDList)
1418     else
1419       begin
1420       //Warning message
1421       //If 'Yes' on warning message then open localDiagnosis
1422       if (not allBlank) then
1423           if MessageDlg(UBAMessages.BA_CONFIRM_DX_OVERWRITE, mtConfirmation, [mbYes, mbNo], 0) = mrNo then
1424                Exit
1425           else
1426                if Assigned(UBAGlobals.globalDxRec) then
1427                   InitializeNewDxRec(UBAGlobals.globalDxRec);
1428                frmBALocalDiagnoses.Enter(UBAConst.F_ORDERS_SIGN, orderIDList);
1429       end;
1430   // TFactors come from FBALocalDiagnoses(Problem List Dx's Only).
1431      if Length(UBAGlobals.TFactors) > 0 then
1432      begin
1433         UBACore.SetTreatmentFactors(UBAGlobals.TFactors);
1434         SigItems.DisplayPlTreatmentFactors;
1435      end;
1436   {End BillingAware}
1437   txtESCode.SetFocus;
1438  end;
1439  
1440  procedure TfrmSignOrders.Exit1Click(Sender: TObject);
1441  begin
1442    Close;
1443  end;
1444  
1445  procedure TfrmSignOrders.Copy1Click(Sender: TObject);
1446  {
1447     - Copy contents of the 'source' order for copy/paste operation
1448  }
1449  var
1450    i : byte;
1451    numSelected: byte;
1452    thisChangeItem: TChangeItem;
1453  begin
1454     try
1455       if BILLING_AWARE then
1456          begin
1457          Paste1.Enabled := true;
1458  
1459           numSelected := GetNumberOfSelectedOrders;
1460  
1461           if numSelected > 1 then
1462             begin
1463             ShowMsg('Only 1 order at a time may be selected for ''Copying''');
1464             Exit;
1465             end;
1466  
1467           for i := 0 to fOrdersSign.frmSignOrders.clstOrders.Items.Count-1 do
1468               if (fOrdersSign.frmSignOrders.clstOrders.Selected[i]) then
1469                 begin
1470                 thisChangeItem := TChangeItem.Create;
1471                 thisChangeItem := nil;
1472                 thisChangeItem := TChangeItem(clstOrders.Items.Objects[i]);
1473                 //Skip this one if it's a "header" on the grid
1474                   if (thisChangeItem = nil) then //or (thisChangeItem.ItemType <> CH_ORD)) then
1475                      begin
1476                      FreeAndNil(thisChangeItem);
1477                      Exit;
1478                      end;
1479  
1480                 fOrdersSign.srcOrderID := TChangeItem(frmSignOrders.clstOrders.Items.Objects[i]).ID;
1481  
1482                 //Copy source order to COPY BUFFER and add it to the Dx List
1483                 CopyBuffer := TBADxRecord.Create;
1484                 InitializeNewDxRec(CopyBuffer);
1485                 GetBADxListForOrder(CopyBuffer, fOrdersSign.srcOrderID);
1486                 fOrdersSign.CopyBuffer.FOrderID := BUFFER_ORDER_ID;
1487                 UBAGlobals.tempDxList.Add(CopyBuffer);
1488  
1489                 //*************************************************************************
1490                 if (NOT UBACore.IsOrderBillable(fOrdersSign.srcOrderID) ) then //and
1491                 // added to allow copy to NON CIDC consult order the requires a DX. then
1492                   begin
1493                     ShowMsg(BA_NA_COPY_DISALLOWED);
1494                     fOrdersSign.srcOrderID := '';
1495                     Exit;
1496                   end;
1497                 //*************************************************************************
1498  
1499                 fOrdersSign.srcIndex := clstOrders.ItemIndex;
1500                 fOrdersSign.chkBoxStatus := GetCheckBoxStatus(fOrdersSign.srcOrderID);
1501                 Break;
1502                 end;
1503           end; //if BILLING_AWARE
1504     except
1505       on EListError do
1506          begin
1507            ShowMsg('EListError in frmSignOrders.Copy1Click()');
1508          raise;
1509          end;
1510     end;
1511  end;
1512  
1513  procedure TfrmSignOrders.Paste1Click(Sender: TObject);
1514  {
1515   - Populate 'target' orders of a copy/paste operation with contents of 'source' order
1516  }  
1517  var
1518    i: byte;
1519    newRec: TBADxRecord;
1520  begin
1521    if BILLING_AWARE then
1522       begin
1523        if not Assigned(fOrdersSign.CopyBuffer) then //CQ5414
1524          fOrdersSign.CopyBuffer := TBADxRecord.Create; //CQ5414
1525  
1526       try
1527           for i := 0 to clstOrders.Count - 1 do
1528                 begin
1529                 if (fOrdersSign.frmSignOrders.clstOrders.Selected[i]) then
1530                   begin
1531                     fOrdersSign.targetOrderID := TChangeItem(fOrdersSign.frmSignOrders.clstOrders.Items.Objects[i]).ID;
1532  
1533                    if fOrdersSign.targetOrderID = fOrdersSign.srcOrderID then //disallow copying an order to itself
1534                       Continue
1535                    else
1536                       begin
1537                         fOrdersSign.CopyBuffer.FOrderID := BUFFER_ORDER_ID;
1538  
1539                       //***************************************************************
1540                       if Not UBACore.IsOrderBillable(targetOrderID) then
1541                         begin
1542                           ShowMsg(BA_NA_PASTE_DISALLOWED);
1543                           fOrdersSign.targetOrderID := '';
1544                           Continue;
1545                         end;
1546                       //***************************************************************
1547  
1548                       newRec := TBADxRecord.Create;
1549                       with newRec do
1550                         begin
1551                           FOrderID :=  fOrdersSign.targetOrderID;
1552                           FBADxCode := CopyBuffer.FBADxCode;
1553                           FBASecDx1 := CopyBuffer.FBASecDx1;
1554                           FBASecDx2 := CopyBuffer.FBASecDx2;
1555                           FBASecDx3 := CopyBuffer.FBASecDx3;
1556                         end;
1557  
1558                      tempDxList.Add(newRec);
1559  
1560                      CopyTFCIToTargetOrder( fOrdersSign.targetOrderID, fOrdersSign.chkBoxStatus);
1561                      SetCheckBoxStatus( fOrdersSign.targetOrderID);  //calls uSignItems.SetSigItems()
1562                    end;
1563                   end;
1564                 end;
1565       except
1566          on EListError do
1567             begin
1568               ShowMsg('EListError in frmSignOrders.Paste1Click()'+#13+'for i := 0 to clstOrders.Count - 1 do');
1569             raise;
1570             end;
1571       end;
1572           clstOrders.Refresh; //Update grid to show pasted Dx
1573       end;
1574  end;
1575  
1576  procedure TfrmSignOrders.clstOrdersMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
1577  {
1578   - Open copy/paste popup menu.
1579  }
1580  var
1581    ClientPoint: TPoint;
1582    ScreenPoint: TPoint;
1583  begin
1584    if not BILLING_AWARE then clstOrders.PopupMenu := nil;
1585    
1586    if BILLING_AWARE then
1587       begin
1588       try
1589          if Button = mbRight then  //Right-click to open copy/paste popup menu
1590             begin
1591             //CQ3325
1592             if fOrdersSign.frmSignOrders.clstOrders.Items.Count = 1 then
1593                begin
1594                  Copy1.Enabled := false;
1595                  Paste1.Enabled := false
1596                end
1597             else
1598                begin
1599                  Copy1.Enabled := true;
1600                end;
1601             //End CQ3325
1602  
1603             if not frmSignOrders.clstOrders.Selected[clstOrders.ItemIndex] then
1604                (Sender as TCheckListBox).Selected[clstOrders.ItemIndex] := true;
1605  
1606             ClientPoint.X := X;
1607             ClientPoint.Y := Y;
1608             ScreenPoint := clstOrders.ClientToScreen(ClientPoint);
1609             poBACopyPaste.Popup(ScreenPoint.X, ScreenPoint.Y);
1610             end;
1611       except
1612          on EListError do
1613             begin
1614               ShowMsg('EListError in frmSignOrders.clstOrdersMouseDown()');
1615             raise;
1616             end;
1617       end;
1618       end;
1619  end;
1620  
1621  
1622  procedure TfrmSignOrders.clstCSOrdersClick(Sender: TObject);  
1623  //If grid item is an order-able item, then enable the Diagnosis button
1624  // else disable the Diagnosis button.
1625  var
1626    thisChangeItem: TChangeItem;
1627    i: smallint;
1628    thisOrderList: TStringList;
1629  begin
1630    thisOrderList := TStringList.Create;
1631  
1632   {Begin BillingAware}
1633   if  BILLING_AWARE then
1634   begin
1635  
1636   if clstCSOrders.Items.Count > 1 then
1637          copy1.Enabled := True
1638       else
1639          copy1.Enabled := False;
1640  
1641       for i := 0 to clstCSOrders.Items.Count - 1 do
1642          begin
1643             if clstCSOrders.Selected[i] then
1644                begin
1645                  thisChangeItem := TChangeItem(clstCSOrders.Items.Objects[i]);
1646  
1647                  //Disallow copying of a grid HEADER item on LEFT MOUSE CLICK
1648                if thisChangeItem = nil then
1649                   begin
1650                     Copy1.Enabled := false;
1651                     buOrdersDiagnosis.Enabled := false;
1652                     Exit;
1653                   end;
1654  
1655                if (thisChangeItem <> nil) then //Blank row - not an order item
1656                   begin
1657                     thisOrderList.Clear;
1658                     thisOrderList.Add(thisChangeItem.ID);
1659  
1660                     if IsAllOrdersNA(thisOrderList) then
1661                     begin
1662                       Diagnosis1.Enabled := false;
1663                       buOrdersDiagnosis.Enabled := false;
1664                    end
1665                   else
1666                   begin
1667                      Diagnosis1.Enabled := true;
1668                      buOrdersDiagnosis.Enabled := true;
1669                   end
1670                end
1671                else
1672                begin
1673                   buOrdersDiagnosis.Enabled := false;
1674                   Diagnosis1.Enabled := False;
1675                   Break;
1676                end;
1677             end;
1678          end;
1679  
1680    if Assigned(thisOrderList) then thisOrderList.Free;
1681    end;        
1682  end;
1683  
1684  procedure TfrmSignOrders.clstCSOrdersClickCheck(Sender: TObject);
1685  
1686     procedure updateAllChilds(CheckedStatus: boolean; ParentOrderId: string);
1687     var
1688       idx: integer;
1689     begin
1690       for idx := 0 to clstCSOrders.Items.Count - 1 do
1691          if TOrder(clstCSOrders.Items.Objects[idx]).ParentID = ParentOrderId then
1692          begin
1693             if clstCSOrders.Checked[idx] <> CheckedStatus then
1694             begin
1695                clstCSOrders.Checked[idx] := CheckedStatus;
1696                SigItemsCS.EnableSettings(idx, clstCSOrders.checked[Idx]);
1697             end;
1698          end;
1699     end;
1700  
1701  begin
1702    with clstCSOrders do
1703    begin
1704      if Length(TOrder(Items.Objects[ItemIndex]).ParentID)>0 then
1705      begin
1706        SigItemsCS.EnableSettings(ItemIndex, checked[ItemIndex]);
1707        updateAllChilds(checked[ItemIndex],TOrder(Items.Objects[ItemIndex]).ParentID);
1708      end else
1709        SigItemsCS.EnableSettings(ItemIndex, checked[ItemIndex]);
1710    end;
1711    if CSItemsAreChecked and nonDCCSItemsAreChecked then
1712    begin
1713       lblDeaText.Visible := TRUE;
1714       lblSmartCardNeeded.Visible := TRUE;
1715    end
1716    else
1717    begin
1718       lblDeaText.Visible := FALSE;
1719       lblSmartCardNeeded.Visible := FALSE;
1720    end;
1721    if AnyItemsAreChecked then
1722    begin
1723       lblESCode.Visible := IsSignatureRequired;
1724       txtESCode.Visible := IsSignatureRequired
1725    end
1726    else
1727    begin
1728      lblESCode.Visible := ItemsAreChecked or CSItemsAreChecked;
1729      txtESCode.Visible := ItemsAreChecked or CSItemsAreChecked;
1730    end;
1731    if txtESCode.Visible then txtESCode.SetFocus;
1732  end;
1733  
1734  procedure TfrmSignOrders.clstCSOrdersDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
1735  var
1736  {Begin BillingAware}
1737    str: String;
1738    tempID: string;
1739    thisRec: UBAGlobals.TBADxRecord;
1740   {End BillingAware}
1741  
1742    X: string;
1743    ARect: TRect;
1744  begin
1745    inherited;
1746    X := '';
1747    ARect := Rect;
1748  
1749  {Begin BillingAware}
1750    if  BILLING_AWARE then
1751    begin
1752       with clstCSOrders do
1753       begin
1754         if Index < Items.Count then
1755         begin
1756            Canvas.FillRect(ARect);
1757            Canvas.Pen.Color := Get508CompliantColor(clSilver);
1758            Canvas.MoveTo(ARect.Left, ARect.Bottom);
1759            Canvas.LineTo(ARect.Right, ARect.Bottom);
1760            x := FilteredString(Items[Index]);
1761            ARect.Right := ARect.Right - 50;    //50 to 40
1762            //Vertical column line
1763            Canvas.MoveTo(ARect.Right, Rect.Top);
1764            Canvas.LineTo(ARect.Right, Rect.Bottom);
1765            //Adjust position of 'Diagnosis' column label for font size
1766            laDiagnosis.Left := ARect.Right + 14;
1767            if uSignItems.GetAllBtnLeftPos > 0 then
1768               laDiagnosis.left := uSignItems.GetAllBtnLeftPos - (laDiagnosis.Width +5);
1769                // ARect.Right below controls the right-hand side of the Dx Column
1770                // Adjust ARect.Right in conjunction with procedure uSignItems.TSigItems.lbDrawItem(), because the
1771                // two rectangles overlap each other.
1772             if  BILLING_AWARE then
1773             begin
1774                arRect[Index] := Classes.Rect(ARect.Right+2, ARect.Top, ARect.Right + 108, ARect.Bottom);
1775                Canvas.FillRect(arRect[Index]);
1776             end;
1777  
1778                //Win32 API - This call to DrawText draws the text of the ORDER - not the diagnosis code
1779                 DrawText(Canvas.handle, PChar(x), Length(x), ARect, DT_LEFT or DT_NOPREFIX or DT_WORDBREAK);
1780         if  BILLING_AWARE then
1781           begin
1782               if Assigned(UBAGlobals.tempDxList) then
1783                  begin
1784                     tempID := TOrder(clstCSOrders.Items.Objects[Index]).ID;
1785  
1786                  if UBAGlobals.tempDxNodeExists(tempID) then
1787                      begin
1788                         thisRec := TBADxRecord.Create;
1789                         UBAGlobals.GetBADxListForOrder(thisRec, tempID);
1790                         str := Piece(thisRec.FBADxCode,'^',1);
1791                         {v25 BA}
1792                         str := Piece(str,':',1);
1793                         DrawText(Canvas.handle, PChar(str), Length(str), arRect[Index], DT_LEFT or DT_NOPREFIX or DT_WORDBREAK);
1794                         if Not UBACore.IsOrderBillable(tempID) then
1795                         begin
1796                              Canvas.Font.Color := clBlue;
1797                              DrawText(Canvas.handle, PChar(NOT_APPLICABLE), Length(NOT_APPLICABLE), {Length(str),} arRect[Index], DT_LEFT or DT_NOPREFIX or DT_WORDBREAK);
1798                         end;
1799                      end
1800                   else
1801                      begin
1802                        //   determine if order is billable, if NOT then insert NA in Dx field
1803                       if Not UBACore.IsOrderBillable(tempID) then
1804                          begin
1805                              Canvas.Font.Color := clBlue;
1806                              DrawText(Canvas.handle, PChar(NOT_APPLICABLE), Length(NOT_APPLICABLE), {Length(str),} arRect[Index], DT_LEFT or DT_NOPREFIX or DT_WORDBREAK);
1807                          end;
1808                      end;
1809                  end;
1810              end;
1811  
1812          end;
1813         end;
1814    end
1815    else
1816       begin
1817          X := '';
1818          ARect := Rect;
1819          with clstCSOrders do
1820             begin
1821               if Index < Items.Count then
1822                  begin
1823                    Canvas.FillRect(ARect);
1824                    Canvas.Pen.Color := Get508CompliantColor(clSilver);
1825                    Canvas.MoveTo(ARect.Left, ARect.Bottom - 1);
1826                    Canvas.LineTo(ARect.Right, ARect.Bottom - 1);
1827                    X := FilteredString(Items[Index]);
1828                    DrawText(Canvas.handle, PChar(x), Length(x), ARect, DT_LEFT or DT_NOPREFIX or DT_WORDBREAK);
1829                  end;
1830             end;
1831       end;
1832  {End BillingAware}
1833  end;
1834  
1835  procedure TfrmSignOrders.clstCSOrdersMeasureItem(Control: TWinControl;
1836    Index: Integer; var AHeight: Integer);
1837  var
1838    X: string;
1839    ARect: TRect;
1840  begin
1841    inherited;
1842    AHeight := SigItemHeight;
1843    with clstCSOrders do if Index < Items.Count then
1844    begin
1845      ARect := ItemRect(Index);
1846      Canvas.FillRect(ARect);
1847      x := FilteredString(Items[Index]);
1848      AHeight := WrappedTextHeightByFont(Canvas, Font, x, ARect);
1849      if AHeight > 255 then AHeight := 255;
1850      //-------------------
1851      {Bug fix-HDS00001627}
1852      //if AHeight <  13 then AHeight := 13; {ORIG}
1853      if AHeight <  13 then AHeight := 15;
1854      //-------------------
1855    end;
1856  end;
1857  
1858  procedure TfrmSignOrders.clstOrdersClick(Sender: TObject);
1859  //If grid item is an order-able item, then enable the Diagnosis button
1860  // else disable the Diagnosis button.
1861  var
1862    thisChangeItem: TChangeItem;
1863    i: smallint;
1864    thisOrderList: TStringList;
1865  begin
1866    thisOrderList := TStringList.Create;
1867  
1868   {Begin BillingAware}
1869   if  BILLING_AWARE then
1870   begin
1871  
1872   if clstOrders.Items.Count > 1 then
1873          copy1.Enabled := True
1874       else
1875          copy1.Enabled := False;
1876  
1877       for i := 0 to clstOrders.Items.Count - 1 do
1878          begin
1879             if clstOrders.Selected[i] then
1880                begin
1881                  thisChangeItem := TChangeItem(clstOrders.Items.Objects[i]);
1882  
1883                  //Disallow copying of a grid HEADER item on LEFT MOUSE CLICK
1884                if thisChangeItem = nil then
1885                   begin
1886                     Copy1.Enabled := false;
1887                     buOrdersDiagnosis.Enabled := false;
1888                     Exit;
1889                   end;
1890  
1891                if (thisChangeItem <> nil) then //Blank row - not an order item
1892                   begin
1893                     thisOrderList.Clear;
1894                     thisOrderList.Add(thisChangeItem.ID);
1895  
1896                     if IsAllOrdersNA(thisOrderList) then
1897                     begin
1898                       Diagnosis1.Enabled := false;
1899                       buOrdersDiagnosis.Enabled := false;
1900                    end
1901                   else
1902                   begin
1903                      Diagnosis1.Enabled := true;
1904                      buOrdersDiagnosis.Enabled := true;
1905                   end
1906                end
1907                else
1908                begin
1909                   buOrdersDiagnosis.Enabled := false;
1910                   Diagnosis1.Enabled := False;
1911                   Break;
1912                end;
1913             end;
1914          end;
1915  
1916    if Assigned(thisOrderList) then thisOrderList.Free;
1917    end;        
1918  end;
1919  
1920  procedure TfrmSignOrders.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
1921  var
1922    j: integer; //CQ5054
1923  begin
1924    inherited;
1925    if FOSTFHintWndActive then
1926    begin
1927      FOSTFhintWindow.ReleaseHandle ;
1928      FOSTFHintWndActive := False ;
1929    end;
1930  
1931    case Key of
1932       67,99:  if (ssAlt in Shift) then ShowTreatmentFactorHints(BAFactorsRec.FBAFactorSC,fraCoPay.lblSC2); //C,c
1933       86,118: if (ssAlt in Shift) then ShowTreatmentFactorHints(BAFactorsRec.FBAFactorCV,fraCoPay.lblCV2); //V,v
1934       79,111: if (ssAlt in Shift) then ShowTreatmentFactorHints(BAFactorsRec.FBAFactorAO,fraCoPay.lblAO2); //O,o
1935       82,114: if (ssAlt in Shift) then ShowTreatmentFactorHints(BAFactorsRec.FBAFactorIR,fraCoPay.lblIR2); //R,r
1936       65,97:  if (ssAlt in Shift) then ShowTreatmentFactorHints(BAFactorsRec.FBAFactorEC,fraCoPay.lblSWAC2); //A,a
1937       77,109: if (ssAlt in Shift) then ShowTreatmentFactorHints(BAFactorsRec.FBAFactorMST,fraCoPay.lblMST2); //M,m
1938       78,110: if (ssAlt in Shift) then ShowTreatmentFactorHints(BAFactorsRec.FBAFactorHNC,fraCoPay.lblHNC2); //N,n
1939       72,104: if (ssALT in Shift) then ShowTreatmentFactorHints(BAFactorsRec.FBAFactorSHAD,fraCopay.lblSHAD2); // H,h
1940       //CQ5054
1941       83,115: if (ssAlt in Shift) then
1942            begin
1943              for j := 0 to clstOrders.Items.Count-1 do
1944                  clstOrders.Selected[j] := false;
1945              clstOrders.Selected[0] := true;
1946              clstOrders.SetFocus;
1947            end;
1948       //end CQ5054
1949    end;
1950  end;
1951  
1952  //BILLING AWARE Procedure
1953  procedure TfrmSignOrders.ShowTreatmentFactorHints(var pHintText: string; var pCompName: TVA508StaticText); // 508
1954  var
1955   HRect: TRect;
1956   thisRect: TRect;
1957   x,y: integer;
1958  
1959  begin
1960    try
1961       if FOSTFhintWndActive then
1962          begin
1963            FOSTFhintWindow.ReleaseHandle;
1964            FOSTFhintWndActive := False;
1965          end;
1966    except
1967       on E: Exception do
1968          begin
1969          {$ifdef debug}Show508Message('Unhandled exception in procedure TfrmSignOrders.ShowTreatmentFactorHints()');{$endif}
1970          raise;
1971          end;
1972    end;
1973  
1974    try
1975        FOSTFhintWindow := THintWindow.Create(frmSignOrders);
1976        FOSTFhintWindow.Color := clInfoBk;
1977        GetWindowRect(pCompName.Handle,thisRect);
1978        x := thisRect.Left;
1979        y := thisRect.Top;
1980        hrect := FOSTFhintWindow.CalcHintRect(Screen.Width, pHintText,nil);
1981        hrect.Left   := hrect.Left + X;
1982        hrect.Right  := hrect.Right + X;
1983        hrect.Top    := hrect.Top + Y;
1984        hrect.Bottom := hrect.Bottom + Y;
1985  
1986        fraCoPay.LabelCaptionsOn(not FOSTFHintWndActive);
1987  
1988        FOSTFhintWindow.ActivateHint(hrect, pHintText);
1989        FOSTFHintWndActive := True;
1990    except
1991       on E: Exception do
1992          begin
1993          {$ifdef debug}Show508Message('Unhandled exception in procedure TfrmSignOrders.ShowTreatmentFactorHints()');{$endif}
1994          raise;
1995          end;
1996    end;
1997  end;
1998  
1999  procedure TfrmSignOrders.FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
2000  begin
2001     try
2002        if FOSTFhintWndActive then
2003        begin
2004           FOSTFhintWindow.ReleaseHandle;
2005           FOSTFHintWndActive := False;
2006           Application.ProcessMessages;
2007        end;
2008    except
2009       on E: Exception do
2010          begin
2011          {$ifdef debug}Show508Message('Unhandled exception in procedure TfrmSignOrders.FormMouseMove()');{$endif}
2012          raise;
2013          end;
2014    end;
2015  end;
2016  
2017  procedure TfrmSignOrders.FormPaint(Sender: TObject);
2018  begin
2019    inherited;
2020  
2021    if fOrdersSign.frmSignOrders.clstCSOrders.count = 0 then
2022    begin
2023     fOrdersSign.frmSignOrders.clstOrders.Height := fOrdersSign.frmSignOrders.pnlOrderlist.Height - fOrdersSign.frmSignOrders.clstOrders.Top - 4;
2024     fOrdersSign.frmSignOrders.clstOrders.Width := fOrdersSign.frmSignOrders.pnlOrderlist.Width - fOrdersSign.frmSignOrders.clstOrders.Left - 4;
2025    end;
2026    if fOrdersSign.frmSignOrders.clstOrders.count = 0 then
2027    begin
2028     fOrdersSign.frmSignOrders.clstCSOrders.Height := fOrdersSign.frmSignOrders.pnlCSOrderlist.Height - fOrdersSign.frmSignOrders.clstCSOrders.Top - 4;
2029     fOrdersSign.frmSignOrders.clstCSOrders.Width := fOrdersSign.frmSignOrders.pnlCSOrderlist.Width - fOrdersSign.frmSignOrders.clstCSOrders.Left - 4;
2030    end;
2031  end;
2032  
2033  procedure TfrmSignOrders.FormResize(Sender: TObject);
2034  begin
2035    inherited;  
2036  
2037    if fOrdersSign.frmSignOrders.clstCSOrders.count = 0 then
2038    begin
2039     fOrdersSign.frmSignOrders.clstOrders.Height := fOrdersSign.frmSignOrders.pnlOrderlist.Height - fOrdersSign.frmSignOrders.clstOrders.Top - 4;
2040     fOrdersSign.frmSignOrders.clstOrders.Width := fOrdersSign.frmSignOrders.pnlOrderlist.Width - fOrdersSign.frmSignOrders.clstOrders.Left - 4;
2041    end;
2042    if fOrdersSign.frmSignOrders.clstOrders.count = 0 then
2043    begin
2044     fOrdersSign.frmSignOrders.clstCSOrders.Height := fOrdersSign.frmSignOrders.pnlCSOrderlist.Height - fOrdersSign.frmSignOrders.clstCSOrders.Top - 4;
2045     fOrdersSign.frmSignOrders.clstCSOrders.Width := fOrdersSign.frmSignOrders.pnlCSOrderlist.Width - fOrdersSign.frmSignOrders.clstCSOrders.Left - 4;
2046    end;
2047    clstOrders.invalidate;
2048  end;
2049  
2050  procedure TfrmSignOrders.fraCoPaylblHNCMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
2051  begin
2052    fraCoPay.LabelCaptionsOn(not FOSTFHintWndActive)
2053  end;
2054  
2055  procedure TfrmSignOrders.fraCoPayLabel23Enter(Sender: TObject);
2056  begin
2057      (Sender as TVA508StaticText).Font.Style := [fsBold];
2058  end;
2059  
2060  procedure TfrmSignOrders.fraCoPayLabel23Exit(Sender: TObject);
2061  begin
2062      (Sender as TVA508StaticText).Font.Style := [];
2063  end;
2064  
2065  procedure TfrmSignOrders.SetItemTextToState;
2066  var
2067    i : integer;
2068  begin
2069    //The with statement below would cause access violations on other Delphi machines.
2070    {  with clstOrders do
2071      begin }
2072    //Must use fully qualifying path includeing the unit... very wierd!
2073  
2074    if fOrdersSign.frmSignOrders.clstOrders.Count < 1 then Exit;
2075    for i := 0 to fOrdersSign.frmSignOrders.clstOrders.Count-1 do
2076      if fOrdersSign.frmSignOrders.clstOrders.Items.Objects[i] <> nil then //Not a Group Title
2077      begin
2078        if fOrdersSign.frmSignOrders.clstOrders.Items.Objects[i] is TOrder then
2079        if fOrdersSign.frmSignOrders.clstOrders.Checked[i] then
2080          fOrdersSign.frmSignOrders.clstOrders.Items[i] := 'Checked '+TOrder(fOrdersSign.frmSignOrders.clstOrders.Items.Objects[i]).Text
2081        else
2082          fOrdersSign.frmSignOrders.clstOrders.Items[i] := 'Not Checked '+TOrder(fOrdersSign.frmSignOrders.clstOrders.Items.Objects[i]).Text;
2083      end;
2084    if fOrdersSign.frmSignOrders.clstOrders.ItemIndex >= 0 then
2085      fOrdersSign.frmSignOrders.clstOrders.Selected[fOrdersSign.frmSignOrders.clstOrders.ItemIndex] := True;
2086  //    end;
2087  end;
2088  
2089  procedure TfrmSignOrders.clstOrdersKeyUp(Sender: TObject; var Key: Word;
2090    Shift: TShiftState);
2091  begin
2092    if (Key = VK_Space) then
2093      FormatListForScreenReader
2094  end;
2095  
2096  procedure TfrmSignOrders.FormatListForScreenReader;
2097  begin
2098    if ScreenReaderActive then
2099      SetItemTextToState;
2100  end;
2101  
2102  end.

Module Calls (2 levels)


fOrdersSign
 ├mCoPayDesc
 │ ├rPCE
 │ └UBAGlobals
 ├XuDsigS
 │ ├wcrypt2
 │ ├XuDsigU
 │ ├XlfMime
 │ ├XuDsigConst
 │ ├WinSCard
 │ └fPINPrompt
 ├uConsults
 │ └uConst
 ├UBAGlobals...
 ├UBACore
 │ ├uConst
 │ ├UBAGlobals...
 │ ├fFrame
 │ ├fReview
 │ ├rOrders
 │ ├uCore
 │ ├rCore
 │ └UBAConst
 ├UBAMessages
 ├UBAConst
 ├fBase508Form
 │ ├uConst
 │ └uHelpManager
 ├fPrintLocation
 │ ├fAutoSz
 │ ├rCore...
 │ ├uCore...
 │ └fFrame...
 ├fCSRemaining
 │ ├uCore...
 │ └rOrders...
 ├rODMeds
 │ ├uCore...
 │ └uConst
 ├rCore...
 ├rOrders...
 ├uConst
 ├uCore...
 ├uOrders
 │ ├uConst
 │ ├rConsults
 │ ├rOrders...
 │ ├fODBase
 │ ├XuDsigS...
 │ ├fODDiet
 │ ├fODMisc
 │ ├fODGen
 │ ├fODMedIn
 │ ├fODMedOut
 │ ├fODText
 │ ├fODConsult
 │ ├fODProc
 │ ├fODRad
 │ ├fODLab
 │ ├fODBBank
 │ ├fODMeds
 │ ├fODMedIV
 │ ├fODVitals
 │ ├fODAuto
 │ ├fOMNavA
 │ ├rCore...
 │ ├uCore...
 │ ├fFrame...
 │ ├fEncnt
 │ ├fOMVerify
 │ ├fOrderSaveQuick
 │ ├fOMSet
 │ ├rMisc
 │ ├uODBase
 │ ├rODMeds...
 │ ├fLkUpLocation
 │ ├fOrdersPrint
 │ ├fOMAction
 │ ├fARTAllgy
 │ ├fOMHTML
 │ ├fOrders
 │ ├rODBase
 │ ├fODChild
 │ ├fMeds
 │ ├rMeds
 │ ├rPCE...
 │ ├fRptBox
 │ ├fODMedNVA
 │ ├fODChangeUnreleasedRenew
 │ ├rODAllergy
 │ ├UBAGlobals...
 │ └uTemplateFields
 ├uSignItems
 │ ├fODBase...
 │ ├UBACore...
 │ ├uConst
 │ ├rOrders...
 │ ├fOrdersSign...
 │ ├fReview...
 │ ├UBAGlobals...
 │ └uCore...
 ├fBALocalDiagnoses
 │ ├fAutoSz...
 │ ├fPCELex
 │ ├uConsults...
 │ ├rPCE...
 │ ├UBAGlobals...
 │ ├UBACore...
 │ ├uCore...
 │ ├rCore...
 │ ├rOrders...
 │ ├fOrdersSign...
 │ ├UBAConst
 │ ├UBAMessages
 │ ├fReview...
 │ ├fODConsult...
 │ └fFrame...
 ├fFrame...
 ├rODLab
 │ └uCore...
 └fRptBox...

Module Called-By (2 levels)


            fOrdersSign
           UBAGlobals┤ 
            rOrders┤ │ 
            uOrders┤ │ 
            fODBase┤ │ 
            UBACore┤ │ 
             fFrame┤ │ 
            fOrders┤ │ 
  fBALocalDiagnoses┤ │ 
            fPCELex┤ │ 
               rPCE┤ │ 
         fDiagnoses┤ │ 
             fPtSel┤ │ 
     fOrdersSign...┤ │ 
         mCoPayDesc┤ │ 
            fReview┤ │ 
fBAOptionsDiagnoses┤ │ 
         uSignItems┤ │ 
       fOrdersRenew┤ │ 
         fODConsult┤ │ 
       fEditConsult┤ │ 
     fOrdersRelease┘ │ 
            fFrame...┤ 
           fOrders...┤ 
 fBALocalDiagnoses...┤ 
           fReview...┤ 
        uSignItems...┘