67. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 3/22/2018 8:26:04 AM Central Daylight 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.

67.1 Files compared

# Location File Last Modified
1 OR_30_405V42.zip\OR_30_405V42_SRC fFrame.pas Wed Jan 17 18:08:06 2018 UTC
2 OR_30_405V42.zip\OR_30_405V42_SRC fFrame.pas Wed Mar 21 14:39:00 2018 UTC

67.2 Comparison summary

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

67.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

67.4 Active regular expressions

No regular expressions were active.

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