47. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 2/23/2017 7:16:43 AM Central Standard Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

47.1 Files compared

# Location File Last Modified
1 CPRS_v31_223_cif.zip\OR_30_377V223_SRC.zip\CPRS-chart fFrame.pas Wed Nov 16 17:31:40 2016 UTC
2 CPRS_v31_223_cif.zip\OR_30_377V223_SRC.zip\CPRS-chart fFrame.pas Fri Feb 17 20:21:33 2017 UTC

47.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 2 10056
Changed 1 2
Inserted 0 0
Removed 0 0

47.3 Comparison options

Whitespace
Character case Differences in character case are significant
Line endings Differences in line endings (CR and LF characters) are ignored
CR/LF characters Not shown in the comparison detail

47.4 Active regular expressions

No regular expressions were active.

47.5 Comparison detail

  1   unit fFram e;
  2   { This is  the main f orm for th e CPRS GUI .  It prov ides a pat ient-encou nter-user  framework
  3     which al l the othe r forms of  the GUI u se. }
  4  
  5   {$OPTIMIZA TION OFF}                                 / / REMOVE A FTER UNIT  IS DEBUGGE D
  6   {$WARN SYM BOL_PLATFO RM OFF}
  7   {$DEFINE C COWBROKER}
  8  
  9   {$undef de bug}
  10  
  11   interface
  12  
  13   uses
  14     Windows,  Messages,  SysUtils,  Classes,  Graphics,  Controls,  Forms, Dia logs, Tabs , ComCtrls ,
  15     ExtCtrls , Menus, S tdCtrls, B uttons, OR Fn, fPage,  uConst, O RCtrls, Tr pcb, Contn rs,
  16     OleCtrls , VERGENCE CONTEXTORL ib_TLB, Co mObj, AppE vnts, fBas e508Form,  oPKIEncryp tion,
  17     VA508Acc essibility Manager, R ichEdit, f DebugRepor t, StrUtil s, vcl.Act nList,
  18     System.S yncObjs, U _CPTAppMon itor, ORNe tIntf;
  19  
  20   type
  21     TfrmFram e = class( TfrmBase50 8Form)
  22       pnlToo lbar: TPan el;
  23       stsAre a: TStatus Bar;
  24       tabPag e: TTabCon trol;
  25       pnlPag e: TPanel;
  26       bvlPag eTop: TBev el;
  27       bvlToo lTop: TBev el;
  28       pnlPat ient: TKey ClickPanel ;
  29       lblPtN ame: TStat icText;
  30       lblPtS SN: TStati cText;
  31       lblPtA ge: TStati cText;
  32       pnlVis it: TKeyCl ickPanel;
  33       lblPtL ocation: T StaticText ;
  34       lblPtP rovider: T StaticText ;
  35       mnuFra me: TMainM enu;
  36       mnuFil e: TMenuIt em;
  37       mnuFil eExit: TMe nuItem;
  38       mnuFil eOpen: TMe nuItem;
  39       mnuFil eReview: T MenuItem;
  40       Z1: TM enuItem;
  41       mnuFil ePrint: TM enuItem;
  42       mnuEdi t: TMenuIt em;
  43       mnuEdi tUndo: TMe nuItem;
  44       Z3: TM enuItem;
  45       mnuEdi tCut: TMen uItem;
  46       mnuEdi tCopy: TMe nuItem;
  47       mnuEdi tPaste: TM enuItem;
  48       Z4: TM enuItem;
  49       mnuEdi tPref: TMe nuItem;
  50       Prefs1 : TMenuIte m;
  51       mnu18p t1: TMenuI tem;
  52       mnu14p t1: TMenuI tem;
  53       mnu12p t1: TMenuI tem;
  54       mnu10p t1: TMenuI tem;
  55       mnu8pt : TMenuIte m;
  56       mnuHel p: TMenuIt em;
  57       mnuHel pContents:  TMenuItem ;
  58       mnuHel pTutor: TM enuItem;
  59       Z5: TM enuItem;
  60       mnuHel pAbout: TM enuItem;
  61       mnuToo ls: TMenuI tem;
  62       mnuVie w: TMenuIt em;
  63       mnuVie wChart: TM enuItem;
  64       mnuCha rtReports:  TMenuItem ;
  65       mnuCha rtLabs: TM enuItem;
  66       mnuCha rtDCSumm:  TMenuItem;
  67       mnuCha rtCslts: T MenuItem;
  68       mnuCha rtNotes: T MenuItem;
  69       mnuCha rtOrders:  TMenuItem;
  70       mnuCha rtMeds: TM enuItem;
  71       mnuCha rtProbs: T MenuItem;
  72       mnuCha rtCover: T MenuItem;
  73       mnuHel pBroker: T MenuItem;
  74       mnuFil eEncounter : TMenuIte m;
  75       mnuVie wDemo: TMe nuItem;
  76       mnuVie wPostings:  TMenuItem ;
  77       mnuHel pLists: TM enuItem;
  78       Z6: TM enuItem;
  79       mnuHel pSymbols:  TMenuItem;
  80       mnuFil eNext: TMe nuItem;
  81       Z7: TM enuItem;
  82       mnuFil eRefresh:  TMenuItem;
  83       pnlPri maryCare:  TKeyClickP anel;
  84       lblPtC are: TStat icText;
  85       lblPtA ttending:  TStaticTex t;
  86       pnlRem inders: TK eyClickPan el;
  87       imgRem inder: TIm age;
  88       mnuVie wReminders : TMenuIte m;
  89       anmtRe mSearch: T Animate;
  90       lstCIR NLocations : TORListB ox;
  91       popCIR N: TPopupM enu;
  92       popCIR NSelectAll : TMenuIte m;
  93       popCIR NSelectNon e: TMenuIt em;
  94       popCIR NClose: TM enuItem;
  95       mnuFil ePrintSetu p: TMenuIt em;
  96       LabInf o1: TMenuI tem;
  97       mnuFil eNotifRemo ve: TMenuI tem;
  98       Z8: TM enuItem;
  99       mnuToo lsOptions:  TMenuItem ;
  100       mnuCha rtSurgery:  TMenuItem ;
  101       OROpen Dlg: TOpen Dialog;
  102       mnuFil eResumeCon text: TMen uItem;
  103       mnuFil eResumeCon textSet: T MenuItem;
  104       Useexi stingconte xt1: TMenu Item;
  105       mnuFil eBreakCont ext: TMenu Item;
  106       pnlCCO W: TPanel;
  107       imgCCO W: TImage;
  108       pnlPat ientSelect ed: TPanel ;
  109       pnlNoP atientSele cted: TPan el;
  110       pnlPos tings: TKe yClickPane l;
  111       lblPtP ostings: T StaticText ;
  112       lblPtC WAD: TStat icText;
  113       mnuFil ePrintSele ctedItems:  TMenuItem ;
  114       popAle rts: TPopu pMenu;
  115       mnuAle rtContinue : TMenuIte m;
  116       mnuAle rtForward:  TMenuItem ;
  117       mnuAle rtRenew: T MenuItem;
  118       AppEve nts: TAppl icationEve nts;
  119       paVAA:  TKeyClick Panel;
  120       mnuToo lsGraphing : TMenuIte m;
  121       laVAA2 : TButton;
  122       laMHV:  TButton;
  123       mnuVie wInformati on: TMenuI tem;
  124       mnuVie wVisits: T MenuItem;
  125       mnuVie wPrimaryCa re: TMenuI tem;
  126       mnuVie wMyHealthe Vet: TMenu Item;
  127       mnuIns urance: TM enuItem;
  128       mnuVie wFlags: TM enuItem;
  129       mnuVie wRemoteDat a: TMenuIt em;
  130       compAc cessTabPag e: TVA508C omponentAc cessibilit y;
  131       pnlCVn Flag: TPan el;
  132       btnCom batVet: TB utton;
  133       pnlFla g: TKeyCli ckPanel;
  134       lblFla g: TLabel;
  135       pnlRem oteData: T KeyClickPa nel;
  136       pnlVis taWeb: TKe yClickPane l;
  137       lblVis taWeb: TLa bel;
  138       pnlCIR N: TKeyCli ckPanel;
  139       lblCIR N: TLabel;
  140       mnuEdi tRedo: TMe nuItem;
  141       lblPtM HTC: TStat icText;
  142       Digita lSigningSe tup1: TMen uItem;
  143       mnuFoc usChanges:  TMenuItem ;
  144       txtCmd Flags: TVA 508StaticT ext;
  145       mnuFil eViewNotif ications:  TMenuItem;
  146       CPAppM on: TCopyA pplication Monitor;
  147       proced ure tabPag eChange(Se nder: TObj ect);
  148       proced ure FormCr eate(Sende r: TObject );
  149       proced ure FormRe size(Sende r: TObject );
  150       proced ure pnlPat ientMouseD own(Sender : TObject;  Button: T MouseButto n;
  151         Shif t: TShiftS tate; X, Y : Integer) ;
  152       proced ure pnlPat ientMouseU p(Sender:  TObject; B utton: TMo useButton;
  153         Shif t: TShiftS tate; X, Y : Integer) ;
  154       proced ure pnlVis itMouseDow n(Sender:  TObject; B utton: TMo useButton;
  155         Shif t: TShiftS tate; X, Y : Integer) ;
  156       proced ure pnlVis itMouseUp( Sender: TO bject; But ton: TMous eButton;
  157         Shif t: TShiftS tate; X, Y : Integer) ;
  158       proced ure mnuFil eExitClick (Sender: T Object);
  159       proced ure pnlPos tingsMouse Down(Sende r: TObject ; Button:  TMouseButt on;
  160         Shif t: TShiftS tate; X, Y : Integer) ;
  161       proced ure pnlPos tingsMouse Up(Sender:  TObject;  Button: TM ouseButton ;
  162         Shif t: TShiftS tate; X, Y : Integer) ;
  163       proced ure mnuFon tSizeClick (Sender: T Object);
  164       proced ure mnuCha rtTabClick (Sender: T Object);
  165       proced ure FormDe stroy(Send er: TObjec t);
  166       proced ure mnuFil eOpenClick (Sender: T Object);
  167       proced ure mnuHel pBrokerCli ck(Sender:  TObject);
  168       proced ure mnuFil eEncounter Click(Send er: TObjec t);
  169       proced ure mnuVie wPostingsC lick(Sende r: TObject );
  170       proced ure mnuHel pAboutClic k(Sender:  TObject);
  171       proced ure mnuFil eReviewCli ck(Sender:  TObject);
  172       proced ure FormCl oseQuery(S ender: TOb ject; var  CanClose:  Boolean);
  173       proced ure mnuHel pListsClic k(Sender:  TObject);
  174       proced ure ToolCl ick(Sender : TObject) ;
  175       proced ure mnuEdi tClick(Sen der: TObje ct);
  176       proced ure mnuEdi tUndoClick (Sender: T Object);
  177       proced ure mnuEdi tCutClick( Sender: TO bject);
  178       proced ure mnuEdi tCopyClick (Sender: T Object);
  179       proced ure mnuEdi tPasteClic k(Sender:  TObject);
  180       proced ure mnuHel pSymbolsCl ick(Sender : TObject) ;
  181       proced ure FormCl ose(Sender : TObject;  var Actio n: TCloseA ction);
  182       proced ure mnuFil ePrintClic k(Sender:  TObject);
  183       proced ure mnuGEC StatusClic k(Sender:  TObject);
  184       proced ure mnuFil eNextClick (Sender: T Object);
  185       proced ure pnlPri maryCareMo useDown(Se nder: TObj ect;
  186         Butt on: TMouse Button; Sh ift: TShif tState; X,  Y: Intege r);
  187       proced ure pnlPri maryCareMo useUp(Send er: TObjec t; Button:  TMouseBut ton;
  188         Shif t: TShiftS tate; X, Y : Integer) ;
  189       proced ure pnlRem indersMous eDown(Send er: TObjec t; Button:  TMouseBut ton;
  190         Shif t: TShiftS tate; X, Y : Integer) ;
  191       proced ure pnlRem indersMous eUp(Sender : TObject;  Button: T MouseButto n;
  192         Shif t: TShiftS tate; X, Y : Integer) ;
  193       proced ure pnlCIR NClick(Sen der: TObje ct);
  194       proced ure lstCIR NLocations Click(Send er: TObjec t);
  195       proced ure popCIR NCloseClic k(Sender:  TObject);
  196       proced ure popCIR NSelectAll Click(Send er: TObjec t);
  197       proced ure popCIR NSelectNon eClick(Sen der: TObje ct);
  198       proced ure mnuFil ePrintSetu pClick(Sen der: TObje ct);
  199       proced ure LabInf o1Click(Se nder: TObj ect);
  200       proced ure mnuFil eNotifRemo veClick(Se nder: TObj ect);
  201       proced ure mnuToo lsOptionsC lick(Sende r: TObject );
  202       proced ure mnuFil eRefreshCl ick(Sender : TObject) ;
  203       proced ure FormKe yDown(Send er: TObjec t; var Key : Word;
  204         Shif t: TShiftS tate);
  205       proced ure FormAc tivate(Sen der: TObje ct);
  206       proced ure pnlPri maryCareEn ter(Sender : TObject) ;
  207       proced ure pnlPri maryCareEx it(Sender:  TObject);
  208       proced ure pnlPat ientClick( Sender: TO bject);
  209       proced ure pnlVis itClick(Se nder: TObj ect);
  210       proced ure pnlPri maryCareCl ick(Sender : TObject) ;
  211       proced ure pnlRem indersClic k(Sender:  TObject);
  212       proced ure pnlPos tingsClick (Sender: T Object);
  213       proced ure ctxCon textorCanc eled(Sende r: TObject );
  214       proced ure ctxCon textorComm itted(Send er: TObjec t);
  215       proced ure ctxCon textorPend ing(Sender : TObject;
  216         cons t aContext ItemCollec tion: IDis patch);
  217       proced ure mnuDeb ugReportCl ick(Sender : TObject) ;
  218       proced ure mnuFil eBreakCont extClick(S ender: TOb ject);
  219       proced ure mnuFil eResumeCon textGetCli ck(Sender:  TObject);
  220       proced ure mnuFil eResumeCon textSetCli ck(Sender:  TObject);
  221       proced ure pnlFla gMouseDown (Sender: T Object; Bu tton: TMou seButton;
  222         Shif t: TShiftS tate; X, Y : Integer) ;
  223       proced ure pnlFla gMouseUp(S ender: TOb ject; Butt on: TMouse Button;
  224         Shif t: TShiftS tate; X, Y : Integer) ;
  225       proced ure pnlFla gClick(Sen der: TObje ct);
  226       proced ure mnuFil ePrintSele ctedItemsC lick(Sende r: TObject );
  227       proced ure mnuAle rtRenewCli ck(Sender:  TObject);
  228       proced ure mnuAle rtForwardC lick(Sende r: TObject );
  229       proced ure pnlFla gEnter(Sen der: TObje ct);
  230       proced ure pnlFla gExit(Send er: TObjec t);
  231       proced ure tabPag eMouseUp(S ender: TOb ject; Butt on: TMouse Button;
  232         Shif t: TShiftS tate; X, Y : Integer) ;
  233       proced ure lstCIR NLocations Exit(Sende r: TObject );
  234       proced ure AppEve ntsActivat e(Sender:  TObject);
  235       proced ure Screen ActiveForm Change(Sen der: TObje ct);
  236       proced ure AppEve ntsShortCu t(var Msg:  TWMKey; v ar Handled : Boolean) ;
  237       proced ure mnuToo lsGraphing Click(Send er: TObjec t);
  238       proced ure pnlCIR NMouseDown (Sender: T Object; Bu tton: TMou seButton;
  239         Shif t: TShiftS tate; X, Y : Integer) ;
  240       proced ure pnlCIR NMouseUp(S ender: TOb ject; Butt on: TMouse Button;
  241         Shif t: TShiftS tate; X, Y : Integer) ;
  242       proced ure laMHVC lick(Sende r: TObject );
  243       proced ure laVAA2 Click(Send er: TObjec t);
  244       proced ure ViewIn fo(Sender:  TObject);
  245       proced ure mnuVie wInformati onClick(Se nder: TObj ect);
  246       proced ure compAc cessTabPag eCaptionQu ery(Sender : TObject;
  247         var  Text: stri ng);
  248       proced ure btnCom batVetClic k(Sender:  TObject);
  249       proced ure pnlVis taWebClick (Sender: T Object);
  250       proced ure pnlVis taWebMouse Up(Sender:  TObject;  Button: TM ouseButton ;
  251         Shif t: TShiftS tate; X, Y : Integer) ;
  252       proced ure pnlVis taWebMouse Down(Sende r: TObject ; Button:  TMouseButt on;
  253         Shif t: TShiftS tate; X, Y : Integer) ;
  254       proced ure mnuEdi tRedoClick (Sender: T Object);
  255       proced ure tabPag eMouseDown (Sender: T Object; Bu tton: TMou seButton;
  256         Shif t: TShiftS tate; X, Y : Integer) ;
  257       proced ure Digita lSigningSe tup1Click( Sender: TO bject);
  258       proced ure mnuFoc usChangesC lick(Sende r: TObject );
  259       proced ure AppEve ntsMessage (var Msg:  tagMSG; va r Handled:  Boolean);
  260       proced ure mnuFil eViewNotif icationsCl ick(Sender : TObject) ;
  261       proced ure paVAAR esize(Send er: TObjec t);
  262       proced ure LoadBu ffer(Sende r: TObject ; LoadList : TStrings ; var Proc essLoad: B oolean);
  263       proced ure LoadPr operties(S ender: TOb ject);
  264       proced ure SaveBu ffer(Sende r: TObject ; SaveList : TStringL ist; var R eturnList:  TStringLi st);
  265       proced ure StartP ollBuff(Se nder: TObj ect; var E rror: Bool ean);
  266       proced ure StopPo llBuff(Sen der: TObje ct; var Er ror: Boole an);
  267     private
  268       FProcc essingNext Click : bo olean;
  269       FJustE nteredApp  : boolean;
  270       FCCOWI nstalled:  boolean;
  271       FCCOWC ontextChan ging: bool ean;
  272       FCCOWI conName: s tring;
  273       FCCOWD rivedChang e: boolean ;
  274       FCCOWB usy: boole an;
  275       FCCOWE rror: bool ean;
  276       FCCOWJ ustJoined:  boolean;
  277       FNoPat ientSelect ed: boolea n;
  278       FRefre shing: boo lean;
  279       FClosi ng: boolea n;
  280       FConte xtChanging : Boolean;
  281       FChang eSource: I nteger;
  282       FCreat eProgress:  Integer;
  283       FEditC trl: TCust omEdit;
  284       FLastP age: TForm ;
  285       FNextB uttonL: In teger;
  286       FNextB uttonR: In teger;
  287       FNextB uttonActiv e: Boolean ;
  288       FNextB uttonBitma p: TBitmap ;
  289       FNextB utton: TBi tBtn;
  290       FTermi nate: Bool ean;
  291       FTabCh anged: TNo tifyEvent;
  292       FOldAc tivate: TN otifyEvent ;
  293       FOldAc tiveFormCh ange: TNot ifyEvent;
  294       FECSAu thUser: Bo olean;
  295       FFixed StatusWidt h: integer ;
  296       FPrevI nPatient:  Boolean;
  297       FFirst Load:    B oolean;
  298       FFlagL ist: TStri ngList;
  299       FPrevP tID: strin g;
  300       FGraph FloatActiv e: boolean ;
  301       FGraph Context: s tring;
  302       FDoNot ChangeEncW indow: boo lean;
  303       FOrder PrintForm:  boolean;
  304       FRevie wclick: bo olean;
  305       FCtrlT abUsed: bo olean;
  306       proced ure Refres hFixedStat usWidth;
  307       proced ure FocusA pplication TopForm;
  308       proced ure AppAct ivated(Sen der: TObje ct);
  309       proced ure AppDeA ctivated(S ender: TOb ject);
  310       proced ure AppExc eption(Sen der: TObje ct; E: Exc eption);
  311       functi on AllowCo ntextChang eAll(var R eason: str ing):  Boo lean;
  312       proced ure ClearP atient;
  313       proced ure Change Font(NewFo ntSize: In teger);
  314       proced ure Create Tab(ATabID : integer;  ALabel: s tring);
  315       proced ure Determ ineNextTab ;
  316       functi on ExpandC ommand(x:  string): s tring;
  317       proced ure FitToo lbar;
  318       proced ure LoadSi zesForUser ;
  319       proced ure SaveSi zesForUser ;
  320       proced ure LoadUs erPreferen ces;
  321       proced ure SaveUs erPreferen ces;
  322       proced ure Switch ToPage(New Form: TFor m);
  323       functi on TabToPa geID(Tab:  Integer):  Integer;
  324       functi on Timeout Condition:  boolean;
  325       functi on GetTime dOut: bool ean;
  326       proced ure TimeOu tAction;
  327       proced ure SetUse rTools;
  328       proced ure SetDeb ugMenu;
  329       proced ure SetupP atient(AFl aggedList  : TStringL ist = nil) ;
  330       proced ure Remind ersChanged (Sender: T Object);
  331       proced ure Report sOnlyDispl ay;
  332       proced ure UMInit iate(var M essage: TM essage);    message U M_INITIATE ;
  333       proced ure UMNewO rder(var M essage: TM essage);    message U M_NEWORDER ;
  334       proced ure UMStat usText(var  Message:  TMessage);  message U M_STATUSTE XT;
  335       proced ure UMShow Page(var M essage: TM essage);    message U M_SHOWPAGE ;
  336       proced ure WMSetF ocus(var M essage: TM essage);    message W M_SETFOCUS ;
  337       proced ure WMSysC ommand(var  Message:  TMessage);  message W M_SYSCOMMA ND;
  338       proced ure Update ECSParamet er(var Cmd Parameter:  string);
  339       functi on  ValidE CSUser: bo olean;
  340       proced ure StartC COWContext or;
  341       functi on  AllowC COWContext Change(var  CCOWRespo nse: UserR esponse; N ewDFN: str ing): bool ean;
  342       proced ure Update CCOWContex t;
  343       proced ure CheckH yperlinkRe sponse(aCo ntextItemC ollection:  IDispatch ; var Hype rlinkReaso n: string) ;
  344       proced ure CheckF orDifferen tPatient(a ContextIte mCollectio n: IDispat ch; var Pt Changed: b oolean);
  345   {$IFDEF CC OWBROKER}
  346       proced ure CheckF orDifferen tUser(aCon textItemCo llection:  IDispatch;  var UserC hanged: bo olean);
  347   {$ENDIF}
  348       proced ure HideEv erything(A Message: s tring = 'N o patient  is current ly selecte d.');
  349       proced ure ShowEv erything;
  350       functi on FindBes tCCOWDFN:  string;
  351       proced ure Handle CCOWError( AMessage:  string);
  352       proced ure SetUpN extButton;
  353       proced ure NextBu ttonClick( Sender: TO bject);
  354       proced ure NextBu ttonMouseD own(Sender : TObject;  Button: T MouseButto n;
  355         Shif t: TShiftS tate; X, Y : Integer) ;
  356       proced ure ModalE nd(Sender:  TObject);
  357     public
  358       Enduri ngPtSelSpl itterPos,  frmFrameHe ight, pnlP atientSele ctedHeight : integer;
  359       Enduri ngPtSelCol umns: stri ng;
  360       proced ure SetBAD xList;
  361       proced ure SetAct iveTab(Pag eID: Integ er);
  362       proced ure Refres hCWAD(Send er: TObjec t); // TDr ugs Patch  OR*3*377 a nd WV*1*24  - DanP@SL C 11-20-20 15
  363       proced ure Update VAAMHVButt ons(Sender : TObject) ; // TDrug s Patch OR *3*377 and  WV*1*24 -  DanP@SLC  01-02-2016
  364  
  365       functi on PageIDT oTab(PageI D: Integer ): Integer ;
  366       proced ure ShowHi deChartTab Menus(AMen uItem: TMe nuItem);
  367       proced ure Update PtInfoOnRe fresh;
  368       functi on  TabExi sts(ATabID : integer) : boolean;
  369       proced ure Displa yEncounter Text;
  370       functi on DLLActi ve: boolea n;
  371       proper ty ChangeS ource:     Integer re ad FChange Source;
  372       proper ty CCOWCon textChangi ng: Boolea n read FCC OWContextC hanging;
  373       proper ty CCOWDri vedChange:  Boolean   read FCCOW DrivedChan ge;
  374       proper ty CCOWBus y: Boolean     read F CCOWBusy   write FCCO WBusy;
  375       proper ty Context Changing:  Boolean re ad FContex tChanging;
  376       proper ty TimedOu t:         Boolean re ad GetTime dOut;
  377       proper ty Closing :          Boolean re ad FClosin g;
  378       proper ty OnTabCh anged:     TNotifyEve nt read FT abChanged  write FTab Changed;
  379       proper ty GraphFl oatActive:  boolean r ead FGraph FloatActiv e write FG raphFloatA ctive;
  380       proper ty GraphCo ntext: str ing read F GraphConte xt write F GraphConte xt;
  381       proced ure Toggle MenuItemCh ecked(Send er: TObjec t);
  382       proced ure SetUpC IRN;
  383       proper ty DoNotCh angeEncWin dow: boole an read FD oNotChange EncWindow  write FDoN otChangeEn cWindow;
  384       proper ty OrderPr intForm: b oolean rea d FOrderPr intForm wr ite FOrder PrintForm;
  385     end;
  386  
  387     TRpcReco rd = recor d
  388       RpcNam e: String;
  389       UCallL istIndex:  Integer;
  390       Result ListIndex:  Integer;
  391       Search Index: Int eger;
  392       RPCTex t: TString List;
  393       RPCRun Time: stri ng;
  394     end;
  395  
  396   var
  397     frmFrame : TfrmFram e;
  398     uTabList : TStringL ist;
  399     uLabRemo teType, uR emoteType,  uReportID , uLabRepI D : string ;
  400     FlaggedP TList: TSt ringList;
  401     ctxConte xtor : TCo ntextorCon trol;
  402     NextTab,  LastTab,  ChangingTa b: Integer ;
  403     uUseVist aWeb: bool ean;
  404     PTSwitch Refresh: b oolean = F alse;  //f lag for pa tient refr esh or swi tch of pat ients
  405     ProbTabC licked: bo olean = FA LSE;
  406     TabCtrlC licked: Bo olean = FA LSE;
  407     DEAConte xt: Boolea n = False;
  408     DelayRev iewChanges : Boolean  = False;
  409     WatchArr ay: Array  of TRpcRec ord;
  410  
  411   const
  412     PASSCODE  = '_gghwn 7pghCrOJvO V61PtPvgde EU2u5cRsGv pkVDjKT_H7 SdKE_hqFYW sUIVT1H7Jw T6Yz8oCtd2 u2PALqWxib NXx3Yo8GPc TYsNaxW' +  'ZFo8OgT1 1D5TIvpu3c DQuZd3Yh_n V9jhkvb0ZB GdO9n-uNXP PEK7xfYWCI 2Wp3Dsu9YD Sd_EM34nvr gy64cqu9_j FJKJnGiXY9 6Lf1ecLiv4 LT9qtmJ-Ba wYt7O9JZGA swi344BmmC bNxfgvgf0g fGZea';
  413     EM_SETZO OM = (WM_U SER + 225) ;
  414   implementa tion
  415  
  416   {$R *.DFM}
  417   {$R sBitma ps}
  418   {$R sRemSr ch}
  419  
  420   uses
  421     ORNet, r Core, fPtS elMsg, fPt Sel, fCove rSheet, fP robs, fMed s, fOrders , rOrders,  fNotes, f Consults,  fDCSumm,
  422     rMisc, C lipbrd, fL abs, fRepo rts, rRepo rts, fPtDe mo, fEncnt , fPtCWAD,  uCore, fA bout, fRev iew, fxBro ker,
  423     fxLists,  fxServer,  ORSystem,  fRptBox,  fSplash, r ODAllergy,  uInit, fL abTests, f LabInfo, u GlobalVar,
  424     uReminde rs, fRemin derTree, O RClasses,  fDeviceSel ect, fDraw ers, fRemi nderDialog , ShellAPI , rVitals,
  425     fOptions , fGraphs,  fGraphDat a, rTempla tes, fSurg ery, rSurg ery, uEven tHooks, uS ignItems,
  426     fDefault Event, rEC S, fIconLe gend, uOrd ers, fPtSe lOptns, Da teUtils, u Spell, uOr Ptf, fPati entFlagMul ti,
  427     fAlertFo rward, UBA Globals, f BAOptionsD iagnoses,  UBACore, f OrdersSign , uVitals,  fOrdersRe new, fMHTe st, uFormM onitor
  428     {$IFDEF  CCOWBROKER }
  429     , CCOW_c onst
  430     {$ENDIF}
  431     , VA508A ccessibili tyRouter,  fOtherSche dule, VAUt ils, uVA50 8CPRSCompa tibility,  fIVRoutes,
  432     fPrintLo cation, fT emplateEdi tor, fTemp lateDialog , fCombatV et, fFocus edControls ,
  433     fViewNot ifications , iCoverSh eetIntf, U _AVCatcher , System.I niFiles;
  434  
  435   var
  436     IsRunExe cuted: Boo lean = FAL SE;
  437     GraphFlo at: TfrmGr aphs;
  438  
  439   const
  440     FCP_UPDA TE  = 10;                                //  form crea te about t o check au to-update
  441     FCP_SETH OOK = 20;                                //  form crea te about t o set time out hooks
  442     FCP_SERV ER  = 30;                                //  form crea te about t o connect  to server
  443     FCP_CHKV ER  = 40;                                //  form crea te about t o check ve rsion
  444     FCP_OBJE CTS = 50;                                //  form crea te about t o create c ore object s
  445     FCP_FORM S   = 60;                                //  form crea te about t o create c hild forms
  446     FCP_PTSE L   = 70;                                //  form crea te about t o select p atient
  447     FCP_FINI SH  = 99;                                //  form crea te finishe d successf ully
  448  
  449     TX_IN_US E     = 'V istA CPRS  in use by:  ';     //  use same  as with CP RSInstance s in fTime out
  450     TX_OPTIO N     = 'O R CPRS GUI  CHART';
  451     TX_ECSOP T     = 'E C GUI CONT EXT';
  452     TX_PTINQ       = 'R etrieving  demographi c informat ion...';
  453     TX_NOTIF _STOP = 'S top proces sing notif ications?' ;
  454     TC_NOTIF _STOP = 'C urrently P rocessing  Notificati ons';
  455     TX_UNK_N OTIF  = 'U nable to p rocess the  follow up  action fo r this not ification' ;
  456     TC_UNK_N OTIF  = 'F ollow Up A ction Not  Implemente d';
  457     TX_NO_SU RG_NOTIF =  'This not ification  must be pr ocessed us ing the Su rgery tab,  ' + CRLF  +
  458                          'which is  not curre ntly avail able to yo u.';
  459     TC_NO_SU RG_NOTIF =  'Surgery  Tab Not Av ailable';
  460     TX_VER1        = 'T his is ver sion ';
  461     TX_VER2        = '  of CPRSCha rt.exe.';
  462     TX_VER3        = CR LF + 'The  running se rver versi on is ';
  463     TX_VER_R EQ    = '  version se rver is re quired.';
  464     TX_VER_O LD    = CR LF + 'It i s strongly  recommend ed that yo u upgrade. ';
  465     TX_VER_O LD2   = CR LF + 'The  program ca nnot be ru n until th e client i s upgraded .';
  466     TX_VER_N EW    = CR LF + 'The  program ca nnot be ru n until th e server i s upgraded .';
  467     TC_VER         = 'S erver/Clie nt Incompa tibility';
  468     TC_CLIER R     = 'C lient Spec ifications  Mismatch' ;
  469  
  470     SHOW_NOT IFICATIONS  = True;
  471  
  472     TC_DGSR_ ERR    = ' Remote Dat a Error';
  473     TC_DGSR_ SHOW   = ' Restricted  Remote Re cord';
  474     TC_DGSR_ DENY   = ' Remote Acc ess Denied ';
  475     TX_DGSR_ YESNO  = C RLF + 'Do  you want t o continue  accessing  this remo te patient  record?';
  476  
  477     TX_CCOW_ LINKED   =  'Clinical  Link On';
  478     TX_CCOW_ CHANGING =  'Clinical  link chan ging';
  479     TX_CCOW_ BROKEN   =  'Clinical  link brok en';
  480     TX_CCOW_ ERROR    =  'CPRS was  unable to  communica te with th e CCOW Con text Vault ' + CRLF +
  481                          'CCOW pat ient synch ronization  will be u navailable  for the r emainder o f this ses sion.';
  482     TC_CCOW_ ERROR    =  'CCOW Err or';
  483  
  484   function T frmFrame.T imeoutCond ition: boo lean;
  485   begin
  486     Result : = (FCreate Progress <  FCP_PTSEL );
  487   end;
  488  
  489   function T frmFrame.G etTimedOut : boolean;
  490   begin
  491     Result : = uInit.Ti medOut;
  492   end;
  493  
  494   procedure  TfrmFrame. TimeOutAct ion;
  495   var
  496     ClosingC PRS: boole an;
  497  
  498     procedur e CloseCPR S;
  499     begin
  500       if Clo singCPRS t hen
  501         halt ;
  502       try
  503         Clos ingCPRS :=  TRUE;
  504         Clos e;
  505       except
  506         halt ;
  507       end;
  508     end;
  509  
  510   begin
  511     ClosingC PRS := FAL SE;
  512     try
  513       if ass igned(frmO therSchedu le) then f rmOtherSch edule.Clos e;
  514       if ass igned (frm IVRoutes)  then frmIV Routes.Clo se;
  515       if frm Frame.DLLA ctive then
  516       begin
  517          Clo seVitalsDL L();
  518          Clo seMHDLL();
  519       end;
  520       CloseC PRS;
  521     except
  522       CloseC PRS;
  523     end;
  524   end;
  525  
  526   { General  Functions  and Proced ures }
  527  
  528  
  529  
  530   procedure  TfrmFrame. AppExcepti on(Sender:  TObject;  E: Excepti on);
  531   const
  532    XWB_M_REJ ECT = 2000 0 + 2; //  M error
  533   var
  534     AnAddr:  Pointer;
  535     ErrMsg:  string;
  536  
  537   begin
  538     Applicat ion.Normal izeTopMost s;
  539     if (E is  EIntError ) then
  540     begin
  541       ErrMsg  := E.Mess age + CRLF  +
  542                  'Creat eProgress:  ' + IntTo Str(FCreat eProgress)  + CRLF +
  543                  'RPC I nfo: ' + R PCLastCall ;
  544       if EEx ternal(E). ExceptionR ecord <> n il then
  545       begin
  546         AnAd dr := EExt ernal(E).E xceptionRe cord^.Exce ptionAddre ss;
  547         ErrM sg := ErrM sg + CRLF  + 'Address  was ' + I ntToStr(In teger(AnAd dr));
  548       end;
  549       //Pass  this mess age up
  550       E.Mess age := Err Msg;
  551     end;
  552  
  553     if (E is  EBrokerEr ror) or (E  is EOleEx ception) t hen
  554     begin
  555       FCreat eProgress  := FCP_FOR MS;
  556  
  557        //Opt ion for cu stom actio n
  558        {
  559        if (E  is EBroke rError) th en
  560        begin
  561          if  EBrokerErr or(E).Code  = XWB_M_R EJECT then
  562          beg in
  563           Ex ceptionLog .CustomBut tonCaption  := 'Debug ';
  564           Ex ceptionLog .OnCustomM ethod := m nuDebugRep ortClick;
  565          end ;
  566        end;
  567        }
  568  
  569       //Tell  the excep tion logge r that we  can't cont inue
  570       Except ionLog.Ter minateApp  := true;
  571     end;
  572     Applicat ion.Restor eTopMosts;
  573   end;
  574  
  575   procedure  TfrmFrame. btnCombatV etClick(Se nder: TObj ect);
  576   begin
  577     inherite d;
  578     frmComba tVet := Tf rmCombatVe t.Create(f rmFrame);
  579     frmComba tVet.ShowM odal;
  580     frmComba tVet.Free;
  581   end;
  582  
  583   function T frmFrame.A llowContex tChangeAll (var Reaso n: string) : Boolean;
  584   var
  585     Silent:  Boolean;
  586   begin
  587     if pnlNo PatientSel ected.Visi ble then
  588     begin
  589       Result  := True;
  590       exit;
  591     end;
  592     FContext Changing : = True;
  593     Result : = True;
  594     if COMOb jectActive  or SpellC heckInProg ress or DL LActive th en
  595       begin
  596         Reas on := 'COM _OBJECT_AC TIVE';
  597         Resu lt:= False ;
  598       end;
  599     // frmCo verSheet w ill always  AllowCont extChange
  600     if Resul t then Res ult := frm Problems.A llowContex tChange(Re ason);
  601     if Resul t then Res ult := frm Meds.Allow ContextCha nge(Reason );
  602     if Resul t then Res ult := frm Orders.All owContextC hange(Reas on);
  603     if Resul t then Res ult := frm Notes.Allo wContextCh ange(Reaso n);
  604     if Resul t then Res ult := frm Consults.A llowContex tChange(Re ason);
  605     if Resul t then Res ult := frm DCSumm.All owContextC hange(Reas on);
  606     if Resul t then
  607       if Ass igned(frmS urgery) th en Result  := frmSurg ery.AllowC ontextChan ge(Reason) ;;
  608     if Resul t then Res ult := frm Labs.Allow ContextCha nge(Reason );;
  609     if Resul t then Res ult := frm Reports.Al lowContext Change(Rea son);
  610     if Resul t then Res ult := frm GraphData. AllowConte xtChange(R eason);
  611     if (not  User.IsRep ortsOnly)  then
  612       if Res ult and Ch anges.Requ ireReview  then //Res ult := Rev iewChanges (TimedOut) ;
  613         case  BOOLCHAR[ FCCOWConte xtChanging ] of
  614           '1 ': begin
  615                   if Ch anges.Requ ireReview  then
  616                     beg in
  617                       R eason := ' Items will  be left u nsigned.';
  618                       R esult := F alse;
  619                     end
  620                   else
  621                     Res ult := Tru e;
  622                 end;
  623           '0 ': begin
  624                   Silen t := (Time dOut) or ( Reason = ' COMMIT');
  625                   Resul t := Revie wChanges(S ilent);
  626                 end;
  627         end;
  628     FContext Changing : = False;
  629   end;
  630  
  631   // TDrugs  Patch OR*3 *377 and W V*1*24 - D anP@SLC 11 -20-2015
  632   // Added s o the cove rsheet had  a quick w ay to upda te.
  633   procedure  TfrmFrame. RefreshCWA D(Sender:  TObject);
  634   begin
  635     lblPtCWA D.Caption  := GetCWAD Info(Patie nt.DFN);
  636     if Lengt h(lblPtCWA D.Caption)  > 0 then
  637       lblPtP ostings.Ca ption := ' Postings'
  638     else
  639       lblPtP ostings.Ca ption := ' No Posting s';
  640     pnlPosti ngs.Captio n := lblPt Postings.C aption + '  ' + lblPt CWAD.Capti on;
  641   end;
  642  
  643   procedure  TfrmFrame. ClearPatie nt;
  644   { call all  pages to  make sure  patient re lated info rmation is  cleared ( when switc hing patie nts) }
  645   var
  646     aCPRSTab : ICPRSTab ;
  647   begin
  648     //if frm Frame.Time dout then  Exit; // a dded to co rrect Acce ss Violati on when "R efresh Pat ient Infor mation" se lected
  649     lblPtNam e.Caption      := '';
  650     lblPtSSN .Caption       := '';
  651     lblPtAge .Caption       := '';
  652     pnlPatie nt.Caption     := '';
  653     lblPtCWA D.Caption      := '';
  654     if DoNot ChangeEncW indow = fa lse then
  655        begin
  656         lblP tLocation. Caption :=  'Visit No t Selected ';
  657         lblP tProvider. Caption :=  'Current  Provider N ot Selecte d';
  658         pnlV isit.Capti on      :=  lblPtLoca tion.Capti on + CRLF  + lblPtPro vider.Capt ion;
  659        end;
  660     lblPtCar e.Caption      := 'Pr imary Care  Team Unas signed';
  661     lblPtAtt ending.Cap tion := '' ;
  662     lblPtMHT C.Caption  := '';
  663     pnlPrima ryCare.Cap tion := lb lPtCare.Ca ption + '  ' + lblPtA ttending.C aption + '  ' + lblPt MHTC.Capti on;
  664     if Suppo rts(frmCov erSheet, I CPRSTab, a CPRSTab) t hen
  665       aCPRST ab.OnClear PtData(Sel f);
  666     frmProbl ems.ClearP tData;
  667     frmMeds. ClearPtDat a;
  668     frmOrder s.ClearPtD ata;
  669     frmNotes .ClearPtDa ta;
  670     frmConsu lts.ClearP tData;
  671     frmDCSum m.ClearPtD ata;
  672     if Assig ned(frmSur gery) then  frmSurger y.ClearPtD ata;
  673     frmLabs. ClearPtDat a;
  674     frmGraph Data.Clear PtData;
  675     frmRepor ts.ClearPt Data;
  676     tabPage. TabIndex : = PageIDTo Tab(CT_NOP AGE);        // to ma ke sure Di splayPage  gets calle d
  677     tabPageC hange(tabP age);
  678     ClearRem inderData;
  679     SigItems .Clear;
  680     Changes. Clear;
  681     lstCIRNL ocations.C lear;
  682     ClearFla g;
  683     if Assig ned(FlagLi st) then F lagList.Cl ear;
  684     HasFlag  := False;
  685     HidePati entSelectM essages;
  686     if (Grap hFloat <>  nil) and G raphFloatA ctive then
  687     with Gra phFloat do
  688     begin
  689       Initia lize;
  690       Displa yData('top ');
  691       Displa yData('bot tom');
  692       Captio n := 'CPRS  Graphing  - Patient:  ' + Mixed Case(Patie nt.Name);
  693     end;
  694     if frmFr ame.TimedO ut then
  695     begin
  696       infoBo x('CPRS ha s encounte red a seri ous proble m and is u nable to d isplay the  selected  patient''s  data. '
  697                + 'To pr event pati ent safety  issues, C PRS is shu tting down . Shutting  down and  then resta rting CPRS  will corr ect the pr oblem, and  you may c ontinue wo rking in C PRS.'
  698                 + CRLF  + CRLF + ' Please rep ort all oc currences  of this pr oblem by c ontacting  your CPRS  Help Desk. ', 'CPRS E rror', MB_ OK);
  699       frmFra me.Close;
  700     end;
  701   end;
  702  
  703   procedure  TfrmFrame. DigitalSig ningSetup1 Click(Send er: TObjec t);
  704   var
  705     aPKIEncr yptionEngi ne: IPKIEn cryptionEn gine;
  706     aMessage , successM sg: string ;
  707   begin
  708     inherite d;
  709     try
  710       //get  PKI engine  component s ready
  711       NewPKI Encryption Engine(RPC BrokerV, a PKIEncrypt ionEngine) ;
  712       CallV( 'ORDEA LNK MSG', []);
  713       succes sMsg := RP CBrokerV.R esults.Tex t;
  714       if not  IsDigital SignatureA vailable(a PKIEncrypt ionEngine,  AMessage,  successMs g) then
  715         Show Msg('There  was a pro blem linki ng your PI V card. Ei ther the '
  716         + 'P IV card na me does NO T match yo ur VistA a ccount nam e or the P IV card is  already '
  717         + 'l inked to a nother Vis tA account .  Ensure  that the c orrect PIV  card has  '
  718         + 'b een insert ed for you r VistA ac count. Ple ase contac t your PIV  Card Coor dinator '
  719         + 'i f you cont inue to ha ve problem s.');
  720     except
  721       on E:  Exception  do
  722         Show Msg('Probl em during  digital si gning setu p: '+ E.Me ssage);
  723     end;
  724   end;
  725  
  726   procedure  TfrmFrame. DisplayEnc ounterText ;
  727   { updates  the displa y in the h eader bar  of encount er related  informati on (locati on & provi der) }
  728   begin
  729     if DoNot ChangeEncW indow = tr ue then ex it;
  730     with Enc ounter do
  731     begin
  732       if Len gth(Locati onText) >  0
  733         then  lblPtLoca tion.Capti on := Loca tionText
  734         else  lblPtLoca tion.Capti on := 'Vis it Not Sel ected';
  735       if Len gth(Provid erName) >  0
  736         then  lblPtProv ider.Capti on := 'Pro vider:  '  + Provider Name
  737         else  lblPtProv ider.Capti on := 'Cur rent Provi der Not Se lected';
  738     end;
  739     pnlVisit .Caption : = lblPtLoc ation.Capt ion + CRLF  + lblPtPr ovider.Cap tion;
  740     FitToolB ar;
  741   end;
  742  
  743   function T frmFrame.D LLActive:  boolean;
  744   begin
  745     Result : = (VitalsD LLHandle < > 0) or (M HDLLHandle  <> 0);
  746   end;
  747  
  748   { Form Eve nts (Creat e, Destroy ) -------- ---------- ---------- ---------- ---------- ---------- - }
  749  
  750  
  751   procedure  TfrmFrame. RefreshFix edStatusWi dth;
  752   begin
  753     with sts Area do
  754       FFixed StatusWidt h := Panel s[0].Width  + Panels[ 2].Width +  Panels[3] .Width + P anels[4].W idth;
  755   end;
  756  
  757   procedure  TfrmFrame. FormCreate (Sender: T Object);
  758   { connect  to server,  create ta b pages, s elect a pa tient, & i nitialize  core objec ts }
  759   var
  760     ClientVe r, ServerV er, Server Req, SAN:  string;
  761  
  762     Procedur e LoadExce ptionLogge r;
  763     var
  764      TmpLst:  TStringLi st;
  765      TmpStr:  String;
  766     begin
  767       TmpLst  := TStrin gList.Crea te;
  768       try
  769       Except ionLog.Day sToPurge : = StrToInt Def(GetUse rParam('OR  CPRS EXCE PTION PURG E'), 60);
  770       Except ionLog.Ena bled := St rToBoolDef (GetUserPa ram('OR CP RS EXCEPTI ON LOGGER' ), false);
  771       GetUse rListParam (TmpLst, ' OR CPRS EX CEPTION EM AIL');
  772       for Tm pStr in Tm pLst do
  773        Excep tionLog.Em ailTo.Add( Piece(TmpS tr, U, 2)) ;
  774       Except ionLog.OnA ppExceptio n := AppEx ception;
  775       finall y
  776         TmpL st.Free;
  777       end;
  778     end;
  779  
  780   begin
  781     FJustEnt eredApp :=  false;
  782     SizeHold er := TSiz eHolder.Cr eate;
  783     FOldActi veFormChan ge := Scre en.OnActiv eFormChang e;
  784     Screen.O nActiveFor mChange :=  ScreenAct iveFormCha nge;
  785     FCCOWJus tJoined :=  False;
  786     if not ( ParamSearc h('CCOW')= 'DISABLE')  then
  787       try
  788         Star tCCOWConte xtor;
  789         FCCO WJustJoine d := True;
  790       except
  791         IsRu nExecuted  := False;
  792         FCCO WInstalled  := False;
  793         pnlC COW.Visibl e := False ;
  794         mnuF ileResumeC ontext.Vis ible := Fa lse;
  795         mnuF ileBreakCo ntext.Visi ble := Fal se;
  796       end
  797     else
  798       begin
  799         IsRu nExecuted  := False;
  800         FCCO WInstalled  := False;
  801         pnlC COW.Visibl e := False ;
  802         mnuF ileResumeC ontext.Vis ible := Fa lse;
  803         mnuF ileBreakCo ntext.Visi ble := Fal se;
  804       end;
  805  
  806     RefreshF ixedStatus Width;
  807     FTermina te := Fals e;
  808  
  809     FFlagLis t := TStri ngList.Cre ate;
  810  
  811     // setup  initial t imeout her e so can t imeout log on
  812     FCreateP rogress :=  FCP_SETHO OK;
  813     InitTime Out(Timeou tCondition , TimeOutA ction);
  814  
  815     // conne ct to the  server and  create an  option co ntext
  816     FCreateP rogress :=  FCP_SERVE R;
  817  
  818   {$IFDEF CC OWBROKER}
  819     EnsureBr oker;
  820     if ctxCo ntextor <>  nil then
  821     begin
  822       if Par amSearch(' CCOW') = ' PATIENTONL Y' then
  823         RPCB rokerV.Con textor :=  nil
  824       else
  825         RPCB rokerV.Con textor :=  ctxContext or;
  826     end
  827     else
  828       RPCBro kerV.Conte xtor := ni l;
  829   {$ENDIF}
  830  
  831     if not C onnectToSe rver(TX_OP TION) then
  832     begin
  833       if Ass igned(RPCB rokerV) th en
  834         Info Box(RPCBro kerV.RPCBE rror, 'Err or', MB_OK  or MB_ICO NERROR);
  835       Close;
  836       Exit;
  837     end;
  838  
  839     if ctxCo ntextor <>  nil then
  840     begin
  841       if not  (ParamSea rch('CCOW' ) = 'PATIE NTONLY') t hen
  842         ctxC ontextor.N otificatio nFilter :=  ctxContex tor.Notifi cationFilt er + ';Use r';
  843     end;
  844  
  845     FECSAuth User := Va lidECSUser ;
  846     uECSRepo rt := TECS Report.Cre ate;
  847     uECSRepo rt.ECSPerm it := FECS AuthUser;
  848     RPCBroke rV.CreateC ontext(TX_ OPTION);
  849    // Applic ation.OnEx ception :=  AppExcept ion;
  850     LoadExce ptionLogge r;
  851     FOldActi vate := Ap plication. OnActivate ;
  852     Applicat ion.OnActi vate := Ap pActivated ;
  853     Applicat ion.OnDeAc tivate :=  AppDeActiv ated;
  854  
  855     // creat e initial  core objec ts
  856     FCreateP rogress :=  FCP_OBJEC TS;
  857     User :=  TUser.Crea te;
  858  
  859     // make  sure we're  using the  matching  server ver sion
  860     FCreateP rogress :=  FCP_CHKVE R;
  861     ClientVe r := Clien tVersion(A pplication .ExeName);
  862     ServerVe r := Serve rVersion(T X_OPTION,  ClientVer) ;
  863     if (Serv erVer = '0 .0.0.0') t hen
  864     begin
  865       InfoBo x('Unable  to determi ne current  version o f server.' , TX_OPTIO N, MB_OK);
  866       Close;
  867       Exit;
  868     end;
  869     ServerRe q := Piece (FileVersi onValue(Ap plication. ExeName, F ILE_VER_IN TERNALNAME ), ' ', 1) ;
  870     if (Clie ntVer <> S erverReq)  then
  871     begin
  872       InfoBo x('Client  "version"  does not m atch clien t "require d" server. ', TC_CLIE RR, MB_OK) ;
  873       Close;
  874       Exit;
  875     end;
  876     SAN := s CallV('XUS  PKI GET U PN', []);
  877     if SAN=' ' then Dig italSignin gSetup1.Vi sible := T rue
  878     else Dig italSignin gSetup1.Vi sible := F alse;
  879     if (Comp areVersion (ServerVer , ServerRe q) <> 0) t hen
  880     begin
  881       if (sC allV('ORWU  DEFAULT D IVISION',  [nil]) = ' 1') then
  882       begin
  883         if ( InfoBox('P roceed wit h mismatch ed Client  and Server  versions? ', TC_CLIE RR, MB_YES NO) = ID_N O) then
  884         begi n
  885           Cl ose;
  886           Ex it;
  887         end;
  888       end
  889       else
  890       begin
  891         if ( CompareVer sion(Serve rVer, Serv erReq) > 0 ) then //  Server new er than Re quired
  892         begi n
  893           //  NEXT LINE  COMMENTED  OUT - CHA NGED FOR V ERSION 19. 16, PATCH  OR*3*155:
  894           //       if G etUserPara m('ORWOR R EQUIRE CUR RENT CLIEN T') = '1'  then
  895           if  (true) th en // "Tru e" stateme nt guarant ees "requi red" curre nt version  client.
  896           be gin
  897              InfoBox(TX _VER1 + Cl ientVer +  TX_VER2 +  CRLF + Ser verReq + T X_VER_REQ  + TX_VER3  + ServerVe r + '.' +  TX_VER_OLD 2, TC_VER,  MB_OK);
  898              Close;
  899              Exit;
  900           en d;
  901         end
  902         else  InfoBox(T X_VER1 + C lientVer +  TX_VER2 +  CRLF + Se rverReq +  TX_VER_REQ  + TX_VER3  + ServerV er + '.' +  TX_VER_OL D, TC_VER,  MB_OK);
  903       end;
  904       if (Co mpareVersi on(ServerV er, Server Req) < 0)  then // Se rver older  then Requ ired
  905       begin
  906         Info Box(TX_VER 1 + Client Ver + TX_V ER2 + CRLF  + ServerR eq + TX_VE R_REQ + TX _VER3 + Se rverVer +  '.' + TX_V ER_NEW, TC _VER, MB_O K);
  907         Clos e;
  908         Exit ;
  909       end;
  910     end;
  911  
  912     // Add f uture tabs  here as t hey are cr eated/impl emented:
  913     if (
  914        (not  User.HasCo rTabs) and
  915        (not  User.HasRp tTab)
  916        )
  917     then
  918     begin
  919       InfoBo x('No vali d tabs ass igned', 'T ab Access  Problem',  MB_OK);
  920       Close;
  921       Exit;
  922     end;
  923     // Globa l flags se t by serve r
  924     IsLeJeun eActive :=  ServerHas Patch(Camp LejeunePat ch);
  925     SpansInt lDateLine  := SiteSpa nsIntlDate Line;
  926  
  927     // creat e creating  core obje cts
  928     Patient  := TPatien t.Create;
  929     Encounte r := TEnco unter.Crea te;
  930     Changes  := TChange s.Create;
  931     Notifica tions := T Notificati ons.Create ;
  932     RemoteSi tes := TRe moteSiteLi st.Create;
  933     RemoteRe ports := T RemoteRepo rtList.Cre ate;
  934     uTabList  := TStrin gList.Crea te;
  935     FlaggedP TList := T StringList .Create;
  936     HasFlag   := False;
  937     FlagList  := TStrin gList.Crea te;
  938     // set u p structur es specifi c to the u ser
  939     Caption  := TX_IN_U SE + Mixed Case(User. Name) + '   (' + Stri ng(RPCBrok erV.Server ) + ')';
  940     SetDebug Menu;
  941     if Inter activeRemi ndersActiv e then
  942       Notify WhenRemind ersChange( RemindersC hanged);
  943     // load  all the ta b pages
  944     FCreateP rogress :=  FCP_FORMS ;
  945     //Create Tab(TObjec t(frmProbl ems), Tfrm Problems,  CT_PROBLEM S, 'Proble ms');
  946     CreateTa b(CT_PROBL EMS, 'Prob lems');
  947     CreateTa b(CT_MEDS,      'Meds ');
  948     CreateTa b(CT_ORDER S,   'Orde rs');
  949     CreateTa b(CT_NOTES ,    'Note s');
  950     CreateTa b(CT_CONSU LTS, 'Cons ults');
  951     if ShowS urgeryTab  then Creat eTab(CT_SU RGERY,  'S urgery');
  952     CreateTa b(CT_DCSUM M,   'D/C  Summ');
  953     CreateTa b(CT_LABS,      'Labs ');
  954     CreateTa b(CT_REPOR TS,  'Repo rts');
  955     CreateTa b(CT_COVER ,    'Cove r Sheet');
  956     ShowHide ChartTabMe nus(mnuVie wChart);
  957     //  We d efer calli ng LoadUse rPreferenc es to UMIn itiate, so  that the  font sizin g
  958     // routi nes recogn ize this a s the appl ication's  main form  (this hasn 't been
  959     // set y et).
  960     FNextBut tonBitmap  := TBitmap .Create;
  961     FNextBut tonBitmap. LoadFromRe sourceName (hInstance , 'BMP_HAN DRIGHT');
  962     // set t he timeout  to DTIME  now that t here is a  connection
  963     UpdateTi meOutInter val(User.D TIME * 100 0);  // DT IME * 1000  mSec
  964     // get a  patient
  965     HandleNe eded;                                 // ma ke sure ha ndle is th ere for OR WPT SHARE  call
  966     FCreateP rogress :=  FCP_PTSEL ;
  967     Enabled  := False;
  968     FFirstLo ad := True ;                         // Fir st time to  initializ e the fFra me
  969     FCreateP rogress :=  FCP_FINIS H;
  970     pnlRemin ders.Visib le := Inte ractiveRem indersActi ve;
  971     GraphFlo atActive : = false;
  972     GraphCon text := '' ;
  973     frmGraph Data := Tf rmGraphDat a.Create(s elf);         // form  is only v isible for  testing
  974     GraphDat aOnUser;
  975     uRemoteT ype := '';
  976     uLabRemo teType :=  '';
  977     uReportI D := '';
  978     uLabRepI D := '';
  979     FPrevPtI D := '';
  980     SetUserT ools;
  981     Enduring PtSelSplit terPos :=  0;
  982     Enduring PtSelColum ns := '';
  983     if User. IsReportsO nly then / / Reports  Only tab.
  984       Report sOnlyDispl ay; // Cal ls procedu re to hide  all compo nents/menu s not need ed.
  985     InitialO rderVariab les;
  986  
  987     PostMess age(Handle , UM_INITI ATE, 0, 0) ;    // se lect patie nt after m ain form i s created
  988     SetFormM onitoring( true);
  989     //Will l oad the co py/paste b uffer
  990     CPAppMon .LoadTheBu ffer;
  991     CPAppMon .LoadThePr operties;
  992   end;
  993  
  994   procedure  TfrmFrame. StartCCOWC ontextor;
  995   begin
  996     try
  997       ctxCon textor :=  TContextor Control.Cr eate(Self) ;
  998       with c txContexto r do
  999         begi n
  1000           On Pending :=  ctxContex torPending ;
  1001           On Committed  := ctxCont extorCommi tted;
  1002           On Canceled : = ctxConte xtorCancel ed;
  1003         end;
  1004       FCCOWB usy := Fal se;
  1005       FCCOWI nstalled : = True;
  1006       FCCOWD rivedChang e := False ;
  1007       ctxCon textor.Run ('CPRSChar t', '', TR UE, 'Patie nt');
  1008       IsRunE xecuted :=  True;
  1009     except
  1010       on exc  : EOleExc eption do
  1011       begin
  1012         IsRu nExecuted  := False;
  1013         Free AndNil(ctx Contextor) ;
  1014         try
  1015           ct xContextor  := TConte xtorContro l.Create(S elf);
  1016           wi th ctxCont extor do
  1017              begin
  1018                OnPendin g := ctxCo ntextorPen ding;
  1019                OnCommit ted := ctx ContextorC ommitted;
  1020                OnCancel ed := ctxC ontextorCa nceled;
  1021              end;
  1022           FC COWBusy :=  False;
  1023           FC COWInstall ed := True ;
  1024           FC COWDrivedC hange := F alse;
  1025           ct xContextor .Run('CPRS Chart' + ' #', '', TR UE, 'Patie nt');
  1026           Is RunExecute d := True;
  1027           if  ParamSear ch('CCOW')  = 'FORCE'  then
  1028           be gin
  1029              mnuFileRes umeContext .Enabled : = False;
  1030              mnuFileBre akContext. Visible :=  True;
  1031              mnuFileBre akContext. Enabled :=  True;
  1032           en d
  1033           el se
  1034           be gin
  1035              ctxContext or.Suspend ;
  1036              mnuFileRes umeContext .Visible : = True;
  1037              mnuFileBre akContext. Visible :=  True;
  1038              mnuFileBre akContext. Enabled :=  False;
  1039           en d;
  1040         exce pt
  1041           Is RunExecute d := False ;
  1042           FC COWInstall ed := Fals e;
  1043           Fr eeAndNil(c txContexto r);
  1044           pn lCCOW.Visi ble := Fal se;
  1045           mn uFileResum eContext.V isible :=  False;
  1046           mn uFileBreak Context.Vi sible := F alse;
  1047         end;
  1048       end;
  1049     end
  1050   end;
  1051  
  1052   procedure  TfrmFrame. UMInitiate (var Messa ge: TMessa ge);
  1053   begin
  1054     NotifyOt herApps(NA E_OPEN, In tToStr(Use r.DUZ));
  1055     LoadUser Preference s;
  1056     GetBASta tus(User.D UZ,Patient .DFN);
  1057     mnuFileO penClick(S elf);
  1058     Enabled  := True;
  1059     // If Ti medOut, Cl ose has al ready been  called.
  1060     if not T imedOut an d (Patient .DFN = '')  then Clos e;
  1061   end;
  1062  
  1063   procedure  TfrmFrame. FormDestro y(Sender:  TObject);
  1064   { free cor e objects  used by CP RS }
  1065   Var
  1066    I:integer ;
  1067   begin
  1068     Applicat ion.OnActi vate := FO ldActivate ;
  1069     Screen.O nActiveFor mChange :=  FOldActiv eFormChang e;
  1070     FNextBut tonBitmap. Free;
  1071     if FNext Button <>  nil then F NextButton .Free;
  1072     uTabList .Free;
  1073     FlaggedP TList.Free ;
  1074     RemoteSi tes.Free;
  1075     RemoteRe ports.Free ;
  1076     Notifica tions.Free ;
  1077     Changes. Free;
  1078     Encounte r.Free;
  1079     Patient. Free;
  1080     User.Fre e;
  1081     SizeHold er.Free;
  1082     ctxConte xtor.Free;
  1083     frmDebug Report.Fre e;
  1084  
  1085     for I :=  high(Watc hArray) do wnto low(W atchArray)  do
  1086       WatchA rray[I].RP CText.Free ;
  1087     SetLengt h(WatchArr ay, 0);
  1088   end;
  1089  
  1090   procedure  TfrmFrame. ModalEnd(S ender: TOb ject);
  1091   begin
  1092     Halt;
  1093   end;
  1094  
  1095   procedure  TfrmFrame. FormCloseQ uery(Sende r: TObject ; var CanC lose: Bool ean);
  1096   { cancels  close if t he user ca ncels the  ReviewChan ges screen  }
  1097   var
  1098     Reason:  string;
  1099     I: integ er;
  1100     SystemMo dal: Boole an;
  1101   begin
  1102    //check f or modal w indows and  close any  that may  exist
  1103    if Applic ation.Moda lLevel > 0  then
  1104    begin
  1105     SystemMo dal := tru e;
  1106     // Scree n.ActiveFo rm.Close() ;
  1107     for i :=  Screen.Fo rmCount -  1 downto 1  do begin
  1108      if (fsM odal in Sc reen.Forms [i].FormSt ate) and ( Screen.For ms[i] <> A pplication .MainForm)  then
  1109      begin
  1110        Scree n.Forms[i] .Close();
  1111        Syste mModal :=  False;
  1112      end;
  1113     end;
  1114  
  1115     if Syste mModal the n
  1116      Applica tion.OnMod alEnd := M odalEnd;
  1117    end;
  1118  
  1119     if (FCre ateProgres s < FCP_FI NISH) then  Exit;
  1120     if User. IsReportsO nly then / / Reports  Only tab.
  1121       exit;
  1122     if Timed Out then
  1123       begin
  1124         if C hanges.Req uireReview  then Revi ewChanges( TimedOut);
  1125         Exit ;
  1126       end;
  1127     if not A llowContex tChangeAll (Reason) t hen CanClo se := Fals e;
  1128   end;
  1129  
  1130   procedure  TfrmFrame. SetUserToo ls;
  1131   var
  1132     item, pa rent: TToo lMenuItem;
  1133     ok: bool ean;
  1134     index, i , idx, cou nt: Intege r;
  1135     UserTool : TMenuIte m;
  1136     Menus: T StringList ;
  1137   begin
  1138     if User. IsReportsO nly then / / Reports  Only tab.
  1139     begin
  1140       mnuToo ls.Clear;  // Remove  all curren t items.
  1141       UserTo ol := TMen uItem.Crea te(Self);
  1142       UserTo ol.Caption  := 'Optio ns...';
  1143       UserTo ol.Hint :=  'Options' ;
  1144       UserTo ol.OnClick  := mnuToo lsOptionsC lick;
  1145       mnuToo ls.Add(Use rTool); //  Add back  the "Optio ns" menu.
  1146       exit;
  1147     end;
  1148     if User. GECStatus  then
  1149     begin
  1150       UserTo ol := TMen uItem.Crea te(self);
  1151       UserTo ol.Caption  := 'GEC R eferral St atus Displ ay';
  1152       UserTo ol.Hint :=  'GEC Refe rral Statu s Display' ;
  1153       UserTo ol.OnClick  := mnuGEC StatusClic k;
  1154       mnuToo ls.Add(Use rTool); //  Add back  the "Optio ns" menu.
  1155     end;
  1156     GetToolM enu; // Fo r all othe r users, p roceed nor mally with  creation  of Tools m enu:
  1157     for i :=  uToolMenu Items.Coun t-1 downto  0 do
  1158     begin
  1159       item : = TToolMen uItem(uToo lMenuItems [i]);
  1160       if (An siCompareT ext(item.C aption, 'E vent Captu re Interfa ce') = 0 )  and
  1161          (no t uECSRepo rt.ECSPerm it) then
  1162       begin
  1163         uToo lMenuItems .Delete(i) ;
  1164         Brea k;
  1165       end;
  1166     end;
  1167     Menus :=  TStringLi st.Create;
  1168     try
  1169       count  := 0;
  1170       idx :=  0;
  1171       index  := 0;
  1172       while  count < uT oolMenuIte ms.Count d o
  1173       begin
  1174         for  I := 0 to  uToolMenuI tems.Count  - 1 do
  1175         begi n
  1176           it em := TToo lMenuItem( uToolMenuI tems[i]);
  1177           if  assigned( item.MenuI tem) then  continue;
  1178           if  item.SubM enuID = ''  then
  1179              ok := True
  1180           el se
  1181           be gin
  1182              idx := Men us.IndexOf (item.SubM enuID);
  1183              ok := (idx  >= 0);
  1184           en d;
  1185           if  ok then
  1186           be gin
  1187              inc(count) ;
  1188              UserTool : = TMenuIte m.Create(S elf);
  1189              UserTool.C aption :=  Item.Capti on;
  1190              if Item.Ac tion <> ''  then
  1191              begin
  1192                UserTool .Hint := I tem.Action ;
  1193                UserTool .OnClick : = ToolClic k;
  1194              end;
  1195              Item.MenuI tem := Use rTool;
  1196              if item.Su bMenuID =  '' then
  1197              begin
  1198                mnuTools .Insert(In dex,UserTo ol);
  1199                inc(Inde x);
  1200              end
  1201              else
  1202              begin
  1203                parent : = TToolMen uItem(Menu s.Objects[ idx]);
  1204                parent.M enuItem.Ad d(UserTool );
  1205              end;
  1206              if item.Me nuID <> ''  then
  1207                Menus.Ad dObject(it em.MenuID,  item);
  1208           en d;
  1209         end;
  1210       end;
  1211     finally
  1212       Menus. Free;
  1213     end;
  1214     FreeAndN il(uToolMe nuItems);
  1215   end;
  1216  
  1217   procedure  TfrmFrame. UpdateECSP arameter(v ar CmdPara meter: str ing);  //E CS
  1218   var
  1219     vstID,Ac cVer,Svr,S vrPort,VUs er: string ;
  1220   begin
  1221     AccVer   := '';
  1222     Svr      := '';
  1223     SvrPort  := '';
  1224     VUser    := '';
  1225     if RPCBr okerV <> n il then
  1226     begin
  1227       AccVer   := Strin g(RPCBroke rV.AccessV erifyCodes );
  1228       Svr      := Strin g(RPCBroke rV.Server) ;
  1229       SvrPor t := IntTo Str(RPCBro kerV.Liste nerPort);
  1230       VUser    := RPCBr okerV.User .DUZ;
  1231     end;
  1232     vstID :=  GetVisitI D;
  1233     CmdParam eter :=' S vr=' +Svr
  1234                     +'  SvrPort='+ SvrPort
  1235                     +'  VUser='+ V User
  1236                     +'  PtIEN='+ P atient.DFN
  1237                     +'  PdIEN='+In tToStr(Enc ounter.Pro vider)
  1238                     +'  vstIEN='+v stID
  1239                     +'  locIEN='+I ntToStr(En counter.Lo cation)
  1240                     +'  Date=0'
  1241                     +'  Division=' +GetDivisi onID;
  1242  
  1243   end;
  1244  
  1245   procedure  TfrmFrame. compAccess TabPageCap tionQuery( Sender: TO bject;
  1246     var Text : string);
  1247   begin
  1248     Text :=  GetTabText ;
  1249   end;
  1250  
  1251   function T frmFrame.V alidECSUse r: boolean ;   //ECS
  1252   var
  1253     isTrue:  boolean;
  1254   begin
  1255     Result : = True;
  1256     with RPC BrokerV do
  1257     begin
  1258       ShowEr rorMsgs :=  semQuiet;
  1259       Connec ted     :=  True;
  1260      try
  1261         isTr ue := Crea teContext( TX_ECSOPT) ;
  1262         if n ot isTrue  then
  1263           Re sult := Fa lse;
  1264         Show ErrorMsgs  := semRais e;
  1265       except
  1266         on E : Exceptio n do
  1267         begi n
  1268           Sh owErrorMsg s := semRa ise;
  1269           Re sult := Fa lse;
  1270         end;
  1271       end;
  1272     end;
  1273   end;
  1274  
  1275   procedure  TfrmFrame. FormClose( Sender: TO bject; var  Action: T CloseActio n);
  1276   begin
  1277     FClosing  := TRUE;
  1278     SetFormM onitoring( false);
  1279     If Assig ned(Patien t) then
  1280      CPAppMo n.SaveTheB uffer; //s ave the bu ffer
  1281  
  1282  
  1283     if FCrea teProgress  < FCP_FIN ISH then F Terminate  := True;
  1284  
  1285     FlushNot ifierBuffe r;
  1286     if FCrea teProgress  = FCP_FIN ISH then N otifyOther Apps(NAE_C LOSE, '');
  1287     Terminat eOtherAppN otificatio n;
  1288  
  1289     if Graph Float <> n il then
  1290     begin
  1291       if frm Frame.Grap hFloatActi ve then
  1292         Grap hFloat.Clo se;
  1293       GraphF loat.Relea se;
  1294     end;
  1295  
  1296     // unhoo k the time out hooks
  1297     ShutDown TimeOut;
  1298     // clear ing change s will unl ock notes
  1299     if FCrea teProgress  = FCP_FIN ISH then C hanges.Cle ar;
  1300     // clear  server si de flag gl obal tmp
  1301     if FCrea teProgress  = FCP_FIN ISH then C learFlag;
  1302     // save  user prefe rences
  1303     if FCrea teProgress  = FCP_FIN ISH then S aveUserPre ferences;
  1304     // call  close for  each page  in case th ere is any  special p rocessing
  1305     if FCrea teProgress  > FCP_FOR MS then
  1306     begin
  1307       mnuFra me.Merge(n il);
  1308       frmCov erSheet.Cl ose;
  1309       frmPro blems.Clos e;   //frm Problems.R elease;
  1310       frmMed s.Close;        //frm Meds.Relea se;
  1311       frmOrd ers.Close;      //frm Orders.Rel ease;
  1312       frmNot es.Close;       //frm Notes.Rele ase;
  1313       frmCon sults.Clos e;   //frm Consults.R elease;
  1314       frmDCS umm.Close;      //frm DCSumm.Rel ease;
  1315       if Ass igned(frmS urgery) th en frmSurg ery.Close;     //frmS urgery.Rel ease;
  1316       frmLab s.Close;        //frm Labs.Relea se;
  1317       frmRep orts.Close ;    //frm Reports.Re lease;
  1318       frmGra phData.Clo se;  //frm GraphData. Release;
  1319  
  1320     end;
  1321     // if <  FCP_FINISH  we came h ere from i nside Form Create, so  need to c all termin ate
  1322     if FCrea teProgress  < FCP_FIN ISH then A pplication .Terminate ;
  1323   end;
  1324  
  1325   procedure  TfrmFrame. SetDebugMe nu;
  1326   var
  1327     IsProgra mmer: Bool ean;
  1328   begin
  1329     IsProgra mmer := Us er.HasKey( 'XUPROGMOD E') or (Sh owRPCList  = True);
  1330     mnuHelpB roker.Visi ble   := I sProgramme r;
  1331     mnuHelpL ists.Visib le    := I sProgramme r;
  1332     mnuHelpS ymbols.Vis ible  := I sProgramme r;
  1333     mnuFocus Changes.Vi sible := I sProgramme r;  {added  10 May 20 12  dlp se e fFocusCo ntrols }
  1334     Z6.Visib le               := I sProgramme r;
  1335   end;
  1336  
  1337   { Updates  posted to  MainForm - ---------- ---------- ---------- ---------- ---------- ---------- -- }
  1338  
  1339   procedure  TfrmFrame. UMNewOrder (var Messa ge: TMessa ge);
  1340   { post a n otice of c hange in o rders to a ll TPages,  wParam=Or derAction,  lParam=TO rder }
  1341   var
  1342     OrderAct : string;
  1343   begin
  1344     with Mes sage do
  1345     begin
  1346       CoverS heet.OnRef reshPanel( Self, CV_C PRS_ALLG);
  1347       CoverS heet.OnRef reshPanel( Self, CV_C PRS_POST);
  1348       frmPro blems.Noti fyOrder(WP aram, TOrd er(LParam) );
  1349       frmMed s.NotifyOr der(WParam , TOrder(L Param));
  1350       frmOrd ers.Notify Order(WPar am, TOrder (LParam));
  1351       frmNot es.NotifyO rder(WPara m, TOrder( LParam));
  1352       frmCon sults.Noti fyOrder(WP aram, TOrd er(LParam) );
  1353       frmDCS umm.Notify Order(WPar am, TOrder (LParam));
  1354       if Ass igned(frmS urgery) th en frmSurg ery.Notify Order(WPar am, TOrder (LParam));
  1355       frmLab s.NotifyOr der(WParam , TOrder(L Param));
  1356       frmRep orts.Notif yOrder(WPa ram, TOrde r(LParam)) ;
  1357       lblPtC WAD.Captio n := GetCW ADInfo(Pat ient.DFN);
  1358       if Len gth(lblPtC WAD.Captio n) > 0 the n
  1359         lblP tPostings. Caption :=  'Postings '
  1360       else
  1361         lblP tPostings. Caption :=  'No Posti ngs';
  1362       pnlPos tings.Capt ion := lbl PtPostings .Caption +  ' ' + lbl PtCWAD.Cap tion;
  1363       OrderA ct := '';
  1364       case W Param of
  1365         ORDE R_NEW:   O rderAct :=  'NW';
  1366         ORDE R_DC:    O rderAct :=  'DC';
  1367         ORDE R_RENEW: O rderAct :=  'RN';
  1368         ORDE R_HOLD:  O rderAct :=  'HD';
  1369         ORDE R_EDIT:  O rderAct :=  'XX';
  1370         ORDE R_ACT:   O rderAct :=  'AC';
  1371       end;
  1372       if Len gth(OrderA ct) > 0 th en NotifyO therApps(N AE_ORDER,  OrderAct +  U + TOrde r(LParam). ID);  // a dd FillerI D
  1373     end;
  1374   end;
  1375  
  1376   { Tab Sele ction (nav igate betw een pages)  --------- ---------- ---------- ---------- ---------- -- }
  1377  
  1378   procedure  TfrmFrame. WMSetFocus (var Messa ge: TMessa ge);
  1379   var
  1380     aCPRS508 : ICPRS508 ;
  1381   begin
  1382     if (FLas tPage <> n il) and (n ot TimedOu t) and
  1383        (not  (csDestroy ing in FLa stPage.Com ponentStat e)) and FL astPage.Vi sible then
  1384        if FL astPage.In heritsFrom (TfrmPage)  then
  1385          Tfr mPage(FLas tPage).Foc usFirstCon trol
  1386        else  if Support s(fLastPag e, ICPRS50 8, aCPRS50 8) then
  1387          aCP RS508.OnFo cusFirstCo ntrol(Self );
  1388   end;
  1389  
  1390   procedure  TfrmFrame. UMShowPage (var Messa ge: TMessa ge);
  1391   { shows a  page when  the UM_SHO WPAGE mess age is rec eived }
  1392   var
  1393     aCPRSTab : ICPRSTab ;
  1394   begin
  1395     if FCCOW DrivedChan ge then FC COWDrivedC hange := F alse;
  1396  
  1397     if FLast Page <> ni l then
  1398       if FLa stPage.Inh eritsFrom( TfrmPage)  then
  1399         Tfrm Page(FLast Page).Disp layPage
  1400       else i f Supports (fLastPage , ICPRSTab , aCPRSTab ) then
  1401         aCPR STab.OnDis playPage(S elf, CC_CL ICK);
  1402  
  1403     FChangeS ource := C C_CLICK;   // reset t o click so  we're onl y dealing  with excep tions to c lick
  1404     if assig ned(FTabCh anged) the n
  1405       FTabCh anged(Self );
  1406   end;
  1407  
  1408   procedure  TfrmFrame. SwitchToPa ge(NewForm : TForm);
  1409   { unmerge/ merge menu s, bring p age to top  of z-orde r, call fo rm-specifi c OnDispla y code }
  1410   begin
  1411     if FLast Page = New Form then
  1412       begin
  1413         if N otificatio ns.Active  and Assign ed(NewForm ) then Pos tMessage(H andle, UM_ SHOWPAGE,  0, 0);
  1414         Exit ;
  1415       end;
  1416     if (FLas tPage <> n il) then
  1417     begin
  1418       mnuFra me.Unmerge (FLastPage .Menu);
  1419       FLastP age.Hide;
  1420     end;
  1421     if Assig ned(NewFor m) then be gin
  1422       mnuFra me.Merge(N ewForm.Men u);
  1423       NewFor m.Show;
  1424     end;
  1425     lstCIRNL ocations.V isible :=  False;
  1426     pnlCIRN. BevelOuter  := bvRais ed;
  1427     lstCIRNL ocations.S endToBack;
  1428     mnuFileP rint.Enabl ed := Fals e;            // let  individual  page enab le this
  1429     mnuFileP rintSetup. Enabled :=  False;       // let  individual  page enab le this
  1430     mnuFileP rintSelect edItems.En abled := F alse;
  1431     FLastPag e := NewFo rm;
  1432     if NewFo rm <> nil  then
  1433     begin
  1434       if New Form.Name  = frmNotes .Name then  frmNotes. Align := a lClient
  1435         else  frmNotes. Align := a lNone;
  1436       if New Form.Name  = frmConsu lts.Name t hen frmCon sults.Alig n := alCli ent
  1437         else  frmConsul ts.Align : = alNone;
  1438       if New Form.Name  = frmRepor ts.Name th en frmRepo rts.Align  := alClien t
  1439         else  frmReport s.Align :=  alNone;
  1440       if New Form.Name  = frmDCSum m.Name the n frmDCSum m.Align :=  alClient
  1441         else  frmDCSumm .Align :=  alNone;
  1442       if Ass igned(frmS urgery) th en
  1443         if N ewForm.Nam e = frmSur gery.Name  then frmSu rgery.Alig n := alcli ent
  1444           el se frmSurg ery.Align  := alNone;
  1445       NewFor m.BringToF ront;                      // to  cause tab  switch to  happen im mediately
  1446       Applic ation.Proc essMessage s;
  1447       PostMe ssage(Hand le, UM_SHO WPAGE, 0,  0);  // th is calls D isplayPage  for the f orm
  1448     end;
  1449   end;
  1450  
  1451   procedure  TfrmFrame. mnuDebugRe portClick( Sender: TO bject);
  1452   begin
  1453     inherite d;
  1454     if not A ssigned(fr mDebugRepo rt) then f rmDebugRep ort := Tfr mDebugRepo rt.Create( self);
  1455      frmDebu gReport.Sh ow;
  1456   end;
  1457  
  1458   procedure  TfrmFrame. mnuChartTa bClick(Sen der: TObje ct);
  1459   { use the  Tag proper ty of the  menu item  to switch  to proper  page }
  1460   begin
  1461     with Sen der as TMe nuItem do  tabPage.Ta bIndex :=  PageIDToTa b(Tag);
  1462     LastTab  := TabToPa geID(tabPa ge.TabInde x) ;
  1463     tabPageC hange(tabP age);
  1464   end;
  1465  
  1466   procedure  TfrmFrame. tabPageCha nge(Sender : TObject) ;
  1467   { switches  to form l inked to N ewTab }
  1468   var
  1469     PageID :  integer;
  1470   begin
  1471     PageID : = TabToPag eID((sende r as TTabC ontrol).Ta bIndex);
  1472     if (Page ID <> CT_N OPAGE) and  (TabPage. CanFocus)  and Assign ed(FLastPa ge) and
  1473        (not  TabPage.Fo cused) the n
  1474       TabPag e.SetFocus ;  //CQ: 1 4854
  1475     if (not  User.IsRep ortsOnly)  then
  1476     begin
  1477       case P ageID of
  1478         CT_N OPAGE:   S witchToPag e(nil);
  1479         CT_C OVER:    S witchToPag e(frmCover Sheet);
  1480         CT_P ROBLEMS: S witchToPag e(frmProbl ems);
  1481         CT_M EDS:     S witchToPag e(frmMeds) ;
  1482         CT_O RDERS:   S witchToPag e(frmOrder s);
  1483         CT_N OTES:    S witchToPag e(frmNotes );
  1484         CT_C ONSULTS: S witchToPag e(frmConsu lts);
  1485         CT_D CSUMM:   S witchToPag e(frmDCSum m);
  1486         CT_S URGERY:  S witchToPag e(frmSurge ry);
  1487         CT_L ABS:     S witchToPag e(frmLabs) ;
  1488         CT_R EPORTS:  S witchToPag e(frmRepor ts);
  1489       end; { case}
  1490     end
  1491     else //  Reports On ly tab.
  1492       Switch ToPage(frm Reports);
  1493     if Scree nReaderSys temActive  and FCtrlT abUsed the n
  1494       SpeakP atient;
  1495     Changing Tab := Pag eID;
  1496   end;
  1497  
  1498   function T frmFrame.P ageIDToTab (PageID: I nteger): I nteger;
  1499   { returns  the tab in dex that c orresponds  to a give n PageID }
  1500   VAR
  1501     i: integ er;
  1502   begin
  1503     i :=  uT abList.Ind exOf(IntTo Str(PageID ));
  1504     Result : = i;
  1505   end;
  1506  
  1507   function T frmFrame.T abToPageID (Tab: Inte ger): Inte ger;
  1508   { returns  the consta nt that id entifies t he page gi ven a TabI ndex }
  1509   begin
  1510     if (Tab  > -1) and  (Tab < uTa bList.Coun t) then
  1511       Result  := StrToI ntDef(uTab List[Tab],  CT_UNKNOW N)
  1512     else
  1513       Result  := CT_NOP AGE;
  1514   end;
  1515  
  1516   { File Men u Events - ---------- ---------- ---------- ---------- ---------- ---------- ---------- -- }
  1517  
  1518   procedure  TfrmFrame. SetupPatie nt(AFlagge dList : TS tringList) ;
  1519   var
  1520     AMsg, Se lectMsg: s tring;
  1521   begin
  1522     with Pat ient do
  1523     begin
  1524       ClearP atient;  / / must be  called to  avoid leav ing previo us patient 's informa tion visib le!
  1525       btnCom batVet.Cap tion := 'C V '+ Comba tVet.Expir ationDate;
  1526       btnCom batVet.Vis ible := Pa tient.Comb atVet.IsEl igible;
  1527       Visibl e := True;
  1528       Applic ation.Proc essMessage s;
  1529       lblPtN ame.Captio n := Name  + Status;  //CQ #1749 1: Allow f or the dis play of th e patient  status ind icator in  header bar .
  1530       lblPtS SN.Caption  := SSN;
  1531       lblPtA ge.Caption  := Format FMDateTime ('mmm dd,y yyy', DOB)  + ' (' +  IntToStr(A ge) + ')';
  1532       pnlPat ient.Capti on := lblP tName.Capt ion + ' '  + lblPtSSN .Caption +  ' ' + lbl PtAge.Capt ion;
  1533       if Len gth(CWAD)  > 0
  1534         then  lblPtPost ings.Capti on := 'Pos tings'
  1535         else  lblPtPost ings.Capti on := 'No  Postings';
  1536       lblPtC WAD.Captio n := CWAD;
  1537       pnlPos tings.Capt ion := lbl PtPostings .Caption +  ' ' + lbl PtCWAD.Cap tion;
  1538       if (Le ngth(Prima ryTeam) >  0) or (Len gth(Primar yProvider)  > 0) then  begin
  1539         lblP tCare.Capt ion := Pri maryTeam;
  1540         if P rimaryProv ider <> ''  then lblP tCare.Capt ion := lbl PtCare.Cap tion + ' /  ' + Mixed Case(Prima ryProvider );
  1541         if L ength(Asso ciate)>0 t hen lblPtC are.Captio n :=  lblP tCare.Capt ion + ' /  ' + MixedC ase(Associ ate);
  1542       end;
  1543       if Len gth(Attend ing) > 0 t hen lblPtA ttending.C aption :=  '(Inpatien t) Attendi ng:  ' + M ixedCase(A ttending);
  1544       pnlPri maryCare.C aption :=  lblPtCare. Caption +  ' ' + lblP tAttending .Caption;
  1545       if Len gth(InProv ider) > 0   then lblP tAttending .Caption : = lblPtAtt ending.Cap tion + ' -  (Inpatien t) Provide r: ' + Mix edCase(InP rovider);
  1546       if Len gth(MHTC)  > 0 then l blPtMHTC.C aption :=  'MH Treatm ent Coordi nator: ' +  MixedCase (MHTC);
  1547       if (Le ngth(MHTC)  = 0) and  (Inpatient  = True) a nd (Specia ltySvc = ' P') then
  1548         lblP tMHTC.Capt ion := 'MH  Treatment  Coordinat or Unassig ned';
  1549       pnlPri maryCare.C aption :=  lblPtCare. Caption +  ' ' + lblP tAttending .Caption +  ' ' + lbl PtMHTC.Cap tion;
  1550       SetUpC IRN;
  1551       Displa yEncounter Text;
  1552       SetSha reNode(DFN , Handle);
  1553       with P atient do
  1554         Noti fyOtherApp s(NAE_NEWP T, SSN + U  + FloatTo Str(DOB) +  U + Name) ;
  1555       Select Msg := '';
  1556       if Mea nsTestRequ ired(Patie nt.DFN, AM sg) then S electMsg : = AMsg;
  1557       if Has LegacyData (Patient.D FN, AMsg)      then S electMsg : = SelectMs g + CRLF +  AMsg;
  1558  
  1559       HasAct iveFlg(Fla gList, Has Flag, Pati ent.DFN);
  1560       if Has Flag then  begin
  1561         txtC mdFlags.Vi sible := f alse;
  1562         pnlF lag.Enable d := True;
  1563         lblF lag.Font.C olor := Ge t508Compli antColor(c lMaroon);
  1564         lblF lag.Enable d := True;
  1565         if ( not FReFre shing) and  (TriggerP RFPopUp(Pa tient.DFN) ) then
  1566           Sh owFlags;
  1567       end el se begin
  1568         txtC mdFlags.Vi sible := S creenReade rSystemAct ive;
  1569         pnlF lag.Enable d := False ;
  1570         lblF lag.Font.C olor := cl BtnFace;
  1571         lblF lag.Enable d := False ;
  1572       end;
  1573       FPrevP tID := pat ient.DFN;
  1574       { frmC over.Updat eVAAButton ; //VAA CQ 7525  (mov ed here in  v26.30 (R V))}
  1575       Update VAAMHVButt ons(nil);
  1576       Proces sPatientCh angeEventH ook;
  1577       if Len gth(Select Msg) > 0 t hen ShowPa tientSelec tMessages( SelectMsg) ;
  1578     end;
  1579   end;
  1580  
  1581   procedure  TfrmFrame. mnuFileNex tClick(Sen der: TObje ct);
  1582   var
  1583     SaveDFN,  NewDFN: s tring; //  *DFN*
  1584     NextInde x: Integer ;
  1585     Reason:  string;
  1586     CCOWResp onse: User Response;
  1587     AccessSt atus: inte ger;
  1588  
  1589       proced ure Update PatientInf oForAlert;
  1590       begin
  1591         if P atient.Inp atient the n begin
  1592           En counter.In patient :=  True;
  1593           En counter.Lo cation :=  Patient.Lo cation;
  1594           En counter.Da teTime :=  Patient.Ad mitTime;
  1595           En counter.Vi sitCategor y := 'H';
  1596         end;
  1597         if U ser.IsProv ider then  Encounter. Provider : = User.DUZ ;
  1598         Setu pPatient(F laggedPTLi st);
  1599         if ( FlaggedPTL ist.IndexO f(Patient. DFN) < 0)  then
  1600           Fl aggedPTLis t.Add(Pati ent.DFN);
  1601       end;
  1602  
  1603   begin
  1604     DoNotCha ngeEncWind ow := Fals e;
  1605     OrderPri ntForm :=  False;
  1606     mnuFile. Tag := 0;
  1607     SaveDFN  := Patient .DFN;
  1608     Notifica tions.Next ;
  1609     if Notif ications.A ctive then
  1610     begin
  1611       NewDFN  := Notifi cations.DF N;
  1612       if Sav eDFN <> Ne wDFN then
  1613       begin
  1614         // n ewdfn does  not have  new patien t.co infor mation for  CCOW call
  1615         if ( (Sender =  mnuFileOpe n) or (All owContextC hangeAll(R eason)))
  1616              and AllowA ccessToSen sitivePati ent(NewDFN , AccessSt atus) then
  1617         begi n
  1618           Re mindersSta rted := FA LSE;
  1619           Pa tient.DFN  := NewDFN;
  1620           En counter.Cl ear;
  1621           Ch anges.Clea r;
  1622           if  Assigned( FlagList)  then
  1623           be gin
  1624            F lagList.Cl ear;
  1625            H asFlag :=  False;
  1626            H asActiveFl g(FlagList , HasFlag,  NewDFN);
  1627           en d;
  1628           if  FCCOWInst alled and  (ctxContex tor.State  = csPartic ipating) t hen
  1629              begin
  1630                if (Allo wCCOWConte xtChange(C COWRespons e, Patient .DFN)) the n
  1631                  Update PatientInf oForAlert
  1632                else
  1633                  begin
  1634                    case  CCOWRespo nse of
  1635                      ur Cancel:
  1636                         begin
  1637                           Patient. DFN := Sav eDFN;
  1638                           Notifica tions.Prio r;
  1639                           Exit;
  1640                         end;
  1641                      ur Break:
  1642                         begin
  1643                           // do no t revert t o old DFN  if context  was manua lly broken  by user -  v26 (RV)
  1644                           if (ctxC ontextor.S tate = csP articipati ng) then P atient.DFN  := SaveDF N;
  1645                           UpdatePa tientInfoF orAlert;
  1646                         end;
  1647                      el se
  1648                         UpdatePati entInfoFor Alert;
  1649                    end;
  1650                  end;
  1651              end
  1652           el se
  1653              UpdatePati entInfoFor Alert
  1654         end  else
  1655         begi n
  1656           if  AccessSta tus in [DG SR_ASK, DG SR_DENY] t hen
  1657           be gin
  1658              Notificati ons.Clear;
  1659              // hide th e 'next no tification ' button
  1660              FNextButto nActive :=  False;
  1661              FNextButto n.Free;
  1662              FNextButto n := nil;
  1663              mnuFileNex t.Enabled  := False;
  1664              mnuFileNot ifRemove.E nabled :=  False;
  1665              Patient.DF N := '';
  1666              mnuFileOpe nClick(mnu FileNext);
  1667              exit;
  1668           en d
  1669           el se
  1670           if  SaveDFN < > '' then
  1671           be gin
  1672              Patient.DF N := SaveD FN;
  1673              Notificati ons.Prior;
  1674              Exit;
  1675           en d
  1676           el se
  1677           be gin
  1678              Notificati ons.Clear;
  1679              Patient.DF N := '';
  1680              mnuFileOpe nClick(mnu FileNext);
  1681              exit;
  1682           en d;
  1683         end;
  1684       end;
  1685       stsAre a.Panels.I tems[1].Te xt := Noti fications. Text;
  1686       FChang eSource :=  CC_NOTIFI CATION;
  1687       NextIn dex := Pag eIDToTab(C T_COVER);
  1688       tabPag e.TabIndex  := CT_NOP AGE;
  1689       tabPag eChange(ta bPage);
  1690       mnuFil eNotifRemo ve.Enabled  := Notifi cations.Fo llowup in  [NF_FLAGGE D_ORDERS,
  1691                                                                      NF_ORDER_ REQUIRES_E LEC_SIGNAT URE,
  1692                                                                      NF_MEDICA TIONS_EXPI RING_INPT,
  1693                                                                      NF_MEDICA TIONS_EXPI RING_OUTPT ,
  1694                                                                      NF_UNVERI FIED_MEDIC ATION_ORDE R,
  1695                                                                      NF_UNVERI FIED_ORDER ,
  1696                                                                      NF_FLAGGE D_OI_EXP_I NPT,
  1697                                                                      NF_FLAGGE D_OI_EXP_O UTPT];
  1698       case N otificatio ns.FollowU p of
  1699         NF_L AB_RESULTS                     :  NextIndex  := PageID ToTab(CT_L ABS);
  1700         NF_F LAGGED_ORD ERS                 :  NextIndex  := PageID ToTab(CT_O RDERS);
  1701         NF_O RDER_REQUI RES_ELEC_S IGNATURE :  NextIndex  := PageID ToTab(CT_O RDERS);
  1702         NF_A BNORMAL_LA B_RESULTS           :  NextIndex  := PageID ToTab(CT_L ABS);
  1703         NF_I MAGING_RES ULTS                :  NextIndex  := PageID ToTab(CT_R EPORTS);
  1704         NF_C ONSULT_REQ UEST_RESOL UTION    :  NextIndex  := PageID ToTab(CT_C ONSULTS);
  1705         NF_A BNORMAL_IM AGING_RESU LTS      :  NextIndex  := PageID ToTab(CT_R EPORTS);
  1706         NF_I MAGING_REQ UEST_CANCE L_HELD   :  NextIndex  := PageID ToTab(CT_O RDERS);
  1707         NF_N EW_SERVICE _CONSULT_R EQUEST   :  NextIndex  := PageID ToTab(CT_C ONSULTS);
  1708         NF_C ONSULT_REQ UEST_CANCE L_HOLD   :  NextIndex  := PageID ToTab(CT_C ONSULTS);
  1709         NF_S ITE_FLAGGE D_RESULTS           :  NextIndex  := PageID ToTab(CT_O RDERS);
  1710         NF_O RDERER_FLA GGED_RESUL TS       :  NextIndex  := PageID ToTab(CT_O RDERS);
  1711         NF_O RDER_REQUI RES_COSIGN ATURE    :  NextIndex  := PageID ToTab(CT_O RDERS);
  1712         NF_L AB_ORDER_C ANCELED             :  NextIndex  := PageID ToTab(CT_O RDERS);
  1713         NF_S TAT_RESULT S                   :
  1714           if  Piece(Pie ce(Notific ations.Ale rtData, '| ', 2), '@' , 2) = 'LR CH' then
  1715              NextIndex  := PageIDT oTab(CT_LA BS)
  1716           el se if Piec e(Piece(No tification s.AlertDat a, '|', 2) , '@', 2)  = 'GMRC' t hen
  1717              NextIndex  := PageIDT oTab(CT_CO NSULTS)
  1718           el se if Piec e(Piece(No tification s.AlertDat a, '|', 2) , '@', 2)  = 'RA' the n
  1719              NextIndex  := PageIDT oTab(CT_RE PORTS);
  1720         NF_D NR_EXPIRIN G                   :  NextIndex  := PageID ToTab(CT_O RDERS);
  1721         NF_M EDICATIONS _EXPIRING_ INPT     :  NextIndex  := PageID ToTab(CT_O RDERS);
  1722         NF_M EDICATIONS _EXPIRING_ OUTPT    :  NextIndex  := PageID ToTab(CT_O RDERS);
  1723         NF_U NVERIFIED_ MEDICATION _ORDER   :  NextIndex  := PageID ToTab(CT_O RDERS);
  1724         NF_R X_RENEWAL_ REQUEST             :
  1725           be gin
  1726              if (Notifi cations.Al ertData =  '') then
  1727              begin
  1728                Notifica tions.Dele te;
  1729              end;
  1730              NextIndex  := PageIDT oTab(CT_OR DERS);
  1731           en d;
  1732         NF_L APSED_ORDE R                   :  NextIndex  := PageID ToTab(CT_O RDERS);
  1733         NF_H IRISK_ORDE R                   :  NextIndex  := PageID ToTab(CT_O RDERS);
  1734         NF_N EW_ORDER                       :  NextIndex  := PageID ToTab(CT_O RDERS);
  1735         NF_I MAGING_RES ULTS_AMEND ED       :  NextIndex  := PageID ToTab(CT_R EPORTS);
  1736         NF_C RITICAL_LA B_RESULTS           :  NextIndex  := PageID ToTab(CT_L ABS);
  1737         NF_U NVERIFIED_ ORDER               :  NextIndex  := PageID ToTab(CT_O RDERS);
  1738         NF_F LAGGED_OI_ RESULTS             :  NextIndex  := PageID ToTab(CT_O RDERS);
  1739         NF_F LAGGED_OI_ ORDER               :  NextIndex  := PageID ToTab(CT_O RDERS);
  1740         NF_D C_ORDER                        :  NextIndex  := PageID ToTab(CT_O RDERS);
  1741         NF_D EA_AUTO_DC _CS_MED_OR DER      :  NextIndex  := PageID ToTab(CT_O RDERS);
  1742         NF_D EA_CERT_RE VOKED               :  NextIndex  := PageID ToTab(CT_O RDERS);
  1743         NF_C ONSULT_UNS IGNED_NOTE          :  NextIndex  := PageID ToTab(CT_C ONSULTS);
  1744         NF_D CSUMM_UNSI GNED_NOTE           :  NextIndex  := PageID ToTab(CT_D CSUMM);
  1745         NF_N OTES_UNSIG NED_NOTE            :  NextIndex  := PageID ToTab(CT_N OTES);
  1746         NF_C ONSULT_REQ UEST_UPDAT ED       :  NextIndex  := PageID ToTab(CT_C ONSULTS);
  1747         NF_F LAGGED_OI_ EXP_INPT            :  NextIndex  := PageID ToTab(CT_O RDERS);
  1748         NF_F LAGGED_OI_ EXP_OUTPT           :  NextIndex  := PageID ToTab(CT_O RDERS);
  1749         NF_C ONSULT_PRO C_INTERPRE TATION   :  NextIndex  := PageID ToTab(CT_C ONSULTS);
  1750         NF_I MAGING_REQ UEST_CHANG ED       :
  1751           be gin
  1752              ReportBox( GetNotific ationFollo wUpText(Pa tient.DFN,  Notificat ions.Follo wUp, Notif ications.A lertData),  Pieces(Pi ece(Notifi cations.Re cordID, U,  1), ':',  2, 3), Tru e);
  1753              Notificati ons.Delete ;
  1754           en d;
  1755         NF_L AB_THRESHO LD_EXCEEDE D        :  NextIndex  := PageID ToTab(CT_L ABS);
  1756         NF_M AMMOGRAM_R ESULTS              :  NextIndex  := PageID ToTab(CT_R EPORTS);
  1757         NF_P AP_SMEAR_R ESULTS              :  NextIndex  := PageID ToTab(CT_R EPORTS);
  1758         NF_A NATOMIC_PA THOLOGY_RE SULTS    :  NextIndex  := PageID ToTab(CT_R EPORTS);
  1759         NF_S URGERY_UNS IGNED_NOTE          :  if TabExi sts(CT_SUR GERY) then
  1760                                                  NextInd ex := Page IDToTab(CT _SURGERY)
  1761                                                else
  1762                                                  InfoBox (TX_NO_SUR G_NOTIF, T C_NO_SURG_ NOTIF, MB_ OK);
  1763  
  1764       else
  1765       begin
  1766         if I sSmartAler t(Notifica tions.Foll owUp) then  NextIndex  := PageID ToTab(CT_N OTES)
  1767         else  InfoBox(T X_UNK_NOTI F, TC_UNK_ NOTIF, MB_ OK);
  1768       end;
  1769       end; / /case
  1770  
  1771       tabPag e.TabIndex  := NextIn dex;
  1772       tabPag eChange(ta bPage);
  1773  
  1774     end
  1775     else mnu FileOpenCl ick(mnuFil eNext); // case else
  1776   end;
  1777  
  1778   procedure  TfrmFrame. SetBADxLis t;
  1779   var
  1780     i: small int;
  1781   begin
  1782     if not A ssigned(UB AGlobals.t empDxList)  then
  1783        begin
  1784        UBAGl obals.temp DxList :=  TList.Crea te;
  1785        UBAGl obals.temp DxList.Cou nt := 0;
  1786        Appli cation.Pro cessMessag es;
  1787        end
  1788     else
  1789        begin
  1790        //Kil l the old  Dx list
  1791        for i  := 0 to p red(UBAGlo bals.tempD xList.Coun t) do
  1792           TO bject(UBAG lobals.tem pDxList[i] ).Free;
  1793  
  1794        UBAGl obals.temp DxList.Cle ar;
  1795        Appli cation.Pro cessMessag es;
  1796  
  1797        //Cre ate new Dx  list for  newly sele cted patie nt
  1798         if n ot Assigne d(UBAGloba ls.tempDxL ist) then
  1799            b egin
  1800            U BAGlobals. tempDxList  := TList. Create;
  1801            U BAGlobals. tempDxList .Count :=  0;
  1802            A pplication .ProcessMe ssages;
  1803            e nd;
  1804        end;
  1805   end;
  1806  
  1807   procedure  TfrmFrame. mnuFileOpe nClick(Sen der: TObje ct);
  1808   { select a  new patie nt & updat e the head er display s (patient  id, encou nter, post ings) }
  1809   var
  1810     SaveDFN,  Reason: s tring;
  1811     ok, OldR emindersSt arted, PtS elCancelle d: Boolean ;
  1812     CCOWResp onse: User Response;
  1813     ThisSess ionChanges : TChanges ;
  1814     i: Integ er;
  1815   begin
  1816     pnlPatie nt.Enabled  := FALSE;
  1817     if (Send er = mnuFi leOpen) or  (FRefresh ing) then
  1818       PTSwit chRefresh  := True
  1819     else
  1820       PTSwit chRefresh  := FALSE;  // part of  a change  to CQ #115 29
  1821     PtSelCan celled :=  FALSE;
  1822     if not F Refreshing  then
  1823       mnuFil e.Tag := 0
  1824     else
  1825       mnuFil e.Tag := 1 ;
  1826     Determin eNextTab;
  1827     // if Se nder <> mn uFileNext  then         //CQ 162 73 & 16419  - Missing  Review/Si gn Changes  dialog wh en clickin g 'Next' b utton.
  1828     ThisSess ionChanges  := TChang es.Create;
  1829     try
  1830       // Loo p through  and add in  the docum ents
  1831       for i  := 0 to Ch anges.Docu ments.Coun t - 1 do
  1832         begi n
  1833           Th isSessionC hanges.Add (CH_DOC,
  1834              TChangeIte m(Changes. Documents. Items[i]). ID,
  1835              TChangeIte m(Changes. Documents. Items[i]). Text,
  1836              TChangeIte m(Changes. Documents. Items[i]). GroupName,
  1837              TChangeIte m(Changes. Documents. Items[i]). SignState,
  1838              TChangeIte m(Changes. Documents. Items[i]). ParentID,
  1839              TChangeIte m(Changes. Documents. Items[i]). User,
  1840              TChangeIte m(Changes. Documents. Items[i]). OrderDG,
  1841              TChangeIte m(Changes. Documents. Items[i]). DCOrder,
  1842              TChangeIte m(Changes. Documents. Items[i]). Delay);
  1843         end;
  1844       // Loo p through  and add in  the order s
  1845       for i  := 0 to Ch anges.Orde rs.Count -  1 do
  1846         begi n
  1847           Th isSessionC hanges.Add (CH_ORD,
  1848              TChangeIte m(Changes. Orders.Ite ms[i]).ID,
  1849              TChangeIte m(Changes. Orders.Ite ms[i]).Tex t,
  1850              TChangeIte m(Changes. Orders.Ite ms[i]).Gro upName,
  1851              TChangeIte m(Changes. Orders.Ite ms[i]).Sig nState,
  1852              TChangeIte m(Changes. Orders.Ite ms[i]).Par entID,
  1853              TChangeIte m(Changes. Orders.Ite ms[i]).Use r,
  1854              TChangeIte m(Changes. Orders.Ite ms[i]).Ord erDG,
  1855              TChangeIte m(Changes. Orders.Ite ms[i]).DCO rder,
  1856              TChangeIte m(Changes. Orders.Ite ms[i]).Del ay);
  1857         end;
  1858       // Loo p through  and add in  PCE
  1859       for i  := 0 to Ch anges.PCE. Count - 1  do
  1860         begi n
  1861           Th isSessionC hanges.Add (CH_PCE,
  1862              TChangeIte m(Changes. PCE.Items[ i]).ID,
  1863              TChangeIte m(Changes. PCE.Items[ i]).Text,
  1864              TChangeIte m(Changes. PCE.Items[ i]).GroupN ame,
  1865              TChangeIte m(Changes. PCE.Items[ i]).SignSt ate,
  1866              TChangeIte m(Changes. PCE.Items[ i]).Parent ID,
  1867              TChangeIte m(Changes. PCE.Items[ i]).User,
  1868              TChangeIte m(Changes. PCE.Items[ i]).OrderD G,
  1869              TChangeIte m(Changes. PCE.Items[ i]).DCOrde r,
  1870              TChangeIte m(Changes. PCE.Items[ i]).Delay) ;
  1871         end;
  1872       if not  AllowCont extChangeA ll(Reason)  then
  1873         begi n
  1874           pn lPatient.E nabled :=  True;
  1875           //  If this i s cancelle d then rel oad this s essions ch anges.
  1876           Ch anges.Clea r;
  1877           //  Loop thro ugh and ad d in the d ocuments
  1878           fo r i := 0 t o ThisSess ionChanges .Documents .Count - 1  do
  1879              begin
  1880                Changes. Add(CH_DOC ,
  1881                  TChang eItem(This SessionCha nges.Docum ents.Items [i]).ID,
  1882                  TChang eItem(This SessionCha nges.Docum ents.Items [i]).Text,
  1883                  TChang eItem(This SessionCha nges.Docum ents.Items [i]).Group Name,
  1884                  TChang eItem(This SessionCha nges.Docum ents.Items [i]).SignS tate,
  1885                  TChang eItem(This SessionCha nges.Docum ents.Items [i]).Paren tID,
  1886                  TChang eItem(This SessionCha nges.Docum ents.Items [i]).User,
  1887                  TChang eItem(This SessionCha nges.Docum ents.Items [i]).Order DG,
  1888                  TChang eItem(This SessionCha nges.Docum ents.Items [i]).DCOrd er,
  1889                  TChang eItem(This SessionCha nges.Docum ents.Items [i]).Delay );
  1890              end;
  1891           //  Loop thro ugh and ad d in the o rders
  1892           fo r i := 0 t o ThisSess ionChanges .Orders.Co unt - 1 do
  1893              begin
  1894                Changes. Add(CH_ORD , TChangeI tem(ThisSe ssionChang es.Orders. Items[i]). ID,
  1895                  TChang eItem(This SessionCha nges.Order s.Items[i] ).Text,
  1896                  TChang eItem(This SessionCha nges.Order s.Items[i] ).GroupNam e,
  1897                  TChang eItem(This SessionCha nges.Order s.Items[i] ).SignStat e,
  1898                  TChang eItem(This SessionCha nges.Order s.Items[i] ).ParentID ,
  1899                  TChang eItem(This SessionCha nges.Order s.Items[i] ).User,
  1900                  TChang eItem(This SessionCha nges.Order s.Items[i] ).OrderDG,
  1901                  TChang eItem(This SessionCha nges.Order s.Items[i] ).DCOrder,
  1902                  TChang eItem(This SessionCha nges.Order s.Items[i] ).Delay);
  1903              end;
  1904           //  Loop thro ugh and ad d in PCE
  1905           fo r i := 0 t o ThisSess ionChanges .PCE.Count  - 1 do
  1906              begin
  1907                Changes. Add(CH_PCE , TChangeI tem(ThisSe ssionChang es.PCE.Ite ms[i]).ID,
  1908                  TChang eItem(This SessionCha nges.PCE.I tems[i]).T ext,
  1909                  TChang eItem(This SessionCha nges.PCE.I tems[i]).G roupName,
  1910                  TChang eItem(This SessionCha nges.PCE.I tems[i]).S ignState,
  1911                  TChang eItem(This SessionCha nges.PCE.I tems[i]).P arentID,
  1912                  TChang eItem(This SessionCha nges.PCE.I tems[i]).U ser,
  1913                  TChang eItem(This SessionCha nges.PCE.I tems[i]).O rderDG,
  1914                  TChang eItem(This SessionCha nges.PCE.I tems[i]).D COrder,
  1915                  TChang eItem(This SessionCha nges.PCE.I tems[i]).D elay);
  1916              end;
  1917           ex it;
  1918         end;
  1919     finally
  1920       ThisSe ssionChang es.Clear;
  1921       ThisSe ssionChang es.Free;
  1922     end;
  1923     // updat e status t ext here
  1924     stsArea. Panels.Ite ms[1].Text  := '';
  1925     if (not  User.IsRep ortsOnly)  then
  1926       begin
  1927         if n ot FRefres hing then
  1928           be gin
  1929              Notificati ons.Next;  // avoid p rompt if n o more ale rts select ed to proc ess  {v14a  RV}
  1930              if Notific ations.Act ive then
  1931                begin
  1932                  if (in foBox(TX_N OTIF_STOP,  TC_NOTIF_ STOP, MB_Y ESNO) = ID _NO) then
  1933                    begi n
  1934                      No tification s.Prior;
  1935                      pn lPatient.E nabled :=  True;
  1936                      ex it;
  1937                    end;
  1938                end;
  1939              if Notific ations.Act ive then
  1940                Notifica tions.Prio r;
  1941           en d;
  1942       end;
  1943  
  1944     if FNoPa tientSelec ted then
  1945       SaveDF N := ''
  1946     else
  1947       SaveDF N := Patie nt.DFN;
  1948  
  1949     OldRemin dersStarte d := Remin dersStarte d;
  1950     Reminder sStarted : = FALSE;
  1951     try
  1952       if FRe freshing t hen
  1953         begi n
  1954           Up datePtInfo OnRefresh;
  1955           ok  := True;
  1956         end
  1957       else
  1958         begi n
  1959           ok  := FALSE;
  1960           if  (not User .IsReports Only) then
  1961              begin
  1962                if FCCOW Installed  and (ctxCo ntextor.St ate = csPa rticipatin g) then
  1963                  begin
  1964                    Upda teCCOWCont ext;
  1965                    if n ot FCCOWEr ror then
  1966                      be gin
  1967                         FCCOWIconN ame := 'BM P_CCOW_LIN KED';
  1968                         pnlCCOW.Hi nt := TX_C COW_LINKED ;
  1969                         imgCCOW.Pi cture.Bitm ap.LoadFro mResourceN ame(hInsta nce, FCCOW IconName);
  1970                      en d;
  1971                  end
  1972                else
  1973                  begin
  1974                    FCCO WIconName  := 'BMP_CC OW_BROKEN' ;
  1975                    pnlC COW.Hint : = TX_CCOW_ BROKEN;
  1976                    imgC COW.Pictur e.Bitmap.L oadFromRes ourceName( hInstance,  FCCOWIcon Name);
  1977                  end;
  1978                if (Pati ent.DFN =  '') or (Se nder = mnu FileOpen)  or (Sender  = mnuFile Next) or ( Sender = m nuViewDemo ) then
  1979                  Select Patient(SH OW_NOTIFIC ATIONS, Fo nt.Size, P tSelCancel led);
  1980                if PtSel Cancelled  then
  1981                  begin
  1982                    pnlP atient.Ena bled := Tr ue;
  1983                    exit ;
  1984                  end;
  1985                ShowEver ything;
  1986                // HideE verything( 'Retrievin g informat ion - plea se wait... .');  //v2 7 (pending ) RV
  1987                DisplayE ncounterTe xt;
  1988                FPrevInP atient :=  Patient.In patient;
  1989                if Notif ications.A ctive then
  1990                  begin
  1991                    // d isplay 'ne xt notific ation' but ton
  1992                    SetU pNextButto n;
  1993                    FNex tButtonAct ive := Tru e;
  1994                    mnuF ileNext.En abled := T rue;
  1995                    mnuF ileNextCli ck(mnuFile Open);
  1996                  end
  1997                else
  1998                  begin
  1999                    // h ide the 'n ext notifi cation' bu tton
  2000                    FNex tButtonAct ive := FAL SE;
  2001                    FNex tButton.Fr ee;
  2002                    FNex tButton :=  nil;
  2003                    mnuF ileNext.En abled := F ALSE;
  2004                    mnuF ileNotifRe move.Enabl ed := FALS E;
  2005                    if P atient.DFN  <> SaveDF N then
  2006                      ok  := True;
  2007                  end
  2008              end
  2009           el se
  2010              begin
  2011                Notifica tions.Clea r;
  2012                SelectPa tient(FALS E, Font.Si ze, PtSelC ancelled);  // Call P t. Sel. w/ o notifica tions.
  2013                if PtSel Cancelled  then
  2014                  exit;
  2015                ShowEver ything;
  2016                DisplayE ncounterTe xt;
  2017                FPrevInP atient :=  Patient.In patient;
  2018                ok := Tr ue;
  2019              end;
  2020         end;
  2021       if ok  then
  2022         begi n
  2023           if  FCCOWInst alled and  (ctxContex tor.State  = csPartic ipating) a nd (not FR efreshing)  and (not  FCCOWJustJ oined) the n
  2024              begin
  2025                if (Allo wCCOWConte xtChange(C COWRespons e, Patient .DFN)) the n
  2026                  begin
  2027                    Setu pPatient;
  2028                    tabP age.TabInd ex := Page IDToTab(Ne xtTab);
  2029                    tabP ageChange( tabPage);
  2030                  end
  2031                else
  2032                  begin
  2033                    case  CCOWRespo nse of
  2034                      ur Cancel:
  2035                         UpdateCCOW Context;
  2036                      ur Break:
  2037                         begin
  2038                           // do no t revert t o old DFN  if context  was manua lly broken  by user -  v26 (RV)
  2039                           if (ctxC ontextor.S tate = csP articipati ng) then
  2040                             Patien t.DFN := S aveDFN;
  2041                           SetupPat ient;
  2042                           tabPage. TabIndex : = PageIDTo Tab(NextTa b);
  2043                           tabPageC hange(tabP age);
  2044                         end;
  2045                    else
  2046                      be gin
  2047                         SetupPatie nt;
  2048                         tabPage.Ta bIndex :=  PageIDToTa b(NextTab) ;
  2049                         tabPageCha nge(tabPag e);
  2050                      en d;
  2051                    end;
  2052                  end;
  2053              end
  2054           el se
  2055              begin
  2056                SetupPat ient;
  2057                tabPage. TabIndex : = PageIDTo Tab(NextTa b);
  2058                tabPageC hange(tabP age);
  2059                FCCOWJus tJoined :=  FALSE;
  2060              end;
  2061         end;
  2062     finally
  2063       if (no t FRefresh ing) and ( Patient.DF N = SaveDF N) then
  2064         Remi ndersStart ed := OldR emindersSt arted;
  2065       FFirst Load := FA LSE;
  2066     end;
  2067     { Begin  BillingAwa re }
  2068     if BILLI NG_AWARE t hen
  2069       frmFra me.SetBADx List; // e nd IsBilli ngAware
  2070     { End Bi llingAware  }
  2071     if not F Refreshing  then
  2072       begin
  2073         DoNo tChangeEnc Window :=  FALSE;
  2074         Orde rPrintForm  := FALSE;
  2075         uCor e.TempEnco unterLoc : = 0;
  2076         uCor e.TempEnco unterLocNa me := '';
  2077       end;
  2078     pnlPatie nt.Enabled  := True;
  2079   end;
  2080  
  2081   procedure  TfrmFrame. DetermineN extTab;
  2082   begin
  2083     if (FRef reshing or  User.UseL astTab) an d (not FFi rstLoad) t hen
  2084       begin
  2085         if ( tabPage.Ta bIndex < 0 ) then
  2086           Ne xtTab := L astTab
  2087         else
  2088           Ne xtTab := T abToPageID (tabPage.T abIndex);
  2089       end
  2090     else
  2091       NextTa b := User. InitialTab ;
  2092     if NextT ab = CT_NO PAGE then
  2093       NextTa b := User. InitialTab ;
  2094     if User. IsReportsO nly then / / Reports  Only tab.
  2095       NextTa b := CT_RE PORTS; //  Only one t ab should  exist by t his point  in "REPORT S ONLY" mo de.
  2096     if not T abExists(N extTab) th en
  2097       NextTa b := CT_CO VER;
  2098     if NextT ab = CT_NO PAGE then
  2099       NextTa b := User. InitialTab ;
  2100     if NextT ab = CT_OR DERS then
  2101       if frm Orders <>  nil then
  2102         with  frmOrders  do
  2103           be gin
  2104              if (lstShe ets.ItemIn dex > -1)  and (TheCu rrentView  <> nil) an d (TheCurr entView.Ev entDelay.P tEventIFN  > 0) then
  2105                PtEvtCom pleted(The CurrentVie w.EventDel ay.PtEvent IFN, TheCu rrentView. EventDelay .EventName );
  2106           en d;
  2107   end;
  2108  
  2109   procedure  TfrmFrame. mnuFileEnc ounterClic k(Sender:  TObject);
  2110   { displays  encounter  window an d updates  encounter  display in  case enco unter was  updated }
  2111   begin
  2112     UpdateEn counter(NP F_ALL); {* KCM*}
  2113     DisplayE ncounterTe xt;
  2114   end;
  2115  
  2116   procedure  TfrmFrame. mnuFileRev iewClick(S ender: TOb ject);
  2117   { displays  the Revie w Changes  window (wh ich resets  the Encou nter objec t) }
  2118   var
  2119     EventCha nges: bool ean;
  2120     NameNeed Look: stri ng;
  2121   begin
  2122     FReviewC lick := Tr ue;
  2123     mnuFile. Tag := 1;
  2124     EventCha nges := Fa lse;
  2125     NameNeed Look := '' ;
  2126     //Update PtInfoOnRe fresh;
  2127     if Chang es.Count >  0 then
  2128     begin
  2129      if (frm Orders <>  nil) and ( frmOrders. TheCurrent View <> ni l) and ( f rmOrders.T heCurrentV iew.EventD elay.Event IFN>0) the n
  2130      begin
  2131        Event Changes :=  True;
  2132        NameN eedLook :=  frmOrders .TheCurren tView.View Name;
  2133        frmOr ders.PtEvt Completed( frmOrders. TheCurrent View.Event Delay.PtEv entIFN, fr mOrders.Th eCurrentVi ew.EventDe lay.EventN ame);
  2134      end;
  2135      ReviewC hanges(Tim edOut, Eve ntChanges) ;
  2136      if TabT oPageID(ta bPage.TabI ndex)= CT_ MEDS then
  2137      begin
  2138        frmOr ders.InitO rderSheets 2(NameNeed Look);
  2139      end;
  2140     end
  2141     else Inf oBox('No n ew changes  to review /sign.', ' Review Cha nges', MB_ OK);
  2142     //CQ #17 491: Moved  UpdatePtI nfoOnRefre sh here to  allow for  the updat ing of the  patient s tatus indi cator
  2143     //in the  header ba r (after t he Review  Changes di alog close s) if the  patient be comes admi tted/disch arged.
  2144     UpdatePt InfoOnRefr esh;
  2145     FOrderPr intForm :=  false;
  2146     FReviewC lick := fa lse;
  2147   end;
  2148  
  2149   procedure  TfrmFrame. mnuFileExi tClick(Sen der: TObje ct);
  2150   { see the  CloseQuery  event }
  2151   var
  2152     i: small int;
  2153   begin
  2154     try
  2155        if  B ILLING_AWA RE then
  2156            b egin
  2157            i f Assigned (tempDxLis t) then
  2158                for i :=  0 to pred (UBAGlobal s.tempDxLi st.Count)  do
  2159                   TObje ct(UBAGlob als.tempDx List[i]).F ree;
  2160  
  2161            U BAGlobals. tempDxList .Clear;
  2162            A pplication .ProcessMe ssages;
  2163            e nd; //end  IsBillingA ware
  2164     except
  2165        on EA ccessViola tion do
  2166           be gin
  2167           {$ ifdef debu g}Show508M essage('Ac cess Viola tion in pr ocedure Tf rmFrame.mn uFileExitC lick()');{ $endif}
  2168           ra ise;
  2169           en d;
  2170        on E:  Exception  do
  2171           be gin
  2172           {$ ifdef debu g}Show508M essage('Un handled ex ception in  procedure  TfrmFrame .mnuFileEx itClick()' );{$endif}
  2173           ra ise;
  2174           en d;
  2175     end;
  2176  
  2177     Close;
  2178   end;
  2179  
  2180   { View Men u Events - ---------- ---------- ---------- ---------- ---------- ---------- ---------- -- }
  2181  
  2182   procedure  TfrmFrame. mnuViewPos tingsClick (Sender: T Object);
  2183   begin
  2184   end;
  2185  
  2186   { Tool Men u Events - ---------- ---------- ---------- ---------- ---------- ---------- ---------- -- }
  2187  
  2188   function T frmFrame.E xpandComma nd(x: stri ng): strin g;
  2189   { look for  'macros'  on the com mand line  and expand  them usin g current  context }
  2190  
  2191     procedur e Substitu te(const K ey, Data:  string);
  2192     var
  2193       Stop,  Start: Int eger;
  2194     begin
  2195       Stop   := Pos(Key , x) - 1;
  2196       Start  := Stop +  Length(Key ) + 1;
  2197       x := C opy(x, 1,  Stop) + Da ta + Copy( x, Start,  Length(x)) ;
  2198     end;
  2199  
  2200   begin
  2201     if Pos(' %MREF', x)  > 0 then  Substitute ('%MREF',
  2202       '^TMP( ''ORWCHART '',' + MSc alar('$J')  + ',''' +  DottedIPS tr + ''','  + IntToHe x(Handle,  8) + ')');
  2203     if Pos(' %SRV',  x)  > 0 then  Substitute ('%SRV',   String(RPC BrokerV.Se rver));
  2204     if Pos(' %PORT', x)  > 0 then  Substitute ('%PORT',  IntToStr(R PCBrokerV. ListenerPo rt));
  2205     if Pos(' %DFN',  x)  > 0 then  Substitute ('%DFN',   Patient.DF N);  //*DF N*
  2206     if Pos(' %DUZ',  x)  > 0 then  Substitute ('%DUZ',   IntToStr(U ser.DUZ));
  2207     if Pos(' %H', x) >  0  then Su bstitute(' %H', Strin g(RPCBroke rV.LogIn.L ogInHandle ));
  2208     Result : = x;
  2209   end;
  2210  
  2211   procedure  TfrmFrame. ToolClick( Sender: TO bject);
  2212   { executes  the progr am associa ted with a n item on  the Tools  menu, the  command li ne is stor ed
  2213     in the i tem's hint  property  }
  2214   const
  2215     TXT_ECS_ NOTFOUND =  'The ECS  applicatio n is not f ound at th e default  directory, ' + #13 +  'would you  like manu ally searc h it?';
  2216     TC_ECS_N OTFOUND =  'Applicati on Not Fou nd';
  2217   var
  2218     x, AFile , Param, M enuCommand , ECSAppen d, CapNm,  curPath :  string;
  2219     IsECSInt erface: bo olean;
  2220  
  2221     function  TakeOutAm ps(AString : string):  string;
  2222     var
  2223       S1,S2:  string;
  2224     begin
  2225       if Pos ('&',AStri ng)=0 then
  2226       begin
  2227         Resu lt := AStr ing;
  2228         Exit ;
  2229       end;
  2230       S1 :=  Piece(AStr ing,'&',1) ;
  2231       S2 :=  Piece(AStr ing,'&',2) ;
  2232       Result  := S1 + S 2;
  2233     end;
  2234  
  2235     function  ExcuteEC( AFile,APar a: string) : boolean;
  2236     begin
  2237       if (Sh ellExecute (Handle, ' open', PCh ar(AFile),  PChar(Par am), '', S W_NORMAL)  > 32 ) the n Result : = True
  2238       else
  2239       begin
  2240         if I nfoBox(TXT _ECS_NOTFO UND, TC_EC S_NOTFOUND , MB_YESNO  or MB_ICO NERROR) =  IDYES then
  2241         begi n
  2242           if  OROpenDlg .Execute t hen
  2243           be gin
  2244               AFile :=  OROpenDlg. FileName;
  2245               if Pos('e cs gui.exe ',lowerCas e(AFile))< 1 then
  2246               begin
  2247                 ShowMsg ('This is  not a vali d ECS appl ication.') ;
  2248                 Result  := True;
  2249               end else
  2250               begin
  2251                 if (She llExecute( Handle, 'o pen', PCha r(AFile),  PChar(Para m), '', SW _NORMAL)<3 2) then Re sult := Fa lse
  2252                 else Re sult := Tr ue;
  2253               end;
  2254           en d
  2255           el se Result  := True;
  2256         end  else Resul t := True;
  2257       end;
  2258     end;
  2259  
  2260     function  ExcuteECS (AFile, AP ara: strin g; var cur rPath: str ing): bool ean;
  2261     var
  2262       comman dline,RPCH andle: str ing;
  2263       Startu pInfo: TSt artupInfo;
  2264       Proces sInfo: TPr ocessInfor mation;
  2265     begin
  2266       FillCh ar(Startup Info, Size Of(TStartu pInfo), 0) ;
  2267       with S tartupInfo  do
  2268       begin
  2269         cb : = SizeOf(T StartupInf o);
  2270         dwFl ags := STA RTF_USESHO WWINDOW;
  2271         wSho wWindow :=  SW_SHOWNO RMAL;
  2272       end;
  2273       comman dline := A File + Par am;
  2274       RPCHan dle := Get AppHandle( RPCBrokerV );
  2275       comman dline := c ommandline  + ' H=' +  RPCHandle ;
  2276       if Cre ateProcess (nil, PCha r(commandl ine), nil,  nil, Fals e,
  2277         NORM AL_PRIORIT Y_CLASS, n il, nil, S tartupInfo , ProcessI nfo) then  Result :=  True
  2278       else
  2279       begin
  2280         if I nfoBox(TXT _ECS_NOTFO UND, TC_EC S_NOTFOUND , MB_YESNO  or MB_ICO NERROR) =  IDYES then
  2281         begi n
  2282           if  OROpenDlg .Execute t hen
  2283           be gin
  2284               AFile :=  OROpenDlg. FileName;
  2285               if Pos('e cs gui.exe ',lowerCas e(AFile))< 1 then
  2286               begin
  2287                 ShowMsg ('This is  not a vali d ECS appl ication.') ;
  2288                 Result  := True;
  2289               end else
  2290               begin
  2291                 SaveUse rPath('Eve nt Capture  Interface ='+AFile,  currPath);
  2292                 FillCha r(StartupI nfo, SizeO f(TStartup Info), 0);
  2293                 with St artupInfo  do
  2294                 begin
  2295                   cb :=  SizeOf(TS tartupInfo );
  2296                   dwFla gs := STAR TF_USESHOW WINDOW;
  2297                   wShow Window :=  SW_SHOWNOR MAL;
  2298                 end;
  2299                 command line := AF ile + Para m;
  2300                 RPCHand le := GetA ppHandle(R PCBrokerV) ;
  2301                 command line := co mmandline  + ' H=' +  RPCHandle;
  2302                 if not  CreateProc ess(nil, P Char(comma ndline), n il, nil, F alse,
  2303                    NORM AL_PRIORIT Y_CLASS, n il, nil,St artupInfo, ProcessInf o) then Re sult := Fa lse
  2304                 else Re sult := Tr ue;
  2305               end;
  2306           en d
  2307           el se Result  := True;
  2308         end  else Resul t := True;
  2309       end;
  2310     end;
  2311  
  2312   begin
  2313     MenuComm and := '';
  2314     ECSAppen d   := '';
  2315     IsECSInt erface :=  False;
  2316     curPath  := '';
  2317     CapNm :=  LowerCase (TMenuItem (Sender).C aption);
  2318     CapNm :=  TakeOutAm ps(CapNm);
  2319     if AnsiC ompareText ('event ca pture inte rface',Cap Nm)=0 then
  2320     begin
  2321       IsECSI nterface : = True;
  2322       if FEC SAuthUser  then Updat eECSParame ter(ECSApp end)
  2323       else b egin
  2324         Show Msg('You d on''t have  permissio n to use E CS.');
  2325         exit ;
  2326       end;
  2327     end;
  2328     MenuComm and := TMe nuItem(Sen der).Hint  + ECSAppen d;
  2329     x := Exp andCommand (MenuComma nd);
  2330     if CharA t(x, 1) =  '"' then
  2331     begin
  2332       x      := Copy(x,  2, Length (x));
  2333       AFile  := Copy(x,  1, Pos('" ',x)-1);
  2334       Param  := Copy(x,  Pos('"',x )+1, Lengt h(x));
  2335     end else
  2336     begin
  2337       AFile  := Piece(x , ' ', 1);
  2338       Param  := Copy(x,  Length(AF ile)+1, Le ngth(x));
  2339     end;
  2340     if IsECS Interface  then
  2341     begin
  2342       if not  ExcuteECS (AFile,Par am,curPath ) then
  2343         Excu teECS(AFil e,Param,cu rPath);
  2344       if Len gth(curPat h)>0 then
  2345         TMen uItem(Send er).Hint : = curPath;
  2346     end
  2347     else if  (Pos('ecs' ,LowerCase (AFile))>0 ) and (not  IsECSInte rface) the n
  2348     begin
  2349       if not  ExcuteEC( AFile,Para m) then
  2350         Excu teEC(AFile ,Param);
  2351     end else
  2352     begin
  2353       ShellE xecute(Han dle, 'open ', PChar(A File), PCh ar(Param),  '', SW_NO RMAL);
  2354     end;
  2355   end;
  2356  
  2357   { Help Men u Events - ---------- ---------- ---------- ---------- ---------- ---------- ---------- -- }
  2358  
  2359   procedure  TfrmFrame. mnuHelpBro kerClick(S ender: TOb ject);
  2360   { used for  debugging  - shows l ast n brok er calls }
  2361   begin
  2362     ShowBrok er;
  2363   end;
  2364  
  2365   procedure  TfrmFrame. mnuHelpLis tsClick(Se nder: TObj ect);
  2366   { used for  debugging  - shows i nternal co ntents of  TORListBox  }
  2367   begin
  2368     if Scree n.ActiveCo ntrol is T ListBox
  2369       then D ebugListIt ems(TListB ox(Screen. ActiveCont rol))
  2370       else I nfoBox('Fo cus contro l is not a  listbox',  'ListBox  Data', MB_ OK);
  2371   end;
  2372  
  2373   procedure  TfrmFrame. mnuHelpSym bolsClick( Sender: TO bject);
  2374   { used for  debugging  - shows c urrent sym bol table  }
  2375   begin
  2376     DebugSho wServer;
  2377   end;
  2378  
  2379   procedure  TfrmFrame. mnuHelpAbo utClick(Se nder: TObj ect);
  2380   { displays  the about  screen }
  2381   begin
  2382     ShowAbou t;
  2383   end;
  2384  
  2385   { Status B ar Methods  }
  2386  
  2387   procedure  TfrmFrame. UMStatusTe xt(var Mes sage: TMes sage);
  2388   { displays  status ba r text (us ing the po inter to a  text buff er passed  in LParam)  }
  2389   begin
  2390     stsArea. Panels.Ite ms[0].Text  := StrPas (PChar(Mes sage.LPara m));
  2391     stsArea. Refresh;
  2392   end;
  2393  
  2394   { Toolbar  Methods (m ake panels  act like  buttons) - ---------- ---------- ---------- ---------- -- }
  2395  
  2396   procedure  TfrmFrame. pnlPatient MouseDown( Sender: TO bject; But ton: TMous eButton;
  2397     Shift: T ShiftState ; X, Y: In teger);
  2398   { emulate  a button p ress in th e patient  identifica tion panel  }
  2399   begin
  2400     if pnlPa tient.Beve lOuter = b vLowered t hen exit;
  2401     pnlPatie nt.BevelOu ter := bvL owered;
  2402     with lbl PtName do  SetBounds( Left+2, To p+2, Width , Height);
  2403     with lbl PtSSN  do  SetBounds( Left+2, To p+2, Width , Height);
  2404     with lbl PtAge  do  SetBounds( Left+2, To p+2, Width , Height);
  2405   end;
  2406  
  2407   procedure  TfrmFrame. pnlPatient MouseUp(Se nder: TObj ect; Butto n: TMouseB utton;
  2408     Shift: T ShiftState ; X, Y: In teger);
  2409   { emulate  the button  raising i n the pati ent identi fication p anel & cal l Patient  Inquiry }
  2410   begin
  2411     if pnlPa tient.Beve lOuter = b vRaised th en exit;
  2412     pnlPatie nt.BevelOu ter := bvR aised;
  2413     with lbl PtName do  SetBounds( Left-2, To p-2, Width , Height);
  2414     with lbl PtSSN  do  SetBounds( Left-2, To p-2, Width , Height);
  2415     with lbl PtAge  do  SetBounds( Left-2, To p-2, Width , Height);
  2416   end;
  2417  
  2418   procedure  TfrmFrame. pnlVisitMo useDown(Se nder: TObj ect; Butto n: TMouseB utton;
  2419     Shift: T ShiftState ; X, Y: In teger);
  2420   { emulate  a button p ress in th e encounte r panel }
  2421   begin
  2422     if User. IsReportsO nly then
  2423       exit;
  2424     if pnlVi sit.BevelO uter = bvL owered the n exit;
  2425     pnlVisit .BevelOute r := bvLow ered;
  2426     with lbl PtLocation  do SetBou nds(Left+2 , Top+2, W idth, Heig ht);
  2427     with lbl PtProvider  do SetBou nds(Left+2 , Top+2, W idth, Heig ht);
  2428   end;
  2429  
  2430   procedure  TfrmFrame. pnlVisitMo useUp(Send er: TObjec t; Button:  TMouseBut ton;
  2431     Shift: T ShiftState ; X, Y: In teger);
  2432   { emulate  a button r aising in  the encoun ter panel  and call U pdate Prov ider/Locat ion }
  2433   begin
  2434     if User. IsReportsO nly then
  2435       exit;
  2436     if pnlVi sit.BevelO uter = bvR aised then  exit;
  2437     pnlVisit .BevelOute r := bvRai sed;
  2438     with lbl PtLocation  do SetBou nds(Left-2 , Top-2, W idth, Heig ht);
  2439     with lbl PtProvider  do SetBou nds(Left-2 , Top-2, W idth, Heig ht);
  2440   end;
  2441  
  2442   procedure  TfrmFrame. pnlVistaWe bClick(Sen der: TObje ct);
  2443   begin
  2444     inherite d;
  2445     uUseVist aWeb := tr ue;
  2446     pnlVista Web.BevelO uter := bv Lowered;
  2447     pnlCIRNC lick(self) ;
  2448     uUseVist aWeb := fa lse;
  2449   end;
  2450  
  2451   procedure  TfrmFrame. pnlVistaWe bMouseDown (Sender: T Object; Bu tton: TMou seButton;
  2452     Shift: T ShiftState ; X, Y: In teger);
  2453   begin
  2454     inherite d;
  2455     pnlVista Web.BevelO uter := bv Lowered;
  2456   end;
  2457  
  2458   procedure  TfrmFrame. pnlVistaWe bMouseUp(S ender: TOb ject; Butt on: TMouse Button;
  2459     Shift: T ShiftState ; X, Y: In teger);
  2460   begin
  2461     inherite d;
  2462     pnlVista Web.BevelO uter := bv Raised;
  2463   end;
  2464  
  2465   procedure  TfrmFrame. pnlPrimary CareMouseD own(Sender : TObject;
  2466     Button:  TMouseButt on; Shift:  TShiftSta te; X, Y:  Integer);
  2467   begin
  2468     if pnlPr imaryCare. BevelOuter  = bvLower ed then ex it;
  2469     pnlPrima ryCare.Bev elOuter :=  bvLowered ;
  2470     with lbl PtCare       do SetBo unds(Left+ 2, Top+2,  Width, Hei ght);
  2471     with lbl PtAttendin g do SetBo unds(Left+ 2, Top+2,  Width, Hei ght);
  2472     with lbl PtMHTC do  SetBounds( Left+2, To p+2, Width , Height);
  2473   end;
  2474  
  2475   procedure  TfrmFrame. pnlPrimary CareMouseU p(Sender:  TObject;
  2476     Button:  TMouseButt on; Shift:  TShiftSta te; X, Y:  Integer);
  2477   begin
  2478     if pnlPr imaryCare. BevelOuter  = bvRaise d then exi t;
  2479     pnlPrima ryCare.Bev elOuter :=  bvRaised;
  2480     with lbl PtCare       do SetBo unds(Left- 2, Top-2,  Width, Hei ght);
  2481     with lbl PtAttendin g do SetBo unds(Left- 2, Top-2,  Width, Hei ght);
  2482     with lbl PtMHTC       do SetBo unds(Left- 2, Top-2,  Width, Hei ght);
  2483   end;
  2484  
  2485   procedure  TfrmFrame. pnlPosting sMouseDown (Sender: T Object;
  2486     Button:  TMouseButt on; Shift:  TShiftSta te; X, Y:  Integer);
  2487   { emulate  a button p ress in th e postings  panel }
  2488   begin
  2489     if pnlPo stings.Bev elOuter =  bvLowered  then exit;
  2490     pnlPosti ngs.BevelO uter := bv Lowered;
  2491     with lbl PtPostings  do SetBou nds(Left+2 , Top+2, W idth, Heig ht);
  2492     with lbl PtCWAD      do SetBou nds(Left+2 , Top+2, W idth, Heig ht);
  2493   end;
  2494  
  2495   procedure  TfrmFrame. pnlPosting sMouseUp(S ender: TOb ject;
  2496     Button:  TMouseButt on; Shift:  TShiftSta te; X, Y:  Integer);
  2497   { emulate  a button r aising in  the postin g panel an d call Pos tings }
  2498   begin
  2499     if pnlPo stings.Bev elOuter =  bvRaised t hen exit;
  2500     pnlPosti ngs.BevelO uter := bv Raised;
  2501     with lbl PtPostings  do SetBou nds(Left-2 , Top-2, W idth, Heig ht);
  2502     with lbl PtCWAD      do SetBou nds(Left-2 , Top-2, W idth, Heig ht);
  2503   end;
  2504  
  2505   { Resize a nd Font-Ch ange proce dures ---- ---------- ---------- ---------- ---------- ---------- -- }
  2506  
  2507   procedure  TfrmFrame. LoadSizesF orUser;
  2508   var
  2509     s1, s2,  s3, s4, Du mmy: integ er;
  2510     panelBot tom, panel MedIn, Res toreWidth,  MinCnst :  integer;
  2511  
  2512     procedur e GetMinCo ntraint(aC ontrol: TW inControl;  var LastM inWidth: I nteger);
  2513     var
  2514      I: inte ger;
  2515     begin
  2516      if aCon trol.Const raints.Min Width > La stMinWidth  then
  2517        LastM inWidth :=  aControl. Constraint s.MinWidth ;
  2518  
  2519      for I : = 0 to aCo ntrol.Cont rolCount -  1 do
  2520      begin
  2521        if aC ontrol.Con trols[i] i s TWinCont rol then
  2522         GetM inContrain t(TWinCont rol(aContr ol.Control s[i]), Las tMinWidth) ;
  2523      end;
  2524  
  2525     end;
  2526  
  2527   begin
  2528     ChangeFo nt(UserFon tSize);
  2529     CoverShe et.OnSetFo ntSize(Sel f, UserFon tSize);
  2530     CoverShe et.OnSetSc reenReader Status(Sel f, ScreenR eaderSyste mActive);
  2531     SetUserB ounds(TCon trol(frmFr ame));
  2532     SetUserW idths(TCon trol(frmPr oblems.pnl Left));
  2533     SetUserW idths(TCon trol(frmOr ders.pnlLe ft));
  2534     RestoreW idth := fr mNotes.pnl Left.Width ;
  2535     SetUserW idths(TCon trol(frmNo tes.pnlLef t));
  2536     MinCnst  := 0;
  2537     GetMinCo ntraint(fr mNotes.pnl Left, MinC nst);
  2538     if frmNo tes.pnlLef t.Width <  MinCnst th en
  2539      frmNote s.pnlLeft. Width := R estoreWidt h;
  2540  
  2541     frmNotes .splHorz.L eft := frm Notes.pnlL eft.left +  1;
  2542     SetUserW idths(TCon trol(frmCo nsults.pnl Left));
  2543     SetUserW idths(TCon trol(frmDC Summ.pnlLe ft));
  2544     if Assig ned(frmSur gery) then  SetUserWi dths(TCont rol(frmSur gery.pnlLe ft));
  2545     SetUserW idths(TCon trol(frmLa bs.pnlLeft ));
  2546     SetUserW idths(TCon trol(frmRe ports.pnlL eft));
  2547     SetUserC olumns(TCo ntrol(frmO rders.hdrO rders));
  2548     SetUserC olumns(TCo ntrol(frmM eds.hdrMed sIn));  //  still nee d conversi on
  2549     SetUserC olumns(TCo ntrol(frmM eds.hdrMed sOut));
  2550     SetUserS tring('frm PtSel.lstv Alerts',En duringPtSe lColumns);
  2551     SetUserS tring(Spel lCheckerSe ttingName,  SpellChec kerSetting s);
  2552     SetUserB ounds2(Tem plateEdito rSplitters , tmplEdit orSplitter Middle,
  2553                     tmp lEditorSpl itterPrope rties, tmp lEditorSpl itterMain,  tmplEdito rSplitterB oil);
  2554     SetUserB ounds2(Tem plateEdito rSplitters 2, tmplEdi torSplitte rNotes, Du mmy, Dummy , Dummy);
  2555     SetUserB ounds2(Rem inderTreeN ame, RemTr eeDlgLeft,  RemTreeDl gTop, RemT reeDlgWidt h, RemTree DlgHeight) ;
  2556     SetUserB ounds2(Rem DlgName, R emDlgLeft,  RemDlgTop , RemDlgWi dth, RemDl gHeight);
  2557     SetUserB ounds2(Rem DlgSplitte rs, RemDlg Spltr1, Re mDlgSpltr2 , Dummy ,D ummy);
  2558     SetUserB ounds2(Dra werSplitte rs,s1, s2,  s3, S4);
  2559     frmNotes .Drawers.L astOpenSiz e := s1;
  2560     frmConsu lts.Drawer s.LastOpen Size := s2 ;
  2561     frmDCSum m.Drawers. LastOpenSi ze := s3;
  2562     if Assig ned(frmSur gery) then  frmSurger y.Drawers. LastOpenSi ze := S4;  //CQ7315
  2563  
  2564     SetUserB ounds2(Not eSplitters ,s1, s2, s 3, s4);
  2565     frmNotes .LoadUserS plitterSet tings(s1,  s2, s3, s4 );
  2566  
  2567     SetUserB ounds2(Lab Splitters, s1, s2, s3 , s4);
  2568     frmLabs. LoadUserSe ttings(s1,  s2, s3, s 4);
  2569  
  2570     with frm Meds do
  2571        begin
  2572        SetUs erBounds2( frmMeds.Na me+'Split' , panelBot tom, panel MedIn, Dum my, Dummy) ;
  2573        if (p anelBottom  > frmMeds .Height-50 ) then pan elBottom : = frmMeds. Height-50;
  2574        if (p anelMedIn  > panelBot tom-50) th en panelMe dIn := pan elBottom-5 0;
  2575        frmMe ds.pnlBott om.Height  := panelBo ttom;
  2576        frmMe ds.pnlMedI n.Height : = panelMed In;
  2577        //Med s Tab Non- VA meds co lumns
  2578        SetUs erColumns( TControl(h drMedsNonV A)); //CQ7 314
  2579        end;
  2580  
  2581     if Param Search('re z') = '640 ' then Set Bounds(Lef t, Top, 64 8, 488);   // for tes ting
  2582  
  2583   end;
  2584  
  2585   procedure  TfrmFrame. SaveSizesF orUser;
  2586   var
  2587     SizeList : TStringL ist;
  2588     SurgTemp Ht: intege r;
  2589     s1, s2,  s3, s4: in teger;
  2590   begin
  2591     SaveUser FontSize(M ainFontSiz e);
  2592     SizeList  := TStrin gList.Crea te;
  2593     try
  2594       with S izeList do
  2595       begin
  2596         Add( StrUserBou nds(frmFra me));
  2597         Add( StrUserWid th(frmProb lems.pnlLe ft));
  2598         Add( StrUserWid th(frmOrde rs.pnlLeft ));
  2599         Add( StrUserWid th(frmNote s.pnlLeft) );
  2600         Add( StrUserWid th(frmCons ults.pnlLe ft));
  2601         Add( StrUserWid th(frmDCSu mm.pnlLeft ));
  2602         if A ssigned(fr mSurgery)  then Add(S trUserWidt h(frmSurge ry.pnlLeft ));
  2603         Add( StrUserWid th(frmLabs .pnlLeft)) ;
  2604         Add( StrUserWid th(frmRepo rts.pnlLef t));
  2605         Add( StrUserCol umns(frmOr ders.hdrOr ders));
  2606         Add( StrUserCol umns(frmMe ds.hdrMeds In));
  2607         Add( StrUserCol umns(frmMe ds.hdrMeds Out));
  2608         Add( StrUserStr ing(SpellC heckerSett ingName, S pellChecke rSettings) );
  2609         Add( StrUserBou nds2(Templ ateEditorS plitters,  tmplEditor SplitterMi ddle,
  2610                  tmplEd itorSplitt erProperti es, tmplEd itorSplitt erMain, tm plEditorSp litterBoil ));
  2611         Add( StrUserBou nds2(Templ ateEditorS plitters2,  tmplEdito rSplitterN otes, 0, 0 , 0));
  2612         Add( StrUserBou nds2(Remin derTreeNam e, RemTree DlgLeft, R emTreeDlgT op, RemTre eDlgWidth,  RemTreeDl gHeight));
  2613         Add( StrUserBou nds2(RemDl gName, Rem DlgLeft, R emDlgTop,  RemDlgWidt h, RemDlgH eight));
  2614         Add( StrUserBou nds2(RemDl gSplitters , RemDlgSp ltr1, RemD lgSpltr2,  0 ,0));
  2615  
  2616         //v2 6.47 - RV  - access v iolation i f Surgery  Tab not en abled.  Se t to desig ner height  as defaul t.
  2617         if A ssigned(fr mSurgery)  then SurgT empHt := f rmSurgery. Drawers.pn lTemplates .Height el se SurgTem pHt := 85;
  2618         Add( StrUserBou nds2(Drawe rSplitters , frmNotes .Drawers.L astOpenSiz e,
  2619                                                    frmCo nsults.Dra wers.LastO penSize,
  2620                                                    frmDC Summ.Drawe rs.LastOpe nSize,
  2621                                                    SurgT empHt)); / / last par ameter = C Q7315
  2622         Add( StrUserBou nds2(Drawe rSplitters , frmNotes .Drawers.L astOpenSiz e,
  2623                                                    frmCo nsults.Dra wers.LastO penSize,
  2624                                                    frmDC Summ.Drawe rs.LastOpe nSize,
  2625                                                    SurgT empHt));
  2626  
  2627         frmN otes.SaveU serSplitte rSettings( s1, s2, s3 , s4);
  2628         Add( StrUserBou nds2(NoteS plitters,  s1, s2, s3 , s4));
  2629  
  2630         frmL abs.SaveUs erSettings (s1, s2, s 3, s4);
  2631         Add( StrUserBou nds2(LabSp litters, s 1, s2, s3,  s4));
  2632  
  2633         //Me ds Tab Spl itters
  2634         Add( StrUserBou nds2(frmMe ds.Name+'S plit',frmM eds.pnlBot tom.Height ,frmMeds.p nlMedIn.He ight,0,0)) ;
  2635  
  2636         //Me ds Tab Non -VA meds c olumns
  2637         Add( StrUserCol umns(fMeds .frmMeds.h drMedsNonV A)); //CQ7 314
  2638  
  2639         //Or ders Tab c olumns
  2640         Add( StrUserCol umns(fOrde rs.frmOrde rs.hdrOrde rs)); //CQ 6328
  2641  
  2642         if E nduringPtS elSplitter Pos <> 0 t hen
  2643           Ad d(StrUserB ounds2('fr mPtSel.spt Vert', End uringPtSel SplitterPo s, 0, 0, 0 ));
  2644         if E nduringPtS elColumns  <> '' then
  2645           Ad d('C^frmPt Sel.lstvAl erts^' + E nduringPtS elColumns) ;
  2646  
  2647         //** ** Copy/Pa ste
  2648   //      Ad d(StrUserB ounds2('fr mNotes.Rea dOnlyEditM onitor', f rmNotes.Re adOnlyEdit Monitor.He ight, 0, 0 , 0)); //  Notes savi ng is done  on the no tes form.
  2649       end;
  2650       //Add  sizes for  forms that  used Save UserBounds () to save  thier pos itions
  2651       SizeHo lder.AddSi zesToStrLi st(SizeLis t);
  2652       //Send  the SizeL ist to the  Database
  2653       SaveUs erSizes(Si zeList);
  2654     finally
  2655       SizeLi st.Free;
  2656     end;
  2657   end;
  2658  
  2659   procedure  TfrmFrame. FormResize (Sender: T Object);
  2660   { need to  resize tab  forms spe cifically  since they  don't inh erit resiz e event (b ecause the y
  2661     are deri ved from T Form itsel f) }
  2662   begin
  2663     if FTerm inate or F Closing th en Exit;
  2664     if csDes troying in  Component State then  Exit;
  2665     // These  MoveWindo w methods  can be pha sed out. T Form now h as TAlign  property t hat set to
  2666     // alCli ent works  perfectly  well. Tfrm CoverSheet  update no  longer us es it.
  2667     //MoveWi ndow(frmCo ver.Handle ,  0, 0, p nlPage.Cli entWidth,  pnlPage.Cl ientHeight , True);
  2668     MoveWind ow(frmProb lems.Handl e, 0, 0, p nlPage.Cli entWidth,  pnlPage.Cl ientHeight , True);
  2669     MoveWind ow(frmMeds .Handle,      0, 0, p nlPage.Cli entWidth,  pnlPage.Cl ientHeight , True);
  2670     MoveWind ow(frmOrde rs.Handle,    0, 0, p nlPage.Cli entWidth,  pnlPage.Cl ientHeight , True);
  2671     MoveWind ow(frmNote s.Handle,     0, 0, p nlPage.Cli entWidth,  pnlPage.Cl ientHeight , True);
  2672     MoveWind ow(frmCons ults.Handl e, 0, 0, p nlPage.Cli entWidth,  pnlPage.Cl ientHeight , True);
  2673     MoveWind ow(frmDCSu mm.Handle,    0, 0, p nlPage.Cli entWidth,  pnlPage.Cl ientHeight , True);
  2674     if Assig ned(frmSur gery) then  MoveWindo w(frmSurge ry.Handle,      0, 0,  pnlPage.C lientWidth , pnlPage. ClientHeig ht, True);
  2675     MoveWind ow(frmLabs .Handle,      0, 0, p nlPage.Cli entWidth,  pnlPage.Cl ientHeight , True);
  2676     MoveWind ow(frmRepo rts.Handle ,  0, 0, p nlPage.Cli entWidth,  pnlPage.Cl ientHeight , True);
  2677     with sts Area do
  2678     begin
  2679       Panels [1].Width  := stsArea .Width - F FixedStatu sWidth;
  2680       FNextB uttonL :=  Panels[0]. Width + Pa nels[1].Wi dth;
  2681       FNextB uttonR :=  FNextButto nL + Panel s[2].Width ;
  2682     end;
  2683     if Notif ications.A ctive then  SetUpNext Button;
  2684     lstCIRNL ocations.L eft  := FN extButtonL  - ScrollB arWidth -  100;
  2685     lstCIRNL ocations.W idth := Cl ientWidth  - lstCIRNL ocations.L eft;
  2686     //cq: 15 641
  2687     if frmFr ame.FNextB uttonActiv e then //  keeps butt on aligned  if cancel  is presse d
  2688     begin
  2689       FNextB utton.Left  := FNextB uttonL;
  2690       FNextB utton.Top  := stsArea .Top;
  2691     end;
  2692     Self.Rep aint;
  2693   end;
  2694  
  2695   procedure  TfrmFrame. ChangeFont (NewFontSi ze: Intege r);
  2696   { Makes ch anges in a ll compone nts whenev er the fon t size is  changed.   This is ha rdcoded an d
  2697     based on  MS Sans S erif for n ow, as onl y the font  size may  be selecte d. Courier  New is us ed
  2698     wherever  non-propo rtional fo nts are re quired. }
  2699   const
  2700     TAB_VOFF SET = 7;
  2701   var
  2702     OldFont:  TFont;
  2703   begin
  2704   // Ho ho!   ResizeAnc horedFormT oFont(self ) doesn't  work here  because th e
  2705   // Form si ze is alia sed with M ainFormSiz e.
  2706     OldFont  := TFont.C reate;
  2707     try
  2708       Disabl eAlign;
  2709       try
  2710         OldF ont.Assign (Font);
  2711         with  Self           do Fo nt.Size :=  NewFontSi ze;
  2712         with  lblPtName      do Fo nt.Size :=  NewFontSi ze;   // m ust change  BOLDED la bels by ha nd
  2713         with  lblPtSSN       do Fo nt.Size :=  NewFontSi ze;
  2714         with  lblPtAge       do Fo nt.Size :=  NewFontSi ze;
  2715         with  lblPtLoca tion do Fo nt.Size :=  NewFontSi ze;
  2716         with  lblPtProv ider do Fo nt.Size :=  NewFontSi ze;
  2717         with  lblPtPost ings do Fo nt.Size :=  NewFontSi ze;
  2718         with  lblPtCare      do Fo nt.Size :=  NewFontSi ze;
  2719         with  lblPtAtte nding do F ont.Size : = NewFontS ize;
  2720         with  lblPtMHTC       do F ont.Size : = NewFontS ize;
  2721         with  lblFlag        do Fo nt.Size :=  NewFontSi ze;
  2722         with  lblPtCWAD      do Fo nt.Size :=  NewFontSi ze;
  2723         with  lblCIRN        do Fo nt.Size :=  NewFontSi ze;
  2724         with  lblVistaW eb   do Fo nt.Size :=  NewFontSi ze;
  2725         with  lstCIRNLo cations do
  2726           be gin
  2727              Font.Size  := NewFont Size;
  2728              ItemHeight  := NewFon tSize + 6;
  2729           en d;
  2730         with  tabPage        do Fo nt.Size :=  NewFontSi ze;
  2731         with  laMHV          do Fo nt.Size :=  NewFontSi ze; //VAA
  2732         with  laVAA2         do Fo nt.Size :=  NewFontSi ze; //VAA
  2733  
  2734         frmF rameHeight  := frmFra me.Height;
  2735         pnlP atientSele ctedHeight  := pnlPat ientSelect ed.Height;
  2736         tabP age.Height  := MainFo ntHeight +  TAB_VOFFS ET;   // r esize tab  selector
  2737         FitT oolbar;                                           // r esize tool bar
  2738         stsA rea.Font.S ize := New FontSize;
  2739         stsA rea.Height  := MainFo ntHeight +  TAB_VOFFS ET;
  2740         stsA rea.Panels [0].Width  := ResizeW idth( OldF ont, Font,  stsArea.P anels[0].W idth);
  2741         stsA rea.Panels [2].Width  := ResizeW idth( OldF ont, Font,  stsArea.P anels[2].W idth);
  2742  
  2743         Refr eshFixedSt atusWidth;
  2744         Form Resize( se lf );
  2745       finall y
  2746         Enab leAlign;
  2747       end;
  2748     finally
  2749       OldFon t.Free;
  2750     end;
  2751  
  2752     case (Ne wFontSize)  of
  2753      8: mnu8 pt.Checked  := true;
  2754     10: mnu1 0pt1.Check ed := true ;
  2755     12: mnu1 2pt1.Check ed := true ;
  2756     14: mnu1 4pt1.Check ed := true ;
  2757     18: mnu1 8pt1.Check ed := true ;
  2758     end;
  2759  
  2760     //Now th at the for m elements  are resiz ed, the pa ges will k now what s ize to tak e.
  2761  
  2762     //frmCov erSheet.Fo nt.Size :=  NewFontSi ze;
  2763     CoverShe et.OnSetFo ntSize(Sel f, NewFont Size);
  2764     frmProbl ems.SetFon tSize(NewF ontSize);
  2765     frmMeds. SetFontSiz e(NewFontS ize);
  2766     frmOrder s.SetFontS ize(NewFon tSize);
  2767     frmNotes .SetFontSi ze(NewFont Size);
  2768     frmConsu lts.SetFon tSize(NewF ontSize);
  2769     frmDCSum m.SetFontS ize(NewFon tSize);
  2770     if Assig ned(frmSur gery) then  frmSurger y.SetFontS ize(NewFon tSize);
  2771     frmLabs. SetFontSiz e(NewFontS ize);
  2772     frmRepor ts.SetFont Size(NewFo ntSize);
  2773     TfrmIcon Legend.Set FontSize(N ewFontSize );
  2774     uOrders. SetFontSiz e(NewFontS ize);
  2775     if Assig ned(frmRem Dlg) then  frmRemDlg. SetFontSiz e;
  2776     //if (Tf rmRemDlg.G etInstance  <> nil) t hen TfrmRe mDlg.GetIn stance.Set FontSize;
  2777     if Assig ned(frmRem inderTree)  then frmR eminderTre e.SetFontS ize(NewFon tSize);
  2778     if Graph Float <> n il then Re sizeAnchor edFormToFo nt(GraphFl oat);
  2779   end;
  2780  
  2781   procedure  TfrmFrame. FitToolBar ;
  2782   { resizes  and reposi tions the  panels & l abels used  in the to olbar }
  2783   const
  2784     PATIENT_ WIDTH = 29 ;
  2785     VISIT_WI DTH   = 36 ;
  2786     POSTING_ WIDTH = 11 .5;
  2787     FLAG_WID TH    = 5;
  2788     CV_WIDTH       = 15 ; //14; WA T
  2789     CIRN_WID TH    = 11 ;
  2790     MHV_WIDT H     = 6;
  2791     LINES_HI GH2    = 2 ;
  2792     LINES_HI GH3    = 3 ;    //lbl PtMHTC lin e change
  2793     M_HORIZ        = 4;
  2794     M_MIDDLE       = 2;
  2795     M_NVERT        = 4;
  2796     M_WVERT        = 6;
  2797     TINY_MAR GIN   = 2;
  2798   begin
  2799     if lblPt MHTC.capti on = '' th en
  2800     begin
  2801       lblPtM HTC.Visibl e := false ;
  2802       pnlToo lbar.Heigh t  := (LIN ES_HIGH2 *  lblPtName .Height) +  M_HORIZ +  M_MIDDLE  + M_HORIZ  + M_MIDDLE
  2803     end
  2804     else
  2805     begin
  2806       if (lb lPtAttendi ng.Caption  <> '') an d (lblPtAt tending.Ca ption <> l blPtMHTC.C aption) th en
  2807       begin
  2808         lblP tMHTC.Visi ble := tru e;
  2809         pnlT oolbar.Hei ght  := (L INES_HIGH3  * lblPtNa me.Height)  + M_HORIZ  + M_MIDDL E + M_HORI Z + M_HORI Z;
  2810       end;
  2811       if lbl PtAttendin g.Caption  = '' then
  2812       begin
  2813         lblP tAttending .Caption : = lblPtMHT C.Caption;
  2814         lblP tMHTC.Visi ble := fal se;
  2815         pnlT oolbar.Hei ght  := (L INES_HIGH2  * lblPtNa me.Height)  + M_HORIZ  + M_MIDDL E + M_HORI Z + M_MIDD LE;
  2816       end;
  2817     end;
  2818     pnlPatie nt.Width    := Higher Of(PATIENT _WIDTH * M ainFontWid th, lblPtN ame.Width  + (M_WVERT  * 2));
  2819     lblPtSSN .Top        := M_HORI Z + lblPtN ame.Height  + M_MIDDL E;
  2820     lblPtAge .Top        := lblPtS SN.Top;
  2821     lblPtAge .Left       := pnlPat ient.Width  - lblPtAg e.Width -  M_WVERT;
  2822     pnlVisit .Width      := Higher Of(LowerOf (VISIT_WID TH * MainF ontWidth,
  2823                                                HigherOf( lblPtProvi der.Width  + (M_WVERT  * 2),
  2824                                                          lblPtLocat ion.Width  + (M_WVERT  * 2))),
  2825                                       PATIENT _WIDTH * M ainFontWid th);
  2826     lblPtPro vider.Top   := lblPtS SN.Top;
  2827     lblPtAtt ending.Top  := lblPtS SN.Top;
  2828     lblPtMHT C.Top        := M_MID DLE + lblP tSSN.Heigh t + lblPtS SN.Top;
  2829     pnlPosti ngs.Width   := Round( POSTING_WI DTH * Main FontWidth) ;
  2830     if btnCo mbatVet.Vi sible then
  2831      begin
  2832       pnlCVn Flag.Width    := Roun d(CV_WIDTH  * MainFon tWidth);
  2833       pnlFla g.Width       := Roun d(CV_WIDTH  * MainFon tWidth);
  2834       btnCom batVet.Hei ght := Rou nd(pnlCVnF lag.Height  div 2);
  2835      end
  2836     else
  2837      begin
  2838       pnlCVn Flag.Width    := Roun d(FLAG_WID TH * MainF ontWidth);
  2839       pnlFla g.Width       := Roun d(FLAG_WID TH * MainF ontWidth);
  2840      end;
  2841     pnlRemot eData.Widt h := Round (CIRN_WIDT H * MainFo ntWidth) +  M_WVERT;
  2842     pnlVista Web.Height  := pnlRem oteData.He ight div 2 ;
  2843     paVAA.Wi dth         := Round( MHV_WIDTH  * MainFont Width) + M _WVERT + 2 ;
  2844     with lbl PtPostings  do
  2845       SetBou nds(M_WVER T, M_HORIZ , pnlPosti ngs.Width- M_WVERT-M_ WVERT, lbl PtName.Hei ght);
  2846     with lbl PtCWAD      do
  2847       SetBou nds(M_WVER T, lblPtSS N.Top, lbl PtPostings .Width, lb lPtName.He ight);
  2848     //Low re solution h andling: F irst, try  to fit eve rything on  by shrink ing fields
  2849     if pnlPr imaryCare. Width < Hi gherOf( lb lPtCare.Le ft + lblPt Care.Width , HigherOf (lblPtAtte nding.Left  + lblPtAt tending.Wi dth,lblPtM HTC.Left +  lblPtMHTC .Width)) +  TINY_MARG IN then
  2850     //if pnl PrimaryCar e.Width <  HigherOf(  lblPtCare. Left + lbl PtCare.Wid th, lblPtA ttending.L eft + lblP tAttending .Width) +  TINY_MARGI N then
  2851     begin
  2852       lblPtA ge.Left :=  lblPtAge. Left - (lb lPtName.Le ft - TINY_ MARGIN);
  2853       lblPtN ame.Left : = TINY_MAR GIN;
  2854       lblPTS SN.Left :=  TINY_MARG IN;
  2855       pnlPat ient.Width  := Higher Of( lblPtN ame.Left +  lblPtName .Width, lb lPtAge.Lef t + lblPtA ge.Width)+  TINY_MARG IN;
  2856       lblPtL ocation.Le ft := TINY _MARGIN;
  2857       lblPtP rovider.Le ft := TINY _MARGIN;
  2858       pnlVis it.Width : = HigherOf ( lblPtLoc ation.Left  + lblPtLo cation.Wid th, lblPtP rovider.Le ft + lblPt Provider.W idth)+ TIN Y_MARGIN;
  2859     end;
  2860     HorzScro llBar.Rang e := 0;
  2861   end;
  2862  
  2863   { Temporar y Calls -- ---------- ---------- ---------- ---------- ---------- ---------- ---------- -- }
  2864  
  2865   procedure  TfrmFrame. ToggleMenu ItemChecke d(Sender:  TObject);
  2866   begin
  2867     TMenuIte m(Sender). Checked :=  not TMenu Item(Sende r).Checked ;
  2868   end;
  2869  
  2870   {--------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------}
  2871   {  mnuFocu sChangesCl ick - togg les the Fo cused Cont rols windo w for form s that sup port it  }
  2872   {--------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------}
  2873   procedure  TfrmFrame. mnuFocusCh angesClick (Sender: T Object);
  2874   begin
  2875     inherite d;
  2876     ShowFocu sedControl Dialog :=  mnuFocusCh anges.Chec ked;
  2877   end;
  2878  
  2879   procedure  TfrmFrame. mnuFontSiz eClick(Sen der: TObje ct);
  2880   begin
  2881     if (frmR emDlg <> n il) then
  2882       ShowMs g('Please  close the  reminder d ialog befo re changin g font siz es.')
  2883     else if  (dlgProbs  <> nil) th en
  2884       ShowMs g('Font si ze cannot  be changed  while add ing or edi ting a pro blem.')
  2885     else beg in
  2886       with ( Sender as  TMenuItem)  do begin
  2887         Togg leMenuItem Checked(Se nder);
  2888         fMed s.oldFont  := MainFon tSize; //C Q9182
  2889         Chan geFont(Tag );
  2890       end;
  2891     end;
  2892   end;
  2893  
  2894   procedure  TfrmFrame. mnuEditCli ck(Sender:  TObject);
  2895   var
  2896     IsReadOn ly: Boolea n;
  2897   begin
  2898     FEditCtr l := nil;
  2899     if Scree n.ActiveCo ntrol is T CustomEdit  then FEdi tCtrl := T CustomEdit (Screen.Ac tiveContro l);
  2900     if FEdit Ctrl <> ni l then beg in
  2901       if       FEditCtr l is TMemo      then  IsReadOnly  := TMemo( FEditCtrl) .ReadOnly
  2902       else i f FEditCtr l is TEdit      then  IsReadOnly  := TEdit( FEditCtrl) .ReadOnly
  2903       else i f FEditCtr l is TRich Edit then  IsReadOnly  := TRichE dit(FEditC trl).ReadO nly
  2904       else I sReadOnly  := True;
  2905  
  2906       mnuEdi tRedo.Enab led := FEd itCtrl.Per form(EM_CA NREDO, 0,  0) <> 0;
  2907       mnuEdi tUndo.Enab led := (FE ditCtrl.Pe rform(EM_C ANUNDO, 0,  0) <> 0)  and (FEdit Ctrl.Perfo rm(EM_CANR EDO, 0, 0)  = 0);
  2908  
  2909       mnuEdi tCut.Enabl ed := FEdi tCtrl.SelL ength > 0;
  2910       mnuEdi tCopy.Enab led := mnu EditCut.En abled;
  2911       mnuEdi tPaste.Ena bled := (I sReadOnly  = False) a nd Clipboa rd.HasForm at(CF_TEXT );
  2912     end else  begin
  2913       mnuEdi tUndo.Enab led  := Fa lse;
  2914       mnuEdi tCut.Enabl ed   := Fa lse;
  2915       mnuEdi tCopy.Enab led  := Fa lse;
  2916       mnuEdi tPaste.Ena bled := Fa lse;
  2917     end;
  2918   end;
  2919  
  2920   procedure  TfrmFrame. mnuEditUnd oClick(Sen der: TObje ct);
  2921   begin
  2922     FEditCtr l.Perform( EM_UNDO, 0 , 0);
  2923   end;
  2924  
  2925   procedure  TfrmFrame. mnuEditRed oClick(Sen der: TObje ct);
  2926   begin
  2927     FEditCtr l.Perform( EM_REDO, 0 , 0);
  2928   end;
  2929  
  2930  
  2931   procedure  TfrmFrame. mnuEditCut Click(Send er: TObjec t);
  2932   begin
  2933     FEditCtr l.CutToCli pboard;
  2934   end;
  2935  
  2936   procedure  TfrmFrame. mnuEditCop yClick(Sen der: TObje ct);
  2937   begin
  2938     FEditCtr l.CopyToCl ipboard;
  2939   end;
  2940  
  2941   procedure  TfrmFrame. mnuEditPas teClick(Se nder: TObj ect);
  2942   begin
  2943     FEditCtr l.PasteFro mClipboard ;  // use  AsText to  prevent fo rmatting f rom being  pasted
  2944   end;
  2945  
  2946   procedure  TfrmFrame. mnuFilePri ntClick(Se nder: TObj ect);
  2947   begin
  2948     case mnu FilePrint. Tag of
  2949     CT_NOTES :    frmNo tes.Reques tPrint;
  2950     CT_CONSU LTS: frmCo nsults.Req uestPrint;
  2951     CT_DCSUM M:   frmDC Summ.Reque stPrint;
  2952     CT_REPOR TS:  frmRe ports.Requ estPrint;
  2953     CT_LABS:      frmLa bs.Request Print;
  2954     CT_ORDER S:   frmOr ders.Reque stPrint;
  2955     CT_PROBL EMS: frmPr oblems.Req uestPrint;
  2956     CT_SURGE RY:  if As signed(frm Surgery) t hen frmSur gery.Reque stPrint;
  2957     end;
  2958   end;
  2959  
  2960   procedure  TfrmFrame. WMSysComma nd(var Mes sage: TMes sage);
  2961   begin
  2962     case Tab ToPageID(t abPage.Tab Index) of
  2963       CT_NOT ES:
  2964           if  Assigned( Screen.Act iveControl .Parent) a nd (Screen .ActiveCon trol.Paren t.Name = ' cboCosigne r') then
  2965              with Messa ge do
  2966                begin
  2967                  SendMe ssage(frmN otes.Handl e, Msg, WP aram, LPar am);
  2968                  Result  := 0;
  2969                end
  2970           el se
  2971              inherited;
  2972       CT_DCS UMM:
  2973           if  Assigned( Screen.Act iveControl .Parent) a nd (Screen .ActiveCon trol.Paren t.Name = ' cboAttendi ng') then
  2974              with Messa ge do
  2975                begin
  2976                  SendMe ssage(frmD CSumm.Hand le, Msg, W Param, lPa ram);
  2977                  Result  := 0;
  2978                end
  2979           el se
  2980              inherited;
  2981       CT_CON SULTS:
  2982           if  Assigned( Screen.Act iveControl .Parent) a nd (Screen .ActiveCon trol.Paren t.Name = ' cboCosigne r') then
  2983              with Messa ge do
  2984                begin
  2985                  SendMe ssage(frmC onsults.Ha ndle, Msg,  WParam, l Param);
  2986                  Result  := 0;
  2987                end
  2988           el se
  2989              inherited;
  2990     else
  2991       inheri ted;
  2992     end;
  2993     if Messa ge.WParam  = SC_MAXIM IZE then
  2994     begin
  2995       // for m becomes  maximized;
  2996       frmOrd ers.mnuOpt imizeField sClick(sel f);
  2997       frmPro blems.mnuO ptimizeFie ldsClick(s elf);
  2998       frmMed s.mnuOptim izeFieldsC lick(self) ;
  2999     end
  3000     else if  Message.WP aram = SC_ MINIMIZE t hen
  3001     begin
  3002       // for m becomes  maximized;
  3003     end
  3004     else if  Message.WP aram = SC_ RESTORE th en
  3005     begin
  3006       // for m is resto red (from  maximized) ;
  3007       frmOrd ers.mnuOpt imizeField sClick(sel f);
  3008       frmPro blems.mnuO ptimizeFie ldsClick(s elf);
  3009       frmMed s.mnuOptim izeFieldsC lick(self) ;
  3010     end;
  3011   end;
  3012  
  3013   procedure  TfrmFrame. RemindersC hanged(Sen der: TObje ct);
  3014   var
  3015     ImgName:  string;
  3016   begin
  3017     pnlRemin ders.tag : = HAVE_REM INDERS;
  3018     pnlRemin ders.Hint  := 'Click  to display  reminders ';
  3019     case Get ReminderSt atus of
  3020       rsUnkn own:
  3021         begi n
  3022           Im gName := ' BMP_REMIND ERS_UNKNOW N';
  3023           pn lReminders .Caption : = 'Reminde rs';
  3024         end;
  3025       rsDue:
  3026         begi n
  3027           Im gName := ' BMP_REMIND ERS_DUE';
  3028           pn lReminders .Caption : = 'Due Rem inders';
  3029         end;
  3030       rsAppl icable:
  3031         begi n
  3032           Im gName := ' BMP_REMIND ERS_APPLIC ABLE';
  3033           pn lReminders .Caption : = 'Applica ble Remind ers';
  3034         end;
  3035       rsNotA pplicable:
  3036         begi n
  3037           Im gName := ' BMP_REMIND ERS_OTHER' ;
  3038           pn lReminders .Caption : = 'Other R eminders';
  3039         end;
  3040       else
  3041         begi n
  3042           Im gName := ' BMP_REMIND ERS_NONE';
  3043           pn lReminders .Hint := ' There are  currently  no reminde rs availab le';
  3044           pn lReminders .Caption : = pnlRemin ders.Hint;
  3045           pn lReminders .tag := NO _REMINDERS ;
  3046         end;
  3047     end;
  3048     if(Remin dersEvalua tingInBack ground) th en
  3049     begin
  3050       if(anm tRemSearch .ResName =  '') then
  3051       begin
  3052         TORE xposedAnim ate(anmtRe mSearch).O nMouseDown  := pnlRem indersMous eDown;
  3053         TORE xposedAnim ate(anmtRe mSearch).O nMouseUp    := pnlRem indersMous eUp;
  3054         anmt RemSearch. ResHandle  := 0;
  3055         anmt RemSearch. ResName :=  'REMSEARC HAVI';
  3056       end;
  3057       imgRem inder.Visi ble := FAL SE;
  3058       anmtRe mSearch.Ac tive := TR UE;
  3059       anmtRe mSearch.Vi sible := T RUE;
  3060       if(pnl Reminders. Hint <> '' ) then
  3061         pnlR eminders.H int := CRL F + pnlRem inders.Hin t + '.';
  3062       pnlRem inders.Hin t := 'Eval uating Rem inders...   ' + pnlRe minders.Hi nt;
  3063       pnlRem inders.Cap tion := pn lReminders .Hint;
  3064     end
  3065     else
  3066     begin
  3067       anmtRe mSearch.Vi sible := F ALSE;
  3068       imgRem inder.Visi ble := TRU E;
  3069       imgRem inder.Pict ure.Bitmap .LoadFromR esourceNam e(hInstanc e, ImgName );
  3070       anmtRe mSearch.Ac tive := FA LSE;
  3071     end;
  3072     mnuViewR eminders.E nabled :=  (pnlRemind ers.tag =  HAVE_REMIN DERS);
  3073   end;
  3074  
  3075   procedure  TfrmFrame. pnlReminde rsMouseDow n(Sender:  TObject;
  3076     Button:  TMouseButt on; Shift:  TShiftSta te; X, Y:  Integer);
  3077   begin
  3078     if(not I nitialRemi ndersLoade d) then
  3079       Startu pReminders ;
  3080     if(pnlRe minders.ta g = HAVE_R EMINDERS)  then
  3081       pnlRem inders.Bev elOuter :=  bvLowered ;
  3082   end;
  3083  
  3084   procedure  TfrmFrame. pnlReminde rsMouseUp( Sender: TO bject;
  3085     Button:  TMouseButt on; Shift:  TShiftSta te; X, Y:  Integer);
  3086   begin
  3087     pnlRemin ders.Bevel Outer := b vRaised;
  3088     if(pnlRe minders.ta g = HAVE_R EMINDERS)  then
  3089       ViewIn fo(mnuView Reminders) ;
  3090   end;
  3091  
  3092   //-------- ---------- --- CIRN-r elated pro cedures -- ---------- ---------- ----------
  3093  
  3094   procedure  TfrmFrame. SetUpCIRN;
  3095   var
  3096     i: integ er;
  3097     iNwHIN,  iRDVOnly:  integer;
  3098     aAutoQue ry,aVistaW ebLabel: s tring;
  3099     ASite: T RemoteSite ;
  3100     item: TV A508Access ibilityIte m;
  3101     id: inte ger;
  3102   begin
  3103     uUseVist aWeb := fa lse;
  3104     with Rem oteSites d o
  3105     begin
  3106       Change Patient(Pa tient.DFN) ;
  3107       lblCIR N.Caption  := ' Remot e Data';
  3108       lblCIR N.Alignmen t := taCen ter;
  3109       aVista WebLabel : = GetVista Web_JLV_La belName;
  3110       if aVi staWebLabe l = '' the n aVistaWe bLabel :=  'VistaWeb' ;
  3111       lblVis taWeb.Capt ion := aVi staWebLabe l;
  3112       pnlVis taWeb.Beve lOuter :=  bvRaised;
  3113       iNwHIN  := 0;
  3114       iRDVOn ly := 0;
  3115       for i  := 0 to Re moteSites. Count - 1  do
  3116         begi n
  3117           if  not(LeftS tr(TRemote Site(Remot eSites.Sit eList.Item s[i]).Site ID, 4) = ' 200N') the n
  3118              begin
  3119                iRDVOnly  := 1;
  3120                continue ;
  3121              end
  3122           el se
  3123              iNwHIN :=  1;
  3124         end;
  3125  
  3126       if Rem oteDataExi sts and (( iRDVOnly =  1) or (iN wHIN = 1))  and (Remo teSites.Co unt > 0) t hen
  3127         begi n
  3128           if  ScreenRea derSystemA ctive then
  3129           be gin
  3130            i tem := amg rMain.Acce ssData.Fin dItem(pnlR emoteData,  False);
  3131            i d:= item.I NDEX;
  3132            a mgrMain.Ac cessData[i d].AccessT ext := '';
  3133           en d;
  3134           lb lCIRN.Enab led     :=  True;
  3135           pn lCIRN.TabS top     :=  True;
  3136           lb lCIRN.Font .Color  :=  Get508Com pliantColo r(clBlue);
  3137           ls tCIRNLocat ions.Font. Color  :=  Get508Comp liantColor (clBlue);
  3138           lb lCIRN.Capt ion := 'Re mote Data' ;
  3139           pn lCIRN.Hint  := 'Click  to displa y other fa cilities h aving data  for this  patient.';
  3140           lb lVistaWeb. Font.Color  := Get508 CompliantC olor(clBlu e);
  3141           pn lVistaWeb. Hint := 'C lick to go  to VistaW eb to see  data from  other faci lities for  this pati ent.';
  3142           if  RemoteSit es.Count >  0 then
  3143              lstCIRNLoc ations.Ite ms.Add('0'  + U + 'Al l Availabl e Sites');
  3144           fo r i := 0 t o RemoteSi tes.Count  - 1 do
  3145              begin
  3146                ASite :=  TRemoteSi te(SiteLis t[i]);
  3147                lstCIRNL ocations.I tems.Add(A Site.SiteI D + U + AS ite.SiteNa me + U +
  3148                  Format FMDateTime ('mmm dd y yyy hh:nn' , ASite.La stDate));
  3149              end;
  3150         end
  3151       else
  3152         begi n
  3153           if  ScreenRea derSystemA ctive then
  3154           be gin
  3155            i tem := amg rMain.Acce ssData.Fin dItem(pnlR emoteData,  False);
  3156            i d:= item.I NDEX;
  3157            a mgrMain.Ac cessData[i d].AccessT ext := 'No  remote da ta availab le';
  3158           en d;
  3159           lb lCIRN.Font .Color  :=  clWindowT ext;
  3160           lb lVistaWeb. Font.Color  := clWind owText;
  3161           lb lCIRN.Enab led     :=  False;
  3162           pn lCIRN.TabS top     :=  False;
  3163           pn lCIRN.Hint  := NoData Reason;
  3164           if  (iNwHIN =  1) and (i RDVOnly =  0) then
  3165              begin
  3166               lblVistaW eb.Font.Co lor := Get 508Complia ntColor(cl Blue);
  3167               pnlVistaW eb.Hint :=  'Click to  go to Vis taWeb to s ee data fr om other f acilities  for this p atient (in cludes Non -VA data). ';
  3168              end;
  3169         end;
  3170       aAutoQ uery := Au toRDV;         //Chec k to see i f Remote Q ueries sho uld be use d for all  available  sites
  3171       if (aA utoQuery =  '1') and  (lstCIRNLo cations.Co unt > 0) t hen
  3172         begi n
  3173           ls tCIRNLocat ions.ItemI ndex := 0;
  3174           ls tCIRNLocat ions.Check ed[0] := t rue;
  3175           ls tCIRNLocat ionsClick( self);
  3176         end;
  3177     end;
  3178   end;
  3179  
  3180   procedure  TfrmFrame. paVAAResiz e(Sender:  TObject);
  3181   begin
  3182     laMHV.He ight := pa VAA.Client Height div  2;
  3183   end;
  3184  
  3185   procedure  TfrmFrame. pnlCIRNCli ck(Sender:  TObject);
  3186   begin
  3187     ViewInfo (mnuViewRe moteData);
  3188   end;
  3189  
  3190   procedure  TfrmFrame. lstCIRNLoc ationsClic k(Sender:  TObject);
  3191   var
  3192     iIndex,j ,iAll,iCur : integer;
  3193     aMsg,s:  string;
  3194     AccessSt atus: inte ger;
  3195   begin
  3196     iAll :=  1;
  3197     AccessSt atus := 0;
  3198     iIndex : = lstCIRNL ocations.I temIndex;
  3199     if not C heckHL7TCP Link then
  3200       begin
  3201         Info Box('Local  HL7 TCP L ink is dow n.' + CRLF  + 'Unable  to retrie ve remote  data.', TC _DGSR_ERR,  MB_OK);
  3202         lstC IRNLocatio ns.Checked [iIndex] : = false;
  3203         Exit ;
  3204       end;
  3205     if lstCI RNLocation s.Items.Co unt > 1 th en
  3206       if pie ce(lstCIRN Locations. Items[1],' ^',1) = '0 ' then
  3207         iAll  := 2;
  3208     with frm Reports do
  3209       if pie ce(uRemote Type,'^',2 ) = 'V' th en
  3210         begi n
  3211           lv Reports.It ems.BeginU pdate;
  3212           lv Reports.It ems.Clear;
  3213           lv Reports.Co lumns.Clea r;
  3214           lv Reports.It ems.EndUpd ate;
  3215         end;
  3216     uReportI nstruction  := '';
  3217     frmRepor ts.TabCont rol1.Tabs. Clear;
  3218     frmLabs. TabControl 1.Tabs.Cle ar;
  3219     frmRepor ts.TabCont rol1.Tabs. AddObject( 'Local',ni l);
  3220     frmLabs. TabControl 1.Tabs.Add Object('Lo cal',nil);
  3221     StatusTe xt('Checki ng Remote  Sites...') ;
  3222     if piece (lstCIRNLo cations.It ems[iIndex ],'^',1) =  '0' then  // All sit es have be en clicked
  3223       if lst CIRNLocati ons.Checke d[iIndex]  = false th en // All  selection  is being t urned off
  3224         begi n
  3225           wi th RemoteS ites.SiteL ist do
  3226           fo r j := 0 t o Count -  1 do
  3227              if lstCIRN Locations. Checked[j+ 1] = true  then
  3228                begin
  3229                  lstCIR NLocations .Checked[j +1] := fal se;
  3230                  TRemot eSite(Remo teSites.Si teList[j]) .Selected  := false;
  3231                  TRemot eSite(Remo teSites.Si teList[j]) .ReportCle ar;
  3232                  TRemot eSite(Remo teSites.Si teList[j]) .LabClear;
  3233                end;
  3234         end
  3235       else
  3236         begi n
  3237           wi th RemoteS ites.SiteL ist do
  3238           fo r j := 0 t o Count -  1 do
  3239                begin
  3240                  Screen .Cursor :=  crHourGla ss;
  3241                  Screen .Cursor :=  crDefault ;
  3242                  aMsg : = aMsg + '  at site:  ' + TRemot eSite(Item s[j]).Site Name;
  3243                  s := l stCIRNLoca tions.Item s[j+1];
  3244                  lstCIR NLocations .Items[j+1 ] := piece s(s, '^',  1, 3);
  3245                  case A ccessStatu s of
  3246                  DGSR_F AIL: begin
  3247                                if  piece(aMsg ,':',1) =  'RPC name  not found  at site' t hen //Allo w for back ward compa tibility
  3248                                  b egin
  3249                                     lstCIRNLo cations.Ch ecked[j+1]  := true;
  3250                                     TRemoteSi te(RemoteS ites.SiteL ist[j]).Re portClear;
  3251                                     TRemoteSi te(RemoteS ites.SiteL ist[j]).La bClear;
  3252                                     TRemoteSi te(Items[j ]).Selecte d := true;
  3253                                  e nd
  3254                                els e
  3255                                  b egin
  3256                                     InfoBox(a Msg, TC_DG SR_ERR, MB _OK);
  3257                                     lstCIRNLo cations.Ch ecked[j+1]  := false;
  3258                                     lstCIRNLo cations.It ems[j+1] : = pieces(s , '^', 1,  3) + '^' +  TC_DGSR_E RR;
  3259                                     TRemoteSi te(Items[j ]).Selecte d := false ;
  3260                                     Continue;
  3261                                  e nd;
  3262                              end;
  3263                  DGSR_N ONE: begin
  3264                                lst CIRNLocati ons.Checke d[j+1] :=  true;
  3265                                TRe moteSite(R emoteSites .SiteList[ j]).Report Clear;
  3266                                TRe moteSite(R emoteSites .SiteList[ j]).LabCle ar;
  3267                                TRe moteSite(I tems[j]).S elected :=  true;
  3268                              end;
  3269                  DGSR_S HOW: begin
  3270                                Inf oBox(AMsg,  TC_DGSR_S HOW, MB_OK );
  3271                                lst CIRNLocati ons.Checke d[j+1] :=  true;
  3272                                TRe moteSite(R emoteSites .SiteList[ j]).Report Clear;
  3273                                TRe moteSite(R emoteSites .SiteList[ j]).LabCle ar;
  3274                                TRe moteSite(I tems[j]).S elected :=  true;
  3275                              end;
  3276                  DGSR_A SK:  if In foBox(AMsg  + TX_DGSR _YESNO, TC _DGSR_SHOW , MB_YESNO  or MB_ICO NWARNING o r
  3277                                MB_ DEFBUTTON2 ) = IDYES  then
  3278                                beg in
  3279                                  l stCIRNLoca tions.Chec ked[j+1] : = true;
  3280                                  T RemoteSite (RemoteSit es.SiteLis t[j]).Repo rtClear;
  3281                                  T RemoteSite (RemoteSit es.SiteLis t[j]).LabC lear;
  3282                                  T RemoteSite (Items[j]) .Selected  := true;
  3283                                end
  3284                                els e
  3285                                  b egin
  3286                                     lstCIRNLo cations.Ch ecked[j+1]  := false;
  3287                                     lstCIRNLo cations.It ems[j+1] : = pieces(s , '^', 1,  3) + '^' +  TC_DGSR_S HOW;
  3288                                     TRemoteSi te(Items[j ]).Selecte d := false ;
  3289                                     Continue;
  3290                                  e nd;
  3291                  else        begin
  3292                                Inf oBox(AMsg,  TC_DGSR_D ENY, MB_OK );
  3293                                lst CIRNLocati ons.Checke d[j+1] :=  false;
  3294                                lst CIRNLocati ons.Items[ j+1] := pi eces(s, '^ ', 1, 3) +  '^' + TC_ DGSR_DENY;
  3295                                TRe moteSite(I tems[j]).S elected :=  false;
  3296                                Con tinue;
  3297                              end;
  3298                  end;
  3299                end;
  3300         end
  3301     else
  3302       begin
  3303         if i Index > 0  then
  3304           be gin
  3305              iCur := iI ndex - iAl l;
  3306              TRemoteSit e(RemoteSi tes.SiteLi st[iCur]). Selected : =
  3307                lstCIRNL ocations.C hecked[iIn dex];
  3308              if lstCIRN Locations. Checked[iI ndex] = tr ue then
  3309                with Rem oteSites.S iteList do
  3310                begin
  3311                  Screen .Cursor :=  crHourGla ss;
  3312                  Screen .Cursor :=  crDefault ;
  3313                  aMsg : = aMsg + '  at site:  ' + TRemot eSite(Item s[iCur]).S iteName;
  3314                  s := l stCIRNLoca tions.Item s[iIndex];
  3315                  lstCIR NLocations .Items[iIn dex] := pi eces(s, '^ ', 1, 3);
  3316                  case A ccessStatu s of
  3317                  DGSR_F AIL: begin
  3318                                if  piece(aMsg ,':',1) =  'RPC name  not found  at site' t hen //Allo w for back ward compa tibility
  3319                                  b egin
  3320                                     lstCIRNLo cations.Ch ecked[iInd ex] := tru e;
  3321                                     TRemoteSi te(RemoteS ites.SiteL ist[iCur]) .ReportCle ar;
  3322                                     TRemoteSi te(RemoteS ites.SiteL ist[iCur]) .LabClear;
  3323                                     TRemoteSi te(Items[i Cur]).Sele cted := tr ue;
  3324                                  e nd
  3325                                els e
  3326                                  b egin
  3327                                     InfoBox(a Msg, TC_DG SR_ERR, MB _OK);
  3328                                     lstCIRNLo cations.Ch ecked[iInd ex] := fal se;
  3329                                     lstCIRNLo cations.It ems[iIndex ] := piece s(s, '^',  1, 3) + '^ ' + TC_DGS R_ERR;
  3330                                     TRemoteSi te(Items[i Cur]).Sele cted := fa lse;
  3331                                  e nd;
  3332                              end;
  3333                  DGSR_N ONE: begin
  3334                                lst CIRNLocati ons.Checke d[iIndex]  := true;
  3335                                TRe moteSite(R emoteSites .SiteList[ iCur]).Rep ortClear;
  3336                                TRe moteSite(R emoteSites .SiteList[ iCur]).Lab Clear;
  3337                                TRe moteSite(I tems[iCur] ).Selected  := true;
  3338                              end;
  3339                  DGSR_S HOW: begin
  3340                                Inf oBox(AMsg,  TC_DGSR_S HOW, MB_OK );
  3341                                lst CIRNLocati ons.Checke d[iIndex]  := true;
  3342                                TRe moteSite(R emoteSites .SiteList[ iCur]).Rep ortClear;
  3343                                TRe moteSite(R emoteSites .SiteList[ iCur]).Lab Clear;
  3344                                TRe moteSite(I tems[iCur] ).Selected  := true;
  3345                              end;
  3346                  DGSR_A SK:  if In foBox(AMsg  + TX_DGSR _YESNO, TC _DGSR_SHOW , MB_YESNO  or MB_ICO NWARNING o r
  3347                                MB_ DEFBUTTON2 ) = IDYES  then
  3348                                beg in
  3349                                  l stCIRNLoca tions.Chec ked[iIndex ] := true;
  3350                                  T RemoteSite (RemoteSit es.SiteLis t[iCur]).R eportClear ;
  3351                                  T RemoteSite (RemoteSit es.SiteLis t[iCur]).L abClear;
  3352                                  T RemoteSite (Items[iCu r]).Select ed := true ;
  3353                                end
  3354                                els e
  3355                                  b egin
  3356                                     lstCIRNLo cations.Ch ecked[iInd ex] := fal se;
  3357                                     lstCIRNLo cations.It ems[iIndex ] := piece s(s, '^',  1, 3) + '^ ' + TC_DGS R_SHOW;
  3358                                  e nd;
  3359                  else        begin
  3360                                Inf oBox(AMsg,  TC_DGSR_D ENY, MB_OK );
  3361                                lst CIRNLocati ons.Checke d[iIndex]  := false;
  3362                                lst CIRNLocati ons.Items[ iIndex] :=  pieces(s,  '^', 1, 3 ) + '^' +  TC_DGSR_DE NY;
  3363                                TRe moteSite(I tems[iCur] ).Selected  := false;
  3364                              end;
  3365                  end;
  3366                  with f rmReports  do
  3367                    if p iece(uRemo teType,'^' ,1) = '1'  then
  3368                      if  not(piece (uRemoteTy pe,'^',2)  = 'V') the n
  3369                         begin
  3370                           TabContr ol1.Visibl e := true;
  3371                           pnlRight Top.Height  := lblTit le.Height  + TabContr ol1.Height ;
  3372                         end;
  3373                  with f rmLabs do
  3374                    if p iece(uLabR emoteType, '^',1) = ' 1' then
  3375                      if  not(piece (uLabRemot eType,'^', 2) = 'V')  then
  3376                         begin
  3377                           TabContr ol1.Visibl e := true;
  3378                           pnlRight Top.Height  := lblTit le.Height  + TabContr ol1.Height ;
  3379                         end;
  3380                end;
  3381           en d;
  3382       end;
  3383     with Rem oteSites.S iteList do
  3384       for j  := 0 to Co unt - 1 do
  3385         if T RemoteSite (Items[j]) .Selected
  3386           an d (not(Lef tStr(TRemo teSite(Ite ms[j]).Sit eID ,4) =  '200N'))   then
  3387           be gin
  3388              frmReports .TabContro l1.Tabs.Ad dObject(TR emoteSite( Items[j]). SiteName,
  3389                TRemoteS ite(Items[ j]));
  3390              frmLabs.Ta bControl1. Tabs.AddOb ject(TRemo teSite(Ite ms[j]).Sit eName,
  3391                TRemoteS ite(Items[ j]));
  3392           en d;
  3393     if not(P iece(uRepo rtID,':',1 ) = 'OR_VW AL')
  3394       and no t(Piece(uR eportID,': ',1) = 'OR _VWRX')
  3395       and no t(Piece(uR eportID,': ',1) = 'OR _VWVS')
  3396       and (f rmReports. tvReports. SelectionC ount > 0)  then frmRe ports.tvRe portsClick (self);
  3397     if not(u LabRepID =  '6:GRAPH' ) and not( uLabRepID  = '5:WORKS HEET')
  3398       and no t(uLabRepI D = '4:SEL ECTED TEST S BY DATE' )
  3399       and (f rmLabs.tvR eports.Sel ectionCoun t > 0) the n frmLabs. tvReportsC lick(self) ;
  3400     StatusTe xt('');
  3401   end;
  3402  
  3403   procedure  TfrmFrame. popCIRNClo seClick(Se nder: TObj ect);
  3404   begin
  3405     lstCIRNL ocations.V isible :=  False;
  3406     lstCirnL ocations.S endToBack;
  3407     pnlCIRN. BevelOuter  := bvRais ed;
  3408   end;
  3409  
  3410   procedure  TfrmFrame. popCIRNSel ectAllClic k(Sender:  TObject);
  3411  
  3412   begin
  3413     lstCIRNL ocations.I temIndex : = 0;
  3414     lstCIRNL ocations.C hecked[0]  := true;
  3415     lstCIRNL ocations.O nClick(Sel f);
  3416   end;
  3417  
  3418   procedure  TfrmFrame. popCIRNSel ectNoneCli ck(Sender:  TObject);
  3419  
  3420   begin
  3421     lstCIRNL ocations.I temIndex : = 0;
  3422     lstCIRNL ocations.C hecked[0]  := false;
  3423     lstCIRNL ocations.O nClick(Sel f);
  3424   end;
  3425  
  3426   procedure  TfrmFrame. mnuFilePri ntSetupCli ck(Sender:  TObject);
  3427   var
  3428     CurrPrt:  string;
  3429   begin
  3430     CurrPrt  := SelectD evice(Self , Encounte r.Location , True, 'P rint Devic e Selectio n');
  3431     User.Cur rentPrinte r := Piece (CurrPrt,  U, 1);
  3432   end;
  3433  
  3434   procedure  TfrmFrame. LabInfo1Cl ick(Sender : TObject) ;
  3435   begin
  3436     ExecuteL abInfo;
  3437   end;
  3438  
  3439   procedure  TfrmFrame. mnuFileNot ifRemoveCl ick(Sender : TObject) ;
  3440   const
  3441     TC_REMOV E_ALERT  =  'Remove C urrent Ale rt';
  3442     TX_REMOV E_ALERT1 =  'This act ion will d elete the  alert you  are curren tly proces sing; the  alert will  ' + CRLF  +
  3443           'd isappear a utomatical ly when al l orders h ave been a cted on, b ut this ac tion may'  + CRLF +
  3444           'b e used to  remove the  alert if  some order s are to b e left unc hanged.' +  CRLF + CR LF +
  3445           'Y our ';
  3446     TX_REMOV E_ALERT2 =  ' alert f or ';
  3447     TX_REMOV E_ALERT3 =  ' will be  deleted!'  + CRLF +  CRLF + 'Ar e you sure ?';
  3448   var
  3449     AlertMsg , AlertTyp e: string;
  3450  
  3451     procedur e StopProc essingNoti fs;
  3452       begin
  3453         Noti fications. Clear;
  3454         FNex tButtonAct ive := Fal se;
  3455         stsA rea.Panels [2].Bevel  := pbLower ed;
  3456         mnuF ileNext.En abled := F alse;
  3457         mnuF ileNotifRe move.Enabl ed := Fals e;
  3458       end;
  3459  
  3460   begin
  3461     if not N otificatio ns.Active  then Exit;
  3462     case Not ifications .Followup  of
  3463       NF_MED ICATIONS_E XPIRING_IN PT    : Al ertType :=  'Expiring  Medicatio ns';
  3464       NF_MED ICATIONS_E XPIRING_OU TPT   : Al ertType :=  'Expiring  Medicatio ns';
  3465       NF_ORD ER_REQUIRE S_ELEC_SIG NATURE: Al ertType :=  'Unsigned  Orders';
  3466       NF_FLA GGED_ORDER S                : Al ertType :=  'Flagged  Orders (fo r clarific ation)';
  3467       NF_UNV ERIFIED_ME DICATION_O RDER  : Al ertType :=  'Unverifi ed Medicat ion Order' ;
  3468       NF_UNV ERIFIED_OR DER              : Al ertType :=  'Unverifi ed Order';
  3469       NF_FLA GGED_OI_EX P_INPT           : Al ertType :=  'Flagged  Orderable  Item (INPT )';
  3470       NF_FLA GGED_OI_EX P_OUTPT          : Al ertType :=  'Flagged  Orderable  Item (OUTP T)';
  3471     else
  3472       Exit;
  3473     end;
  3474     AlertMsg  := TX_REM OVE_ALERT1  + AlertTy pe + TX_RE MOVE_ALERT 2 + Patien t.Name + T X_REMOVE_A LERT3;
  3475     if InfoB ox(AlertMs g, TC_REMO VE_ALERT,  MB_YESNO)  = ID_YES t hen
  3476       begin
  3477         Noti fications. DeleteForC urrentUser ;
  3478         Noti fications. Next;   //  avoid pro mpt if no  more alert s selected  to proces s  {v14a R V}
  3479         if N otificatio ns.Active  then
  3480           be gin
  3481              if (InfoBo x(TX_NOTIF _STOP, TC_ NOTIF_STOP , MB_YESNO ) = ID_NO)  then
  3482                begin
  3483                  Notifi cations.Pr ior;
  3484                  mnuFil eNextClick (Self);
  3485                end
  3486              else
  3487                StopProc essingNoti fs;
  3488           en d
  3489         else
  3490           St opProcessi ngNotifs;
  3491       end;
  3492   end;
  3493  
  3494   procedure  TfrmFrame. mnuToolsOp tionsClick (Sender: T Object);
  3495   // persona l preferen ces - chan ges may ne ed to be a pplied to  chart
  3496   var
  3497     i: integ er;
  3498   begin
  3499     i := 0;
  3500     DialogOp tions(i);
  3501   end;
  3502  
  3503   procedure  TfrmFrame. LoadUserPr eferences;
  3504   begin
  3505     LoadSize sForUser;
  3506     GetUserT emplateDef aults(TRUE );
  3507   end;
  3508  
  3509   procedure  TfrmFrame. SaveUserPr eferences;
  3510   begin
  3511     SaveSize sForUser;          //  position  & size set tings
  3512     SaveUser TemplateDe faults;
  3513   end;
  3514  
  3515   procedure  TfrmFrame. mnuFileRef reshClick( Sender: TO bject);
  3516   begin
  3517     FRefresh ing := TRU E;
  3518     try
  3519       mnuFil eOpenClick (Self);
  3520     finally
  3521       FRefre shing := F ALSE;
  3522       OrderP rintForm : = FALSE;
  3523     end;
  3524   end;
  3525  
  3526   procedure  TfrmFrame. AppActivat ed(Sender:  TObject);
  3527   begin
  3528     if assig ned(FOldAc tivate) th en
  3529       FOldAc tivate(Sen der);
  3530     SetActiv eWindow(Ap plication. Handle);
  3531     if Scree nReaderSys temActive  and assign ed(Patient ) and (Pat ient.Name  <> '') and  (Patient. Status <>  '') then
  3532         Spea kTabAndPat ient;
  3533   end;
  3534  
  3535   // close T reatment F actor hint  window if  alt-tab p ressed.
  3536   procedure  TfrmFrame. AppDeActiv ated(Sende r: TObject );
  3537   begin
  3538     if FRVTF hintWindow Active the n
  3539     begin
  3540        FRVTF HintWindow .ReleaseHa ndle;
  3541        FRVTF HintWindow Active :=  False;
  3542     end
  3543     else
  3544     if FOSTF HintWndAct ive then
  3545     begin
  3546        FOSTF hintWindow .ReleaseHa ndle;
  3547        FOSTF HintWndAct ive := Fal se ;
  3548     end;
  3549     if FHint WinActive  then   //  graphing -  hints on  values
  3550     begin
  3551       FHintW in.Release Handle;
  3552       FHintW inActive : = false;
  3553     end;
  3554   end;
  3555  
  3556   procedure  TfrmFrame. LoadBuffer (Sender: T Object; Lo adList: TS trings; va r ProcessL oad: Boole an);
  3557   Var
  3558     IPAddr:  string;
  3559   begin
  3560     inherite d;
  3561       //Load  the buffe r
  3562    CPAppMon. UserDuz :=  User.DUZ;  //Current  User's DU Z
  3563    IPAddr :=  DottedIPS tr;
  3564    CallVistA ('ORWTIU P OLL', [Use r.DUZ, IPA ddr, IntTo Hex(frmFra me.Handle,  8)], Load List);
  3565    if Piece( LoadList.V alues['(0, 0)'], '^',  1) = '-1'  then
  3566    begin
  3567     ProcessL oad := fal se;
  3568     CPAppMon .StopTheBu ffer;
  3569    end else
  3570     ProcessL oad := tru e;
  3571   end;
  3572  
  3573   procedure  TfrmFrame. LoadProper ties(Sende r: TObject );
  3574   Var
  3575    SavedStyl es, DivID,  WrdRet, T mp: String ;
  3576   begin
  3577     //Load t he paramet ers
  3578     with CPA ppMon do b egin
  3579      //Check  if the bu ffer has a lread load ed
  3580      DivID : = GetDivis ionID;
  3581      CallVis tA('ORWTIU  WRDCOPY',  [DivID],W rdRet);
  3582      NumberO fWordsToBe gin := Str ToFloatDef (Piece(Wrd Ret, '^',  1), 0);
  3583  
  3584      CallVis tA('ORWTIU  PCTCOPY',  [DivID],  Tmp);
  3585      Percent ToVerify : = (StrToFl oatDef(Tmp , 0) * 100 );
  3586  
  3587      //Is su per user?
  3588      CallVis tA('ORWTIU  VIEWCOPY' , [User.DU Z, 0, DivI d], Tmp);
  3589      SuperUs er := Trim (Tmp) = '2 ';
  3590  
  3591      //load  the exlcud ed apps
  3592      GetUser ListParam( ExcludeApp s, 'ORQQTI U COPY/PAS TE EXCLUDE  APP');
  3593  
  3594      //load  the match  text prope rties
  3595      CallVis tA('ORWTIU  LDCPIDNT' , [nil], S avedStyles );
  3596  
  3597      Display Paste := T rim(SavedS tyles) <>  '-1;Visual  Disable O verride';
  3598      CPAppMo n.Enabled  := Trim(Sa vedStyles)  <> '-2';
  3599  
  3600      if Disp layPaste a nd CPAppMo n.Enabled  then begin
  3601       if Sav edStyles < > '' then  begin
  3602        if (P iece(Saved Styles, ', ', 1) = '1 ') then
  3603         Matc hStyle :=  MatchStyle  + [fsBold ];
  3604        if (P iece(Saved Styles, ', ', 2) = '1 ') then
  3605         Matc hStyle :=  MatchStyle  + [fsItal ic];
  3606        if (P iece(Saved Styles, ', ', 3) = '1 ') then
  3607         Matc hStyle :=  MatchStyle  + [fsUnde rline];
  3608  
  3609        Match Highlight  :=  (Piece (SavedStyl es, ',', 4 ) = '1');
  3610        Highl ightColor  := StrToIn tDef(Piece (SavedStyl es, ',', 5 ), clYello w);
  3611  
  3612        //LCS
  3613        LCSTo ggle := (P iece(Saved Styles, ', ', 6) = '1 ');
  3614        if (P iece(Saved Styles, ', ', 7) = '1 ') then
  3615         LCST extStyle : = LCSTextS tyle + [fs Bold];
  3616        if (P iece(Saved Styles, ', ', 8) = '1 ') then
  3617         LCST extStyle : = LCSTextS tyle + [fs Italic];
  3618        if (P iece(Saved Styles, ', ', 9) = '1 ') then
  3619         LCST extStyle : = LCSTextS tyle + [fs Underline] ;
  3620  
  3621        LCSUs eColor :=   (Piece(Sa vedStyles,  ',', 10)  = '1');
  3622        LCSTe xtColor :=  StrToIntD ef(Piece(S avedStyles , ',', 11) , clRed);
  3623        LCSCh arLimit :=  StrToIntD ef(Piece(S avedStyles , ',', 12) , 0)
  3624       end;
  3625      end;
  3626  
  3627     end;
  3628   end;
  3629  
  3630   procedure  TfrmFrame. SaveBuffer (Sender: T Object; Sa veList: TS tringList;
  3631     var Retu rnList: TS tringList) ;
  3632   var
  3633     I, X, Z,  TotalBuff er, LineCn t, SubLine Cnt: Integ er;
  3634     Division ID, aName,  aValue: s tring;
  3635     aList: i ORNetMult;
  3636     LookUpLs t: THashed StringList ;
  3637   begin
  3638     inherite d;
  3639     TotalBuf fer := Str ToIntDef(S aveList.Va lues['Tota lBufferToS ave'], -1) ;
  3640     Division ID := GetD ivisionID;
  3641     If Total Buffer > - 1 then
  3642     begin
  3643       LookUp Lst := THa shedString List.Creat e;
  3644       try
  3645         Look UpLst.Begi nUpdate;
  3646         Look UpLst.Assi gn(SaveLis t);
  3647         Look UpLst.EndU pdate;
  3648  
  3649         newo rNetMult(a List);
  3650  
  3651         for  I := 1 to  TotalBuffe r do
  3652         begi n
  3653           aL ist.AddSub script([I,  0], LookU pLst.Value s[IntToStr (I) + ',0' ]);
  3654  
  3655           Li neCnt := S trToIntDef (LookUpLst .Values[In tToStr(I)  + ',-1'],  -1);
  3656           fo r X := 1 t o LineCnt  - 1 do
  3657           be gin
  3658              SubLineCnt  :=
  3659                StrToInt Def(LookUp Lst.Values [IntToStr( I) + ',' +  IntToStr( X + 1) +
  3660                ',-1'],  -1);
  3661              if SubLine Cnt > -1 t hen
  3662              begin
  3663                for Z :=  1 to SubL ineCnt - 1  do
  3664                begin
  3665                  aName  := IntToSt r(I) + ','  + IntToSt r(X) + ','  +
  3666                    IntT oStr(Z);
  3667                  aValue  := Filter edString(L ookUpLst.V alues[aNam e]);
  3668                  aList. AddSubscri pt([I,X,Z] , aValue);
  3669                end;
  3670              end
  3671              else
  3672              begin
  3673                aName :=  IntToStr( I) + ',' +  IntToStr( X);
  3674                aValue : = Filtered String(Loo kUpLst.Val ues[aName] );
  3675                aList.Ad dSubscript ([I,X], aV alue);
  3676              end;
  3677           en d;
  3678         end;
  3679  
  3680         Call VistA('ORW TIU SVCOPY ', [aList,  DivisionI D], Return List);
  3681       finall y
  3682         Look UpLst.Free ;
  3683       end;
  3684     end;
  3685   end;
  3686  
  3687   procedure  TfrmFrame. StartPollB uff(Sender : TObject;  var Error : Boolean) ;
  3688   Var
  3689    DivID, IP Addr, TmpR tn: string ;
  3690   begin
  3691     inherite d;
  3692     DivID :=  GetDivisi onID;
  3693     IPAddr : = DottedIP Str;
  3694     CallVist A('ORWTIU  START',  [ User.DUZ,  DivID, IPA ddr, IntTo Hex(frmFra me.Handle,  8)], TmpR tn);
  3695     Error :=  TmpRtn =  '0';
  3696   end;
  3697  
  3698   procedure  TfrmFrame. StopPollBu ff(Sender:  TObject;  var Error:  Boolean);
  3699   Var
  3700    IPAddr, T mpRtn: str ing;
  3701   begin
  3702     inherite d;
  3703     IPAddr : = DottedIP Str;
  3704     CallVist A('ORWTIU  STOP', [Us er.DUZ, IP Addr, IntT oHex(frmFr ame.Handle , 8)], Tmp Rtn);
  3705     Error :=  TmpRtn =  '0';
  3706   end;
  3707  
  3708   procedure  TfrmFrame. CreateTab( ATabID: in teger; ALa bel: strin g);
  3709   begin
  3710     //  old  comment -  try making  owner sel f (instead  of applic ation) to  see if sol ves TMenuI tem.Insert  bug
  3711     case ATa bID of
  3712       CT_PRO BLEMS : be gin
  3713                         frmProblem s := TfrmP roblems.Cr eate(Self) ;
  3714                         frmProblem s.Parent : = pnlPage;
  3715                      en d;
  3716       CT_MED S     : be gin
  3717                         frmMeds :=  TfrmMeds. Create(Sel f);
  3718                         frmMeds.Pa rent := pn lPage;
  3719                         frmMeds.In itfMedsSiz e;
  3720                      en d;
  3721       CT_ORD ERS   : be gin
  3722                         frmOrders  := TfrmOrd ers.Create (Self);
  3723                         frmOrders. Parent :=  pnlPage;
  3724                      en d;
  3725       CT_HP        : be gin
  3726                         // not yet
  3727                      en d;
  3728       CT_NOT ES    : be gin
  3729                         frmNotes : = TfrmNote s.Create(S elf);
  3730                         frmNotes.P arent := p nlPage;
  3731                      en d;
  3732       CT_CON SULTS : be gin
  3733                         frmConsult s := TfrmC onsults.Cr eate(Self) ;
  3734                         frmConsult s.Parent : = pnlPage;
  3735                      en d;
  3736       CT_DCS UMM   : be gin
  3737                         frmDCSumm  := TfrmDCS umm.Create (Self);
  3738                         frmDCSumm. Parent :=  pnlPage;
  3739                      en d;
  3740       CT_LAB S     : be gin
  3741                         frmLabs :=  TfrmLabs. Create(Sel f);
  3742                         frmLabs.Pa rent := pn lPage;
  3743                      en d;
  3744       CT_REP ORTS  : be gin
  3745                         frmReports  := TfrmRe ports.Crea te(Self);
  3746                         frmReports .Parent :=  pnlPage;
  3747                      en d;
  3748       CT_SUR GERY  : be gin
  3749                         frmSurgery  := TfrmSu rgery.Crea te(Self);
  3750                         frmSurgery .Parent :=  pnlPage;
  3751                      en d;
  3752       CT_COV ER    : be gin
  3753                         frmCoverSh eet := Tfr mCoverShee t.Create(S elf);
  3754                         frmCoverSh eet.Parent  := pnlPag e;
  3755                         CoverSheet .OnRefresh CWAD := Re freshCWAD;
  3756                         CoverSheet .OnRefresh Reminders  := Reminde rsChanged;
  3757                      en d;
  3758     else
  3759       Exit;
  3760     end;
  3761     if ATabI D = CT_COV ER then
  3762       begin
  3763         uTab List.Inser t(0, IntTo Str(ATabID ));
  3764         tabP age.Tabs.I nsert(0, A Label);
  3765         tabP age.TabInd ex := 0;
  3766       end
  3767     else
  3768       begin
  3769         uTab List.Add(I ntToStr(AT abID));
  3770         tabP age.Tabs.A dd(ALabel) ;
  3771       end;
  3772   end;
  3773  
  3774   procedure  TfrmFrame. ShowHideCh artTabMenu s(AMenuIte m: TMenuIt em);
  3775   var
  3776     i: integ er;
  3777   begin
  3778     for i :=  0 to AMen uItem.Coun t - 1 do
  3779       AMenuI tem.Items[ i].Visible  := TabExi sts(AMenuI tem.Items[ i].Tag);
  3780   end;
  3781  
  3782   function T frmFrame.T abExists(A TabID: int eger): boo lean;
  3783   begin
  3784     Result : = (uTabLis t.IndexOf( IntToStr(A TabID)) >  -1)
  3785   end;
  3786  
  3787   procedure  TfrmFrame. ReportsOnl yDisplay;
  3788   begin
  3789  
  3790   // Configu re "Edit"  menu:
  3791   menuHideAl lBut(mnuEd it, mnuEdi tPref);      // Hide  everything  under Edi t menu exc ept Prefer ences.
  3792   menuHideAl lBut(mnuEd itPref, Pr efs1); //  Hide every thing unde r Preferen ces menu e xcept Font s.
  3793  
  3794   // Remaini ng pull-do wn menus:
  3795   mnuView.vi sible := f alse;
  3796   mnuFileRef resh.visib le := fals e;
  3797   mnuFileEnc ounter.vis ible := fa lse;
  3798   mnuFileRev iew.visibl e := false ;
  3799   mnuFileNex t.visible  := false;
  3800   mnuFileNot ifRemove.v isible :=  false;
  3801   mnuHelpBro ker.visibl e := false ;
  3802   mnuHelpLis ts.visible  := false;
  3803   mnuHelpSym bols.visib le := fals e;
  3804  
  3805   // Top pan el compone nts:
  3806   pnlVisit.h int := 'Pr ovider/Loc ation';
  3807   pnlVisit.o nMouseDown  := nil;
  3808   pnlVisit.o nMouseUp : = nil;
  3809  
  3810   // Forms f or other t abs:
  3811   frmCoverSh eet.visibl e := false ;
  3812   frmProblem s.visible  := false;
  3813   frmMeds.vi sible := f alse;
  3814   frmOrders. visible :=  false;
  3815   frmNotes.v isible :=  false;
  3816   frmConsult s.visible  := false;
  3817   frmDCSumm. visible :=  false;
  3818   if Assigne d(frmSurge ry) then
  3819     frmSurge ry.visible  := false;
  3820   frmLabs.vi sible := f alse;
  3821  
  3822   // Other t abs (so to  speak):
  3823   tabPage.ta bs.clear;
  3824   tabPage.ta bs.add('Re ports');
  3825  
  3826   end;
  3827  
  3828   procedure  TfrmFrame. UpdatePtIn foOnRefres h;
  3829   var
  3830     tmpDFN:  string;
  3831   begin
  3832     tmpDFN : = Patient. DFN;
  3833     Patient. Clear;
  3834     Patient. DFN := tmp DFN;
  3835     uCore.Te mpEncounte rLoc := 0;   //hds759 1  Clinic/ Ward movem ent.
  3836     uCore.Te mpEncounte rLocName : = ''; //hd s7591  Cli nic/Ward m ovement.
  3837     uCore.Te mpEncounte rText := ' ';
  3838     uCore.Te mpEncounte rDateTime  := 0;
  3839     uCore.Te mpEncounte rVistCat : = #0;
  3840     if (not  FRefreshin g) and (FR eviewClick  = false)  then DoNot ChangeEncW indow := f alse;
  3841     if (FPre vInPatient  and Patie nt.Inpatie nt) then                  //tran sfering in side hospi tal
  3842       begin
  3843              if FReview Click = Tr ue then
  3844                begin
  3845                  ucore. TempEncoun terLoc :=  Encounter. Location;
  3846                  uCore. TempEncoun terLocName  := Encoun ter.Locati onName;
  3847                  uCore. TempEncoun terText :=  Encounter .LocationT ext;
  3848                  uCore. TempEncoun terDateTim e := Encou nter.DateT ime;
  3849                  uCore. TempEncoun terVistCat  := Encoun ter.VisitC ategory;
  3850                end
  3851              else if (p atient.Loc ation <> e ncounter.L ocation) a nd (OrderP rintForm =  false) th en
  3852                    begi n
  3853                      fr mPrintLoca tion.Switc hEncounter Loction(En counter.Lo cation, En counter.lo cationName , Encounte r.Location Text,
  3854                                                                  En counter.Da teTime, En counter.Vi sitCategor y);
  3855                      Di splayEncou nterText;
  3856                      ex it;
  3857                    end
  3858              else if (p atient.Loc ation <> e ncounter.L ocation) a nd (OrderP rintForm =  True) the n
  3859                begin
  3860                  OrderP rintForm : = false;
  3861                  Exit;
  3862                end;
  3863              if orderpr intform =  false then  Encounter .Location  := Patient .Location;
  3864       end
  3865     else if  (FPrevInPa tient and  (not Patie nt.Inpatie nt)) then      //pati ent was di scharged
  3866     begin
  3867       Encoun ter.Inpati ent := Fal se;
  3868       Encoun ter.Locati on := 0;
  3869       FPrevI nPatient : = False;
  3870       lblPtN ame.Captio n := '';
  3871       lblPtN ame.Captio n := Patie nt.Name +  Patient.St atus; //CQ  #17491: R efresh pat ient statu s indicato r in heade r bar on d ischarge.
  3872     end
  3873     else if  ((not FPre vInPatient ) and Pati ent.Inpati ent) then      //pati ent was ad mitted
  3874     begin
  3875       Encoun ter.Inpati ent := Tru e;
  3876       uCore. TempEncoun terLoc :=  Encounter. Location;   //hds7591   Clinic/W ard moveme nt.
  3877       uCore. TempEncoun terLocName  := Encoun ter.Locati onName; // hds7591  C linic/Ward  movement.
  3878       uCore. TempEncoun terText :=  Encounter .LocationT ext;
  3879       uCore. TempEncoun terDateTim e := Encou nter.DateT ime;
  3880       uCore. TempEncoun terVistCat  := Encoun ter.VisitC ategory;
  3881       lblPtN ame.Captio n := '';
  3882       lblPtN ame.Captio n := Patie nt.Name +  Patient.St atus; //CQ  #17491: R efresh pat ient statu s indicato r in heade r bar on a dmission.
  3883       if (FR eviewClick  = False)  and (encou nter.Locat ion <> pat ient.Locat ion) and ( OrderPrint Form = fal se) then
  3884           be gin
  3885              frmPrintLo cation.Swi tchEncount erLoction( Encounter. Location,  Encounter. locationNa me, Encoun ter.Locati onText,
  3886                                                       En counter.Da teTime, En counter.Vi sitCategor y);
  3887              //agp valu es are res et dependi ng on the  user proce ss
  3888              uCore.Temp EncounterL oc := 0;   //hds7591   Clinic/Wa rd movemen t.
  3889              uCore.Temp EncounterL ocName :=  ''; //hds7 591  Clini c/Ward mov ement.
  3890              uCore.Temp EncounterT ext := '';
  3891              uCore.Temp EncounterD ateTime :=  0;
  3892              uCore.Temp EncounterV istCat :=  #0;
  3893           en d
  3894       else
  3895       if Ord erPrintFor m = false  then
  3896         begi n
  3897           En counter.Lo cation :=  Patient.Lo cation;
  3898           En counter.Da teTime :=  Patient.Ad mitTime;
  3899           En counter.Vi sitCategor y := 'H';
  3900         end;
  3901       FPrevI nPatient : = True;
  3902     end;
  3903     DisplayE ncounterTe xt;
  3904   end;
  3905  
  3906   procedure  TfrmFrame. UpdateVAAM HVButtons( Sender: TO bject);
  3907   begin
  3908     Patient. RefreshVAA Status;
  3909     Patient. RefreshMHV Status;
  3910  
  3911     if Patie nt.PtIsVAA  then
  3912       laVAA2 .Hint := ' Patient ha s active i nsurance'
  3913     else
  3914       laVAA2 .Hint := ' No active  insurance' ;
  3915  
  3916     if Patie nt.PtIsMHV  then
  3917       laMHV. Hint := 'P atient has  data in M y HealtheV et'
  3918     else
  3919       laMHV. Hint := 'N o MyHealth yVet data' ;
  3920  
  3921     laMHV.Al ign := alT op;
  3922     laMHV.He ight := pa VAA.Client Height div  2;
  3923     laVAA2.A lign := al Client;
  3924  
  3925     laMHV.En abled := P atient.PtI sMHV;
  3926     laVAA2.E nabled :=  Patient.Pt IsVAA;
  3927  
  3928     paVAA.Vi sible := ( Patient.Pt IsVAA or P atient.PtI sMHV);
  3929   end;
  3930  
  3931   procedure  TfrmFrame. FormKeyDow n(Sender:  TObject; v ar Key: Wo rd; Shift:  TShiftSta te);
  3932   var
  3933     NewTabIn dex: integ er;
  3934   begin
  3935     inherite d;
  3936     FCtrlTab Used := FA LSE;
  3937     //CQ2844 : Toggle R emote Data  button us ing Alt+R
  3938      case Ke y of
  3939        82,11 4:  if (ss Alt in Shi ft) then
  3940                     frm Frame.pnlC IRNClick(S ender);
  3941        end;
  3942  
  3943     if (Key  = VK_TAB)  then
  3944     begin
  3945       if (ss Ctrl in Sh ift) then
  3946       begin
  3947         FCtr lTabUsed : = TRUE;
  3948         if n ot (Active Control is  TCustomMe mo) or not  TMemo(Act iveControl ).WantTabs  then begi n
  3949           Ne wTabIndex  := tabPage .TabIndex;
  3950           if  ssShift i n Shift th en
  3951              dec(NewTab Index)
  3952           el se
  3953              inc(NewTab Index);
  3954           if  NewTabInd ex >= tabP age.Tabs.C ount then
  3955              dec(NewTab Index,tabP age.Tabs.C ount)
  3956           el se if NewT abIndex <  0 then
  3957              inc(NewTab Index,tabP age.Tabs.C ount);
  3958           ta bPage.TabI ndex := Ne wTabIndex;
  3959           ta bPageChang e(tabPage) ;
  3960           Ke y := 0;
  3961         end;
  3962       end;
  3963     end;
  3964   end;
  3965  
  3966   procedure  TfrmFrame. FormActiva te(Sender:  TObject);
  3967   var
  3968     aCPRS508 : ICPRS508 ;
  3969   begin
  3970     if Assig ned(FLastP age) then
  3971       if FLa stPage.Inh eritsFrom( TfrmPage)  then
  3972         Tfrm Page(FLast Page).Focu sFirstCont rol
  3973       else i f Supports (fLastPage , ICPRS508 , aCPRS508 ) then
  3974         aCPR S508.OnFoc usFirstCon trol(Sende r);;
  3975   end;
  3976  
  3977   procedure  TfrmFrame. pnlPrimary CareEnter( Sender: TO bject);
  3978   begin
  3979     with Sen der as TPa nel do
  3980       if (Co ntrolCount  > 0) and  (Controls[ 0] is TSpe edButton)  and (TSpee dButton(Co ntrols[0]) .Down)
  3981       then
  3982         Beve lInner :=  bvLowered
  3983       else
  3984         Beve lInner :=  bvRaised;
  3985   end;
  3986  
  3987   procedure  TfrmFrame. pnlPrimary CareExit(S ender: TOb ject);
  3988   var
  3989     ShiftIsD own,TabIsD own : bool ean;
  3990   begin
  3991     with Sen der as TPa nel do beg in
  3992       BevelI nner := bv None;
  3993       //Make  the lstCI RNLocation s act as i f between  pnlCIRN &  pnlReminde rs
  3994       //in t he Tab Ord er
  3995       if (ls tCIRNLocat ions.CanFo cus) then
  3996       begin
  3997         Shif tIsDown :=  Boolean(H i(GetKeySt ate(VK_SHI FT)));
  3998         TabI sDown := B oolean(Hi( GetKeyStat e(VK_TAB)) );
  3999         if T abIsDown t hen
  4000           if  (ShiftIsD own) and ( Name = 'pn lReminders ') then
  4001              lstCIRNLoc ations.Set Focus
  4002           el se if Not  (ShiftIsDo wn) and (N ame = 'pnl CIRN') the n
  4003              lstCIRNLoc ations.Set Focus;
  4004       end;
  4005     end;
  4006   end;
  4007  
  4008   procedure  TfrmFrame. pnlPatient Click(Send er: TObjec t);
  4009   begin
  4010     Screen.C ursor := c rHourglass ; //wat cq  18425 add ed hourgla ss and dis abled mnuF ileOpen
  4011     mnuFileO pen.Enable d := False ;
  4012     try
  4013     pnlPatie nt.Enabled  := false;
  4014     ViewInfo (mnuViewDe mo);
  4015     pnlPatie nt.Enabled  := true;
  4016     finally
  4017       Screen .Cursor :=  crDefault ;
  4018       mnuFil eOpen.Enab led := Tru e;
  4019     end;
  4020   end;
  4021  
  4022   procedure  TfrmFrame. pnlVisitCl ick(Sender : TObject) ;
  4023   begin
  4024     ViewInfo (mnuViewVi sits);
  4025   end;
  4026  
  4027   procedure  TfrmFrame. pnlPrimary CareClick( Sender: TO bject);
  4028   begin
  4029     ViewInfo (mnuViewPr imaryCare) ;
  4030   end;
  4031  
  4032   procedure  TfrmFrame. pnlReminde rsClick(Se nder: TObj ect);
  4033   begin
  4034     if(pnlRe minders.ta g = HAVE_R EMINDERS)  then
  4035         View Info(mnuVi ewReminder s);
  4036  
  4037   end;
  4038  
  4039   procedure  TfrmFrame. pnlPosting sClick(Sen der: TObje ct);
  4040   begin
  4041     ViewInfo (mnuViewPo stings);
  4042   end;
  4043  
  4044   //======== ========== =========  CCOW main  changes == ========== ========== ==
  4045  
  4046   procedure  TfrmFrame. HandleCCOW Error(AMes sage: stri ng);
  4047   begin
  4048     {$ifdef  DEBUG}
  4049       Show50 8Message(A Message);
  4050     {$endif}
  4051     InfoBox( TX_CCOW_ER ROR, TC_CC OW_ERROR,  MB_ICONERR OR or MB_O K);
  4052     FCCOWIns talled :=  False;
  4053     imgCCOW. Picture.Bi tMap.LoadF romResourc eName(hIns tance, 'BM P_CCOW_BRO KEN');
  4054     pnlCCOW. Hint := TX _CCOW_BROK EN;
  4055     mnuFileR esumeConte xt.Visible  := True;
  4056     mnuFileR esumeConte xt.Enabled  := False;
  4057     mnuFileB reakContex t.Visible  := True;
  4058     mnuFileB reakContex t.Enabled  := False;
  4059     FCCOWErr or := True ;
  4060   end;
  4061  
  4062   function T frmFrame.A llowCCOWCo ntextChang e(var CCOW Response:  UserRespon se; NewDFN : string):  boolean;
  4063   var
  4064     PtData :  IContextI temCollect ion;
  4065     PtDataIt em2, PtDat aItem3, Pt DataItem4  : IContext Item;
  4066     response  : UserRes ponse;
  4067     StationN umber: str ing;
  4068     IsProdAc ct: boolea n;
  4069   begin
  4070     Result : = False;
  4071     response  := 0;
  4072     try
  4073       // Sta rt a conte xt change  transactio n
  4074       if FCC OWInstalle d then
  4075          beg in
  4076              FCCOWError  := False;
  4077              imgCCOW.Pi cture.BitM ap.LoadFro mResourceN ame(hInsta nce, 'BMP_ CCOW_CHANG ING');
  4078              pnlCCOW.Hi nt := TX_C COW_CHANGI NG;
  4079              try
  4080                ctxConte xtor.Start ContextCha nge();
  4081              except
  4082                on E: Ex ception do  HandleCCO WError(E.M essage);
  4083              end;
  4084              if FCCOWEr ror then
  4085              begin
  4086                Result : = False;
  4087                Exit;
  4088              end;
  4089              // Set the  new propo sed contex t data.
  4090              PtData :=  CoContextI temCollect ion.Create ();
  4091              StationNum ber := Use r.StationN umber;
  4092              IsProdAcct  := User.I sProductio nAccount;
  4093  
  4094              {$IFDEF CC OWBROKER}
  4095              //IsProdAc ct := RPCB rokerV.Log in.IsProdu ction;  // not yet
  4096              {$ENDIF}
  4097  
  4098              PtDataItem 2 := CoCon textItem.C reate();
  4099              PtDataItem 2.Set_Name ('Patient. co.Patient Name');                  // Pati ent.Name
  4100              PtDataItem 2.Set_Valu e(Piece(Pa tient.Name , ',', 1)  + U + Piec e(Patient. Name, ',',  2) + '^^^ ^');
  4101              PtData.Add (PtDataIte m2);
  4102  
  4103              PtDataItem 3 := CoCon textItem.C reate();
  4104              if not IsP rodAcct th en
  4105                PtDataIt em3.Set_Na me('Patien t.id.MRN.D FN_' + Sta tionNumber  + '_TEST' )    // Pa tient.DFN
  4106              else
  4107                PtDataIt em3.Set_Na me('Patien t.id.MRN.D FN_' + Sta tionNumber );              // Pa tient.DFN
  4108              PtDataItem 3.Set_Valu e(Patient. DFN);
  4109              PtData.Add (PtDataIte m3);
  4110  
  4111              if Patient .ICN <> ''  then
  4112                begin
  4113                  PtData Item4 := C oContextIt em.Create( );
  4114                  if not  IsProdAcc t then
  4115                    PtDa taItem4.Se t_Name('Pa tient.id.M RN.Nationa lIDNumber_ TEST')   / / Patient. ICN
  4116                  else
  4117                    PtDa taItem4.Se t_Name('Pa tient.id.M RN.Nationa lIDNumber' );       / / Patient. ICN
  4118                  PtData Item4.Set_ Value(Pati ent.ICN);
  4119                  PtData .Add(PtDat aItem4);
  4120                end;
  4121  
  4122              // End the  context c hange tran saction.
  4123              FCCOWError  := False;
  4124              try
  4125                response  := ctxCon textor.End ContextCha nge(true,  PtData);
  4126              except
  4127                on E: Ex ception do  HandleCCO WError(E.M essage);
  4128              end;
  4129              if FCCOWEr ror then
  4130              begin
  4131                HideEver ything;
  4132                Result : = False;
  4133                Exit;
  4134              end;
  4135          end
  4136       else
  4137         begi n
  4138           Re sult := Tr ue;
  4139           Ex it;
  4140         end;
  4141  
  4142       CCOWRe sponse :=  response;
  4143       if (re sponse = U rCommit) t hen
  4144       begin
  4145         // N ew context  is commit ted.
  4146         mnuF ileResumeC ontext.Ena bled := Fa lse;
  4147         mnuF ileBreakCo ntext.Enab led := Tru e;
  4148         FCCO WIconName  := 'BMP_CC OW_LINKED' ;
  4149         pnlC COW.Hint : = TX_CCOW_ LINKED;
  4150         imgC COW.Pictur e.BitMap.L oadFromRes ourceName( hInstance,  FCCOWIcon Name);
  4151         Resu lt := True ;
  4152       end
  4153       else i f (respons e = UrCanc el) then
  4154       begin
  4155         // P roposed co ntext chan ge is canc eled. Retu rn to the  current co ntext.
  4156         PtDa ta.RemoveA ll;
  4157         mnuF ileResumeC ontext.Ena bled := Fa lse;
  4158         mnuF ileBreakCo ntext.Enab led := Tru e;
  4159         imgC COW.Pictur e.BitMap.L oadFromRes ourceName( hInstance,  FCCOWIcon Name);
  4160         Resu lt := Fals e;
  4161       end
  4162       else i f (respons e = UrBrea k) then
  4163       begin
  4164         // T he context or has bro ken the li nk by susp ending.  T his app sh ould
  4165         // u pdate the  Clinical L ink icon,  enable the  Resume me nu item, a nd
  4166         // d isable the  Suspend m enu item.
  4167         PtDa ta.RemoveA ll;
  4168         mnuF ileResumeC ontext.Ena bled := Tr ue;
  4169         mnuF ileBreakCo ntext.Enab led := Fal se;
  4170         FCCO WIconName  := 'BMP_CC OW_BROKEN' ;
  4171         pnlC COW.Hint : = TX_CCOW_ BROKEN;
  4172         imgC COW.Pictur e.BitMap.L oadFromRes ourceName( hInstance,  FCCOWIcon Name);
  4173         if P atient.Inp atient the n
  4174         begi n
  4175           En counter.In patient :=  True;
  4176           En counter.Lo cation :=  Patient.Lo cation;
  4177           En counter.Da teTime :=  Patient.Ad mitTime;
  4178           En counter.Vi sitCategor y := 'H';
  4179         end;
  4180         if U ser.IsProv ider then  Encounter. Provider : = User.DUZ ;
  4181         Setu pPatient;
  4182         tabP age.TabInd ex := Page IDToTab(Us er.Initial Tab);
  4183         tabP ageChange( tabPage);
  4184         Resu lt := Fals e;
  4185       end;
  4186     except
  4187       on exc  : EOleExc eption do
  4188         Show Msg('EOleE xception:  ' + exc.Me ssage);
  4189     end;
  4190   end;
  4191  
  4192   procedure  TfrmFrame. ctxContext orCanceled (Sender: T Object);
  4193   begin
  4194     // Appli cation sho uld mainta in its sta te as the  current (e xisting) c ontext.
  4195     imgCCOW. Picture.Bi tMap.LoadF romResourc eName(hIns tance, FCC OWIconName );
  4196   end;
  4197  
  4198   procedure  TfrmFrame. ctxContext orPending( Sender: TO bject;
  4199     const aC ontextItem Collection : IDispatc h);
  4200   var
  4201     Reason,  HyperLinkR eason: str ing;
  4202     PtChange d: boolean ;
  4203   {$IFDEF CC OWBROKER}
  4204     UserChan ged: boole an;
  4205   {$ENDIF}
  4206   begin
  4207     // If th e app woul d lose dat a, or have  other pro blems chan ging conte xt at
  4208     // this  time, it s hould retu rn a messa ge using S etSurveyRe ponse. Not e that the
  4209     // user  may decide  to commit  the conte xt change  anyway.
  4210     //
  4211     // if (c annot-chan ge-context -without-a -problem)  then
  4212     //   con textor.Set SurveyResp onse('Cond itional ac cept reaso n...');
  4213     if FCCOW Busy then
  4214     begin
  4215       Sleep( 10000);
  4216     end;
  4217  
  4218     FCCOWErr or := Fals e;
  4219     try
  4220       CheckF orDifferen tPatient(a ContextIte mCollectio n, PtChang ed);
  4221   {$IFDEF CC OWBROKER}
  4222       CheckF orDifferen tUser(aCon textItemCo llection,  UserChange d);
  4223   {$ENDIF}
  4224     except
  4225       on E:  Exception  do HandleC COWError(E .Message);
  4226     end;
  4227     if FCCOW Error then
  4228     begin
  4229       HideEv erything;
  4230       Exit;
  4231     end;
  4232  
  4233   {$IFDEF CC OWBROKER}
  4234     if PtCha nged or Us erChanged  then
  4235   {$ELSE}
  4236     if PtCha nged then
  4237   {$ENDIF}
  4238       begin
  4239         FCCO WContextCh anging :=  True;
  4240         imgC COW.Pictur e.BitMap.L oadFromRes ourceName( hInstance,  'BMP_CCOW _CHANGING' );
  4241         pnlC COW.Hint : = TX_CCOW_ CHANGING;
  4242         Allo wContextCh angeAll(Re ason);
  4243       end;
  4244     CheckHyp erlinkResp onse(aCont extItemCol lection, H yperlinkRe ason);
  4245     Reason : = Hyperlin kReason +  Reason;
  4246     if Pos(' COM_OBJECT _ACTIVE',  Reason) >  0 then
  4247       Sleep( 12000)
  4248     else if  Length(Rea son) > 0 t hen
  4249       ctxCon textor.Set SurveyResp onse(Reaso n)
  4250     else
  4251       begin
  4252         imgC COW.Pictur e.BitMap.L oadFromRes ourceName( hInstance,  'BMP_CCOW _LINKED');
  4253         pnlC COW.Hint : = TX_CCOW_ LINKED;
  4254       end;
  4255     FCCOWCon textChangi ng := Fals e;
  4256   end;
  4257  
  4258   procedure  TfrmFrame. ctxContext orCommitte d(Sender:  TObject);
  4259   var
  4260     Reason:  string;
  4261     PtChange d: boolean ;
  4262     i: integ er;
  4263   begin
  4264     // Appli cation sho uld now ac cess the n ew context  and updat e its stat e.
  4265     FCCOWErr or := Fals e;
  4266     try
  4267     {$IFDEF  CCOWBROKER }
  4268       with R PCBrokerV  do if (Was UserDefine d and IsUs erCleared  and (ctxCo ntextor.Cu rrentConte xt.Present (CCOW_USER _NAME) = n il)) then     // RV 0 5/11/04
  4269       begin
  4270         Reas on := 'COM MIT';
  4271         if A llowContex tChangeAll (Reason) t hen
  4272         begi n
  4273           Cl ose;
  4274           Ex it;
  4275         end;
  4276       end;
  4277     {$ENDIF}
  4278       CheckF orDifferen tPatient(c txContexto r.CurrentC ontext, Pt Changed);
  4279     except
  4280       on E:  Exception  do HandleC COWError(E .Message);
  4281     end;
  4282     if FCCOW Error then
  4283     begin
  4284       HideEv erything;
  4285       Exit;
  4286     end;
  4287     if not P tChanged t hen exit;
  4288     FCCOWDri vedChange  := True;
  4289     i := 0;
  4290     while Le ngth(Scree n.Forms[i] .Name) > 0  do
  4291     begin
  4292       if fsM odal in Sc reen.Forms [i].FormSt ate then
  4293       begin
  4294         Scre en.Forms[i ].ModalRes ult := mrC ancel;
  4295         i :=  i + 1;
  4296       end el se  // the  fsModal f orms alway s sequence d prior to  the none- fsModal fo rms
  4297         Brea k;
  4298     end;
  4299     Reason : = 'COMMIT' ;
  4300     if Allow ContextCha ngeAll(Rea son) then  UpdateCCOW Context;
  4301     FCCOWIco nName := ' BMP_CCOW_L INKED';
  4302     pnlCCOW. Hint := TX _CCOW_LINK ED;
  4303     imgCCOW. Picture.Bi tMap.LoadF romResourc eName(hIns tance, FCC OWIconName );
  4304   end;
  4305  
  4306   function T frmFrame.F indBestCCO WDFN: stri ng;
  4307   var
  4308     data: IC ontextItem Collection ;
  4309     anItem:  IContextIt em;
  4310     StationN umber, tem pDFN: stri ng;
  4311     IsProdAc ct:  Boole an;
  4312  
  4313     procedur e FindNext BestDFN;
  4314     begin
  4315       Statio nNumber :=  User.Stat ionNumber;
  4316       if IsP rodAcct th en
  4317         anIt em := data .Present(' Patient.id .MRN.DFN_'  + Station Number)
  4318       else
  4319         anIt em := data .Present(' Patient.id .MRN.DFN_'  + Station Number + ' _TEST');
  4320       if anI tem <>  ni l then tem pDFN := an Item.Get_V alue();
  4321     end;
  4322  
  4323   begin
  4324     if uCore .User = ni l then
  4325     begin
  4326       Result  := '';
  4327       exit;
  4328     end;
  4329     IsProdAc ct := User .IsProduct ionAccount ;
  4330     // Get a n item col lection of  the curre nt context
  4331     FCCOWErr or := Fals e;
  4332     try
  4333       data : = ctxConte xtor.Curre ntContext;
  4334     except
  4335       on E:  Exception  do HandleC COWError(E .Message);
  4336     end;
  4337     if FCCOW Error then
  4338     begin
  4339       HideEv erything;
  4340       Exit;
  4341     end;
  4342     // Retri eve the Co ntextItem  name and v alue as st rings
  4343     if IsPro dAcct then
  4344       anItem  := data.P resent('Pa tient.id.M RN.Nationa lIDNumber' )
  4345     else
  4346       anItem  := data.P resent('Pa tient.id.M RN.Nationa lIDNumber_ TEST');
  4347     if anIte m <> nil t hen
  4348       begin
  4349         temp DFN := Get DFNFromICN (anItem.Ge t_Value()) ;                        // "Pub lic" RPC c all
  4350         if t empDFN = ' -1' then F indNextBes tDFN;
  4351       end
  4352     else
  4353       FindNe xtBestDFN;
  4354     Result : = tempDFN;
  4355     data :=  nil;
  4356     anItem : = nil;
  4357   end;
  4358  
  4359   procedure  TfrmFrame. UpdateCCOW Context;
  4360   var
  4361     PtDFN(*,  PtName*):  string;
  4362   begin
  4363     if not F CCOWInstal led then e xit;
  4364     DoNotCha ngeEncWind ow := fals e;
  4365     PtDFN :=  FindBestC COWDFN;
  4366     if StrTo Int64Def(P tDFN, 0) >  0 then
  4367       begin
  4368         // S elect new  patient ba sed on con text value
  4369         if P atient.DFN  = PtDFN t hen exit;
  4370         Pati ent.DFN :=  PtDFN;
  4371         if ( Patient.Na me = '-1')  then
  4372           be gin
  4373              HideEveryt hing;
  4374              exit;
  4375           en d
  4376         else
  4377           Sh owEverythi ng;
  4378         Enco unter.Clea r;
  4379         if P atient.Inp atient the n
  4380         begi n
  4381           En counter.In patient :=  True;
  4382           En counter.Lo cation :=  Patient.Lo cation;
  4383           En counter.Da teTime :=  Patient.Ad mitTime;
  4384           En counter.Vi sitCategor y := 'H';
  4385         end;
  4386         if U ser.IsProv ider then  Encounter. Provider : = User.DUZ ;
  4387         if n ot FFirstL oad then S etupPatien t;
  4388         { fr mCover.Upd ateVAAButt on; //VAA}
  4389         Upda teVAAMHVBu ttons(nil) ;
  4390         Dete rmineNextT ab;
  4391         tabP age.TabInd ex := Page IDToTab(Ne xtTab);
  4392         tabP ageChange( tabPage);
  4393       end
  4394     else
  4395       HideEv erything;
  4396   end;
  4397  
  4398   procedure  TfrmFrame. mnuFileBre akContextC lick(Sende r: TObject );
  4399   begin
  4400     FCCOWErr or := Fals e;
  4401     FCCOWIco nName := ' BMP_CCOW_C HANGING';
  4402     pnlCCOW. Hint := TX _CCOW_CHAN GING;
  4403     imgCCOW. Picture.Bi tMap.LoadF romResourc eName(hIns tance, FCC OWIconName );
  4404     try
  4405       ctxCon textor.Sus pend;
  4406     except
  4407       on E:  Exception  do HandleC COWError(E .Message);
  4408     end;
  4409     if FCCOW Error then  exit;
  4410     FCCOWIco nName := ' BMP_CCOW_B ROKEN';
  4411     pnlCCOW. Hint := TX _CCOW_BROK EN;
  4412     imgCCOW. Picture.Bi tMap.LoadF romResourc eName(hIns tance, FCC OWIconName );
  4413     mnuFileR esumeConte xt.Enabled  := True;
  4414     mnuFileB reakContex t.Enabled  := False;
  4415   end;
  4416  
  4417   procedure  TfrmFrame. mnuFileRes umeContext GetClick(S ender: TOb ject);
  4418   var
  4419     Reason:  string;
  4420   begin
  4421     Reason : = '';
  4422     if not A llowContex tChangeAll (Reason) t hen exit;
  4423     FCCOWIco nName := ' BMP_CCOW_C HANGING';
  4424     pnlCCOW. Hint := TX _CCOW_CHAN GING;
  4425     imgCCOW. Picture.Bi tMap.LoadF romResourc eName(hIns tance, FCC OWIconName );
  4426     FCCOWErr or := Fals e;
  4427     try
  4428       ctxCon textor.Res ume;
  4429     except
  4430       on E:  Exception  do HandleC COWError(E .Message);
  4431     end;
  4432     if FCCOW Error then  exit;
  4433     UpdateCC OWContext;
  4434     if not F NoPatientS elected th en
  4435     begin
  4436       FCCOWI conName :=  'BMP_CCOW _LINKED';
  4437       pnlCCO W.Hint :=  TX_CCOW_LI NKED;
  4438       imgCCO W.Picture. BitMap.Loa dFromResou rceName(hI nstance, F CCOWIconNa me);
  4439       mnuFil eResumeCon text.Enabl ed := Fals e;
  4440       mnuFil eBreakCont ext.Visibl e := True;
  4441       mnuFil eBreakCont ext.Enable d := True;
  4442     end;
  4443   end;
  4444  
  4445   procedure  TfrmFrame. mnuFileRes umeContext SetClick(S ender: TOb ject);
  4446   var
  4447     CCOWResp onse: User Response;
  4448     Reason:  string;
  4449   begin
  4450     Reason : = '';
  4451     if not A llowContex tChangeAll (Reason) t hen exit;
  4452     FCCOWIco nName := ' BMP_CCOW_C HANGING';
  4453     pnlCCOW. Hint := TX _CCOW_CHAN GING;
  4454     imgCCOW. Picture.Bi tMap.LoadF romResourc eName(hIns tance, FCC OWIconName );
  4455     FCCOWErr or := Fals e;
  4456     try
  4457       ctxCon textor.Res ume;
  4458     except
  4459       on E:  Exception  do HandleC COWError(E .Message);
  4460     end;
  4461     if FCCOW Error then  exit;
  4462     if (Allo wCCOWConte xtChange(C COWRespons e, Patient .DFN)) the n
  4463       begin
  4464         mnuF ileResumeC ontext.Ena bled := Fa lse;
  4465         mnuF ileBreakCo ntext.Visi ble := Tru e;
  4466         mnuF ileBreakCo ntext.Enab led := Tru e;
  4467         FCCO WIconName  := 'BMP_CC OW_LINKED' ;
  4468         pnlC COW.Hint : = TX_CCOW_ LINKED;
  4469         imgC COW.Pictur e.BitMap.L oadFromRes ourceName( hInstance,  FCCOWIcon Name);
  4470       end
  4471     else
  4472       begin
  4473         mnuF ileResumeC ontext.Ena bled := Tr ue;
  4474         mnuF ileBreakCo ntext.Enab led := Fal se;
  4475         FCCO WIconName  := 'BMP_CC OW_BROKEN' ;
  4476         pnlC COW.Hint : = TX_CCOW_ BROKEN;
  4477         imgC COW.Pictur e.BitMap.L oadFromRes ourceName( hInstance,  FCCOWIcon Name);
  4478         try
  4479           if  ctxContex tor.State  in [csPart icipating]  then ctxC ontextor.S uspend;
  4480         exce pt
  4481           on  E: Except ion do Han dleCCOWErr or(E.Messa ge);
  4482         end;
  4483      end;
  4484     SetupPat ient;
  4485     tabPage. TabIndex : = PageIDTo Tab(User.I nitialTab) ;
  4486     tabPageC hange(tabP age);
  4487   end;
  4488  
  4489   procedure  TfrmFrame. CheckForDi fferentPat ient(aCont extItemCol lection: I Dispatch;  var PtChan ged: boole an);
  4490   var
  4491     data : I ContextIte mCollectio n;
  4492     anItem:  IContextIt em;
  4493     PtDFN, P tName: str ing;
  4494   begin
  4495     if uCore .Patient =  nil then
  4496     begin
  4497       PtChan ged := Fal se;
  4498       Exit;
  4499     end;
  4500     data :=  IContextIt emCollecti on(aContex tItemColle ction) ;
  4501     PtDFN :=  FindBestC COWDFN;
  4502     // Retri eve the Co ntextItem  name and v alue as st rings
  4503     anItem : = data.Pre sent('Pati ent.co.Pat ientName') ;
  4504     if anIte m <> nil t hen PtName  := anItem .Get_Value ();
  4505     PtChange d := not ( (PtDFN = P atient.DFN ) and (PtN ame = Piec e(Patient. Name, ',',  1) + U +  Piece(Pati ent.Name,  ',', 2) +  '^^^^'));
  4506   end;
  4507  
  4508   {$IFDEF CC OWBROKER}
  4509   procedure  TfrmFrame. CheckForDi fferentUse r(aContext ItemCollec tion: IDis patch; var  UserChang ed: boolea n);
  4510   var
  4511     data : I ContextIte mCollectio n;
  4512   begin
  4513     if uCore .User = ni l then
  4514     begin
  4515       UserCh anged := F alse;
  4516       Exit;
  4517     end;
  4518     data :=  IContextIt emCollecti on(aContex tItemColle ction) ;
  4519     UserChan ged := RPC BrokerV.Is UserContex tPending(d ata);
  4520   end;
  4521   {$ENDIF}
  4522  
  4523   procedure  TfrmFrame. CheckHyper linkRespon se(aContex tItemColle ction: IDi spatch; va r Hyperlin kReason: s tring);
  4524   var
  4525     data : I ContextIte mCollectio n;
  4526     anItem :  IContextI tem;
  4527     itemvalu e: string;
  4528     PtSubjec t: string;
  4529   begin
  4530     data :=  IContextIt emCollecti on(aContex tItemColle ction) ;
  4531       anItem :=  data.Prese nt('[hds_m ed_ DNS     ]request.i d.name');
  4532     // Retri eve the Co ntextItem  name and v alue as st rings
  4533     if anIte m <> nil t hen
  4534       begin
  4535         item Value := a nItem.Get_ Value();
  4536         if i temValue =  'GetWindo wHandle' t hen
  4537           be gin
  4538              PtSubject  := 'patien t.id.mrn.d fn_' + Use r.StationN umber;
  4539              if not Use r.IsProduc tionAccoun t then PtS ubject :=  PtSubject  + '_test';
  4540              if data.Pr esent(PtSu bject) <>  nil then
  4541                Hyperlin kReason :=  '!@#$' +  IntToStr(S elf.Handle ) + ':0:'
  4542              else
  4543                Hyperlin kReason :=  '';
  4544           en d;
  4545       end;
  4546   end;
  4547  
  4548   procedure  TfrmFrame. HideEveryt hing(AMess age: strin g = 'No pa tient is c urrently s elected.') ;
  4549   begin
  4550     FNoPatie ntSelected  := TRUE;
  4551     pnlNoPat ientSelect ed.Caption  := AMessa ge;
  4552     pnlNoPat ientSelect ed.Visible  := True;
  4553     pnlNoPat ientSelect ed.BringTo Front;
  4554     mnuFileR eview.Enab led := Fal se;
  4555     mnuFileP rint.Enabl ed := Fals e;
  4556     mnuFileP rintSelect edItems.En abled := F alse;
  4557     mnuFileE ncounter.E nabled :=  False;
  4558     mnuFileN ext.Enable d := False ;
  4559     mnuFileR efresh.Ena bled := Fa lse;
  4560     mnuFileP rintSetup. Enabled :=  False;
  4561     mnuFileP rintSelect edItems.En abled := F alse;
  4562     mnuFileN otifRemove .Enabled : = False;
  4563     mnuFileR esumeConte xt.Enabled  := False;
  4564     mnuFileB reakContex t.Enabled  := False;
  4565     mnuEdit. Enabled :=  False;
  4566     mnuView. Enabled :=  False;
  4567     mnuTools .Enabled : = False;
  4568     if FNext ButtonActi ve then FN extButton. Visible :=  False;
  4569   end;
  4570  
  4571   procedure  TfrmFrame. ShowEveryt hing;
  4572   begin
  4573     FNoPatie ntSelected  := FALSE;
  4574     pnlNoPat ientSelect ed.Caption  := '';
  4575     pnlNoPat ientSelect ed.Visible  := False;
  4576     pnlNoPat ientSelect ed.SendToB ack;
  4577     mnuFileR eview.Enab led := Tru e;
  4578     mnuFileP rint.Enabl ed := True ;
  4579     mnuFileE ncounter.E nabled :=  True;
  4580     mnuFileN ext.Enable d := True;
  4581     mnuFileR efresh.Ena bled := Tr ue;
  4582     mnuFileP rintSetup. Enabled :=  True;
  4583     mnuFileP rintSelect edItems.En abled := T rue;
  4584     mnuFileN otifRemove .Enabled : = True;
  4585     if not F CCOWError  then
  4586     begin
  4587       if FCC OWIconName = 'BMP_CCO W_BROKEN'  then
  4588       begin
  4589         mnuF ileResumeC ontext.Ena bled := Tr ue;
  4590         mnuF ileBreakCo ntext.Enab led := Fal se;
  4591       end el se
  4592       begin
  4593         mnuF ileResumeC ontext.Ena bled := Fa lse;
  4594         mnuF ileBreakCo ntext.Enab led := Tru e;
  4595       end;
  4596     end;
  4597     mnuEdit. Enabled :=  True;
  4598     mnuView. Enabled :=  True;
  4599     mnuTools .Enabled : = True;
  4600     if FNext ButtonActi ve then FN extButton. Visible :=  True;
  4601   end;
  4602  
  4603  
  4604   procedure  TfrmFrame. pnlFlagMou seDown(Sen der: TObje ct; Button : TMouseBu tton;
  4605     Shift: T ShiftState ; X, Y: In teger);
  4606   begin
  4607     pnlFlag. BevelOuter  := bvLowe red;
  4608   end;
  4609  
  4610   procedure  TfrmFrame. pnlFlagMou seUp(Sende r: TObject ; Button:  TMouseButt on;
  4611     Shift: T ShiftState ; X, Y: In teger);
  4612   begin
  4613     pnlFlag. BevelOuter  := bvRais ed;
  4614   end;
  4615  
  4616   procedure  TfrmFrame. pnlFlagCli ck(Sender:  TObject);
  4617   begin
  4618     ViewInfo (mnuViewFl ags);
  4619   end;
  4620  
  4621   procedure  TfrmFrame. mnuFilePri ntSelected ItemsClick (Sender: T Object);
  4622   begin
  4623       case T abToPageID (tabPage.T abIndex) o f
  4624         CT_N OTES:    f rmNotes.Ls tNotesToPr int;
  4625         CT_C ONSULTS: f rmConsults .LstConsul tsToPrint;
  4626         CT_D CSUMM:   f rmDCSumm.L stSummsToP rint;
  4627    end; {cas e}
  4628   end;
  4629  
  4630   procedure  TfrmFrame. mnuAlertRe newClick(S ender: TOb ject);
  4631   var XQAID:  string;
  4632   begin
  4633     XQAID :=  Piece(Not ifications .RecordID,  '^', 2);
  4634     RenewAle rt(XQAID);
  4635   end;
  4636  
  4637   procedure  TfrmFrame. mnuFileVie wNotificat ionsClick( Sender: TO bject);
  4638   begin
  4639     ShowPati entNotific ations(mnu FileNextCl ick);
  4640   end;
  4641  
  4642   procedure  TfrmFrame. mnuAlertFo rwardClick (Sender: T Object);
  4643   var
  4644     XQAID, A lertMsg: s tring;
  4645   begin
  4646     XQAID :=  Piece(Not ifications .RecordID, '^', 2);
  4647     AlertMsg  := Piece( Notificati ons.Record ID, '^', 1 );
  4648     RenewAle rt(XQAID);   // must  renew/rest ore an ale rt before  it can be  forwarded
  4649     ForwardA lertTo(XQA ID + '^' +  AlertMsg) ;
  4650   end;
  4651  
  4652   procedure  TfrmFrame. mnuGECStat usClick(Se nder: TObj ect);
  4653   var
  4654   ans, Resul t,str,str1 ,title: st ring;
  4655   cnt,i: int eger;
  4656   fin: boole an;
  4657  
  4658   begin
  4659     Result : = sCallV(' ORQQPXRM G EC STATUS  PROMPT', [ Patient.DF N]);
  4660     if Piece (Result,U, 1) <> '0'  then
  4661       begin
  4662         titl e := Piece (Result,U, 2);
  4663           if  pos('~',P iece(Resul t,U,1))>0  then
  4664                   begin
  4665                   str:= '';
  4666                   str1  := Piece(R esult,U,1) ;
  4667                   cnt : = DelimCou nt(str1, ' ~');
  4668                   for i :=1 to cnt +1 do
  4669                       b egin
  4670                       i f i = 1 th en str :=  Piece(str1 ,'~',i);
  4671                       i f i > 1 th en str :=s tr+CRLF+Pi ece(str1,' ~',i);
  4672                       e nd;
  4673                 end
  4674                 else st r := Piece (Result,U, 1);
  4675           if  Piece(Res ult,U,3)=' 1' then
  4676              begin
  4677                 fin :=  (InfoBox(s tr,title,  MB_YESNO o r MB_DEFBU TTON2)=IDY ES);
  4678                 if fin  = true the n ans := ' 1';
  4679                 if fin  = false th en ans :=  '0';
  4680                 CallV(' ORQQPXRM G EC FINISHE D?',[Patie nt.DFN,ans ]);
  4681              end
  4682           el se
  4683           In foBox(str, title, MB_ OK);
  4684       end;
  4685   end;
  4686  
  4687   procedure  TfrmFrame. pnlFlagEnt er(Sender:  TObject);
  4688   begin
  4689     pnlFlag. BevelInner  := bvRais ed;
  4690     pnlFlag. BevelOuter  := bvNone ;
  4691     pnlFlag. BevelWidth  := 3;
  4692   end;
  4693  
  4694   procedure  TfrmFrame. pnlFlagExi t(Sender:  TObject);
  4695   begin
  4696     pnlFlag. BevelWidth  := 2;
  4697     pnlFlag. BevelInner  := bvNone ;
  4698     pnlFlag. BevelOuter  := bvRais ed;
  4699   end;
  4700  
  4701   procedure  TfrmFrame. tabPageMou seDown(Sen der: TObje ct; Button : TMouseBu tton;
  4702     Shift: T ShiftState ; X, Y: In teger);
  4703   begin
  4704     inherite d;
  4705     TabCtrlC licked :=  True;
  4706   end;
  4707  
  4708   procedure  TfrmFrame. tabPageMou seUp(Sende r: TObject ; Button:  TMouseButt on;
  4709     Shift: T ShiftState ; X, Y: In teger);
  4710   begin
  4711     LastTab  := TabToPa geID((send er as TTab Control).T abIndex);
  4712   end;
  4713  
  4714   procedure  TfrmFrame. lstCIRNLoc ationsExit (Sender: T Object);
  4715   begin
  4716       //Make  the lstCI RNLocation s act as i f between  pnlCIRN &  pnlReminde rs
  4717       //in t he Tab Ord er
  4718     if Boole an(Hi(GetK eyState(VK _TAB))) th en
  4719       if Boo lean(Hi(Ge tKeyState( VK_SHIFT)) ) then
  4720         pnlC IRN.SetFoc us
  4721       else
  4722         pnlR eminders.S etFocus;
  4723   end;
  4724  
  4725   procedure  TfrmFrame. AppEventsA ctivate(Se nder: TObj ect);
  4726   begin
  4727     FJustEnt eredApp :=  True;
  4728   end;
  4729  
  4730   procedure  TfrmFrame. AppEventsM essage(var  Msg: tagM SG; var Ha ndled: Boo lean);
  4731   var
  4732     Control:  TComponen t;
  4733   begin
  4734     Handled  := false;
  4735     if (Msg. message =  WM_MOUSEWH EEL) and ( GetKeyStat e(VK_LBUTT ON) < 0) t hen begin
  4736       Contro l := FindC ontrol(Msg .hwnd);
  4737       if not  Assigned( Control) t hen
  4738         Hand led := Tru e
  4739       else i f (Control  is TRichE dit) then  begin
  4740         Hand led := Tru e;
  4741         Send Message(se lf.Handle,  EM_SETZOO M, 0, 0);
  4742       end;
  4743      end;
  4744   end;
  4745  
  4746   procedure  TfrmFrame. ScreenActi veFormChan ge(Sender:  TObject);
  4747   begin
  4748     if(assig ned(FOldAc tiveFormCh ange)) the n
  4749       FOldAc tiveFormCh ange(Sende r);
  4750     //Focus  the Form t hat Stays  on Top aft er the App lication R egains foc us.
  4751     if FJust EnteredApp  then
  4752       FocusA pplication TopForm;
  4753     FJustEnt eredApp :=  false;
  4754   end;
  4755  
  4756   procedure  TfrmFrame. FocusAppli cationTopF orm;
  4757   var
  4758     I : inte ger;
  4759   begin
  4760     for I :=  (Screen.F ormCount-1 ) downto 0  do //Set  the last o ne opened  last
  4761     begin
  4762       with S creen.Form s[I] do
  4763         if ( FormStyle  = fsStayOn Top) and ( Enabled) a nd (Visibl e) then
  4764           Se tFocus;
  4765     end;
  4766   end;
  4767  
  4768   procedure  TfrmFrame. AppEventsS hortCut(va r Msg: TWM Key;
  4769     var Hand led: Boole an);
  4770   begin
  4771     if ((Boo lean(Hi(Ge tKeyState( VK_MENU{AL T})))) and  (Msg.Char Code = VK_ F1)) then
  4772     begin
  4773       FocusA pplication TopForm;
  4774       Handle d := True;
  4775     end;
  4776   end;
  4777  
  4778   procedure  TfrmFrame. mnuToolsGr aphingClic k(Sender:  TObject);
  4779   var
  4780     contexth int: strin g;
  4781   begin
  4782     Screen.C ursor := c rHourGlass ;
  4783     contexth int := mnu ToolsGraph ing.Hint;
  4784     if Graph Float = ni l then                // new gra ph
  4785     begin
  4786       GraphF loat := Tf rmGraphs.C reate(self );
  4787       try
  4788         with  GraphFloa t do
  4789         begi n
  4790           if  btnClose. Tag = 1 th en
  4791           be gin
  4792              Screen.Cur sor := crD efault;
  4793              exit;
  4794           en d;
  4795           In itialize;
  4796           Ca ption := ' CPRS Graph ing - Pati ent: ' + M ixedCase(P atient.Nam e);
  4797           Bo rderIcons  := [biSyst emMenu, bi Maximize,  biMinimize ];
  4798           Bo rderStyle  := bsSizea ble;
  4799           Bo rderWidth  := 1;
  4800           //  context s ensitive        type  (tabPage.T abIndex)   & [item]
  4801           Re sizeAnchor edFormToFo nt(GraphFl oat);
  4802           Gr aphFloat.p nlFooter.H int := con texthint;    // conte xt from la b most rec ent
  4803           Sh ow;
  4804         end;
  4805       finall y
  4806         if G raphFloat. btnClose.T ag = 1 the n
  4807         begi n
  4808           Gr aphFloatAc tive := fa lse;
  4809           Gr aphFloat.F ree;
  4810           Gr aphFloat : = nil;
  4811         end
  4812         else
  4813           Gr aphFloatAc tive := tr ue;
  4814       end;
  4815     end
  4816     else
  4817     begin
  4818       GraphF loat.Capti on := 'CPR S Graphing  - Patient : ' + Mixe dCase(Pati ent.Name);
  4819       GraphF loat.pnlFo oter.Hint  := context hint;   //  context f rom lab mo st recent
  4820       if Gra phFloat.bt nClose.Tag  = 1 then
  4821       begin
  4822         Scre en.Cursor  := crDefau lt;
  4823         exit ;
  4824       end
  4825       else i f GraphFlo atActive a nd (frmGra phData.pnl Data.Hint  = Patient. DFN) then
  4826       begin
  4827         if l ength(Grap hFloat.pnl Footer.Hin t) > 1 the n
  4828         begi n
  4829           Gr aphFloat.C lose;
  4830           Gr aphFloatAc tive := tr ue;
  4831           Gr aphFloat.S how;
  4832         end;
  4833         Grap hFloat.Bri ngToFront;               // grap h is activ e, same pa tient
  4834       end
  4835       else i f frmGraph Data.pnlDa ta.Hint =  Patient.DF N then
  4836       begin                                     // graph  is not ac tive, same  patient
  4837         // c ontext sen sitive
  4838         Grap hFloat.Sho w;
  4839         Grap hFloatActi ve := true ;
  4840       end
  4841       else
  4842       //with  GraphFloa t do                      // new  patient
  4843       begin
  4844         Grap hFloat.Ini tialRetain ;
  4845         Grap hFloatActi ve := fals e;
  4846         Grap hFloat.Fre e;
  4847         Grap hFloat :=  nil;
  4848         mnuT oolsGraphi ngClick(se lf);           // del ete and re curse
  4849       end;
  4850     end;
  4851     mnuTools Graphing.H int := '';
  4852     Screen.C ursor := c rDefault;
  4853   end;
  4854  
  4855   procedure  TfrmFrame. pnlCIRNMou seDown(Sen der: TObje ct; Button : TMouseBu tton; Shif t: TShiftS tate; X, Y : Integer) ;
  4856   begin
  4857     pnlCIRN. BevelOuter  := bvLowe red;
  4858   end;
  4859  
  4860   procedure  TfrmFrame. pnlCIRNMou seUp(Sende r: TObject ; Button:  TMouseButt on; Shift:  TShiftSta te; X, Y:  Integer);
  4861   begin
  4862     pnlCIRN. BevelOuter  := bvRais ed;
  4863   end;
  4864  
  4865   procedure  TfrmFrame. laMHVClick (Sender: T Object);
  4866   begin
  4867     ViewInfo (mnuViewMy HealtheVet );
  4868   end;
  4869  
  4870   procedure  TfrmFrame. laVAA2Clic k(Sender:  TObject);
  4871   begin
  4872     ViewInfo (mnuInsura nce);
  4873   end;
  4874  
  4875   procedure  TfrmFrame. ViewInfo(S ender: TOb ject);
  4876   var
  4877     SelectNe w: Boolean ;
  4878     { TODO 5  -oDanP -c New CoverS heet : Nee d to finis h the VAA  button stu ff ASAP! }
  4879     aInsuran ceSubscrib erName: st ring;
  4880     aReportT ext: TStri ngList;
  4881     aAddress : string;
  4882     ID: inte ger;
  4883     aCPRS508 : ICPRS508 ;
  4884   begin
  4885     if Sende r is TMenu Item then  begin
  4886       ID :=  TMenuItem( Sender).Ta g;
  4887     end else  if Sender  is TActio n then beg in
  4888       ID :=  TAction(Se nder).Tag;
  4889     end else  begin
  4890       ID :=  -1;
  4891     end;
  4892     case ID  of
  4893       1:begi n { displa ys patient  inquiry r eport (whi ch optiona lly allows  new patie nt to be s elected) }
  4894           St atusText(T X_PTINQ);
  4895           Pa tientInqui ry(SelectN ew);
  4896           if  Assigned( FLastPage)  then
  4897              if FLastPa ge.Inherit sFrom(Tfrm Page) then
  4898                TfrmPage (FLastPage ).FocusFir stControl
  4899              else if Su pports(fLa stPage, IC PRS508, aC PRS508) th en
  4900                aCPRS508 .OnFocusFi rstControl (Sender);
  4901           St atusText(' ');
  4902           if  SelectNew  then mnuF ileOpenCli ck(mnuView Demo);
  4903         end;
  4904       2:begi n
  4905           if  (not User .IsReports Only) then  // Report s Only tab .
  4906              mnuFileEnc ounterClic k(Self);
  4907         end;
  4908       3:begi n
  4909           Re portBox(De tailPrimar yCare(Pati ent.DFN),  'Primary C are', True );
  4910         end;
  4911       4:begi n
  4912           if  Patient.P tIsMHV the n
  4913              ShellExecu te(laMHV.H andle, 'op en', PChar ('http://w ww.myhealt h.va.gov/' ), '', '',  SW_NORMAL );
  4914         end;
  4915       5:begi n
  4916          if  Patient.Pt IsVAA then
  4917            t ry
  4918               aReportTe xt := TStr ingList.Cr eate;
  4919               Patient.G etVAAInfor mation(aIn suranceSub scriberNam e, aReport Text);
  4920               ReportBox (aReportTe xt, aInsur anceSubscr iberName,  True);
  4921            f inally
  4922               FreeAndNi l(aReportT ext);
  4923            e nd;
  4924         end;
  4925       6:begi n
  4926           Sh owFlags;
  4927         end;
  4928       7:begi n
  4929           if  uUseVista Web = true  then
  4930              begin
  4931                lblCIRN. Alignment  := taCente r;
  4932                lstCIRNL ocations.V isible :=  false;
  4933                lstCIRNL ocations.S endToBack;
  4934                aAddress  := GetVis taWebAddre ss(Patient .DFN);
  4935                ShellExe cute(pnlCi rn.Handle,  'open', P Char(aAddr ess), PCha r(''), '',  SW_NORMAL );
  4936                pnlCIRN. BevelOuter  := bvRais ed;
  4937                Exit;
  4938              end;
  4939           if  not Remot eSites.Rem oteDataExi sts then E xit;
  4940           if  (not lstC IRNLocatio ns.Visible ) then
  4941              begin
  4942                pnlCIRN. BevelOuter  := bvLowe red;
  4943                lstCIRNL ocations.V isible :=  True;
  4944                lstCIRNL ocations.B ringToFron t;
  4945                lstCIRNL ocations.S etFocus;
  4946                pnlCIRN. Hint := 'C lick to cl ose list.' ;
  4947              end
  4948           el se
  4949              begin
  4950                pnlCIRN. BevelOuter  := bvRais ed;
  4951                lstCIRNL ocations.V isible :=  False;
  4952                lstCIRNL ocations.S endToBack;
  4953                pnlCIRN. Hint := 'C lick to di splay othe r faciliti es having  data for t his patien t.';
  4954              end;
  4955         end;
  4956       8:begi n
  4957           Vi ewReminder Tree;
  4958         end;
  4959       9:begi n { displa ys the win dow that s hows crisi s notes, w arnings, a llergies,  & advance  directives  }
  4960           Sh owCWAD;
  4961         end;
  4962     end;
  4963   end;
  4964  
  4965   procedure  TfrmFrame. mnuViewInf ormationCl ick(Sender : TObject) ;
  4966   begin
  4967     mnuViewD emo.Enable d := frmFr ame.pnlPat ient.Enabl ed;
  4968     mnuViewV isits.Enab led := frm Frame.pnlV isit.Enabl ed;
  4969     mnuViewP rimaryCare .Enabled : = frmFrame .pnlPrimar yCare.Enab led;
  4970     mnuViewM yHealtheVe t.Enabled  := not (Co py(frmFram e.laMHV.Hi nt, 1, 2)  = 'No');
  4971     mnuInsur ance.Enabl ed := not  (Copy(frmF rame.laVAA 2.Hint, 1,  2) = 'No' );
  4972     mnuViewF lags.Enabl ed := frmF rame.lblFl ag.Enabled ;
  4973     mnuViewR emoteData. Enabled :=  frmFrame. lblCirn.En abled;
  4974     mnuViewR eminders.E nabled :=  frmFrame.p nlReminder s.Enabled;
  4975     mnuViewP ostings.En abled := f rmFrame.pn lPostings. Enabled;
  4976   end;
  4977  
  4978   procedure  TfrmFrame. SetActiveT ab(PageID:  Integer);
  4979   begin
  4980     tabPage. TabIndex : = frmFrame .PageIDToT ab(PageID) ;
  4981     tabPageC hange(tabP age);
  4982   end;
  4983  
  4984   procedure  TfrmFrame. NextButton Click(Send er: TObjec t);
  4985   begin
  4986     if FProc cessingNex tClick the n Exit;
  4987     FProcces singNextCl ick := tru e;
  4988     popAlert s.AutoPopu p := TRUE;
  4989     mnuFileN ext.Enable d := True;
  4990     mnuFileN extClick(S elf);
  4991     FProcces singNextCl ick := fal se;
  4992   end;
  4993  
  4994   procedure  TfrmFrame. NextButton MouseDown( Sender: TO bject; But ton: TMous eButton;
  4995         Shif t: TShiftS tate; X, Y : Integer) ;
  4996   begin
  4997      popAler ts.AutoPop up := TRUE ;
  4998   end;
  4999  
  5000   procedure  TfrmFrame. SetUpNextB utton;
  5001    begin
  5002      if FNex tButton <>  nil then
  5003      begin
  5004         FNex tButton.fr ee;
  5005         FNex tButton :=  nil;
  5006      end;
  5007      FNextBu tton := TB itBtn.Crea te(self);
  5008      FNextBu tton.Paren t:= frmFra me;
  5009      FNextBu tton.Glyph  := FNextB uttonBitma p;
  5010      FNextBu tton.OnMou seDown :=  NextButton MouseDown;
  5011      FNextBu tton.OnCli ck := Next ButtonClic k;
  5012      FNextBu tton.Capti on := '&Ne xt';
  5013      FNextBu tton.Popup Menu := po pAlerts;
  5014      FNextBu tton.Top : = stsArea. Top;
  5015      FNextBu tton.Left  := FNextBu ttonL;
  5016      FNextBu tton.Heigh t := stsAr ea.Height;
  5017      FNextBu tton.Width  := stsAre a.Panels[2 ].Width;
  5018      FNextBu tton.TabSt op := True ;
  5019      FNextBu tton.TabOr der := 1;
  5020      FNextBu tton.show;
  5021   end;
  5022  
  5023   initializa tion
  5024     SpecifyF ormIsNotAD ialog(Tfrm Frame);
  5025  
  5026   finalizati on
  5027  
  5028  
  5029   end.