Produced by Araxis Merge on 1/4/2018 2:42:55 PM 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 | TMP_Code.zip\TMP_Code\CRM\VA.TMP.WebResources.zip\VA.TMP.WebResources\J Script Functions\HTML | VIALogin.js | Wed Nov 22 14:32:16 2017 UTC |
| 2 | TMP_Code.zip\TMP_Code\CRM\VA.TMP.WebResources.zip\VA.TMP.WebResources\J Script Functions\HTML | VIALogin.js | Wed Jan 3 23:03:22 2018 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 3 | 964 |
| 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 | if (typeof (MCS) == "undefined ") | |
| 2 | MCS = {}; | |
| 3 | ||
| 4 | if (typeof (MCS.VIAL ogin == "u ndefined") ) | |
| 5 | MCS.VI ALogin = { } | |
| 6 | ||
| 7 | MCS.VIALog in.KeepAli veWindowNa me = "crms soi"; | |
| 8 | MCS.VIALog in.Refresh es = 0; | |
| 9 | ||
| 10 | // ******* ********** ********** ********** *********P age Specif ic Functio ns | |
| 11 | MCS.VIALog in.Login = function () { | |
| 12 | var ty peCode = X rm.Page.co ntext.getQ ueryString Parameters ().etc; | |
| 13 | if (ty peCode == 4201 && Xr m.Page.get Attribute( "cvt_servi ceactivity id").getVa lue() == n ull) | |
| 14 | re turn; | |
| 15 | if (ty peCode == 4214 && Xr m.Page.get Attribute( "mcs_relat edtsaid"). getValue() == null) | |
| 16 | re turn; | |
| 17 | var st ateCode = Xrm.Page.g etAttribut e('stateco de').getVa lue(); | |
| 18 | if (st ateCode != 3) | |
| 19 | re turn; | |
| 20 | if (!M CS.VIALogi n.CheckVis taSwitches ()) | |
| 21 | re turn; | |
| 22 | ||
| 23 | MCS.VI ALogin.Get SamlToken( ); | |
| 24 | ||
| 25 | if (Xr m.Page.get Attribute( "cvt_samlt oken").get Value() == null) | |
| 26 | re turn; | |
| 27 | if (MC S.VIALogin .GetSettin g("VIA Log in Endpoin t") != "") { | |
| 28 | MC S.VIALogin .LoginToVi aBah("pat" ); | |
| 29 | MC S.VIALogin .LoginToVi aBah("pro" ); | |
| 30 | } | |
| 31 | else { | |
| 32 | MC S.VIALogin .ViaLoginV imt("pat") ; | |
| 33 | MC S.VIALogin .ViaLoginV imt("pro") ; | |
| 34 | } | |
| 35 | }; | |
| 36 | ||
| 37 | // ******* ********** ********** ********** ********** *STS Retri eval Funct ions****** ********** ********** ********** ********** ****** | |
| 38 | //Retrieve s the SSOi SAML Toke n either t hrough Kee p Alive or through D irect IAM STS depend ing on whi ch URLs ar e availabl e | |
| 39 | MCS.VIALog in.GetSaml Token = fu nction () { | |
| 40 | var re freshUrl = MCS.VIALo gin.GetKee pAliveUrl( ); | |
| 41 | var ke epAliveLog inUrl = MC S.VIALogin .GetKeepAl iveLoginUr l(); | |
| 42 | var di rectIamUrl = MCS.VIA Login.GetS tsUrl(); | |
| 43 | ||
| 44 | if (re freshUrl ! = "" && ke epAliveLog inUrl != " ") | |
| 45 | MC S.VIALogin .RefreshTo ken(); | |
| 46 | else i f (directI amUrl != " ") | |
| 47 | MC S.VIALogin .CallIamSt s(directIa mUrl); | |
| 48 | else { | |
| 49 | al ert("No PI V Authenti cation has been set up"); | |
| 50 | Xr m.Page.get Attribute( "cvt_samlt oken").set Value("FAK E SAML TOK EN"); | |
| 51 | } | |
| 52 | }; | |
| 53 | ||
| 54 | //Retrieve s the Toke n from IAM directly | |
| 55 | MCS.VIALog in.CallIam Sts = func tion (iamU rl) { | |
| 56 | var po ststring = "<soapenv :Envelope xmlns:soap env=\"http ://schemas .xmlsoap.o rg/soap/en velope/\" xmlns:ns=\ "http://do cs.oasis-o pen.org/ws -sx/ws-tru st/200512\ ">" | |
| 57 | + "<soapenv: Header/>" | |
| 58 | + "<soapenv: Body>" | |
| 59 | + "<ns:Reque stSecurity Token>" | |
| 60 | + "<ns:Base> " | |
| 61 | + "<wss:TLS xmlns:wss= \"http://d ocs.oasis- open.org/w ss/2004/01 /oasis-200 401-wss-ws security-s ecext-1.0. xsd\"/>" | |
| 62 | + "</ns:Base >" | |
| 63 | + "<wsp:Appl iesTo xmln s:wsp=\"ht tp://schem as.xmlsoap .org/ws/20 04/09/poli cy\">" | |
| 64 | + "<wsa:Endp ointRefere nce xmlns: wsa=\"http ://schemas .xmlsoap.o rg/ws/2004 /08/addres sing\">" | |
| 65 | + "<wsa:Ad dress>http s:// DNS . URL /TMP</wsa: Address>" | |
| 66 | + "</wsa:End pointRefer ence>" | |
| 67 | + "</wsp:App liesTo>" | |
| 68 | + "<ns:Issue r>" | |
| 69 | + "<wsa:Ad dress xmln s:wsa=\"ht tp://schem as.xmlsoap .org/ws/20 04/08/addr essing\">h ttps:// DNS /Issuer/sm token/SAML 2</wsa:Add ress>" | |
| 70 | + "</ns:Issu er>" | |
| 71 | + "<ns:Reque stType>htt p://schema s.xmlsoap. org/ws/200 5/02/trust /Validate< /ns:Reques tType>" | |
| 72 | + "</ns:Requ estSecurit yToken>" | |
| 73 | + "</soapenv :Body>" | |
| 74 | + "</soapenv :Envelope> " | |
| 75 | ; | |
| 76 | url = iamUrl == null ? MCS .VIALogin. GetStsUrl( ) : iamUrl ; | |
| 77 | //$.su pport.cors = true; | |
| 78 | $.get( url).done( function ( ) { | |
| 79 | $. ajax({ | |
| 80 | url: url , | |
| 81 | type: 'P OST', | |
| 82 | crossDom ain: true, | |
| 83 | data: po ststring, | |
| 84 | contentT ype: 'text /plain', | |
| 85 | dataType : 'text', | |
| 86 | success: function (result) { | |
| 87 | resp onse = res ult; | |
| 88 | Xrm. Page.getAt tribute("c vt_samltok en").setVa lue(result ); | |
| 89 | }, | |
| 90 | error: f unction (j qXHR, tran Status, er rorThrown) { | |
| 91 | aler t("Unable to Get SAM L token to log into Vista\n" + | |
| 92 | 'Status: ' + jqXHR.s tatus + ' ' + jqXHR. statusText + '. ' + | |
| 93 | 'Response: ' + jqXHR .responseT ext | |
| 94 | ); | |
| 95 | } | |
| 96 | }) ; | |
| 97 | }).fai l(function (err) { | |
| 98 | va r error = ("ERROR: r eadyState - " + err. readyState + " Statu s = " + er r.status + | |
| 99 | " text = " + err.s tatusText + ". Respo nse Text = " + err.r esponseTex t); | |
| 100 | al ert("Error in Get SA ML Token: " + error) ; | |
| 101 | }); | |
| 102 | }; | |
| 103 | ||
| 104 | //Function calls the refresh e ndpoint an d sets the resulting SAML toke n onto the form if t he call is successfu l, otherwi se keeps c alling its elf every 5 seconds | |
| 105 | MCS.VIALog in.Refresh Token = fu nction () { | |
| 106 | MCS.VI ALogin.Ref reshes++; | |
| 107 | var ur l = MCS.VI ALogin.Get KeepAliveU rl(); | |
| 108 | var to ken = ""; | |
| 109 | $.ajax ({ | |
| 110 | ur l: url, | |
| 111 | su ccess: fun ction (res ult) { | |
| 112 | if (resu lt != null ) | |
| 113 | toke n = result .SAMLToken ; | |
| 114 | if (toke n != null && token ! = "") | |
| 115 | Xrm. Page.getAt tribute("c vt_samltok en").setVa lue(token) ; | |
| 116 | else | |
| 117 | aler t("No toke n retrieve d, running login the n refreshi ng token. Please lo gin with y our PIN an d this pop -up should go away") ; | |
| 118 | }, | |
| 119 | er ror: funct ion (reque st, status , error) { | |
| 120 | alert("T oken Refre sh call fa iled: " + request.re sponseText + "; info : " + requ est.status Text); | |
| 121 | }, | |
| 122 | al ways: func tion () { | |
| 123 | if (Xrm. Page.getAt tribute("c vt_samltok en").getVa lue() == n ull && MCS .VIALogin. Refreshes < 2) { | |
| 124 | setT imeout(MCS .VIALogin. RefreshTok en, 5000); | |
| 125 | MCS. VIALogin.K eepSession Alive(); | |
| 126 | } | |
| 127 | } | |
| 128 | ||
| 129 | }); | |
| 130 | }; | |
| 131 | ||
| 132 | //Funtion to open th e Keep Ali ve page (i f its alre ady open, then it wi ll just fo rce focus to it) | |
| 133 | MCS.VIALog in.KeepSes sionAlive = function () { | |
| 134 | var ur l = MCS.VI ALogin.Get KeepAliveL oginUrl(); | |
| 135 | ssoiWi ndow = win dow.open(u rl, | |
| 136 | MC S.VIALogin .KeepAlive WindowName , | |
| 137 | 'h eight=500, width=865 , location =yes, resi zable=yes, scrollbar s=yes, sta tus=yes, t itlebar=ye s, top=100 , left=100 ', | |
| 138 | tr ue | |
| 139 | ); | |
| 140 | ssoiWi ndow.focus (); | |
| 141 | return ; | |
| 142 | }; | |
| 143 | ||
| 144 | // ******* ********** ********** ********** *****VIA L ogin Funct ions****** ********** ********** ********** ********** * | |
| 145 | ////////// ////////// ///iHub Vi aLogin | |
| 146 | //main met hod to log into VIA using BAH' s VIA Logi n Web Part (iHub) | |
| 147 | MCS.VIALog in.LoginTo ViaBah = f unction (s ide) { | |
| 148 | var ur l = MCS.VI ALogin.Via LoginUrl() ; | |
| 149 | var to ken = Xrm. Page.getAt tribute("c vt_samltok en").getVa lue(); | |
| 150 | if (to ken == nul l || token == "") { | |
| 151 | al ert("No VI A Login co mpleted be cause SAML token not found. " ); | |
| 152 | re turn; | |
| 153 | } | |
| 154 | var fa cility = M CS.VIALogi n.GetFacil ityNumber( side); | |
| 155 | var me ssage = MC S.VIALogin .SetupViaM essage(fac ility, tok en); | |
| 156 | var du z = MCS.VI ALogin.Cal lBahLogin( message); | |
| 157 | if (du z != "") | |
| 158 | Xr m.Page.get Attribute( "cvt_" + s ide + "use rduz").set Value(duz) ; | |
| 159 | else | |
| 160 | al ert("No VI A Login co mpleted fo r " + side + "side") ; | |
| 161 | }; | |
| 162 | ||
| 163 | //Helper m ethod tp P repare the VIA Login Message | |
| 164 | MCS.VIALog in.SetupVi aMessage = function (facilityN umber, tok en) { | |
| 165 | var vi aMessage = {}; | |
| 166 | viaMes sage.Acces sCode = "d onotuse"; | |
| 167 | viaMes sage.Verif yCode = "d onotuse"; | |
| 168 | viaMes sage.SiteI d = facili tyNumber; | |
| 169 | viaMes sage.SamlT oken = tok en; | |
| 170 | return viaMessag e; | |
| 171 | }; | |
| 172 | ||
| 173 | //Helper m ethod call ed by VIA Login whic h performs the ajax call and r eturns the resulting Duz (if e xists) | |
| 174 | MCS.VIALog in.CallBah Login = fu nction (me ssage, url ) { | |
| 175 | var du z = ""; | |
| 176 | $.ajax ({ | |
| 177 | as ync: false , | |
| 178 | ty pe: 'POST' , | |
| 179 | ur l: url, | |
| 180 | be foreSend: function ( request) { | |
| 181 | request. setRequest Header("CR MSSOiSessi onSaml", w indow.btoa (message.S amlToken)) | |
| 182 | }, | |
| 183 | da taType: 'j son', | |
| 184 | co ntentType: 'applicat ion/json', | |
| 185 | da ta: JSON.s tringify(m essage), | |
| 186 | su ccess: fun ction (dat a, textSta tus, jqXHR ) { | |
| 187 | if (data == null | | data.Dat a == null || data.Da ta[0] == n ull || dat a.Data[0]. Duz == nul l) { | |
| 188 | if ( data == nu ll) | |
| 189 | alert("No data retur ned"); | |
| 190 | else if (data. Data == nu ll || data .Data[0] = = null) | |
| 191 | alert("Emp ty Data" + data.Erro rMessage); | |
| 192 | else if (data. Data[0].Fa ult != nul l) | |
| 193 | alert("Fai led to log in: " + da ta.Data[0] .Fault.Mes sage) | |
| 194 | } | |
| 195 | else { | |
| 196 | if ( data.Data[ 0].Duz != null) | |
| 197 | duz = data .Data[0].D uz; | |
| 198 | //al ert(textSt atus + ". Duz: " + ) ; | |
| 199 | } | |
| 200 | ||
| 201 | }, | |
| 202 | er ror: funct ion (jqXHR , textStat us, errorT hrown) { | |
| 203 | alert(te xtStatus + ". Error : " + erro rThrown); | |
| 204 | return " "; | |
| 205 | } | |
| 206 | }); | |
| 207 | return duz; | |
| 208 | }; | |
| 209 | ||
| 210 | ////////// ////////// /EC ViaLog in | |
| 211 | //main met hod to log into VIA using VIMT EC (throu gh Actions /CWF/LOB) | |
| 212 | MCS.VIALog in.ViaLogi nVimt = fu nction (si de, access , verify) { | |
| 213 | var sa mlToken = Xrm.Page.g etAttribut e("cvt_sam ltoken").g etValue(); | |
| 214 | var st ationNumbe r = MCS.VI ALogin.Get FacilityNu mber(side) ; | |
| 215 | MCS.VI ALogin.Log inWithActi on(samlTok en, statio nNumber, s ide, acces s, verify) ; | |
| 216 | } | |
| 217 | ||
| 218 | //Calls th e action a nd sets th e resultin g DUZ onto the page or else ca lls the Lo gin throug h Access-V erify code s | |
| 219 | MCS.VIALog in.LoginWi thAction = function (samlToken , stationN umber, sid e, access, verify) { | |
| 220 | var re questName = "cvt_Via LoginActio n"; | |
| 221 | ||
| 222 | var re questParam s = | |
| 223 | [{ | |
| 224 | Key: "St ationNumbe r", | |
| 225 | Type: MC S.Scripts. Process.Da taType.Str ing, | |
| 226 | Value: s tationNumb er | |
| 227 | }, | |
| 228 | { | |
| 229 | Key: "Sa mlToken", | |
| 230 | Type: MC S.Scripts. Process.Da taType.Str ing, | |
| 231 | Value: s amlToken | |
| 232 | }, | |
| 233 | { | |
| 234 | Key: "Ac cessCode", | |
| 235 | Type: MC S.Scripts. Process.Da taType.Str ing, | |
| 236 | Value: t ypeof(acce ss) === "u ndefined" ? "" : acc ess | |
| 237 | }, | |
| 238 | { | |
| 239 | Key: "Ve rifyCode", | |
| 240 | Type: MC S.Scripts. Process.Da taType.Str ing, | |
| 241 | Value: t ypeof(veri fy) === "u ndefined" ? "" : ver ify | |
| 242 | }] ; | |
| 243 | ||
| 244 | MCS.Sc ripts.Proc ess.Execut eAction(re questName, requestPa rams) | |
| 245 | .d one(functi on (respon se) { | |
| 246 | // Succe ss | |
| 247 | var user Duz = resp onse.UserD uz; | |
| 248 | var succ ess = resp onse.Succe ssfulLogin ; | |
| 249 | var erro rMessage = response. ErrorMessa ge; | |
| 250 | //alert( "Duz: " + userDuz + "\nError: " + errorM essage); | |
| 251 | ||
| 252 | if (succ ess) | |
| 253 | Xrm. Page.getAt tribute("c vt_" + sid e + "userd uz").setVa lue(userDu z); | |
| 254 | else { | |
| 255 | //Xr m.Page.get Attribute( "cvt_" + s ide + "log inError"). setValue(e rrorMessag e); | |
| 256 | var useAVCodes = confirm ("Failed t o log in w ith PIV, a ttempting Access Ver ify Codes for " + si de + " sid e"); | |
| 257 | if ( useAVCodes ) | |
| 258 | MCS.VIALog in.LoginWi thAccessVe rify(side, samlToken , stationN umber); | |
| 259 | } | |
| 260 | }) | |
| 261 | .f ail(functi on (err) { | |
| 262 | alert("L ogin Actio n Failed: " + err.re sponseText ); | |
| 263 | }) ; | |
| 264 | }; | |
| 265 | ||
| 266 | //Helper t o re-call LoginVIMT using acce ssVerify e ntered by user promp t - user c an leave b lank or hi t cancel t o end loop | |
| 267 | MCS.VIALog in.LoginWi thAccessVe rify = fun ction (sid e, samlTok en, statio nNumber) { | |
| 268 | var ac cessCode = prompt("P lease ente r your acc ess code f or the " + side + " facility." ); | |
| 269 | var ve rifyCode; | |
| 270 | if (ac cessCode ! = null && accessCode != "") { | |
| 271 | ve rifyCode = prompt("P lease ente r your ver ify code f or the " + side + " facility." ); | |
| 272 | if (verifyCo de != null && verify Code != "" ) | |
| 273 | MCS.VIAL ogin.Login WithAction (samlToken , stationN umber, sid e, accessC ode, verif yCode); | |
| 274 | } | |
| 275 | }; | |
| 276 | ||
| 277 | // ******* ********** *******Hel per method s to retri eve Integr ation Sett ings (URLS ) ******** ********** ********** ********* | |
| 278 | //Helper M ethod to g et SAML To ken URL | |
| 279 | MCS.VIALog in.GetStsU rl = funct ion () { | |
| 280 | var de faultUrl = "";// "ht tps://dev. services.e auth.va.go v:9301/STS /RequestSe curityToke n"; | |
| 281 | var ur l = MCS.VI ALogin.Get Setting("I AM SAML To ken Endpoi nt"); | |
| 282 | return url != "" ? url : d efaultUrl; | |
| 283 | }; | |
| 284 | ||
| 285 | //Helper m ethod to g et the Kee p Alive Lo gin Page | |
| 286 | MCS.VIALog in.GetKeep AliveLogin Url = func tion () { | |
| 287 | var de faultUrl = "";//"htt ps://qacrm dac.np.crm .vrm.vba.v a.gov/CRMS SOi/qa/def ault.aspx" ; | |
| 288 | var ur l = MCS.VI ALogin.Get Setting("K eep Alive Login Endp oint"); | |
| 289 | return url != "" ? url : d efaultUrl; | |
| 290 | }; | |
| 291 | ||
| 292 | //Helper M ethod to g et the url to refres h your tok en (assumi ng you hav e already called the login pag e) | |
| 293 | MCS.VIALog in.GetKeep AliveUrl = function () { | |
| 294 | var de faultUrl = "";// "ht tps://qacr mdac.np.cr m.vrm.vba. va.gov/CRM SSOi/qa/re freshtoken session.as px"; | |
| 295 | var ur l = MCS.VI ALogin.Get Setting("R efresh SAM L Token En dpoint"); | |
| 296 | return url != "" ? url : d efaultUrl; | |
| 297 | }; | |
| 298 | ||
| 299 | //Helper M ethod to g et BAH VIA Login iHu b Endpoint URL | |
| 300 | MCS.VIALog in.ViaLogi nUrl = fun ction () { | |
| 301 | var ur l = MCS.VI ALogin.Get Setting("V IA Login E ndpoint"); | |
| 302 | var de faultUrl = "";//"htt ps://qacrm dac.np.crm .vrm.vba.v a.gov/WebP arts/DEV/a pi/VIA/Log inVIA/2.1/ json"; | |
| 303 | return url != "" ? url : d efaultUrl; | |
| 304 | }; | |
| 305 | ||
| 306 | //Helper m ethod to g et any int egration s etting wit h the pass ed in name | |
| 307 | MCS.VIALog in.GetSett ing = func tion (name ) { | |
| 308 | var va lue = ""; | |
| 309 | var fi lter = "mc s_name eq '" + name + "'"; | |
| 310 | calls = CrmRestK it.ByQuery ("mcs_inte grationset ting", ['m cs_value'] , filter, false); | |
| 311 | calls. fail(funct ion (err) { | |
| 312 | re turn value ; | |
| 313 | }).don e(function (data) { | |
| 314 | if (data && data.d && data.d.res ults != nu ll && data .d.results .length != 0) { | |
| 315 | value = data.d.res ults[0].mc s_value | |
| 316 | } | |
| 317 | }) ; | |
| 318 | return value; | |
| 319 | }; | |
| 320 | ||
| 321 | //Helper m ethod to g et the TSA id whethe r the curr ent record is an app t or a blo ck resourc e | |
| 322 | MCS.VIALog in.GetTsaI d = functi on () { | |
| 323 | var ts aObj = Xrm .Page.getA ttribute(" mcs_relate dtsa"); | |
| 324 | if (ts aObj != nu ll) | |
| 325 | re turn tsaOb j.getValue ()[0].id; | |
| 326 | var ts aId; | |
| 327 | var sa = Xrm.Pag e.getAttri bute("cvt_ serviceact ivityid"). getValue() [0].id; | |
| 328 | CrmRes tKit.Retri eve('Servi ceAppointm ent', sa, ['mcs_rela tedtsa'], false) | |
| 329 | .f ail(functi on (err) { | |
| 330 | alert("f ailed TSA check, Una ble to per form VIA l ogin: " + MCS.cvt_Co mmon.RestE rror(err)) ; | |
| 331 | }) | |
| 332 | .d one(functi on (data) { | |
| 333 | if (data != null & & data.d ! = null) { | |
| 334 | tsaI d = data.d .mcs_relat edtsa.Id; | |
| 335 | } | |
| 336 | }) ; | |
| 337 | return tsaId; | |
| 338 | }; | |
| 339 | ||
| 340 | //Helper m ethod to g et the sta tion numbe r of the f acility | |
| 341 | MCS.VIALog in.GetFaci lityNumber = functio n (side) { | |
| 342 | var ts aId = MCS. VIALogin.G etTsaId(); | |
| 343 | var pa tFacId = n ull; | |
| 344 | var pr oFacId = n ull; | |
| 345 | var is InterFacil ity = fals e; | |
| 346 | CrmRes tKit.Retri eve('mcs_s ervices', tsaId, ['c vt_Patient Facility', 'cvt_Prov iderFacili ty', 'cvt_ ServiceSco pe'], fals e) | |
| 347 | .f ail(functi on (err) { | |
| 348 | alert("f ailed TSA check, Una ble to per form VIA l ogin: " + MCS.cvt_Co mmon.RestE rror(err)) ; | |
| 349 | }) | |
| 350 | .d one(functi on (data) { | |
| 351 | if (data != null & & data.d ! = null) { | |
| 352 | if ( data.d.cvt _PatientFa cility != null) | |
| 353 | patFacId = data.d.cv t_PatientF acility.Id ; | |
| 354 | if ( data.d.cvt _ProviderF acility != null) | |
| 355 | proFacId = data.d.cv t_Provider Facility.I d; | |
| 356 | if ( data.d.cvt _ServiceSc ope != nul l) | |
| 357 | isInterFac ility = da ta.d.cvt_S erviceScop e.Value == 917290000 ; | |
| 358 | } | |
| 359 | }) ; | |
| 360 | var id = side == "pat" ? p atFacId : proFacId; | |
| 361 | var fa cilityNumb er; | |
| 362 | CrmRes tKit.Retri eve('mcs_f acility', id, ['mcs_ StationNum ber'], fal se) | |
| 363 | .f ail(functi on (err) { | |
| 364 | alert("F ailed to g et TSA, Un able to Pe rform VIA Login: " + MCS.cvt_C ommon.Rest Error(err) ); | |
| 365 | }) .done(func tion (data ) { | |
| 366 | if (data != null & & data.d ! = null) | |
| 367 | faci lityNumber = data.d. mcs_Statio nNumber; | |
| 368 | else | |
| 369 | aler t("Failed to get TSA station n umber, Una ble to Per form VIA L ogin"); | |
| 370 | }) ; | |
| 371 | return facilityN umber; | |
| 372 | }; | |
| 373 | ||
| 374 | MCS.VIALog in.CheckVi staSwitche s = functi on () { | |
| 375 | var Vi staSwitche sConfig = true; | |
| 376 | var ba seSwitchCo nfig = tru e; | |
| 377 | var hm Config = t rue; | |
| 378 | var if cConfig = true; | |
| 379 | var si ngleNonHmC onfig = tr ue; | |
| 380 | var fi lter = "mc s_name eq 'Active Se ttings'"; | |
| 381 | calls = CrmRestK it.ByQuery ("mcs_sett ing", ['cv t_UseVista Integratio n', 'cvt_U seVVSHomeM obile', 'c vt_UseVVSI nterfacili ty', 'cvt_ UseVVSSing leEncounte rNonHomeMo bile'], fi lter, fals e); | |
| 382 | calls. fail(funct ion (err) { | |
| 383 | re turn Vista SwitchesCo nfig; | |
| 384 | }).don e(function (data) { | |
| 385 | if (data && data.d && data.d.res ults != nu ll && data .d.results .length != 0) { | |
| 386 | var reco rd = data. d.results[ 0]; | |
| 387 | baseSwit chConfig = record.cv t_UseVista Integratio n != null ? record.c vt_UseVist aIntegrati on : true; | |
| 388 | hmConfig = record. cvt_UseVVS HomeMobile != null ? record.cv t_UseVVSHo meMobile : true; | |
| 389 | ifcConfi g = record .cvt_UseVV SInterfaci lity != nu ll ? recor d.cvt_UseV VSInterfac ility : tr ue; | |
| 390 | singleNo nHmConfig = record.c vt_UseVVSS ingleEncou nterNonHom eMobile != null ? re cord.cvt_U seVVSSingl eEncounter NonHomeMob ile : true ; | |
| 391 | } | |
| 392 | }); | |
| 393 | //Note that this is a trip le equal, not a doub le, so a n ull value is conside red accept able to co ntinue, on ly a false will mean "don't sh ow Get Con sults" | |
| 394 | if (ba seSwitchCo nfig === f alse) | |
| 395 | re turn false ; | |
| 396 | var ap ptTypeChec k = MCS.VI ALogin.App ointmentTy peSwitchCh eck(hmConf ig, ifcCon fig, singl eNonHmConf ig); | |
| 397 | return apptTypeC heck; | |
| 398 | }; | |
| 399 | ||
| 400 | MCS.VIALog in.Appoint mentTypeSw itchCheck = function (hmConfig , ifcConfi g, singleN onHmConfig ) { | |
| 401 | var Xr m = parent .Xrm; | |
| 402 | var ts aId = MCS. VIALogin.G etTsaId(); | |
| 403 | var pa tFacId = n ull; | |
| 404 | var pr oFacId = n ull; | |
| 405 | var su bSpecialty = null; | |
| 406 | var sp ecialty = null; | |
| 407 | var is InterFacil ity = fals e; | |
| 408 | CrmRes tKit.Retri eve('mcs_s ervices', tsaId, ['c vt_Patient Facility', 'cvt_Prov iderFacili ty', 'cvt_ ServiceSco pe', 'cvt_ servicetyp e', 'cvt_s ervicesubt ype', 'cvt _relatedpr ovidersite id', 'cvt_ relatedpat ientsiteid '], false) | |
| 409 | .f ail(functi on (err) { | |
| 410 | alert("f ailed TSA check, def aulting to display C onsults" + MCS.cvt_C ommon.Rest Error(err) ); | |
| 411 | }) | |
| 412 | .d one(functi on (data) { | |
| 413 | if (data != null & & data.d ! = null) { | |
| 414 | if ( data.d.cvt _PatientFa cility != null) | |
| 415 | patFacId = data.d.cv t_PatientF acility.Id ; | |
| 416 | if ( data.d.cvt _ProviderF acility != null) | |
| 417 | proFacId = data.d.cv t_Provider Facility.I d; | |
| 418 | if ( data.d.cvt _ServiceSc ope != nul l) | |
| 419 | isInterFac ility = da ta.d.cvt_S erviceScop e.Value == 917290000 ; | |
| 420 | if ( data.d.cvt _servicety pe != null ) | |
| 421 | specialty = data.d.c vt_service type.Id; | |
| 422 | if ( data.d.cvt _servicesu btype != n ull) | |
| 423 | subSpecial ty = data. d.cvt_serv icesubtype .Id; | |
| 424 | if ( data.d.cvt _relatedpr ovidersite id != null ) | |
| 425 | TsaProvide rSiteId = data.d.cvt _relatedpr ovidersite id.Id; //T his is key to run ea ch time TS A is set b ecause the Provider Site does not come t hrough unt il after T SA js has run, but t his functi on runs be fore TSA j s is compl ete, so pu lling in T SAProvider SiteId wil l set prov iderSiteId when its not otherw ise popula ted | |
| 426 | if ( data.d.cvt _relatedpr ovidersite id != null ) | |
| 427 | TsaPatient SiteId = d ata.d.cvt_ relatedpat ientsiteid .Id; | |
| 428 | } | |
| 429 | }) ; | |
| 430 | ||
| 431 | var ts aObj = Xrm .Page.getA ttribute(" mcs_relate dtsa"); | |
| 432 | if (ts aObj != nu ll) { | |
| 433 | ||
| 434 | var is HomeMobile = Xrm.Pag e.getAttri bute("cvt_ type").get Value(); | |
| 435 | if (is HomeMobile ) | |
| 436 | re turn hmCon fig; | |
| 437 | var is SingleNonH m = Xrm.Pa ge.getAttr ibute("cvt _telehealt hmodality" ).getValue (); | |
| 438 | if (is SingleNonH m) | |
| 439 | re turn singl eNonHmConf ig; | |
| 440 | } | |
| 441 | ||
| 442 | var su bSpecialty Switch = n ull; | |
| 443 | if (su bSpecialty != null) { | |
| 444 | // Check SubS pecialty S witch | |
| 445 | Cr mRestKit.R etrieve('m cs_service subtype', subSpecial ty, ['cvt_ UseVVS'], false) | |
| 446 | .fail(fu nction (er r) { | |
| 447 | aler t("failed sub-specia lty type c heck, look ing for sp ecialty sw itch: " + MCS.cvt_Co mmon.RestE rror(err)) ; | |
| 448 | }).done( function ( data) { | |
| 449 | subS pecialtySw itch = dat a.d.cvt_Us eVVS; | |
| 450 | }); | |
| 451 | } | |
| 452 | //vari ous "===" is so that if the va lue is nul l, then we evaluate the next c ondition i nstead of considerin g it false | |
| 453 | if (su bSpecialty Switch === false) | |
| 454 | re turn false ; | |
| 455 | var sp ecialtySwi tch = true ; | |
| 456 | if (su bSpecialty Switch == null) { | |
| 457 | Cr mRestKit.R etrieve('m cs_service type', spe cialty, [' cvt_UseVVS '], false) | |
| 458 | .fail(fu nction (er r) { | |
| 459 | aler t("failed specialty type check , defaulti ng to disp lay Consul ts" + MCS. cvt_Common .RestError (err)); | |
| 460 | }) | |
| 461 | .done(fu nction (da ta) { | |
| 462 | spec ialtySwitc h = data.d .cvt_UseVV S; | |
| 463 | }); | |
| 464 | } | |
| 465 | if (sp ecialtySwi tch === fa lse) | |
| 466 | re turn false ; | |
| 467 | ||
| 468 | if (is InterFacil ity) | |
| 469 | re turn ifcCo nfig; | |
| 470 | ||
| 471 | var fa cilitySwit ch = true; | |
| 472 | ||
| 473 | if (pa tFacId != null && pr oFacId != null && pa tFacId == proFacId) { | |
| 474 | Cr mRestKit.R etrieve('m cs_facilit y', patFac Id, ['cvt_ UseVistaIn trafacilit y'], false ) | |
| 475 | .fail(fu nction (er r) { | |
| 476 | aler t("failed Intrafacil ity check, defaultin g to displ ay Consult s" + MCS.c vt_Common. RestError( err)); | |
| 477 | }) | |
| 478 | .done(fu nction (da ta) { | |
| 479 | if ( data != nu ll && data .d != null ) | |
| 480 | facilitySw itch = dat a.d.cvt_Us eVistaIntr afacility != null ? data.d.cvt _UseVistaI ntrafacili ty : true; | |
| 481 | }); | |
| 482 | } | |
| 483 | return facilityS witch === false ? fa lse : true ; | |
| 484 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.