46. EPMO Open Source Coordination Office Redaction File Detail Report

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

46.1 Files compared

# Location File Last Modified
1 CPRS_src.zip\CPRS_src\CPRS-chart fFrame.pas Fri Mar 2 18:13:10 2018 UTC
2 CPRS_src.zip\CPRS_src\CPRS-chart fFrame.pas Fri Mar 2 19:28:48 2018 UTC

46.2 Comparison summary

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

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

46.4 Active regular expressions

No regular expressions were active.

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