Produced by Araxis Merge on 6/22/2018 1:29:26 PM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | v1603_release_60.zip\CRM_solutions\VCCMResources.zip\WebResources | ftp_RequestJScriptMedicationPickerjsC52C2D59-C7B5-E711-945A-0050568D743D | Tue May 22 14:39:24 2018 UTC |
| 2 | v1603_release_60.zip\CRM_solutions\VCCMResources.zip\WebResources | ftp_RequestJScriptMedicationPickerjsC52C2D59-C7B5-E711-945A-0050568D743D | Fri Jun 8 21:34:31 2018 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 1848 |
| Changed | 1 | 2 |
| 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 | /// <refer ence path= "../../Web ServiceSec urityLib/j s/WebServi ceSecurity Library.js " /> | |
| 2 | ||
| 3 | var config Data = nul l, | |
| 4 | contex t = null, | |
| 5 | _setti ngs = null , | |
| 6 | _medsF romCRM = [ ], | |
| 7 | _useSe cureMedica tionAPI = true; | |
| 8 | var fieldM appings = [ | |
| 9 | { | |
| 10 | fi eld: "Sele cted", | |
| 11 | VA Path: null , | |
| 12 | ti tle: " ", | |
| 13 | ty pe: "boole an", | |
| 14 | te mplate: fu nction (pD ataItem) { | |
| 15 | return " <img class ='checkmar k' src='" + (pDataIt em.Previou slySelecte dInCRM == true ? "/_ imgs/grid/ checkbox.p ng" : "/_i mgs/grid/c heckbox_li ght.png") + "' oncli ck='checkm ark_click( this);' ti tle='Selec t this med ication fo r renewal and inclus ion in a p rogress no te' />"; | |
| 16 | }, | |
| 17 | he aderTempla te: "<img src='/_img s/grid/che ckbox.png' onclick=' headerChec kmark_clic k();' id=' headerChec kmark' tit le='Select all/no me dications for renewa l and incl usion in a progress note' />", | |
| 18 | gr oupable: f alse, | |
| 19 | so rtable: fa lse, | |
| 20 | fi lterable: false, | |
| 21 | wi dth: 25 | |
| 22 | }, | |
| 23 | { | |
| 24 | fi eld: "Prev iouslySele ctedInCRM" , | |
| 25 | ty pe: "boole an", | |
| 26 | hi dden: true , | |
| 27 | // width: 1 | |
| 28 | }, | |
| 29 | { | |
| 30 | fi eld: "Loca lId", | |
| 31 | VA : "LocalId ", | |
| 32 | VA Path: ["Lo calId"], | |
| 33 | CR M: "ftp_Pi ckedMedica tionVALoca lId", | |
| 34 | hi dden: true , | |
| 35 | // width: 1 | |
| 36 | }, | |
| 37 | { | |
| 38 | fi eld: "CRMI d", | |
| 39 | VA : "CRMId", | |
| 40 | CR M: "ftp_pi ckedmedica tionId", | |
| 41 | hi dden: true , | |
| 42 | // width: 1 | |
| 43 | }, | |
| 44 | { | |
| 45 | fi eld: "RxNu mber", | |
| 46 | ti tle: "Rx N umber", | |
| 47 | VA : "RxNumbe r", | |
| 48 | VA Path: ["Or ders[0].Pr escription Id"], | |
| 49 | CR M: "ftp_Rx Number", | |
| 50 | fi lterable: false, | |
| 51 | he aderAttrib utes: { | |
| 52 | title: " Rx Number" | |
| 53 | }, | |
| 54 | wi dth: 60 | |
| 55 | }, | |
| 56 | { | |
| 57 | fi eld: "Name ", | |
| 58 | ti tle: "Med Name", | |
| 59 | VA : "Name", | |
| 60 | VA Path: ["Pr oducts[0]. SuppliedNa me", "Qual ifiedName" , "Name"], | |
| 61 | CR M: "ftp_na me", | |
| 62 | fi lterable: { | |
| 63 | multi: t rue | |
| 64 | }, | |
| 65 | he aderAttrib utes: { | |
| 66 | title: " Name" | |
| 67 | }, | |
| 68 | wi dth: 80 | |
| 69 | }, | |
| 70 | { | |
| 71 | fi eld: "Inst ructions", | |
| 72 | ti tle: "Inst ructions", | |
| 73 | VA : "Sig", | |
| 74 | VA Path: ["Si g"], | |
| 75 | CR M: "ftp_In structions ", | |
| 76 | fi lterable: false, | |
| 77 | he aderAttrib utes: { | |
| 78 | title: " Instructio ns" | |
| 79 | }, | |
| 80 | wi dth: 180 | |
| 81 | }, | |
| 82 | { | |
| 83 | fi eld: "Pati entInstruc tions", | |
| 84 | ti tle: "Pati ent Instru ctions", | |
| 85 | VA : "Patient Instructio n", | |
| 86 | VA Path: ["Pa tientInstr uction"], | |
| 87 | CR M: "ftp_Pa tientInstr uctions", | |
| 88 | fi lterable: false, | |
| 89 | he aderAttrib utes: { | |
| 90 | title: " Patient In structions " | |
| 91 | }, | |
| 92 | wi dth: 180 | |
| 93 | }, | |
| 94 | { | |
| 95 | fi eld: "VaSt atus", | |
| 96 | ti tle: "Stat us", | |
| 97 | VA : "VaStatu s", | |
| 98 | VA Path: ["Va Status"], | |
| 99 | CR M: "ftp_VA Status", | |
| 100 | fi lterable: { | |
| 101 | multi: t rue | |
| 102 | }, | |
| 103 | he aderAttrib utes: { | |
| 104 | title: " Status" | |
| 105 | }, | |
| 106 | wi dth: 60 | |
| 107 | }, | |
| 108 | { | |
| 109 | fi eld: "Fill sRemaining ", | |
| 110 | ti tle: "Refi lls Left", | |
| 111 | ty pe: "numbe r", | |
| 112 | VA : "FillsRe maining", | |
| 113 | VA Path: ["Or ders[0].Fi llsRemaini ng"], | |
| 114 | CR M: "ftp_Re fillsRemai ning_numbe r", | |
| 115 | he aderAttrib utes: { | |
| 116 | title: " Refills Le ft" | |
| 117 | }, | |
| 118 | wi dth: 60 | |
| 119 | }, | |
| 120 | { | |
| 121 | fi eld: "Quan tity", | |
| 122 | ti tle: "Quan tity", | |
| 123 | ty pe: "numbe r", | |
| 124 | VA : "", | |
| 125 | VA Path: ["Or ders[0].Qu antityOrde red"], | |
| 126 | CR M: "", | |
| 127 | he aderAttrib utes: { | |
| 128 | title: " Quantity" | |
| 129 | }, | |
| 130 | wi dth: 50 | |
| 131 | }, | |
| 132 | { | |
| 133 | fi eld: "Over allStart", | |
| 134 | ti tle: "Issu e Date", | |
| 135 | ty pe: "date" , | |
| 136 | VA : "Overall Start", | |
| 137 | VA Path: ["Ov erallStart "], | |
| 138 | CR M: "ftp_Is sueDate_te xt", | |
| 139 | te mplate: fu nction (pD ataItem) { | |
| 140 | return ! !pDataItem .OverallSt art ? kend o.toString (pDataItem .OverallSt art, "M/dd /yyyy") : ""; | |
| 141 | }, | |
| 142 | fi lterable: false, | |
| 143 | he aderAttrib utes: { | |
| 144 | title: " Issue Date " | |
| 145 | }, | |
| 146 | wi dth: 70 | |
| 147 | }, | |
| 148 | { | |
| 149 | fi eld: "Last Filled", | |
| 150 | ti tle: "Last Refill", | |
| 151 | ty pe: "date" , | |
| 152 | VA : "LastFil led", | |
| 153 | VA Path: ["La stFilled"] , | |
| 154 | CR M: "ftp_La stRefill_t ext", | |
| 155 | te mplate: fu nction (pD ataItem) { | |
| 156 | return ! !pDataItem .LastFille d ? kendo. toString(p DataItem.L astFilled, "M/dd/yyy y") : ""; | |
| 157 | }, | |
| 158 | fi lterable: false, | |
| 159 | he aderAttrib utes: { | |
| 160 | title: " Last Refil l" | |
| 161 | }, | |
| 162 | wi dth: 70 | |
| 163 | }, | |
| 164 | { | |
| 165 | fi eld: "Over allStop", | |
| 166 | ti tle: "Expi ration", | |
| 167 | ty pe: "date" , | |
| 168 | VA : "Overall Stop", | |
| 169 | VA Path: ["Ov erallStop" ], | |
| 170 | CR M: "ftp_Ex pirationDa te_text", | |
| 171 | te mplate: fu nction (pD ataItem) { | |
| 172 | return ! !pDataItem .OverallSt op ? kendo .toString( pDataItem. OverallSto p, "M/dd/y yyy") : "" ; | |
| 173 | }, | |
| 174 | fi lterable: false, | |
| 175 | he aderAttrib utes: { | |
| 176 | title: " Expiration " | |
| 177 | }, | |
| 178 | wi dth: 70 | |
| 179 | } | |
| 180 | ]; | |
| 181 | ||
| 182 | ||
| 183 | $(document ).ready(fu nction () { | |
| 184 | doPage Load(); | |
| 185 | }); | |
| 186 | ||
| 187 | function d oPageLoad( ) { | |
| 188 | try { | |
| 189 | co nfigData = parseData Parameters FromUrl(lo cation.sea rch); | |
| 190 | co ntext = ge tContext() ; | |
| 191 | va r today = new Date() ; | |
| 192 | to day.setHou rs(0, 0, 0 , 0); | |
| 193 | va r fifteenM onthsPrior = new Dat e(); | |
| 194 | fi fteenMonth sPrior.set Month(toda y.getMonth () - 15); | |
| 195 | if (!!!$("#h eaderStart Date").dat a("kendoDa tePicker") ) { | |
| 196 | $("#head erStartDat e").kendoD atePicker( { | |
| 197 | valu e: fifteen MonthsPrio r, | |
| 198 | date Input: tru e, | |
| 199 | chan ge: header StartDate_ onChange | |
| 200 | }); | |
| 201 | } | |
| 202 | ||
| 203 | if (!!!$("#h eaderEndDa te").data( "kendoDate Picker")) { | |
| 204 | $("#head erEndDate" ).kendoDat ePicker({ | |
| 205 | valu e: today, | |
| 206 | date Input: tru e, | |
| 207 | foot er: "Today - #: kend o.toString (data, 'd' ) #", | |
| 208 | chan ge: header EndDate_on Change | |
| 209 | }); | |
| 210 | } | |
| 211 | ||
| 212 | // load test data in AW S environm ent | |
| 213 | if (locati on.href.in dexOf("htt ps:// URL /VCCMDEV") > -1) { | |
| 214 | setTimeo ut( | |
| 215 | func tion () { | |
| 216 | processDat aFromMedic ationAPI(t estData); | |
| 217 | }, | |
| 218 | 500 | |
| 219 | ); | |
| 220 | } | |
| 221 | el se { | |
| 222 | loadPrev iouslySele ctedMedica tionsFromC RM(configD ata.id); | |
| 223 | } | |
| 224 | } | |
| 225 | catch (err) { | |
| 226 | co nsole.erro r(err.mess age); | |
| 227 | al ert("Docum ent ready error: " + err.messa ge); | |
| 228 | } | |
| 229 | } | |
| 230 | function h eaderStart Date_onCha nge() { | |
| 231 | if (!! this.value ()) { | |
| 232 | ap plyHeaderD ateFilter( ); | |
| 233 | } | |
| 234 | else { | |
| 235 | va r today = new Date() ; | |
| 236 | to day.setHou rs(0, 0, 0 , 0); | |
| 237 | va r fifteenM onthsPrior = new Dat e(); | |
| 238 | fi fteenMonth sPrior.set Month(toda y.getMonth () - 15); | |
| 239 | th is.value(f ifteenMont hsPrior); | |
| 240 | ap plyHeaderD ateFilter( ); | |
| 241 | } | |
| 242 | } | |
| 243 | function h eaderEndDa te_onChang e() { | |
| 244 | if (!! this.value ()) { | |
| 245 | ap plyHeaderD ateFilter( ); | |
| 246 | } | |
| 247 | else { | |
| 248 | va r today = new Date() ; | |
| 249 | to day.setHou rs(0, 0, 0 , 0); | |
| 250 | th is.value(t oday); | |
| 251 | ap plyHeaderD ateFilter( ); | |
| 252 | } | |
| 253 | } | |
| 254 | ||
| 255 | function l oadPreviou slySelecte dMedicatio nsFromCRM( pRequestId ) { | |
| 256 | try{ | |
| 257 | sh owLoadingM essage("Lo ading medi cations... "); | |
| 258 | va r requestI d = !!pReq uestId ? p RequestId : !!config Data.id ? configData .id : !!pa rent.Xrm & & !!parent .Xrm.Page && !!paren t.Xrm.Page .data && ! !parent.Xr m.Page.dat a.entity ? parent.Xr m.Page.dat a.entity.g etId() : " "; | |
| 259 | _m edsFromCRM = []; | |
| 260 | if (!!reques tId) { | |
| 261 | var quer yColumns = []; | |
| 262 | fieldMap pings.forE ach(functi on (c, i) { if (!!c. CRM) { que ryColumns. push(c.CRM ); } }); | |
| 263 | var quer yString = "$select=f tp_Request Id," + que ryColumns. join() + " &$filter=f tp_Request Id/Id eq g uid'" + re questId + "'"; | |
| 264 | try { | |
| 265 | SDK. REST.retri eveMultipl eRecords( | |
| 266 | "ftp_picke dmedicatio n", | |
| 267 | queryStrin g, | |
| 268 | function ( retrievedR ecords) { | |
| 269 | if (ty peof retri evedRecord s != "unde fined" && !!retrieve dRecords & & retrieve dRecords.l ength > 0) _medsFrom CRM = _med sFromCRM.c oncat(retr ievedRecor ds); | |
| 270 | }, | |
| 271 | errorHandl er, | |
| 272 | function ( ) { | |
| 273 | findAc tiveSettin gs(queryMe dicationAP I); | |
| 274 | } | |
| 275 | ); | |
| 276 | } | |
| 277 | catch (e ) { | |
| 278 | show ErrorMessa ge("Error retrieving previousl y picked m edications from CRM: " + e.mes sage); | |
| 279 | } | |
| 280 | } | |
| 281 | el se { | |
| 282 | showDiv( "#newRecor dMessageCo ntainer"); | |
| 283 | } | |
| 284 | } | |
| 285 | catch (err) { | |
| 286 | th row err; | |
| 287 | } | |
| 288 | } | |
| 289 | function f indActiveS ettings(pC allbackFun ction) { | |
| 290 | //get the Active Settings record fro m either t he parent request fo rm or dire ctly from CRM | |
| 291 | if (!! _settings) { | |
| 292 | if (typeof p CallbackFu nction == "function" ) { pCallb ackFunctio n(); } | |
| 293 | } | |
| 294 | else { | |
| 295 | if (!!parent ._retrieve dSettings) { | |
| 296 | _setting s = parent ._retrieve dSettings; | |
| 297 | if (type of pCallba ckFunction == "funct ion") { pC allbackFun ction(); } | |
| 298 | } | |
| 299 | el se { | |
| 300 | var quer yString = "$select=* &$filter=m cs_name eq 'Active S ettings'"; | |
| 301 | try { | |
| 302 | SDK. REST.retri eveMultipl eRecords( | |
| 303 | "mcs_sett ing", | |
| 304 | queryStri ng, | |
| 305 | function (retrieved Records) { | |
| 306 | if (t ypeof retr ievedRecor ds != "und efined" && !!retriev edRecords && retriev edRecords. length == 1) _settin gs = retri evedRecord s[0]; | |
| 307 | }, | |
| 308 | errorHand ler, | |
| 309 | function () { | |
| 310 | if (! !_settings ) { | |
| 311 | i f (typeof pCallbackF unction == "function ") { pCall backFuncti on(); } | |
| 312 | } | |
| 313 | } | |
| 314 | ); | |
| 315 | } | |
| 316 | catch (e ) { | |
| 317 | show ErrorMessa ge("Error retrieving Active Se ttings: " + e.messag e); | |
| 318 | } | |
| 319 | } | |
| 320 | } | |
| 321 | } | |
| 322 | function q ueryMedica tionAPI() { | |
| 323 | try{ | |
| 324 | if (!!parent ._national Id) { | |
| 325 | if (!!_s ettings && !!_settin gs.ftp_DAC URL) { | |
| 326 | if ( _useSecure Medication API == tru e) { | |
| 327 | if (!!_set tings.ftp_ Medication APISecureU RL) { | |
| 328 | try{ | |
| 329 | va r secureMe dAPIURL = _settings. ftp_DACURL + _settin gs.ftp_Med icationAPI SecureURL; | |
| 330 | va r secureMe dAPIParams = [{ key: "identifi er", type: "c:string ", value: JSON.strin gify({ Nat ionalId: p arent._nat ionalId }) }]; | |
| 331 | Cr mSecurityT okenEncryp tion( | |
| 332 | secureMe dAPIURL, | |
| 333 | secureMe dAPIParams , | |
| 334 | context. getClientU rl(), | |
| 335 | function (pError, pResponse) { | |
| 336 | if ( !!pError) { | |
| 337 | throw new Error(pErr or); | |
| 338 | } | |
| 339 | else if (pResp onse.Error Occurred) { | |
| 340 | throw new Error(pRes ponse.Erro rMessage); | |
| 341 | } | |
| 342 | else { | |
| 343 | processDat aFromMedic ationAPI(p Response.D ata); | |
| 344 | } | |
| 345 | } | |
| 346 | ); | |
| 347 | } | |
| 348 | catch (e) { | |
| 349 | th row new Er ror("Error querying Secure Med ications A PI: " + e. message); | |
| 350 | } | |
| 351 | } | |
| 352 | else { | |
| 353 | throw new Error( "Configura tion error ... Missin g Medicati on API Sec ure URL. C heck Activ e Settings ."); | |
| 354 | } | |
| 355 | } | |
| 356 | else { | |
| 357 | if (!!_set tings.ftp_ Medication APIURL) { | |
| 358 | var me dQueryUrl = _setting s.ftp_DACU RL + _sett ings.ftp_M edicationA PIURL + pa rent._nati onalId + ( !!_setting s.ftp_Filt er ? _sett ings.ftp_F ilter : "" ); | |
| 359 | try { | |
| 360 | $. ajax({ | |
| 361 | type: "G ET", | |
| 362 | url: med QueryUrl, | |
| 363 | contentT ype: "appl ication/js on; charse t=utf-8", | |
| 364 | dataType : "json", | |
| 365 | success: function (response) { | |
| 366 | if ( response.E rrorOccurr ed == fals e) { | |
| 367 | processDat aFromMedic ationAPI(r esponse.Da ta); | |
| 368 | } | |
| 369 | else { | |
| 370 | showErrorM essage("Er ror queryi ng Medicat ions API: " + respon se.ErrorMe ssage); | |
| 371 | } | |
| 372 | }, | |
| 373 | error: f unction (j qXHR, text Status, er rorThrown) { | |
| 374 | show ErrorMessa ge("Error querying M edications API: " + errorThrow n); | |
| 375 | }, | |
| 376 | async: t rue, | |
| 377 | cache: f alse | |
| 378 | }) ; | |
| 379 | } | |
| 380 | catch (e) { | |
| 381 | th row new Er ror("Error querying Medication s API: " + e.message ); | |
| 382 | } | |
| 383 | } | |
| 384 | else { | |
| 385 | throw new Error( "Configura tion error ... Missin g Medicati on API URL . Check Ac tive Setti ngs."); | |
| 386 | } | |
| 387 | } | |
| 388 | } | |
| 389 | else { | |
| 390 | thro w new Erro r("Configu ration err or... Miss ing DAC UR L. Check A ctive Sett ings."); | |
| 391 | } | |
| 392 | ||
| 393 | } | |
| 394 | el se { | |
| 395 | throw ne w Error("C onfigurati on error: missing Ve teran Nati onalId"); | |
| 396 | } | |
| 397 | } | |
| 398 | catch (e) { | |
| 399 | sh owErrorMes sage(e.mes sage); | |
| 400 | } | |
| 401 | } | |
| 402 | function p rocessData FromMedica tionAPI(pD ata) { | |
| 403 | var me dsFromHDR = []; | |
| 404 | if (!! pData && A rray.isArr ay(pData) && pData.l ength > 0) { | |
| 405 | fo r (var i = 0; i < pD ata.length ; i++) { | |
| 406 | var this Medication FromAPI = pData[i]; | |
| 407 | var newM edObj = {} ; | |
| 408 | for (var j = 0; j < fieldMap pings.leng th; j++) { | |
| 409 | var thisFieldM apping = f ieldMappin gs[j]; | |
| 410 | //pa rse fields from medi cation API data, usi ng thisFie ldMapping' s VAPath(s ) to find data in th e payload | |
| 411 | if ( !!thisFiel dMapping.V APath && t hisFieldMa pping.VAPa th.length > 0) { | |
| 412 | var thisVa lueString = ""; | |
| 413 | for (var k = 0; k < thisFieldM apping.VAP ath.length && !!!thi sValueStri ng; k++) { | |
| 414 | thisVa lueString = getDeepP roperty(th isFieldMap ping.VAPat h[k], this Medication FromAPI); | |
| 415 | } | |
| 416 | ||
| 417 | if (thisFi eldMapping .type == " date") { | |
| 418 | newMed Obj[thisFi eldMapping .field] = !!thisValu eString ? new Date(t hisValueSt ring.subst r(0, 4), t hisValueSt ring.subst r(4, 2) - 1, thisVal ueString.s ubstr(6, 2 )) : ""; | |
| 419 | } | |
| 420 | else if (t hisFieldMa pping.type == "numbe r") { | |
| 421 | var th isValueNum ber = !!th isValueStr ing ? pars eInt(thisV alueString ) : thisVa lueString; | |
| 422 | newMed Obj[thisFi eldMapping .field] = thisValueN umber; | |
| 423 | //save highest a nd lowest number, to inform sl ider filte rs. | |
| 424 | var mi nVarName = thisField Mapping.fi eld + "_sl idermin"; | |
| 425 | var ma xVarName = thisField Mapping.fi eld + "_sl idermax"; | |
| 426 | window [minVarNam e] = 0; | |
| 427 | window [maxVarNam e] = | |
| 428 | !! !window[ma xVarName] && !!!this ValueNumbe r ? 0 : | |
| 429 | !! !window[ma xVarName] && !!thisV alueNumber ? thisVal ueNumber : | |
| 430 | !! window[max VarName] & & !!!thisV alueNumber && window [maxVarNam e] > 0 ? w indow[maxV arName] : | |
| 431 | !! window[max VarName] & & !!thisVa lueNumber && thisVal ueNumber > window[ma xVarName] ? thisValu eNumber : | |
| 432 | wi ndow[maxVa rName] > 0 ? window[ maxVarName ] : | |
| 433 | 0; | |
| 434 | } | |
| 435 | else { | |
| 436 | newMed Obj[thisFi eldMapping .field] = thisValueS tring; | |
| 437 | } | |
| 438 | } | |
| 439 | } | |
| 440 | //var ma tchingCRMR owIndex = _medsFromC RM.length > 0 ? Arra yIndexOfOb jectByAttr ibute(_med sFromCRM, getDeepPro perty("fie ldMappings [" + Array IndexOfObj ectByAttri bute(field Mappings, "VA", "Loc alId") + " ].CRM", wi ndow), new MedObj.Loc alId) : -1 ; | |
| 441 | var matc hingCRMRow Index = _m edsFromCRM .length > 0 ? ArrayI ndexOfObje ctByAttrib ute(_medsF romCRM, "f tp_PickedM edicationV ALocalId", newMedObj .LocalId) : -1; | |
| 442 | newMedOb j.Previous lySelected InCRM = ma tchingCRMR owIndex > -1; | |
| 443 | newMedOb j.Selected = newMedO bj.Previou slySelecte dInCRM == true; | |
| 444 | //newMed Obj.CRMId = newMedOb j.Previous lySelected InCRM ? _m edsFromCRM [matchingC RMRowIndex ][getDeepP roperty("f ieldMappin gs[" + Arr ayIndexOfO bjectByAtt ribute(fie ldMappings , "VA", "C RMId") + " ].CRM", wi ndow)] : n ull; | |
| 445 | newMedOb j.CRMId = newMedObj. Previously SelectedIn CRM ? _med sFromCRM[m atchingCRM RowIndex]. ftp_picked medication Id : null; | |
| 446 | medsFrom HDR.push(n ewMedObj); | |
| 447 | } | |
| 448 | } | |
| 449 | render Medication s(medsFrom HDR); | |
| 450 | } | |
| 451 | function r enderMedic ations(pDa taForKendo Grid) { | |
| 452 | try { | |
| 453 | if (!!pDataF orKendoGri d && Array .isArray(p DataForKen doGrid)) { | |
| 454 | destroyM edicationG rid(); | |
| 455 | var note GridDiv = $("<div id ='medicati onGridDiv' ></div>"). appendTo(" #medicatio nGridDivPa rentDiv"); | |
| 456 | var medi cationGrid = $("#med icationGri dDiv").ken doGrid({ | |
| 457 | colu mns: field Mappings, | |
| 458 | sort able: true , | |
| 459 | edit able: fals e, | |
| 460 | resi zable: tru e, | |
| 461 | scro llable: tr ue, | |
| 462 | heig ht: 300, | |
| 463 | navi gatable: t rue, | |
| 464 | noRe cords: { | |
| 465 | template: "No medica tion recor ds found f rom last 1 5 months." | |
| 466 | }, | |
| 467 | page able: { | |
| 468 | pageSize: 5//, | |
| 469 | //pageSize s: [5, 10, 20, 40, " all"] | |
| 470 | }, | |
| 471 | filt erable: tr ue,//{ mod e: "row"}, | |
| 472 | //se lectable: "multiple" , | |
| 473 | //pe rsistSelec tion: true , | |
| 474 | data Source: pD ataForKend oGrid, | |
| 475 | data Bound: fun ction (e) { | |
| 476 | var view = this.data Source.vie w(); | |
| 477 | for (var i = 0; i < view.lengt h; i++) { | |
| 478 | if (vi ew[i].Sele cted == tr ue) { | |
| 479 | va r thisRow = this.tbo dy.find("t r[data-uid ='" + view [i].uid + "']"); | |
| 480 | th isRow.addC lass("k-st ate-select ed"); | |
| 481 | $( thisRow).f ind("img") .attr("src ", "/_imgs /grid/chec kbox.png") | |
| 482 | // checkmark_ click($(th isRow).fin d("img")[0 ]); | |
| 483 | } | |
| 484 | } | |
| 485 | ||
| 486 | //attach t o single-c lick event of rows t o mimic cl icking the row's 'Ch eckmark' s elector | |
| 487 | this.eleme nt.on('cli ck', 'tbod y tr[data- uid]', fun ction (ce) { | |
| 488 | ce.sto pImmediate Propagatio n(); | |
| 489 | ||
| 490 | //ce.c urrentTarg et should be the <tr > element that is th e parent o f the clic ked <td> o r <img> el ement | |
| 491 | //cons ole.log(ce .target); | |
| 492 | //cons ole.log(ce .currentTa rget); | |
| 493 | ||
| 494 | var cl ickedEleme nt = ce.ta rget; | |
| 495 | var ch eckmarkFor Row = $(ce .currentTa rget).find (".checkma rk")[0]; | |
| 496 | ||
| 497 | if (!! clickedEle ment && !! checkmarkF orRow) { | |
| 498 | if (clickedE lement.out erHTML.ind exOf("<but ton") == 0 && clicke dElement.i nnerHTML = = "EDIT") { | |
| 499 | //don't select row when user clicks th e EDIT but ton | |
| 500 | return; | |
| 501 | } | |
| 502 | if (clickedE lement == checkmarkF orRow) { | |
| 503 | //user c licked che ckmark | |
| 504 | //the ch eckmark_cl ick functi on will ha ve already fired, so end this function. | |
| 505 | return; | |
| 506 | } | |
| 507 | ch eckmark_cl ick(checkm arkForRow) ; | |
| 508 | } | |
| 509 | ||
| 510 | //chec kmark for row | |
| 511 | //$(ce .currentTa rget).find (".checkma rk"); | |
| 512 | ||
| 513 | //data item for row | |
| 514 | //$('# notesGridD iv').data( 'kendoGrid ').dataIte m($(ce.cur rentTarget )) | |
| 515 | //cons ole.log($( '#notesGri dDiv').dat a('kendoGr id').dataI tem($(ce.c urrentTarg et))); | |
| 516 | }); | |
| 517 | setHelperT ext(); | |
| 518 | }, | |
| 519 | chan ge: functi on (e) { | |
| 520 | }, | |
| 521 | filt erMenuInit : function (e) { | |
| 522 | var fieldN ame = e.fi eld; | |
| 523 | var thisCo lumn = e.s ender.colu mns[ArrayI ndexOfObje ctByAttrib ute(e.send er.columns , "field", fieldName )]; | |
| 524 | /* | |
| 525 | if (thisCo lumn.type == "number ") { | |
| 526 | var el ementId = "rangeslid er_" + fie ldName; | |
| 527 | $(e.co ntainer[0] ).html("<d iv id='" + elementId + "'><inp ut/><input /></div>") | |
| 528 | ||
| 529 | var sl iderMinVal ue = windo w[fieldNam e + "_slid ermin"] > 0 ? window [fieldName + "_slide rmin"] - 1 : 0; | |
| 530 | var sl iderMaxVal ue = windo w[fieldNam e + "_slid ermax"] + 1; | |
| 531 | $("#" + elementI d).kendoRa ngeSlider( { | |
| 532 | ch ange: func tion (s) { | |
| 533 | if (s.va lues[0] == s.sender. options.mi n && s.val ues[1] == s.sender.o ptions.max ) { | |
| 534 | //cl ear this f ilter | |
| 535 | remo veFilterFr omGrid("fi lter_" + f ieldName); | |
| 536 | } | |
| 537 | else { | |
| 538 | //ad d this fil ter | |
| 539 | var grid = $(" #medicatio nGridDiv") .data("ken doGrid"); | |
| 540 | addF ilterToGri d({ | |
| 541 | logic: "an d", | |
| 542 | filters: [ | |
| 543 | { fiel d: fieldNa me, operat or: "neq", value: nu ll }, | |
| 544 | { fiel d: fieldNa me, operat or: "gte", value: s. values[0] }, | |
| 545 | { fiel d: fieldNa me, operat or: "lte", value: s. values[1] } | |
| 546 | ], | |
| 547 | id: "filte r_" + fiel dName | |
| 548 | }); | |
| 549 | } | |
| 550 | ||
| 551 | //grid.d ataSource. filter(fil terObject) | |
| 552 | }, | |
| 553 | mi n: sliderM inValue, | |
| 554 | ma x: sliderM axValue, | |
| 555 | sm allStep: 1 , | |
| 556 | la rgeStep: 3 , | |
| 557 | ti ckPlacemen t: "both" | |
| 558 | }); | |
| 559 | } | |
| 560 | */ | |
| 561 | }, | |
| 562 | filt er: functi on (e) { | |
| 563 | } | |
| 564 | }); | |
| 565 | applyHea derDateFil ter(); | |
| 566 | ||
| 567 | var grid ButtonsDiv = $( | |
| 568 | "<di v id='Acti onButtons' >" + | |
| 569 | "<input id ='btnRefre shGrid' ty pe='button ' class='C rmButton' value='Ref resh Medic ation Grid ' title='R efresh the medicatio ns listed in the gri d.' onclic k='doPageL oad();' /> " + | |
| 570 | "<input id ='btnSaveS election' type='butt on' class= 'CrmButton ' value='S ave Select ion' title ='Save you r new sele ction(s) t o CRM, for later use in a Prog ress Note. ' onclick= 'btnSaveSe lection_cl ick();' di sabled='di sabled'/>" + | |
| 571 | "</d iv>").appe ndTo(".k-p ager-wrap" ); | |
| 572 | toggleSa veSelectio nButton(); | |
| 573 | showDiv( "#Medicati onPickerCo ntainer"); | |
| 574 | } | |
| 575 | } | |
| 576 | catch (e) { | |
| 577 | sh owErrorMes sage("Erro r renderin g medicati ons on gri d: " + e.m essage); | |
| 578 | } | |
| 579 | } | |
| 580 | ||
| 581 | function h eaderCheck mark_click () { | |
| 582 | var to talSelecte d = 0; | |
| 583 | var vi ew = $("#m edicationG ridDiv").d ata("kendo Grid").dat aSource.vi ew() | |
| 584 | for (v ar i = 0; i < view.l ength; i++ ) { | |
| 585 | if (view[i]. Selected = = true) { | |
| 586 | totalSel ected++; | |
| 587 | } | |
| 588 | } | |
| 589 | var cl earAll = t otalSelect ed == view .length; | |
| 590 | $(".ch eckmark"). each(funct ion (i, th isCheckmar k) { captu reMedicati onSelectio n(thisChec kmark, !cl earAll); } ); //selec t/unselect all check marks on c urrent pag e of grid | |
| 591 | } | |
| 592 | function c heckmark_c lick(pChec kmark) { | |
| 593 | try { | |
| 594 | va r wasCheck edWhenClic ked = $('# medication GridDiv'). data('kend oGrid').da taItem($(p Checkmark) .closest(" tr")).Sele cted == tr ue; | |
| 595 | ca ptureMedic ationSelec tion(pChec kmark, !wa sCheckedWh enClicked) ; | |
| 596 | } | |
| 597 | catch (err) { | |
| 598 | al ert('Medic ation Grid Web Resou rce Functi on Error(c heckmark_c lick): ' + err.messa ge); | |
| 599 | re turn null; | |
| 600 | } | |
| 601 | } | |
| 602 | function c aptureMedi cationSele ction(pChe ckmark, pS elect) { | |
| 603 | var th isRow = $( pCheckmark ).closest( "tr"); | |
| 604 | var me dicationGr id = $('#m edicationG ridDiv').d ata('kendo Grid'); | |
| 605 | var me dDataItem = medicati onGrid.dat aItem(this Row); | |
| 606 | medDat aItem.Sele cted = pSe lect; | |
| 607 | ||
| 608 | if (pS elect) { | |
| 609 | // add the ap propriate kendo clas s to highl ight the r ow | |
| 610 | th isRow.addC lass("k-st ate-select ed"); | |
| 611 | pC heckmark.s etAttribut e("src", " /_imgs/gri d/checkbox .png"); | |
| 612 | } | |
| 613 | else { | |
| 614 | // remove the appropria te kendo c lass that highlights the row | |
| 615 | th isRow.remo veClass("k -state-sel ected"); | |
| 616 | pC heckmark.s etAttribut e("src", " /_imgs/gri d/checkbox _light.png "); | |
| 617 | } | |
| 618 | toggle SaveSelect ionButton( ); | |
| 619 | } | |
| 620 | function t oggleSaveS electionBu tton() { | |
| 621 | var me dicationGr id = $('#m edicationG ridDiv').d ata('kendo Grid'); | |
| 622 | //enab le/disable btnApplyS electedNot es button | |
| 623 | var ro ws = medic ationGrid. dataSource .data(); | |
| 624 | var at LeastOneRo wIsDirty = false; | |
| 625 | for (v ar i = 0; i < rows.l ength && a tLeastOneR owIsDirty == false; i++) { | |
| 626 | at LeastOneRo wIsDirty = rows[i].P reviouslyS electedInC RM != rows [i].Select ed; | |
| 627 | } | |
| 628 | if (at LeastOneRo wIsDirty) { | |
| 629 | $( "#btnSaveS election") .removeAtt r("disable d"); | |
| 630 | } | |
| 631 | else { | |
| 632 | $( "#btnSaveS election") .attr("dis abled", "d isabled"); | |
| 633 | } | |
| 634 | } | |
| 635 | ||
| 636 | function b tnSaveSele ction_clic k(pButton) { | |
| 637 | saveSe lectedMedi cationsToC RM(); | |
| 638 | } | |
| 639 | function s aveSelecte dMedicatio nsToCRM(pI ndex) { | |
| 640 | try{ | |
| 641 | va r medGridD ata = $("# medication GridDiv"). data("kend oGrid").da taSource.d ata(); | |
| 642 | va r index = !!pIndex ? pIndex : 0; | |
| 643 | if (!!medGri dData && i ndex < med GridData.l ength) { | |
| 644 | showLoad ingMessage ("Saving s election(s )..."); | |
| 645 | var this Row = medG ridData[in dex]; | |
| 646 | index++; | |
| 647 | ||
| 648 | if (this Row.Select ed == true && thisRo w.Previous lySelected InCRM == f alse && th isRow.CRMI d == null) { | |
| 649 | //cr eate this row in CRM | |
| 650 | var newRecord = { | |
| 651 | ftp_Reques tId: { | |
| 652 | Id: pa rent.Xrm.P age.data.e ntity.getI d(), | |
| 653 | Logica lName: par ent.Xrm.Pa ge.data.en tity.getEn tityName() , | |
| 654 | Name: parent.Xrm .Page.data .entity.ge tPrimaryAt tributeVal ue() | |
| 655 | } | |
| 656 | }; | |
| 657 | fiel dMappings. forEach(fu nction (th isFieldMap ping, i) { | |
| 658 | if (!!this FieldMappi ng.CRM && thisFieldM apping.CRM != "ftp_p ickedmedic ationId" & & !!thisFi eldMapping .field && !!thisRow[ thisFieldM apping.fie ld]) { | |
| 659 | newRec ord[thisFi eldMapping .CRM] = th isRow[this FieldMappi ng.field]; | |
| 660 | if (th isFieldMap ping.type == "date" && !!thisR ow[thisFie ldMapping. field]) { | |
| 661 | // set crm fi eld with s tring repr esentation of date, YYYYMMDD | |
| 662 | ne wRecord[th isFieldMap ping.CRM] = zeroPadD atePartAsS tring(this Row[thisFi eldMapping .field].ge tFullYear( ).toString (), 4) + z eroPadDate PartAsStri ng((thisRo w[thisFiel dMapping.f ield].getM onth() + 1 ).toString (), 2) + z eroPadDate PartAsStri ng(thisRow [thisField Mapping.fi eld].getDa te().toStr ing(), 2) | |
| 663 | } | |
| 664 | } | |
| 665 | }); | |
| 666 | ||
| 667 | SDK. REST.creat eRecord( | |
| 668 | newRecord, | |
| 669 | "ftp_picke dmedicatio n", | |
| 670 | function ( createdRec ord) { | |
| 671 | saveSe lectedMedi cationsToC RM(index); | |
| 672 | }, | |
| 673 | function ( e) { | |
| 674 | consol e.error(e. message); | |
| 675 | saveSe lectedMedi cationsToC RM(index); | |
| 676 | } | |
| 677 | ); | |
| 678 | } | |
| 679 | else if (thisRow.S elected == false && thisRow.Pr eviouslySe lectedInCR M == true) { | |
| 680 | //de lete this row from C RM | |
| 681 | if ( thisRow.CR MId != nul l) { | |
| 682 | SDK.REST.d eleteRecor d( | |
| 683 | thisRo w.CRMId, | |
| 684 | "ftp_p ickedmedic ation", | |
| 685 | functi on () { | |
| 686 | sa veSelected Medication sToCRM(ind ex); | |
| 687 | }, | |
| 688 | functi on (e) { | |
| 689 | co nsole.erro r(e.messag e); | |
| 690 | sa veSelected Medication sToCRM(ind ex); | |
| 691 | } | |
| 692 | ); | |
| 693 | } | |
| 694 | else { | |
| 695 | //don't kn ow ID of C RM record we want to delete... | |
| 696 | //this sho uld never happen | |
| 697 | } | |
| 698 | } | |
| 699 | else if (thisRow.S elected == true && t hisRow.Pre viouslySel ectedInCRM == true & & thisRow. CRMId != n ull) { | |
| 700 | //ma ke sure co lumn data is up to d ate in CRM | |
| 701 | var updateObj = {}; | |
| 702 | fiel dMappings. forEach(fu nction (th isFieldMap ping, i) { | |
| 703 | if (!!this FieldMappi ng.CRM && thisFieldM apping.CRM != "ftp_p ickedmedic ationId" & & !!thisFi eldMapping .field && !!thisRow[ thisFieldM apping.fie ld]) { | |
| 704 | update Obj[thisFi eldMapping .CRM] = th isRow[this FieldMappi ng.field]; | |
| 705 | if (th isFieldMap ping.type == "date" && !!thisR ow[thisFie ldMapping. field]) { | |
| 706 | // set crm fi eld with s tring repr esentation of date, YYYYMMDD | |
| 707 | up dateObj[th isFieldMap ping.CRM] = zeroPadD atePartAsS tring(this Row[thisFi eldMapping .field].ge tFullYear( ).toString (), 4) + z eroPadDate PartAsStri ng((thisRo w[thisFiel dMapping.f ield].getM onth() + 1 ).toString (), 2) + z eroPadDate PartAsStri ng(thisRow [thisField Mapping.fi eld].getDa te().toStr ing(), 2) | |
| 708 | } | |
| 709 | } | |
| 710 | }); | |
| 711 | if ( thisRow.CR MId != nul l) { | |
| 712 | SDK.REST.u pdateRecor d( | |
| 713 | thisRo w.CRMId, | |
| 714 | update Obj, | |
| 715 | "ftp_p ickedmedic ation", | |
| 716 | functi on () { | |
| 717 | sa veSelected Medication sToCRM(ind ex); | |
| 718 | }, | |
| 719 | functi on (e) { | |
| 720 | co nsole.erro r(e.messag e); | |
| 721 | sa veSelected Medication sToCRM(ind ex); | |
| 722 | } | |
| 723 | ); | |
| 724 | } | |
| 725 | else { | |
| 726 | //don't kn ow ID of C RM record we want to update... (this shou ld never h appen) | |
| 727 | } | |
| 728 | } | |
| 729 | else { | |
| 730 | save SelectedMe dicationsT oCRM(index ); | |
| 731 | } | |
| 732 | } | |
| 733 | el se { | |
| 734 | doPageLo ad(); | |
| 735 | //loadPr eviouslySe lectedMedi cationsFro mCRM(confi gData.id); | |
| 736 | } | |
| 737 | } | |
| 738 | catch (err) { | |
| 739 | co nsole.erro r(err.mess age); | |
| 740 | al ert(err.me ssage); | |
| 741 | } | |
| 742 | } | |
| 743 | ||
| 744 | function a pplyHeader DateFilter () { | |
| 745 | var gr id = $("#m edicationG ridDiv").d ata("kendo Grid"); | |
| 746 | var he aderStartD atePicker = $("#head erStartDat e").data(" kendoDateP icker"); | |
| 747 | var he aderEndDat ePicker = $("#header EndDate"). data("kend oDatePicke r"); | |
| 748 | if (!! grid && !! headerStar tDatePicke r && !!hea derEndDate Picker) { | |
| 749 | va r newStart DateValue = headerSt artDatePic ker.value( ); | |
| 750 | ne wStartDate Value.setH ours(0, 0, 0, 0); | |
| 751 | co nsole.log( "newStartD ateValue: " + newSta rtDateValu e); | |
| 752 | va r newEndDa teValue = headerEndD atePicker. value(); | |
| 753 | ne wEndDateVa lue.setHou rs(0, 0, 0 , 0); | |
| 754 | co nsole.log( "newEndDat eValue: " + newEndDa teValue); | |
| 755 | ad dFilterToG rid({ | |
| 756 | logic: " and", | |
| 757 | filters: [ | |
| 758 | { fi eld: "Last Filled", o perator: " neq", valu e: null }, | |
| 759 | { fi eld: "Last Filled", o perator: " gte", valu e: newStar tDateValue }, | |
| 760 | { fi eld: "Last Filled", o perator: " lte", valu e: newEndD ateValue } | |
| 761 | ], | |
| 762 | id: "fil ter_LastFi lled_heade r" | |
| 763 | }) ; | |
| 764 | } | |
| 765 | } | |
| 766 | function a ddFilterTo Grid(pNewF ilterObjec t) { | |
| 767 | var gr id = $("#m edicationG ridDiv").d ata("kendo Grid"); | |
| 768 | if (!! grid) { | |
| 769 | va r currentF ilter = gr id.dataSou rce.filter (); | |
| 770 | if (!!curren tFilter) { | |
| 771 | var exis tingIndexO fThisFilte r = ArrayI ndexOfObje ctByAttrib ute(curren tFilter.fi lters, "id ", pNewFil terObject. id); | |
| 772 | if (exis tingIndexO fThisFilte r > -1) { | |
| 773 | //re move and r e-add | |
| 774 | remo veFilterFr omGrid(pNe wFilterObj ect.id); | |
| 775 | curr entFilter = $("#medi cationGrid Div").data ("kendoGri d").dataSo urce.filte r(); | |
| 776 | curr entFilter. filters.pu sh(pNewFil terObject) ; | |
| 777 | grid .dataSourc e.filter(c urrentFilt er); | |
| 778 | } | |
| 779 | else { | |
| 780 | curr entFilter. filters.pu sh(pNewFil terObject) ; | |
| 781 | grid .dataSourc e.filter(c urrentFilt er); | |
| 782 | } | |
| 783 | } | |
| 784 | el se { | |
| 785 | grid.dat aSource.fi lter({ | |
| 786 | logi c: "and", | |
| 787 | filt ers: [pNew FilterObje ct] | |
| 788 | }); | |
| 789 | } | |
| 790 | se tHelperTex t(); | |
| 791 | } | |
| 792 | } | |
| 793 | function r emoveFilte rFromGrid( pFilterId) { | |
| 794 | if (!! pFilterId) { | |
| 795 | va r grid = $ ("#medicat ionGridDiv ").data("k endoGrid") ; | |
| 796 | if (!!grid) { | |
| 797 | var curr entFilter = grid.dat aSource.fi lter(); | |
| 798 | if (!!cu rrentFilte r) { | |
| 799 | var filterInde x = ArrayI ndexOfObje ctByAttrib ute(curren tFilter.fi lters, "id ", pFilter Id); | |
| 800 | curr entFilter. filters.sp lice(filte rIndex, 1) ; | |
| 801 | grid .dataSourc e.filter(c urrentFilt er); | |
| 802 | if ( ArrayIndex OfObjectBy Attribute( currentFil ter.filter s, "id", p FilterId) > -1) { | |
| 803 | removeFilt erFromGrid (pFilterId ); | |
| 804 | } | |
| 805 | } | |
| 806 | } | |
| 807 | } | |
| 808 | } | |
| 809 | function s etHelperTe xt() { | |
| 810 | var he aderStartD atePicker = $("#head erStartDat e").data(" kendoDateP icker"); | |
| 811 | var he aderEndDat ePicker = $("#header EndDate"). data("kend oDatePicke r"); | |
| 812 | var st artDate = headerStar tDatePicke r.value(); | |
| 813 | var en dDate = he aderEndDat ePicker.va lue(); | |
| 814 | ||
| 815 | var la stXMonthsV alue = Mat h.round((e ndDate - s tartDate) / 1000 / 6 0 / 60 / 2 4 / 365 * 12); | |
| 816 | var mo nthsString = lastXMo nthsValue == 1 ? "mo nth" : "mo nths"; | |
| 817 | $("#la stXMonthsT ext").html ("(within the last " + lastXMo nthsValue. toString() + " " + m onthsStrin g + ")"); | |
| 818 | $(".k- grid-norec ords").fir st().text( "No medica tion recor ds found f rom last " + lastXMo nthsValue. toString() + " " + m onthsStrin g + ".") | |
| 819 | } | |
| 820 | ||
| 821 | function d estroyMedi cationGrid () { | |
| 822 | var me dicationGr idDiv = $( "#medicati onGridDiv" ); | |
| 823 | if (!! medication GridDiv && medicatio nGridDiv.l ength == 1 ) { | |
| 824 | if (!!medica tionGridDi v.data("ke ndoGrid")) { | |
| 825 | $("#medi cationGrid Div").data ("kendoGri d").destro y(); | |
| 826 | } | |
| 827 | $( "#medicati onGridDiv" ).empty(); | |
| 828 | $( "#medicati onGridDiv" ).remove() ; | |
| 829 | } | |
| 830 | kendo. destroy("# medication GridDivPar entDiv"); | |
| 831 | } | |
| 832 | ||
| 833 | /*helper f unctions*/ | |
| 834 | function z eroPadDate PartAsStri ng(pValue, pPlaces) { | |
| 835 | return pValue.to String().l ength < pP laces ? ze roPadDateP artAsStrin g("0" + pV alue, pPla ces) : pVa lue.toStri ng(); | |
| 836 | } | |
| 837 | function p arseDataPa rametersFr omUrl(pQue ryString) { | |
| 838 | //exam ple query string (un encoded): contactid= {32CA1B55- DC81-E611- 9445-00505 68D743D}&f ullname=TI FINKLE, AN DREW&sensi tivity=tru e&IsUSD=tr ue | |
| 839 | var fu llParamete rArray = p QueryStrin g.substr(1 ).split("& "); | |
| 840 | ||
| 841 | //clea n up the U RL query s tring and split each member in to a key/v alue pair | |
| 842 | for (v ar i in fu llParamete rArray) { | |
| 843 | fu llParamete rArray[i] = fullPara meterArray [i].replac e(/\+/g, " ").split( "="); | |
| 844 | } | |
| 845 | ||
| 846 | var fu llObject = {}; | |
| 847 | for (v ar i in fu llParamete rArray) { | |
| 848 | va r thisPara meterName = fullPara meterArray [i][0]; | |
| 849 | va r thisPara meterValue = fullPar ameterArra y[i][1]; | |
| 850 | fu llObject[t hisParamet erName] = thisParame terValue; | |
| 851 | if (thisPara meterName. toLowerCas e() == "da ta") { | |
| 852 | var data Object = { }; | |
| 853 | var cust omDataArra y = decode URICompone nt(thisPar ameterValu e).split(" &"); | |
| 854 | for (var j in cust omDataArra y) { | |
| 855 | cust omDataArra y[j] = cus tomDataArr ay[j].repl ace(/\+/g, " ").spli t("="); | |
| 856 | data Object[cus tomDataArr ay[j][0]] = customDa taArray[j] [1]; | |
| 857 | } | |
| 858 | fullObje ct[thisPar ameterName ] = dataOb ject; | |
| 859 | } | |
| 860 | } | |
| 861 | return fullObjec t; | |
| 862 | } | |
| 863 | function e rrorHandle r(err) { | |
| 864 | consol e.error(er r.message) ; | |
| 865 | alert( err.messag e); | |
| 866 | } | |
| 867 | function A rrayIndexO fObjectByA ttribute(p Array, pAt tr, pValue ) { | |
| 868 | for (v ar i = 0; i < pArray .length; i += 1) { | |
| 869 | if (pArray[i ][pAttr] = == pValue) { | |
| 870 | return i ; | |
| 871 | } | |
| 872 | } | |
| 873 | return -1; | |
| 874 | } | |
| 875 | function g etDeepProp erty(pPath , pObject) { | |
| 876 | if (!! pPath) { | |
| 877 | va r pathAsAr ray = pPat h.split(". "); | |
| 878 | va r returnOb j = !!pObj ect ? pObj ect : wind ow[pathAsA rray.shift ()]; | |
| 879 | if (typeof r eturnObj ! = "undefin ed") { | |
| 880 | while (! !returnObj && pathAs Array.leng th > 0) { | |
| 881 | var nextLevel = pathAsAr ray.shift( ); | |
| 882 | var isArrayQue ry = nextL evel.index Of("[") > -1 && next Level.inde xOf("]") = = nextLeve l.indexOf( "[") + 2; | |
| 883 | var nextLevelN ame = !isA rrayQuery ? nextLeve l : nextLe vel.split( "[")[0]; | |
| 884 | var nextLevelA rrayMember = !isArra yQuery ? n ull : pars eInt((next Level.spli t("[")[1]) .substr(0, (nextLeve l.split("[ ")[1].leng th))); | |
| 885 | ||
| 886 | retu rnObj = is ArrayQuery ? returnO bj[nextLev elName][ne xtLevelArr ayMember] : returnOb j[nextLeve lName]; | |
| 887 | ||
| 888 | } | |
| 889 | return r eturnObj; | |
| 890 | } | |
| 891 | el se { | |
| 892 | return u ndefined; | |
| 893 | } | |
| 894 | } | |
| 895 | else { | |
| 896 | re turn undef ined; | |
| 897 | } | |
| 898 | } | |
| 899 | function s howLoading Message(pM essage) { | |
| 900 | $("#pr ogressText ").html(pM essage); | |
| 901 | showDi v("#loadin gGifDiv"); | |
| 902 | } | |
| 903 | function s howErrorMe ssage(pMes sage) { | |
| 904 | $("#er rorText"). html(pMess age); | |
| 905 | showDi v("#errorC ontainer") ; | |
| 906 | } | |
| 907 | function s howDiv(pDi vToShow) { | |
| 908 | var kn ownDivs = [ | |
| 909 | "# loadingGif Div", | |
| 910 | "# errorConta iner", | |
| 911 | "# Medication PickerCont ainer", | |
| 912 | "# newRecordM essageCont ainer" | |
| 913 | ]; | |
| 914 | for (v ar d = 0; d < knownD ivs.length ; d++) { | |
| 915 | if (knownDiv s[d] == pD ivToShow) { | |
| 916 | $(knownD ivs[d]).sh ow(); | |
| 917 | } | |
| 918 | el se { | |
| 919 | $(knownD ivs[d]).hi de(); | |
| 920 | } | |
| 921 | } | |
| 922 | } | |
| 923 | function g etContext( ) { | |
| 924 | return (typeof G etGlobalCo ntext != " undefined" ) ? GetGlo balContext () : null; | |
| 925 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.