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

309.1 Files compared

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

309.2 Comparison summary

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

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

309.4 Active regular expressions

No regular expressions were active.

309.5 Comparison detail

  1   //App_Reso urces.host name = "ht tps:// DNS . URL /";
  2  
  3   var App_Ut ils = {
  4           Ge tDomainPat h : functi on() {
  5                    if ( /localhost $/.test(do cument.loc ation.host name) || w indow.loca tion.proto col == "fi le:") {
  6                             App.de bug = true ;
  7                             if (!A pp.DebugMo de) {
  8                                      App.Debu gMode = tr ue;
  9                                      App_Util s.DebugMod e();
  10                             }
  11                             return  App_Utils .GetRefere ncePath();
  12                    } el se {
  13                             App.de bug = fals e;
  14                             return  encodeURI (window.lo cation.pro tocol + "/ /"
  15                                               + window.l ocation.ho st + "/");
  16                    }
  17           },
  18           Ge tReference Path : fun ction() {
  19                    var  hn = docum ent.locati on.hostnam e
  20                    var  port = doc ument.loca tion.port
  21  
  22                    if ( ((hn == "l ocalhost"  && port ==  4000) ||  hn == 'pro vider.mhpr o.localhos t')
  23                                      || windo w.location .protocol  == "file:" ) {
  24                             return  encodeURI (App_Resou rces.hostn ameProvide r);
  25                    } el se if ((hn  == "local host" && p ort == 900 0)) {
  26                             // jas mine testi ng veteran
  27                             return  encodeURI (App_Resou rces.hostn ame);
  28                    } el se if (((h n == "loca lhost" &&  port == 30 00) || hn  == 'vetera n.mhpro.lo calhost')
  29                                      || windo w.location .protocol  == "file:" ) {
  30                             return  encodeURI (App_Resou rces.hostn ame);
  31                    } el se {
  32                             var re ferencePat h = window .location. protocol +  "//"
  33                                               + window.l ocation.ho st + windo w.location .pathname;
  34                             var in dex = refe rencePath. indexOf("i ndex.html" );
  35                             if (in dex !== -1 ) {
  36                                      referenc ePath = re ferencePat h.substrin g(0, index );
  37                             }
  38                             return  encodeURI (reference Path);
  39                    }
  40           },
  41           Se tRequestHe ader : fun ction() {
  42                    var  sync = Bac kbone.sync ;
  43                    Back bone.sync  = function (method, m odel, opti ons) {
  44                             option s.beforeSe nd = funct ion(xhr) {
  45                                      if (App_ Utils.GetS essionToke n() != nul l) {
  46                                               xhr.setReq uestHeader ('Authoriz ation', 'B earer '
  47                                                                + Ap p_Utils.Ge tSessionTo ken());
  48                                      }
  49                             };
  50                             sync(m ethod, mod el, option s);
  51                    };
  52           },
  53           Er rorHandlin g : functi on() {
  54                    var  sync = Bac kbone.sync ;
  55                    Back bone.sync  = function (method, m odel, opti ons) {
  56                             var er ror = opti ons.error;
  57                             option s.error =  function(x hr, status Txt, throw n) {
  58                                      if (!MHP RO.View.he ader) {//  early erro rs before  full start
  59                                               MHPRO.Layo ut.header
  60                                                                .sho w(MHPRO.Vi ew.header  = new MHPR O.View.Hea der());
  61                                      }
  62                    if ( xhr.status  === 401 | | xhr.stat us === 403 ) {
  63                         //User in  not authen ticated
  64                         App_Utils. LaunchpadL ogin();
  65  
  66                         if (App.de bug) {
  67                             if (mo del.key == = "Last Ac cessed Tim e") {
  68                                 cl earInterva l(App.Keep AliveInter val); //st op the loo p for heav ens sake
  69                             }
  70                         }
  71                                      } else i f (model.k ey == 'eve nt' && xhr .status == = 200) {
  72                                               App.vent.t rigger('ev ent:succes s');
  73                                      } else i f ((model. key == 'de lete:compl eted' || m odel.key = = 'delete: alert') &&  xhr.statu s === 200)  {
  74                         var delete Id = model .get("_id" );
  75                         var eventT ype = mode l.get("eve ntType");
  76                         App.vent.t rigger('de lete:succe ss', {curr entTab: ev entType, d eleteId: d eleteId});
  77                    } el se if (mod el.key = ' delete:com pleted') {
  78                                               // a real  error occu rred on th e delete,  we still n eed to cle ar out the  modal:
  79                         $('#delete -event-mod al').modal ('hide');
  80  
  81                         // Broadca st model e rror
  82                         App.vent.t rigger(
  83                             ((mode l.key ? mo del.key :  "general")  + ":faile d"),
  84                             {
  85                                 mo del : mode l,
  86                                 xh r : xhr
  87                             });
  88                         // Let for mat this f or a human
  89                         App_Utils. FormatErro rMSG(model , xhr);
  90                         // Pass er ror to mod el
  91                         error(xhr,  statusTxt , thrown);
  92                                      }
  93                    else  if (model .key == 'd elete:mult iple-provi der' && xh r.status = == 200) {
  94                         App.vent.t rigger('de lete:multi Provider') ;
  95                    } el se if (xhr .status == = 404
  96                                                       &&  model.key  === "Righ t of Acces s") {
  97                                               // User ha s not acce pted Right  of Access , redirect  so they
  98                                               // can be  prompted.
  99                                               App_Utils. ROARedirec t();
  100                                      } else i f (model.k ey == 'res ource-dire ctory-ha'
  101                                                       ||  model.key  == 'resou rce-direct ory-pvs'
  102                                                       ||  model.key  == 'resou rce-direct ory-mhpro' ) {
  103                                               App.vent.t rigger('re sources:fa iled', mod el.key);
  104                                      } else {
  105                                               // Broadca st model e rror
  106                                               App.vent.t rigger(
  107                                                                ((mo del.key ?  model.key  : "general ") + ":fai led"),
  108                                                                {
  109                                                                         model  : model,
  110                                                                         xhr :  xhr
  111                                                                });
  112                                               // Let for mat this f or a human
  113                                               App_Utils. FormatErro rMSG(model , xhr);
  114                                               // Pass er ror to mod el
  115                                               error(xhr,  statusTxt , thrown);
  116                                      }
  117                             };
  118                             sync(m ethod, mod el, option s);
  119                    };
  120           },
  121           Co okieExists  : functio n(cookieNa me) {
  122                    retu rn documen t.cookie.i ndexOf(coo kieName) >  0;
  123           },
  124           De leteCookie  : functio n(cookieNa me) {
  125                    docu ment.cooki e = encode URICompone nt(cookieN ame) + "=d eleted; ex pires="
  126                                      + new Da te(0).toUT CString();
  127           },
  128           Se tSessionTo ken : func tion(name,  value) {
  129                    valu e = value. replace(/" /g, "").re place(/'/g , "");
  130                    sess ionStorage .setItem(n ame, '"' +  value.toS tring() +  '"');
  131           },
  132           Cl earSession Token : fu nction(nam e) {
  133                    sess ionStorage .setItem(n ame, null) ;
  134           },
  135           Re trieveToke n : functi on(name) {
  136                    var  token = se ssionStora ge.getItem (name);
  137                    if ( token != ' null' && t oken != nu ll) {
  138                             return  token.rep lace(/"/g,  "");
  139                    } el se {
  140                             return  null;
  141                    }
  142           },
  143           Ge tSessionTo ken : func tion() {
  144                    retu rn App_Uti ls.Retriev eToken('to ken');
  145           },
  146           Ge tMHVToken  : function () {
  147                    retu rn App_Uti ls.Retriev eToken('mh vToken');
  148           },
  149           Ap pCleanup :  function( ) {
  150                    if ( App_Utils. GetSession Token() !=  null) {
  151                             MHPRO. Model.Dele teToken =  new MHPRO. Model.dele teToken();
  152                             MHPRO. Model.Dele teToken.de stroy({
  153                                      dataType  : "text",
  154                                      contentT ype : fals e,
  155                                      processD ata : fals e,
  156                                      complete  : functio n(model, r esponse) {
  157                                               App.vent.t rigger('to ken:delete d');
  158                                      }
  159                             });
  160                             App_Ut ils.ClearS essionToke n('token') ;
  161                             App_Ut ils.ClearS essionToke n('mhvToke n');
  162                    } el se {
  163                             App.ve nt.trigger ('token:de leted');
  164                    }
  165                    App. vent.on('t oken:delet ed', funct ion(data)  {
  166                             if (Ap p_Utils.Co okieExists ('JSESSION ID')) {
  167                                      App_Util s.DeleteCo okie('JSES SIONID');
  168                                      App.vent .trigger(' cookie:del eted');
  169                             } else  {
  170                                      App.vent .trigger(' cookie:del eted');
  171                             }
  172                             App.ve nt.trigger ('AppClean up:complet e');
  173                    });
  174           },
  175           Fo rmatErrorM SG : funct ion(model,  xhr) {
  176                    var  key, res,  status, st atustext,  msg, devms g;
  177                    key  = res = st atus = sta tustext =  msg = '';
  178                    key  = model.ke y ? model. key : "";
  179                    if ( xhr.respon seJSON) {
  180                             res =  xhr.respon seJSON.dev eloperMess age ? xhr. responseJS ON.develop erMessage
  181                                               : "";
  182                             devmsg  = xhr.res ponseJSON. message ?  xhr.respon seJSON.mes sage : "";
  183                    }
  184  
  185                    stat us = xhr.s tatus ? xh r.status :  "No statu s";
  186                    stat ustext = x hr.statusT ext ? xhr. statusText  : "No sta tus text";
  187                    msg  = key + "  encountere d the foll owing erro r: " + res  + " (Stat us: "
  188                                      + status  + " / " +  statustex t + ") " +  devmsg;
  189                    App. vent.trigg er('websit e:error',  msg);
  190           },
  191           Ge tLocalStor age : func tion(key)  {
  192                    retu rn localSt orage.getI tem(key);
  193           },
  194           Se tLocalStor age : func tion(key,  value) {
  195                    loca lStorage.s etItem(key , JSON.str ingify(val ue));
  196           },
  197           De leteLocalS torage : f unction(ke y) {
  198                    loca lStorage.r emoveItem( key);
  199           },
  200           Re turnToLaun chpad : fu nction() {
  201                    // R edirect ba ck to Laun chpad here .
  202                    wind ow.locatio n = App_Ut ils.GetDom ainPath()  + "launchp ad";
  203           },
  204           La unchpadLog in : funct ion() {
  205                    // R edirect ba ck to Laun chpad Logi n. User is  not logge din
  206                    if ( App.debug)  {
  207                             consol e.log("Red irect back  to Launch pad Login. ")
  208                             consol e
  209                                               .log(MHPRO .Resources .HAResourc es.get('oa uth-login' )
  210                                                                .toJ SON().href
  211                                                                + '? &redirect_ uri='
  212                                                                + Ap p_Utils.Ge tReference Path()
  213                                                                + 'm hpro/')
  214                    } el se {
  215                             window .location  = MHPRO.Re sources.HA Resources. get('oauth -login')
  216                                               .toJSON(). href
  217                                               + '?&redir ect_uri='  + App_Util s.GetRefer encePath() ;
  218                    }
  219  
  220           },
  221           VA MFLogout :  function( ) {
  222                    var  url = "";
  223                    if ( MHPRO_Data .app.appCo nfig.veter an) {
  224                             if (MH PRO_Data.a pp.appConf ig.prod) {
  225                                      // For v eteran in  pre-produc tion and p roduction  environmen ts, a
  226                                      // logou t page has  to be set  up with V AAFI team.  Once the  page
  227                                      // is se t up, the  client wil l use an e ndpoint si milar to:
  228                                      // https ://<auth-e nvironment -address>/ pkmslogout ?filename= app-x-logo ut.html
  229                                      url = Ap p_Utils.Ge tDomainPat h()
  230                                                       +  'pkmslogou t?filename =mbb-logou t.html';
  231                             } else  {
  232                                      // For v eteran in  developmen t environm ents:
  233                                      // https ://<enviro nment-addr ess>/ssoep roxy/logou t
  234  
  235                                      // A red irect_uri  parameter  may be spe cified in  developmen t to
  236                                      // redir ect the br owser afte r a succes sful logou t:
  237                                      // https ://<enviro nment-addr ess>/ssoep roxy/logou t?redirect _uri=(your
  238                                      // app h ome page)
  239                                      url = Ap p_Utils.Ge tDomainPat h() + 'sso eproxy/log out' + '?'
  240                                                       +  new Date() .getTime()  + '&redir ect_uri='
  241                                                       +  App_Utils. GetDomainP ath() + 'l aunchpad/' ;
  242                             }
  243                    } el se if (MHP RO_Data.ap p.appConfi g.provider ) {
  244                             // The  logout en dpoint for  provider  will be:
  245                             // htt ps://<envi ronment_ad dress>/Aut horization Services/l ogout
  246                             url =  MHPRO.Reso urces.HARe sources.ge t('logout' ).toJSON() .href + '? '
  247                                               + new Date ().getTime () + '&red irect_uri= '
  248                                               + App_Util s.GetDomai nPath() +  'launchpad /';
  249                    } el se {// Cor dova logou t js here.
  250                             // con sole.log(' in else co rdova....' );
  251  
  252                    }
  253                    wind ow.locatio n = url;
  254           },
  255           Ge tUrlParame ter : func tion(sPara m) {
  256                    var  sPageURL =  window.lo cation.sea rch.substr ing(1);
  257                    var  sURLVariab les = sPag eURL.split ('&');
  258                    for  (var i = 0 ; i < sURL Variables. length; i+ +) {
  259                             var sP arameterNa me = sURLV ariables[i ].split('= ');
  260                             if (sP arameterNa me[0] == s Param) {
  261                                      return s ParameterN ame[1];
  262                             }
  263                    }
  264           },
  265           Se tUrl : fun ction() {
  266                    var  url = wind ow.locatio n.href;
  267                    url  = url.slic e(0, url.i ndexOf('?' ));
  268                    retu rn encodeU RI(url);
  269           },
  270           Ba ckButton :  function( ) {
  271                    wind ow.history .back();
  272           },
  273           Ri ghtOfAcces s : functi on() {
  274                    MHPR O.Model.RO A = new MH PRO.Model. roa();
  275                    MHPR O.Model.RO A.fetch({
  276                             succes s : functi on(model,  response)  {
  277                                      response .rightOfAc cessAccept ed ? App.v ent
  278                                                       .t rigger('ro a:accepted ') : App_U tils.ROARe direct();
  279                             },
  280                             error  : function (model, re sponse) {
  281                             }
  282                    });
  283           },
  284           RO ARedirect  : function () {
  285                    wind ow.locatio n = App_Ut ils.GetDom ainPath()
  286                                      + 'Mobil eHealthPla tformWeb/r oa/index.h tml?url='
  287                                      + App_Ut ils.GetRef erencePath ();
  288           },
  289           De bugMode :  function()  {
  290  
  291                    if ( App_Utils. GetSession Token() == = null) {
  292                             // Qui ck and dir ty input t o add toke n if devel oping and  token is n ot
  293                             // pre sent
  294                             var ht ml = '<for m class="f orm-inline ">'
  295                                               + '<div cl ass="form- group">'
  296                                               + '<label  for="token Input">Tok en:</label > '
  297                                               + '<input  type="text " class="f orm-contro l input-sm " id="toke nInput" pl aceholder= "Enter Tok en" value= "">'
  298                                               + '</div>'
  299                                               + '<button  type="but ton" class ="btn-defa ult btn-sm " id="setT oken">Set  Token</but ton>'
  300                                               + '</form> ';
  301                             if (!$ ("#debug") .length) {
  302                                      $("body" ).append(
  303                                                       "< div id='to ken' style ='position :absolute;  right:10p x; top:0px ;'>"
  304                                                                         + html  + "</div> ");
  305                             }
  306                             $("#se tToken").o n("click",  function( ) {
  307                                      var toke n = $("#to kenInput") .val();
  308                                      App_Util s.SetSessi onToken('t oken', tok en);
  309                                      location .reload();
  310                             });
  311                    }
  312                    if ( App_Utils. GetLocalSt orage('MHP RO_Eula'))  {
  313                             // Add  button to  clear Eul a localSto rage value
  314                             var ht ml2 = '<bu tton type= "button" c lass="btn- default bt n-sm" id=" eulaBtn" s tyle="posi tion:absol ute; right :335px; to p:0px;">De lete Eula< /button>';
  315                             if (!$ ("#eulaBtn ").length)  {
  316                                      $("body" ).append(h tml2);
  317                             }
  318                             $("#eu laBtn").on ("click",  function()  {
  319                                      App_Util s.DeleteLo calStorage ('MHPRO_Eu la');
  320                                      location .reload();
  321                             });
  322                    }
  323                    if ( App_Utils. GetSession Token() !=  null) {
  324                             // Add  button to  clear MHP USER token
  325                             var ht ml3 = '<bu tton type= "button" c lass="btn- default bt n-sm" id=" tokenBtn"  style="pos ition:abso lute; righ t:425px; t op:0px;">D elete Toke n</button> ';
  326                             if (!$ ("#tokenBt n").length ) {
  327                                      $("body" ).append(h tml3);
  328                             }
  329                             $("#to kenBtn").o n("click",  function( ) {
  330                                      App_Util s.ClearSes sionToken( 'token');
  331                                      location .reload();
  332                             });
  333                    }
  334  
  335                    // A ny other c ode to qui ckly aid i n developm ent
  336           },
  337           Fl attenLinks  : functio n(object)  {
  338                    var  links = ob ject.get(' link');
  339                    if ( typeof lin ks !== 'un defined')  {
  340                             for (v ar i = 0,  size = lin ks.length;  i < size;  i++) {
  341                                      if (link s[i].title ) {
  342                                               object.set (links[i]. title, lin ks[i]);
  343                                      } else {
  344                                               object.set ('self', l inks[i]);
  345                                      }
  346                             }
  347                             object .unset('li nk');
  348                    }
  349           },
  350           ge tResourceU rl : funct ion(rel, p arameters)  {
  351                    var  url = MHPR O.Resource s.MHPRORes ources.get (rel).toJS ON().href;
  352                    if ( MHPRO.Data .app.appCo nfig.provi der) {
  353                              url=u rl.replace ("{provide r-assignin g-authorit y}",
  354                                                                                                            MHPR O.Model.Us er.attribu tes.mhpuse r.userIden tifier.ass igningAuth ority);
  355                              url=u rl.replace ("{provide r-id}",
  356                                                                                                            MHPR O.Model.Us er.attribu tes.mhpuse r.userIden tifier.uni queId);
  357                    }
  358                    if ( parameters ) {
  359                             for (v ar parm in  parameter s) {
  360                                               url=url.re place('{'+ parm+'}',  parameters [parm]);
  361                             }
  362                    }
  363                    retu rn url;
  364           },
  365           /* *
  366            *  Retrieves  assignmen t patient  names (ret urns immed iately; ca llback is  only
  367            *  executed  after all  names retr ieved)
  368            *
  369            *  @param as  -
  370            *              Backbone  collectio n or javas cript arra y
  371            *  @param cb  -
  372            *              callback  after all  names ret rieved
  373            *  @param op tionalPati entNamesBy IdCache -
  374            *              An optio nal object  to use as  a cache,  whose keys  are the
  375            *              patient  IDs and va lues are t he patient  names. If  specified ,
  376            *              this met hod will a dd newly r etrieved p atient nam es to the
  377            *              object,  and rely o n the obje ct for a p reliminary  lookup be fore
  378            *              requesti ng the dat a from the  server. I f unspecif ied, all n ames
  379            *              will be  retrieved  from the s erver.
  380            * /
  381           re trievePati entNames :  function( as, cb) {
  382           va r baseUrl  = MHPRO.Re sources.PV SResources .get("pati ents").toJ SON().href ;
  383  
  384           va r isBackbo ne = !Arra y.isArray( as);
  385  
  386           //  using thi s until PV S direct e nd point i s availabl e
  387           ba seUrl = ba seUrl.repl ace(/patie nts/, "pat ient") + " /";
  388  
  389           //  should wo rk for arr ays and ba ckbone col lections -  CPB
  390           va r total =  as.length
  391           if  (total ==  0) {
  392                cb()
  393                return
  394           }
  395  
  396  
  397           va r distinc t = {};
  398           if  (isBackbo ne) {
  399                //var tm pCollectio n = new Ba ckbone.col lection(as .toJSON()) ;
  400                as.each( function(i tem) {
  401                    dist inct[item. get('patie ntId')] =  item;
  402                })
  403           }  else {
  404                for (var  i = 0; i  < as.lengt h; i++)
  405                    dist inct[as[i] .patientId ] = as[i];
  406           }
  407  
  408           // console.lo g('distinc t', distin ct);
  409  
  410           va r distCoun t = 0;
  411           va r complete dDistinct  = function (x) {
  412                distCoun t++;
  413                if (dist Count == O bject.keys (distinct) .length) {
  414                                                                if ( isBackbone ) {
  415                                                                                           as.each(fu nction(ass ignment) {
  416                                                                                                   as signment.s et({
  417                                                                                                                     displa yName: dis tinct[assi gnment.get ('patientI d')].displ ayName
  418                                                                                                                     }, { s ilent: tru e });
  419                                                                                           });
  420                                                                } el se {
  421                                      _.each(a s, functio n(assignme nt, index)  {
  422                             assign ment.displ ayName = d istinct[as signment.p atientId]. displayNam e;
  423                                      });
  424                                                                         }
  425                    cb() ;
  426                }
  427           };
  428  
  429           $. each(disti nct, funct ion(patien tId, patie ntObj) {
  430                var pati entUrl;
  431                var loca lPatientId ;
  432                if (isBa ckbone) {
  433                    loca lPatientId  = patient Obj.get('p atientId') ;
  434                    pati entUrl = b aseUrl + p atientObj. get('patie ntAssignAu th') + "/"  + localPa tientId;
  435                }
  436                else {
  437                    loca lPatientId  = patient Obj.patien tId;
  438                    pati entUrl = b aseUrl + p atientObj. patientAss ignAuth +  "/" + loca lPatientId ;
  439                }
  440  
  441                $.ajax(
  442                    {
  443                         type : 'GE T',
  444                         url : pati entUrl,
  445                         dataType :  'json',
  446                         headers :  {
  447                             'Autho rization'  : 'Bearer  '
  448                             + App_ Utils.GetS essionToke n()
  449                         }
  450                    }).d one(functi on(respons e) {
  451                    if ( response)  {
  452                         distinct[l ocalPatien tId].displ ayName = r esponse.di splayName
  453                    }
  454                    comp letedDisti nct()
  455                                                                }).f ail(functi on(respons e) {
  456                                                                                  distinct [localPati entId].dis playName =  "---"
  457                                                                                  complete dDistinct( )
  458                                                       }) ;
  459           }) ;
  460       },
  461           /* *
  462            *  Checks is  a given s tring cont ains inval id date.
  463            *
  464            *  @param da te -
  465            *              the stri ng to be v alidated
  466            *  @return B oolean
  467            * /
  468           Ha sInvalidDa te : funct ion(date)  {
  469                    // v alidate da te format  mm/dd/yyyy  with opti onal time  extension
  470                    var  dateCheck  = new RegE xp(
  471                                      "^((0?[1 -9]|1[012] )[/](0?[1- 9]|[12][0- 9]|3[01])[ /](19|20)? [0-9]{2})* $");
  472                    if ( !dateCheck .test(date ))
  473                             return  true;
  474  
  475                    var  components  = date.sp lit("/"),  month = pa rseInt(com ponents[0] , 10), day  = parseIn t(
  476                                      componen ts[1], 10) ,
  477                    // p arseint on  e.g. "201 4 14:23" w ill just r eturn the  year
  478                    year  = parseIn t(componen ts[2], 10) ;
  479  
  480                    if ( month ===  4 || month  === 6 ||  month ===  9 || month  === 11) {
  481                             if (da y > 30)
  482                                      return t rue;
  483                    } el se if (mon th !== 2)  {
  484                             if (da y > 31)
  485                                      return t rue;
  486                    } el se {
  487                             // we  are in feb
  488                             if (ye ar % 4 ===  0) {
  489                                      // leap  year
  490                                      if (day  > 29) {
  491                                               return tru e;
  492                                      }
  493                             } else  {
  494                                      if (day  > 28) {
  495                                               return tru e;
  496                                      }
  497                             }
  498                    }
  499                    retu rn false;
  500           },
  501           /* *
  502            *  Place foc us at firs t element  of bootstr ap drop do wn (for sc reen reade r / 508)
  503            * /
  504                    SetD ropDownFoc us: functi on (target ) {
  505                             var _s elf = this ;
  506                             // On  dropdown o pen
  507                             target .on('shown .bs.dropdo wn', funct ion() {
  508                                               // Set ari a-expanded  to true
  509                                               $('.select ion-btn'). attr('aria -expanded' , true);
  510  
  511                                               // Set foc us on the  first link  in the dr opdown
  512                                               // delayed  by 0.5 se cond to al low VO ann ouncement  of expande d state
  513                                               setTimeout (function( ) {
  514                                                          var select or = '#'+t arget.attr ('id')+' . dropdown-m enu li:fir st-child a ';
  515                                                                $(se lector).fo cus();
  516                                               }, 500);
  517  
  518                                               // hide ot her elemen ts
  519                                               $('header,  .dropdown -hide, foo ter, .scro llbar-grad ient').att r('aria-hi dden', 'tr ue');
  520                             });
  521  
  522                             // On  dropdown c lose
  523                             target .on('hidde n.bs.dropd own', func tion() {
  524                                               // Set ari a-expanded  to false
  525                                               //$('.sele ction-btn' ).attr('ar ia-expande d', false) ;
  526                         $('.select ion-btn'). removeAttr ('aria-exp anded');
  527  
  528                                               // un-hide  other ele ments
  529                                                 $('heade r, .dropdo wn-hide, f ooter, .sc rollbar-gr adient').r emoveAttr( 'aria-hidd en');
  530                             });
  531           },
  532       SetBut tonDropDow nFocus: fu nction (bu tton) {
  533           va r _self =  this;
  534           //  On dropdo wn open
  535           bu tton.on('s hown.bs.dr opdown', f unction()  {
  536                // Set a ria-expand ed to true
  537                button.a ttr('aria- expanded',  true);
  538                var menu Control =  button.att r('aria-co ntrols');
  539  
  540                // Set f ocus on th e first li nk in the  dropdown
  541                // delay ed by 0.5  second to  allow VO a nnouncemen t of expan ded state
  542                setTimeo ut(functio n() {
  543                    var  selector =  '#' + men uControl + ' li:first -child a';
  544                    $(se lector).fo cus();
  545                }, 500);
  546  
  547                // hide  other elem ents
  548                $('heade r, .dropdo wn-hide, f ooter, .sc rollbar-gr adient').a ttr('aria- hidden', ' true');
  549           }) ;
  550  
  551           //  On dropdo wn close
  552           bu tton.on('h idden.bs.d ropdown',  function()  {
  553                // Set a ria-expand ed to fals e
  554                //$('.se lection-bt n').attr(' aria-expan ded', fals e);
  555                button.r emoveAttr( 'aria-expa nded');
  556  
  557                // un-hi de other e lements
  558                $('heade r, .dropdo wn-hide, f ooter, .sc rollbar-gr adient').r emoveAttr( 'aria-hidd en');
  559           }) ;
  560       },
  561  
  562       /**
  563            *  The eleme nt to focu s on page  load, e.g.  authentic ated user  name
  564            * /
  565           Fo cusOnLoad  : function () {
  566                    $('# header-log in-link'). focus(); / / header < a> id for
  567                    // m hpuser.dis playname
  568           },
  569       /**
  570        * For  modals in side <head er>, e.g.  About, Hel p
  571        * @pa ram modalI d - the ac tive modal  id
  572        */
  573       Header ModalShown : function  (modalId)  {
  574           $( ".va-title -area, .ap p-title-ar ea, #error Section, # content, f ooter, .sc rollbar-gr adient").a ttr("aria- hidden", t rue);
  575           $( "#" + moda lId).remov eAttr('ari a-hidden') ;   // ari a-hidden=f alse can b e unreliab le
  576           th is.FocusOn Modal();
  577       },
  578  
  579       Header ModalHidde n: functio n (modalId ) {
  580           $( ".va-title -area, .ap p-title-ar ea, #error Section, # content, f ooter, .sc rollbar-gr adient").r emoveAttr( "aria-hidd en");
  581           $( "#" + moda lId).attr( "aria-hidd en", true) ;
  582       },
  583           /* *
  584            *  For modal s that are  NOT part  of same te mplate as  its invoki ng view, e .g.
  585            *  About, He lp, Timeou t, and EUL A Modal co de segment  is enclos ed within  the
  586            *  .modal-co ntainer th at is outs ide of the  core elem ents (head er, main,
  587            *  footer).  See HTML s tructure i n layout.h tml.
  588            *
  589            *  @param mo dal -
  590            *              The moda l ID (pref ixed with  '#") or un ique CSS s elector
  591            *              (prefixe d with '.' )
  592            * /
  593           Se tModalCont ainer : fu nction(mod al) {
  594                    $(mo dal).on(
  595                                      'shown.b s.modal',
  596                                      function () {
  597                                               $("header,  #content,  footer, . scrollbar- gradient,  #errorSect ion").attr (
  598                                                                'ari a-hidden',  'true');
  599                                               $(modal).r emoveAttr( 'aria-hidd en'); // a ria-hidden =false can
  600                                               // be unre liable
  601                                               $(".modal- title").fo cus();
  602                                      });
  603                    $(mo dal).on(
  604                                      'hidden. bs.modal',
  605                                      function () {
  606                                               $("header,  #content,  footer, . scrollbar- gradient,  #errorSect ion")
  607                                                                .rem oveAttr('a ria-hidden ');
  608                                               $(modal).a ttr("aria- hidden", t rue);
  609                                      });
  610           },
  611           /* *
  612            *  For modal s that are  embedded  in <main>  as part of  the invok ing view,  e.g.
  613            *  Veteran:  ; Provider : Patient  Search, Pe nding Upda tes, .
  614            *
  615            *  @param mo dal -
  616            *              ID of th e modal be ing manipu lated
  617            *  @param fo cus -
  618            *              optional : the HTML  element t o get focu s when mod al is
  619            *              dismisse d; can be  either a C SS class n ame (if un ique) or a n
  620            *              element  ID; defaul t to '.mod al-title'  if not pro vided
  621            * /
  622           Se tMainModal  : functio n(modal, f ocus) {
  623                    // o n display
  624                    $(mo dal).on(
  625                                      'shown.b s.modal',
  626                                      function () {
  627                                               $("header,  .modal-hi de, footer , .scrollb ar-gradien t, #errorS ection").a ttr(
  628                                                                'ari a-hidden',  'true');
  629                                               $(modal).r emoveAttr( 'aria-hidd en'); // a ria-hidden =false can
  630                                               // be unre liable
  631                                               var target  = focus ?  focus : ' .modal-tit le'; // de fault
  632                                               // to
  633                                               // .modal- title
  634                                               // (usuall y
  635                                               // <h4>)
  636                                               $(target). focus();
  637                                      });
  638  
  639                    // o n dismiss
  640                    $(mo dal).on(
  641                                      'hidden. bs.modal',
  642                                      function () {
  643                                               $("header,  .modal-hi de, footer , .scrollb ar-gradien t, #errorS ection")
  644                                                                .rem oveAttr('a ria-hidden ');
  645                                               $(modal).a ttr('aria- hidden', t rue);
  646                                      });
  647           }
  648  
  649   };
  650  
  651   jQuery.fn. putCursorA tEnd = fun ction() {
  652           re turn this. each(funct ion() {
  653                    // c onsole.log ("putCurso rAtEnd");
  654                    // C ache refer ences
  655                    var  $el = $(th is), el =  this;
  656                    // O nly focus  if input i sn't alrea dy
  657                    if ( !$el.is(": focus")) {
  658                             $el.fo cus();
  659                    }
  660                    // I f this fun ction exis ts... (IE  9+)
  661                    if ( el.setSele ctionRange ) {
  662                             // Dou ble the le ngth becau se Opera i s inconsis tent about  whether a
  663                             // car riage retu rn is one  character  or two.
  664                             var le n = $el.va l().length  * 2;
  665                             // Tim eout seems  to be req uired for  Blink
  666                             setTim eout(funct ion() {
  667                                      el.setSe lectionRan ge(len, le n);
  668                             }, 1);
  669                    } el se {
  670                             // As  a fallback , replace  the conten ts with it self
  671                             // Doe sn't work  in Chrome,  but Chrom e supports  setSelect ionRange
  672                             $el.va l($el.val( ));
  673                    }
  674                    // S croll to t he bottom,  in case w e're in a  tall texta rea
  675                    // ( Necessary  for Firefo x and Chro me)
  676                    this .scrollTop  = 999999;
  677           }) ;
  678   };