Produced by Araxis Merge on 2/4/2019 11:34:07 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.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | MHPRO_v1.x.zip\mhpro-web-master@18b10e0e051.zip\app\veteran\cordova\grunt_merge\ios\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\ios\common\lib | app_utils.js | Fri Feb 1 20:43:48 2019 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 1178 |
| Changed | 2 | 4 |
| Inserted | 0 | 0 |
| Removed | 0 | 0 |
| 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 |
No regular expressions were active.
| 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,cl osebuttonc aption="", ' + | |
| 240 | 'suppres sesIncreme ntalRender ing=yes'); | |
| 241 | ||
| 242 | va r pathName ; | |
| 243 | ||
| 244 | ro aWindow.ad dEventList ener('load start', fu nction(eve nt) { | |
| 245 | ||
| 246 | App_Util s.setRemot eReqHeader (); | |
| 247 | App_Util s.setRemot eEULA(); | |
| 248 | ||
| 249 | var xurl = event.u rl; | |
| 250 | var urlP arser = do cument.cre ateElement ('a'); | |
| 251 | urlParse r.href = x url; | |
| 252 | ||
| 253 | pathName = urlPars er.pathnam e; | |
| 254 | pathName = pathNam e.replace( /\//g, '') ; | |
| 255 | ||
| 256 | var hash Value = xu rl.split(' #')[1]; | |
| 257 | if (hash Value) { | |
| 258 | if(h ashValue = == 'form-r eview'){ | |
| 259 | submitRoa = true; | |
| 260 | }els e{ | |
| 261 | submitRoa = false; | |
| 262 | } | |
| 263 | } | |
| 264 | ||
| 265 | if(submi tRoa && pa thName === 'mhpro'){ | |
| 266 | MHPR O.Data.Tra cking.isRo aAccepted = true; | |
| 267 | MHPR O.Data.Tra cking.isUs erPressedC ancelOnROA = false; | |
| 268 | App. vent.trigg er('roa:cl ose'); | |
| 269 | App. vent.trigg er('load:u ser', { in it: true } ); | |
| 270 | } | |
| 271 | ||
| 272 | if(pathN ame === 'l aunchpad') { | |
| 273 | MHPR O.Data.Tra cking.isRo aAccepted = false; | |
| 274 | MHPR O.Data.Tra cking.isUs erPressedC ancelOnROA = true; | |
| 275 | App_ Utils.remo veRemoteRe qHeader(); | |
| 276 | App_ Utils.remo veRemoteEU LA(); | |
| 277 | App. vent.trigg er('roa:cl ose'); | |
| 278 | App. vent.trigg er('load:u ser', { in it: true } ); | |
| 279 | } | |
| 280 | ||
| 281 | }) ; | |
| 282 | ||
| 283 | Ap p.vent.on( 'roa:close ', functio n(){ | |
| 284 | roaWindo w.close(); | |
| 285 | }) ; | |
| 286 | }, | |
| 287 | setRem oteReqHead er: functi on(){ | |
| 288 | ro aWindow.ex ecuteScrip t( | |
| 289 | {code : "xhr.setRe questHeade r('Authori zation', ' Bearer '" + App_Util s.GetSessi onToken() + ");"}, | |
| 290 | function (data){ | |
| 291 | if(d ata){} | |
| 292 | }); | |
| 293 | }, | |
| 294 | setRem oteEULA: f unction(){ | |
| 295 | ro aWindow.ex ecuteScrip t({code : "localStor age.setIte m('MHPRO_E ula', " + App_Utils. GetLocalSt orage('MHP RO_Eula') + ");"}, | |
| 296 | function (data){ | |
| 297 | if(d ata){} | |
| 298 | }); | |
| 299 | }, | |
| 300 | remove RemoteReqH eader: fun ction(){ | |
| 301 | ro aWindow.ex ecuteScrip t( | |
| 302 | {code : "sessionSt orage.setI tem('token ', null);" }, | |
| 303 | function (data){ | |
| 304 | if(d ata){} | |
| 305 | }); | |
| 306 | }, | |
| 307 | remove RemoteEULA : function (){ | |
| 308 | ro aWindow.ex ecuteScrip t( | |
| 309 | {code : "localStor age.remove Item('MHPR O_Eula');" }, | |
| 310 | function (data){ | |
| 311 | if(d ata){} | |
| 312 | }); | |
| 313 | }, | |
| 314 | DebugM ode: funct ion () { | |
| 315 | ||
| 316 | if (document. location.h ostname == "localhos t" && App_ Utils.GetS essionToke n() === nu ll){ | |
| 317 | //Quick and dirty input to a dd token i f developi ng and tok en is not present | |
| 318 | var html = '<form class="for m-inline"> ' + | |
| 319 | '<di v class="f orm-group" >' + | |
| 320 | '<label fo r="tokenIn put">Token :</label> ' + | |
| 321 | '<input ty pe="text" class="for m-control input-sm" id="tokenI nput" plac eholder="E nter Token ">' + | |
| 322 | //'<input type="text " class="f orm-contro l input-sm " id="toke nInput" pl aceholder= "Enter Tok en" value= "fcbc44de- b012-4f74- ae9b-235be 0203b4d">' + | |
| 323 | '</d iv>' + | |
| 324 | '<bu tton type= "button" c lass="btn- default bt n-sm" id=" setToken"> Set Token< /button>' + | |
| 325 | '</f orm>'; | |
| 326 | if (!$(" #debug").l ength) { | |
| 327 | $("b ody").appe nd("<div i d='token' style='pos ition:abso lute; righ t:10px; to p:0px;'>" + html + " </div>"); | |
| 328 | } | |
| 329 | $("#setT oken").on( "click", f unction () { | |
| 330 | var token = $( "#tokenInp ut").val() ; | |
| 331 | App_ Utils.SetS essionToke n('token', token); | |
| 332 | loca tion.reloa d(); | |
| 333 | }); | |
| 334 | } | |
| 335 | if (document .location. hostname = = "localho st" && App _Utils.Get LocalStora ge('MHPRO_ Eula')) { | |
| 336 | //Add bu tton to cl ear Eula l ocalStorag e value | |
| 337 | 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>'; | |
| 338 | if (!$(" #eulaBtn") .length) { | |
| 339 | $("b ody").appe nd(html2); | |
| 340 | } | |
| 341 | $("#eula Btn").on(" click", fu nction () { | |
| 342 | App_ Utils.Dele teLocalSto rage('MHPR O_Eula'); | |
| 343 | loca tion.reloa d(); | |
| 344 | }); | |
| 345 | } | |
| 346 | if (document .location. hostname = = "localho st" && App _Utils.Get LocalStora ge('MHPRO_ Leave_Moda l')) { | |
| 347 | //Add bu tton to cl ear leave modal loca lStorage v alue | |
| 348 | 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>'; | |
| 349 | if (!$(" #leaveBtn" ).length) { | |
| 350 | $("b ody").appe nd(html); | |
| 351 | } | |
| 352 | $("#leav eBtn").on( "click", f unction () { | |
| 353 | App_ Utils.Dele teLocalSto rage('MHPR O_Leave_Mo dal'); | |
| 354 | loca tion.reloa d(); | |
| 355 | }); | |
| 356 | } | |
| 357 | if (document .location. hostname = = "localho st" && App _Utils.Get SessionTok en() != nu ll) { | |
| 358 | //Add bu tton to cl ear MHPUSE R token | |
| 359 | 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>'; | |
| 360 | if (!$(" #tokenBtn" ).length) { | |
| 361 | $("b ody").appe nd(html3); | |
| 362 | } | |
| 363 | $("#toke nBtn").on( "click", f unction () { | |
| 364 | App_ Utils.Clea rSessionTo ken('token '); | |
| 365 | loca tion.reloa d(); | |
| 366 | }); | |
| 367 | } | |
| 368 | // Any other code to qu ickly aid in develop ment | |
| 369 | }, | |
| 370 | Flatte nLinks: fu nction(obj ect) { | |
| 371 | va r links = object.get ('link'); | |
| 372 | if (typeof l inks !== ' undefined' ) { | |
| 373 | for (var i= 0, siz e = links. length; i< size; i++) { | |
| 374 | if ( links[i].t itle) { | |
| 375 | object.set (links[i]. title,link s[i]); | |
| 376 | } el se { | |
| 377 | object.set ('self',li nks[i]); | |
| 378 | } | |
| 379 | } | |
| 380 | object.u nset('link '); | |
| 381 | } | |
| 382 | }, | |
| 383 | /** | |
| 384 | * Ret rieves ass ignment pa tient name s (returns immediate ly; callba ck is only | |
| 385 | * exe cuted afte r all name s retrieve d) | |
| 386 | * | |
| 387 | * @pa ram as - | |
| 388 | * Ba ckbone col lection or javascrip t array | |
| 389 | * @pa ram cb - | |
| 390 | * ca llback aft er all nam es retriev ed | |
| 391 | * @pa ram option alPatientN amesByIdCa che - | |
| 392 | * An optional object to use as a c ache, whos e keys are the | |
| 393 | * pa tient IDs and values are the p atient nam es. If spe cified, | |
| 394 | * th is method will add n ewly retri eved patie nt names t o the | |
| 395 | * ob ject, and rely on th e object f or a preli minary loo kup before | |
| 396 | * re questing t he data fr om the ser ver. If un specified, all names | |
| 397 | * wi ll be retr ieved from the serve r. | |
| 398 | */ | |
| 399 | retrie vePatientN ames : fun ction(as, cb) { | |
| 400 | va r baseUrl = MHPRO.Re sources.PV SResources .get("pati ents").toJ SON().href ; | |
| 401 | ||
| 402 | va r isBackbo ne = !Arra y.isArray( as); | |
| 403 | ||
| 404 | // using thi s until PV S direct e nd point i s availabl e | |
| 405 | ba seUrl = ba seUrl.repl ace(/patie nts/, "pat ient") + " /"; | |
| 406 | ||
| 407 | // should wo rk for arr ays and ba ckbone col lections - CPB | |
| 408 | va r total = as.length | |
| 409 | if (total == 0) { | |
| 410 | cb() | |
| 411 | return | |
| 412 | } | |
| 413 | ||
| 414 | va r distinc t = {}; | |
| 415 | if (isBackbo ne) { | |
| 416 | //var tm pCollectio n = new Ba ckbone.col lection(as .toJSON()) ; | |
| 417 | as.each( function(i tem) { | |
| 418 | dist inct[item. get('patie ntId')] = item; | |
| 419 | }) | |
| 420 | } else { | |
| 421 | for (var i = 0; i < as.lengt h; i++) | |
| 422 | dist inct[as[i] .patientId ] = as[i]; | |
| 423 | } | |
| 424 | ||
| 425 | // console.lo g('distinc t', distin ct); | |
| 426 | ||
| 427 | va r distCoun t = 0; | |
| 428 | va r complete dDistinct = function (x) { | |
| 429 | distCoun t++; | |
| 430 | if (dist Count == O bject.keys (distinct) .length) { | |
| 431 | if ( isBackbone ) { | |
| 432 | as.each(fu nction(ass ignment) { | |
| 433 | assign ment.set({ | |
| 434 | di splayName: distinct[ assignment .get('pati entId')].d isplayName | |
| 435 | }, { s ilent: tru e }); | |
| 436 | }); | |
| 437 | } el se { | |
| 438 | _.each(as, function( assignment , index) { | |
| 439 | assign ment.displ ayName = d istinct[as signment.p atientId]. displayNam e; | |
| 440 | }); | |
| 441 | } | |
| 442 | cb() ; | |
| 443 | } | |
| 444 | }; | |
| 445 | ||
| 446 | $. each(disti nct, funct ion(patien tId, patie ntObj) { | |
| 447 | var pati entUrl; | |
| 448 | var loca lPatientId ; | |
| 449 | if (isBa ckbone) { | |
| 450 | loca lPatientId = patient Obj.get('p atientId') ; | |
| 451 | pati entUrl = b aseUrl + p atientObj. get('patie ntAssignAu th') + "/" + localPa tientId; | |
| 452 | } | |
| 453 | else { | |
| 454 | loca lPatientId = patient Obj.patien tId; | |
| 455 | pati entUrl = b aseUrl + p atientObj. patientAss ignAuth + "/" + loca lPatientId ; | |
| 456 | } | |
| 457 | ||
| 458 | $.ajax( | |
| 459 | { | |
| 460 | type : 'GE T', | |
| 461 | url : pati entUrl, | |
| 462 | dataType : 'json', | |
| 463 | headers : { | |
| 464 | 'Autho rization' : 'Bearer ' | |
| 465 | + App_ Utils.GetS essionToke n() | |
| 466 | } | |
| 467 | }).d one(functi on(respons e) { | |
| 468 | if ( response) { | |
| 469 | distinct[l ocalPatien tId].displ ayName = r esponse.di splayName | |
| 470 | } | |
| 471 | comp letedDisti nct() | |
| 472 | }).fail(fu nction(res ponse) { | |
| 473 | distin ct[localPa tientId].d isplayName = "---" | |
| 474 | comple tedDistinc t() | |
| 475 | }); | |
| 476 | }) ; | |
| 477 | }, | |
| 478 | /** | |
| 479 | * Che cks is a g iven strin g contains invalid d ate. | |
| 480 | * @pa ram str - the string to be val idated | |
| 481 | * @re turn Boole an | |
| 482 | */ | |
| 483 | HasIn validDate: function( date) { | |
| 484 | // v alidate da te format mm/dd/yyyy with opti onal time extension | |
| 485 | var dateCheck = new RegE xp("^((0?[ 1-9]|1[012 ])[/](0?[1 -9]|[12][0 -9]|3[01]) [/](19|20) ?[0-9]{2}) *$"); | |
| 486 | if ( !dateCheck .test(date )) return true; | |
| 487 | ||
| 488 | va r componen ts = date. split("/") , | |
| 489 | mo nth = pars eInt(compo nents[0], 10), | |
| 490 | da y = parseI nt(compone nts[1], 10 ), | |
| 491 | // parseint on e.g. "2 014 14:23" will just return th e year | |
| 492 | ye ar = parse Int(compon ents[2], 1 0); | |
| 493 | ||
| 494 | if (month == = 4 || mon th === 6 | | month == = 9 || mon th === 11) { | |
| 495 | if ( day > 30) return tru e; | |
| 496 | } else if (m onth !== 2 ) { | |
| 497 | if ( day > 31) return tru e; | |
| 498 | } else { | |
| 499 | // w e are in f eb | |
| 500 | if ( year % 4 = == 0) { | |
| 501 | // lea p year | |
| 502 | if (da y > 29) { | |
| 503 | return t rue; | |
| 504 | } | |
| 505 | } el se { | |
| 506 | if (da y > 28) { | |
| 507 | return t rue; | |
| 508 | } | |
| 509 | } | |
| 510 | } | |
| 511 | re turn false ; | |
| 512 | }, | |
| 513 | /** | |
| 514 | * The element t o focus on page load , e.g. aut henticated user name | |
| 515 | */ | |
| 516 | FocusO nLoad: fun ction () { | |
| 517 | // $('#header -login-lin k').focus( ); // h eader <a> id for mhp user.displ ayname | |
| 518 | $( '#isHomeTa g').focus( ); | |
| 519 | }, | |
| 520 | /** | |
| 521 | * For modals th at are NOT part of s ame templa te as its invoking v iew, e.g. About, Hel p, | |
| 522 | * Tim eout, and EULA Modal code segm ent is enc losed with in the .mo dal-contai ner that i s | |
| 523 | * out side of th e core ele ments (hea der, main, footer). See HTML s tructure i n layout.h tml. | |
| 524 | * @pa ram modal - The moda l ID (pref ixed with '#") or un ique CSS s elector (p refixed wi th '.') | |
| 525 | */ | |
| 526 | SetMod alContaine r: functio n (modal) { | |
| 527 | $( modal).on( 'shown.bs. modal', fu nction () { | |
| 528 | $("heade r, #conten t, footer, .scrollba r-gradient ").attr('a ria-hidden ', 'true') ; | |
| 529 | $(modal) .removeAtt r('aria-hi dden'); // aria-hi dden=false can be un reliable | |
| 530 | $(".moda l-title"). focus(); | |
| 531 | }) ; | |
| 532 | $( modal).on( 'hidden.bs .modal', f unction () { | |
| 533 | $("heade r, #conten t, footer, .scrollba r-gradient ").removeA ttr('aria- hidden'); | |
| 534 | $(modal) .attr("ari a-hidden", true); | |
| 535 | }) ; | |
| 536 | }, | |
| 537 | ||
| 538 | /** | |
| 539 | * For modals th at are emb edded in < main> as p art of the invoking view, | |
| 540 | * e.g . Veteran: ; Provide r: Patient Search, P ending Upd ates, | |
| 541 | * . | |
| 542 | * @pa ram modal - ID of th e modal be ing manipu lated | |
| 543 | * @pa ram focus - optional : the HTML element t o get focu s when mod al is dism issed; | |
| 544 | * can be either a CSS class name (if u nique) or an element ID; defau lt | |
| 545 | * to '.m odal-title ' if not p rovided | |
| 546 | */ | |
| 547 | SetMai nModal: fu nction (mo dal, focus ) { | |
| 548 | // on displa y | |
| 549 | $( modal).on( 'shown.bs. modal', fu nction () { | |
| 550 | $("heade r, .modal- hide, foot er, .scrol lbar-gradi ent").attr ('aria-hid den', 'tru e'); | |
| 551 | $(modal) .removeAtt r('aria-hi dden'); / / aria-hid den=false can be unr eliable | |
| 552 | var targ et = focus ? focus : '.modal-t itle'; // default to .modal -title (us ually <h4> ) | |
| 553 | $(target ).focus(); | |
| 554 | }) ; | |
| 555 | ||
| 556 | // on dismis s | |
| 557 | $( modal).on( 'hidden.bs .modal', f unction () { | |
| 558 | $("heade r, .modal- hide, foot er, .scrol lbar-gradi ent").remo veAttr('ar ia-hidden' ); | |
| 559 | $(modal) .attr('ari a-hidden', true); | |
| 560 | }) ; | |
| 561 | } | |
| 562 | }; | |
| 563 | ||
| 564 | jQuery.fn. putCursorA tEnd = fun ction () { | |
| 565 | return this.each (function () { | |
| 566 | // console.lo g("putCurs orAtEnd"); | |
| 567 | // Cache ref erences | |
| 568 | va r $el = $( this), | |
| 569 | el = thi s; | |
| 570 | // Only focu s if input isn't alr eady | |
| 571 | if (!$el.is( ":focus")) { | |
| 572 | $el.focu s(); | |
| 573 | } | |
| 574 | // If this f unction ex ists... (I E 9+) | |
| 575 | if (el.setSe lectionRan ge) { | |
| 576 | // 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. | |
| 577 | var len = $el.val( ).length * 2; | |
| 578 | // Timeo ut seems t o be requi red for Bl ink | |
| 579 | setTimeo ut(functio n () { | |
| 580 | el.s etSelectio nRange(len , len); | |
| 581 | }, 1); | |
| 582 | } else { | |
| 583 | // As a fallback, replace th e contents with itse lf | |
| 584 | // Doesn 't work in Chrome, b ut Chrome supports s etSelectio nRange | |
| 585 | $el.val( $el.val()) ; | |
| 586 | } | |
| 587 | // Scroll to the botto m, in case we're in a tall tex tarea | |
| 588 | // (Necessar y for Fire fox and Ch rome) | |
| 589 | th is.scrollT op = 99999 9; | |
| 590 | }); | |
| 591 | }; |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.