46. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 2/17/2017 12:43:23 PM 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_V32_T20_cif.zip\OR_30_405V20_SRC.zip\CPRS-chart fFrame.pas Thu Dec 15 14:28:30 2016 UTC
2 CPRS_V32_T20_cif.zip\OR_30_405V20_SRC.zip\CPRS-chart fFrame.pas Fri Feb 17 17:16:56 2017 UTC

46.2 Comparison summary

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