313. EPMO Open Source Coordination Office Redaction File Detail Report

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

313.1 Files compared

# Location File Last Modified
1 MHPRO_v1.x.zip\mhpro-web-master@18b10e0e051.zip\app\veteran\cordova\grunt_merge\android\common\lib app_utils.js Wed Dec 20 15:17:09 2017 UTC
2 MHPRO_v1.x.zip\mhpro-web-master@18b10e0e051.zip\app\veteran\cordova\grunt_merge\android\common\lib app_utils.js Fri Feb 1 20:43:48 2019 UTC

313.2 Comparison summary

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

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

313.4 Active regular expressions

No regular expressions were active.

313.5 Comparison detail

  1   //App_Reso urces.host name = "ht tps:// DNS . URL /";
  2   var roaWin dow = null ;
  3   var submit Roa = fals e;
  4   var App_Ut ils = {
  5       GetDom ainPath: f unction ()  {
  6           Ap p.debug =  false;
  7           if  (!App.Deb ugMode) {
  8                App.Debu gMode = tr ue;
  9                App_Util s.DebugMod e();
  10           }
  11           re turn App_U tils.GetRe ferencePat h();
  12       },
  13       GetRef erencePath : function  () {
  14           if  (document .location. hostname = = "localho st" || win dow.locati on.protoco l == "file :") {
  15                return A pp_Resourc es.hostnam e;
  16           }
  17           el se {
  18                var refe rencePath  = window.l ocation.pr otocol + " //" + wind ow.locatio n.host + w indow.loca tion.pathn ame;
  19                var inde x = refere ncePath.in dexOf("ind ex.html");
  20                if (inde x !== -1)  {
  21                    refe rencePath  = referenc ePath.subs tring(0, i ndex);
  22                }
  23                return e ncodeURI(r eferencePa th);
  24           }
  25       },
  26       SetReq uestHeader : function  () {
  27           va r sync = B ackbone.sy nc;
  28           Ba ckbone.syn c = functi on (method , model, o ptions) {
  29                options. beforeSend  = functio n (xhr) {
  30                    if ( App_Utils. GetSession Token() !=  null) {
  31                         xhr.setReq uestHeader ('Authoriz ation', 'B earer ' +  App_Utils. GetSession Token());
  32                    }
  33                };
  34                sync(met hod, model , options) ;
  35           };
  36       },
  37       ErrorH andling: f unction ()  {
  38           va r sync = B ackbone.sy nc;
  39           Ba ckbone.syn c = functi on (method , model, o ptions) {
  40                var erro r = option s.error;
  41                options. error = fu nction (xh r, statusT xt, thrown ) {
  42                    if ( !MHPRO.Vie w.header)  {//early e rrors befo re full st art
  43                         MHPRO.Layo ut.header. show(MHPRO .View.head er = new M HPRO.View. Header());
  44                    }
  45                    if ( xhr.status  === 401)  {
  46                         //User in  not authen ticated
  47                         App_Utils. LaunchpadL ogin();
  48                    }
  49                    else  if (model .key == 'e vent' && x hr.status  === 200) {
  50                         App.vent.t rigger('ev ent:succes s');
  51                    }
  52                    else  if (xhr.s tatus ===  404 && mod el.key ===  "Right of  Access")  {
  53                         //User has  not accep ted Right  of Access,  redirect  so they ca n be promp ted.
  54                         App_Utils. ROARedirec t();
  55                    }
  56                    else  if (model .key == 'r esource-di rectory-ha ' || model .key == 'r esource-di rectory-pv s' || mode l.key == ' resource-d irectory-m hpro') {
  57                         App.vent.t rigger('re sources:fa iled', mod el.key);
  58                    }
  59                    else  {
  60                         //Broadcas t model er ror
  61                         App.vent.t rigger(((m odel.key ?  model.key  : "genera l") + ":fa iled"), {  model: mod el, xhr: x hr });
  62                         //Let form at this fo r a human
  63                         App_Utils. FormatErro rMSG(model , xhr);
  64                         //Pass err or to mode l
  65                         error(xhr,  statusTxt , thrown);
  66                    }
  67                };
  68                sync(met hod, model , options) ;
  69           };
  70       },
  71       Cookie Exists: fu nction (co okieName)  {
  72           re turn docum ent.cookie .indexOf(c ookieName)  > 0;
  73       },
  74       Delete Cookie: fu nction (co okieName)  {
  75           do cument.coo kie = enco deURICompo nent(cooki eName) + " =deleted;  expires="  + new Date (0).toUTCS tring();
  76       },
  77       SetSes sionToken:  function  (name, val ue) {
  78           va lue = valu e.replace( /"/g, ""). replace(/' /g, "");
  79           se ssionStora ge.setItem (name, '"'  + value.t oString()  +'"');
  80       },
  81       ClearS essionToke n: functio n (name) {
  82           se ssionStora ge.setItem (name, nul l);
  83           se ssionStora ge.removeI tem(name);
  84       },
  85       Retrie veToken: f unction (n ame) {
  86           va r token =  sessionSto rage.getIt em(name);
  87           if  (token !=  'null' &&  token !=  null) {
  88                return t oken.repla ce(/"/g, " ");
  89           }
  90           el se { retur n null; }
  91       },
  92       GetSes sionToken:  function  () {
  93           re turn App_U tils.Retri eveToken(' token');
  94       },
  95       GetMHV Token: fun ction () {
  96           re turn App_U tils.Retri eveToken(' mhvToken') ;
  97       },
  98       AppCle anup: func tion () {
  99           if  (App_Util s.GetSessi onToken()  != null) {
  100                MHPRO.Mo del.Delete Token = ne w MHPRO.Mo del.delete Token();
  101                MHPRO.Mo del.Delete Token.dest roy({
  102                    data Type: "tex t",
  103                    cont entType: f alse,
  104                    proc essData: f alse,
  105                    comp lete: func tion (mode l, respons e) {
  106                         App.vent.t rigger('to ken:delete d');
  107                    }
  108                });
  109                App_Util s.ClearSes sionToken( 'token');
  110                App_Util s.ClearSes sionToken( 'mhvToken' );
  111           }
  112           el se {
  113                App.vent .trigger(' token:dele ted');
  114           }
  115           Ap p.vent.on( 'token:del eted', fun ction (dat a) {
  116                if (App_ Utils.Cook ieExists(' JSESSIONID ')) {
  117                    App_ Utils.Dele teCookie(' JSESSIONID ');
  118                    App. vent.trigg er('cookie :deleted') ;
  119                }
  120                else { A pp.vent.tr igger('coo kie:delete d'); }
  121                App.vent .trigger(' AppCleanup :complete' );
  122           }) ;
  123       },
  124       Format ErrorMSG:  function ( model, xhr ) {
  125           va r key, res , status,  statustext , msg, dev msg;
  126           ke y = res =  status = s tatustext  = msg = '' ;
  127           ke y = model. key ? mode l.key : "" ;
  128           if  (xhr.resp onseJSON)  {
  129                res = xh r.response JSON.devel operMessag e ? xhr.re sponseJSON .developer Message :  "";
  130                devmsg =  xhr.respo nseJSON.me ssage ? xh r.response JSON.messa ge : "";
  131           }
  132  
  133           st atus = xhr .status ?  xhr.status  : "No sta tus";
  134           st atustext =  xhr.statu sText ? xh r.statusTe xt : "No s tatus text ";
  135           ms g = key +  " encounte red the fo llowing er ror: " + r es + " (St atus: " +  status + "  / " + sta tustext+")  " + devms g;
  136           Ap p.vent.tri gger('webs ite:error' , msg);
  137       },
  138       GetLoc alStorage:  function  (key) {
  139           re turn local Storage.ge tItem(key) ;
  140       },
  141       SetLoc alStorage:  function  (key, valu e) {
  142           lo calStorage .setItem(k ey, JSON.s tringify(v alue));
  143       },
  144       Delete LocalStora ge: functi on (key) {
  145           lo calStorage .removeIte m(key);
  146       },
  147       Return ToLaunchpa d: functio n () {
  148           Ap p_Utils.Ap pCleanup() ;
  149           Ap p_Utils.VA MFLogout() ;
  150       },
  151       Launch padLogin:  function ( ) {
  152           // Redirect b ack to Lau nchpad Log in. User i s not logg edin
  153           if  (App.debu g) {
  154                console. log("Redir ect back t o Launchpa d Login.")
  155                console. log(MHPRO. Resources. HAResource s.get('oau th-login') .toJSON(). href + '?& redirect_u ri=' + App _Utils.Get ReferenceP ath() + 'm hpro/')
  156           }
  157           el se { windo w.location  = MHPRO.R esources.H AResources .get('oaut h-login'). toJSON().h ref + '?&r edirect_ur i=' + App_ Utils.GetR eferencePa th(); }
  158  
  159       },
  160       VAMFLo gout: func tion () {
  161           $( ".containe r-fluid"). hide();
  162           va r url = Ap p_Utils.Ge tDomainPat h() + 'sso eproxy/log out' + '?'  + new Dat e().getTim e();
  163  
  164           $. ajax({
  165                url: url ,
  166                async: f alse,
  167                success:  function  (response)  {
  168                    App. start();
  169                }
  170           }) ;
  171       },
  172       /*
  173       VAMFLo gout: func tion () {
  174           va r url = "" ;
  175           if  (MHPRO_Da ta.app.app Config.vet eran) {
  176                if (MHPR O_Data.app .appConfig .prod) {
  177                    //   For vetera n in pre-p roduction  and produc tion envir onments, a  logout pa ge has to  be set up  with VAAFI  team. Onc e the page  is set up , the clie nt will us e an endpo int simila r to:
  178                    //   https://<a uth-enviro nment-addr ess>/pkmsl ogout?file name=app-x -logout.ht ml
  179                    url  = App_Util s.GetDomai nPath() +  'pkmslogou t?filename =mbb-logou t.html';
  180                }
  181                else {
  182                    //   For vetera n in devel opment env ironments:
  183                    //   https://<e nvironment -address>/ ssoeproxy/ logout
  184  
  185                    //   A redirect _uri param eter may b e specifie d in devel opment to  redirect t he browser  after a s uccessful  logout:
  186                    //   https://<e nvironment -address>/ ssoeproxy/ logout?red irect_uri= (your app  home page)                 
  187                    url  = App_Util s.GetDomai nPath() +  'ssoeproxy /logout' +  '?' + new  Date().ge tTime() +  '&redirect _uri=' + A pp_Utils.G etDomainPa th() + 'la unchpad/';
  188                }
  189           }
  190           el se if (MHP RO_Data.ap p.appConfi g.provider ) {
  191                //  The  logout end point for  provider w ill be:
  192                //  http s://<envir onment_add ress>/Auth orizationS ervices/lo gout
  193                url = MH PRO.Resour ces.HAReso urces.get( 'logout'). toJSON().h ref + '?'  + new Date ().getTime () + '&red irect_uri= ' + App_Ut ils.GetDom ainPath()  + 'launchp ad/';
  194           }
  195           el se {//Cord ova logout  js here.
  196                App.vent .trigger(' start');
  197           }
  198           wi ndow.locat ion = url;
  199       },
  200       */
  201       GetUrl Parameter:  function  (sParam) {
  202           va r sPageURL  = window. location.s earch.subs tring(1);
  203           va r sURLVari ables = sP ageURL.spl it('&');
  204           fo r (var i =  0; i < sU RLVariable s.length;  i++)
  205           {
  206                var sPar ameterName  = sURLVar iables[i]. split('=') ;
  207                if (sPar ameterName [0] == sPa ram)
  208                {
  209                    retu rn sParame terName[1] ;
  210                }
  211           }
  212       },
  213       SetUrl : function  () {
  214           va r url = wi ndow.locat ion.href;
  215           ur l = url.sl ice(0, url .indexOf(' ?'));
  216           re turn encod eURI(url);
  217       },
  218       BackBu tton: func tion () {
  219           wi ndow.histo ry.back();
  220       },
  221       RightO fAccess: f unction ()  {
  222           MH PRO.Model. ROA = new  MHPRO.Mode l.roa();
  223           MH PRO.Model. ROA.fetch( {
  224                success:  function  (model, re sponse) {
  225                    if(r esponse.ri ghtOfAcces sAccepted) {
  226                         MHPRO.Data .Tracking. isRoaAccep ted = resp onse.right OfAccessAc cepted;
  227                         App.vent.t rigger('ro a:accepted ');
  228                    }els e{
  229                         App_Utils. ROARedirec t();
  230                    }
  231                    //re sponse.rig htOfAccess Accepted ?  App.vent. trigger('r oa:accepte d') : App_ Utils.ROAR edirect();
  232                },
  233                error: f unction (m odel, resp onse) {}
  234           }) ;
  235       },
  236       ROARed irect: fun ction () {
  237             var roaUrl  = encodeU RI('https: // DNS .vamisece. io/MobileH ealthPlatf ormWeb/roa /index.htm l?url=http s:// DNS .vamisece. io/mhpro/' );
  238  
  239           ro aWindow =  cordova.In AppBrowser .open(roaU rl, '_blan k', 'locat ion=no,too lbar=no');
  240  
  241           va r pathName ;
  242  
  243           ro aWindow.ad dEventList ener('load start', fu nction(eve nt) {
  244  
  245                App_Util s.setRemot eReqHeader ();
  246                App_Util s.setRemot eEULA();
  247  
  248                var xurl  = event.u rl;
  249                var urlP arser = do cument.cre ateElement ('a');
  250                urlParse r.href = x url;
  251  
  252                pathName  = urlPars er.pathnam e;
  253                pathName  = pathNam e.replace( /\//g, '') ;
  254  
  255                // alert ('loadstar t -> url:  ' + event. url + '\np athname: '  + pathNam e);
  256  
  257                /*
  258                var hash Value = xu rl.split(' #')[1];
  259                if (hash Value) {
  260                    if(h ashValue = == 'form-r eview'){
  261                         submitRoa  = true;
  262                    }els e{
  263                         submitRoa  = false;
  264                    }
  265                }
  266                */
  267  
  268                // alert ('pathname : ' + urlP arser.path name + '<b r>\ -> pat hName: ' +  pathName  + ' <br>\  Token: ' +  App_Utils .GetSessio nToken());
  269  
  270                if(submi tRoa && pa thName ===  'mhpro'){
  271                    MHPR O.Data.Tra cking.isRo aAccepted  = true;
  272                    MHPR O.Data.Tra cking.isUs erPressedC ancelOnROA  = false;
  273                    App. vent.trigg er('roa:cl ose');
  274                    App. vent.trigg er('load:u ser', { in it: true } );
  275                }
  276  
  277                if(pathN ame === 'l aunchpad') {
  278                    MHPR O.Data.Tra cking.isRo aAccepted  = false;
  279                    MHPR O.Data.Tra cking.isUs erPressedC ancelOnROA  = true;
  280                    App_ Utils.remo veRemoteRe qHeader();
  281                    App_ Utils.remo veRemoteEU LA();
  282                    App. vent.trigg er('roa:cl ose');
  283                    App. vent.trigg er('load:u ser', { in it: true } );
  284                }
  285  
  286           }) ;
  287  
  288           ro aWindow.ad dEventList ener('load stop', fun ction(even t) {
  289                console. log('loads top: ' + e vent.url);
  290                if (even t.url.inde xOf('#form -review')  > 0) {
  291                    subm itRoa = tr ue;
  292                }
  293           }) ;
  294  
  295           Ap p.vent.on( 'roa:close ', functio n(){
  296                roaWindo w.close();
  297           }) ;
  298       },
  299       setRem oteReqHead er: functi on(){
  300           ro aWindow.ex ecuteScrip t(
  301                {code :  "xhr.setRe questHeade r('Authori zation', ' Bearer '"  + App_Util s.GetSessi onToken()  + ");"},
  302                function (data){
  303                    if(d ata){}
  304                });
  305       },
  306       setRem oteEULA: f unction(){
  307           ro aWindow.ex ecuteScrip t({code :  "localStor age.setIte m('MHPRO_E ula', " +  App_Utils. GetLocalSt orage('MHP RO_Eula')  + ");"},
  308                function (data){
  309                    if(d ata){}
  310                });
  311       },
  312       remove RemoteReqH eader: fun ction(){
  313           ro aWindow.ex ecuteScrip t(
  314                {code :  "sessionSt orage.setI tem('token ', null);" },
  315                function (data){
  316                    if(d ata){}
  317                });
  318       },
  319       remove RemoteEULA : function (){
  320           ro aWindow.ex ecuteScrip t(
  321                {code :  "localStor age.remove Item('MHPR O_Eula');" },
  322                function (data){
  323                    if(d ata){}
  324                });
  325       },
  326       DebugM ode: funct ion () {
  327  
  328           if (document. location.h ostname ==  "localhos t" && App_ Utils.GetS essionToke n() === nu ll){
  329                //Quick  and dirty  input to a dd token i f developi ng and tok en is not  present
  330                var html  = '<form  class="for m-inline"> ' +
  331                    '<di v class="f orm-group" >' +
  332                    '<la bel for="t okenInput" >Token:</l abel> ' +
  333                    '<in put type=" text" clas s="form-co ntrol inpu t-sm" id=" tokenInput " placehol der="Enter  Token">'  +
  334                    //'< input type ="text" cl ass="form- control in put-sm" id ="tokenInp ut" placeh older="Ent er Token"  value="fcb c44de-b012 -4f74-ae9b -235be0203 b4d">' +
  335                    '</d iv>' +
  336                    '<bu tton type= "button" c lass="btn- default bt n-sm" id=" setToken"> Set Token< /button>'  +
  337                    '</f orm>';
  338                if (!$(" #debug").l ength) {
  339                    $("b ody").appe nd("<div i d='token'  style='pos ition:abso lute; righ t:10px; to p:0px;'>"  + html + " </div>");
  340                }
  341                $("#setT oken").on( "click", f unction ()  {
  342                    var  token = $( "#tokenInp ut").val() ;
  343                    App_ Utils.SetS essionToke n('token',  token);
  344                    loca tion.reloa d();
  345                });
  346           }
  347           if  (document .location. hostname = = "localho st" && App _Utils.Get LocalStora ge('MHPRO_ Eula')) {
  348                //Add bu tton to cl ear Eula l ocalStorag e value
  349                var html 2 = '<butt on type="b utton" cla ss="btn-de fault btn- sm" id="eu laBtn" sty le="positi on:absolut e; right:3 35px; top: 0px;">Dele te Eula</b utton>';
  350                if (!$(" #eulaBtn") .length) {
  351                    $("b ody").appe nd(html2);
  352                }
  353                $("#eula Btn").on(" click", fu nction ()  {
  354                    App_ Utils.Dele teLocalSto rage('MHPR O_Eula');
  355                    loca tion.reloa d();
  356                });
  357           }
  358           if  (document .location. hostname = = "localho st" && App _Utils.Get LocalStora ge('MHPRO_ Leave_Moda l')) {
  359                //Add bu tton to cl ear leave  modal loca lStorage v alue
  360                var html  = '<butto n type="bu tton" clas s="btn-def ault btn-s m" id="lea veBtn" sty le="positi on:absolut e; right:5 25px; top: 0px;">Dele te Leave</ button>';
  361                if (!$(" #leaveBtn" ).length)  {
  362                    $("b ody").appe nd(html);
  363                }
  364                $("#leav eBtn").on( "click", f unction ()  {
  365                    App_ Utils.Dele teLocalSto rage('MHPR O_Leave_Mo dal');
  366                    loca tion.reloa d();
  367                });
  368           }
  369           if  (document .location. hostname = = "localho st" && App _Utils.Get SessionTok en() != nu ll) {
  370                //Add bu tton to cl ear MHPUSE R token
  371                var html 3 = '<butt on type="b utton" cla ss="btn-de fault btn- sm" id="to kenBtn" st yle="posit ion:absolu te; right: 425px; top :0px;">Del ete Token< /button>';
  372                if (!$(" #tokenBtn" ).length)  {
  373                    $("b ody").appe nd(html3);
  374                }
  375                $("#toke nBtn").on( "click", f unction ()  {
  376                    App_ Utils.Clea rSessionTo ken('token ');
  377                    loca tion.reloa d();
  378                });
  379           }
  380           // Any other  code to qu ickly aid  in develop ment
  381       },
  382       Flatte nLinks: fu nction(obj ect) {
  383           va r links =  object.get ('link');
  384           if  (typeof l inks !== ' undefined' ) {
  385                for (var  i= 0, siz e = links. length; i< size; i++)  {
  386                    if ( links[i].t itle) {
  387                         object.set (links[i]. title,link s[i]);
  388                    } el se {
  389                         object.set ('self',li nks[i]);
  390                    }
  391                }
  392                object.u nset('link ');
  393           }
  394       },
  395       /**
  396        * Ret rieves ass ignment pa tient name s (returns  immediate ly; callba ck is only
  397        * exe cuted afte r all name s retrieve d)
  398        *
  399        * @pa ram as -
  400        *             Ba ckbone col lection or  javascrip t array
  401        * @pa ram cb -
  402        *             ca llback aft er all nam es retriev ed
  403        * @pa ram option alPatientN amesByIdCa che -
  404        *             An  optional  object to  use as a c ache, whos e keys are  the
  405        *             pa tient IDs  and values  are the p atient nam es. If spe cified,
  406        *             th is method  will add n ewly retri eved patie nt names t o the
  407        *             ob ject, and  rely on th e object f or a preli minary loo kup before
  408        *             re questing t he data fr om the ser ver. If un specified,  all names
  409        *             wi ll be retr ieved from  the serve r.
  410        */
  411       retrie vePatientN ames : fun ction(as,  cb) {
  412           va r baseUrl  = MHPRO.Re sources.PV SResources .get("pati ents").toJ SON().href ;
  413  
  414           va r isBackbo ne = !Arra y.isArray( as);
  415  
  416           //  using thi s until PV S direct e nd point i s availabl e
  417           ba seUrl = ba seUrl.repl ace(/patie nts/, "pat ient") + " /";
  418  
  419           //  should wo rk for arr ays and ba ckbone col lections -  CPB
  420           va r total =  as.length
  421           if  (total ==  0) {
  422                cb()
  423                return
  424           }
  425  
  426           va r distinc t = {};
  427           if  (isBackbo ne) {
  428                //var tm pCollectio n = new Ba ckbone.col lection(as .toJSON()) ;
  429                as.each( function(i tem) {
  430                    dist inct[item. get('patie ntId')] =  item;
  431                })
  432           }  else {
  433                for (var  i = 0; i  < as.lengt h; i++)
  434                    dist inct[as[i] .patientId ] = as[i];
  435           }
  436  
  437           // console.lo g('distinc t', distin ct);
  438  
  439           va r distCoun t = 0;
  440           va r complete dDistinct  = function (x) {
  441                distCoun t++;
  442                if (dist Count == O bject.keys (distinct) .length) {
  443                    if ( isBackbone ) {
  444                         as.each(fu nction(ass ignment) {
  445                             assign ment.set({
  446                                 di splayName:  distinct[ assignment .get('pati entId')].d isplayName
  447                             }, { s ilent: tru e });
  448                         });
  449                    } el se {
  450                         _.each(as,  function( assignment , index) {
  451                             assign ment.displ ayName = d istinct[as signment.p atientId]. displayNam e;
  452                         });
  453                    }
  454                    cb() ;
  455                }
  456           };
  457  
  458           $. each(disti nct, funct ion(patien tId, patie ntObj) {
  459                var pati entUrl;
  460                var loca lPatientId ;
  461                if (isBa ckbone) {
  462                    loca lPatientId  = patient Obj.get('p atientId') ;
  463                    pati entUrl = b aseUrl + p atientObj. get('patie ntAssignAu th') + "/"  + localPa tientId;
  464                }
  465                else {
  466                    loca lPatientId  = patient Obj.patien tId;
  467                    pati entUrl = b aseUrl + p atientObj. patientAss ignAuth +  "/" + loca lPatientId ;
  468                }
  469  
  470                $.ajax(
  471                    {
  472                         type : 'GE T',
  473                         url : pati entUrl,
  474                         dataType :  'json',
  475                         headers :  {
  476                             'Autho rization'  : 'Bearer  '
  477                             + App_ Utils.GetS essionToke n()
  478                         }
  479                    }).d one(functi on(respons e) {
  480                    if ( response)  {
  481                         distinct[l ocalPatien tId].displ ayName = r esponse.di splayName
  482                    }
  483                    comp letedDisti nct()
  484                }).fail( function(r esponse) {
  485                    dist inct[local PatientId] .displayNa me = "---"
  486                    comp letedDisti nct()
  487                });
  488           }) ;
  489       },
  490       /**
  491        * Che cks is a g iven strin g contains  invalid d ate.
  492        * @pa ram str -  the string  to be val idated
  493        * @re turn Boole an
  494        */
  495       HasInv alidDate:  function(d ate) {
  496           //  validate  date forma t mm/dd/yy yy with op tional tim e extensio n
  497           va r dateChec k = new Re gExp("^((0 ?[1-9]|1[0 12])[/](0? [1-9]|[12] [0-9]|3[01 ])[/](19|2 0)?[0-9]{2 })*$");
  498           if  (!dateChe ck.test(da te)) retur n true;
  499  
  500           va r componen ts = date. split("/") ,
  501                month =  parseInt(c omponents[ 0], 10),
  502                day = pa rseInt(com ponents[1] , 10),
  503                // parse int on e.g . "2014 14 :23" will  just retur n the year
  504                year = p arseInt(co mponents[2 ], 10);
  505  
  506           if  (month == = 4 || mon th === 6 | | month == = 9 || mon th === 11)  {
  507                if (day  > 30) retu rn true;
  508           }  else if (m onth !== 2 ) {
  509                if (day  > 31) retu rn true;
  510           }  else {
  511                // we ar e in feb
  512                if (year  % 4 === 0 ) {
  513                    // l eap year
  514                    if ( day > 29)  {
  515                         return tru e;
  516                    }
  517                } else {
  518                    if ( day > 28)  {
  519                         return tru e;
  520                    }
  521                }
  522           }
  523           re turn false ;
  524       },
  525       /**
  526        * The  element t o focus on  page load , e.g. aut henticated  user name
  527        */
  528       FocusO nLoad: fun ction () {
  529           //  $('#heade r-login-li nk').focus ();    //  header <a>  id for mh puser.disp layname
  530           $( '#isHomeTa g').focus( );
  531       },
  532       /**
  533        * For  modals th at are NOT  part of s ame templa te as its  invoking v iew, e.g.  About, Hel p,
  534        * Tim eout, and  EULA Modal  code segm ent is enc losed with in the .mo dal-contai ner that i s
  535        * out side of th e core ele ments (hea der, main,  footer).  See HTML s tructure i n layout.h tml.
  536        * @pa ram modal  - The moda l ID (pref ixed with  '#") or un ique CSS s elector (p refixed wi th '.')
  537        */
  538       SetMod alContaine r: functio n (modal)  {
  539           $( modal).on( 'shown.bs. modal', fu nction ()  {
  540                $(this). addClass(' scroll-dis able');
  541                $("heade r, #conten t, footer,  .scrollba r-gradient ").attr('a ria-hidden ', 'true') ;
  542                $(modal) .removeAtt r('aria-hi dden');    // aria-hi dden=false  can be un reliable
  543                $(".moda l-title"). focus();
  544           }) ;
  545           $( modal).on( 'hidden.bs .modal', f unction ()  {
  546                $(this). removeClas s('scroll- disable');
  547                $("heade r, #conten t, footer,  .scrollba r-gradient ").removeA ttr('aria- hidden');
  548                $(modal) .attr("ari a-hidden",  true);
  549           }) ;
  550       },
  551  
  552       /**
  553        * For  modals th at are emb edded in < main> as p art of the  invoking  view,
  554        * e.g . Veteran:  ; Provide r: Patient  Search, P ending Upd ates,
  555        * .
  556        * @pa ram modal  - ID of th e modal be ing manipu lated
  557        * @pa ram focus  - optional : the HTML  element t o get focu s when mod al is dism issed;
  558        *         can be  either a  CSS class  name (if u nique) or  an element  ID; defau lt
  559        *         to '.m odal-title ' if not p rovided
  560        */
  561       SetMai nModal: fu nction (mo dal, focus ) {
  562           //  on displa y
  563           $( modal).on( 'shown.bs. modal', fu nction ()  {
  564                $("heade r, .modal- hide, foot er, .scrol lbar-gradi ent").attr ('aria-hid den', 'tru e');
  565                $(modal) .removeAtt r('aria-hi dden');  / / aria-hid den=false  can be unr eliable
  566                var targ et = focus  ? focus :  '.modal-t itle';     // default  to .modal -title (us ually <h4> )
  567                $(target ).focus();
  568           }) ;
  569  
  570           //  on dismis s
  571           $( modal).on( 'hidden.bs .modal', f unction ()  {
  572                $("heade r, .modal- hide, foot er, .scrol lbar-gradi ent").remo veAttr('ar ia-hidden' );
  573                $(modal) .attr('ari a-hidden',  true);
  574           }) ;
  575       }
  576   };
  577  
  578   jQuery.fn. putCursorA tEnd = fun ction () {
  579       return  this.each (function  () {
  580           // console.lo g("putCurs orAtEnd");
  581           //  Cache ref erences
  582           va r $el = $( this),
  583                el = thi s;
  584           //  Only focu s if input  isn't alr eady
  585           if  (!$el.is( ":focus"))  {
  586                $el.focu s();
  587           }
  588           //  If this f unction ex ists... (I E 9+)
  589           if  (el.setSe lectionRan ge) {
  590                // Doubl e the leng th because  Opera is  inconsiste nt about w hether a c arriage re turn is on e characte r or two.
  591                var len  = $el.val( ).length *  2;
  592                // Timeo ut seems t o be requi red for Bl ink
  593                setTimeo ut(functio n () {
  594                    el.s etSelectio nRange(len , len);
  595                }, 1);
  596           }  else {
  597                // As a  fallback,  replace th e contents  with itse lf
  598                // Doesn 't work in  Chrome, b ut Chrome  supports s etSelectio nRange
  599                $el.val( $el.val()) ;
  600           }
  601           //  Scroll to  the botto m, in case  we're in  a tall tex tarea
  602           //  (Necessar y for Fire fox and Ch rome)
  603           th is.scrollT op = 99999 9;
  604       });
  605   };