Produced by Araxis Merge on 12/4/2017 8:32:39 AM Central 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 | VCCM.zip\VCCM\CRM_solutions\VCCMResources\VCCMResources_1_0_0_9.zip\WebResources | ftp_VistAMultiNoteFormScriptVistACPRSMultiProgressD9489705-E7FC-E511-9433-0050568D743D | Tue Apr 25 02:17:22 2017 UTC |
| 2 | VCCM.zip\VCCM\CRM_solutions\VCCMResources\VCCMResources_1_0_0_9.zip\WebResources | ftp_VistAMultiNoteFormScriptVistACPRSMultiProgressD9489705-E7FC-E511-9433-0050568D743D | Thu Nov 30 17:21:26 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 5 | 5476 |
| Changed | 4 | 8 |
| 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 | //VistACPR SMultiProg ressNoteFo rmScript.j s | |
| 2 | //Contains variables and funct ions used by the CRM Form and Ribbon | |
| 3 | //Requires jQuery lo aded on th e CRM Form | |
| 4 | //The form where thi s script l ibrary is applied mu st have th e followin g form par ameters de fined | |
| 5 | /* | |
| 6 | parameter_ regardingo bjectid - Type:Uni queId | |
| 7 | parameter_ regardingo bjectidnam e - Type :SafeStrin g | |
| 8 | parameter_ regardingo bjectidtyp e - Type :SafeStrin g | |
| 9 | parameter_ triageexpe rt - Typ e:SafeStri ng | |
| 10 | parameter_ triageminu tes - Ty pe:Integer | |
| 11 | */ | |
| 12 | ||
| 13 | //Static V ariables | |
| 14 | var vcmn_c rmOdataEnd Point = '/ XRMService s/2011/Org anizationD ata.svc'; | |
| 15 | var vcmn_s erverUrl = Xrm.Page. context.ge tClientUrl (); | |
| 16 | ||
| 17 | //var vcmn _NoteWrite Url = 'htt ps://qacrm dac.np.crm .vrm.vba. DNS /WebParts/ DEV/api/no teswrite'; //OLD MANU AL DEV URL | |
| 18 | var vcmn_N oteWriteUr l = ''; | |
| 19 | //var vcmn _eesummary URLbase = 'https://q acrmdac.np .crm.vrm.v ba. DNS /WebParts/ QA/api/ees ummary/1.0 /xml/ftpCR M/'; //OLD MANU AL DEV URL | |
| 20 | var vcmn_e esummaryUR Lbase = '' ; | |
| 21 | //var vcmn _VistaUser sURLbase = 'https:// qacrmdac.n p.crm.vrm. vba. DNS /WebParts/ DEV/api/Vi staUsers/1 .0/json/ft pCRM/john/ smith/1234 ?noFilter= true'; //OLD MANU AL DEV URL | |
| 22 | var vcmn_V istaUsersU RLbase = ' '; | |
| 23 | //var vcmn _AddSigner sUrl = 'ht tps://qacr mdac.np.cr m.vrm.vba. DNS /WebParts/ DEV/api/VI A/AddSigne rs/1.0/jso n'; //OLD MANU AL DEV URL | |
| 24 | var vcmn_A ddSignersU rl = ''; | |
| 25 | ||
| 26 | //Producti on Environ ment Indic ator | |
| 27 | var vcmn_I sProductio nEnvironme nt = false ; | |
| 28 | ||
| 29 | //Word Wra p Line Lim it | |
| 30 | var vcmn_W ordWrapLim it = 75; | |
| 31 | ||
| 32 | //Addition al Signers Data | |
| 33 | var vcmn_A ddlSigners NameArray = null; | |
| 34 | var vcmn_A ddlSigners IenArray = null; | |
| 35 | var vcmn_l ocalStorag eVarName = ""; | |
| 36 | ||
| 37 | //Workload Encounter data | |
| 38 | var vcmn_P rogressNot eSubject = 'Progress Note: '; | |
| 39 | var vcmn_T riageNoteS ubject = ' Triage Not e: '; | |
| 40 | var vcmn_W orkloadEnc ounterSubj ect = 'Wor kload Enco unter Note : '; | |
| 41 | var vcmn_i sWorkloadE ncounter = false; | |
| 42 | var vcmn_m atchLookup Id = ''; | |
| 43 | ||
| 44 | var vcmn_V iaLoginNam e = null; | |
| 45 | var vcmn_V iaLoginTok en = null; | |
| 46 | var vcmn_V iaLoginFac ility = nu ll; | |
| 47 | var vcmn_V iaPatientI d = null; | |
| 48 | var vcmn_V iaInPatien t = null; | |
| 49 | var vcmn_V iaCptCode = null; | |
| 50 | var vcmn_V iaCptDescr iption = n ull; | |
| 51 | ||
| 52 | var vcmn_b aseService EndpointUr l = null; | |
| 53 | var vcmn_r equestingA pp = null; | |
| 54 | var vcmn_c onsumingAp pToken = n ull; | |
| 55 | var vcmn_c onsumingAp pPassword = null; | |
| 56 | ||
| 57 | function v cmn_getQue ryVariable (vcmn_vari able) { | |
| 58 | try { | |
| 59 | // Get a Quer y Variable | |
| 60 | va r vcmn_que ry = windo w.location .search.su bstring(1) ; | |
| 61 | va r vcmn_var s = vcmn_q uery.split ("&"); | |
| 62 | fo r (var i = 0; i < vc mn_vars.le ngth; i++) { | |
| 63 | var vcmn _pair = vc mn_vars[i] .split("=" ); | |
| 64 | if (vcmn _pair[0] = = vcmn_var iable) { | |
| 65 | retu rn decodeU RIComponen t(vcmn_pai r[1]); | |
| 66 | } | |
| 67 | } | |
| 68 | re turn ""; | |
| 69 | } | |
| 70 | catch (err) { | |
| 71 | al ert('Progr ess Note F orm Load S cript Func tion Error (vcmn_getQ ueryVariab le): ' + e rr.message ); | |
| 72 | } | |
| 73 | } | |
| 74 | ||
| 75 | function v cmn_setSim pleLookupV alue(vcmn_ LookupId, vcmn_Type, vcmn_Id, vcmn_Name) { | |
| 76 | try { | |
| 77 | // Sets the v alue for l ookup attr ibutes tha t accept o nly a sing le entity reference. | |
| 78 | va r vcmn_loo kupReferen ce = []; | |
| 79 | vc mn_lookupR eference[0 ] = {}; | |
| 80 | vc mn_lookupR eference[0 ].id = vcm n_Id; | |
| 81 | vc mn_lookupR eference[0 ].entityTy pe = vcmn_ Type; | |
| 82 | vc mn_lookupR eference[0 ].name = v cmn_Name; | |
| 83 | Xr m.Page.get Attribute( vcmn_Looku pId).setVa lue(vcmn_l ookupRefer ence); | |
| 84 | } | |
| 85 | catch (err) { | |
| 86 | al ert('Progr ess Note F orm Load S cript Func tion Error (vcmn_setS impleLooku pValue): ' + err.mes sage); | |
| 87 | } | |
| 88 | } | |
| 89 | ||
| 90 | function v cmn_conver tCrmDateTo VistADate( vcmn_crmDa te) { | |
| 91 | try { | |
| 92 | va r vcmn_Vis tADate = n ull; | |
| 93 | if (vcmn_crm Date != nu ll) { | |
| 94 | var vcmn _crmYear = (vcmn_crm Date.getFu llYear()). toString() ; | |
| 95 | var vcmn _crmMonth = '00'; | |
| 96 | if ((vcm n_crmDate. getMonth() + 1) < 10 ) { | |
| 97 | vcmn _crmMonth = '0' + (v cmn_crmDat e.getMonth () + 1).to String(); | |
| 98 | } | |
| 99 | else { | |
| 100 | vcmn _crmMonth = (vcmn_cr mDate.getM onth() + 1 ).toString (); | |
| 101 | } | |
| 102 | var vcmn _crmDay = '00'; | |
| 103 | if ((vcm n_crmDate. getDate()) < 10) { | |
| 104 | vcmn _crmDay = '0' + (vcm n_crmDate. getDate()) .toString( ); | |
| 105 | } | |
| 106 | else { | |
| 107 | vcmn _crmDay = (vcmn_crmD ate.getDat e()).toStr ing(); | |
| 108 | } | |
| 109 | var vcmn _crmHours = '00'; | |
| 110 | if ((vcm n_crmDate. getHours() ) < 10) { | |
| 111 | vcmn _crmHours = '0' + (v cmn_crmDat e.getHours ()).toStri ng(); | |
| 112 | } | |
| 113 | else { | |
| 114 | vcmn _crmHours = (vcmn_cr mDate.getH ours()).to String(); | |
| 115 | } | |
| 116 | var vcmn _crmMinute s = '00'; | |
| 117 | if ((vcm n_crmDate. getMinutes ()) < 10) { | |
| 118 | vcmn _crmMinute s = '0' + (vcmn_crmD ate.getMin utes()).to String(); | |
| 119 | } | |
| 120 | else { | |
| 121 | vcmn _crmMinute s = (vcmn_ crmDate.ge tMinutes() ).toString (); | |
| 122 | } | |
| 123 | var vcmn _crmSecond s = '00'; | |
| 124 | if ((vcm n_crmDate. getSeconds ()) < 10) { | |
| 125 | vcmn _crmSecond s = '0' + (vcmn_crmD ate.getSec onds()).to String(); | |
| 126 | } | |
| 127 | else { | |
| 128 | vcmn _crmSecond s = (vcmn_ crmDate.ge tSeconds() ).toString (); | |
| 129 | } | |
| 130 | ||
| 131 | //Create VistA Dat e | |
| 132 | vcmn_Vis tADate = v cmn_crmYea r + vcmn_c rmMonth + vcmn_crmDa y + vcmn_c rmHours + vcmn_crmMi nutes + vc mn_crmSeco nds; | |
| 133 | } | |
| 134 | re turn vcmn_ VistADate; | |
| 135 | } | |
| 136 | catch (err) { | |
| 137 | al ert('Progr ess Note E rror(vcmn_ convertCrm DateToVist ADate): ' + err.mess age); | |
| 138 | re turn null; | |
| 139 | } | |
| 140 | } | |
| 141 | ||
| 142 | function v cmn_decryp tServiceCo nnector(vc mn_connect orArray, v cmn_connec torValue) { | |
| 143 | var vc mn_decrypt edString = ""; | |
| 144 | if (vc mn_connect orArray != null && v cmn_connec torArray ! = "") { | |
| 145 | va r vcmn_new Array = vc mn_connect orArray.to String().s plit(','); | |
| 146 | vc mn_newArra y.reverse( ); | |
| 147 | fo r (i = 0; i < vcmn_n ewArray.le ngth; i++) { | |
| 148 | var vcmn _curChar = ""; | |
| 149 | if (i == 0) { | |
| 150 | vcmn _curChar = vcmn_newA rray[i] - vcmn_conne ctorValue; | |
| 151 | } | |
| 152 | else { | |
| 153 | vcmn _curChar = vcmn_newA rray[i] - (i + vcmn_ connectorV alue); | |
| 154 | } | |
| 155 | vcmn_dec ryptedStri ng = vcmn_ decryptedS tring + St ring.fromC harCode(vc mn_curChar ); | |
| 156 | } | |
| 157 | } | |
| 158 | return vcmn_decr yptedStrin g; | |
| 159 | } | |
| 160 | ||
| 161 | function v cmn_UserHa sTeam(team Name, user Guid) { | |
| 162 | try { | |
| 163 | va r vcmn_tea mid = null ; | |
| 164 | va r vcmn_cur rentUserId = userGui d; | |
| 165 | va r vcmn_con ditionalFi lter = "(N ame eq '" + teamName + "')"; | |
| 166 | va r vcmn_tea mData = vc mn_getMult ipleEntity DataSync(' TeamSet', 'TeamId', vcmn_condi tionalFilt er, 'Name' , 'asc', 0 ); | |
| 167 | if (vcmn_tea mData != n ull) { | |
| 168 | for (var i = 0; i <= vcmn_te amData.d.r esults.len gth - 1; i ++) { | |
| 169 | //Ge t Info | |
| 170 | if ( vcmn_teamD ata.d.resu lts[i].Tea mId != nul l) { vcmn_ teamid = v cmn_teamDa ta.d.resul ts[i].Team Id; } | |
| 171 | brea k; | |
| 172 | } | |
| 173 | } | |
| 174 | // If Team ex ists, chec k if the c urrent use r is part of that te am | |
| 175 | va r vcmn_tea mMembershi pId = null ; | |
| 176 | if (vcmn_tea mid != nul l && vcmn_ currentUse rId != nul l) { | |
| 177 | var vcmn _condition alFilter = "(TeamId eq (guid'" + vcmn_te amid + "') and Syste mUserId eq (guid'" + vcmn_curr entUserId + "'))"; | |
| 178 | var vcmn _teamMembe rshipData = vcmn_get MultipleEn tityDataSy nc('TeamMe mbershipSe t', 'TeamI d, SystemU serId,Team Membership Id', vcmn_ conditiona lFilter, ' TeamId', ' asc', 0); | |
| 179 | if (vcmn _teamMembe rshipData != null) { | |
| 180 | for (var i = 0 ; i <= vcm n_teamMemb ershipData .d.results .length - 1; i++) { | |
| 181 | //Get Info | |
| 182 | if (vcmn_t eamMembers hipData.d. results[i] .TeamMembe rshipId != null) { v cmn_teamMe mbershipId = vcmn_te amMembersh ipData.d.r esults[i]. TeamMember shipId; } | |
| 183 | break; | |
| 184 | } | |
| 185 | } | |
| 186 | } | |
| 187 | if (vcmn_tea mMembershi pId != nul l) { retur n true; } | |
| 188 | ||
| 189 | // otherwise return fal se | |
| 190 | re turn false ; | |
| 191 | } | |
| 192 | catch (err) { | |
| 193 | // Display Er ror | |
| 194 | al ert("An er ror occure d in the v cmn_UserHa sTeam func tion. Err or Detail Message: " + err); | |
| 195 | } | |
| 196 | } | |
| 197 | ||
| 198 | function v cmn_Settin gsWebServi ceURL_resp onse(vcmn_ settingDat a, vcmn_la stSkip, vc mn_NoteWri teUrl_NA) { | |
| 199 | try { | |
| 200 | // vcmn_lastS kip is the starting point in t he result (use if mo re than 50 records) //Not used in this s cenario | |
| 201 | va r vcmn_Dac Url = null ; | |
| 202 | va r vcmn_Not esWriteApi Url = null ; | |
| 203 | va r vcmn_ees ummaryApiU rl = null; | |
| 204 | va r vcmn_Vis taUserApiU rl = null; | |
| 205 | va r vcmn_Via AddlSigner sApiUrl = null; | |
| 206 | ||
| 207 | fo r (var i = 0; i <= v cmn_settin gData.d.re sults.leng th - 1; i+ +) { | |
| 208 | //Get in fo | |
| 209 | if (vcmn _settingDa ta.d.resul ts[i].ftp_ DACURL != null) { vc mn_DacUrl = vcmn_set tingData.d .results[i ].ftp_DACU RL; } | |
| 210 | if (vcmn _settingDa ta.d.resul ts[i].ftp_ NotesWrite APIURL != null) { vc mn_NotesWr iteApiUrl = vcmn_set tingData.d .results[i ].ftp_Note sWriteAPIU RL; } | |
| 211 | if (vcmn _settingDa ta.d.resul ts[i].ftp_ ESRAPIURL != null) { vcmn_eesu mmaryApiUr l = vcmn_s ettingData .d.results [i].ftp_ES RAPIURL; } | |
| 212 | if (vcmn _settingDa ta.d.resul ts[i].ftp_ VistaUsers APIURL != null) { vc mn_VistaUs erApiUrl = vcmn_sett ingData.d. results[i] .ftp_Vista UsersAPIUR L; } | |
| 213 | if (vcmn _settingDa ta.d.resul ts[i].ftp_ IsProducti onEnvironm ent != nul l) { vcmn_ IsProducti onEnvironm ent = vcmn _settingDa ta.d.resul ts[i].ftp_ IsProducti onEnvironm ent; } | |
| 214 | if (vcmn _settingDa ta.d.resul ts[i].ftp_ VIAAdditio nalSigners URL != nul l) { vcmn_ ViaAddlSig nersApiUrl = vcmn_se ttingData. d.results[ i].ftp_VIA Additional SignersURL ; } | |
| 215 | if (vcmn _settingDa ta.d.resul ts[i].ftp_ VIAService BaseURL != null) { v cmn_baseSe rviceEndpo intUrl = v cmn_settin gData.d.re sults[i].f tp_VIAServ iceBaseURL ; } | |
| 216 | if (vcmn _settingDa ta.d.resul ts[i].ftp_ VIARequest ingApplica tionCode ! = null) { vcmn_reque stingApp = vcmn_sett ingData.d. results[i] .ftp_VIARe questingAp plicationC ode; } | |
| 217 | if (vcmn _settingDa ta.d.resul ts[i].ftp_ VIAConsumi ngApplicat ionToken ! = null) { vcmn_consu mingAppTok en = vcmn_ settingDat a.d.result s[i].ftp_V IAConsumin gApplicati onToken; } | |
| 218 | if (vcmn _settingDa ta.d.resul ts[i].ftp_ VIAConsumi ngApplicat ionPasswor d != null) { vcmn_co nsumingApp Password = vcmn_sett ingData.d. results[i] .ftp_VIACo nsumingApp licationPa ssword; } | |
| 219 | break; | |
| 220 | } | |
| 221 | ||
| 222 | if (vcmn_Dac Url != nul l && vcmn_ NotesWrite ApiUrl != null) { | |
| 223 | //Constr uct full w eb service URL | |
| 224 | vcmn_Not eWriteUrl = vcmn_Dac Url + vcmn _NotesWrit eApiUrl; | |
| 225 | } | |
| 226 | el se { | |
| 227 | Xrm.Page .ui.setFor mNotificat ion("ERROR : THE VIST A NOTES WR ITE SERVIC E URL IS M ISSING, PL EASE CONTA CT TECHNIC AL SUPPORT !", "ERROR ", "VISTAS ERVICE"); | |
| 228 | } | |
| 229 | if (vcmn_Dac Url != nul l && vcmn_ eesummaryA piUrl != n ull) { | |
| 230 | //Constr uct full w eb service URL | |
| 231 | vcmn_ees ummaryURLb ase = vcmn _DacUrl + vcmn_eesum maryApiUrl ; | |
| 232 | } | |
| 233 | el se { | |
| 234 | Xrm.Page .ui.setFor mNotificat ion("ERROR : THE EESU MMARY SERV ICE URL IS MISSING, PLEASE CON TACT TECHN ICAL SUPPO RT!", "ERR OR", "VIST ASERVICE") ; | |
| 235 | } | |
| 236 | if (vcmn_Dac Url != nul l && vcmn_ VistaUserA piUrl != n ull) { | |
| 237 | //Constr uct full w eb service URL | |
| 238 | vcmn_Vis taUsersURL base = vcm n_DacUrl + vcmn_Vist aUserApiUr l; | |
| 239 | } | |
| 240 | el se { | |
| 241 | Xrm.Page .ui.setFor mNotificat ion("ERROR : THE VIST A USERS SE RVICE URL IS MISSING , PLEASE C ONTACT TEC HNICAL SUP PORT!", "E RROR", "VI STASERVICE "); | |
| 242 | } | |
| 243 | if (vcmn_Dac Url != nul l && vcmn_ ViaAddlSig nersApiUrl != null) { | |
| 244 | //Constr uct full w eb service URL | |
| 245 | vcmn_Add SignersUrl = vcmn_Da cUrl + vcm n_ViaAddlS ignersApiU rl; | |
| 246 | } | |
| 247 | el se { | |
| 248 | Xrm.Page .ui.setFor mNotificat ion("ERROR : THE VIA ADDITIONAL SIGNERS S ERVICE URL IS MISSIN G, PLEASE CONTACT TE CHNICAL SU PPORT!", " ERROR", "V ISTASERVIC E"); | |
| 249 | } | |
| 250 | ||
| 251 | if (vcmn_bas eServiceEn dpointUrl == null || vcmn_requ estingApp == null || vcmn_cons umingAppTo ken == nul l || vcmn_ consumingA ppPassword == null) { | |
| 252 | Xrm.Page .ui.setFor mNotificat ion("ERROR : THE 'VIA Service C onnector' CONFIGURAT ION IS MIS SING DATA IN THE 'Se ttings Ent ity', PLEA SE CONTACT TECHNICAL SUPPORT!" , "ERROR", "VISTASER VICE"); | |
| 253 | } | |
| 254 | // Decrypt VI A Service Connector Items | |
| 255 | vc mn_request ingApp = v cmn_decryp tServiceCo nnector(vc mn_request ingApp, 4) ; | |
| 256 | vc mn_consumi ngAppToken = vcmn_de cryptServi ceConnecto r(vcmn_con sumingAppT oken, 6); | |
| 257 | vc mn_consumi ngAppPassw ord = vcmn _decryptSe rviceConne ctor(vcmn_ consumingA ppPassword , 8); | |
| 258 | ||
| 259 | // Proceed wi th Form Lo ad logic w ith URL | |
| 260 | vc mn_newProg ressNoteLo ad_WebURL( ); | |
| 261 | } | |
| 262 | catch (err) { | |
| 263 | al ert('Progr ess Note F orm Load S cript Func tion Error (vcmn_Sett ingsWebSer viceURL_re sponse): ' + err.mes sage); | |
| 264 | } | |
| 265 | } | |
| 266 | ||
| 267 | function v cmn_newPro gressNoteL oad() { | |
| 268 | try { | |
| 269 | // GET CRM SE TTINGS WEB SERVICE U RLS | |
| 270 | va r vcmn_con ditionalFi lter = "(m cs_name eq 'Active S ettings')" ; | |
| 271 | vc mn_getMult ipleEntity DataAsync( 'mcs_setti ngSet', 'f tp_DACURL, ftp_Notes WriteAPIUR L, ftp_ESR APIURL, ft p_VistaUse rsAPIURL, ftp_IsProd uctionEnvi ronment, f tp_VIAAddi tionalSign ersURL, ft p_VIAServi ceBaseURL, ftp_VIARe questingAp plicationC ode, ftp_V IAConsumin gApplicati onToken, f tp_VIACons umingAppli cationPass word', vcm n_conditio nalFilter, 'mcs_name ', 'asc', 0, vcmn_Se ttingsWebS erviceURL_ response, vcmn_NoteW riteUrl); | |
| 272 | } | |
| 273 | catch (err) { | |
| 274 | // Display Er ror | |
| 275 | al ert('Progr ess Note F orm Load S cript Func tion Error (vcmn_newP rogressNot eLoad): ' + err.mess age); | |
| 276 | } | |
| 277 | } | |
| 278 | ||
| 279 | function v cmn_newPro gressNoteL oad_WebURL () { | |
| 280 | try { | |
| 281 | // Check if m arked as a workload encounter | |
| 282 | if (Xrm.Page .getAttrib ute('ftp_i sworkloade ncounter') .getValue( ) == true) { | |
| 283 | vcmn_isW orkloadEnc ounter = t rue; | |
| 284 | Xrm.Page .ui.tabs.g et('Tab_Wo rkloadEnco unter').se tVisible(t rue); | |
| 285 | Xrm.Page .getAttrib ute("ftp_s electedwor kloadnotet itletext") .setRequir edLevel("r equired"); | |
| 286 | Xrm.Page .getAttrib ute("ftp_s electedwor kloadlocat iontext"). setRequire dLevel("re quired"); | |
| 287 | Xrm.Page .getAttrib ute("ftp_w orkloadinp atient").s etRequired Level("req uired"); | |
| 288 | //Set Si gn this no te to Yes | |
| 289 | Xrm.Page .getAttrib ute('ftp_s ignthisnot e').setVal ue(1000000 01); | |
| 290 | Xrm.Page .getAttrib ute('ftp_s ignthisnot e').setSub mitMode('a lways'); | |
| 291 | } | |
| 292 | el se { | |
| 293 | vcmn_isW orkloadEnc ounter = f alse; | |
| 294 | Xrm.Page .ui.tabs.g et('Tab_Wo rkloadEnco unter').se tVisible(f alse); | |
| 295 | Xrm.Page .getAttrib ute("ftp_s electedwor kloadnotet itletext") .setRequir edLevel("n one"); | |
| 296 | Xrm.Page .getAttrib ute("ftp_s electedwor kloadlocat iontext"). setRequire dLevel("no ne"); | |
| 297 | Xrm.Page .getAttrib ute("ftp_w orkloadinp atient").s etRequired Level("non e"); | |
| 298 | } | |
| 299 | ||
| 300 | // Only handl e forms in create st ate | |
| 301 | if (Xrm.Page .ui.getFor mType() != 1) { retu rn false; } | |
| 302 | ||
| 303 | // Set defaul t values b ased on th e current user's USD Config an d Facility | |
| 304 | va r vcmn_cur rentUserId = Xrm.Pag e.context. getUserId( ); | |
| 305 | va r vcmn_cur rentUserDa ta = vcmn_ getSingleE ntityDataS ync('Syste mUserSet', 'msdyusd_ USDConfigu rationId, ftp_Facili tySiteId', vcmn_curr entUserId) ; | |
| 306 | if (vcmn_cur rentUserDa ta != null ) { | |
| 307 | if (vcmn _currentUs erData.d.m sdyusd_USD Configurat ionId != n ull) { | |
| 308 | if ( vcmn_curre ntUserData .d.msdyusd _USDConfig urationId. Id != null ) { | |
| 309 | if (vcmn_c urrentUser Data.d.ftp _FacilityS iteId != n ull) { | |
| 310 | if (vc mn_current UserData.d .ftp_Facil itySiteId. Id != null ) { | |
| 311 | // Data Requi red to loo kup Facili ty Group D efaults ar e present | |
| 312 | va r vcmn_con ditionalFi lter = "(f tp_facilit ysiteid/Id eq guid'" + vcmn_cu rrentUserD ata.d.ftp_ FacilitySi teId.Id + "') and (f tp_usdgrou pid/Id eq guid'" + v cmn_curren tUserData. d.msdyusd_ USDConfigu rationId.I d + "')"; | |
| 313 | vc mn_getMult ipleEntity DataAsync( 'ftp_facil itygroupde faultSet', 'ftp_loca lnotestitl e, ftp_hos pitallocat ion', vcmn _condition alFilter, 'ftp_name' , 'asc', 0 , vcmn_fac ilityGroup Default_re sponse, vc mn_current UserData.d .ftp_Facil itySiteId. Id); | |
| 314 | } | |
| 315 | } | |
| 316 | } | |
| 317 | } | |
| 318 | } | |
| 319 | ||
| 320 | // Determine if regardi ng field i s prefille d (added b y subgrid+ ) | |
| 321 | va r vcmn_req uestId = X rm.Page.ge tAttribute ('regardin gobjectid' ).getValue (); | |
| 322 | va r vcmn_tri ageexpert = null; | |
| 323 | va r vcmn_tri ageminutes = null; | |
| 324 | if (vcmn_req uestId == null) { | |
| 325 | //Get cu stom param eters pass ed to the form | |
| 326 | var vcmn _regarding objectid = vcmn_getQ ueryVariab le("parame ter_regard ingobjecti d"); | |
| 327 | var vcmn _regarding objectidna me = vcmn_ getQueryVa riable("pa rameter_re gardingobj ectidname" ); | |
| 328 | var vcmn _regarding objectidty pe = vcmn_ getQueryVa riable("pa rameter_re gardingobj ectidtype" ); | |
| 329 | vcmn_tri ageexpert = vcmn_get QueryVaria ble("param eter_triag eexpert"); | |
| 330 | vcmn_tri ageminutes = vcmn_ge tQueryVari able("para meter_tria geminutes" ); | |
| 331 | ||
| 332 | if (vcmn _regarding objectid = = '' || vc mn_regardi ngobjectid == null | | vcmn_reg ardingobje ctidname = = '' || vc mn_regardi ngobjectid name == nu ll || | |
| 333 | vcmn _regarding objectidty pe == '' | | vcmn_reg ardingobje ctidtype = = null) { return fal se; } | |
| 334 | } | |
| 335 | el se { | |
| 336 | var vcmn _regarding objectid = vcmn_requ estId[0].i d; | |
| 337 | var vcmn _regarding objectidna me = vcmn_ requestId[ 0].name; | |
| 338 | var vcmn _regarding objectidty pe = vcmn_ requestId[ 0].entityT ype; | |
| 339 | } | |
| 340 | if (vcmn_tri ageexpert == null) { vcmn_tria geexpert = 'NO'; } | |
| 341 | if (vcmn_tri ageminutes == null) { vcmn_tri ageminutes = 0; } | |
| 342 | ||
| 343 | // Populate r egarding o bject | |
| 344 | vc mn_setSimp leLookupVa lue('regar dingobject id', vcmn_ regardingo bjectidtyp e, vcmn_re gardingobj ectid, vcm n_regardin gobjectidn ame); | |
| 345 | Xr m.Page.get Attribute( 'regarding objectid') .setSubmit Mode('alwa ys'); | |
| 346 | ||
| 347 | // Prompt use r if progr ess note i s a worklo ad encount er | |
| 348 | Xr m.Utility. confirmDia log( | |
| 349 | "Is this note a Wo rkload Enc ounter?, S elect OK i f Yes, oth erwise CAN CEL.", | |
| 350 | function () { | |
| 351 | Xrm. Page.getAt tribute('f tp_isworkl oadencount er').setVa lue(true); | |
| 352 | Xrm. Page.getAt tribute('f tp_isworkl oadencount er').setSu bmitMode(' always'); | |
| 353 | //Di splay work load encou nter tab a nd other i nfo accord ingly... | |
| 354 | Xrm. Page.ui.ta bs.get('Ta b_Workload Encounter' ).setVisib le(true); | |
| 355 | vcmn _isWorkloa dEncounter = true; | |
| 356 | Xrm. Page.getAt tribute("f tp_selecte dworkloadn otetitlete xt").setRe quiredLeve l("require d"); | |
| 357 | Xrm. Page.getAt tribute("f tp_selecte dworkloadl ocationtex t").setReq uiredLevel ("required "); | |
| 358 | Xrm. Page.getAt tribute("f tp_workloa dinpatient ").setRequ iredLevel( "required" ); | |
| 359 | } | |
| 360 | ); | |
| 361 | ||
| 362 | // Populate s ubject wit h regardin g objects title | |
| 363 | Xr m.Page.get Attribute( 'subject') .setValue( vcmn_Progr essNoteSub ject + vcm n_regardin gobjectidn ame); | |
| 364 | if (vcmn_tri ageexpert == 'YES') { Xrm.Page .getAttrib ute('subje ct').setVa lue(vcmn_T riageNoteS ubject + v cmn_regard ingobjecti dname); } | |
| 365 | if (Xrm.Page .getAttrib ute('ftp_i sworkloade ncounter') .getValue( ) == true) { Xrm.Pag e.getAttri bute('subj ect').setV alue(vcmn_ WorkloadEn counterSub ject + vcm n_regardin gobjectidn ame); } | |
| 366 | Xr m.Page.get Attribute( 'subject') .setSubmit Mode('alwa ys'); | |
| 367 | // Default Sa ve to CPPR S | |
| 368 | Xr m.Page.get Attribute( 'ftp_savet ovista').s etValue(10 0000001); //Yes | |
| 369 | Xr m.Page.get Attribute( 'ftp_savet ovista').s etSubmitMo de('always '); | |
| 370 | ||
| 371 | va r vcmn_vet eranId = n ull; //Fr om request customeri d | |
| 372 | ||
| 373 | // Populate f orm with r elated CRM data | |
| 374 | va r vcmn_sub ReasonId = null; //R eference t o the Reas on for Req uest Sub R eason | |
| 375 | va r vcmn_min orReasonId = null; //Referenc e to the R eason for Request Mi nor Reason | |
| 376 | va r vcmn_sub ReasonTemp lateText = null; | |
| 377 | va r vcmn_min orReasonTe mplateText = null; | |
| 378 | va r vcmn_min orReasonNo teSubText = null; | |
| 379 | ||
| 380 | va r vcmn_req uestData = vcmn_getS ingleEntit yDataSync( 'IncidentS et', 'ftp_ CallbackNu mber, ftp_ ReasonforR equest, ft p_SubReaso nId, ftp_M inorReason Id, Descri ption, Cus tomerId, f tp_LastFil led, ftp_Q uantityRep ortsTaking , ftp_RxNu mber, ftp_ RxRefillQu antity, ft p_Tracking Number, ft p_OpiodAgr eementOnfi le, ftp_UD Sonfile, f tp_StateDr ugMonitori ngReport, ftp_spdmps tateonfile , ftp_SPDM PState2, f tp_pickupm ethod, ftp _earlyrefi llcomment, ftp_quant itytaking, ftp_vacat ionstart, ftp_vacati onend', vc mn_regardi ngobjectid ); | |
| 381 | if (vcmn_req uestData ! = null) { | |
| 382 | if (vcmn _requestDa ta.d.ftp_C allbackNum ber != nul l) { | |
| 383 | Xrm. Page.getAt tribute('f tp_callbac knumber'). setValue(v cmn_reques tData.d.ft p_Callback Number); | |
| 384 | Xrm. Page.getAt tribute('f tp_callbac knumber'). setSubmitM ode('alway s'); | |
| 385 | } | |
| 386 | if (vcmn _requestDa ta.d.ftp_R easonforRe quest != n ull) { | |
| 387 | vcmn _setSimple LookupValu e('ftp_rea sonforrequ est', vcmn _requestDa ta.d.ftp_R easonforRe quest.Logi calName, v cmn_reques tData.d.ft p_Reasonfo rRequest.I d, vcmn_re questData. d.ftp_Reas onforReque st.Name); | |
| 388 | Xrm. Page.getAt tribute('f tp_reasonf orrequest' ).setSubmi tMode('alw ays'); | |
| 389 | } | |
| 390 | ||
| 391 | if(vcm n_requestD ata.d.ftp_ ReasonforR equest.Nam e == "Phar macy Outbo und Call") { | |
| 392 | if(typeo f outbound Template_b uildNoteTe xt == "fun ction"){ | |
| 393 | outboundTe mplate_bui ldNoteText (); | |
| 394 | } | |
| 395 | } | |
| 396 | else{ | |
| 397 | if (vcmn _requestDa ta.d.ftp_S ubReasonId != null) { | |
| 398 | vcmn_subRe asonId = v cmn_reques tData.d.ft p_SubReaso nId.Id; | |
| 399 | if (vcmn_s ubReasonId != null) { | |
| 400 | // Get Templa te Text | |
| 401 | va r vcmn_sub reasonData = vcmn_ge tSingleEnt ityDataSyn c('ftp_sub reasonSet' , 'ftp_not etext', vc mn_subReas onId); | |
| 402 | if (vcmn_sub reasonData .d.ftp_not etext != n ull) { | |
| 403 | vcmn _subReason TemplateTe xt = vcmn_ subreasonD ata.d.ftp_ notetext; | |
| 404 | } | |
| 405 | } | |
| 406 | } | |
| 407 | if (vcmn _requestDa ta.d.ftp_M inorReason Id != null ) { | |
| 408 | vcmn_minor ReasonId = vcmn_requ estData.d. ftp_MinorR easonId.Id ; | |
| 409 | if (vcmn_m inorReason Id != null ) { | |
| 410 | // Get Templa te Text | |
| 411 | va r vcmn_min orreasonDa ta = vcmn_ getSingleE ntityDataS ync('ftp_m inorreason Set', 'ftp _name, ftp _notetext' , vcmn_min orReasonId ); | |
| 412 | if (vcmn_min orreasonDa ta.d.ftp_n ame != nul l) { | |
| 413 | vcmn _minorReas onTemplate Text = vcm n_minorrea sonData.d. ftp_name; | |
| 414 | } | |
| 415 | if (vcmn_min orreasonDa ta.d.ftp_n otetext != null) { | |
| 416 | vcmn _minorReas onNoteSubT ext = vcmn _minorreas onData.d.f tp_notetex t; | |
| 417 | } | |
| 418 | } | |
| 419 | } | |
| 420 | ||
| 421 | if (vcmn _requestDa ta.d.Custo merId != n ull) { | |
| 422 | vcmn_setSi mpleLookup Value('ftp _patient', vcmn_requ estData.d. CustomerId .LogicalNa me, vcmn_r equestData .d.Custome rId.Id, vc mn_request Data.d.Cus tomerId.Na me); | |
| 423 | Xrm.Page.g etAttribut e('ftp_pat ient').set SubmitMode ('always') ; | |
| 424 | //Set as v eteran id | |
| 425 | vcmn_veter anId = vcm n_requestD ata.d.Cust omerId.Id | |
| 426 | } | |
| 427 | ||
| 428 | //Constr uct Templa te Note | |
| 429 | var vcmn _subReason Name = nul l; | |
| 430 | var vcmn _templateN ote = ""; | |
| 431 | var vcmn _lastFille d = ""; | |
| 432 | var vcmn _quantityR eportsTaki ng = null; | |
| 433 | var vcmn _rxNumber = null; | |
| 434 | var vcmn _rxRefillQ uantity = null; | |
| 435 | var vcmn _trackingN umber = nu ll; | |
| 436 | var vcmn _opioidAgr eementOnfi le = null; | |
| 437 | var vcmn _UDSonfile = null; | |
| 438 | var vcmn _stateDrug Monitoring Report = n ull; | |
| 439 | var vcmn _spdmpstat eonfile = null; | |
| 440 | var vcmn _sPDMPStat e2 = null; | |
| 441 | var vcmn _pickupmet hod = null ; | |
| 442 | ||
| 443 | var vcmn _earlyRefi llComment = null; | |
| 444 | var vcmn _quantityT aking = nu ll; | |
| 445 | var vcmn _vacationS tart = nul l; | |
| 446 | var vcmn _vacationE nd = null; | |
| 447 | ||
| 448 | if (vcmn _requestDa ta.d.ftp_L astFilled != null) { vcmn_last Filled = n ew Date(pa rseInt(vcm n_requestD ata.d.ftp_ LastFilled .toString( ).replace( "/Date(", "").replac e(")/", "" ), 10)); } | |
| 449 | if (vcmn _requestDa ta.d.ftp_Q uantityRep ortsTaking != null) { vcmn_qua ntityRepor tsTaking = vcmn_requ estData.d. ftp_Quanti tyReportsT aking; } | |
| 450 | if (vcmn _requestDa ta.d.ftp_R xNumber != null) { v cmn_rxNumb er = vcmn_ requestDat a.d.ftp_Rx Number; } | |
| 451 | if (vcmn _requestDa ta.d.ftp_R xRefillQua ntity != n ull) { vcm n_rxRefill Quantity = vcmn_requ estData.d. ftp_RxRefi llQuantity ; } | |
| 452 | if (vcmn _requestDa ta.d.ftp_T rackingNum ber != nul l) { vcmn_ trackingNu mber = vcm n_requestD ata.d.ftp_ TrackingNu mber; } | |
| 453 | if (vcmn _requestDa ta.d.ftp_O piodAgreem entOnfile != null) { vcmn_opio idAgreemen tOnfile = vcmn_reque stData.d.f tp_OpiodAg reementOnf ile.Value; } | |
| 454 | if (vcmn _requestDa ta.d.ftp_U DSonfile ! = null) { vcmn_UDSon file = vcm n_requestD ata.d.ftp_ UDSonfile. Value; } | |
| 455 | if (vcmn _requestDa ta.d.ftp_S tateDrugMo nitoringRe port != nu ll) { vcmn _stateDrug Monitoring Report = v cmn_reques tData.d.ft p_StateDru gMonitorin gReport.Va lue; } | |
| 456 | if (vcmn _requestDa ta.d.ftp_s pdmpstateo nfile != n ull) { vcm n_spdmpsta teonfile = vcmn_requ estData.d. ftp_spdmps tateonfile .Value; } | |
| 457 | if (vcmn _requestDa ta.d.ftp_S PDMPState2 != null) { vcmn_sPD MPState2 = vcmn_requ estData.d. ftp_SPDMPS tate2.Valu e; } | |
| 458 | if (vcmn _requestDa ta.d.ftp_p ickupmetho d != null) { vcmn_pi ckupmethod = vcmn_re questData. d.ftp_pick upmethod.V alue; } | |
| 459 | ||
| 460 | if (vcmn _requestDa ta.d.ftp_e arlyrefill comment != null) { v cmn_earlyR efillComme nt = vcmn_ requestDat a.d.ftp_ea rlyrefillc omment; } | |
| 461 | if (vcmn _requestDa ta.d.ftp_q uantitytak ing != nul l) { vcmn_ quantityTa king = vcm n_requestD ata.d.ftp_ quantityta king; } | |
| 462 | if (vcmn _requestDa ta.d.ftp_v acationsta rt != null ) { vcmn_v acationSta rt = new D ate(parseI nt(vcmn_re questData. d.ftp_vaca tionstart. toString() .replace(" /Date(", " ").replace (")/", "") , 10)); } | |
| 463 | if (vcmn _requestDa ta.d.ftp_v acationend != null) { vcmn_vac ationEnd = new Date( parseInt(v cmn_reques tData.d.ft p_vacation end.toStri ng().repla ce("/Date( ", "").rep lace(")/", ""), 10)) ; } | |
| 464 | ||
| 465 | if (vcmn _requestDa ta.d.ftp_S ubReasonId != null) { | |
| 466 | vcmn_subRe asonId = v cmn_reques tData.d.ft p_SubReaso nId.Id; | |
| 467 | vcmn_subRe asonName = vcmn_requ estData.d. ftp_SubRea sonId.Name ; | |
| 468 | ||
| 469 | if (vcmn_s ubReasonNa me == 'Reg ular') { | |
| 470 | vc mn_templat eNote = vc mn_templat eNote + "V eteran is requesting a RENEWAL ." + "\n\n "; | |
| 471 | vc mn_templat eNote = vc mn_templat eNote + "L ast Filled : " + vcmn _lastFille d + "\n\n" ; | |
| 472 | if (vcmn_min orReasonTe mplateText != null) { | |
| 473 | vcmn _templateN ote = vcmn _templateN ote + vcmn _minorReas onTemplate Text + "\n \n"; | |
| 474 | } | |
| 475 | if (vcmn_min orReasonNo teSubText != null) { | |
| 476 | vcmn _templateN ote = vcmn _templateN ote + vcmn _minorReas onNoteSubT ext + "\n\ n"; | |
| 477 | } | |
| 478 | if (vcmn_sub ReasonTemp lateText ! = null) { | |
| 479 | vcmn _templateN ote = vcmn _templateN ote + vcmn _subReason TemplateTe xt + "\n\n "; | |
| 480 | } | |
| 481 | } | |
| 482 | ||
| 483 | if (vcmn_s ubReasonNa me == 'Ear ly') { | |
| 484 | vc mn_templat eNote = vc mn_templat eNote + "V eteran is requesting EARLY FIL L." + "\n\ n"; | |
| 485 | vc mn_templat eNote = vc mn_templat eNote + "L ast Filled : " + vcmn _lastFille d + "\n\n" ; | |
| 486 | if (vcmn_min orReasonTe mplateText != null) { | |
| 487 | vcmn _templateN ote = vcmn _templateN ote + vcmn _minorReas onTemplate Text + "\n \n"; | |
| 488 | } | |
| 489 | ||
| 490 | if (vcmn_qua ntityTakin g != null) { | |
| 491 | vcmn _templateN ote = vcmn _templateN ote + "Qua ntity Taki ng: " + vc mn_quantit yTaking + "\n\n"; | |
| 492 | } | |
| 493 | ||
| 494 | if (vcmn_vac ationStart != null & & vcmn_vac ationEnd ! = null) { | |
| 495 | vcmn _templateN ote = vcmn _templateN ote + "Vet eran Leavi ng Town: " + vcmn_va cationStar t + ' - ' + vcmn_vac ationEnd + "\n\n"; | |
| 496 | } | |
| 497 | ||
| 498 | if (vcmn_min orReasonNo teSubText != null) { | |
| 499 | vcmn _templateN ote = vcmn _templateN ote + vcmn _minorReas onNoteSubT ext + "\n\ n"; | |
| 500 | } | |
| 501 | if (vcmn_sub ReasonTemp lateText ! = null) { | |
| 502 | vcmn _templateN ote = vcmn _templateN ote + vcmn _subReason TemplateTe xt + "\n\n "; | |
| 503 | } | |
| 504 | } | |
| 505 | ||
| 506 | if (vcmn_s ubReasonNa me == 'Los t') { | |
| 507 | vc mn_templat eNote = vc mn_templat eNote + "V eteran cla ims prescr iptions(s) were LOST and is re questing a new presc ription/ea rly fill." + "\n\n"; | |
| 508 | if (vcmn_rxN umber != n ull) { | |
| 509 | vcmn _templateN ote = vcmn _templateN ote + "RX# : " + vcmn _rxNumber + "\n\n"; | |
| 510 | } | |
| 511 | if (vcmn_rxR efillQuant ity != nul l) { | |
| 512 | vcmn _templateN ote = vcmn _templateN ote + "Rx Refill Qua ntity: " + vcmn_rxRe fillQuanti ty + "\n\n "; | |
| 513 | } | |
| 514 | vc mn_templat eNote = vc mn_templat eNote + "L ast Filled : " + vcmn _lastFille d + "\n\n" ; | |
| 515 | if (vcmn_min orReasonTe mplateText != null) { | |
| 516 | vcmn _templateN ote = vcmn _templateN ote + vcmn _minorReas onTemplate Text + "\n \n"; | |
| 517 | } | |
| 518 | if (vcmn_tra ckingNumbe r != null) { | |
| 519 | vcmn _templateN ote = vcmn _templateN ote + "Tra cking Numb er: " + vc mn_trackin gNumber + "\n\n"; | |
| 520 | } | |
| 521 | if (vcmn_min orReasonNo teSubText != null) { | |
| 522 | vcmn _templateN ote = vcmn _templateN ote + vcmn _minorReas onNoteSubT ext + "\n\ n"; | |
| 523 | } | |
| 524 | if (vcmn_sub ReasonTemp lateText ! = null) { | |
| 525 | vcmn _templateN ote = vcmn _templateN ote + vcmn _subReason TemplateTe xt + "\n\n "; | |
| 526 | } | |
| 527 | } | |
| 528 | ||
| 529 | if (vcmn_s ubReasonNa me == 'Sto len') { | |
| 530 | vc mn_templat eNote = vc mn_templat eNote + "V eteran cla ims prescr iptions(s) were STOL EN and is requesting a new pre scription/ early fill ." + "\n\n "; | |
| 531 | vc mn_templat eNote = vc mn_templat eNote + "L ast Filled : " + vcmn _lastFille d + "\n\n" ; | |
| 532 | if (vcmn_min orReasonTe mplateText != null) { | |
| 533 | vcmn _templateN ote = vcmn _templateN ote + vcmn _minorReas onTemplate Text + "\n \n"; | |
| 534 | } | |
| 535 | if (vcmn_min orReasonNo teSubText != null) { | |
| 536 | vcmn _templateN ote = vcmn _templateN ote + vcmn _minorReas onNoteSubT ext + "\n\ n"; | |
| 537 | } | |
| 538 | if (vcmn_sub ReasonTemp lateText ! = null) { | |
| 539 | vcmn _templateN ote = vcmn _templateN ote + vcmn _subReason TemplateTe xt + "\n\n "; | |
| 540 | } | |
| 541 | } | |
| 542 | ||
| 543 | //If Templ ate Text w as populat ed, fill i n addition al info... | |
| 544 | if (vcmn_t emplateNot e != '') { | |
| 545 | vc mn_templat eNote = vc mn_templat eNote + "\ n_________ __________ __________ __________ __________ __________ __________ __________ __________ __________ __________ _________\ n\n"; | |
| 546 | // Is an Opio id Agreeme nt current and onfil e? | |
| 547 | if (vcmn_opi oidAgreeme ntOnfile ! = null) { | |
| 548 | vcmn _templateN ote = vcmn _templateN ote + "Con sent for L ong-Term O pioid Ther apy for Pa in:\n"; | |
| 549 | if ( vcmn_opioi dAgreement Onfile == 100000000) { | |
| 550 | //Yes Option | |
| 551 | vcmn_t emplateNot e = vcmn_t emplateNot e + "[X] Y es - See P ostings\n\ n"; | |
| 552 | } | |
| 553 | if ( vcmn_opioi dAgreement Onfile == 100000001) { | |
| 554 | //No O ption | |
| 555 | vcmn_t emplateNot e = vcmn_t emplateNot e + "[X] N o - Vetera n does not have a si gned Conse nt for Lon g-Term Opi oid Therap y for pain (in Posti ngs).\nCon sent MUST be reviewe d and sign ed as soon as possib le.\n\n"; | |
| 556 | } | |
| 557 | } | |
| 558 | // Is valid U rine Drug Screen on- file? | |
| 559 | if (vcmn_UDS onfile != null) { | |
| 560 | vcmn _templateN ote = vcmn _templateN ote + "Is valid Urin e Drug Scr een on-fil e?\n"; | |
| 561 | if ( vcmn_UDSon file == 10 0000000) { | |
| 562 | //Yes Option | |
| 563 | vcmn_t emplateNot e = vcmn_t emplateNot e + "[X] Y es - See P ostings\n\ n"; | |
| 564 | } | |
| 565 | if ( vcmn_UDSon file == 10 0000001) { | |
| 566 | //No O ption | |
| 567 | vcmn_t emplateNot e = vcmn_t emplateNot e + "[X] N o - Vetera n does not have a va lid Urine Drug Scree n on-file. \n\n"; | |
| 568 | } | |
| 569 | } | |
| 570 | // State Drug Monitorin g Report? | |
| 571 | if (vcmn_sta teDrugMoni toringRepo rt != null ) { | |
| 572 | vcmn _templateN ote = vcmn _templateN ote + "Sta te Prescri ption Drug Monitorin g Program (SPDMP) re port compl eted in la st year:\n "; | |
| 573 | if ( vcmn_state DrugMonito ringReport == 100000 000) { | |
| 574 | //Posi tive Optio n | |
| 575 | vcmn_t emplateNot e = vcmn_t emplateNot e + "[X] P ositive - see SPDMP note.\n\n" ; | |
| 576 | } | |
| 577 | if ( vcmn_state DrugMonito ringReport == 100000 001) { | |
| 578 | //Nega tive Optio n | |
| 579 | vcmn_t emplateNot e = vcmn_t emplateNot e + "[X] N egative.\n \n"; | |
| 580 | } | |
| 581 | if ( vcmn_state DrugMonito ringReport == 100000 002) { | |
| 582 | //Not on File Op tion | |
| 583 | vcmn_t emplateNot e = vcmn_t emplateNot e + "[X] N one on fil e, Pharmac y to reque st.\n\n"; | |
| 584 | } | |
| 585 | //Ad d in State s (2), con vert integ ers to sta te names f rom form's hidden st ate option s | |
| 586 | var vcmn_usSta tesOptions = Xrm.Pag e.getAttri bute("ftp_ usstatesop tion").get Options(); | |
| 587 | var vcmn_state List = ""; | |
| 588 | if ( vcmn_spdmp stateonfil e != null) { | |
| 589 | //find text valu e for opti on | |
| 590 | $(vcmn _usStatesO ptions).ea ch(functio n (i, e) { | |
| 591 | var vcmn _optionTex t = $(this )[0].text; | |
| 592 | var vcmn _optionVal ue = $(thi s)[0].valu e; | |
| 593 | if (vcmn _spdmpstat eonfile == vcmn_opti onValue) { vcmn_stat eList = vc mn_optionT ext; } | |
| 594 | }); | |
| 595 | } | |
| 596 | if ( vcmn_sPDMP State2 != null) { | |
| 597 | //find text valu e for opti on | |
| 598 | $(vcmn _usStatesO ptions).ea ch(functio n (i, e) { | |
| 599 | var vcmn _optionTex t = $(this )[0].text; | |
| 600 | var vcmn _optionVal ue = $(thi s)[0].valu e; | |
| 601 | if (vcmn _sPDMPStat e2 == vcmn _optionVal ue) { vcmn _stateList = vcmn_st ateList + ", " + vcm n_optionTe xt; } | |
| 602 | }); | |
| 603 | } | |
| 604 | if ( vcmn_state List != "" ) { | |
| 605 | //Add states lis t to note | |
| 606 | vcmn_t emplateNot e = vcmn_t emplateNot e + "State Prescript ion Drug M onitoring Program fo r the foll owing stat e(s): " + vcmn_state List; | |
| 607 | } | |
| 608 | } | |
| 609 | ||
| 610 | // If ftp_pic kupmethod has a valu e | |
| 611 | if (vcmn_pic kupmethod != null) { | |
| 612 | vcmn _templateN ote = vcmn _templateN ote + "\n_ __________ __________ __________ __________ __________ __________ __________ __________ __________ __________ __________ _______\n\ n"; | |
| 613 | vcmn _templateN ote = vcmn _templateN ote + "Vet eran reque sted Metho d of Pick Up: "; | |
| 614 | if ( vcmn_picku pmethod == 100000000 ) { | |
| 615 | //Mail Option | |
| 616 | vcmn_t emplateNot e = vcmn_t emplateNot e + "[X] M ail. \n\n" ; | |
| 617 | } | |
| 618 | if ( vcmn_picku pmethod == 100000001 ) { | |
| 619 | //Wind ow Option | |
| 620 | vcmn_t emplateNot e = vcmn_t emplateNot e + "[X] W indow. \n\ n"; | |
| 621 | } | |
| 622 | //Ge t veteran' s current address | |
| 623 | if ( vcmn_veter anId != nu ll) { | |
| 624 | var vc mn_contact Data = vcm n_getSingl eEntityDat aSync('Con tactSet', 'Address1_ Composite' , vcmn_vet eranId); | |
| 625 | if (vc mn_contact Data != nu ll) { | |
| 626 | if (vcmn _contactDa ta.d.Addre ss1_Compos ite != nul l && vcmn_ contactDat a.d.Addres s1_Composi te != '') { | |
| 627 | vcmn_templ ateNote = vcmn_templ ateNote + "Address c onfirmed w ith caller : \n"; | |
| 628 | vcmn_templ ateNote = vcmn_templ ateNote + vcmn_conta ctData.d.A ddress1_Co mposite + "\n"; | |
| 629 | if (Xrm.Pa ge.getAttr ibute('ftp _callbackn umber').ge tValue() ! = null) { | |
| 630 | vc mn_templat eNote = vc mn_templat eNote + Xr m.Page.get Attribute( 'ftp_callb acknumber' ).getValue (); | |
| 631 | } | |
| 632 | } | |
| 633 | } | |
| 634 | } | |
| 635 | } | |
| 636 | } | |
| 637 | ||
| 638 | //Write no te text if not Triag e: | |
| 639 | if (vcmn_t riageexper t == 'NO' || vcmn_tr iageexpert == null) { | |
| 640 | Xr m.Page.get Attribute( 'ftp_noted etail').se tValue(vcm n_template Note); | |
| 641 | Xr m.Page.get Attribute( 'ftp_noted etail').se tSubmitMod e('always' ); | |
| 642 | } | |
| 643 | } | |
| 644 | } | |
| 645 | ||
| 646 | //Defaul t Diagnosi s code if TAN user, based on s ystemuser lookup | |
| 647 | var vcmn _currentUs erId = Xrm .Page.cont ext.getUse rId(); | |
| 648 | var vcmn _currentUs erData = v cmn_getSin gleEntityD ataSync('S ystemUserS et', 'msdy usd_USDCon figuration Id, ftp_Fa cilitySite Id', vcmn_ currentUse rId); | |
| 649 | if (vcmn _currentUs erData != null) { | |
| 650 | if ( vcmn_curre ntUserData .d.msdyusd _USDConfig urationId != null) { | |
| 651 | if (vcmn_c urrentUser Data.d.msd yusd_USDCo nfiguratio nId.Name ! = null) { | |
| 652 | if (vc mn_current UserData.d .msdyusd_U SDConfigur ationId.Na me == 'TAN Configura tion') { | |
| 653 | // Get Defaul t Tan Conf iguration from User' s Facility | |
| 654 | if (vcmn_cur rentUserDa ta.d.ftp_F acilitySit eId != nul l) { | |
| 655 | if (vcmn _currentUs erData.d.f tp_Facilit ySiteId.Id != null) { | |
| 656 | var vcmn_curre ntUserFaci lityData = vcmn_getS ingleEntit yDataSync( 'ftp_facil itySet', ' ftp_defaul ttandiagno siscode', vcmn_curre ntUserData .d.ftp_Fac ilitySiteI d.Id); | |
| 657 | if ( vcmn_curre ntUserFaci lityData ! = null) { | |
| 658 | if (vcmn_c urrentUser FacilityDa ta.d.ftp_d efaulttand iagnosisco de != null ) { | |
| 659 | if (vc mn_current UserFacili tyData.d.f tp_default tandiagnos iscode.Id != null) { | |
| 660 | // Write Diag nosis code to Progre ss Note Fo rm if a Tr iage Note | |
| 661 | if (vcmn_tri ageexpert == 'YES') { | |
| 662 | vcmn_set SimpleLook upValue('f tp_diagnos iscode', v cmn_curren tUserFacil ityData.d. ftp_defaul ttandiagno siscode.Lo gicalName, vcmn_curr entUserFac ilityData. d.ftp_defa ulttandiag nosiscode. Id, vcmn_c urrentUser FacilityDa ta.d.ftp_d efaulttand iagnosisco de.Name); | |
| 663 | Xrm.Page .getAttrib ute('ftp_d iagnosisco de').setSu bmitMode(' always'); | |
| 664 | } | |
| 665 | } | |
| 666 | } | |
| 667 | } | |
| 668 | ||
| 669 | //Ma tch up the VHG Triag e minute c onfigurati on with CP T Code | |
| 670 | if ( vcmn_triag eminutes > 0) { | |
| 671 | var vcmn_c onditional Filter = " (ftp_usert ype/Id eq guid'" + v cmn_curren tUserData. d.msdyusd_ USDConfigu rationId.I d + "') an d (ftp_sta rtminutes le " + vcm n_triagemi nutes + " ) and (ftp _endminute s ge " + v cmn_triage minutes + " )"; | |
| 672 | vcmn_getMu ltipleEnti tyDataAsyn c('ftp_cpt codeSet', 'ftp_cptco deId, ftp_ name, ftp_ startminut es, ftp_en dminutes', vcmn_cond itionalFil ter, 'ftp_ startminut es', 'asc' , 0, vcmn_ cptCode_re sponse, vc mn_triagem inutes); | |
| 673 | } | |
| 674 | } | |
| 675 | } | |
| 676 | } | |
| 677 | } | |
| 678 | } | |
| 679 | } | |
| 680 | ||
| 681 | if (vcmn _requestDa ta.d.Descr iption != null && vc mn_request Data.d.Des cription ! = '' && vc mn_triagee xpert != ' YES' && vc mn_subReas onTemplate Text == nu ll && vcmn _templateN ote == '') { | |
| 682 | //Pr ompt user to include existing Request No tes if the re is a cu rrent valu e | |
| 683 | Xrm. Utility.co nfirmDialo g( | |
| 684 | "Would you like to i nclude the primary n ote descri ption from the Reque st?, Selec t OK if Ye s, otherwi se CANCEL. ", | |
| 685 | function ( ) { | |
| 686 | Xrm.Pa ge.getAttr ibute('ftp _notedetai l').setVal ue(vcmn_re questData. d.Descript ion); | |
| 687 | Xrm.Pa ge.getAttr ibute('ftp _notedetai l').setSub mitMode('a lways'); | |
| 688 | } | |
| 689 | ); | |
| 690 | } | |
| 691 | ||
| 692 | //****** FIX DEFECT 481450 ** **** | |
| 693 | if (vcmn _requestDa ta.d.Descr iption != null && vc mn_request Data.d.Des cription ! = '' && vc mn_triagee xpert == ' YES') { | |
| 694 | //Pr ompt user to include existing Request No tes if the re is a cu rrent valu e | |
| 695 | Xrm. Utility.co nfirmDialo g( | |
| 696 | "Would you like to i nclude the primary n ote descri ption from the Reque st?, Selec t OK if Ye s, otherwi se CANCEL. ", | |
| 697 | function ( ) { | |
| 698 | //Get the existi ng Triage Note | |
| 699 | var vc mn_TriageN ote = Xrm. Page.getAt tribute('f tp_notedet ail').getV alue(); | |
| 700 | if (vc mn_TriageN ote != nul l) { | |
| 701 | Xr m.Page.get Attribute( 'ftp_noted etail').se tValue(vcm n_requestD ata.d.Desc ription + "\n\n" + v cmn_Triage Note); | |
| 702 | } | |
| 703 | else { Xrm.Page. getAttribu te('ftp_no tedetail') .setValue( vcmn_reque stData.d.D escription ); } | |
| 704 | Xrm.Pa ge.getAttr ibute('ftp _notedetai l').setSub mitMode('a lways'); | |
| 705 | } | |
| 706 | ); | |
| 707 | } | |
| 708 | //****** END FIX DE FECT 48145 0 ****** | |
| 709 | } | |
| 710 | ||
| 711 | // Get Curren t Facility based on veteran/co ntact Use Current Fa cility (ft p_currentf acilityid) Text, if empty use Home Facil ity (ftp_F acilityId) | |
| 712 | if (vcmn_vet eranId != null) { | |
| 713 | var vcmn _contactDa ta = vcmn_ getSingleE ntityDataS ync('Conta ctSet', 'f tp_current facilityid , ftp_Faci lityId', v cmn_vetera nId); | |
| 714 | if (vcmn _contactDa ta != null ) { | |
| 715 | if ( vcmn_conta ctData.d.f tp_current facilityid != null) { | |
| 716 | if (vcmn_c ontactData .d.ftp_cur rentfacili tyid.Id != null) { | |
| 717 | vcmn_s etSimpleLo okupValue( 'ftp_patie ntfacility ', vcmn_co ntactData. d.ftp_curr entfacilit yid.Logica lName, vcm n_contactD ata.d.ftp_ currentfac ilityid.Id , vcmn_con tactData.d .ftp_curre ntfacility id.Name); | |
| 718 | Xrm.Pa ge.getAttr ibute('ftp _patientfa cility').s etSubmitMo de('always '); | |
| 719 | } | |
| 720 | else { | |
| 721 | //Get Facility f rom Home F acility | |
| 722 | if (vc mn_contact Data.d.ftp _FacilityI d != null) { | |
| 723 | vc mn_setSimp leLookupVa lue('ftp_p atientfaci lity', vcm n_contactD ata.d.ftp_ FacilityId .LogicalNa me, vcmn_c ontactData .d.ftp_Fac ilityId.Id , vcmn_con tactData.d .ftp_Facil ityId.Name ); | |
| 724 | Xr m.Page.get Attribute( 'ftp_patie ntfacility ').setSubm itMode('al ways'); | |
| 725 | } | |
| 726 | } | |
| 727 | } | |
| 728 | else { | |
| 729 | //Get Faci lity from Home Facil ity | |
| 730 | if (vcmn_c ontactData .d.ftp_Fac ilityId != null) { | |
| 731 | vcmn_s etSimpleLo okupValue( 'ftp_patie ntfacility ', vcmn_co ntactData. d.ftp_Faci lityId.Log icalName, vcmn_conta ctData.d.f tp_Facilit yId.Id, vc mn_contact Data.d.ftp _FacilityI d.Name); | |
| 732 | Xrm.Pa ge.getAttr ibute('ftp _patientfa cility').s etSubmitMo de('always '); | |
| 733 | } | |
| 734 | } | |
| 735 | } | |
| 736 | } | |
| 737 | ||
| 738 | // Set other default fo rm values | |
| 739 | Xr m.Page.get Attribute( 'scheduled end').setV alue(new D ate()); | |
| 740 | Xr m.Page.get Attribute( 'scheduled end').setS ubmitMode( 'always'); | |
| 741 | ||
| 742 | // Append Gen eric Templ ate Data t o top of e xisting no te | |
| 743 | va r vcmn_gen ericTempla teData = " Callback N umber: "; | |
| 744 | if (Xrm.Page .getAttrib ute('ftp_c allbacknum ber').getV alue() != null && Xr m.Page.get Attribute( 'ftp_callb acknumber' ).getValue () != "") { | |
| 745 | vcmn_gen ericTempla teData = v cmn_generi cTemplateD ata + Xrm. Page.getAt tribute('f tp_callbac knumber'). getValue() ; | |
| 746 | } | |
| 747 | // Construct new note w ith existi ng note da ta | |
| 748 | va r vcmn_exi stingNoteD ata = ""; | |
| 749 | if (Xrm.Page .getAttrib ute("ftp_n otedetail" ).getValue () != null && Xrm.Pa ge.getAttr ibute("ftp _notedetai l").getVal ue() != "" ) { | |
| 750 | vcmn_exi stingNoteD ata = Xrm. Page.getAt tribute("f tp_notedet ail").getV alue(); | |
| 751 | } | |
| 752 | vc mn_generic TemplateDa ta = vcmn_ genericTem plateData + "\n\n" + vcmn_exis tingNoteDa ta; | |
| 753 | // Replace ex isting not e | |
| 754 | Xr m.Page.get Attribute( 'ftp_noted etail').se tValue(vcm n_genericT emplateDat a); | |
| 755 | Xr m.Page.get Attribute( 'ftp_noted etail').se tSubmitMod e('always' ); | |
| 756 | ||
| 757 | // Change Foc us to the Notes fiel d | |
| 758 | Xr m.Page.get Control("f tp_notedet ail").setF ocus(); | |
| 759 | ||
| 760 | // Get ICN vi a web serv ice and ge t Service Connected disabiliti es thereaf ter | |
| 761 | // Preserved Variables | |
| 762 | va r vcmn_vet eranId = n ull; //Fr om request customeri d | |
| 763 | va r vcmn_vet eranFirstN ame = ''; | |
| 764 | va r vcmn_vet eranLastNa me = ''; | |
| 765 | va r vcmn_SSN = ''; | |
| 766 | va r vcmn_DOB = ''; | |
| 767 | ||
| 768 | // Get regard ing data | |
| 769 | va r vcmn_req uestId = X rm.Page.ge tAttribute ('regardin gobjectid' ).getValue (); | |
| 770 | if (vcmn_req uestId == null) { re turn false ; } | |
| 771 | va r vcmn_req uestData = vcmn_getS ingleEntit yDataSync( 'IncidentS et', 'Cust omerId', v cmn_reques tId[0].id) ; | |
| 772 | ||
| 773 | if (vcmn_req uestData ! = null) { | |
| 774 | if (vcmn _requestDa ta.d.Custo merId != n ull) { | |
| 775 | vcmn _veteranId = vcmn_re questData. d.Customer Id; | |
| 776 | //Ve rify that the custom erid is of type cont act | |
| 777 | if ( vcmn_veter anId.Logic alName != 'contact') { | |
| 778 | return fal se; | |
| 779 | } | |
| 780 | } | |
| 781 | } | |
| 782 | if (vcmn_vet eranId == null) { | |
| 783 | return f alse; | |
| 784 | } | |
| 785 | ||
| 786 | va r vcmn_con tactData = vcmn_getS ingleEntit yDataSync( 'ContactSe t', 'First Name, Last Name, ftp_ DateofBirt h, Governm entId', vc mn_veteran Id.Id); | |
| 787 | if (vcmn_con tactData ! = null) { | |
| 788 | if (vcmn _contactDa ta.d.First Name != nu ll) { vcmn _veteranFi rstName = vcmn_conta ctData.d.F irstName; } | |
| 789 | if (vcmn _contactDa ta.d.LastN ame != nul l) { vcmn_ veteranLas tName = vc mn_contact Data.d.Las tName; } | |
| 790 | if (vcmn _contactDa ta.d.ftp_D ateofBirth != null) { vcmn_DOB = vcmn_co ntactData. d.ftp_Date ofBirth; } | |
| 791 | if (vcmn _contactDa ta.d.Gover nmentId != null) { v cmn_SSN = vcmn_conta ctData.d.G overnmentI d; } | |
| 792 | } | |
| 793 | ||
| 794 | // Perform MV I Search f or Service Connected Disabilit ies | |
| 795 | vc mn_unatten dedMviSear chSCD(vcmn _veteranFi rstName, v cmn_vetera nLastName, vcmn_DOB, vcmn_SSN) ; | |
| 796 | } | |
| 797 | catch (err) { | |
| 798 | al ert('Progr ess Note F orm Load S cript Func tion Error (vcmn_newP rogressNot eLoad_WebU RL): ' + e rr.message ); | |
| 799 | } | |
| 800 | } | |
| 801 | ||
| 802 | function v cmn_getSer viceConnec tedDisabil ities(vcmn _patientIC N) { | |
| 803 | //**** ********** ********** ********** ********** ********** ********** ********** ********** ********** ********** *** | |
| 804 | //Janu ary 16 201 7 - EXIT T HE FUNCTIO N, NOT USE D SEE BELO W | |
| 805 | return false; | |
| 806 | //***T HE CODE BE LOW HAS BE EN TEMPORA RILY DISAB LED TO NOT INCLUDE S ERVICE CON NECTED DIS ABILITIES IN THE NOT E | |
| 807 | //**** ********** ********** ********** ********** ********** ********** ********** ********** ********** ********** *** | |
| 808 | try { | |
| 809 | // ******Deve loper Bypa ss for mis sing ICN** **** | |
| 810 | if (vcmn_pat ientICN == '' || vcm n_patientI CN == null ) { | |
| 811 | if ((Xrm .Page.cont ext.getUse rId()).toU pperCase() == "{CA50 0504-CBC5- E511-8173- 000C2941CE 19}") { | |
| 812 | aler t("Develop er ICN byp ass applie d!"); | |
| 813 | vcmn _patientIC N = "12345 6V123456"; | |
| 814 | } | |
| 815 | } | |
| 816 | ||
| 817 | // Verify Pat ient ICN | |
| 818 | if (vcmn_pat ientICN == '' || vcm n_patientI CN == null ) { | |
| 819 | //No ICN , do not p roceed | |
| 820 | return f alse; | |
| 821 | } | |
| 822 | ||
| 823 | // Get the se rvice conn ected disa bilities d ata from t he web ser vice | |
| 824 | va r vcmn_dis abilitiesX mlData = v cmn_getDis abilityDat a(vcmn_pat ientICN); | |
| 825 | ||
| 826 | // Temporary action: xm l result i s empty, u se sample data, comm ent out wh en not use d | |
| 827 | // ********** ********** ********** ********** ********** ********** ********** ********** ********** ********** ********** ******** | |
| 828 | // if (vcmn_d isabilitie sXmlData = = null || vcmn_disab ilitiesXml Data == '' ) { vcmn_d isabilitie sXmlData = xml_resul ts3; } | |
| 829 | // ********** ********** ********** ********** ********** ********** ********** ********** ********** ********** ********** ******** | |
| 830 | ||
| 831 | // If no data , do not p roceed. | |
| 832 | if (vcmn_dis abilitiesX mlData == null || vc mn_disabil itiesXmlDa ta == '') { return f alse; } | |
| 833 | ||
| 834 | // Create bas e Note Str ing | |
| 835 | va r vcmn_SCD noteString = ''; | |
| 836 | vc mn_SCDnote String = v cmn_SCDnot eString + "\n------- ---------- ---------- ---------- ---------- ---------- ---------- ------\n"; | |
| 837 | vc mn_SCDnote String = v cmn_SCDnot eString + "Special T reatment A uthority a nd Service Connected Disabilit ies"; | |
| 838 | vc mn_SCDnote String = v cmn_SCDnot eString + "\n------- ---------- ---------- ---------- ---------- ---------- ---------- ------\n"; | |
| 839 | ||
| 840 | // Search XML values | |
| 841 | vc mn_xmlDoc = $.parseX ML(vcmn_di sabilities XmlData); | |
| 842 | $v cmn_xml = $(vcmn_xml Doc); | |
| 843 | ||
| 844 | // Data from parentnode 'enrollme ntDetermin ationInfo' | |
| 845 | va r $vcmn_en rollmentDe terminatio nInfo = nu ll; | |
| 846 | va r $vcmn_pr imaryEligi bility = n ull; | |
| 847 | va r $vcmn_ty pe = null; | |
| 848 | va r vcmn_typ eText = nu ll; | |
| 849 | va r $vcmn_en rollmentCa tegoryName = null; | |
| 850 | va r vcmn_enr ollmentCat egoryNameT ext = null ; | |
| 851 | va r $vcmn_sp ecialFacto rs = null; | |
| 852 | va r $vcmn_en vContamina ntsInd = n ull; | |
| 853 | va r vcmn_env Contaminan tsIndText = null; | |
| 854 | va r $vcmn_ra diationExp osureInd = null; | |
| 855 | va r vcmn_rad iationExpo sureIndTex t = null; | |
| 856 | va r $vcmn_ag entOrangeI nd = null; | |
| 857 | va r vcmn_age ntOrangeIn dText = nu ll; | |
| 858 | va r $vcmn_ca mpLejeuneI nd = null; | |
| 859 | va r vcmn_cam pLejeuneIn dText = nu ll; | |
| 860 | va r $vcmn_se rviceConne ctionAward = null; | |
| 861 | va r $vcmn_se rviceConne ctedPercen tage = nul l; | |
| 862 | va r vcmn_ser viceConnec tedPercent ageText = null; | |
| 863 | va r $vcmn_ra tedDisabil ities = nu ll; | |
| 864 | ||
| 865 | va r $vcmn_ag entOrangeL ocation = null; | |
| 866 | va r vcmn_age ntOrangeLo cationText = null; | |
| 867 | va r $vcmn_ra diationExp osureMetho d = null; | |
| 868 | va r vcmn_rad iationExpo sureMethod Text = nul l; | |
| 869 | ||
| 870 | va r $vcmn_no seThroatRa diumInfo = null; | |
| 871 | va r $vcmn_di agnosedWit hCancer = null; | |
| 872 | va r vcmn_dia gnosedWith CancerText = null; | |
| 873 | ||
| 874 | va r $vcmn_mi litarySexu alTraumaIn fo = null; | |
| 875 | va r $vcmn_mi lSexTrauma Status = n ull; | |
| 876 | va r vcmn_mil SexTraumaS tatusText = null; | |
| 877 | ||
| 878 | // Data from parentnode 'military ServiceInf o' | |
| 879 | va r $vcmn_mi litaryServ iceInfo = null; | |
| 880 | va r $vcmn_co mbatVetera nEligibili tyEndDate = null; | |
| 881 | va r vcmn_com batVeteran Eligibilit yEndDateTe xt = null; | |
| 882 | va r $vcmn_sh adIndicato r = null; | |
| 883 | va r vcmn_sha dIndicator Text = nul l; | |
| 884 | ||
| 885 | va r vcmn_rat edDisabili tyPercenta geTotal = 0; | |
| 886 | ||
| 887 | va r vcmn_det ailrowcoun t = 0; | |
| 888 | ||
| 889 | $v cmn_enroll mentDeterm inationInf o = $vcmn_ xml.find(' enrollment Determinat ionInfo'); | |
| 890 | if ($vcmn_en rollmentDe terminatio nInfo != n ull) { | |
| 891 | $vcmn_pr imaryEligi bility = $ vcmn_enrol lmentDeter minationIn fo.find('p rimaryElig ibility'); | |
| 892 | if ($vcm n_primaryE ligibility != null) { | |
| 893 | $vcm n_type = $ vcmn_prima ryEligibil ity.find(' type'); | |
| 894 | if ( $vcmn_type != null) { vcmn_typ eText = $v cmn_type.t ext(); } | |
| 895 | } | |
| 896 | ||
| 897 | $vcmn_en rollmentCa tegoryName = $vcmn_e nrollmentD eterminati onInfo.fin d('enrollm entCategor yName'); | |
| 898 | if ($vcm n_enrollme ntCategory Name != nu ll) { vcmn _enrollmen tCategoryN ameText = $vcmn_enro llmentCate goryName.t ext(); } | |
| 899 | ||
| 900 | $vcmn_sp ecialFacto rs = $vcmn _enrollmen tDetermina tionInfo.f ind('speci alFactors' ); | |
| 901 | if ($vcm n_specialF actors != null) { | |
| 902 | $vcm n_envConta minantsInd = $vcmn_s pecialFact ors.find(' envContami nantsInd') ; | |
| 903 | if ( $vcmn_envC ontaminant sInd != nu ll) { vcmn _envContam inantsIndT ext = $vcm n_envConta minantsInd .text(); } | |
| 904 | $vcm n_radiatio nExposureI nd = $vcmn _specialFa ctors.find ('radiatio nExposureI nd'); | |
| 905 | if ( $vcmn_radi ationExpos ureInd != null) { vc mn_radiati onExposure IndText = $vcmn_radi ationExpos ureInd.tex t(); } | |
| 906 | $vcm n_agentOra ngeInd = $ vcmn_speci alFactors. find('agen tOrangeInd '); | |
| 907 | if ( $vcmn_agen tOrangeInd != null) { vcmn_age ntOrangeIn dText = $v cmn_agentO rangeInd.t ext(); } | |
| 908 | $vcm n_campLeje uneInd = $ vcmn_speci alFactors. find('camp LejeuneInd '); | |
| 909 | if ( $vcmn_camp LejeuneInd != null) { vcmn_cam pLejeuneIn dText = $v cmn_campLe jeuneInd.t ext(); } | |
| 910 | ||
| 911 | $vcm n_agentOra ngeLocatio n = $vcmn_ specialFac tors.find( 'agentOran geLocation '); | |
| 912 | if ( $vcmn_agen tOrangeLoc ation != n ull) { vcm n_agentOra ngeLocatio nText = $v cmn_agentO rangeLocat ion.text() ; } | |
| 913 | $vcm n_radiatio nExposureM ethod = $v cmn_specia lFactors.f ind('radia tionExposu reMethod') ; | |
| 914 | if ( $vcmn_radi ationExpos ureMethod != null) { vcmn_radi ationExpos ureMethodT ext = $vcm n_radiatio nExposureM ethod.text (); } | |
| 915 | } | |
| 916 | ||
| 917 | $vcmn_se rviceConne ctionAward = $vcmn_e nrollmentD eterminati onInfo.fin d('service Connection Award'); | |
| 918 | if ($vcm n_serviceC onnectionA ward != nu ll) { | |
| 919 | $vcm n_serviceC onnectedPe rcentage = $vcmn_ser viceConnec tionAward. find('serv iceConnect edPercenta ge'); | |
| 920 | if ( $vcmn_serv iceConnect edPercenta ge != null ) { vcmn_s erviceConn ectedPerce ntageText = $vcmn_se rviceConne ctedPercen tage.text( ); } | |
| 921 | $vcm n_ratedDis abilities = $vcmn_se rviceConne ctionAward .find('rat edDisabili ties'); | |
| 922 | //Ge t each dis ability li sted and a dd to note string | |
| 923 | vcmn _SCDnoteSt ring = vcm n_SCDnoteS tring + "S C Disabili ty: "; | |
| 924 | $vcm n_ratedDis abilities. find('rate dDisabilit y').each(f unction () { | |
| 925 | var vcmn_r atedDisabi lityPercen t = 0; | |
| 926 | var vcmn_d isability = null; | |
| 927 | if (Number ($(this).f ind('perce ntage').te xt()) > 0) { | |
| 928 | vcmn_r atedDisabi lityPercen tageTotal = vcmn_rat edDisabili tyPercenta geTotal + Number($(t his).find( 'percentag e').text() ); | |
| 929 | vcmn_r atedDisabi lityPercen t = Number ($(this).f ind('perce ntage').te xt()); | |
| 930 | } | |
| 931 | //Add Rate d Disabili ties to th e Note Str ing if Dis ability Pe rcent > 0 | |
| 932 | if (vcmn_r atedDisabi lityPercen t > 0) { | |
| 933 | vcmn_S CDnoteStri ng = vcmn_ SCDnoteStr ing + $(th is).find(' disability ').text() + "\n"; | |
| 934 | } | |
| 935 | }); | |
| 936 | vcmn _SCDnoteSt ring = vcm n_SCDnoteS tring + "\ n"; | |
| 937 | } | |
| 938 | ||
| 939 | $vcmn_no seThroatRa diumInfo = $vcmn_enr ollmentDet ermination Info.find( 'noseThroa tRadiumInf o'); | |
| 940 | if ($vcm n_noseThro atRadiumIn fo != null ) { | |
| 941 | $vcm n_diagnose dWithCance r = $vcmn_ noseThroat RadiumInfo .find('dia gnosedWith Cancer'); | |
| 942 | if ( $vcmn_diag nosedWithC ancer != n ull) { vcm n_diagnose dWithCance rText = $v cmn_diagno sedWithCan cer.text() ; } | |
| 943 | } | |
| 944 | ||
| 945 | $vcmn_mi litarySexu alTraumaIn fo = $vcmn _enrollmen tDetermina tionInfo.f ind('milit arySexualT raumaInfo' ); | |
| 946 | if ($vcm n_military SexualTrau maInfo != null) { | |
| 947 | $vcm n_milSexTr aumaStatus = $vcmn_m ilitarySex ualTraumaI nfo.find(' status'); | |
| 948 | if ( $vcmn_milS exTraumaSt atus != nu ll) { vcmn _milSexTra umaStatusT ext = $vcm n_milSexTr aumaStatus .text(); } | |
| 949 | } | |
| 950 | } | |
| 951 | ||
| 952 | $v cmn_milita ryServiceI nfo = $vcm n_xml.find ('military ServiceInf o'); | |
| 953 | if ($vcmn_mi litaryServ iceInfo != null) { | |
| 954 | $vcmn_co mbatVetera nEligibili tyEndDate = $vcmn_mi litaryServ iceInfo.fi nd('combat VeteranEli gibilityEn dDate'); | |
| 955 | if ($vcm n_combatVe teranEligi bilityEndD ate != nul l) { | |
| 956 | vcmn _combatVet eranEligib ilityEndDa teText = v cmn_combat VeteranEli gibilityEn dDateText = $vcmn_co mbatVetera nEligibili tyEndDate. text(); | |
| 957 | } | |
| 958 | $vcmn_sh adIndicato r = $vcmn_ militarySe rviceInfo. find('shad Indicator' ); | |
| 959 | if ($vcm n_shadIndi cator != n ull) { vcm n_shadIndi catorText = $vcmn_sh adIndicato r.text(); } | |
| 960 | } | |
| 961 | ||
| 962 | // If no elig ibility sp ecified, s et to fals e | |
| 963 | if (vcmn_typ eText == n ull || vcm n_typeText == '') { vcmn_typeT ext = fals e; } | |
| 964 | ||
| 965 | // Change boo lean value s to false if not ma rked true | |
| 966 | if (vcmn_env Contaminan tsIndText != 'true') { vcmn_en vContamina ntsIndText = false; } | |
| 967 | if (vcmn_rad iationExpo sureIndTex t != 'true ') { vcmn_ radiationE xposureInd Text = fal se; } | |
| 968 | if (vcmn_age ntOrangeIn dText != ' true') { v cmn_agentO rangeIndTe xt = false ; } | |
| 969 | if (vcmn_cam pLejeuneIn dText != ' true') { v cmn_campLe jeuneIndTe xt = false ; } | |
| 970 | ||
| 971 | if (vcmn_dia gnosedWith CancerText != 'true' ) { vcmn_d iagnosedWi thCancerTe xt = false ; } | |
| 972 | if (vcmn_sha dIndicator Text != 't rue') { vc mn_shadInd icatorText = false; } | |
| 973 | ||
| 974 | // Change all True/Fals e to Yes/N o | |
| 975 | if (vcmn_typ eText == f alse) { vc mn_typeTex t = 'No'; } | |
| 976 | ||
| 977 | if (vcmn_env Contaminan tsIndText == "true") { vcmn_en vContamina ntsIndText = "Yes"; } else { v cmn_envCon taminantsI ndText = " No"; } | |
| 978 | if (vcmn_rad iationExpo sureIndTex t == "true ") { | |
| 979 | vcmn_rad iationExpo sureIndTex t = "Yes"; | |
| 980 | if (vcmn _radiation ExposureMe thodText ! = null) { vcmn_radia tionExposu reIndText = vcmn_rad iationExpo sureIndTex t + " - " + vcmn_rad iationExpo sureMethod Text; } | |
| 981 | } else { | |
| 982 | vcmn_rad iationExpo sureIndTex t = "No"; | |
| 983 | } | |
| 984 | if (vcmn_age ntOrangeIn dText == " true") { | |
| 985 | vcmn_age ntOrangeIn dText = "Y es"; | |
| 986 | if (vcmn _agentOran geLocation Text != nu ll) { vcmn _agentOran geIndText = vcmn_age ntOrangeIn dText + " - " + vcmn _agentOran geLocation Text; } | |
| 987 | } | |
| 988 | el se { | |
| 989 | vcmn_age ntOrangeIn dText = "N o"; | |
| 990 | } | |
| 991 | if (vcmn_cam pLejeuneIn dText == " true") { v cmn_campLe jeuneIndTe xt = "Yes" ; } else { vcmn_camp LejeuneInd Text = "No "; } | |
| 992 | ||
| 993 | if (vcmn_dia gnosedWith CancerText == "true" ) { vcmn_d iagnosedWi thCancerTe xt = "Yes" ; } else { vcmn_diag nosedWithC ancerText = "No"; } | |
| 994 | ||
| 995 | if (vcmn_com batVeteran Eligibilit yEndDateTe xt != null && vcmn_c ombatVeter anEligibil ityEndDate Text != '' ) { vcmn_c ombatVeter anEligibil ityEndDate Text = 'Ye s'; } | |
| 996 | ||
| 997 | if (vcmn_sha dIndicator Text == "t rue") { vc mn_shadInd icatorText = "Yes"; } else { v cmn_shadIn dicatorTex t = "No"; } | |
| 998 | ||
| 999 | // Construct summary no te part | |
| 1000 | if (vcmn_env Contaminan tsIndText != null && vcmn_envC ontaminant sIndText ! = '') { vc mn_SCDnote String = v cmn_SCDnot eString + "Environme ntal Conta minant: " + vcmn_env Contaminan tsIndText + "\n"; } | |
| 1001 | if (vcmn_com batVeteran Eligibilit yEndDateTe xt != null && vcmn_c ombatVeter anEligibil ityEndDate Text != '' ) { vcmn_S CDnoteStri ng = vcmn_ SCDnoteStr ing + "Com bat Vetera n: " + vcm n_combatVe teranEligi bilityEndD ateText + "\n"; } | |
| 1002 | if (vcmn_rad iationExpo sureIndTex t != null && vcmn_ra diationExp osureIndTe xt != '') { vcmn_SCD noteString = vcmn_SC DnoteStrin g + "Radia tion Expos ure: " + v cmn_radiat ionExposur eIndText + "\n"; } | |
| 1003 | if (vcmn_age ntOrangeIn dText != n ull && vcm n_agentOra ngeIndText != '') { vcmn_SCDno teString = vcmn_SCDn oteString + "Agent O range: " + vcmn_agen tOrangeInd Text + "\n "; } | |
| 1004 | if (vcmn_sha dIndicator Text != nu ll && vcmn _shadIndic atorText ! = '') { vc mn_SCDnote String = v cmn_SCDnot eString + "Shipboard Hazard & Defense: " + vcmn_sh adIndicato rText + "\ n"; } | |
| 1005 | if (vcmn_dia gnosedWith CancerText != null & & vcmn_dia gnosedWith CancerText != '') { vcmn_SCDno teString = vcmn_SCDn oteString + "Head/Ne ck Cancer: " + vcmn_ diagnosedW ithCancerT ext + "\n" ; } | |
| 1006 | if (vcmn_mil SexTraumaS tatusText != null && vcmn_milS exTraumaSt atusText ! = '') { vc mn_SCDnote String = v cmn_SCDnot eString + "Military Sexual Tra uma: " + v cmn_milSex TraumaStat usText + " \n"; } | |
| 1007 | if (vcmn_cam pLejeuneIn dText != n ull && vcm n_campLeje uneIndText != '') { vcmn_SCDno teString = vcmn_SCDn oteString + "Camp Le jeune: " + vcmn_camp LejeuneInd Text + "\n "; } | |
| 1008 | ||
| 1009 | // Update not e with new SCD note data | |
| 1010 | va r vcmn_exi stingNoteD ata = ""; | |
| 1011 | if (Xrm.Page .getAttrib ute("ftp_n otedetail" ).getValue () != null && Xrm.Pa ge.getAttr ibute("ftp _notedetai l").getVal ue() != "" ) { | |
| 1012 | vcmn_exi stingNoteD ata = Xrm. Page.getAt tribute("f tp_notedet ail").getV alue(); | |
| 1013 | } | |
| 1014 | vc mn_extende dTemplateD ata = vcmn _existingN oteData + vcmn_SCDno teString; | |
| 1015 | // Replace ex isting not e | |
| 1016 | Xr m.Page.get Attribute( 'ftp_noted etail').se tValue(vcm n_extended TemplateDa ta); | |
| 1017 | Xr m.Page.get Attribute( 'ftp_noted etail').se tSubmitMod e('always' ); | |
| 1018 | } | |
| 1019 | catch (err) { | |
| 1020 | al ert('Progr ess Note F orm Load S cript Func tion Error (vcmn_getS erviceConn ectedDisab ilities): ' + err.me ssage); | |
| 1021 | } | |
| 1022 | } | |
| 1023 | ||
| 1024 | function v cmn_getDis abilityDat a(vcmn_nat ionalId) { | |
| 1025 | try { | |
| 1026 | va r vcmn_ees ummaryURL = vcmn_ees ummaryURLb ase + '000 000' + vcm n_national Id + '0000 00'; | |
| 1027 | va r vcmn_xml Data = nul l; | |
| 1028 | ||
| 1029 | $. ajax({ | |
| 1030 | type: "G ET", | |
| 1031 | url: vcm n_eesummar yURL, | |
| 1032 | contentT ype: "appl ication/xm l; charset =utf-8", | |
| 1033 | dataType : "text", | |
| 1034 | success: function (xmlTextda ta) { | |
| 1035 | vcmn _xmlData = xmlTextda ta; | |
| 1036 | }, | |
| 1037 | error: f unction (j qXHR, text Status, er rorThrown) { | |
| 1038 | //Sy stem Error | |
| 1039 | vcmn _xmlData = null; | |
| 1040 | }, | |
| 1041 | async: f alse, | |
| 1042 | cache: f alse | |
| 1043 | }) ; | |
| 1044 | re turn vcmn_ xmlData; | |
| 1045 | } | |
| 1046 | catch (err) { | |
| 1047 | al ert("Progr ess Note F orm Load S cript Func tion Error (vcmn_getD isabilityD ata): " + err.messag e); | |
| 1048 | re turn null; | |
| 1049 | } | |
| 1050 | } | |
| 1051 | ||
| 1052 | function v cmn_facili tyByCode_r esponse(vc mn_facilit yData, vcm n_lastSkip , vcmn_fac ilityCode) { | |
| 1053 | try { | |
| 1054 | // vcmn_lastS kip is the starting point in t he result (use if mo re than 50 records) //Not used in this s cenario | |
| 1055 | // ***REVISED NOT USED, KEEP FOR FUTURE UPD ATE*** | |
| 1056 | /* | |
| 1057 | va r vcmn_fac ilityid = null; | |
| 1058 | va r vcmn_fac ilityname = null; | |
| 1059 | fo r (var i = 0; i <= v cmn_facili tyData.d.r esults.len gth - 1; i ++) { | |
| 1060 | //Get in fo | |
| 1061 | if (vcmn _facilityD ata.d.resu lts[i].ftp _facilityI d != null) { vcmn_fa cilityid = vcmn_faci lityData.d .results[i ].ftp_faci lityId; } | |
| 1062 | if (vcmn _facilityD ata.d.resu lts[i].ftp _name != n ull) { vcm n_facility name = vcm n_facility Data.d.res ults[i].ft p_name; } | |
| 1063 | break; | |
| 1064 | } | |
| 1065 | if (vcmn_fac ilityid != null) { | |
| 1066 | vcmn_set SimpleLook upValue('f tp_patient facility', 'ftp_faci lity', vcm n_facility id, vcmn_f acilitynam e); | |
| 1067 | Xrm.Page .getAttrib ute('ftp_p atientfaci lity').set SubmitMode ('always') ; | |
| 1068 | } | |
| 1069 | */ | |
| 1070 | } | |
| 1071 | catch (err) { | |
| 1072 | al ert('Progr ess Note F orm Load S cript Func tion Error (vcmn_faci lityByCode _response) : ' + err. message); | |
| 1073 | } | |
| 1074 | } | |
| 1075 | ||
| 1076 | function v cmn_cptCod e_response (vcmn_cptC odeData, v cmn_lastSk ip, vcmn_t riageminut es) { | |
| 1077 | try { | |
| 1078 | // vcmn_lastS kip is the starting point in t he result (use if mo re than 50 records) //Not used in this s cenario | |
| 1079 | fo r (var i = 0; i <= v cmn_cptCod eData.d.re sults.leng th - 1; i+ +) { | |
| 1080 | //Write to CRM pro gress note form | |
| 1081 | vcmn_set SimpleLook upValue('f tp_cptcode ', 'ftp_cp tcode', vc mn_cptCode Data.d.res ults[i].ft p_cptcodeI d, vcmn_cp tCodeData. d.results[ i].ftp_nam e); | |
| 1082 | Xrm.Page .getAttrib ute('ftp_c ptcode').s etSubmitMo de('always '); | |
| 1083 | break; | |
| 1084 | } | |
| 1085 | } | |
| 1086 | catch (err) { | |
| 1087 | al ert('Progr ess Note F orm Load S cript Func tion Error (vcmn_cptC ode_respon se): ' + e rr.message ); | |
| 1088 | } | |
| 1089 | } | |
| 1090 | ||
| 1091 | function v cmn_ribbon ButtonSave () { | |
| 1092 | try { | |
| 1093 | // Save the c urrent CRM data | |
| 1094 | Xr m.Page.dat a.entity.s ave(); | |
| 1095 | } | |
| 1096 | catch (err) { | |
| 1097 | al ert('Progr ess Note R ibbon Func tion Error (vcmn_ribb onButtonSa ve): ' + e rr.message ); | |
| 1098 | } | |
| 1099 | } | |
| 1100 | ||
| 1101 | function v cmn_getCoo kie(cname) { | |
| 1102 | try { | |
| 1103 | va r name = c name + "=" ; | |
| 1104 | va r ca = doc ument.cook ie.split(' ;'); | |
| 1105 | fo r (var i = 0; i < ca .length; i ++) { | |
| 1106 | var c = ca[i]; | |
| 1107 | while (c .charAt(0) == ' ') { | |
| 1108 | c = c.substrin g(1); | |
| 1109 | } | |
| 1110 | if (c.in dexOf(name ) == 0) { | |
| 1111 | retu rn c.subst ring(name. length, c. length); | |
| 1112 | } | |
| 1113 | } | |
| 1114 | re turn ""; | |
| 1115 | } | |
| 1116 | catch (err) { | |
| 1117 | al ert('Progr ess Note R ibbon Func tion Error (vcmn_getC ookie): ' + err.mess age); | |
| 1118 | } | |
| 1119 | } | |
| 1120 | ||
| 1121 | function v cmn_wordWr ap(str, in tWidth, st rBreak, cu t) { | |
| 1122 | try { | |
| 1123 | // Takes a st ring that exceeds a set length and inser ts word wr ap | |
| 1124 | va r m = ((ar guments.le ngth >= 2) ? argumen ts[1] : 75 ) | |
| 1125 | va r b = ((ar guments.le ngth >= 3) ? argumen ts[2] : '\ n') | |
| 1126 | va r c = ((ar guments.le ngth >= 4) ? argumen ts[3] : fa lse) | |
| 1127 | ||
| 1128 | va r i, j, l, s, r | |
| 1129 | ||
| 1130 | st r += '' | |
| 1131 | ||
| 1132 | if (m < 1) { | |
| 1133 | return s tr | |
| 1134 | } | |
| 1135 | ||
| 1136 | fo r (i = -1, l = (r = str.split( /\r\n|\n|\ r/)).lengt h; ++i < l ; r[i] += s) { | |
| 1137 | for (s = r[i], r[i ] = ''; | |
| 1138 | s.leng th > m; | |
| 1139 | r[i] + = s.slice( 0, j) + (( s = s.slic e(j)).leng th ? b : ' ')) { | |
| 1140 | j = c === 2 || (j = s.sl ice(0, m + 1).match( /\S*(\s)?$ /))[1] | |
| 1141 | ? m | |
| 1142 | : j.input.le ngth - j[0 ].length | | c === tr ue && m || | |
| 1143 | j.input.le ngth + (j = s.slice( m).match(/ ^\S*/))[0] .length | |
| 1144 | } | |
| 1145 | } | |
| 1146 | ||
| 1147 | re turn r.joi n('\n') | |
| 1148 | } | |
| 1149 | catch (err) { | |
| 1150 | al ert('Progr ess Note R ibbon Func tion Error (vcmn_word Wrap): ' + err.messa ge); | |
| 1151 | } | |
| 1152 | } | |
| 1153 | ||
| 1154 | function v cmn_ribbon ButtonSave ToVistA() { | |
| 1155 | try { | |
| 1156 | // Check the value of t he Integra tion Statu s Field, i f = 'OK', stop and e xit this s cript | |
| 1157 | va r vcmn_int egrationSt atus = Xrm .Page.getA ttribute(' ftp_integr ationstatu s').getVal ue(); | |
| 1158 | if (vcmn_int egrationSt atus == 'O K') { retu rn false; } | |
| 1159 | ||
| 1160 | // Prompt use r to sign the note | |
| 1161 | va r vcmn_sig nThisNote = Xrm.Page .getAttrib ute('ftp_s ignthisnot e').getVal ue(); | |
| 1162 | va r vcmn_sig nThisNoteF ailure = f alse; | |
| 1163 | if (vcmn_sig nThisNote == null) { | |
| 1164 | Xrm.Util ity.confir mDialog( | |
| 1165 | "Do you need t o sign thi s note?, S elect OK i f Yes, oth erwise CAN CEL.", | |
| 1166 | func tion () { | |
| 1167 | //Check if VIA Login cookie ex ist (not e xpired) | |
| 1168 | var vcmn_V iaLoginCoo kie = vcmn _getCookie ("viasessi onlink"); | |
| 1169 | //Prompt u ser to log in to VIA | |
| 1170 | if (vcmn_V iaLoginCoo kie == "") { | |
| 1171 | alert( "Your VIST A session has expire d. In orde r to sign this note, you must be logged into VISTA !"); | |
| 1172 | Xrm.Pa ge.ui.tabs .get('Tab_ VistALogin ').setVisi ble(true); | |
| 1173 | Xrm.Pa ge.ui.tabs .get('Tab_ VistALogin ').setFocu s(); | |
| 1174 | vcmn_s ignThisNot eFailure = true; | |
| 1175 | return ; | |
| 1176 | } | |
| 1177 | Xrm.Page.g etAttribut e('ftp_sig nthisnote' ).setValue (100000001 ); | |
| 1178 | }, | |
| 1179 | func tion () { | |
| 1180 | Xrm.Page.g etAttribut e('ftp_sig nthisnote' ).setValue (100000000 ); | |
| 1181 | } | |
| 1182 | ); | |
| 1183 | Xrm.Page .getAttrib ute('ftp_s ignthisnot e').setSub mitMode('a lways'); | |
| 1184 | } | |
| 1185 | ||
| 1186 | // Check for additional signers, if they ex ist, the u ser must b e logged i nto VIA to continue process. | |
| 1187 | // Additional Signature s must als o be in sy nc with ma tching Ses sion varia bles | |
| 1188 | ||
| 1189 | vc mn_AddlSig nersNameAr ray = null ; | |
| 1190 | vc mn_AddlSig nersIenArr ay = null; | |
| 1191 | ||
| 1192 | va r vcmn_sel ectedSigne rs = Xrm.P age.getAtt ribute('ft p_selected signers'). getValue() ; | |
| 1193 | if (vcmn_sel ectedSigne rs != null && vcmn_s electedSig ners != '' ) { | |
| 1194 | //Additi onal Signe rs exist i n CRM, ver ify sessio n variable s | |
| 1195 | var vcmn _selectedA rray = vcm n_selected Signers.sp lit('~~~') ; | |
| 1196 | var vcmn _selectedA rrayRecord Count = vc mn_selecte dArray.len gth; | |
| 1197 | if (vcmn _selectedA rrayRecord Count > 1) { | |
| 1198 | vcmn _AddlSigne rsNameArra y = vcmn_s electedArr ay; | |
| 1199 | } | |
| 1200 | ||
| 1201 | var vcmn _selectedI ENArray = ''; | |
| 1202 | var vcmn _selectedI ENArrayRec ordCount = 0; | |
| 1203 | var vcmn _progressN oteId = Xr m.Page.dat a.entity.g etId(); | |
| 1204 | ||
| 1205 | var vcmn _arrayMism atch = fal se; | |
| 1206 | ||
| 1207 | //Get No te's Brows er Local S torage Val ues | |
| 1208 | if (vcmn _progressN oteId != n ull && vcm n_progress NoteId != '') { | |
| 1209 | vcmn _localStor ageVarName = "PN" + vcmn_progr essNoteId; | |
| 1210 | var vcmn_local StorageStr ingValue = localStor age.getIte m(vcmn_loc alStorageV arName); | |
| 1211 | if ( vcmn_local StorageStr ingValue ! = null && vcmn_local StorageStr ingValue ! = '') { | |
| 1212 | vcmn_selec tedIENArra y = vcmn_l ocalStorag eStringVal ue.split(' ~~~'); | |
| 1213 | vcmn_selec tedIENArra yRecordCou nt = vcmn_ selectedIE NArray.len gth; | |
| 1214 | if (vcmn_s electedIEN ArrayRecor dCount > 1 ) { | |
| 1215 | vcmn_A ddlSigners IenArray = vcmn_sele ctedIENArr ay; | |
| 1216 | } | |
| 1217 | } | |
| 1218 | } | |
| 1219 | //Compar e CRM sign er array l ength with LocalStor age array length | |
| 1220 | if (vcmn _selectedA rrayRecord Count != v cmn_select edIENArray RecordCoun t) { vcmn_ arrayMisma tch = true ; } | |
| 1221 | ||
| 1222 | if (vcmn _arrayMism atch == tr ue) { | |
| 1223 | aler t("The cou nt of Addi tional Sig ners selec ted in CRM , does not match the count of Additional Signers i n VISTA!\n \nPlease r emove all the additi onal signe rs on this Progress Note and p erform the selection process a gain!\n\nT his note c annot be i ntegrated with VISTA /CPRS unti l this has been reso lved."); | |
| 1224 | vcmn _signThisN oteFailure = true; | |
| 1225 | } | |
| 1226 | else { | |
| 1227 | //Ch eck if VIA Login coo kie exist (not expir ed) | |
| 1228 | var vcmn_ViaLo ginCookie = vcmn_get Cookie("vi asessionli nk"); | |
| 1229 | if ( vcmn_ViaLo ginCookie == "") { | |
| 1230 | alert("You r VISTA se ssion has expired. I n order to process a note with additiona l signers, you must be logged into VISTA !"); | |
| 1231 | Xrm.Page.u i.tabs.get ('Tab_Vist ALogin').s etVisible( true); | |
| 1232 | Xrm.Page.u i.tabs.get ('Tab_Vist ALogin').s etFocus(); | |
| 1233 | vcmn_signT hisNoteFai lure = tru e; | |
| 1234 | return; | |
| 1235 | } | |
| 1236 | } | |
| 1237 | } | |
| 1238 | ||
| 1239 | // Check if m arked as a workload encounter and if so enforce VI A Login | |
| 1240 | if (Xrm.Page .getAttrib ute('ftp_i sworkloade ncounter') .getValue( ) == true) { | |
| 1241 | //Check if VIA Log in cookie exist (not expired) | |
| 1242 | var vcmn _ViaLoginC ookie = vc mn_getCook ie("viases sionlink") ; | |
| 1243 | if (vcmn _ViaLoginC ookie == " ") { | |
| 1244 | aler t("Your VI STA sessio n has expi red. In or der to pro cess a wor kload enco unter note , you must be logged into VIST A!"); | |
| 1245 | Xrm. Page.ui.ta bs.get('Ta b_VistALog in').setVi sible(true ); | |
| 1246 | Xrm. Page.ui.ta bs.get('Ta b_VistALog in').setFo cus(); | |
| 1247 | vcmn _signThisN oteFailure = true; | |
| 1248 | retu rn; | |
| 1249 | } | |
| 1250 | } | |
| 1251 | ||
| 1252 | if (vcmn_sig nThisNoteF ailure == true) { | |
| 1253 | //****** Developer Bypass for no VISTA authentica tion****** | |
| 1254 | if ((Xrm .Page.cont ext.getUse rId()).toU pperCase() == "{CA50 0504-CBC5- E511-8173- 000C2941CE 19}" || (X rm.Page.co ntext.getU serId()).t oUpperCase () == "{EB 21BC63-81B F-E511-942 C-0050568D 743D}") { | |
| 1255 | aler t("Develop er VISTA a uthenticat ion bypass applied!" ); | |
| 1256 | Xrm. Page.getAt tribute('f tp_signthi snote').se tValue(100 000001); | |
| 1257 | Xrm. Page.getAt tribute('f tp_signthi snote').se tSubmitMod e('always' ); | |
| 1258 | } | |
| 1259 | else { | |
| 1260 | retu rn false; | |
| 1261 | } | |
| 1262 | } | |
| 1263 | ||
| 1264 | // Save the c urrent CRM data | |
| 1265 | Xr m.Page.dat a.entity.s ave(); | |
| 1266 | // Display YE LLOW Progr ess.... | |
| 1267 | Xr m.Page.ui. setFormNot ification( "Verifying progress note data, please wa it..", "IN FO", "SAVE VISTA"); | |
| 1268 | ||
| 1269 | va r vcmn_con firmSaveTo Vista = co nfirm('Are you sure you want t o save thi s note to VistA/CPRS ?\nThis ac tion canno t be cance lled!\n\nU pon comple tion of th is process , the prog ress note will autom atically b e marked a s complete d and you will be pr ompted to exit the r ecord!'); | |
| 1270 | if (vcmn_con firmSaveTo Vista == f alse) { | |
| 1271 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 1272 | return f alse; | |
| 1273 | } | |
| 1274 | // Get regard ing data | |
| 1275 | va r vcmn_req uestId = X rm.Page.ge tAttribute ('regardin gobjectid' ).getValue (); | |
| 1276 | if (vcmn_req uestId == null) { | |
| 1277 | alert('T he current progress note does not have a related r equest ass igned in t he Regardi ng field, the note c annot be c reated in VistA/CPRS !'); | |
| 1278 | Xrm.Page .getContro l('regardi ngobjectid ').setFocu s(); | |
| 1279 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 1280 | return f alse; | |
| 1281 | } | |
| 1282 | // Verify tha t the rega rdingid is of type ' incident' | |
| 1283 | if (vcmn_req uestId[0]. entityType != 'incid ent') { | |
| 1284 | alert('T he current progress note has a n invalid regarding type, it m ust be of the type r equest/inc ident, the note cann ot be crea ted in Vis tA/CPRS!') ; | |
| 1285 | Xrm.Page .getContro l('regardi ngobjectid ').setFocu s(); | |
| 1286 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 1287 | return f alse; | |
| 1288 | } | |
| 1289 | ||
| 1290 | // Preserved Variables | |
| 1291 | va r vcmn_vet eranId = n ull; //Fr om request customeri d | |
| 1292 | va r vcmn_vet eranFirstN ame = ''; | |
| 1293 | va r vcmn_vet eranLastNa me = ''; | |
| 1294 | va r vcmn_SSN = ''; | |
| 1295 | va r vcmn_DOB = ''; | |
| 1296 | ||
| 1297 | va r vcmn_req uestData = vcmn_getS ingleEntit yDataSync( 'IncidentS et', 'Cust omerId', v cmn_reques tId[0].id) ; | |
| 1298 | if (vcmn_req uestData ! = null) { | |
| 1299 | if (vcmn _requestDa ta.d.Custo merId != n ull) { | |
| 1300 | vcmn _veteranId = vcmn_re questData. d.Customer Id; | |
| 1301 | //Ve rify that the custom erid is of type cont act | |
| 1302 | if ( vcmn_veter anId.Logic alName != 'contact') { | |
| 1303 | alert('The related r equest has an invali d customer type, it must be of the type veteran/co ntact, the note cann ot be crea ted in Vis tA/CPRS!') ; | |
| 1304 | Xrm.Page.u i.clearFor mNotificat ion("SAVEV ISTA"); | |
| 1305 | return fal se; | |
| 1306 | } | |
| 1307 | } | |
| 1308 | } | |
| 1309 | if (vcmn_vet eranId == null) { | |
| 1310 | alert('T he related request d oes not ha ve a veter an/contact assigned, the note cannot be created in VistA/CPR S!'); | |
| 1311 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 1312 | return f alse; | |
| 1313 | } | |
| 1314 | ||
| 1315 | va r vcmn_con tactData = vcmn_getS ingleEntit yDataSync( 'ContactSe t', 'First Name, Last Name, ftp_ DateofBirt h, Governm entId', vc mn_veteran Id.Id); | |
| 1316 | if (vcmn_con tactData ! = null) { | |
| 1317 | if (vcmn _contactDa ta.d.First Name != nu ll) { vcmn _veteranFi rstName = vcmn_conta ctData.d.F irstName; } | |
| 1318 | if (vcmn _contactDa ta.d.LastN ame != nul l) { vcmn_ veteranLas tName = vc mn_contact Data.d.Las tName; } | |
| 1319 | if (vcmn _contactDa ta.d.ftp_D ateofBirth != null) { vcmn_DOB = vcmn_co ntactData. d.ftp_Date ofBirth; } | |
| 1320 | if (vcmn _contactDa ta.d.Gover nmentId != null) { v cmn_SSN = vcmn_conta ctData.d.G overnmentI d; } | |
| 1321 | } | |
| 1322 | ||
| 1323 | // **WORKLOAD ENCOUNTER ** | |
| 1324 | vc mn_matchLo okupId = v cmn_SSN; | |
| 1325 | // ********** ********** *** | |
| 1326 | ||
| 1327 | // Perform MV I Search | |
| 1328 | vc mn_unatten dedMviSear ch(vcmn_ve teranFirst Name, vcmn _veteranLa stName, vc mn_DOB, vc mn_SSN); | |
| 1329 | } | |
| 1330 | catch (err) { | |
| 1331 | al ert('Progr ess Note R ibbon Func tion Error (vcmn_ribb onButtonSa veToVistA) : ' + err. message); | |
| 1332 | Xr m.Page.ui. clearFormN otificatio n("SAVEVIS TA"); | |
| 1333 | } | |
| 1334 | } | |
| 1335 | ||
| 1336 | function v cmn_ribbon ButtonSave ToVistA_wi th_ICN(vcm n_patientI CN) { | |
| 1337 | try { | |
| 1338 | // ******Deve loper Bypa ss for mis sing ICN** **** | |
| 1339 | if (vcmn_pat ientICN == '' || vcm n_patientI CN == null ) { | |
| 1340 | if ((Xrm .Page.cont ext.getUse rId()).toU pperCase() == "{CA50 0504-CBC5- E511-8173- 000C2941CE 19}") { | |
| 1341 | aler t("Develop er ICN byp ass applie d!"); | |
| 1342 | vcmn _patientIC N = "12345 6V123456"; | |
| 1343 | } | |
| 1344 | } | |
| 1345 | ||
| 1346 | // Verify Pat ient ICN | |
| 1347 | if (vcmn_pat ientICN == '' || vcm n_patientI CN == null ) { | |
| 1348 | alert('T he assigne d veteran does not h ave a pati ent ICN, t he note ca nnot be cr eated in V istA/CPRS! '); | |
| 1349 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 1350 | return f alse; | |
| 1351 | } | |
| 1352 | ||
| 1353 | // Get regard ing data | |
| 1354 | va r vcmn_req uestId = X rm.Page.ge tAttribute ('regardin gobjectid' ).getValue (); | |
| 1355 | ||
| 1356 | // Preserved Variables | |
| 1357 | va r vcmn_vet eranId = n ull; //Fr om request customeri d | |
| 1358 | va r vcmn_vet eranName = ''; | |
| 1359 | va r vcmn_vet eranFirstN ame = ''; | |
| 1360 | va r vcmn_vet eranLastNa me = ''; | |
| 1361 | va r vcmn_vet eranMiddle Name = ''; | |
| 1362 | ||
| 1363 | va r vcmn_req uestData = vcmn_getS ingleEntit yDataSync( 'IncidentS et', 'Cust omerId', v cmn_reques tId[0].id) ; | |
| 1364 | if (vcmn_req uestData ! = null) { | |
| 1365 | if (vcmn _requestDa ta.d.Custo merId != n ull) { | |
| 1366 | vcmn _veteranId = vcmn_re questData. d.Customer Id; | |
| 1367 | //Ve rify that the custom erid is of type cont act | |
| 1368 | if ( vcmn_veter anId.Logic alName != 'contact') { | |
| 1369 | alert('The related r equest has an invali d customer type, it must be of the type veteran/co ntact, the note cann ot be crea ted in Vis tA/CPRS!') ; | |
| 1370 | Xrm.Page.u i.clearFor mNotificat ion("SAVEV ISTA"); | |
| 1371 | return fal se; | |
| 1372 | } | |
| 1373 | } | |
| 1374 | } | |
| 1375 | if (vcmn_vet eranId == null) { | |
| 1376 | alert('T he related request d oes not ha ve a veter an/contact assigned, the note cannot be created in VistA/CPR S!'); | |
| 1377 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 1378 | return f alse; | |
| 1379 | } | |
| 1380 | ||
| 1381 | va r vcmn_con tactData = vcmn_getS ingleEntit yDataSync( 'ContactSe t', 'FullN ame, First Name, Last Name, Midd leName', v cmn_vetera nId.Id); | |
| 1382 | if (vcmn_con tactData ! = null) { | |
| 1383 | if (vcmn _contactDa ta.d.FullN ame != nul l) { vcmn_ veteranNam e = vcmn_c ontactData .d.FullNam e; } | |
| 1384 | if (vcmn _contactDa ta.d.First Name != nu ll) { vcmn _veteranFi rstName = vcmn_conta ctData.d.F irstName; } | |
| 1385 | if (vcmn _contactDa ta.d.LastN ame != nul l) { vcmn_ veteranLas tName = vc mn_contact Data.d.Las tName; } | |
| 1386 | if (vcmn _contactDa ta.d.Middl eName != n ull) { vcm n_veteranM iddleName = vcmn_con tactData.d .MiddleNam e; } | |
| 1387 | } | |
| 1388 | ||
| 1389 | // Get user d ata | |
| 1390 | va r vcmn_crm UserId = X rm.Page.ge tAttribute ('ownerid' ).getValue (); | |
| 1391 | va r vcmn_use rDomainId = ''; | |
| 1392 | va r vcmn_use rFirstName = ''; | |
| 1393 | va r vcmn_use rLastName = ''; | |
| 1394 | va r vcmn_use rMiddleNam e = ''; | |
| 1395 | va r vcmn_use rSiteId = ''; | |
| 1396 | ||
| 1397 | if (vcmn_crm UserId != null) { | |
| 1398 | //Verify the owner type | |
| 1399 | if (vcmn _crmUserId [0].entity Type != 's ystemuser' ) { | |
| 1400 | aler t('The pro gress note owner mus t be an in dividual u ser and no t a team, the note c annot be c reated in VistA/CPRS !'); | |
| 1401 | Xrm. Page.ui.cl earFormNot ification( "SAVEVISTA "); | |
| 1402 | retu rn false; | |
| 1403 | } | |
| 1404 | ||
| 1405 | var vcmn _userData = vcmn_get SingleEnti tyDataSync ('SystemUs erSet', 'D omainName, FirstName , LastName , MiddleNa me, ftp_Fa cilitySite Id', vcmn_ crmUserId[ 0].id); | |
| 1406 | if (vcmn _userData != null) { | |
| 1407 | if ( vcmn_userD ata.d.Doma inName != null) { vc mn_userDom ainId = vc mn_userDat a.d.Domain Name; } | |
| 1408 | if ( vcmn_userD ata.d.Firs tName != n ull) { vcm n_userFirs tName = vc mn_userDat a.d.FirstN ame; } | |
| 1409 | if ( vcmn_userD ata.d.Last Name != nu ll) { vcmn _userLastN ame = vcmn _userData. d.LastName ; } | |
| 1410 | if ( vcmn_userD ata.d.Midd leName != null) { vc mn_userMid dleName = vcmn_userD ata.d.Midd leName; } | |
| 1411 | if ( vcmn_userD ata.d.ftp_ FacilitySi teId != nu ll) { vcmn _userSiteI d = vcmn_u serData.d. ftp_Facili tySiteId.I d; } | |
| 1412 | } | |
| 1413 | } | |
| 1414 | el se { | |
| 1415 | alert('U nable to v erify the user accou nt for the current a uthor/owne r assigned to this n ote, the n ote cannot be create d in VistA /CPRS!'); | |
| 1416 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 1417 | return f alse; | |
| 1418 | } | |
| 1419 | ||
| 1420 | // Verify tha t the curr ent owner and the cu rrent user is the sa me person, if not do not proce ed | |
| 1421 | if ((vcmn_cr mUserId[0] .id).toUpp erCase() ! = (Xrm.Pag e.context. getUserId( )).toUpper Case()) { | |
| 1422 | alert('T he current author/ow ner does n ot match t he current CRM user, the note cannot be created in VistA/CPR S!'); | |
| 1423 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 1424 | return f alse; | |
| 1425 | } | |
| 1426 | va r vcmn_Not eUserTeam = "NONE"; | |
| 1427 | // Check Team membershi p | |
| 1428 | if (vcmn_Use rHasTeam(" Pharmacy", Xrm.Page. context.ge tUserId()) ) { vcmn_N oteUserTea m = "PHARM ACY"; } | |
| 1429 | if (vcmn_Use rHasTeam(" CCA Team", Xrm.Page. context.ge tUserId()) ) { vcmn_N oteUserTea m = "CCA"; } | |
| 1430 | if (vcmn_Use rHasTeam(" TAN", Xrm. Page.conte xt.getUser Id())) { v cmn_NoteUs erTeam = " TAN"; } | |
| 1431 | // **TEMP, ve rify these team valu es that th ey are cor rect **FUT URE NEED** | |
| 1432 | if (vcmn_Use rHasTeam(" PACT User" , Xrm.Page .context.g etUserId() )) { vcmn_ NoteUserTe am = "PACT "; } | |
| 1433 | if (vcmn_Use rHasTeam(" MSA User", Xrm.Page. context.ge tUserId()) ) { vcmn_N oteUserTea m = "MSA"; } | |
| 1434 | ||
| 1435 | // Verify Tea m Value, t hat one ha s been ass igned | |
| 1436 | if (vcmn_Not eUserTeam == "NONE") { | |
| 1437 | alert('T he current author/ow ner does n ot belong to a CRM t eam that c an integra te notes, the note c annot be c reated in VistA/CPRS !'); | |
| 1438 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 1439 | return f alse; | |
| 1440 | } | |
| 1441 | ||
| 1442 | // Get reques t form con tent | |
| 1443 | va r vcmn_not eDescripti on = Xrm.P age.getAtt ribute('ft p_notedeta il').getVa lue(); | |
| 1444 | if (vcmn_not eDescripti on == null || vcmn_n oteDescrip tion == '' ) { | |
| 1445 | alert('T he note de scription field is e mpty, the note canno t be creat ed in Vist A/CPRS!'); | |
| 1446 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 1447 | return f alse; | |
| 1448 | } | |
| 1449 | ||
| 1450 | if (Xrm.Page .getAttrib ute('ftp_i sworkloade ncounter') .getValue( ) != true) { | |
| 1451 | //Using new hospit al locatio n and loca l notes lo okup field s | |
| 1452 | var vcmn _localTitl e = Xrm.Pa ge.getAttr ibute('ftp _localnote title').ge tValue(); | |
| 1453 | if (vcmn _localTitl e == null) { | |
| 1454 | aler t('The loc al note ti tle field is empty, the note c annot be c reated in VistA/CPRS !'); | |
| 1455 | Xrm. Page.ui.cl earFormNot ification( "SAVEVISTA "); | |
| 1456 | retu rn false; | |
| 1457 | } | |
| 1458 | else { v cmn_localT itle = vcm n_localTit le[0].name ; } | |
| 1459 | ||
| 1460 | vcmn_pat ientAssign edLocation = Xrm.Pag e.getAttri bute('ftp_ notehospit allocation ').getValu e(); | |
| 1461 | if (vcmn _patientAs signedLoca tion == nu ll) { | |
| 1462 | aler t('The hos pital loca tion field is empty, the note cannot be created in VistA/CPR S!'); | |
| 1463 | Xrm. Page.ui.cl earFormNot ification( "SAVEVISTA "); | |
| 1464 | retu rn false; | |
| 1465 | } | |
| 1466 | else { v cmn_patien tAssignedL ocation = vcmn_patie ntAssigned Location[0 ].name; } | |
| 1467 | } | |
| 1468 | ||
| 1469 | va r vcmn_cal lbackNumbe r = Xrm.Pa ge.getAttr ibute('ftp _callbackn umber').ge tValue(); | |
| 1470 | if (vcmn_cal lbackNumbe r == null || vcmn_ca llbackNumb er == '') { | |
| 1471 | alert('T he callbac k number f ield is em pty, the n ote cannot be create d in VistA /CPRS!'); | |
| 1472 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 1473 | return f alse; | |
| 1474 | } | |
| 1475 | va r vcmn_rea sonForRequ est = Xrm. Page.getAt tribute('f tp_reasonf orrequest' ).getValue (); | |
| 1476 | if (vcmn_rea sonForRequ est == nul l) { | |
| 1477 | alert('T he reason for reques t field is empty, th e note can not be cre ated in Vi stA/CPRS!' ); | |
| 1478 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 1479 | return f alse; | |
| 1480 | } | |
| 1481 | ||
| 1482 | va r vcmn_enc ounterCode = 'NEW'; | |
| 1483 | ||
| 1484 | va r vcmn_sig nThisNote = Xrm.Page .getAttrib ute('ftp_s ignthisnot e').getVal ue(); | |
| 1485 | if (vcmn_sig nThisNote == 1000000 01) { vcmn _signThisN ote = true ; } else { vcmn_sign ThisNote = false; } | |
| 1486 | ||
| 1487 | // Get Progre ss Note Gu id/Id | |
| 1488 | va r vcmn_not eId = Xrm. Page.data. entity.get Id(); | |
| 1489 | ||
| 1490 | // Get Create d On Date & Convert format | |
| 1491 | va r vcmn_cre atedOnDate = vcmn_co nvertCrmDa teToVistAD ate(Xrm.Pa ge.getAttr ibute('cre atedon').g etValue()) ; | |
| 1492 | if (vcmn_cre atedOnDate == null) { | |
| 1493 | alert('T he CRM cre atedon fie ld is empt y, the not e cannot b e created in VistA/C PRS!'); | |
| 1494 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 1495 | return f alse; | |
| 1496 | } | |
| 1497 | ||
| 1498 | // Get User E ntry Date | |
| 1499 | va r vcmn_use rEntryDate = vcmn_co nvertCrmDa teToVistAD ate(Xrm.Pa ge.getAttr ibute('ftp _userentry date').get Value()); | |
| 1500 | if (vcmn_use rEntryDate == null) { vcmn_use rEntryDate = vcmn_cr eatedOnDat e; } | |
| 1501 | ||
| 1502 | // Get Facili ty and loo kup facili ty number and HL7 UR L | |
| 1503 | va r vcmn_fac ilityCode = ''; | |
| 1504 | va r vcmn_sit eHL7Listen erAddress = ''; | |
| 1505 | va r vcmn_pat ientFacili ty = Xrm.P age.getAtt ribute('ft p_patientf acility'). getValue() ; | |
| 1506 | if (vcmn_pat ientFacili ty == null ) { | |
| 1507 | alert('T he CRM pat ient facil ity field is empty, the note c annot be c reated in VistA/CPRS !'); | |
| 1508 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 1509 | return f alse; | |
| 1510 | } | |
| 1511 | el se { | |
| 1512 | var vcmn _facilityD ata = vcmn _getSingle EntityData Sync('ftp_ facilitySe t', 'ftp_f acilitycod e, ftp_hl7 listener', vcmn_pati entFacilit y[0].id); | |
| 1513 | if (vcmn _facilityD ata.d.ftp_ facilityco de != null ) { | |
| 1514 | vcmn _facilityC ode = vcmn _facilityD ata.d.ftp_ facilityco de; | |
| 1515 | } | |
| 1516 | else { | |
| 1517 | aler t('The CRM patient f acility co de is miss ing in the Facility setup, the note cann ot be crea ted in Vis tA/CPRS!') ; | |
| 1518 | Xrm. Page.ui.cl earFormNot ification( "SAVEVISTA "); | |
| 1519 | retu rn false; | |
| 1520 | } | |
| 1521 | ||
| 1522 | if (vcmn _facilityD ata.d.ftp_ hl7listene r != null) { | |
| 1523 | var vcmn_siteH L7Listener Address = vcmn_facil ityData.d. ftp_hl7lis tener; | |
| 1524 | } | |
| 1525 | else { | |
| 1526 | aler t('The CRM HL7 liste ner addres s is missi ng in the Facility s etup, the note canno t be creat ed in Vist A/CPRS!'); | |
| 1527 | Xrm. Page.ui.cl earFormNot ification( "SAVEVISTA "); | |
| 1528 | retu rn false; | |
| 1529 | } | |
| 1530 | } | |
| 1531 | ||
| 1532 | va r vcmn_ori ginatorID = ''; | |
| 1533 | va r vcmn_use rSiteNo = ''; | |
| 1534 | ||
| 1535 | // Lookup the Facility/ Site # | |
| 1536 | if (vcmn_use rSiteId != null && v cmn_userSi teId != '' ) { | |
| 1537 | var vcmn _facilityD ata = vcmn _getSingle EntityData Sync('ftp_ facilitySe t', 'ftp_f acilitycod e', vcmn_u serSiteId) ; | |
| 1538 | if (vcmn _facilityD ata != nul l) { | |
| 1539 | if ( vcmn_facil ityData.d. ftp_facili tycode != null) { vc mn_userSit eNo = vcmn _facilityD ata.d.ftp_ facilityco de; } | |
| 1540 | } | |
| 1541 | } | |
| 1542 | ||
| 1543 | // Validate r equired Vi sta Lookup info | |
| 1544 | if (vcmn_use rSiteNo == '' || vcm n_userSite No == null || vcmn_u serFirstNa me == '' | | vcmn_use rFirstName == null | | vcmn_use rLastName == '' || v cmn_userLa stName == null) { | |
| 1545 | //Abort process, m issing inf o | |
| 1546 | alert('O ne of the following required C RM user da ta fields are missin g: Facilty No, First Name or L ast Name, the note c annot be c reated in VistA/CPRS !'); | |
| 1547 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 1548 | return f alse; | |
| 1549 | } | |
| 1550 | ||
| 1551 | if (Xrm.Page .getAttrib ute('ftp_i sworkloade ncounter') .getValue( ) != true) { | |
| 1552 | if (vcmn _IsProduct ionEnviron ment == fa lse) { | |
| 1553 | //Pr ovide the option to search for Lori Nich olls, site # 613 | |
| 1554 | var vcmn_imper sonateProm ptString = "**THIS I S A VISTA USER SEARC H TEST PRO MPT** \n" + | |
| 1555 | "If you wo uld like t o imperson ate the us er: \n" + | |
| 1556 | "Lori Nich olls (613) \n" + | |
| 1557 | "Select OK . Otherwi se, select CANCEL."; | |
| 1558 | var vcmn_confi rmImperson ateVistaUs er = confi rm(vcmn_im personateP romptStrin g); | |
| 1559 | if ( vcmn_confi rmImperson ateVistaUs er == true ) { | |
| 1560 | vcmn_userF irstName = "Lori"; | |
| 1561 | vcmn_userL astName = "Nicholls" ; | |
| 1562 | vcmn_userS iteNo = "6 13"; | |
| 1563 | } | |
| 1564 | } | |
| 1565 | ||
| 1566 | var vcmn _vistauser sData = vc mn_getVist aUsersData (vcmn_user FirstName, vcmn_user LastName, vcmn_userS iteNo, fal se); | |
| 1567 | ||
| 1568 | //Check vista user s data con tent | |
| 1569 | if (vcmn _vistauser sData == n ull || vcm n_vistause rsData.Dat a == null || vcmn_vi stausersDa ta.Data.le ngth == nu ll || vcmn _vistauser sData.Data .length == 0) { | |
| 1570 | //Ab ort proces s, missing info | |
| 1571 | aler t('Unable to obtain Vista User Data, the note cann ot be crea ted in Vis tA/CPRS!') ; | |
| 1572 | Xrm. Page.ui.cl earFormNot ification( "SAVEVISTA "); | |
| 1573 | retu rn false; | |
| 1574 | } | |
| 1575 | ||
| 1576 | var vcmn _selectedU serFirstNa me = ''; | |
| 1577 | var vcmn _selectedU serMiddleN ame = ''; | |
| 1578 | var vcmn _selectedU serLastNam e = ''; | |
| 1579 | var vcmn _selectedU serSuffix = ''; | |
| 1580 | var vcmn _selectedU serDisplay Name = ''; | |
| 1581 | var vcmn _selectedU serTitle = ''; | |
| 1582 | var vcmn _userIsSel ected = fa lse; | |
| 1583 | ||
| 1584 | if (vcmn _vistauser sData.Data .length > 1) { | |
| 1585 | aler t("The Vis ta User li st, contai ns more th an one use r, please select the Vista Use r you want to use fr om the nex t prompt(s ), a total of " + vc mn_vistaus ersData.Da ta.length + " users! "); | |
| 1586 | for (var i = 0 ; i <= vcm n_vistause rsData.Dat a.length - 1; i++) { | |
| 1587 | var vcmn_c urrentUser FirstName = ''; | |
| 1588 | var vcmn_c urrentUser MiddleName = ''; | |
| 1589 | var vcmn_c urrentUser LastName = ''; | |
| 1590 | var vcmn_c urrentUser Suffix = ' '; | |
| 1591 | var vcmn_c urrentUser DisplayNam e = ''; | |
| 1592 | var vcmn_c urrentUser Title = '' ; | |
| 1593 | if (vcmn_v istausersD ata.Data[i ].FirstNam e != null) { vcmn_cu rrentUserF irstName = vcmn_vist ausersData .Data[i].F irstName; } | |
| 1594 | if (vcmn_v istausersD ata.Data[i ].MiddleNa me != null ) { vcmn_c urrentUser MiddleName = vcmn_vi stausersDa ta.Data[i] .MiddleNam e; } | |
| 1595 | if (vcmn_v istausersD ata.Data[i ].LastName != null) { vcmn_cur rentUserLa stName = v cmn_vistau sersData.D ata[i].Las tName; } | |
| 1596 | if (vcmn_v istausersD ata.Data[i ].Suffix ! = null) { vcmn_curre ntUserSuff ix = vcmn_ vistausers Data.Data[ i].Suffix; } | |
| 1597 | if (vcmn_v istausersD ata.Data[i ].DisplayN ame != nul l) { vcmn_ currentUse rDisplayNa me = vcmn_ vistausers Data.Data[ i].Display Name; } | |
| 1598 | if (vcmn_v istausersD ata.Data[i ].Title != null) { v cmn_curren tUserTitle = vcmn_vi stausersDa ta.Data[i] .Title; } | |
| 1599 | //Prompt u ser about this vista user reco rd | |
| 1600 | var vcmn_u serPromptS tring = "C lick OK, t o select t his user. Otherwise CANCEL \n " + | |
| 1601 | "\n Fi rst Name: " + vcmn_c urrentUser FirstName + | |
| 1602 | "\n Mi ddle Name: " + vcmn_ currentUse rMiddleNam e + | |
| 1603 | "\n La st Name: " + vcmn_cu rrentUserL astName + | |
| 1604 | "\n Su ffix: " + vcmn_curre ntUserSuff ix + | |
| 1605 | "\n Di splay Name : " + vcmn _currentUs erDisplayN ame + | |
| 1606 | "\n Ti tle: " + v cmn_curren tUserTitle ; | |
| 1607 | ||
| 1608 | var vcmn_c onfirmSele ctVistaUse r = confir m(vcmn_use rPromptStr ing); | |
| 1609 | if (vcmn_c onfirmSele ctVistaUse r == true) { | |
| 1610 | vcmn_u serIsSelec ted = true ; | |
| 1611 | vcmn_s electedUse rFirstName = vcmn_cu rrentUserF irstName; | |
| 1612 | vcmn_s electedUse rMiddleNam e = vcmn_c urrentUser MiddleName ; | |
| 1613 | vcmn_s electedUse rLastName = vcmn_cur rentUserLa stName; | |
| 1614 | vcmn_s electedUse rSuffix = vcmn_curre ntUserSuff ix; | |
| 1615 | vcmn_s electedUse rDisplayNa me = vcmn_ currentUse rDisplayNa me; | |
| 1616 | vcmn_s electedUse rTitle = v cmn_curren tUserTitle ; | |
| 1617 | break; | |
| 1618 | } | |
| 1619 | } | |
| 1620 | } | |
| 1621 | else { | |
| 1622 | //Se lect data from the f irst recor d | |
| 1623 | vcmn _userIsSel ected = tr ue; | |
| 1624 | if ( vcmn_vista usersData. Data[0].Fi rstName != null) { v cmn_select edUserFirs tName = vc mn_vistaus ersData.Da ta[0].Firs tName; } | |
| 1625 | if ( vcmn_vista usersData. Data[0].Mi ddleName ! = null) { vcmn_selec tedUserMid dleName = vcmn_vista usersData. Data[0].Mi ddleName; } | |
| 1626 | if ( vcmn_vista usersData. Data[0].La stName != null) { vc mn_selecte dUserLastN ame = vcmn _vistauser sData.Data [0].LastNa me; } | |
| 1627 | if ( vcmn_vista usersData. Data[0].Su ffix != nu ll) { vcmn _selectedU serSuffix = vcmn_vis tausersDat a.Data[0]. Suffix; } | |
| 1628 | if ( vcmn_vista usersData. Data[0].Di splayName != null) { vcmn_sele ctedUserDi splayName = vcmn_vis tausersDat a.Data[0]. DisplayNam e; } | |
| 1629 | if ( vcmn_vista usersData. Data[0].Ti tle != nul l) { vcmn_ selectedUs erTitle = vcmn_vista usersData. Data[0].Ti tle; } | |
| 1630 | } | |
| 1631 | ||
| 1632 | //Check if a user was select ed | |
| 1633 | if (vcmn _userIsSel ected == f alse) { | |
| 1634 | aler t('A user was not se lected fro m the prev ious promp ts, the no te cannot be created in VistA/ CPRS!'); | |
| 1635 | Xrm. Page.ui.cl earFormNot ification( "SAVEVISTA "); | |
| 1636 | retu rn false; | |
| 1637 | } | |
| 1638 | ||
| 1639 | //Execut e Integrat ion | |
| 1640 | vcmn_exe cuteVistAI ntegration Request(vc mn_noteId, vcmn_note Descriptio n, vcmn_pa tientICN, vcmn_userD omainId, v cmn_localT itle, vcmn _callbackN umber, vcm n_reasonFo rRequest[0 ].name, vc mn_encount erCode, vc mn_signThi sNote, vcm n_veteranF irstName, vcmn_veter anLastName , vcmn_use rEntryDate , vcmn_cre atedOnDate , vcmn_sel ectedUserF irstName, vcmn_selec tedUserMid dleName, v cmn_select edUserLast Name, vcmn _selectedU serSuffix, vcmn_faci lityCode, vcmn_origi natorID, v cmn_siteHL 7ListenerA ddress, vc mn_patient AssignedLo cation); | |
| 1641 | ||
| 1642 | } | |
| 1643 | el se { | |
| 1644 | //Execut e workload encounter note inte gration st eps | |
| 1645 | vcmn_pre pWorkloadE ncounterIn tegrationS tep01(); | |
| 1646 | } | |
| 1647 | } | |
| 1648 | catch (err) { | |
| 1649 | al ert('Progr ess Note R ibbon Func tion Error (vcmn_ribb onButtonSa veToVistA_ with_ICN): ' + err.m essage); | |
| 1650 | Xr m.Page.ui. clearFormN otificatio n("SAVEVIS TA"); | |
| 1651 | } | |
| 1652 | } | |
| 1653 | ||
| 1654 | function v cmn_prepWo rkloadEnco unterInteg rationStep 01() { | |
| 1655 | try { | |
| 1656 | // Verify Not e Title | |
| 1657 | va r vcmn_Not eTitleIEN = Xrm.Page .getAttrib ute('ftp_s electedwor kloadnotet itleid').g etValue(); | |
| 1658 | if (vcmn_Not eTitleIEN == null || vcmn_Note TitleIEN = = '') { | |
| 1659 | alert('T he selecte d note tit le field i s empty, t he note ca nnot be cr eated in V istA/CPRS! '); | |
| 1660 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 1661 | return f alse; | |
| 1662 | } | |
| 1663 | // Verify Loc ation | |
| 1664 | va r vcmn_Loc ationIEN = Xrm.Page. getAttribu te('ftp_se lectedwork loadlocati onid').get Value(); | |
| 1665 | if (vcmn_Loc ationIEN = = null || vcmn_Locat ionIEN == '') { | |
| 1666 | alert('T he selecte d location field is empty, the note cann ot be crea ted in Vis tA/CPRS!') ; | |
| 1667 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 1668 | return f alse; | |
| 1669 | } | |
| 1670 | // Verify pat ient id | |
| 1671 | if (vcmn_mat chLookupId == null | | vcmn_mat chLookupId == '') { | |
| 1672 | alert('T he veteran /patient d oes not ha ve a SSN, the note c annot be c reated in VistA/CPRS !'); | |
| 1673 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 1674 | return f alse; | |
| 1675 | } | |
| 1676 | ||
| 1677 | // Get the cu rrent CRM User's ass igned site /facility | |
| 1678 | va r vcmn_use rSiteId = ""; | |
| 1679 | ||
| 1680 | va r vcmn_use rData = vc mn_getSing leEntityDa taSync('Sy stemUserSe t', 'ftp_F acilitySit eId', Xrm. Page.conte xt.getUser Id()); | |
| 1681 | if (vcmn_use rData != n ull) { | |
| 1682 | if (vcmn _userData. d.ftp_Faci litySiteId != null) { | |
| 1683 | vcmn _userSiteI d = vcmn_u serData.d. ftp_Facili tySiteId.I d; | |
| 1684 | } | |
| 1685 | } | |
| 1686 | ||
| 1687 | // Lookup the Facility/ Site # | |
| 1688 | if (vcmn_use rSiteId != null && v cmn_userSi teId != '' ) { | |
| 1689 | var vcmn _facilityD ata = vcmn _getSingle EntityData Sync('ftp_ facilitySe t', 'ftp_f acilitycod e', vcmn_u serSiteId) ; | |
| 1690 | if (vcmn _facilityD ata != nul l) { | |
| 1691 | if ( vcmn_facil ityData.d. ftp_facili tycode != null) { vc mn_ViaLogi nFacility = vcmn_fac ilityData. d.ftp_faci litycode; } | |
| 1692 | } | |
| 1693 | } | |
| 1694 | ||
| 1695 | // Check if V IA Login c ookie exis t (not exp ired) | |
| 1696 | va r vcmn_Via LoginCooki e = vcmn_g etCookie(" viasession link"); | |
| 1697 | if (vcmn_Via LoginCooki e != null && vcmn_Vi aLoginCook ie != '') { | |
| 1698 | var vcmn _cookiearr ay = vcmn_ ViaLoginCo okie.split ("~~~~", 2 ); | |
| 1699 | vcmn_Via LoginToken = vcmn_co okiearray[ 0]; | |
| 1700 | vcmn_Via LoginName = vcmn_coo kiearray[1 ]; | |
| 1701 | } | |
| 1702 | el se { | |
| 1703 | alert("Y our VISTA session ha s expired. In order to process a workloa d encounte r note, yo u must be logged int o VISTA!") ; | |
| 1704 | Xrm.Page .ui.tabs.g et('Tab_Vi stALogin') .setVisibl e(true); | |
| 1705 | Xrm.Page .ui.tabs.g et('Tab_Vi stALogin') .setFocus( ); | |
| 1706 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 1707 | return; | |
| 1708 | } | |
| 1709 | ||
| 1710 | // Lookup Pat ient Id us ing VIA 'm atch' serv ice | |
| 1711 | vi alib_match (vcmn_requ estingApp, vcmn_cons umingAppTo ken, vcmn_ consumingA ppPassword , vcmn_bas eServiceEn dpointUrl, vcmn_ViaL oginName, vcmn_ViaLo ginToken, vcmn_ViaLo ginFacilit y, vcmn_ma tchLookupI d, vcmn_pr epWorkload EncounterI ntegration Step01_res ponse); | |
| 1712 | } | |
| 1713 | catch (err) { | |
| 1714 | al ert('Progr ess Note R ibbon Func tion Error (vcmn_prep WorkloadEn counterInt egrationSt ep01): ' + err.messa ge); | |
| 1715 | Xr m.Page.ui. clearFormN otificatio n("SAVEVIS TA"); | |
| 1716 | } | |
| 1717 | } | |
| 1718 | ||
| 1719 | function v cmn_prepWo rkloadEnco unterInteg rationStep 01_respons e(vcmn_err or, vcmn_m atchrespon se) { | |
| 1720 | try { | |
| 1721 | // Check for non VIA se rvice erro r | |
| 1722 | if (vcmn_err or != null ) { | |
| 1723 | alert("U nable to m atch the C RM Veteran /Patient w ith a reco rd in Vist A/CPRS. Th e process failed wit h error: " + vcmn_ma tchrespons e + ", the note cann ot be crea ted in Vis tA/CPRS!") ; | |
| 1724 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 1725 | return f alse; | |
| 1726 | } | |
| 1727 | el se { | |
| 1728 | //Test f or VIA Ser vice Error | |
| 1729 | if (vcmn _matchresp onse.getEl ementsByTa gName("fau lt").lengt h > 0) { | |
| 1730 | aler t("Unable to match t he CRM Vet eran/Patie nt with a record in Vista/CPRS . Service Error: " + vcmn_matc hresponse. getElement sByTagName ("fault")[ 0].textCon tent + ", the note c annot be c reated in VistA/CPRS !"); | |
| 1731 | Xrm. Page.ui.cl earFormNot ification( "SAVEVISTA "); | |
| 1732 | retu rn false; | |
| 1733 | } | |
| 1734 | //Get VI A service Response | |
| 1735 | if (vcmn _matchresp onse.getEl ementsByTa gName("pat ients")[0] ) { | |
| 1736 | var vcmn_match Array = vc mn_matchre sponse.get ElementsBy TagName("p atients")[ 0].childNo des; | |
| 1737 | //ch ildNodes[4 ] holds th e localPid /IEN value | |
| 1738 | vcmn _ViaPatien tId = vcmn _matchArra y[0].child Nodes[4].t extContent ; | |
| 1739 | } | |
| 1740 | else { | |
| 1741 | aler t("Unable to match t he CRM Vet eran/Patie nt with a record in Vista/CPRS . No data returned, the note c annot be c reated in VistA/CPRS !"); | |
| 1742 | Xrm. Page.ui.cl earFormNot ification( "SAVEVISTA "); | |
| 1743 | retu rn false; | |
| 1744 | } | |
| 1745 | } | |
| 1746 | ||
| 1747 | // Verify Inp atient | |
| 1748 | if (Xrm.Page .getAttrib ute('ftp_w orkloadinp atient').g etValue() == true) { | |
| 1749 | vcmn_Via InPatient = "1"; | |
| 1750 | } | |
| 1751 | el se { | |
| 1752 | vcmn_Via InPatient = "0"; | |
| 1753 | } | |
| 1754 | ||
| 1755 | // Verify CPT Code & De scription | |
| 1756 | va r vcmn_Crm CptCode = Xrm.Page.g etAttribut e('ftp_cpt code').get Value(); | |
| 1757 | if (vcmn_Crm CptCode == null) { | |
| 1758 | alert('T he CPT Cod e field is empty, th e note can not be cre ated in Vi stA/CPRS!' ); | |
| 1759 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 1760 | return f alse; | |
| 1761 | } | |
| 1762 | el se { | |
| 1763 | var vcmn _cptData = vcmn_getS ingleEntit yDataSync( 'ftp_cptco deSet', 'f tp_amadesc ription', vcmn_CrmCp tCode[0].i d); | |
| 1764 | if (vcmn _cptData.d .ftp_amade scription != null) { | |
| 1765 | vcmn _ViaCptDes cription = (vcmn_cpt Data.d.ftp _amadescri ption).rep lace(";", "\;"); | |
| 1766 | vcmn _ViaCptCod e = vcmn_C rmCptCode[ 0].name; | |
| 1767 | } | |
| 1768 | else { | |
| 1769 | aler t('The CPT Code is m issing the AMA Descr iption, th e note can not be cre ated in Vi stA/CPRS!' ); | |
| 1770 | Xrm. Page.ui.cl earFormNot ification( "SAVEVISTA "); | |
| 1771 | retu rn false; | |
| 1772 | } | |
| 1773 | } | |
| 1774 | ||
| 1775 | // Get eSigna ture code | |
| 1776 | va r vcmn_eSi gnatureCod e = prompt ("Please e nter your eSignature Code belo w.\nThis i s required to comple te the Wor kload Enco unter Note !"); | |
| 1777 | if (vcmn_eSi gnatureCod e == null || vcmn_eS ignatureCo de == "" | | vcmn_eSi gnatureCod e == "unde fined") { | |
| 1778 | alert('T he eSignat ure Code e ntered is invalid, t he note ca nnot be cr eated in V istA/CPRS! '); | |
| 1779 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 1780 | return f alse; | |
| 1781 | } | |
| 1782 | ||
| 1783 | // Get User E ntry Date | |
| 1784 | va r vcmn_cre atedOnDate = vialib_ convertToS tringDateT ime(Xrm.Pa ge.getAttr ibute('cre atedon').g etValue()) ; | |
| 1785 | va r vcmn_use rEntryDate = null; | |
| 1786 | if (Xrm.Page .getAttrib ute('ftp_u serentryda te').getVa lue() != n ull) { | |
| 1787 | vcmn_use rEntryDate = vialib_ convertToS tringDateT ime(Xrm.Pa ge.getAttr ibute('ftp _userentry date').get Value()); | |
| 1788 | } | |
| 1789 | if (vcmn_use rEntryDate == null) { vcmn_use rEntryDate = vcmn_cr eatedOnDat e; } | |
| 1790 | ||
| 1791 | // Reformat N ote Descri ption as n eeded to h andle long lines of text (Word Wrap) | |
| 1792 | va r vcmn_not eDescripti on = Xrm.P age.getAtt ribute('ft p_notedeta il').getVa lue(); | |
| 1793 | va r vcmn_Not eText = vc mn_noteDes cription; | |
| 1794 | va r vcmn_Rev isedNoteTe xt = ""; | |
| 1795 | // Do Breakdo wn of line s | |
| 1796 | va r vcmn_Tex tLines = v cmn_NoteTe xt.split(' \n'); | |
| 1797 | if (vcmn_Tex tLines.len gth > 0) { | |
| 1798 | //Reform at text | |
| 1799 | for (var i = 0; i < vcmn_Tex tLines.len gth; i++) { | |
| 1800 | //Te st for a l ong line | |
| 1801 | if ( vcmn_TextL ines[i].le ngth > vcm n_WordWrap Limit) { | |
| 1802 | //Break do wn line | |
| 1803 | var vcmn_N ewString = vcmn_word Wrap(vcmn_ TextLines[ i], vcmn_W ordWrapLim it, '\n'); | |
| 1804 | //Add revi sed text b ack | |
| 1805 | vcmn_Revis edNoteText = vcmn_Re visedNoteT ext + vcmn _NewString + "\n"; //Add back the CR/LF used to s plit on | |
| 1806 | } | |
| 1807 | else { | |
| 1808 | //Add text to new no te | |
| 1809 | vcmn_Revis edNoteText = vcmn_Re visedNoteT ext + vcmn _TextLines [i] + "\n" ; //Add ba ck the CR/ LF used to split on | |
| 1810 | } | |
| 1811 | } | |
| 1812 | } | |
| 1813 | if (vcmn_Rev isedNoteTe xt != "" & & vcmn_Rev isedNoteTe xt != null ) { | |
| 1814 | vcmn_not eDescripti on = vcmn_ RevisedNot eText; | |
| 1815 | } | |
| 1816 | ||
| 1817 | // Add list o f addition al signer names to N ote Text i f they exi sts | |
| 1818 | if (vcmn_Add lSignersNa meArray != null && v cmn_AddlSi gnersIenAr ray != nul l) { | |
| 1819 | //Create text stri ngs from a dditional signers ar ray | |
| 1820 | var vcmn _SignerNam es = "\nAd ditional N ote Signer s\n" + "-- ---------- ---------- -------\n" ; | |
| 1821 | for (var i = 0; i <= vcmn_Ad dlSignersN ameArray.l ength - 1; i++) { | |
| 1822 | if ( i >= 1) { | |
| 1823 | var vcmn_s ingleSigne rName = vc mn_AddlSig nersNameAr ray[i].spl it("___"); | |
| 1824 | vcmn_Signe rNames = v cmn_Signer Names + vc mn_singleS ignerName[ 1] + "\n"; | |
| 1825 | } | |
| 1826 | } | |
| 1827 | //Add to Note Desc ription | |
| 1828 | vcmn_not eDescripti on = vcmn_ noteDescri ption + vc mn_SignerN ames; | |
| 1829 | } | |
| 1830 | va r vcmn_Not eTitleIEN = Xrm.Page .getAttrib ute('ftp_s electedwor kloadnotet itleid').g etValue(); | |
| 1831 | va r vcmn_Loc ationIEN = Xrm.Page. getAttribu te('ftp_se lectedwork loadlocati onid').get Value(); | |
| 1832 | ||
| 1833 | // Create tex t strings from addit ional sign ers array | |
| 1834 | va r vcmn_Sig nerIEN = " "; | |
| 1835 | if (vcmn_Add lSignersIe nArray != null) { | |
| 1836 | for (var i = 0; i <= vcmn_Ad dlSignersI enArray.le ngth - 1; i++) { | |
| 1837 | if ( i == 1) { vcmn_Signe rIEN = vcm n_AddlSign ersIenArra y[i]; } | |
| 1838 | if ( i > 1) { v cmn_Signer IEN = vcmn _SignerIEN + "," + v cmn_AddlSi gnersIenAr ray[i]; } | |
| 1839 | } | |
| 1840 | } | |
| 1841 | ||
| 1842 | // Execute VI A saveNote AndEncount er Service | |
| 1843 | vi alib_saveN oteAndEnco unter(vcmn _requestin gApp, vcmn _consuming AppToken, vcmn_consu mingAppPas sword, vcm n_baseServ iceEndpoin tUrl, vcmn _ViaLoginN ame, vcmn_ ViaLoginTo ken, vcmn_ ViaLoginFa cility, vc mn_NoteTit leIEN, vcm n_Location IEN, vcmn_ ViaPatient Id, vcmn_n oteDescrip tion, vcmn _userEntry Date, vcmn _ViaLoginF acility, v cmn_ViaInP atient, vc mn_ViaCptC ode, vcmn_ ViaCptDesc ription, v cmn_eSigna tureCode, vcmn_Signe rIEN, 'E', vcmn_save NoteAndEnc ounter_res ponse) | |
| 1844 | } | |
| 1845 | catch (err) { | |
| 1846 | al ert('Progr ess Note R ibbon Func tion Error (vcmn_prep WorkloadEn counterInt egrationSt ep01_respo nse): ' + err.messag e); | |
| 1847 | Xr m.Page.ui. clearFormN otificatio n("SAVEVIS TA"); | |
| 1848 | } | |
| 1849 | } | |
| 1850 | ||
| 1851 | function v cmn_saveNo teAndEncou nter_respo nse(vcmn_e rrorThrown , vcmn_req uestRespon se, vcmn_n oteText) { | |
| 1852 | //Proc ess Note a nd Encount er Respons e | |
| 1853 | try { | |
| 1854 | if (vcmn_err orThrown ! = null) { | |
| 1855 | //Write Error | |
| 1856 | Xrm.Page .getAttrib ute('ftp_i ntegration status').s etValue('E RROR'); | |
| 1857 | Xrm.Page .getAttrib ute('ftp_i ntegration status').s etSubmitMo de('always '); | |
| 1858 | Xrm.Page .getAttrib ute('ftp_i ntegration error').se tValue(Str ing(vcmn_e rrorThrown )); | |
| 1859 | Xrm.Page .getAttrib ute('ftp_i ntegration error').se tSubmitMod e('always' ); | |
| 1860 | Xrm.Page .getAttrib ute('ftp_i ntegration date').set Value(new Date()); | |
| 1861 | Xrm.Page .getAttrib ute('ftp_i ntegration date').set SubmitMode ('always') ; | |
| 1862 | Xrm.Page .getAttrib ute('ftp_i ntegration noteid').s etValue('' ); | |
| 1863 | Xrm.Page .getAttrib ute('ftp_i ntegration noteid').s etSubmitMo de('always '); | |
| 1864 | alert('T he workloa d encounte r note cre ation in V istA/CPRS failed!\nP lease see the integr ation erro r field fo r details. '); | |
| 1865 | Xrm.Page .getContro l('ftp_int egrationer ror').setF ocus(); | |
| 1866 | Xrm.Page .data.enti ty.save(); | |
| 1867 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 1868 | return f alse; | |
| 1869 | } | |
| 1870 | el se { | |
| 1871 | //Write web servic e response Success o r Failure | |
| 1872 | if (vcmn _requestRe sponse.get ElementsBy TagName("f ault").len gth > 0) { | |
| 1873 | //Wr ite Failur e entry | |
| 1874 | Xrm. Page.getAt tribute('f tp_integra tionstatus ').setValu e('ERROR') ; | |
| 1875 | Xrm. Page.getAt tribute('f tp_integra tionstatus ').setSubm itMode('al ways'); | |
| 1876 | Xrm. Page.getAt tribute('f tp_integra tionerror' ).setValue ("Service Error: " + vcmn_requ estRespons e.getEleme ntsByTagNa me("fault" )[0].textC ontent); | |
| 1877 | Xrm. Page.getAt tribute('f tp_integra tionerror' ).setSubmi tMode('alw ays'); | |
| 1878 | Xrm. Page.getAt tribute('f tp_integra tiondate') .setValue( new Date() ); | |
| 1879 | Xrm. Page.getAt tribute('f tp_integra tiondate') .setSubmit Mode('alwa ys'); | |
| 1880 | Xrm. Page.getAt tribute('f tp_integra tionnoteid ').setValu e(''); | |
| 1881 | Xrm. Page.getAt tribute('f tp_integra tionnoteid ').setSubm itMode('al ways'); | |
| 1882 | aler t('The wor kload enco unter note creation in VistA/C PRS failed !\nPlease see the in tegration error fiel d for deta ils.'); | |
| 1883 | Xrm. Page.getCo ntrol('ftp _integrati onerror'). setFocus() ; | |
| 1884 | Xrm. Page.data. entity.sav e(); | |
| 1885 | Xrm. Page.ui.cl earFormNot ification( "SAVEVISTA "); | |
| 1886 | retu rn false; | |
| 1887 | } | |
| 1888 | else { | |
| 1889 | //Te st for dat a | |
| 1890 | if ( vcmn_reque stResponse .getElemen tsByTagNam e("ns2:sav eNoteAndEn counterRes ponse")[0] ) { | |
| 1891 | //Sucessfu ll creatio n of workl oad encoun ter note | |
| 1892 | Xrm.Page.g etAttribut e('ftp_not edetail'). setValue(v cmn_noteTe xt); | |
| 1893 | Xrm.Page.g etAttribut e('ftp_not edetail'). setSubmitM ode('alway s'); | |
| 1894 | Xrm.Page.g etAttribut e('ftp_int egrationst atus').set Value('OK' ); | |
| 1895 | Xrm.Page.g etAttribut e('ftp_int egrationst atus').set SubmitMode ('always') ; | |
| 1896 | Xrm.Page.g etAttribut e('ftp_int egrationer ror').setV alue(null) ; | |
| 1897 | Xrm.Page.g etAttribut e('ftp_int egrationer ror').setS ubmitMode( 'always'); | |
| 1898 | Xrm.Page.g etAttribut e('ftp_int egrationda te').setVa lue(new Da te()); | |
| 1899 | Xrm.Page.g etAttribut e('ftp_int egrationda te').setSu bmitMode(' always'); | |
| 1900 | Xrm.Page.g etAttribut e('ftp_int egrationno teid').set Value(vcmn _requestRe sponse.get ElementsBy TagName("n s2:saveNot eAndEncoun terRespons e")[0].tex tContent); | |
| 1901 | Xrm.Page.g etAttribut e('ftp_int egrationno teid').set SubmitMode ('always') ; | |
| 1902 | //****UPDA TE e-Sign attributes | |
| 1903 | Xrm.Page.g etAttribut e('ftp_iss igned').se tValue(tru e); | |
| 1904 | Xrm.Page.g etAttribut e('ftp_iss igned').se tSubmitMod e('always' ); | |
| 1905 | Xrm.Page.g etAttribut e('ftp_sig neddate'). setValue(n ew Date()) ; | |
| 1906 | Xrm.Page.g etAttribut e('ftp_sig neddate'). setSubmitM ode('alway s'); | |
| 1907 | //******** ********** ********** | |
| 1908 | Xrm.Page.g etControl( 'ftp_integ rationstat us').setFo cus(); | |
| 1909 | alert('The workload encounter note creat ion in Vis tA/CPRS wa s successf ul, this w orkload en counter no te will no w be marke d as compl eted. \n\n Please exi t this not e record a fter click ing OK to this promp t!'); | |
| 1910 | Xrm.Page.u i.clearFor mNotificat ion("SAVEV ISTA"); | |
| 1911 | Xrm.Page.d ata.entity .save(); | |
| 1912 | ||
| 1913 | if (vcmn_l ocalStorag eVarName ! = "" && vc mn_localSt orageVarNa me != null ) { | |
| 1914 | //Clea r existing session s torage var iable. | |
| 1915 | localS torage.rem oveItem(vc mn_localSt orageVarNa me); | |
| 1916 | } | |
| 1917 | } | |
| 1918 | else { | |
| 1919 | //Write No Data Fail ure | |
| 1920 | Xrm.Page.g etAttribut e('ftp_int egrationst atus').set Value('ERR OR'); | |
| 1921 | Xrm.Page.g etAttribut e('ftp_int egrationst atus').set SubmitMode ('always') ; | |
| 1922 | Xrm.Page.g etAttribut e('ftp_int egrationer ror').setV alue("Serv ice Error: NO DATA R ETURNED FR OM VIA/VIS TA REGARDI NG WORKLOA D WITH ENC OUNTER NOT E CREATION !"); | |
| 1923 | Xrm.Page.g etAttribut e('ftp_int egrationer ror').setS ubmitMode( 'always'); | |
| 1924 | Xrm.Page.g etAttribut e('ftp_int egrationda te').setVa lue(new Da te()); | |
| 1925 | Xrm.Page.g etAttribut e('ftp_int egrationda te').setSu bmitMode(' always'); | |
| 1926 | Xrm.Page.g etAttribut e('ftp_int egrationno teid').set Value(''); | |
| 1927 | Xrm.Page.g etAttribut e('ftp_int egrationno teid').set SubmitMode ('always') ; | |
| 1928 | alert('The workload encounter note creat ion in Vis tA/CPRS fa iled!\nPle ase see th e integrat ion error field for details.') ; | |
| 1929 | Xrm.Page.g etControl( 'ftp_integ rationerro r').setFoc us(); | |
| 1930 | Xrm.Page.d ata.entity .save(); | |
| 1931 | Xrm.Page.u i.clearFor mNotificat ion("SAVEV ISTA"); | |
| 1932 | return fal se; | |
| 1933 | } | |
| 1934 | } | |
| 1935 | } | |
| 1936 | } | |
| 1937 | catch (err) { | |
| 1938 | al ert('Progr ess Note R ibbon Func tion Error (vcmn_save NoteAndEnc ounter_res ponse): ' + err.mess age); | |
| 1939 | Xr m.Page.ui. clearFormN otificatio n("SAVEVIS TA"); | |
| 1940 | } | |
| 1941 | } | |
| 1942 | ||
| 1943 | function v cmn_getVis taUsersDat a(vcmn_use rFirstName , vcmn_use rLastName, vcmn_user SiteNo, vc mn_noFilte r) { | |
| 1944 | try { | |
| 1945 | va r vcmn_jso nData = nu ll; | |
| 1946 | $. ajax({ | |
| 1947 | type: "G ET", | |
| 1948 | url: vcm n_VistaUse rsURLbase + vcmn_use rFirstName + "/" + v cmn_userLa stName + " /" + vcmn_ userSiteNo + "?noFil ter=" + vc mn_noFilte r, | |
| 1949 | contentT ype: "appl ication/js on; charse t=utf-8", | |
| 1950 | dataType : "json", | |
| 1951 | success: function (data) { | |
| 1952 | vcmn _jsonData = data; | |
| 1953 | }, | |
| 1954 | error: f unction (j qXHR, text Status, er rorThrown) { | |
| 1955 | //Sy stem Error | |
| 1956 | vcmn _jsonData = null; | |
| 1957 | }, | |
| 1958 | async: f alse, | |
| 1959 | cache: f alse | |
| 1960 | }) ; | |
| 1961 | re turn vcmn_ jsonData; | |
| 1962 | } | |
| 1963 | catch (err) { | |
| 1964 | al ert('Progr ess Note R ibbon Func tion Error (vcmn_getV istaUsersD ata): ' + err.messag e); | |
| 1965 | re turn null; | |
| 1966 | } | |
| 1967 | } | |
| 1968 | ||
| 1969 | function v cmn_execut eVistAInte grationReq uest(vcmn_ noteId, vc mn_noteDes cription, vcmn_patie ntICN, vcm n_userDoma inId, vcmn _localTitl e, vcmn_ca llbackNumb er, vcmn_r easonForRe quest, vcm n_encounte rCode, vcm n_signThis Note, vcmn _patientFi rstName, v cmn_patien tLastName, vcmn_acti vityDate, vcmn_patie ntAdmitDat e, vcmn_or iginatorFi rstName, v cmn_origin atorMiddle Name, vcmn _originato rLastName, vcmn_orig inatorSuff ix, vcmn_f acilitySit eId, vcmn_ originator ID, vcmn_s iteHL7List enerAddres s, vcmn_pa tientAssig nedLocatio n) { | |
| 1970 | try { | |
| 1971 | // Reformat N ote Descri ption as n eeded to h andle long lines of text (Word Wrap) | |
| 1972 | va r vcmn_Not eText = vc mn_noteDes cription; | |
| 1973 | va r vcmn_Rev isedNoteTe xt = ""; | |
| 1974 | // Do Breakdo wn of line s | |
| 1975 | va r vcmn_Tex tLines = v cmn_NoteTe xt.split(' \n'); | |
| 1976 | if (vcmn_Tex tLines.len gth > 0) { | |
| 1977 | //Reform at text | |
| 1978 | for (var i = 0; i < vcmn_Tex tLines.len gth; i++) { | |
| 1979 | //Te st for a l ong line | |
| 1980 | if ( vcmn_TextL ines[i].le ngth > vcm n_WordWrap Limit) { | |
| 1981 | //Break do wn line | |
| 1982 | var vcmn_N ewString = vcmn_word Wrap(vcmn_ TextLines[ i], vcmn_W ordWrapLim it, '\n'); | |
| 1983 | //Add revi sed text b ack | |
| 1984 | vcmn_Revis edNoteText = vcmn_Re visedNoteT ext + vcmn _NewString + "\n"; //Add back the CR/LF used to s plit on | |
| 1985 | } | |
| 1986 | else { | |
| 1987 | //Add text to new no te | |
| 1988 | vcmn_Revis edNoteText = vcmn_Re visedNoteT ext + vcmn _TextLines [i] + "\n" ; //Add ba ck the CR/ LF used to split on | |
| 1989 | } | |
| 1990 | } | |
| 1991 | } | |
| 1992 | if (vcmn_Rev isedNoteTe xt != "" & & vcmn_Rev isedNoteTe xt != null ) { | |
| 1993 | vcmn_not eDescripti on = vcmn_ RevisedNot eText; | |
| 1994 | } | |
| 1995 | ||
| 1996 | // Add list o f addition al signer names to N ote Text i f they exi sts | |
| 1997 | if (vcmn_Add lSignersNa meArray != null && v cmn_AddlSi gnersIenAr ray != nul l) { | |
| 1998 | //Create text stri ngs from a dditional signers ar ray | |
| 1999 | var vcmn _SignerNam es = "\nAd ditional N ote Signer s\n" + "-- ---------- ---------- -------\n" ; | |
| 2000 | for (var i = 0; i <= vcmn_Ad dlSignersN ameArray.l ength - 1; i++) { | |
| 2001 | if ( i >= 1) { | |
| 2002 | var vcmn_s ingleSigne rName = vc mn_AddlSig nersNameAr ray[i].spl it("___"); | |
| 2003 | vcmn_Signe rNames = v cmn_Signer Names + vc mn_singleS ignerName[ 1] + "\n"; | |
| 2004 | } | |
| 2005 | } | |
| 2006 | //Add to Note Desc ription | |
| 2007 | vcmn_not eDescripti on = vcmn_ noteDescri ption + vc mn_SignerN ames; | |
| 2008 | } | |
| 2009 | ||
| 2010 | va r vcmn_vis itNumber = 'NEW'; | |
| 2011 | va r vcmn_cli entName = "FTPCRM"; | |
| 2012 | va r vcmn_For mat = "JSO N"; | |
| 2013 | va r vcmn_pat ientIdenti fierType = "ICN"; | |
| 2014 | va r vcmn_doc umentAvail abilitySta tus = "AV" ; //Histo rical Note only at t his time | |
| 2015 | va r vcmn_ori ginatorCom binedMiddl e = ""; | |
| 2016 | if (vcmn_ori ginatorMid dleName != '' && vcm n_originat orMiddleNa me != null ) { vcmn_o riginatorC ombinedMid dle = vcmn _originato rMiddleNam e; } | |
| 2017 | if (vcmn_ori ginatorSuf fix != '' && vcmn_or iginatorSu ffix != nu ll) { | |
| 2018 | if (vcmn _originato rCombinedM iddle != ' ') { | |
| 2019 | vcmn _originato rCombinedM iddle = vc mn_origina torCombine dMiddle + " " + vcmn _originato rSuffix; | |
| 2020 | } | |
| 2021 | else { | |
| 2022 | vcmn _originato rCombinedM iddle = vc mn_origina torSuffix; | |
| 2023 | } | |
| 2024 | } | |
| 2025 | ||
| 2026 | va r vcmn_req uestJSON = { | |
| 2027 | "ClientN ame": vcmn _clientNam e, | |
| 2028 | "Format" : vcmn_For mat, | |
| 2029 | "Facilit ySiteID": vcmn_facil itySiteId, | |
| 2030 | "SiteHL7 ListenerAd dress": vc mn_siteHL7 ListenerAd dress, | |
| 2031 | "VisitNu mber": vcm n_visitNum ber, | |
| 2032 | "IsSigne dNote": vc mn_signThi sNote, | |
| 2033 | "Patient AdmitDate" : vcmn_pat ientAdmitD ate, | |
| 2034 | "Patient LastName": vcmn_pati entLastNam e, | |
| 2035 | "Patient FirstName" : vcmn_pat ientFirstN ame, | |
| 2036 | "Patient Identifier ": vcmn_pa tientICN, | |
| 2037 | "Patient Identifier Type": vcm n_patientI dentifierT ype, | |
| 2038 | "Patient AssignedLo cation": v cmn_patien tAssignedL ocation, | |
| 2039 | "NoteTex t": vcmn_n oteDescrip tion, | |
| 2040 | "Origina torID": vc mn_origina torID, | |
| 2041 | "Origina torFirstNa me": vcmn_ originator FirstName, | |
| 2042 | "Origina torMiddleN ame": vcmn _originato rCombinedM iddle, | |
| 2043 | "Origina torLastNam e": vcmn_o riginatorL astName, | |
| 2044 | "Documen tFileName" : vcmn_loc alTitle, | |
| 2045 | "Documen tAvailabil ityStatus" : vcmn_doc umentAvail abilitySta tus, | |
| 2046 | "Activit yDate": vc mn_activit yDate | |
| 2047 | }; | |
| 2048 | ||
| 2049 | va r vcmn_req uestRespon se = ""; | |
| 2050 | ||
| 2051 | $. ajax({ | |
| 2052 | type: "P OST", | |
| 2053 | url: vcm n_NoteWrit eUrl, | |
| 2054 | data: JS ON.stringi fy(vcmn_re questJSON) , | |
| 2055 | contentT ype: "appl ication/js on; charse t=utf-8", | |
| 2056 | dataType : "json", | |
| 2057 | success: function (data) { | |
| 2058 | var vcmn_newda ta = data; | |
| 2059 | vcmn _requestRe sponse = v cmn_newdat a; | |
| 2060 | vcmn _vistAInte grationReq uest_respo nse(null, vcmn_reque stResponse , vcmn_not eDescripti on); | |
| 2061 | }, | |
| 2062 | error: f unction (j qXHR, text Status, er rorThrown) { | |
| 2063 | //Sy stem Error | |
| 2064 | vcmn _vistAInte grationReq uest_respo nse(errorT hrown, nul l, vcmn_no teDescript ion); | |
| 2065 | }, | |
| 2066 | async: f alse, | |
| 2067 | cache: f alse | |
| 2068 | }) ; | |
| 2069 | } | |
| 2070 | catch (err) { | |
| 2071 | al ert('Progr ess Note R ibbon Func tion Error (vcmn_exec uteVistAIn tegrationR equest): ' + err.mes sage); | |
| 2072 | Xr m.Page.ui. clearFormN otificatio n("SAVEVIS TA"); | |
| 2073 | } | |
| 2074 | } | |
| 2075 | ||
| 2076 | function v cmn_vistAI ntegration Request_re sponse(vcm n_errorThr own, vcmn_ requestRes ponse, vcm n_noteDesc ription) { | |
| 2077 | try { | |
| 2078 | // Process In tegration Request Re sponse | |
| 2079 | if (vcmn_err orThrown ! = null) { | |
| 2080 | //Write Error | |
| 2081 | Xrm.Page .getAttrib ute('ftp_i ntegration status').s etValue('E RROR'); | |
| 2082 | Xrm.Page .getAttrib ute('ftp_i ntegration status').s etSubmitMo de('always '); | |
| 2083 | Xrm.Page .getAttrib ute('ftp_i ntegration error').se tValue(Str ing(vcmn_e rrorThrown )); | |
| 2084 | Xrm.Page .getAttrib ute('ftp_i ntegration error').se tSubmitMod e('always' ); | |
| 2085 | Xrm.Page .getAttrib ute('ftp_i ntegration date').set Value(new Date()); | |
| 2086 | Xrm.Page .getAttrib ute('ftp_i ntegration date').set SubmitMode ('always') ; | |
| 2087 | Xrm.Page .getAttrib ute('ftp_i ntegration noteid').s etValue('' ); | |
| 2088 | Xrm.Page .getAttrib ute('ftp_i ntegration noteid').s etSubmitMo de('always '); | |
| 2089 | alert('T he note cr eation in VistA/CPRS failed!\n Please see the integ ration err or field f or details .'); | |
| 2090 | Xrm.Page .getContro l('ftp_int egrationer ror').setF ocus(); | |
| 2091 | Xrm.Page .data.enti ty.save(); | |
| 2092 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 2093 | return f alse; | |
| 2094 | } | |
| 2095 | el se { | |
| 2096 | //Write web servic e response Success o r Failure | |
| 2097 | if (vcmn _requestRe sponse.Err orOccurred == false) { | |
| 2098 | //Ca ll Additio nal Signer s & Finali ze Note fu nction | |
| 2099 | vcmn _finalizeN oteCreatio n(vcmn_req uestRespon se.Status, vcmn_requ estRespons e.Data, vc mn_noteDes cription) | |
| 2100 | } | |
| 2101 | else { | |
| 2102 | //Wr ite Failur e entry | |
| 2103 | Xrm. Page.getAt tribute('f tp_integra tionstatus ').setValu e(vcmn_req uestRespon se.Status) ; | |
| 2104 | Xrm. Page.getAt tribute('f tp_integra tionstatus ').setSubm itMode('al ways'); | |
| 2105 | Xrm. Page.getAt tribute('f tp_integra tionerror' ).setValue (vcmn_requ estRespons e.ErrorMes sage + " DebugInfo: " + vcmn_r equestResp onse.Debug Info); | |
| 2106 | Xrm. Page.getAt tribute('f tp_integra tionerror' ).setSubmi tMode('alw ays'); | |
| 2107 | Xrm. Page.getAt tribute('f tp_integra tiondate') .setValue( new Date() ); | |
| 2108 | Xrm. Page.getAt tribute('f tp_integra tiondate') .setSubmit Mode('alwa ys'); | |
| 2109 | Xrm. Page.getAt tribute('f tp_integra tionnoteid ').setValu e(''); | |
| 2110 | Xrm. Page.getAt tribute('f tp_integra tionnoteid ').setSubm itMode('al ways'); | |
| 2111 | aler t('The not e creation in VistA/ CPRS faile d!\nPlease see the i ntegration error fie ld for det ails.'); | |
| 2112 | Xrm. Page.getCo ntrol('ftp _integrati onerror'). setFocus() ; | |
| 2113 | Xrm. Page.data. entity.sav e(); | |
| 2114 | Xrm. Page.ui.cl earFormNot ification( "SAVEVISTA "); | |
| 2115 | retu rn false; | |
| 2116 | } | |
| 2117 | } | |
| 2118 | } | |
| 2119 | catch (err) { | |
| 2120 | al ert('Progr ess Note R ibbon Func tion Error (vcmn_vist AIntegrati onRequest_ response): ' + err.m essage); | |
| 2121 | Xr m.Page.ui. clearFormN otificatio n("SAVEVIS TA"); | |
| 2122 | } | |
| 2123 | } | |
| 2124 | ||
| 2125 | function v cmn_finali zeNoteCrea tion(vcmn_ integratio nStatus, v cmn_integr ationNoteI d, vcmn_no teDescript ion) { | |
| 2126 | //The Note was s ucessfully created i n Vista/CP RS, add ad ditional s igners if needed | |
| 2127 | try { | |
| 2128 | // Determine if additio nal signer s exists | |
| 2129 | if (vcmn_Add lSignersNa meArray != null && v cmn_AddlSi gnersIenAr ray != nul l) { | |
| 2130 | //Get th e current CRM User's assigned site/facil ity | |
| 2131 | var vcmn _userSiteI d = ""; | |
| 2132 | var vcmn _UserSiteN o = ""; | |
| 2133 | var vcmn _duz = ""; | |
| 2134 | var vcmn _providern ame = ""; | |
| 2135 | ||
| 2136 | var vcmn _userData = vcmn_get SingleEnti tyDataSync ('SystemUs erSet', 'f tp_Facilit ySiteId', Xrm.Page.c ontext.get UserId()); | |
| 2137 | if (vcmn _userData != null) { | |
| 2138 | if ( vcmn_userD ata.d.ftp_ FacilitySi teId != nu ll) { | |
| 2139 | vcmn_userS iteId = vc mn_userDat a.d.ftp_Fa cilitySite Id.Id; | |
| 2140 | } | |
| 2141 | } | |
| 2142 | ||
| 2143 | //Lookup the Facil ity/Site # | |
| 2144 | if (vcmn _userSiteI d != null && vcmn_us erSiteId ! = '') { | |
| 2145 | var vcmn_facil ityData = vcmn_getSi ngleEntity DataSync(' ftp_facili tySet', 'f tp_facilit ycode', vc mn_userSit eId); | |
| 2146 | if ( vcmn_facil ityData != null) { | |
| 2147 | if (vcmn_f acilityDat a.d.ftp_fa cilitycode != null) { vcmn_Use rSiteNo = vcmn_facil ityData.d. ftp_facili tycode; } | |
| 2148 | } | |
| 2149 | } | |
| 2150 | ||
| 2151 | //Check if VIA Log in cookie exist (not expired) | |
| 2152 | var vcmn _ViaLoginC ookie = vc mn_getCook ie("viases sionlink") ; | |
| 2153 | if (vcmn _ViaLoginC ookie != n ull && vcm n_ViaLogin Cookie != '') { | |
| 2154 | var vcmn_cooki earray = v cmn_ViaLog inCookie.s plit("~~~~ ", 2); | |
| 2155 | vcmn _duz = vcm n_cookiear ray[0]; | |
| 2156 | vcmn _providern ame = vcmn _cookiearr ay[1]; | |
| 2157 | } | |
| 2158 | ||
| 2159 | //Create text stri ngs from a dditional signers ar ray | |
| 2160 | var vcmn _SignerIEN = ""; | |
| 2161 | for (var i = 0; i <= vcmn_Ad dlSignersI enArray.le ngth - 1; i++) { | |
| 2162 | if ( i == 1) { vcmn_Signe rIEN = vcm n_AddlSign ersIenArra y[i]; } | |
| 2163 | if ( i > 1) { v cmn_Signer IEN = vcmn _SignerIEN + " " + v cmn_AddlSi gnersIenAr ray[i]; } | |
| 2164 | } | |
| 2165 | ||
| 2166 | //Create the Addit ional Sign ers | |
| 2167 | var vcmn _viaSigner s = new Ob ject(); | |
| 2168 | vcmn_via Signers.Pr oviderName = vcmn_pr ovidername ; | |
| 2169 | vcmn_via Signers.Du z = vcmn_d uz; | |
| 2170 | vcmn_via Signers.Lo ginSiteCod e = vcmn_U serSiteNo; | |
| 2171 | vcmn_via Signers.Ta rget = vcm n_integrat ionNoteId; | |
| 2172 | vcmn_via Signers.Su pplemental Parameters = vcmn_Si gnerIEN; | |
| 2173 | ||
| 2174 | $.ajax({ | |
| 2175 | type : "POST", | |
| 2176 | url: vcmn_AddS ignersUrl, | |
| 2177 | data : JSON.str ingify(vcm n_viaSigne rs), | |
| 2178 | cont entType: " applicatio n/json; ch arset=utf- 8", | |
| 2179 | data Type: "jso n", | |
| 2180 | succ ess: funct ion (data) { | |
| 2181 | vcmn_viaSi gnersRespo nse = JSON .stringify (data.Data ); | |
| 2182 | //Test for Failure | |
| 2183 | if (vcmn_v iaSignersR esponse.Er rorOccurre d == true) { | |
| 2184 | alert( "Error: Un able to ad d the addi tional sig ners selec ted to thi s note.\n\ nPlease re view the n ote and si gners in y our Vista/ CPRS appli cation!"); | |
| 2185 | } | |
| 2186 | }, | |
| 2187 | erro r: functio n (jqXHR, textStatus , errorThr own) { | |
| 2188 | //System E rror | |
| 2189 | alert("Err or: Unable to add th e addition al signers selected to this no te.\n\nPle ase review the note and signer s in your Vista/CPRS applicati on!"); | |
| 2190 | }, | |
| 2191 | asyn c: false, | |
| 2192 | cach e: false | |
| 2193 | }); | |
| 2194 | ||
| 2195 | if (vcmn _localStor ageVarName != "" && vcmn_local StorageVar Name != nu ll) { | |
| 2196 | //Cl ear existi ng session storage v ariable. | |
| 2197 | loca lStorage.r emoveItem( vcmn_local StorageVar Name); | |
| 2198 | } | |
| 2199 | } | |
| 2200 | ||
| 2201 | // Perform st andard for m updates to signify completio n | |
| 2202 | // Write Succ ess entry | |
| 2203 | Xr m.Page.get Attribute( 'ftp_noted etail').se tValue(vcm n_noteDesc ription); | |
| 2204 | Xr m.Page.get Attribute( 'ftp_noted etail').se tSubmitMod e('always' ); | |
| 2205 | Xr m.Page.get Attribute( 'ftp_integ rationstat us').setVa lue(vcmn_i ntegration Status); | |
| 2206 | Xr m.Page.get Attribute( 'ftp_integ rationstat us').setSu bmitMode(' always'); | |
| 2207 | Xr m.Page.get Attribute( 'ftp_integ rationerro r').setVal ue(null); | |
| 2208 | Xr m.Page.get Attribute( 'ftp_integ rationerro r').setSub mitMode('a lways'); | |
| 2209 | Xr m.Page.get Attribute( 'ftp_integ rationdate ').setValu e(new Date ()); | |
| 2210 | Xr m.Page.get Attribute( 'ftp_integ rationdate ').setSubm itMode('al ways'); | |
| 2211 | Xr m.Page.get Attribute( 'ftp_integ rationnote id').setVa lue(vcmn_i ntegration NoteId); | |
| 2212 | Xr m.Page.get Attribute( 'ftp_integ rationnote id').setSu bmitMode(' always'); | |
| 2213 | Xr m.Page.get Control('f tp_integra tionstatus ').setFocu s(); | |
| 2214 | al ert('The n ote creati on in Vist A/CPRS was successfu l, this no te will no w be marke d as compl eted. \n\n Please exi t this not e record a fter click ing OK to this promp t!'); | |
| 2215 | Xr m.Page.ui. clearFormN otificatio n("SAVEVIS TA"); | |
| 2216 | Xr m.Page.dat a.entity.s ave(); | |
| 2217 | } | |
| 2218 | catch (err) { | |
| 2219 | al ert('Progr ess Note R ibbon Func tion Error (vcmn_fina lizeNoteCr eation): ' + err.mes sage); | |
| 2220 | Xr m.Page.ui. clearFormN otificatio n("SAVEVIS TA"); | |
| 2221 | } | |
| 2222 | } | |
| 2223 | ||
| 2224 | function v cmn_getCoo kie(cname) { | |
| 2225 | try { | |
| 2226 | va r name = c name + "=" ; | |
| 2227 | va r ca = doc ument.cook ie.split(' ;'); | |
| 2228 | fo r (var i = 0; i < ca .length; i ++) { | |
| 2229 | var c = ca[i]; | |
| 2230 | while (c .charAt(0) == ' ') { | |
| 2231 | c = c.substrin g(1); | |
| 2232 | } | |
| 2233 | if (c.in dexOf(name ) == 0) { | |
| 2234 | retu rn c.subst ring(name. length, c. length); | |
| 2235 | } | |
| 2236 | } | |
| 2237 | re turn ""; | |
| 2238 | } | |
| 2239 | catch (err) { | |
| 2240 | al ert('Progr ess Note R ibbon Func tion Error (vcmn_getC ookie): ' + err.mess age); | |
| 2241 | } | |
| 2242 | } | |
| 2243 | ||
| 2244 | function v cmn_initVi aDropdownC ontrols() { | |
| 2245 | //Init ialize VIA DropDown Controls | |
| 2246 | //Func tion is tr iggered by The VistA Login Con trol and o nchange of Facility attribute | |
| 2247 | try { | |
| 2248 | Xr m.Page.get Control("W ebResource _HospitalL ocation"). setSrc(Xrm .Page.getC ontrol("We bResource_ HospitalLo cation").g etSrc()); | |
| 2249 | Xr m.Page.get Control("W ebResource _LocalNote sTitle").s etSrc(Xrm. Page.getCo ntrol("Web Resource_L ocalNotesT itle").get Src()); | |
| 2250 | Xr m.Page.get Control("W ebResource _ViaWorklo adLookup") .setSrc(Xr m.Page.get Control("W ebResource _ViaWorklo adLookup") .getSrc()) ; | |
| 2251 | Xr m.Page.get Control("W ebResource _ProgressN oteSignerS earch").se tSrc(Xrm.P age.getCon trol("WebR esource_Pr ogressNote SignerSear ch").getSr c()); | |
| 2252 | } | |
| 2253 | catch (err) { | |
| 2254 | al ert('Progr ess Note V IA Login F unction Er ror(vcmn_i nitViaDrop downContro ls): ' + e rr.message ); | |
| 2255 | } | |
| 2256 | } | |
| 2257 | ||
| 2258 | function v cmn_facili tyGroupDef ault_respo nse(vcmn_f acilityGro upData, vc mn_lastSki p, vcmn_fa cilitySite Id) { | |
| 2259 | try { | |
| 2260 | // vcmn_lastS kip is the starting point in t he result (use if mo re than 50 records) //Not used in this s cenario | |
| 2261 | fo r (var i = 0; i <= v cmn_facili tyGroupDat a.d.result s.length - 1; i++) { | |
| 2262 | //Get Va lues and W rite to Pr ogress Not e | |
| 2263 | if (vcmn _facilityG roupData.d .results[i ].ftp_loca lnotestitl e != null) { | |
| 2264 | Xrm. Page.getAt tribute("f tp_localno testitle") .setValue( vcmn_facil ityGroupDa ta.d.resul ts[i].ftp_ localnotes title); | |
| 2265 | Xrm. Page.getAt tribute('f tp_localno testitle') .setSubmit Mode('alwa ys'); | |
| 2266 | } | |
| 2267 | if (vcmn _facilityG roupData.d .results[i ].ftp_hosp itallocati on != null ) { | |
| 2268 | Xrm. Page.getAt tribute("f tp_hospita llocation" ).setValue (vcmn_faci lityGroupD ata.d.resu lts[i].ftp _hospitall ocation); | |
| 2269 | Xrm. Page.getAt tribute('f tp_hospita llocation' ).setSubmi tMode('alw ays'); | |
| 2270 | } | |
| 2271 | break; | |
| 2272 | } | |
| 2273 | } | |
| 2274 | catch (err) { | |
| 2275 | al ert('Progr ess Note F orm Load S cript Func tion Error (vcmn_faci lityGroupD efault_res ponse): ' + err.mess age); | |
| 2276 | } | |
| 2277 | } | |
| 2278 | ||
| 2279 | function v cmn_buildQ ueryFilter (field, va lue, and) { | |
| 2280 | try { | |
| 2281 | if (value == '') { | |
| 2282 | if (and) { | |
| 2283 | retu rn " and " + field + " eq null "; | |
| 2284 | } else { | |
| 2285 | retu rn field + " eq null "; | |
| 2286 | } | |
| 2287 | } | |
| 2288 | el se { | |
| 2289 | if (and) { | |
| 2290 | retu rn " and " + field + " eq '" + value + " '"; | |
| 2291 | } else { | |
| 2292 | retu rn field + " eq '" + value + " '"; | |
| 2293 | } | |
| 2294 | } | |
| 2295 | } | |
| 2296 | catch (err) { | |
| 2297 | al ert('Progr ess Note R ibbon Func tion Error (vcmn_buil dQueryFilt er): ' + e rr.message ); | |
| 2298 | Xr m.Page.ui. clearFormN otificatio n("SAVEVIS TA"); | |
| 2299 | } | |
| 2300 | } | |
| 2301 | ||
| 2302 | function v cmn_unatte ndedMviSea rch(firstn ame, lastn ame, dobda te, ssn) { | |
| 2303 | try { | |
| 2304 | va r filter = ""; | |
| 2305 | va r filterPr efix = "$s elect=*&$f ilter="; | |
| 2306 | va r edipi = ""; | |
| 2307 | va r dobstrin g = ""; | |
| 2308 | if (dobdate != null) { | |
| 2309 | dobstrin g = dobdat e; | |
| 2310 | } | |
| 2311 | ||
| 2312 | if (ssn != " " && ssn ! = null) { | |
| 2313 | ssn = ss n.replace( /-/g, ""); | |
| 2314 | } | |
| 2315 | ||
| 2316 | // if we have edipi, se arch using just it | |
| 2317 | if (edipi != "") { | |
| 2318 | filter = vcmn_buil dQueryFilt er("crme_E DIPI", edi pi, false) ; | |
| 2319 | filter + = vcmn_bui ldQueryFil ter("crme_ ClassCode" , 'MIL', t rue); | |
| 2320 | filter + = vcmn_bui ldQueryFil ter("crme_ SearchType ", 'Search ByIdentifi er', true) ; | |
| 2321 | ||
| 2322 | //set se arch type as unatten ded | |
| 2323 | filter + = " and cr me_IsAtten ded eq fal se"; | |
| 2324 | } | |
| 2325 | el se { | |
| 2326 | //otherw ise search using las tname, fir stname, ss n, dob | |
| 2327 | filter = vcmn_buil dQueryFilt er("crme_L astName", lastname, false); // assuming l astname wi ll never b e blank | |
| 2328 | ||
| 2329 | if (firs tname != " " && first name != nu ll) { | |
| 2330 | filt er += vcmn _buildQuer yFilter("c rme_FirstN ame", firs tname, tru e); | |
| 2331 | } | |
| 2332 | ||
| 2333 | if (ssn != "" && s sn != null ) { | |
| 2334 | filt er += vcmn _buildQuer yFilter("c rme_SSN", ssn, true) ; | |
| 2335 | } | |
| 2336 | ||
| 2337 | if (dobs tring != " ") { | |
| 2338 | filt er += " an d crme_DOB String eq '" + dobst ring + "'" ; | |
| 2339 | } | |
| 2340 | filter + = vcmn_bui ldQueryFil ter("crme_ SearchType ", 'Search ByFilter', true); | |
| 2341 | ||
| 2342 | //set se arch type as attende d (for now ) | |
| 2343 | filter + = " and cr me_IsAtten ded eq tru e"; | |
| 2344 | } | |
| 2345 | ||
| 2346 | fi lter = enc odeURIComp onent(filt er); | |
| 2347 | fi lter = fil terPrefix + filter; | |
| 2348 | SD K.REST.ret rieveMulti pleRecords ("crme_per son", filt er, vcmn_u nattendedM viSearchCa llback, fu nction (er ror) { ale rt(error.m essage); v cmn_ribbon ButtonSave ToVistA_wi th_ICN("") ; }, vcmn_ unattended MviSearchC omplete); | |
| 2349 | } | |
| 2350 | catch (err) { | |
| 2351 | al ert('Progr ess Note R ibbon Func tion Error (vcmn_unat tendedMviS earch): ' + err.mess age); | |
| 2352 | Xr m.Page.ui. clearFormN otificatio n("SAVEVIS TA"); | |
| 2353 | } | |
| 2354 | } | |
| 2355 | ||
| 2356 | function v cmn_unatte ndedMviSea rchCallbac k(returnDa ta) { | |
| 2357 | try { | |
| 2358 | if (returnDa ta != null && return Data.lengt h >= 1) { | |
| 2359 | // check for excep tions 1st | |
| 2360 | if (retu rnData[0]. crme_Excep tionOccure d || (retu rnData[0]. crme_Retur nMessage ! = null && returnData [0].crme_R eturnMessa ge == "An unexpected error occ ured durin g the MVI search. Pl ease try a gain or co ntact your system ad ministrato r if the p roblem per sists.")) { | |
| 2361 | //do nothing, pass empty ICN | |
| 2362 | vcmn _ribbonBut tonSaveToV istA_with_ ICN(""); | |
| 2363 | } | |
| 2364 | else { | |
| 2365 | var patientMvi Identifier = returnD ata[0].crm e_PatientM viIdentifi er == null ? "" : re turnData[0 ].crme_Pat ientMviIde ntifier; | |
| 2366 | if ( patientMvi Identifier != "") { | |
| 2367 | var idpart s = patien tMviIdenti fier.split ("^"); | |
| 2368 | ||
| 2369 | if (idpart s.length > 0) { | |
| 2370 | var na tionalId = idparts[0 ]; | |
| 2371 | _icn = nationalI d; | |
| 2372 | //Pass on the IC N and cont inue valid ation | |
| 2373 | vcmn_r ibbonButto nSaveToVis tA_with_IC N(_icn); | |
| 2374 | } | |
| 2375 | } | |
| 2376 | } | |
| 2377 | } | |
| 2378 | el se { | |
| 2379 | //Return empty ICN | |
| 2380 | vcmn_rib bonButtonS aveToVistA _with_ICN( ""); | |
| 2381 | } | |
| 2382 | } | |
| 2383 | catch (err) { | |
| 2384 | al ert('Progr ess Note R ibbon Func tion Error (vcmn_unat tendedMviS earchCallb ack): ' + err.messag e); | |
| 2385 | Xr m.Page.ui. clearFormN otificatio n("SAVEVIS TA"); | |
| 2386 | } | |
| 2387 | } | |
| 2388 | ||
| 2389 | function v cmn_unatte ndedMviSea rchComplet e() { | |
| 2390 | //do n othing | |
| 2391 | } | |
| 2392 | ||
| 2393 | function v cmn_buildQ ueryFilter SCD(field, value, an d) { | |
| 2394 | try { | |
| 2395 | if (value == '') { | |
| 2396 | if (and) { | |
| 2397 | retu rn " and " + field + " eq null "; | |
| 2398 | } else { | |
| 2399 | retu rn field + " eq null "; | |
| 2400 | } | |
| 2401 | } | |
| 2402 | el se { | |
| 2403 | if (and) { | |
| 2404 | retu rn " and " + field + " eq '" + value + " '"; | |
| 2405 | } else { | |
| 2406 | retu rn field + " eq '" + value + " '"; | |
| 2407 | } | |
| 2408 | } | |
| 2409 | } | |
| 2410 | catch (err) { | |
| 2411 | al ert('Progr ess Note F orm Load S cript Func tion Error (vcmn_buil dQueryFilt erSCD): ' + err.mess age); | |
| 2412 | Xr m.Page.ui. clearFormN otificatio n("SAVEVIS TA"); | |
| 2413 | } | |
| 2414 | } | |
| 2415 | ||
| 2416 | function v cmn_unatte ndedMviSea rchSCD(fir stname, la stname, do bdate, ssn ) { | |
| 2417 | try { | |
| 2418 | va r filter = ""; | |
| 2419 | va r filterPr efix = "$s elect=*&$f ilter="; | |
| 2420 | va r edipi = ""; | |
| 2421 | va r dobstrin g = ""; | |
| 2422 | if (dobdate != null) { | |
| 2423 | dobstrin g = dobdat e; | |
| 2424 | } | |
| 2425 | ||
| 2426 | if (ssn != " " && ssn ! = null) { | |
| 2427 | ssn = ss n.replace( /-/g, ""); | |
| 2428 | } | |
| 2429 | ||
| 2430 | // if we have edipi, se arch using just it | |
| 2431 | if (edipi != "") { | |
| 2432 | filter = vcmn_buil dQueryFilt erSCD("crm e_EDIPI", edipi, fal se); | |
| 2433 | filter + = vcmn_bui ldQueryFil terSCD("cr me_ClassCo de", 'MIL' , true); | |
| 2434 | filter + = vcmn_bui ldQueryFil terSCD("cr me_SearchT ype", 'Sea rchByIdent ifier', tr ue); | |
| 2435 | ||
| 2436 | //set se arch type as unatten ded | |
| 2437 | filter + = " and cr me_IsAtten ded eq fal se"; | |
| 2438 | } | |
| 2439 | el se { | |
| 2440 | //otherw ise search using las tname, fir stname, ss n, dob | |
| 2441 | filter = vcmn_buil dQueryFilt erSCD("crm e_LastName ", lastnam e, false); //assumin g lastname will neve r be blank | |
| 2442 | ||
| 2443 | if (firs tname != " " && first name != nu ll) { | |
| 2444 | filt er += vcmn _buildQuer yFilterSCD ("crme_Fir stName", f irstname, true); | |
| 2445 | } | |
| 2446 | ||
| 2447 | if (ssn != "" && s sn != null ) { | |
| 2448 | filt er += vcmn _buildQuer yFilterSCD ("crme_SSN ", ssn, tr ue); | |
| 2449 | } | |
| 2450 | ||
| 2451 | if (dobs tring != " ") { | |
| 2452 | filt er += " an d crme_DOB String eq '" + dobst ring + "'" ; | |
| 2453 | } | |
| 2454 | filter + = vcmn_bui ldQueryFil terSCD("cr me_SearchT ype", 'Sea rchByFilte r', true); | |
| 2455 | ||
| 2456 | //set se arch type as attende d (for now ) | |
| 2457 | filter + = " and cr me_IsAtten ded eq tru e"; | |
| 2458 | } | |
| 2459 | ||
| 2460 | fi lter = enc odeURIComp onent(filt er); | |
| 2461 | fi lter = fil terPrefix + filter; | |
| 2462 | SD K.REST.ret rieveMulti pleRecords ("crme_per son", filt er, vcmn_u nattendedM viSearchCa llbackSCD, function (error) { alert(erro r.message) ; vcmn_get ServiceCon nectedDisa bilities(" "); }, vcm n_unattend edMviSearc hComplete) ; | |
| 2463 | } | |
| 2464 | catch (err) { | |
| 2465 | al ert('Progr ess Note F orm Load S cript Func tion Error (vcmn_unat tendedMviS earchSCD): ' + err.m essage); | |
| 2466 | } | |
| 2467 | } | |
| 2468 | ||
| 2469 | function v cmn_unatte ndedMviSea rchCallbac kSCD(retur nData) { | |
| 2470 | try { | |
| 2471 | if (returnDa ta != null && return Data.lengt h >= 1) { | |
| 2472 | // check for excep tions 1st | |
| 2473 | if (retu rnData[0]. crme_Excep tionOccure d || (retu rnData[0]. crme_Retur nMessage ! = null && returnData [0].crme_R eturnMessa ge == "An unexpected error occ ured durin g the MVI search. Pl ease try a gain or co ntact your system ad ministrato r if the p roblem per sists.")) { | |
| 2474 | //do nothing, pass empty ICN | |
| 2475 | vcmn _getServic eConnected Disabiliti es(""); | |
| 2476 | } | |
| 2477 | else { | |
| 2478 | var patientMvi Identifier = returnD ata[0].crm e_PatientM viIdentifi er == null ? "" : re turnData[0 ].crme_Pat ientMviIde ntifier; | |
| 2479 | if ( patientMvi Identifier != "") { | |
| 2480 | var idpart s = patien tMviIdenti fier.split ("^"); | |
| 2481 | ||
| 2482 | if (idpart s.length > 0) { | |
| 2483 | var na tionalId = idparts[0 ]; | |
| 2484 | _icn = nationalI d; | |
| 2485 | //Pass on the IC N and cont inue with SCD | |
| 2486 | vcmn_g etServiceC onnectedDi sabilities (_icn); | |
| 2487 | } | |
| 2488 | } | |
| 2489 | } | |
| 2490 | } | |
| 2491 | el se { | |
| 2492 | //Return empty ICN | |
| 2493 | vcmn_get ServiceCon nectedDisa bilities(" "); | |
| 2494 | } | |
| 2495 | } | |
| 2496 | catch (err) { | |
| 2497 | al ert('Progr ess Note F orm Load S cript Func tion Error (vcmn_unat tendedMviS earchCallb ackSCD): ' + err.mes sage); | |
| 2498 | } | |
| 2499 | } | |
| 2500 | ||
| 2501 | //Standalo ne form lo ad functio ns | |
| 2502 | function v cmn_secure ProgressNo te() { | |
| 2503 | try { | |
| 2504 | // Disable al l form att ributes if form is o pened by a user who does not o wn the pro gress note | |
| 2505 | // Only handl e forms in create st ate | |
| 2506 | if (Xrm.Page .ui.getFor mType() != 2) { retu rn false; } //2 = CR M Update S tatus | |
| 2507 | // Get the cu rrent owne r of the r ecord and compare to the curre nt user | |
| 2508 | va r vcmn_rec ordOwnerId = Xrm.Pag e.getAttri bute('owne rid').getV alue(); | |
| 2509 | // Verify tha t the curr ent owner and the cu rrent user is the sa me person, if not lo ck down th e form | |
| 2510 | if ((vcmn_re cordOwnerI d[0].id).t oUpperCase () != (Xrm .Page.cont ext.getUse rId()).toU pperCase() ) { | |
| 2511 | Xrm.Page .data.enti ty.attribu tes.forEac h(function (attribut e, index) { | |
| 2512 | var control = Xrm.Page.g etControl( attribute. getName()) ; | |
| 2513 | if ( control) { | |
| 2514 | control.se tDisabled( true) | |
| 2515 | } | |
| 2516 | }); | |
| 2517 | } | |
| 2518 | } | |
| 2519 | catch (err) { | |
| 2520 | al ert('Progr ess Note F orm Load F unction Er ror(vcmn_s ecureProgr essNote): ' + err.me ssage); | |
| 2521 | } | |
| 2522 | } | |
| 2523 | ||
| 2524 | function v cmn_initFi nancialDis claimer() { | |
| 2525 | //This function is used to initialze the Finan cial Discl aimer tab on the pro gress note form | |
| 2526 | try { | |
| 2527 | va r vcmn_isR eadDisclai mer = Xrm. Page.getAt tribute("f tp_isreadd isclaimer" ).getValue (); | |
| 2528 | va r vcmn_res ponseToDis claimer = Xrm.Page.g etAttribut e("ftp_isd isclaimerr ead").getV alue(); | |
| 2529 | Xr m.Page.get Attribute( "ftp_patie ntcallersr easonfordi sagreeing" ).setSubmi tMode("alw ays"); | |
| 2530 | if (vcmn_isR eadDisclai mer == tru e && vcmn_ responseTo Disclaimer == true) { | |
| 2531 | Xrm.Page .ui.tabs.g et("Tab_Fi nancialDis claimer"). setVisible (true); | |
| 2532 | Xrm.Page .getAttrib ute("ftp_i spatientag ree").setR equiredLev el("requir ed"); | |
| 2533 | var vcmn _isPatient Agree = Xr m.Page.get Attribute( "ftp_ispat ientagree" ).getValue (); | |
| 2534 | if (vcmn _isPatient Agree == f alse) { | |
| 2535 | Xrm. Page.getAt tribute("f tp_patient callersrea sonfordisa greeing"). setRequire dLevel("re quired"); | |
| 2536 | Xrm. Page.getCo ntrol("ftp _patientca llersreaso nfordisagr eeing").se tVisible(t rue); | |
| 2537 | } | |
| 2538 | else { X rm.Page.ge tControl(" ftp_patien tcallersre asonfordis agreeing") .setVisibl e(false); } | |
| 2539 | } | |
| 2540 | } | |
| 2541 | catch (err) { | |
| 2542 | al ert('Progr ess Note F inancial D isclaimer Function E rror(vcmn_ initFinanc ialDisclai mer): ' + err.messag e); | |
| 2543 | } | |
| 2544 | } | |
| 2545 | ||
| 2546 | //Standalo ne form at tribute on change ev ent functi ons | |
| 2547 | function v cmn_needTo ReadDiscla imer_OnCha nge() { | |
| 2548 | //This function is used to display t he Financi al Disclai mer prompt | |
| 2549 | try { | |
| 2550 | va r vcmn_isR eadDisclai mer = Xrm. Page.getAt tribute("f tp_isreadd isclaimer" ).getValue (); | |
| 2551 | if (vcmn_isR eadDisclai mer == tru e) { | |
| 2552 | //Financ ial Discla imer is ne eded | |
| 2553 | var vcmn _responseT oDisclaime r = confir m("FINANCI AL DISCLAI MER\n\n'Th is is not an authori zation for VA Paymen t'\nand al so\n'To ha ve hospita l contact the neares t VA\nFaci lity for t ransfer up on stabili zation.'\n \nSelect O K if you r ead the di sclaimer t o the pati ent / vete ran and Ca ncel if yo u did not read it.") ; | |
| 2554 | if (vcmn _responseT oDisclaime r == true) { | |
| 2555 | Xrm. Page.ui.ta bs.get("Ta b_Financia lDisclaime r").setVis ible(true) ; | |
| 2556 | Xrm. Page.getAt tribute("f tp_isdiscl aimerread" ).setValue (true); | |
| 2557 | Xrm. Page.getAt tribute("f tp_isdiscl aimerread" ).setSubmi tMode("alw ays"); | |
| 2558 | Xrm. Page.getAt tribute("f tp_ispatie ntagree"). setRequire dLevel("re quired"); | |
| 2559 | //Se t Default Value to N ot Agreein g and Requ ire Reason for disag reeing | |
| 2560 | Xrm. Page.getAt tribute("f tp_ispatie ntagree"). setValue(f alse); | |
| 2561 | Xrm. Page.getAt tribute("f tp_ispatie ntagree"). setSubmitM ode("alway s"); | |
| 2562 | Xrm. Page.getAt tribute("f tp_patient callersrea sonfordisa greeing"). setRequire dLevel("re quired"); | |
| 2563 | Xrm. Page.getCo ntrol("ftp _patientca llersreaso nfordisagr eeing").se tVisible(t rue); | |
| 2564 | Xrm. Page.getCo ntrol("ftp _patientca llersreaso nfordisagr eeing").se tFocus(); | |
| 2565 | } | |
| 2566 | else { | |
| 2567 | Xrm. Page.ui.ta bs.get("Ta b_Financia lDisclaime r").setVis ible(false ); | |
| 2568 | Xrm. Page.getAt tribute("f tp_isdiscl aimerread" ).setValue (false); | |
| 2569 | Xrm. Page.getAt tribute("f tp_isdiscl aimerread" ).setSubmi tMode("alw ays"); | |
| 2570 | Xrm. Page.getAt tribute("f tp_ispatie ntagree"). setRequire dLevel("no ne"); | |
| 2571 | Xrm. Page.getAt tribute("f tp_patient callersrea sonfordisa greeing"). setRequire dLevel("no ne"); | |
| 2572 | Xrm. Page.getCo ntrol("ftp _patientca llersreaso nfordisagr eeing").se tVisible(f alse); | |
| 2573 | } | |
| 2574 | } | |
| 2575 | el se { | |
| 2576 | //No Fin ancial Dis claimer ne eded (Hid e Financia l Disclaim er section ) | |
| 2577 | Xrm.Page .ui.tabs.g et("Tab_Fi nancialDis claimer"). setVisible (false); | |
| 2578 | Xrm.Page .getAttrib ute("ftp_i spatientag ree").setR equiredLev el("none") ; | |
| 2579 | Xrm.Page .getAttrib ute("ftp_p atientcall ersreasonf ordisagree ing").setR equiredLev el("none") ; | |
| 2580 | Xrm.Page .getContro l("ftp_pat ientcaller sreasonfor disagreein g").setVis ible(false ); | |
| 2581 | } | |
| 2582 | } | |
| 2583 | catch (err) { | |
| 2584 | al ert('Progr ess Note F inancial D isclaimer Function E rror(vcmn_ needToRead Disclaimer _OnChange) : ' + err. message); | |
| 2585 | } | |
| 2586 | } | |
| 2587 | ||
| 2588 | function v cmn_isPati entInAgree ment_OnCha nge() { | |
| 2589 | try { | |
| 2590 | va r vcmn_isP atientAgre e = Xrm.Pa ge.getAttr ibute("ftp _ispatient agree").ge tValue(); | |
| 2591 | if (vcmn_isP atientAgre e == false ) { | |
| 2592 | Xrm.Page .getAttrib ute("ftp_p atientcall ersreasonf ordisagree ing").setR equiredLev el("requir ed"); | |
| 2593 | Xrm.Page .getContro l("ftp_pat ientcaller sreasonfor disagreein g").setVis ible(true) ; | |
| 2594 | } | |
| 2595 | el se { | |
| 2596 | Xrm.Page .getAttrib ute("ftp_p atientcall ersreasonf ordisagree ing").setR equiredLev el("none") ; | |
| 2597 | Xrm.Page .getAttrib ute("ftp_p atientcall ersreasonf ordisagree ing").setV alue(null) ; | |
| 2598 | Xrm.Page .getContro l("ftp_pat ientcaller sreasonfor disagreein g").setVis ible(false ); | |
| 2599 | //Update Note | |
| 2600 | vcmn_app endNoteFin ancialDisc laimer_OnC hange(); | |
| 2601 | } | |
| 2602 | } | |
| 2603 | catch (err) { | |
| 2604 | al ert('Progr ess Note F inancial D isclaimer Function E rror(vcmn_ isPatientI nAgreement _OnChange) : ' + err. message); | |
| 2605 | } | |
| 2606 | } | |
| 2607 | ||
| 2608 | function v cmn_append NoteFinanc ialDisclai mer_OnChan ge() { | |
| 2609 | //This function adds Finan cial Discl aimer text to the en d of the N ote | |
| 2610 | try { | |
| 2611 | // Get Curren t Note Tex t | |
| 2612 | va r vcmn_cur rentNoteTe xt = Xrm.P age.getAtt ribute('ft p_notedeta il').getVa lue(); | |
| 2613 | if (vcmn_cur rentNoteTe xt == null ) { vcmn_c urrentNote Text = ""; } | |
| 2614 | // Create new Financial Disclaime r Text | |
| 2615 | va r vcmn_fin ancialDisc laimerText = ""; | |
| 2616 | ||
| 2617 | va r vcmn_sta ndardText = "\n\nFIN ANCIAL DIS CLAIMER\n" + | |
| 2618 | "------- ---------- ---------- ---------- ---------- ---------- ---------- ---\n" + | |
| 2619 | "The fol lowing dis claimer wa s read to the caller :\n" + | |
| 2620 | "Patient was instr ucted, 'Th is is not an authori zation for VA\n" + | |
| 2621 | "Payment and also 'To have h ospital co ntact the nearest VA \n" + | |
| 2622 | "Facilit y for tran sfer upon stabilizat ion.\n"; | |
| 2623 | va r vcmn_ter minationTe xt = "\n-- ---------- ---------- ---------- ---------- ---------- ---------- --------\n "; | |
| 2624 | ||
| 2625 | va r vcmn_isR eadDisclai mer = Xrm. Page.getAt tribute("f tp_isreadd isclaimer" ).getValue (); | |
| 2626 | va r vcmn_res ponseToDis claimer = Xrm.Page.g etAttribut e("ftp_isd isclaimerr ead").getV alue(); | |
| 2627 | if (vcmn_isR eadDisclai mer == tru e && vcmn_ responseTo Disclaimer == true) { | |
| 2628 | var vcmn _isPatient Agree = Xr m.Page.get Attribute( "ftp_ispat ientagree" ).getValue (); | |
| 2629 | if (vcmn _isPatient Agree == t rue) { | |
| 2630 | vcmn _financial Disclaimer Text = vcm n_standard Text + | |
| 2631 | "\nPatient /Caller ag rees with plan." + v cmn_termin ationText; | |
| 2632 | } | |
| 2633 | else { | |
| 2634 | var vcmn_reaso nForDisagr eeing = Xr m.Page.get Attribute( "ftp_patie ntcallersr easonfordi sagreeing" ).getValue (); | |
| 2635 | if ( vcmn_reaso nForDisagr eeing == n ull) { vcm n_reasonFo rDisagreei ng = ""; } | |
| 2636 | vcmn _financial Disclaimer Text = vcm n_standard Text + | |
| 2637 | "\nPatient /Caller do es not agr ee with th e plan bec ause:\n" + | |
| 2638 | vcmn_reaso nForDisagr eeing + vc mn_termina tionText; | |
| 2639 | } | |
| 2640 | } | |
| 2641 | ||
| 2642 | // Append to existing N ote | |
| 2643 | Xr m.Page.get Attribute( 'ftp_noted etail').se tValue(vcm n_currentN oteText + vcmn_finan cialDiscla imerText); | |
| 2644 | Xr m.Page.get Attribute( 'ftp_noted etail').se tSubmitMod e('always' ); | |
| 2645 | } | |
| 2646 | catch (err) { | |
| 2647 | al ert('Progr ess Note F inancial D isclaimer Function E rror(vcmn_ appendNote FinancialD isclaimer_ OnChange): ' + err.m essage); | |
| 2648 | } | |
| 2649 | } | |
| 2650 | ||
| 2651 | function v cmn_execut eCrmOdataG etRequest( vcmn_jsonQ uery, vcmn _aSync, vc mn_aSyncCa llback, vc mn_skipCou nt, vcmn_o ptionArray ) { | |
| 2652 | //This function executes a CRM Odata web servi ce call to retrieve Crm data | |
| 2653 | //*vcm n_jsonQuer y* - a pro perly form atted CRM Odata Quer y string ( required) | |
| 2654 | //*vcm n_aSync* - specify ' true' to e xecute asy nchronousl y otherwis e 'false' (required) | |
| 2655 | //*vcm n_aSyncCal lback* - s pecify the name of t he return function t o call upo n completi on (requir ed if vcmn _aSync = t rue. Othe rwise '') | |
| 2656 | //*vcm n_skipCoun t* - Initi al setting is always '0', incr ements by 50 per CRM SDK Odata standards (required ) | |
| 2657 | //*vcm n_optionAr ray* - is an optiona l array or single va lue, that contains a dditional task speci fic variab les that c an be pass ed between functions (pass 'nu ll' if not used) | |
| 2658 | try { | |
| 2659 | va r vcmn_ent ityData = null; | |
| 2660 | $. ajax({ | |
| 2661 | type: 'G ET', | |
| 2662 | contentT ype: 'appl ication/js on; charse t=utf-8', | |
| 2663 | datatype : 'json', | |
| 2664 | url: vcm n_jsonQuer y, | |
| 2665 | beforeSe nd: functi on (XMLHtt pRequest) { | |
| 2666 | XMLH ttpRequest .setReques tHeader('A ccept', 'a pplication /json'); | |
| 2667 | }, | |
| 2668 | success: function (data, tex tStatus, X mlHttpRequ est) { | |
| 2669 | vcmn _entityDat a = data; | |
| 2670 | if ( vcmn_aSync == true) { | |
| 2671 | vcmn_aSync Callback(v cmn_entity Data, vcmn _skipCount , vcmn_opt ionArray); | |
| 2672 | } | |
| 2673 | }, | |
| 2674 | error: f unction (X MLHttpRequ est, textS tatus, err orThrown) { | |
| 2675 | aler t('Fail: A jax Error in vcmn_ex ecuteCrmOd ataGetRequ est: ' + e rrorThrown + " Reque st: " + vc mn_jsonQue ry); | |
| 2676 | }, | |
| 2677 | async: v cmn_aSync, | |
| 2678 | cache: f alse | |
| 2679 | }) ; | |
| 2680 | re turn vcmn_ entityData ; | |
| 2681 | } | |
| 2682 | catch (err) { | |
| 2683 | al ert('An er ror occure d in the v cmn_execut eCrmOdataG etRequest function. Error Det ail Messag e: ' + err ); | |
| 2684 | } | |
| 2685 | } | |
| 2686 | ||
| 2687 | function v cmn_getMul tipleEntit yDataAsync (vcmn_enti tySetName, vcmn_attr ibuteSet, vcmn_condi tionalFilt er, vcmn_s ortAttribu te, vcmn_s ortDirecti on, vcmn_s kipCount, vcmn_aSync Callback, vcmn_optio nArray) { | |
| 2688 | //This function returns a CRM JSON d ataset for all entit y records matching c riteria pr ovided Asy ncronously | |
| 2689 | //*vcm n_entitySe tName* - i s the name of the en tity set e .g 'Contac tSet' | |
| 2690 | //*vcm n_attribut eSet* - i s a string containin g the Crm Attributes to retrie ve e.g. 'F irstName, LastName, Telephone1 , EMailAdd ress1' | |
| 2691 | //*vcm n_conditio nalFilter* - is the conditiona l filter v alue place d on the d ata values retrived e.g. 'Stat eCode/Valu e eq 0' t o retrieve active co ntact reco rds only | |
| 2692 | //*vcm n_sortAttr ibute* - i s a string containin g the name of the at tribute to sort the result set by e.g. ' LastName' | |
| 2693 | //*vcm n_sortDire ction* - i s a string specifyin g the sort as Ascend ing or Des cending e. g. 'asc' o r 'desc' | |
| 2694 | //*vcm n_skipCoun t* - is th e starting point in the result (use if m ore than 5 0), (Put 0 if not us ed) | |
| 2695 | //*vcm n_aSyncCal lback* - i s the name of the fu nction to call when returning the result | |
| 2696 | //*vcm n_optionAr ray* - is an optiona l array, t hat contai ns additio nal task s pecific va riables th at can be passed bet ween funct ions | |
| 2697 | ||
| 2698 | try { | |
| 2699 | va r vcmn_jso nQuery = v cmn_server Url + vcmn _crmOdataE ndPoint + '/' + vcmn _entitySet Name + '?$ select=' + vcmn_attr ibuteSet + '&$filter =' + vcmn_ conditiona lFilter + '&$orderby =' + vcmn_ sortAttrib ute + ' ' + vcmn_sor tDirection + '&$skip =' + vcmn_ skipCount; | |
| 2700 | vc mn_execute CrmOdataGe tRequest(v cmn_jsonQu ery, true, vcmn_aSyn cCallback, vcmn_skip Count, vcm n_optionAr ray); | |
| 2701 | } | |
| 2702 | catch (err) { | |
| 2703 | al ert('An er ror occure d in the v cmn_getMul tipleEntit yDataAsync function. Error De tail Messa ge: ' + er r); | |
| 2704 | } | |
| 2705 | } | |
| 2706 | ||
| 2707 | function v cmn_getSin gleEntityD ataSync(vc mn_entityS etName, vc mn_attribu teSet, vcm n_entityId ) { | |
| 2708 | //This function returns a CRM JSON d ataset for a single entity rec ord based on the ent ity id pro vided Sync ronously | |
| 2709 | //*vcm n_entitySe tName* - i s the name of the en tity set e .g 'Contac tSet' | |
| 2710 | //*vcm n_attribut eSet* - i s a string containin g the Crm Attributes to retrie ve e.g. 'F irstName, LastName, Telephone1 , EMailAdd ress1' | |
| 2711 | //*vcm n_entityId * - is the Guid for the entity record | |
| 2712 | ||
| 2713 | try { | |
| 2714 | va r vcmn_ent ityIdNoBra cket = vcm n_entityId .replace(/ ({|})/g, ' '); | |
| 2715 | va r vcmn_sel ectString = '(guid' + "'" + vc mn_entityI dNoBracket + "'" + ' )?$select= ' + vcmn_a ttributeSe t; | |
| 2716 | va r vcmn_jso nQuery = v cmn_server Url + vcmn _crmOdataE ndPoint + '/' + vcmn _entitySet Name + vcm n_selectSt ring; | |
| 2717 | va r vcmn_ent ityData = vcmn_execu teCrmOdata GetRequest (vcmn_json Query, fal se, '', 0, null); | |
| 2718 | re turn vcmn_ entityData ; | |
| 2719 | } | |
| 2720 | catch (err) { | |
| 2721 | al ert('An er ror occure d in the v cmn_getSin gleEntityD ataSync fu nction. E rror Detai l Message: ' + err); | |
| 2722 | } | |
| 2723 | } | |
| 2724 | ||
| 2725 | function v cmn_getMul tipleEntit yDataSync( vcmn_entit ySetName, vcmn_attri buteSet, v cmn_condit ionalFilte r, vcmn_so rtAttribut e, vcmn_so rtDirectio n, vcmn_sk ipCount) { | |
| 2726 | //This function returns a CRM JSON d ataset for all entit y records matching c riteria pr ovided Syn cronously | |
| 2727 | //*vcm n_entitySe tName* - i s the name of the en tity set e .g 'Contac tSet' | |
| 2728 | //*vcm n_attribut eSet* - i s a string containin g the Crm Attributes to retrie ve e.g. 'F irstName, LastName, Telephone1 , EMailAdd ress1' | |
| 2729 | //*vcm n_conditio nalFilter* - is the conditiona l filter v alue place d on the d ata values retrived e.g. 'Stat eCode/Valu e eq 0' t o retrieve active co ntact reco rds only | |
| 2730 | //*vcm n_sortAttr ibute* - i s a string containin g the name of the at tribute to sort the result set by e.g. ' LastName' | |
| 2731 | //*vcm n_sortDire ction* - i s a string specifyin g the sort as Ascend ing or Des cending e. g. 'asc' o r 'desc' | |
| 2732 | //*vcm n_skipCoun t* - is th e starting point in the result (use if m ore than 5 0), (Put 0 if not us ed) | |
| 2733 | ||
| 2734 | try { | |
| 2735 | va r vcmn_jso nQuery = v cmn_server Url + vcmn _crmOdataE ndPoint + '/' + vcmn _entitySet Name + '?$ select=' + vcmn_attr ibuteSet + '&$filter =' + vcmn_ conditiona lFilter + '&$orderby =' + vcmn_ sortAttrib ute + ' ' + vcmn_sor tDirection + '&$skip =' + vcmn_ skipCount; | |
| 2736 | va r vcmn_ent ityData = vcmn_execu teCrmOdata GetRequest (vcmn_json Query, fal se, '', vc mn_skipCou nt, null); | |
| 2737 | re turn vcmn_ entityData ; | |
| 2738 | } | |
| 2739 | catch (err) { | |
| 2740 | al ert('An er ror occure d in the v cmn_getMul tipleEntit yDataSync function. Error Det ail Messag e: ' + err ); | |
| 2741 | } | |
| 2742 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.