47. EPMO Open Source Coordination Office Redaction File Detail Report

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

47.1 Files compared

# Location File Last Modified
1 CPRS_Build_4.zip\CPRS_src\CPRS-chart fFrame.pas Tue May 15 15:01:48 2018 UTC
2 CPRS_Build_4.zip\CPRS_src\CPRS-chart fFrame.pas Tue May 15 19:40:33 2018 UTC

47.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 3 10364
Changed 2 4
Inserted 0 0
Removed 0 0

47.3 Comparison options

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

47.4 Active regular expressions

No regular expressions were active.

47.5 Comparison detail

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