Produced by Araxis Merge on 12/4/2017 8:32:33 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_15.zip\WebResources | ftp_VistAMultiNoteFormScriptVistACPRSMultiProgressD9489705-E7FC-E511-9433-0050568D743D | Fri May 19 20:29:42 2017 UTC |
| 2 | VCCM.zip\VCCM\CRM_solutions\VCCMResources\VCCMResources_1_0_0_15.zip\WebResources | ftp_VistAMultiNoteFormScriptVistACPRSMultiProgressD9489705-E7FC-E511-9433-0050568D743D | Thu Nov 30 17:19:08 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 5 | 6050 |
| 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 | var vcmn_V iaDiagnosi sCode = nu ll; | |
| 52 | var vcmn_V iaDiagnosi sDescripti on = null; | |
| 53 | ||
| 54 | var vcmn_b aseService EndpointUr l = null; | |
| 55 | var vcmn_r equestingA pp = null; | |
| 56 | var vcmn_c onsumingAp pToken = n ull; | |
| 57 | var vcmn_c onsumingAp pPassword = null; | |
| 58 | ||
| 59 | var vcmn_f acilityGro upDefaultI d = null; | |
| 60 | ||
| 61 | function v cmn_getQue ryVariable (vcmn_vari able) { | |
| 62 | try { | |
| 63 | // Get a Quer y Variable | |
| 64 | va r vcmn_que ry = windo w.location .search.su bstring(1) ; | |
| 65 | va r vcmn_var s = vcmn_q uery.split ("&"); | |
| 66 | fo r (var i = 0; i < vc mn_vars.le ngth; i++) { | |
| 67 | var vcmn _pair = vc mn_vars[i] .split("=" ); | |
| 68 | if (vcmn _pair[0] = = vcmn_var iable) { | |
| 69 | retu rn decodeU RIComponen t(vcmn_pai r[1]); | |
| 70 | } | |
| 71 | } | |
| 72 | re turn ""; | |
| 73 | } | |
| 74 | catch (err) { | |
| 75 | al ert('Progr ess Note F orm Load S cript Func tion Error (vcmn_getQ ueryVariab le): ' + e rr.message ); | |
| 76 | } | |
| 77 | } | |
| 78 | ||
| 79 | function v cmn_setSim pleLookupV alue(vcmn_ LookupId, vcmn_Type, vcmn_Id, vcmn_Name) { | |
| 80 | try { | |
| 81 | // Sets the v alue for l ookup attr ibutes tha t accept o nly a sing le entity reference. | |
| 82 | va r vcmn_loo kupReferen ce = []; | |
| 83 | vc mn_lookupR eference[0 ] = {}; | |
| 84 | vc mn_lookupR eference[0 ].id = vcm n_Id; | |
| 85 | vc mn_lookupR eference[0 ].entityTy pe = vcmn_ Type; | |
| 86 | vc mn_lookupR eference[0 ].name = v cmn_Name; | |
| 87 | Xr m.Page.get Attribute( vcmn_Looku pId).setVa lue(vcmn_l ookupRefer ence); | |
| 88 | } | |
| 89 | catch (err) { | |
| 90 | al ert('Progr ess Note F orm Load S cript Func tion Error (vcmn_setS impleLooku pValue): ' + err.mes sage); | |
| 91 | } | |
| 92 | } | |
| 93 | ||
| 94 | function v cmn_conver tCrmDateTo VistADate( vcmn_crmDa te) { | |
| 95 | try { | |
| 96 | va r vcmn_Vis tADate = n ull; | |
| 97 | if (vcmn_crm Date != nu ll) { | |
| 98 | var vcmn _crmYear = (vcmn_crm Date.getFu llYear()). toString() ; | |
| 99 | var vcmn _crmMonth = '00'; | |
| 100 | if ((vcm n_crmDate. getMonth() + 1) < 10 ) { | |
| 101 | vcmn _crmMonth = '0' + (v cmn_crmDat e.getMonth () + 1).to String(); | |
| 102 | } | |
| 103 | else { | |
| 104 | vcmn _crmMonth = (vcmn_cr mDate.getM onth() + 1 ).toString (); | |
| 105 | } | |
| 106 | var vcmn _crmDay = '00'; | |
| 107 | if ((vcm n_crmDate. getDate()) < 10) { | |
| 108 | vcmn _crmDay = '0' + (vcm n_crmDate. getDate()) .toString( ); | |
| 109 | } | |
| 110 | else { | |
| 111 | vcmn _crmDay = (vcmn_crmD ate.getDat e()).toStr ing(); | |
| 112 | } | |
| 113 | var vcmn _crmHours = '00'; | |
| 114 | if ((vcm n_crmDate. getHours() ) < 10) { | |
| 115 | vcmn _crmHours = '0' + (v cmn_crmDat e.getHours ()).toStri ng(); | |
| 116 | } | |
| 117 | else { | |
| 118 | vcmn _crmHours = (vcmn_cr mDate.getH ours()).to String(); | |
| 119 | } | |
| 120 | var vcmn _crmMinute s = '00'; | |
| 121 | if ((vcm n_crmDate. getMinutes ()) < 10) { | |
| 122 | vcmn _crmMinute s = '0' + (vcmn_crmD ate.getMin utes()).to String(); | |
| 123 | } | |
| 124 | else { | |
| 125 | vcmn _crmMinute s = (vcmn_ crmDate.ge tMinutes() ).toString (); | |
| 126 | } | |
| 127 | var vcmn _crmSecond s = '00'; | |
| 128 | if ((vcm n_crmDate. getSeconds ()) < 10) { | |
| 129 | vcmn _crmSecond s = '0' + (vcmn_crmD ate.getSec onds()).to String(); | |
| 130 | } | |
| 131 | else { | |
| 132 | vcmn _crmSecond s = (vcmn_ crmDate.ge tSeconds() ).toString (); | |
| 133 | } | |
| 134 | ||
| 135 | //Create VistA Dat e | |
| 136 | vcmn_Vis tADate = v cmn_crmYea r + vcmn_c rmMonth + vcmn_crmDa y + vcmn_c rmHours + vcmn_crmMi nutes + vc mn_crmSeco nds; | |
| 137 | } | |
| 138 | re turn vcmn_ VistADate; | |
| 139 | } | |
| 140 | catch (err) { | |
| 141 | al ert('Progr ess Note E rror(vcmn_ convertCrm DateToVist ADate): ' + err.mess age); | |
| 142 | re turn null; | |
| 143 | } | |
| 144 | } | |
| 145 | ||
| 146 | function v cmn_decryp tServiceCo nnector(vc mn_connect orArray, v cmn_connec torValue) { | |
| 147 | var vc mn_decrypt edString = ""; | |
| 148 | if (vc mn_connect orArray != null && v cmn_connec torArray ! = "") { | |
| 149 | va r vcmn_new Array = vc mn_connect orArray.to String().s plit(','); | |
| 150 | vc mn_newArra y.reverse( ); | |
| 151 | fo r (i = 0; i < vcmn_n ewArray.le ngth; i++) { | |
| 152 | var vcmn _curChar = ""; | |
| 153 | if (i == 0) { | |
| 154 | vcmn _curChar = vcmn_newA rray[i] - vcmn_conne ctorValue; | |
| 155 | } | |
| 156 | else { | |
| 157 | vcmn _curChar = vcmn_newA rray[i] - (i + vcmn_ connectorV alue); | |
| 158 | } | |
| 159 | vcmn_dec ryptedStri ng = vcmn_ decryptedS tring + St ring.fromC harCode(vc mn_curChar ); | |
| 160 | } | |
| 161 | } | |
| 162 | return vcmn_decr yptedStrin g; | |
| 163 | } | |
| 164 | ||
| 165 | function v cmn_UserHa sTeam(team Name, user Guid) { | |
| 166 | try { | |
| 167 | va r vcmn_tea mid = null ; | |
| 168 | va r vcmn_cur rentUserId = userGui d; | |
| 169 | va r vcmn_con ditionalFi lter = "(N ame eq '" + teamName + "')"; | |
| 170 | va r vcmn_tea mData = vc mn_getMult ipleEntity DataSync(' TeamSet', 'TeamId', vcmn_condi tionalFilt er, 'Name' , 'asc', 0 ); | |
| 171 | if (vcmn_tea mData != n ull) { | |
| 172 | for (var i = 0; i <= vcmn_te amData.d.r esults.len gth - 1; i ++) { | |
| 173 | //Ge t Info | |
| 174 | if ( vcmn_teamD ata.d.resu lts[i].Tea mId != nul l) { vcmn_ teamid = v cmn_teamDa ta.d.resul ts[i].Team Id; } | |
| 175 | brea k; | |
| 176 | } | |
| 177 | } | |
| 178 | // If Team ex ists, chec k if the c urrent use r is part of that te am | |
| 179 | va r vcmn_tea mMembershi pId = null ; | |
| 180 | if (vcmn_tea mid != nul l && vcmn_ currentUse rId != nul l) { | |
| 181 | var vcmn _condition alFilter = "(TeamId eq (guid'" + vcmn_te amid + "') and Syste mUserId eq (guid'" + vcmn_curr entUserId + "'))"; | |
| 182 | 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); | |
| 183 | if (vcmn _teamMembe rshipData != null) { | |
| 184 | for (var i = 0 ; i <= vcm n_teamMemb ershipData .d.results .length - 1; i++) { | |
| 185 | //Get Info | |
| 186 | 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; } | |
| 187 | break; | |
| 188 | } | |
| 189 | } | |
| 190 | } | |
| 191 | if (vcmn_tea mMembershi pId != nul l) { retur n true; } | |
| 192 | ||
| 193 | // otherwise return fal se | |
| 194 | re turn false ; | |
| 195 | } | |
| 196 | catch (err) { | |
| 197 | // Display Er ror | |
| 198 | al ert("An er ror occure d in the v cmn_UserHa sTeam func tion. Err or Detail Message: " + err); | |
| 199 | } | |
| 200 | } | |
| 201 | ||
| 202 | function v cmn_Settin gsWebServi ceURL_resp onse(vcmn_ settingDat a, vcmn_la stSkip, vc mn_NoteWri teUrl_NA) { | |
| 203 | try { | |
| 204 | // vcmn_lastS kip is the starting point in t he result (use if mo re than 50 records) //Not used in this s cenario | |
| 205 | va r vcmn_Dac Url = null ; | |
| 206 | va r vcmn_Not esWriteApi Url = null ; | |
| 207 | va r vcmn_ees ummaryApiU rl = null; | |
| 208 | va r vcmn_Vis taUserApiU rl = null; | |
| 209 | va r vcmn_Via AddlSigner sApiUrl = null; | |
| 210 | ||
| 211 | fo r (var i = 0; i <= v cmn_settin gData.d.re sults.leng th - 1; i+ +) { | |
| 212 | //Get in fo | |
| 213 | if (vcmn _settingDa ta.d.resul ts[i].ftp_ DACURL != null) { vc mn_DacUrl = vcmn_set tingData.d .results[i ].ftp_DACU RL; } | |
| 214 | 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; } | |
| 215 | if (vcmn _settingDa ta.d.resul ts[i].ftp_ ESRAPIURL != null) { vcmn_eesu mmaryApiUr l = vcmn_s ettingData .d.results [i].ftp_ES RAPIURL; } | |
| 216 | 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; } | |
| 217 | 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; } | |
| 218 | 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 ; } | |
| 219 | 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 ; } | |
| 220 | 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; } | |
| 221 | 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; } | |
| 222 | 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; } | |
| 223 | break; | |
| 224 | } | |
| 225 | ||
| 226 | if (vcmn_Dac Url != nul l && vcmn_ NotesWrite ApiUrl != null) { | |
| 227 | //Constr uct full w eb service URL | |
| 228 | vcmn_Not eWriteUrl = vcmn_Dac Url + vcmn _NotesWrit eApiUrl; | |
| 229 | } | |
| 230 | el se { | |
| 231 | 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"); | |
| 232 | } | |
| 233 | if (vcmn_Dac Url != nul l && vcmn_ eesummaryA piUrl != n ull) { | |
| 234 | //Constr uct full w eb service URL | |
| 235 | vcmn_ees ummaryURLb ase = vcmn _DacUrl + vcmn_eesum maryApiUrl ; | |
| 236 | } | |
| 237 | el se { | |
| 238 | 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") ; | |
| 239 | } | |
| 240 | if (vcmn_Dac Url != nul l && vcmn_ VistaUserA piUrl != n ull) { | |
| 241 | //Constr uct full w eb service URL | |
| 242 | vcmn_Vis taUsersURL base = vcm n_DacUrl + vcmn_Vist aUserApiUr l; | |
| 243 | } | |
| 244 | el se { | |
| 245 | 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 "); | |
| 246 | } | |
| 247 | if (vcmn_Dac Url != nul l && vcmn_ ViaAddlSig nersApiUrl != null) { | |
| 248 | //Constr uct full w eb service URL | |
| 249 | vcmn_Add SignersUrl = vcmn_Da cUrl + vcm n_ViaAddlS ignersApiU rl; | |
| 250 | } | |
| 251 | el se { | |
| 252 | 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"); | |
| 253 | } | |
| 254 | ||
| 255 | if (vcmn_bas eServiceEn dpointUrl == null || vcmn_requ estingApp == null || vcmn_cons umingAppTo ken == nul l || vcmn_ consumingA ppPassword == null) { | |
| 256 | 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"); | |
| 257 | } | |
| 258 | // Decrypt VI A Service Connector Items | |
| 259 | vc mn_request ingApp = v cmn_decryp tServiceCo nnector(vc mn_request ingApp, 4) ; | |
| 260 | vc mn_consumi ngAppToken = vcmn_de cryptServi ceConnecto r(vcmn_con sumingAppT oken, 6); | |
| 261 | vc mn_consumi ngAppPassw ord = vcmn _decryptSe rviceConne ctor(vcmn_ consumingA ppPassword , 8); | |
| 262 | ||
| 263 | // Proceed wi th Form Lo ad logic w ith URL | |
| 264 | vc mn_newProg ressNoteLo ad_WebURL( ); | |
| 265 | } | |
| 266 | catch (err) { | |
| 267 | al ert('Progr ess Note F orm Load S cript Func tion Error (vcmn_Sett ingsWebSer viceURL_re sponse): ' + err.mes sage); | |
| 268 | } | |
| 269 | } | |
| 270 | ||
| 271 | function v cmn_newPro gressNoteL oad() { | |
| 272 | try { | |
| 273 | // GET CRM SE TTINGS WEB SERVICE U RLS | |
| 274 | va r vcmn_con ditionalFi lter = "(m cs_name eq 'Active S ettings')" ; | |
| 275 | 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); | |
| 276 | } | |
| 277 | catch (err) { | |
| 278 | // Display Er ror | |
| 279 | al ert('Progr ess Note F orm Load S cript Func tion Error (vcmn_newP rogressNot eLoad): ' + err.mess age); | |
| 280 | } | |
| 281 | } | |
| 282 | ||
| 283 | function v cmn_newPro gressNoteL oad_WebURL () { | |
| 284 | try { | |
| 285 | // Check if m arked as a workload encounter | |
| 286 | if (Xrm.Page .getAttrib ute('ftp_i sworkloade ncounter') .getValue( ) == true) { | |
| 287 | vcmn_isW orkloadEnc ounter = t rue; | |
| 288 | Xrm.Page .ui.tabs.g et('Tab_Wo rkloadEnco unter').se tVisible(t rue); | |
| 289 | Xrm.Page .getAttrib ute("ftp_s electedwor kloadnotet itletext") .setRequir edLevel("r equired"); | |
| 290 | Xrm.Page .getAttrib ute("ftp_s electedwor kloadlocat iontext"). setRequire dLevel("re quired"); | |
| 291 | Xrm.Page .getAttrib ute("ftp_w orkloadinp atient").s etRequired Level("req uired"); | |
| 292 | Xrm.Page .getAttrib ute("ftp_c ptcode").s etRequired Level("req uired"); | |
| 293 | Xrm.Page .getAttrib ute("ftp_d iagnosisco de").setRe quiredLeve l("require d"); | |
| 294 | //Set Si gn this no te to Yes | |
| 295 | Xrm.Page .getAttrib ute('ftp_s ignthisnot e').setVal ue(1000000 01); | |
| 296 | Xrm.Page .getAttrib ute('ftp_s ignthisnot e').setSub mitMode('a lways'); | |
| 297 | //Histor ical Note Settings | |
| 298 | Xrm.Page .ui.tabs.g et('Tab_Hi storicalNo te').setVi sible(fals e); | |
| 299 | Xrm.Page .getAttrib ute("ftp_n otehospita llocation" ).setRequi redLevel(" none"); | |
| 300 | Xrm.Page .getAttrib ute("ftp_l ocalnoteti tle").setR equiredLev el("none") ; | |
| 301 | } | |
| 302 | el se { | |
| 303 | vcmn_isW orkloadEnc ounter = f alse; | |
| 304 | Xrm.Page .ui.tabs.g et('Tab_Wo rkloadEnco unter').se tVisible(f alse); | |
| 305 | Xrm.Page .getAttrib ute("ftp_s electedwor kloadnotet itletext") .setRequir edLevel("n one"); | |
| 306 | Xrm.Page .getAttrib ute("ftp_s electedwor kloadlocat iontext"). setRequire dLevel("no ne"); | |
| 307 | Xrm.Page .getAttrib ute("ftp_w orkloadinp atient").s etRequired Level("non e"); | |
| 308 | Xrm.Page .getAttrib ute("ftp_c ptcode").s etRequired Level("non e"); | |
| 309 | Xrm.Page .getAttrib ute("ftp_d iagnosisco de").setRe quiredLeve l("none"); | |
| 310 | //Histor ical Note Settings | |
| 311 | Xrm.Page .ui.tabs.g et('Tab_Hi storicalNo te').setVi sible(true ); | |
| 312 | Xrm.Page .getAttrib ute("ftp_n otehospita llocation" ).setRequi redLevel(" required") ; | |
| 313 | Xrm.Page .getAttrib ute("ftp_l ocalnoteti tle").setR equiredLev el("requir ed"); | |
| 314 | } | |
| 315 | ||
| 316 | // Set defaul t values b ased on th e current user's USD Config an d Facility | |
| 317 | va r vcmn_cur rentUserId = Xrm.Pag e.context. getUserId( ); | |
| 318 | va r vcmn_cur rentUserDa ta = vcmn_ getSingleE ntityDataS ync('Syste mUserSet', 'msdyusd_ USDConfigu rationId, ftp_Facili tySiteId', vcmn_curr entUserId) ; | |
| 319 | if (vcmn_cur rentUserDa ta != null ) { | |
| 320 | if (vcmn _currentUs erData.d.m sdyusd_USD Configurat ionId != n ull) { | |
| 321 | if ( vcmn_curre ntUserData .d.msdyusd _USDConfig urationId. Id != null ) { | |
| 322 | if (vcmn_c urrentUser Data.d.msd yusd_USDCo nfiguratio nId.Name ! = null && vcmn_curre ntUserData .d.msdyusd _USDConfig urationId. Name != '' ) { | |
| 323 | if (vc mn_current UserData.d .msdyusd_U SDConfigur ationId.Na me == "Pha rmacy Conf iguration" ) { | |
| 324 | // Set Local Title View to Pharma cy | |
| 325 | Xr m.Page.get Control("f tp_localno tetitle"). setDefault View("{AF5 A2EBB-A22A -E711-944E -0050568D7 43D}"); | |
| 326 | // Dev Test | |
| 327 | // Xrm.Page.g etControl( "ftp_local notetitle" ).setDefau ltView("{D CEC6C83-B5 34-E711-82 43-000C29F F8C5B}"); | |
| 328 | } | |
| 329 | } | |
| 330 | //Retrieve Facillity Group Def ault info | |
| 331 | if (vcmn_c urrentUser Data.d.ftp _FacilityS iteId != n ull) { | |
| 332 | if (vc mn_current UserData.d .ftp_Facil itySiteId. Id != null ) { | |
| 333 | // Data Requi red to loo kup Facili ty Group D efaults ar e present | |
| 334 | 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 + "')"; | |
| 335 | vc mn_getMult ipleEntity DataAsync( 'ftp_facil itygroupde faultSet', 'ftp_loca lnotestitl e, ftp_hos pitallocat ion, ftp_f acilitygro updefaultI d, ftp_via workloaden counterloc ationdefau lt, ftp_vi aworkloade ncounterno tetitledef ault', vcm n_conditio nalFilter, 'ftp_name ', 'asc', 0, vcmn_fa cilityGrou pDefault_r esponse, v cmn_curren tUserData. d.ftp_Faci litySiteId .Id); | |
| 336 | } | |
| 337 | } | |
| 338 | } | |
| 339 | } | |
| 340 | } | |
| 341 | ||
| 342 | // Only handl e forms in create st ate | |
| 343 | if (Xrm.Page .ui.getFor mType() != 1) { retu rn false; } | |
| 344 | ||
| 345 | // Determine if regardi ng field i s prefille d (added b y subgrid+ ) | |
| 346 | va r vcmn_req uestId = X rm.Page.ge tAttribute ('regardin gobjectid' ).getValue (); | |
| 347 | va r vcmn_tri ageexpert = null; | |
| 348 | va r vcmn_tri ageminutes = null; | |
| 349 | if (vcmn_req uestId == null) { | |
| 350 | //Get cu stom param eters pass ed to the form | |
| 351 | var vcmn _regarding objectid = vcmn_getQ ueryVariab le("parame ter_regard ingobjecti d"); | |
| 352 | var vcmn _regarding objectidna me = vcmn_ getQueryVa riable("pa rameter_re gardingobj ectidname" ); | |
| 353 | var vcmn _regarding objectidty pe = vcmn_ getQueryVa riable("pa rameter_re gardingobj ectidtype" ); | |
| 354 | vcmn_tri ageexpert = vcmn_get QueryVaria ble("param eter_triag eexpert"); | |
| 355 | vcmn_tri ageminutes = vcmn_ge tQueryVari able("para meter_tria geminutes" ); | |
| 356 | ||
| 357 | if (vcmn _regarding objectid = = '' || vc mn_regardi ngobjectid == null | | vcmn_reg ardingobje ctidname = = '' || vc mn_regardi ngobjectid name == nu ll || | |
| 358 | vcmn _regarding objectidty pe == '' | | vcmn_reg ardingobje ctidtype = = null) { return fal se; } | |
| 359 | } | |
| 360 | el se { | |
| 361 | var vcmn _regarding objectid = vcmn_requ estId[0].i d; | |
| 362 | var vcmn _regarding objectidna me = vcmn_ requestId[ 0].name; | |
| 363 | var vcmn _regarding objectidty pe = vcmn_ requestId[ 0].entityT ype; | |
| 364 | } | |
| 365 | if (vcmn_tri ageexpert == null) { vcmn_tria geexpert = 'NO'; } | |
| 366 | if (vcmn_tri ageminutes == null) { vcmn_tri ageminutes = 0; } | |
| 367 | ||
| 368 | // Populate r egarding o bject | |
| 369 | vc mn_setSimp leLookupVa lue('regar dingobject id', vcmn_ regardingo bjectidtyp e, vcmn_re gardingobj ectid, vcm n_regardin gobjectidn ame); | |
| 370 | Xr m.Page.get Attribute( 'regarding objectid') .setSubmit Mode('alwa ys'); | |
| 371 | ||
| 372 | // Prompt use r if progr ess note i s a worklo ad encount er except when a Tri age Note | |
| 373 | if (vcmn_tri ageexpert == 'NO') { | |
| 374 | Xrm.Util ity.confir mDialog( | |
| 375 | "Is this note a Workload Encounter ?, Select OK if Yes, otherwise CANCEL.", | |
| 376 | func tion () { | |
| 377 | Xrm.Page.g etAttribut e('ftp_isw orkloadenc ounter').s etValue(tr ue); | |
| 378 | Xrm.Page.g etAttribut e('ftp_isw orkloadenc ounter').s etSubmitMo de('always '); | |
| 379 | //Display workload e ncounter t ab and oth er info ac cordingly. .. | |
| 380 | Xrm.Page.u i.tabs.get ('Tab_Work loadEncoun ter').setV isible(tru e); | |
| 381 | vcmn_isWor kloadEncou nter = tru e; | |
| 382 | Xrm.Page.g etAttribut e("ftp_sel ectedworkl oadnotetit letext").s etRequired Level("req uired"); | |
| 383 | Xrm.Page.g etAttribut e("ftp_sel ectedworkl oadlocatio ntext").se tRequiredL evel("requ ired"); | |
| 384 | Xrm.Page.g etAttribut e("ftp_wor kloadinpat ient").set RequiredLe vel("requi red"); | |
| 385 | Xrm.Page.g etAttribut e("ftp_cpt code").set RequiredLe vel("requi red"); | |
| 386 | Xrm.Page.g etAttribut e("ftp_dia gnosiscode ").setRequ iredLevel( "required" ); | |
| 387 | //Historic al Note Se ttings | |
| 388 | Xrm.Page.u i.tabs.get ('Tab_Hist oricalNote ').setVisi ble(false) ; | |
| 389 | Xrm.Page.g etAttribut e("ftp_not ehospitall ocation"). setRequire dLevel("no ne"); | |
| 390 | Xrm.Page.g etAttribut e("ftp_loc alnotetitl e").setReq uiredLevel ("none"); | |
| 391 | } | |
| 392 | ); | |
| 393 | } | |
| 394 | el se { | |
| 395 | Xrm.Page .getAttrib ute('ftp_i sworkloade ncounter') .setValue( true); | |
| 396 | Xrm.Page .getAttrib ute('ftp_i sworkloade ncounter') .setSubmit Mode('alwa ys'); | |
| 397 | //Displa y workload encounter tab and o ther info accordingl y... | |
| 398 | Xrm.Page .ui.tabs.g et('Tab_Wo rkloadEnco unter').se tVisible(t rue); | |
| 399 | vcmn_isW orkloadEnc ounter = t rue; | |
| 400 | Xrm.Page .getAttrib ute("ftp_s electedwor kloadnotet itletext") .setRequir edLevel("r equired"); | |
| 401 | Xrm.Page .getAttrib ute("ftp_s electedwor kloadlocat iontext"). setRequire dLevel("re quired"); | |
| 402 | Xrm.Page .getAttrib ute("ftp_w orkloadinp atient").s etRequired Level("req uired"); | |
| 403 | Xrm.Page .getAttrib ute("ftp_c ptcode").s etRequired Level("req uired"); | |
| 404 | Xrm.Page .getAttrib ute("ftp_d iagnosisco de").setRe quiredLeve l("require d"); | |
| 405 | //Histor ical Note Settings | |
| 406 | Xrm.Page .ui.tabs.g et('Tab_Hi storicalNo te').setVi sible(fals e); | |
| 407 | Xrm.Page .getAttrib ute("ftp_n otehospita llocation" ).setRequi redLevel(" none"); | |
| 408 | Xrm.Page .getAttrib ute("ftp_l ocalnoteti tle").setR equiredLev el("none") ; | |
| 409 | } | |
| 410 | ||
| 411 | // If Histori cal Encoun ter | |
| 412 | if (vcmn_isW orkloadEnc ounter == false) { | |
| 413 | Xrm.Page .ui.tabs.g et('Tab_Hi storicalNo te').setVi sible(true ); | |
| 414 | Xrm.Page .getAttrib ute("ftp_n otehospita llocation" ).setRequi redLevel(" required") ; | |
| 415 | Xrm.Page .getAttrib ute("ftp_l ocalnoteti tle").setR equiredLev el("requir ed"); | |
| 416 | } | |
| 417 | ||
| 418 | // Populate s ubject wit h regardin g objects title | |
| 419 | Xr m.Page.get Attribute( 'subject') .setValue( vcmn_Progr essNoteSub ject + vcm n_regardin gobjectidn ame); | |
| 420 | if (vcmn_tri ageexpert == 'YES') { Xrm.Page .getAttrib ute('subje ct').setVa lue(vcmn_T riageNoteS ubject + v cmn_regard ingobjecti dname); } | |
| 421 | 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); } | |
| 422 | Xr m.Page.get Attribute( 'subject') .setSubmit Mode('alwa ys'); | |
| 423 | // Default Sa ve to CPPR S | |
| 424 | Xr m.Page.get Attribute( 'ftp_savet ovista').s etValue(10 0000001); //Yes | |
| 425 | Xr m.Page.get Attribute( 'ftp_savet ovista').s etSubmitMo de('always '); | |
| 426 | ||
| 427 | va r vcmn_vet eranId = n ull; //Fr om request customeri d | |
| 428 | ||
| 429 | // Populate f orm with r elated CRM data | |
| 430 | va r vcmn_sub ReasonId = null; //R eference t o the Reas on for Req uest Sub R eason | |
| 431 | va r vcmn_min orReasonId = null; //Referenc e to the R eason for Request Mi nor Reason | |
| 432 | va r vcmn_sub ReasonTemp lateText = null; | |
| 433 | va r vcmn_min orReasonTe mplateText = null; | |
| 434 | va r vcmn_min orReasonNo teSubText = null; | |
| 435 | ||
| 436 | 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 ); | |
| 437 | if (vcmn_req uestData ! = null) { | |
| 438 | if (vcmn _requestDa ta.d.ftp_C allbackNum ber != nul l) { | |
| 439 | Xrm. Page.getAt tribute('f tp_callbac knumber'). setValue(v cmn_reques tData.d.ft p_Callback Number); | |
| 440 | Xrm. Page.getAt tribute('f tp_callbac knumber'). setSubmitM ode('alway s'); | |
| 441 | } | |
| 442 | if (vcmn _requestDa ta.d.ftp_R easonforRe quest != n ull) { | |
| 443 | 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); | |
| 444 | Xrm. Page.getAt tribute('f tp_reasonf orrequest' ).setSubmi tMode('alw ays'); | |
| 445 | } | |
| 446 | ||
| 447 | if (vcmn _requestDa ta.d.ftp_R easonforRe quest.Name == "Pharm acy Outbou nd Call") { | |
| 448 | if ( typeof out boundTempl ate_buildN oteText == "function ") { | |
| 449 | outboundTe mplate_bui ldNoteText (); | |
| 450 | } | |
| 451 | } | |
| 452 | else { | |
| 453 | if ( vcmn_reque stData.d.f tp_SubReas onId != nu ll) { | |
| 454 | vcmn_subRe asonId = v cmn_reques tData.d.ft p_SubReaso nId.Id; | |
| 455 | if (vcmn_s ubReasonId != null) { | |
| 456 | //Get Template T ext | |
| 457 | var vc mn_subreas onData = v cmn_getSin gleEntityD ataSync('f tp_subreas onSet', 'f tp_notetex t', vcmn_s ubReasonId ); | |
| 458 | if (vc mn_subreas onData.d.f tp_notetex t != null) { | |
| 459 | vc mn_subReas onTemplate Text = vcm n_subreaso nData.d.ft p_notetext ; | |
| 460 | } | |
| 461 | } | |
| 462 | } | |
| 463 | if ( vcmn_reque stData.d.f tp_MinorRe asonId != null) { | |
| 464 | vcmn_minor ReasonId = vcmn_requ estData.d. ftp_MinorR easonId.Id ; | |
| 465 | if (vcmn_m inorReason Id != null ) { | |
| 466 | //Get Template T ext | |
| 467 | var vc mn_minorre asonData = vcmn_getS ingleEntit yDataSync( 'ftp_minor reasonSet' , 'ftp_nam e, ftp_not etext', vc mn_minorRe asonId); | |
| 468 | if (vc mn_minorre asonData.d .ftp_name != null) { | |
| 469 | vc mn_minorRe asonTempla teText = v cmn_minorr easonData. d.ftp_name ; | |
| 470 | } | |
| 471 | if (vc mn_minorre asonData.d .ftp_notet ext != nul l) { | |
| 472 | vc mn_minorRe asonNoteSu bText = vc mn_minorre asonData.d .ftp_notet ext; | |
| 473 | } | |
| 474 | } | |
| 475 | } | |
| 476 | ||
| 477 | if ( vcmn_reque stData.d.C ustomerId != null) { | |
| 478 | 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); | |
| 479 | Xrm.Page.g etAttribut e('ftp_pat ient').set SubmitMode ('always') ; | |
| 480 | //Set as v eteran id | |
| 481 | vcmn_veter anId = vcm n_requestD ata.d.Cust omerId.Id | |
| 482 | } | |
| 483 | ||
| 484 | //Co nstruct Te mplate Not e | |
| 485 | var vcmn_subRe asonName = null; | |
| 486 | var vcmn_templ ateNote = ""; | |
| 487 | var vcmn_lastF illed = "" ; | |
| 488 | var vcmn_quant ityReports Taking = n ull; | |
| 489 | var vcmn_rxNum ber = null ; | |
| 490 | var vcmn_rxRef illQuantit y = null; | |
| 491 | var vcmn_track ingNumber = null; | |
| 492 | var vcmn_opioi dAgreement Onfile = n ull; | |
| 493 | var vcmn_UDSon file = nul l; | |
| 494 | var vcmn_state DrugMonito ringReport = null; | |
| 495 | var vcmn_spdmp stateonfil e = null; | |
| 496 | var vcmn_sPDMP State2 = n ull; | |
| 497 | var vcmn_picku pmethod = null; | |
| 498 | ||
| 499 | var vcmn_early RefillComm ent = null ; | |
| 500 | var vcmn_quant ityTaking = null; | |
| 501 | var vcmn_vacat ionStart = null; | |
| 502 | var vcmn_vacat ionEnd = n ull; | |
| 503 | ||
| 504 | if ( vcmn_reque stData.d.f tp_LastFil led != nul l) { vcmn_ lastFilled = new Dat e(parseInt (vcmn_requ estData.d. ftp_LastFi lled.toStr ing().repl ace("/Date (", "").re place(")/" , ""), 10) ); } | |
| 505 | if ( vcmn_reque stData.d.f tp_Quantit yReportsTa king != nu ll) { vcmn _quantityR eportsTaki ng = vcmn_ requestDat a.d.ftp_Qu antityRepo rtsTaking; } | |
| 506 | if ( vcmn_reque stData.d.f tp_RxNumbe r != null) { vcmn_rx Number = v cmn_reques tData.d.ft p_RxNumber ; } | |
| 507 | if ( vcmn_reque stData.d.f tp_RxRefil lQuantity != null) { vcmn_rxRe fillQuanti ty = vcmn_ requestDat a.d.ftp_Rx RefillQuan tity; } | |
| 508 | if ( vcmn_reque stData.d.f tp_Trackin gNumber != null) { v cmn_tracki ngNumber = vcmn_requ estData.d. ftp_Tracki ngNumber; } | |
| 509 | if ( vcmn_reque stData.d.f tp_OpiodAg reementOnf ile != nul l) { vcmn_ opioidAgre ementOnfil e = vcmn_r equestData .d.ftp_Opi odAgreemen tOnfile.Va lue; } | |
| 510 | if ( vcmn_reque stData.d.f tp_UDSonfi le != null ) { vcmn_U DSonfile = vcmn_requ estData.d. ftp_UDSonf ile.Value; } | |
| 511 | if ( vcmn_reque stData.d.f tp_StateDr ugMonitori ngReport ! = null) { vcmn_state DrugMonito ringReport = vcmn_re questData. d.ftp_Stat eDrugMonit oringRepor t.Value; } | |
| 512 | if ( vcmn_reque stData.d.f tp_spdmpst ateonfile != null) { vcmn_spdm pstateonfi le = vcmn_ requestDat a.d.ftp_sp dmpstateon file.Value ; } | |
| 513 | if ( vcmn_reque stData.d.f tp_SPDMPSt ate2 != nu ll) { vcmn _sPDMPStat e2 = vcmn_ requestDat a.d.ftp_SP DMPState2. Value; } | |
| 514 | if ( vcmn_reque stData.d.f tp_pickupm ethod != n ull) { vcm n_pickupme thod = vcm n_requestD ata.d.ftp_ pickupmeth od.Value; } | |
| 515 | ||
| 516 | if ( vcmn_reque stData.d.f tp_earlyre fillcommen t != null) { vcmn_ea rlyRefillC omment = v cmn_reques tData.d.ft p_earlyref illcomment ; } | |
| 517 | if ( vcmn_reque stData.d.f tp_quantit ytaking != null) { v cmn_quanti tyTaking = vcmn_requ estData.d. ftp_quanti tytaking; } | |
| 518 | if ( vcmn_reque stData.d.f tp_vacatio nstart != null) { vc mn_vacatio nStart = n ew Date(pa rseInt(vcm n_requestD ata.d.ftp_ vacationst art.toStri ng().repla ce("/Date( ", "").rep lace(")/", ""), 10)) ; } | |
| 519 | if ( vcmn_reque stData.d.f tp_vacatio nend != nu ll) { vcmn _vacationE nd = new D ate(parseI nt(vcmn_re questData. d.ftp_vaca tionend.to String().r eplace("/D ate(", "") .replace(" )/", ""), 10)); } | |
| 520 | ||
| 521 | if ( vcmn_reque stData.d.f tp_SubReas onId != nu ll) { | |
| 522 | vcmn_subRe asonId = v cmn_reques tData.d.ft p_SubReaso nId.Id; | |
| 523 | vcmn_subRe asonName = vcmn_requ estData.d. ftp_SubRea sonId.Name ; | |
| 524 | ||
| 525 | if (vcmn_s ubReasonNa me == 'Reg ular') { | |
| 526 | vcmn_t emplateNot e = vcmn_t emplateNot e + "Veter an is requ esting a R ENEWAL." + "\n\n"; | |
| 527 | vcmn_t emplateNot e = vcmn_t emplateNot e + "Last Filled: " + vcmn_las tFilled + "\n\n"; | |
| 528 | if (vc mn_minorRe asonTempla teText != null) { | |
| 529 | vc mn_templat eNote = vc mn_templat eNote + vc mn_minorRe asonTempla teText + " \n\n"; | |
| 530 | } | |
| 531 | if (vc mn_minorRe asonNoteSu bText != n ull) { | |
| 532 | vc mn_templat eNote = vc mn_templat eNote + vc mn_minorRe asonNoteSu bText + "\ n\n"; | |
| 533 | } | |
| 534 | if (vc mn_subReas onTemplate Text != nu ll) { | |
| 535 | vc mn_templat eNote = vc mn_templat eNote + vc mn_subReas onTemplate Text + "\n \n"; | |
| 536 | } | |
| 537 | } | |
| 538 | ||
| 539 | if (vcmn_s ubReasonNa me == 'Ear ly') { | |
| 540 | vcmn_t emplateNot e = vcmn_t emplateNot e + "Veter an is requ esting EAR LY FILL." + "\n\n"; | |
| 541 | vcmn_t emplateNot e = vcmn_t emplateNot e + "Last Filled: " + vcmn_las tFilled + "\n\n"; | |
| 542 | if (vc mn_minorRe asonTempla teText != null) { | |
| 543 | vc mn_templat eNote = vc mn_templat eNote + vc mn_minorRe asonTempla teText + " \n\n"; | |
| 544 | } | |
| 545 | ||
| 546 | if (vc mn_quantit yTaking != null) { | |
| 547 | vc mn_templat eNote = vc mn_templat eNote + "Q uantity Ta king: " + vcmn_quant ityTaking + "\n\n"; | |
| 548 | } | |
| 549 | ||
| 550 | if (vc mn_vacatio nStart != null && vc mn_vacatio nEnd != nu ll) { | |
| 551 | vc mn_templat eNote = vc mn_templat eNote + "V eteran Lea ving Town: " + vcmn_ vacationSt art + ' - ' + vcmn_v acationEnd + "\n\n"; | |
| 552 | } | |
| 553 | ||
| 554 | if (vc mn_minorRe asonNoteSu bText != n ull) { | |
| 555 | vc mn_templat eNote = vc mn_templat eNote + vc mn_minorRe asonNoteSu bText + "\ n\n"; | |
| 556 | } | |
| 557 | if (vc mn_subReas onTemplate Text != nu ll) { | |
| 558 | vc mn_templat eNote = vc mn_templat eNote + vc mn_subReas onTemplate Text + "\n \n"; | |
| 559 | } | |
| 560 | } | |
| 561 | ||
| 562 | if (vcmn_s ubReasonNa me == 'Los t') { | |
| 563 | vcmn_t emplateNot e = vcmn_t emplateNot e + "Veter an claims prescripti ons(s) wer e LOST and is reques ting a new prescript ion/early fill." + " \n\n"; | |
| 564 | if (vc mn_rxNumbe r != null) { | |
| 565 | vc mn_templat eNote = vc mn_templat eNote + "R X#: " + vc mn_rxNumbe r + "\n\n" ; | |
| 566 | } | |
| 567 | if (vc mn_rxRefil lQuantity != null) { | |
| 568 | vc mn_templat eNote = vc mn_templat eNote + "R x Refill Q uantity: " + vcmn_rx RefillQuan tity + "\n \n"; | |
| 569 | } | |
| 570 | vcmn_t emplateNot e = vcmn_t emplateNot e + "Last Filled: " + vcmn_las tFilled + "\n\n"; | |
| 571 | if (vc mn_minorRe asonTempla teText != null) { | |
| 572 | vc mn_templat eNote = vc mn_templat eNote + vc mn_minorRe asonTempla teText + " \n\n"; | |
| 573 | } | |
| 574 | if (vc mn_trackin gNumber != null) { | |
| 575 | vc mn_templat eNote = vc mn_templat eNote + "T racking Nu mber: " + vcmn_track ingNumber + "\n\n"; | |
| 576 | } | |
| 577 | if (vc mn_minorRe asonNoteSu bText != n ull) { | |
| 578 | vc mn_templat eNote = vc mn_templat eNote + vc mn_minorRe asonNoteSu bText + "\ n\n"; | |
| 579 | } | |
| 580 | if (vc mn_subReas onTemplate Text != nu ll) { | |
| 581 | vc mn_templat eNote = vc mn_templat eNote + vc mn_subReas onTemplate Text + "\n \n"; | |
| 582 | } | |
| 583 | } | |
| 584 | ||
| 585 | if (vcmn_s ubReasonNa me == 'Sto len') { | |
| 586 | vcmn_t emplateNot e = vcmn_t emplateNot e + "Veter an claims prescripti ons(s) wer e STOLEN a nd is requ esting a n ew prescri ption/earl y fill." + "\n\n"; | |
| 587 | vcmn_t emplateNot e = vcmn_t emplateNot e + "Last Filled: " + vcmn_las tFilled + "\n\n"; | |
| 588 | if (vc mn_minorRe asonTempla teText != null) { | |
| 589 | vc mn_templat eNote = vc mn_templat eNote + vc mn_minorRe asonTempla teText + " \n\n"; | |
| 590 | } | |
| 591 | if (vc mn_minorRe asonNoteSu bText != n ull) { | |
| 592 | vc mn_templat eNote = vc mn_templat eNote + vc mn_minorRe asonNoteSu bText + "\ n\n"; | |
| 593 | } | |
| 594 | if (vc mn_subReas onTemplate Text != nu ll) { | |
| 595 | vc mn_templat eNote = vc mn_templat eNote + vc mn_subReas onTemplate Text + "\n \n"; | |
| 596 | } | |
| 597 | } | |
| 598 | ||
| 599 | //If Templ ate Text w as populat ed, fill i n addition al info... | |
| 600 | if (vcmn_t emplateNot e != '') { | |
| 601 | vcmn_t emplateNot e = vcmn_t emplateNot e + "\n___ __________ __________ __________ __________ __________ __________ __________ __________ __________ __________ __________ _____\n\n" ; | |
| 602 | //Is a n Opioid A greement c urrent and onfile? | |
| 603 | if (vc mn_opioidA greementOn file != nu ll) { | |
| 604 | vc mn_templat eNote = vc mn_templat eNote + "C onsent for Long-Term Opioid Th erapy for Pain:\n"; | |
| 605 | if (vcmn_opi oidAgreeme ntOnfile = = 10000000 0) { | |
| 606 | //Yes Op tion | |
| 607 | vcmn_tem plateNote = vcmn_tem plateNote + "[X] Yes - See Pos tings\n\n" ; | |
| 608 | } | |
| 609 | if (vcmn_opi oidAgreeme ntOnfile = = 10000000 1) { | |
| 610 | //No Opt ion | |
| 611 | vcmn_tem plateNote = vcmn_tem plateNote + "[X] No - Veteran does not h ave a sign ed Consent for Long- Term Opioi d Therapy for pain ( in Posting s).\nConse nt MUST be reviewed and signed as soon a s possible .\n\n"; | |
| 612 | } | |
| 613 | } | |
| 614 | //Is v alid Urine Drug Scre en on-file ? | |
| 615 | if (vc mn_UDSonfi le != null ) { | |
| 616 | vc mn_templat eNote = vc mn_templat eNote + "I s valid Ur ine Drug S creen on-f ile?\n"; | |
| 617 | if (vcmn_UDS onfile == 100000000) { | |
| 618 | //Yes Op tion | |
| 619 | vcmn_tem plateNote = vcmn_tem plateNote + "[X] Yes - See Pos tings\n\n" ; | |
| 620 | } | |
| 621 | if (vcmn_UDS onfile == 100000001) { | |
| 622 | //No Opt ion | |
| 623 | vcmn_tem plateNote = vcmn_tem plateNote + "[X] No - Veteran does not h ave a vali d Urine Dr ug Screen on-file.\n \n"; | |
| 624 | } | |
| 625 | } | |
| 626 | //Stat e Drug Mon itoring Re port? | |
| 627 | if (vc mn_stateDr ugMonitori ngReport ! = null) { | |
| 628 | vc mn_templat eNote = vc mn_templat eNote + "S tate Presc ription Dr ug Monitor ing Progra m (SPDMP) report com pleted in last year: \n"; | |
| 629 | if (vcmn_sta teDrugMoni toringRepo rt == 1000 00000) { | |
| 630 | //Positi ve Option | |
| 631 | vcmn_tem plateNote = vcmn_tem plateNote + "[X] Pos itive - se e SPDMP no te.\n\n"; | |
| 632 | } | |
| 633 | if (vcmn_sta teDrugMoni toringRepo rt == 1000 00001) { | |
| 634 | //Negati ve Option | |
| 635 | vcmn_tem plateNote = vcmn_tem plateNote + "[X] Neg ative.\n\n "; | |
| 636 | } | |
| 637 | if (vcmn_sta teDrugMoni toringRepo rt == 1000 00002) { | |
| 638 | //Not on File Opti on | |
| 639 | vcmn_tem plateNote = vcmn_tem plateNote + "[X] Non e on file, Pharmacy to request .\n\n"; | |
| 640 | } | |
| 641 | // Add in Sta tes (2), c onvert int egers to s tate names from form 's hidden state opti ons | |
| 642 | va r vcmn_usS tatesOptio ns = Xrm.P age.getAtt ribute("ft p_usstates option").g etOptions( ); | |
| 643 | va r vcmn_sta teList = " "; | |
| 644 | if (vcmn_spd mpstateonf ile != nul l) { | |
| 645 | //find t ext value for option | |
| 646 | $(vcmn_u sStatesOpt ions).each (function (i, e) { | |
| 647 | var vcmn_optio nText = $( this)[0].t ext; | |
| 648 | var vcmn_optio nValue = $ (this)[0]. value; | |
| 649 | if ( vcmn_spdmp stateonfil e == vcmn_ optionValu e) { vcmn_ stateList = vcmn_opt ionText; } | |
| 650 | }); | |
| 651 | } | |
| 652 | if (vcmn_sPD MPState2 ! = null) { | |
| 653 | //find t ext value for option | |
| 654 | $(vcmn_u sStatesOpt ions).each (function (i, e) { | |
| 655 | var vcmn_optio nText = $( this)[0].t ext; | |
| 656 | var vcmn_optio nValue = $ (this)[0]. value; | |
| 657 | if ( vcmn_sPDMP State2 == vcmn_optio nValue) { vcmn_state List = vcm n_stateLis t + ", " + vcmn_opti onText; } | |
| 658 | }); | |
| 659 | } | |
| 660 | if (vcmn_sta teList != "") { | |
| 661 | //Add st ates list to note | |
| 662 | vcmn_tem plateNote = vcmn_tem plateNote + "State P rescriptio n Drug Mon itoring Pr ogram for the follow ing state( s): " + vc mn_stateLi st; | |
| 663 | } | |
| 664 | } | |
| 665 | ||
| 666 | //If f tp_pickupm ethod has a value | |
| 667 | if (vc mn_pickupm ethod != n ull) { | |
| 668 | vc mn_templat eNote = vc mn_templat eNote + "\ n_________ __________ __________ __________ __________ __________ __________ __________ __________ __________ __________ _________\ n\n"; | |
| 669 | vc mn_templat eNote = vc mn_templat eNote + "V eteran req uested Met hod of Pic k Up: "; | |
| 670 | if (vcmn_pic kupmethod == 1000000 00) { | |
| 671 | //Mail O ption | |
| 672 | vcmn_tem plateNote = vcmn_tem plateNote + "[X] Mai l. \n\n"; | |
| 673 | } | |
| 674 | if (vcmn_pic kupmethod == 1000000 01) { | |
| 675 | //Window Option | |
| 676 | vcmn_tem plateNote = vcmn_tem plateNote + "[X] Win dow. \n\n" ; | |
| 677 | } | |
| 678 | // Get vetera n's curren t address | |
| 679 | if (vcmn_vet eranId != null) { | |
| 680 | var vcmn _contactDa ta = vcmn_ getSingleE ntityDataS ync('Conta ctSet', 'A ddress1_Co mposite', vcmn_veter anId); | |
| 681 | if (vcmn _contactDa ta != null ) { | |
| 682 | if ( vcmn_conta ctData.d.A ddress1_Co mposite != null && v cmn_contac tData.d.Ad dress1_Com posite != '') { | |
| 683 | vcmn_templ ateNote = vcmn_templ ateNote + "Address c onfirmed w ith caller : \n"; | |
| 684 | vcmn_templ ateNote = vcmn_templ ateNote + vcmn_conta ctData.d.A ddress1_Co mposite + "\n"; | |
| 685 | if (Xrm.Pa ge.getAttr ibute('ftp _callbackn umber').ge tValue() ! = null) { | |
| 686 | vcmn_t emplateNot e = vcmn_t emplateNot e + Xrm.Pa ge.getAttr ibute('ftp _callbackn umber').ge tValue(); | |
| 687 | } | |
| 688 | } | |
| 689 | } | |
| 690 | } | |
| 691 | } | |
| 692 | } | |
| 693 | ||
| 694 | //Write no te text if not Triag e: | |
| 695 | if (vcmn_t riageexper t == 'NO' || vcmn_tr iageexpert == null) { | |
| 696 | Xrm.Pa ge.getAttr ibute('ftp _notedetai l').setVal ue(vcmn_te mplateNote ); | |
| 697 | Xrm.Pa ge.getAttr ibute('ftp _notedetai l').setSub mitMode('a lways'); | |
| 698 | } | |
| 699 | } | |
| 700 | } | |
| 701 | ||
| 702 | //Defaul t Diagnosi s code if TAN or PHA RMACY user , based on systemuse r lookup | |
| 703 | var vcmn _currentUs erId = Xrm .Page.cont ext.getUse rId(); | |
| 704 | var vcmn _currentUs erData = v cmn_getSin gleEntityD ataSync('S ystemUserS et', 'msdy usd_USDCon figuration Id, ftp_Fa cilitySite Id', vcmn_ currentUse rId); | |
| 705 | if (vcmn _currentUs erData != null) { | |
| 706 | if ( vcmn_curre ntUserData .d.msdyusd _USDConfig urationId != null) { | |
| 707 | if (vcmn_c urrentUser Data.d.msd yusd_USDCo nfiguratio nId.Name ! = null) { | |
| 708 | //TAN logic | |
| 709 | if (vc mn_current UserData.d .msdyusd_U SDConfigur ationId.Na me == 'TAN Configura tion') { | |
| 710 | // Get Defaul t Tan Conf iguration from User' s Facility | |
| 711 | if (vcmn_cur rentUserDa ta.d.ftp_F acilitySit eId != nul l) { | |
| 712 | if (vcmn _currentUs erData.d.f tp_Facilit ySiteId.Id != null) { | |
| 713 | 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); | |
| 714 | if ( vcmn_curre ntUserFaci lityData ! = null) { | |
| 715 | if (vcmn_c urrentUser FacilityDa ta.d.ftp_d efaulttand iagnosisco de != null ) { | |
| 716 | if (vc mn_current UserFacili tyData.d.f tp_default tandiagnos iscode.Id != null) { | |
| 717 | // Write Diag nosis code to Progre ss Note Fo rm if a Tr iage Note (revised 5 /9-17 for workload e ncounter a lso) | |
| 718 | // *if (vcmn_ triageexpe rt == 'YES ') { | |
| 719 | vc mn_setSimp leLookupVa lue('ftp_d iagnosisco de', vcmn_ currentUse rFacilityD ata.d.ftp_ defaulttan diagnosisc ode.Logica lName, vcm n_currentU serFacilit yData.d.ft p_defaultt andiagnosi scode.Id, vcmn_curre ntUserFaci lityData.d .ftp_defau lttandiagn osiscode.N ame); | |
| 720 | Xr m.Page.get Attribute( 'ftp_diagn osiscode') .setSubmit Mode('alwa ys'); | |
| 721 | // *} | |
| 722 | } | |
| 723 | } | |
| 724 | } | |
| 725 | ||
| 726 | //Ma tch up the VHG Triag e minute c onfigurati on with CP T Code | |
| 727 | if ( vcmn_triag eminutes > 0) { | |
| 728 | 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 + " )"; | |
| 729 | 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); | |
| 730 | } | |
| 731 | } | |
| 732 | } | |
| 733 | } | |
| 734 | //Phar macy logic | |
| 735 | if (vc mn_current UserData.d .msdyusd_U SDConfigur ationId.Na me == 'Pha rmacy Conf iguration' ) { | |
| 736 | // Get Defaul t Pharmacy Configura tion from User's Fac ility | |
| 737 | if (vcmn_cur rentUserDa ta.d.ftp_F acilitySit eId != nul l) { | |
| 738 | if (vcmn _currentUs erData.d.f tp_Facilit ySiteId.Id != null) { | |
| 739 | var vcmn_curre ntUserFaci lityData = vcmn_getS ingleEntit yDataSync( 'ftp_facil itySet', ' ftp_defaul tpharmacyp rimarydiag nosiscode' , vcmn_cur rentUserDa ta.d.ftp_F acilitySit eId.Id); | |
| 740 | if ( vcmn_curre ntUserFaci lityData ! = null) { | |
| 741 | if (vcmn_c urrentUser FacilityDa ta.d.ftp_d efaultphar macyprimar ydiagnosis code != nu ll) { | |
| 742 | if (vc mn_current UserFacili tyData.d.f tp_default pharmacypr imarydiagn osiscode.I d != null) { | |
| 743 | // Write Diag nosis code to Progre ss Note Fo rm if a Tr iage Note (revised 5 /9-17 for workload e ncounter a lso) | |
| 744 | // *if (vcmn_ triageexpe rt == 'YES ') { | |
| 745 | vc mn_setSimp leLookupVa lue('ftp_d iagnosisco de', vcmn_ currentUse rFacilityD ata.d.ftp_ defaultpha rmacyprima rydiagnosi scode.Logi calName, v cmn_curren tUserFacil ityData.d. ftp_defaul tpharmacyp rimarydiag nosiscode. Id, vcmn_c urrentUser FacilityDa ta.d.ftp_d efaultphar macyprimar ydiagnosis code.Name) ; | |
| 746 | Xr m.Page.get Attribute( 'ftp_diagn osiscode') .setSubmit Mode('alwa ys'); | |
| 747 | // *} | |
| 748 | } | |
| 749 | } | |
| 750 | } | |
| 751 | } | |
| 752 | } | |
| 753 | } | |
| 754 | } | |
| 755 | } | |
| 756 | } | |
| 757 | ||
| 758 | 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 == '') { | |
| 759 | //Pr ompt user to include existing Request No tes if the re is a cu rrent valu e | |
| 760 | Xrm. Utility.co nfirmDialo g( | |
| 761 | "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. ", | |
| 762 | function ( ) { | |
| 763 | Xrm.Pa ge.getAttr ibute('ftp _notedetai l').setVal ue(vcmn_re questData. d.Descript ion); | |
| 764 | Xrm.Pa ge.getAttr ibute('ftp _notedetai l').setSub mitMode('a lways'); | |
| 765 | } | |
| 766 | ); | |
| 767 | } | |
| 768 | ||
| 769 | //****** FIX DEFECT 481450 ** **** | |
| 770 | if (vcmn _requestDa ta.d.Descr iption != null && vc mn_request Data.d.Des cription ! = '' && vc mn_triagee xpert == ' YES') { | |
| 771 | //Pr ompt user to include existing Request No tes if the re is a cu rrent valu e | |
| 772 | Xrm. Utility.co nfirmDialo g( | |
| 773 | "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. ", | |
| 774 | function ( ) { | |
| 775 | //Get the existi ng Triage Note | |
| 776 | var vc mn_TriageN ote = Xrm. Page.getAt tribute('f tp_notedet ail').getV alue(); | |
| 777 | if (vc mn_TriageN ote != nul l) { | |
| 778 | Xr m.Page.get Attribute( 'ftp_noted etail').se tValue(vcm n_requestD ata.d.Desc ription + "\n\n" + v cmn_Triage Note); | |
| 779 | } | |
| 780 | else { Xrm.Page. getAttribu te('ftp_no tedetail') .setValue( vcmn_reque stData.d.D escription ); } | |
| 781 | Xrm.Pa ge.getAttr ibute('ftp _notedetai l').setSub mitMode('a lways'); | |
| 782 | } | |
| 783 | ); | |
| 784 | } | |
| 785 | //****** END FIX DE FECT 48145 0 ****** | |
| 786 | } | |
| 787 | ||
| 788 | // 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) | |
| 789 | if (vcmn_vet eranId != null) { | |
| 790 | var vcmn _contactDa ta = vcmn_ getSingleE ntityDataS ync('Conta ctSet', 'f tp_current facilityid , ftp_Faci lityId', v cmn_vetera nId); | |
| 791 | if (vcmn _contactDa ta != null ) { | |
| 792 | if ( vcmn_conta ctData.d.f tp_current facilityid != null) { | |
| 793 | if (vcmn_c ontactData .d.ftp_cur rentfacili tyid.Id != null) { | |
| 794 | 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); | |
| 795 | Xrm.Pa ge.getAttr ibute('ftp _patientfa cility').s etSubmitMo de('always '); | |
| 796 | } | |
| 797 | else { | |
| 798 | //Get Facility f rom Home F acility | |
| 799 | if (vc mn_contact Data.d.ftp _FacilityI d != null) { | |
| 800 | 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 ); | |
| 801 | Xr m.Page.get Attribute( 'ftp_patie ntfacility ').setSubm itMode('al ways'); | |
| 802 | } | |
| 803 | } | |
| 804 | } | |
| 805 | else { | |
| 806 | //Get Faci lity from Home Facil ity | |
| 807 | if (vcmn_c ontactData .d.ftp_Fac ilityId != null) { | |
| 808 | 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); | |
| 809 | Xrm.Pa ge.getAttr ibute('ftp _patientfa cility').s etSubmitMo de('always '); | |
| 810 | } | |
| 811 | } | |
| 812 | } | |
| 813 | } | |
| 814 | ||
| 815 | // Set other default fo rm values | |
| 816 | Xr m.Page.get Attribute( 'scheduled end').setV alue(new D ate()); | |
| 817 | Xr m.Page.get Attribute( 'scheduled end').setS ubmitMode( 'always'); | |
| 818 | ||
| 819 | // Append Gen eric Templ ate Data t o top of e xisting no te | |
| 820 | va r vcmn_gen ericTempla teData = " Callback N umber: "; | |
| 821 | if (Xrm.Page .getAttrib ute('ftp_c allbacknum ber').getV alue() != null && Xr m.Page.get Attribute( 'ftp_callb acknumber' ).getValue () != "") { | |
| 822 | vcmn_gen ericTempla teData = v cmn_generi cTemplateD ata + Xrm. Page.getAt tribute('f tp_callbac knumber'). getValue() ; | |
| 823 | } | |
| 824 | // Construct new note w ith existi ng note da ta | |
| 825 | va r vcmn_exi stingNoteD ata = ""; | |
| 826 | if (Xrm.Page .getAttrib ute("ftp_n otedetail" ).getValue () != null && Xrm.Pa ge.getAttr ibute("ftp _notedetai l").getVal ue() != "" ) { | |
| 827 | vcmn_exi stingNoteD ata = Xrm. Page.getAt tribute("f tp_notedet ail").getV alue(); | |
| 828 | } | |
| 829 | vc mn_generic TemplateDa ta = vcmn_ genericTem plateData + "\n\n" + vcmn_exis tingNoteDa ta; | |
| 830 | // Replace ex isting not e | |
| 831 | Xr m.Page.get Attribute( 'ftp_noted etail').se tValue(vcm n_genericT emplateDat a); | |
| 832 | Xr m.Page.get Attribute( 'ftp_noted etail').se tSubmitMod e('always' ); | |
| 833 | ||
| 834 | // Change Foc us to the Notes fiel d | |
| 835 | Xr m.Page.get Control("f tp_notedet ail").setF ocus(); | |
| 836 | ||
| 837 | // Get ICN vi a web serv ice and ge t Service Connected disabiliti es thereaf ter | |
| 838 | // Preserved Variables | |
| 839 | va r vcmn_vet eranId = n ull; //Fr om request customeri d | |
| 840 | va r vcmn_vet eranFirstN ame = ''; | |
| 841 | va r vcmn_vet eranLastNa me = ''; | |
| 842 | va r vcmn_SSN = ''; | |
| 843 | va r vcmn_DOB = ''; | |
| 844 | ||
| 845 | // Get regard ing data | |
| 846 | va r vcmn_req uestId = X rm.Page.ge tAttribute ('regardin gobjectid' ).getValue (); | |
| 847 | if (vcmn_req uestId == null) { re turn false ; } | |
| 848 | va r vcmn_req uestData = vcmn_getS ingleEntit yDataSync( 'IncidentS et', 'Cust omerId', v cmn_reques tId[0].id) ; | |
| 849 | ||
| 850 | if (vcmn_req uestData ! = null) { | |
| 851 | if (vcmn _requestDa ta.d.Custo merId != n ull) { | |
| 852 | vcmn _veteranId = vcmn_re questData. d.Customer Id; | |
| 853 | //Ve rify that the custom erid is of type cont act | |
| 854 | if ( vcmn_veter anId.Logic alName != 'contact') { | |
| 855 | return fal se; | |
| 856 | } | |
| 857 | } | |
| 858 | } | |
| 859 | if (vcmn_vet eranId == null) { | |
| 860 | return f alse; | |
| 861 | } | |
| 862 | ||
| 863 | 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); | |
| 864 | if (vcmn_con tactData ! = null) { | |
| 865 | if (vcmn _contactDa ta.d.First Name != nu ll) { vcmn _veteranFi rstName = vcmn_conta ctData.d.F irstName; } | |
| 866 | if (vcmn _contactDa ta.d.LastN ame != nul l) { vcmn_ veteranLas tName = vc mn_contact Data.d.Las tName; } | |
| 867 | if (vcmn _contactDa ta.d.ftp_D ateofBirth != null) { vcmn_DOB = vcmn_co ntactData. d.ftp_Date ofBirth; } | |
| 868 | if (vcmn _contactDa ta.d.Gover nmentId != null) { v cmn_SSN = vcmn_conta ctData.d.G overnmentI d; } | |
| 869 | } | |
| 870 | ||
| 871 | // Perform MV I Search f or Service Connected Disabilit ies | |
| 872 | vc mn_unatten dedMviSear chSCD(vcmn _veteranFi rstName, v cmn_vetera nLastName, vcmn_DOB, vcmn_SSN) ; | |
| 873 | } | |
| 874 | catch (err) { | |
| 875 | al ert('Progr ess Note F orm Load S cript Func tion Error (vcmn_newP rogressNot eLoad_WebU RL): ' + e rr.message ); | |
| 876 | } | |
| 877 | } | |
| 878 | ||
| 879 | function v cmn_getSer viceConnec tedDisabil ities(vcmn _patientIC N) { | |
| 880 | //**** ********** ********** ********** ********** ********** ********** ********** ********** ********** ********** *** | |
| 881 | //Janu ary 16 201 7 - EXIT T HE FUNCTIO N, NOT USE D SEE BELO W | |
| 882 | return false; | |
| 883 | //***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 | |
| 884 | //**** ********** ********** ********** ********** ********** ********** ********** ********** ********** ********** *** | |
| 885 | try { | |
| 886 | // ******Deve loper Bypa ss for mis sing ICN** **** | |
| 887 | if (vcmn_pat ientICN == '' || vcm n_patientI CN == null ) { | |
| 888 | if ((Xrm .Page.cont ext.getUse rId()).toU pperCase() == "{CA50 0504-CBC5- E511-8173- 000C2941CE 19}") { | |
| 889 | aler t("Develop er ICN byp ass applie d!"); | |
| 890 | vcmn _patientIC N = "12345 6V123456"; | |
| 891 | } | |
| 892 | } | |
| 893 | ||
| 894 | // Verify Pat ient ICN | |
| 895 | if (vcmn_pat ientICN == '' || vcm n_patientI CN == null ) { | |
| 896 | //No ICN , do not p roceed | |
| 897 | return f alse; | |
| 898 | } | |
| 899 | ||
| 900 | // Get the se rvice conn ected disa bilities d ata from t he web ser vice | |
| 901 | va r vcmn_dis abilitiesX mlData = v cmn_getDis abilityDat a(vcmn_pat ientICN); | |
| 902 | ||
| 903 | // Temporary action: xm l result i s empty, u se sample data, comm ent out wh en not use d | |
| 904 | // ********** ********** ********** ********** ********** ********** ********** ********** ********** ********** ********** ******** | |
| 905 | // if (vcmn_d isabilitie sXmlData = = null || vcmn_disab ilitiesXml Data == '' ) { vcmn_d isabilitie sXmlData = xml_resul ts3; } | |
| 906 | // ********** ********** ********** ********** ********** ********** ********** ********** ********** ********** ********** ******** | |
| 907 | ||
| 908 | // If no data , do not p roceed. | |
| 909 | if (vcmn_dis abilitiesX mlData == null || vc mn_disabil itiesXmlDa ta == '') { return f alse; } | |
| 910 | ||
| 911 | // Create bas e Note Str ing | |
| 912 | va r vcmn_SCD noteString = ''; | |
| 913 | vc mn_SCDnote String = v cmn_SCDnot eString + "\n------- ---------- ---------- ---------- ---------- ---------- ---------- ------\n"; | |
| 914 | vc mn_SCDnote String = v cmn_SCDnot eString + "Special T reatment A uthority a nd Service Connected Disabilit ies"; | |
| 915 | vc mn_SCDnote String = v cmn_SCDnot eString + "\n------- ---------- ---------- ---------- ---------- ---------- ---------- ------\n"; | |
| 916 | ||
| 917 | // Search XML values | |
| 918 | vc mn_xmlDoc = $.parseX ML(vcmn_di sabilities XmlData); | |
| 919 | $v cmn_xml = $(vcmn_xml Doc); | |
| 920 | ||
| 921 | // Data from parentnode 'enrollme ntDetermin ationInfo' | |
| 922 | va r $vcmn_en rollmentDe terminatio nInfo = nu ll; | |
| 923 | va r $vcmn_pr imaryEligi bility = n ull; | |
| 924 | va r $vcmn_ty pe = null; | |
| 925 | va r vcmn_typ eText = nu ll; | |
| 926 | va r $vcmn_en rollmentCa tegoryName = null; | |
| 927 | va r vcmn_enr ollmentCat egoryNameT ext = null ; | |
| 928 | va r $vcmn_sp ecialFacto rs = null; | |
| 929 | va r $vcmn_en vContamina ntsInd = n ull; | |
| 930 | va r vcmn_env Contaminan tsIndText = null; | |
| 931 | va r $vcmn_ra diationExp osureInd = null; | |
| 932 | va r vcmn_rad iationExpo sureIndTex t = null; | |
| 933 | va r $vcmn_ag entOrangeI nd = null; | |
| 934 | va r vcmn_age ntOrangeIn dText = nu ll; | |
| 935 | va r $vcmn_ca mpLejeuneI nd = null; | |
| 936 | va r vcmn_cam pLejeuneIn dText = nu ll; | |
| 937 | va r $vcmn_se rviceConne ctionAward = null; | |
| 938 | va r $vcmn_se rviceConne ctedPercen tage = nul l; | |
| 939 | va r vcmn_ser viceConnec tedPercent ageText = null; | |
| 940 | va r $vcmn_ra tedDisabil ities = nu ll; | |
| 941 | ||
| 942 | va r $vcmn_ag entOrangeL ocation = null; | |
| 943 | va r vcmn_age ntOrangeLo cationText = null; | |
| 944 | va r $vcmn_ra diationExp osureMetho d = null; | |
| 945 | va r vcmn_rad iationExpo sureMethod Text = nul l; | |
| 946 | ||
| 947 | va r $vcmn_no seThroatRa diumInfo = null; | |
| 948 | va r $vcmn_di agnosedWit hCancer = null; | |
| 949 | va r vcmn_dia gnosedWith CancerText = null; | |
| 950 | ||
| 951 | va r $vcmn_mi litarySexu alTraumaIn fo = null; | |
| 952 | va r $vcmn_mi lSexTrauma Status = n ull; | |
| 953 | va r vcmn_mil SexTraumaS tatusText = null; | |
| 954 | ||
| 955 | // Data from parentnode 'military ServiceInf o' | |
| 956 | va r $vcmn_mi litaryServ iceInfo = null; | |
| 957 | va r $vcmn_co mbatVetera nEligibili tyEndDate = null; | |
| 958 | va r vcmn_com batVeteran Eligibilit yEndDateTe xt = null; | |
| 959 | va r $vcmn_sh adIndicato r = null; | |
| 960 | va r vcmn_sha dIndicator Text = nul l; | |
| 961 | ||
| 962 | va r vcmn_rat edDisabili tyPercenta geTotal = 0; | |
| 963 | ||
| 964 | va r vcmn_det ailrowcoun t = 0; | |
| 965 | ||
| 966 | $v cmn_enroll mentDeterm inationInf o = $vcmn_ xml.find(' enrollment Determinat ionInfo'); | |
| 967 | if ($vcmn_en rollmentDe terminatio nInfo != n ull) { | |
| 968 | $vcmn_pr imaryEligi bility = $ vcmn_enrol lmentDeter minationIn fo.find('p rimaryElig ibility'); | |
| 969 | if ($vcm n_primaryE ligibility != null) { | |
| 970 | $vcm n_type = $ vcmn_prima ryEligibil ity.find(' type'); | |
| 971 | if ( $vcmn_type != null) { vcmn_typ eText = $v cmn_type.t ext(); } | |
| 972 | } | |
| 973 | ||
| 974 | $vcmn_en rollmentCa tegoryName = $vcmn_e nrollmentD eterminati onInfo.fin d('enrollm entCategor yName'); | |
| 975 | if ($vcm n_enrollme ntCategory Name != nu ll) { vcmn _enrollmen tCategoryN ameText = $vcmn_enro llmentCate goryName.t ext(); } | |
| 976 | ||
| 977 | $vcmn_sp ecialFacto rs = $vcmn _enrollmen tDetermina tionInfo.f ind('speci alFactors' ); | |
| 978 | if ($vcm n_specialF actors != null) { | |
| 979 | $vcm n_envConta minantsInd = $vcmn_s pecialFact ors.find(' envContami nantsInd') ; | |
| 980 | if ( $vcmn_envC ontaminant sInd != nu ll) { vcmn _envContam inantsIndT ext = $vcm n_envConta minantsInd .text(); } | |
| 981 | $vcm n_radiatio nExposureI nd = $vcmn _specialFa ctors.find ('radiatio nExposureI nd'); | |
| 982 | if ( $vcmn_radi ationExpos ureInd != null) { vc mn_radiati onExposure IndText = $vcmn_radi ationExpos ureInd.tex t(); } | |
| 983 | $vcm n_agentOra ngeInd = $ vcmn_speci alFactors. find('agen tOrangeInd '); | |
| 984 | if ( $vcmn_agen tOrangeInd != null) { vcmn_age ntOrangeIn dText = $v cmn_agentO rangeInd.t ext(); } | |
| 985 | $vcm n_campLeje uneInd = $ vcmn_speci alFactors. find('camp LejeuneInd '); | |
| 986 | if ( $vcmn_camp LejeuneInd != null) { vcmn_cam pLejeuneIn dText = $v cmn_campLe jeuneInd.t ext(); } | |
| 987 | ||
| 988 | $vcm n_agentOra ngeLocatio n = $vcmn_ specialFac tors.find( 'agentOran geLocation '); | |
| 989 | if ( $vcmn_agen tOrangeLoc ation != n ull) { vcm n_agentOra ngeLocatio nText = $v cmn_agentO rangeLocat ion.text() ; } | |
| 990 | $vcm n_radiatio nExposureM ethod = $v cmn_specia lFactors.f ind('radia tionExposu reMethod') ; | |
| 991 | if ( $vcmn_radi ationExpos ureMethod != null) { vcmn_radi ationExpos ureMethodT ext = $vcm n_radiatio nExposureM ethod.text (); } | |
| 992 | } | |
| 993 | ||
| 994 | $vcmn_se rviceConne ctionAward = $vcmn_e nrollmentD eterminati onInfo.fin d('service Connection Award'); | |
| 995 | if ($vcm n_serviceC onnectionA ward != nu ll) { | |
| 996 | $vcm n_serviceC onnectedPe rcentage = $vcmn_ser viceConnec tionAward. find('serv iceConnect edPercenta ge'); | |
| 997 | if ( $vcmn_serv iceConnect edPercenta ge != null ) { vcmn_s erviceConn ectedPerce ntageText = $vcmn_se rviceConne ctedPercen tage.text( ); } | |
| 998 | $vcm n_ratedDis abilities = $vcmn_se rviceConne ctionAward .find('rat edDisabili ties'); | |
| 999 | //Ge t each dis ability li sted and a dd to note string | |
| 1000 | vcmn _SCDnoteSt ring = vcm n_SCDnoteS tring + "S C Disabili ty: "; | |
| 1001 | $vcm n_ratedDis abilities. find('rate dDisabilit y').each(f unction () { | |
| 1002 | var vcmn_r atedDisabi lityPercen t = 0; | |
| 1003 | var vcmn_d isability = null; | |
| 1004 | if (Number ($(this).f ind('perce ntage').te xt()) > 0) { | |
| 1005 | vcmn_r atedDisabi lityPercen tageTotal = vcmn_rat edDisabili tyPercenta geTotal + Number($(t his).find( 'percentag e').text() ); | |
| 1006 | vcmn_r atedDisabi lityPercen t = Number ($(this).f ind('perce ntage').te xt()); | |
| 1007 | } | |
| 1008 | //Add Rate d Disabili ties to th e Note Str ing if Dis ability Pe rcent > 0 | |
| 1009 | if (vcmn_r atedDisabi lityPercen t > 0) { | |
| 1010 | vcmn_S CDnoteStri ng = vcmn_ SCDnoteStr ing + $(th is).find(' disability ').text() + "\n"; | |
| 1011 | } | |
| 1012 | }); | |
| 1013 | vcmn _SCDnoteSt ring = vcm n_SCDnoteS tring + "\ n"; | |
| 1014 | } | |
| 1015 | ||
| 1016 | $vcmn_no seThroatRa diumInfo = $vcmn_enr ollmentDet ermination Info.find( 'noseThroa tRadiumInf o'); | |
| 1017 | if ($vcm n_noseThro atRadiumIn fo != null ) { | |
| 1018 | $vcm n_diagnose dWithCance r = $vcmn_ noseThroat RadiumInfo .find('dia gnosedWith Cancer'); | |
| 1019 | if ( $vcmn_diag nosedWithC ancer != n ull) { vcm n_diagnose dWithCance rText = $v cmn_diagno sedWithCan cer.text() ; } | |
| 1020 | } | |
| 1021 | ||
| 1022 | $vcmn_mi litarySexu alTraumaIn fo = $vcmn _enrollmen tDetermina tionInfo.f ind('milit arySexualT raumaInfo' ); | |
| 1023 | if ($vcm n_military SexualTrau maInfo != null) { | |
| 1024 | $vcm n_milSexTr aumaStatus = $vcmn_m ilitarySex ualTraumaI nfo.find(' status'); | |
| 1025 | if ( $vcmn_milS exTraumaSt atus != nu ll) { vcmn _milSexTra umaStatusT ext = $vcm n_milSexTr aumaStatus .text(); } | |
| 1026 | } | |
| 1027 | } | |
| 1028 | ||
| 1029 | $v cmn_milita ryServiceI nfo = $vcm n_xml.find ('military ServiceInf o'); | |
| 1030 | if ($vcmn_mi litaryServ iceInfo != null) { | |
| 1031 | $vcmn_co mbatVetera nEligibili tyEndDate = $vcmn_mi litaryServ iceInfo.fi nd('combat VeteranEli gibilityEn dDate'); | |
| 1032 | if ($vcm n_combatVe teranEligi bilityEndD ate != nul l) { | |
| 1033 | vcmn _combatVet eranEligib ilityEndDa teText = v cmn_combat VeteranEli gibilityEn dDateText = $vcmn_co mbatVetera nEligibili tyEndDate. text(); | |
| 1034 | } | |
| 1035 | $vcmn_sh adIndicato r = $vcmn_ militarySe rviceInfo. find('shad Indicator' ); | |
| 1036 | if ($vcm n_shadIndi cator != n ull) { vcm n_shadIndi catorText = $vcmn_sh adIndicato r.text(); } | |
| 1037 | } | |
| 1038 | ||
| 1039 | // If no elig ibility sp ecified, s et to fals e | |
| 1040 | if (vcmn_typ eText == n ull || vcm n_typeText == '') { vcmn_typeT ext = fals e; } | |
| 1041 | ||
| 1042 | // Change boo lean value s to false if not ma rked true | |
| 1043 | if (vcmn_env Contaminan tsIndText != 'true') { vcmn_en vContamina ntsIndText = false; } | |
| 1044 | if (vcmn_rad iationExpo sureIndTex t != 'true ') { vcmn_ radiationE xposureInd Text = fal se; } | |
| 1045 | if (vcmn_age ntOrangeIn dText != ' true') { v cmn_agentO rangeIndTe xt = false ; } | |
| 1046 | if (vcmn_cam pLejeuneIn dText != ' true') { v cmn_campLe jeuneIndTe xt = false ; } | |
| 1047 | ||
| 1048 | if (vcmn_dia gnosedWith CancerText != 'true' ) { vcmn_d iagnosedWi thCancerTe xt = false ; } | |
| 1049 | if (vcmn_sha dIndicator Text != 't rue') { vc mn_shadInd icatorText = false; } | |
| 1050 | ||
| 1051 | // Change all True/Fals e to Yes/N o | |
| 1052 | if (vcmn_typ eText == f alse) { vc mn_typeTex t = 'No'; } | |
| 1053 | ||
| 1054 | if (vcmn_env Contaminan tsIndText == "true") { vcmn_en vContamina ntsIndText = "Yes"; } else { v cmn_envCon taminantsI ndText = " No"; } | |
| 1055 | if (vcmn_rad iationExpo sureIndTex t == "true ") { | |
| 1056 | vcmn_rad iationExpo sureIndTex t = "Yes"; | |
| 1057 | if (vcmn _radiation ExposureMe thodText ! = null) { vcmn_radia tionExposu reIndText = vcmn_rad iationExpo sureIndTex t + " - " + vcmn_rad iationExpo sureMethod Text; } | |
| 1058 | } else { | |
| 1059 | vcmn_rad iationExpo sureIndTex t = "No"; | |
| 1060 | } | |
| 1061 | if (vcmn_age ntOrangeIn dText == " true") { | |
| 1062 | vcmn_age ntOrangeIn dText = "Y es"; | |
| 1063 | if (vcmn _agentOran geLocation Text != nu ll) { vcmn _agentOran geIndText = vcmn_age ntOrangeIn dText + " - " + vcmn _agentOran geLocation Text; } | |
| 1064 | } | |
| 1065 | el se { | |
| 1066 | vcmn_age ntOrangeIn dText = "N o"; | |
| 1067 | } | |
| 1068 | if (vcmn_cam pLejeuneIn dText == " true") { v cmn_campLe jeuneIndTe xt = "Yes" ; } else { vcmn_camp LejeuneInd Text = "No "; } | |
| 1069 | ||
| 1070 | if (vcmn_dia gnosedWith CancerText == "true" ) { vcmn_d iagnosedWi thCancerTe xt = "Yes" ; } else { vcmn_diag nosedWithC ancerText = "No"; } | |
| 1071 | ||
| 1072 | if (vcmn_com batVeteran Eligibilit yEndDateTe xt != null && vcmn_c ombatVeter anEligibil ityEndDate Text != '' ) { vcmn_c ombatVeter anEligibil ityEndDate Text = 'Ye s'; } | |
| 1073 | ||
| 1074 | if (vcmn_sha dIndicator Text == "t rue") { vc mn_shadInd icatorText = "Yes"; } else { v cmn_shadIn dicatorTex t = "No"; } | |
| 1075 | ||
| 1076 | // Construct summary no te part | |
| 1077 | 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"; } | |
| 1078 | 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"; } | |
| 1079 | 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"; } | |
| 1080 | 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 "; } | |
| 1081 | 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"; } | |
| 1082 | 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" ; } | |
| 1083 | 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"; } | |
| 1084 | 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 "; } | |
| 1085 | ||
| 1086 | // Update not e with new SCD note data | |
| 1087 | va r vcmn_exi stingNoteD ata = ""; | |
| 1088 | if (Xrm.Page .getAttrib ute("ftp_n otedetail" ).getValue () != null && Xrm.Pa ge.getAttr ibute("ftp _notedetai l").getVal ue() != "" ) { | |
| 1089 | vcmn_exi stingNoteD ata = Xrm. Page.getAt tribute("f tp_notedet ail").getV alue(); | |
| 1090 | } | |
| 1091 | vc mn_extende dTemplateD ata = vcmn _existingN oteData + vcmn_SCDno teString; | |
| 1092 | // Replace ex isting not e | |
| 1093 | Xr m.Page.get Attribute( 'ftp_noted etail').se tValue(vcm n_extended TemplateDa ta); | |
| 1094 | Xr m.Page.get Attribute( 'ftp_noted etail').se tSubmitMod e('always' ); | |
| 1095 | } | |
| 1096 | catch (err) { | |
| 1097 | al ert('Progr ess Note F orm Load S cript Func tion Error (vcmn_getS erviceConn ectedDisab ilities): ' + err.me ssage); | |
| 1098 | } | |
| 1099 | } | |
| 1100 | ||
| 1101 | function v cmn_getDis abilityDat a(vcmn_nat ionalId) { | |
| 1102 | try { | |
| 1103 | va r vcmn_ees ummaryURL = vcmn_ees ummaryURLb ase + '000 000' + vcm n_national Id + '0000 00'; | |
| 1104 | va r vcmn_xml Data = nul l; | |
| 1105 | ||
| 1106 | $. ajax({ | |
| 1107 | type: "G ET", | |
| 1108 | url: vcm n_eesummar yURL, | |
| 1109 | contentT ype: "appl ication/xm l; charset =utf-8", | |
| 1110 | dataType : "text", | |
| 1111 | success: function (xmlTextda ta) { | |
| 1112 | vcmn _xmlData = xmlTextda ta; | |
| 1113 | }, | |
| 1114 | error: f unction (j qXHR, text Status, er rorThrown) { | |
| 1115 | //Sy stem Error | |
| 1116 | vcmn _xmlData = null; | |
| 1117 | }, | |
| 1118 | async: f alse, | |
| 1119 | cache: f alse | |
| 1120 | }) ; | |
| 1121 | re turn vcmn_ xmlData; | |
| 1122 | } | |
| 1123 | catch (err) { | |
| 1124 | al ert("Progr ess Note F orm Load S cript Func tion Error (vcmn_getD isabilityD ata): " + err.messag e); | |
| 1125 | re turn null; | |
| 1126 | } | |
| 1127 | } | |
| 1128 | ||
| 1129 | function v cmn_facili tyByCode_r esponse(vc mn_facilit yData, vcm n_lastSkip , vcmn_fac ilityCode) { | |
| 1130 | try { | |
| 1131 | // vcmn_lastS kip is the starting point in t he result (use if mo re than 50 records) //Not used in this s cenario | |
| 1132 | // ***REVISED NOT USED, KEEP FOR FUTURE UPD ATE*** | |
| 1133 | /* | |
| 1134 | va r vcmn_fac ilityid = null; | |
| 1135 | va r vcmn_fac ilityname = null; | |
| 1136 | fo r (var i = 0; i <= v cmn_facili tyData.d.r esults.len gth - 1; i ++) { | |
| 1137 | //Get in fo | |
| 1138 | if (vcmn _facilityD ata.d.resu lts[i].ftp _facilityI d != null) { vcmn_fa cilityid = vcmn_faci lityData.d .results[i ].ftp_faci lityId; } | |
| 1139 | 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; } | |
| 1140 | break; | |
| 1141 | } | |
| 1142 | if (vcmn_fac ilityid != null) { | |
| 1143 | vcmn_set SimpleLook upValue('f tp_patient facility', 'ftp_faci lity', vcm n_facility id, vcmn_f acilitynam e); | |
| 1144 | Xrm.Page .getAttrib ute('ftp_p atientfaci lity').set SubmitMode ('always') ; | |
| 1145 | } | |
| 1146 | */ | |
| 1147 | } | |
| 1148 | catch (err) { | |
| 1149 | al ert('Progr ess Note F orm Load S cript Func tion Error (vcmn_faci lityByCode _response) : ' + err. message); | |
| 1150 | } | |
| 1151 | } | |
| 1152 | ||
| 1153 | function v cmn_cptCod e_response (vcmn_cptC odeData, v cmn_lastSk ip, vcmn_t riageminut es) { | |
| 1154 | try { | |
| 1155 | // vcmn_lastS kip is the starting point in t he result (use if mo re than 50 records) //Not used in this s cenario | |
| 1156 | fo r (var i = 0; i <= v cmn_cptCod eData.d.re sults.leng th - 1; i+ +) { | |
| 1157 | //Write to CRM pro gress note form | |
| 1158 | 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); | |
| 1159 | Xrm.Page .getAttrib ute('ftp_c ptcode').s etSubmitMo de('always '); | |
| 1160 | break; | |
| 1161 | } | |
| 1162 | } | |
| 1163 | catch (err) { | |
| 1164 | al ert('Progr ess Note F orm Load S cript Func tion Error (vcmn_cptC ode_respon se): ' + e rr.message ); | |
| 1165 | } | |
| 1166 | } | |
| 1167 | ||
| 1168 | function v cmn_ribbon ButtonSave () { | |
| 1169 | try { | |
| 1170 | // Save the c urrent CRM data | |
| 1171 | Xr m.Page.dat a.entity.s ave(); | |
| 1172 | } | |
| 1173 | catch (err) { | |
| 1174 | al ert('Progr ess Note R ibbon Func tion Error (vcmn_ribb onButtonSa ve): ' + e rr.message ); | |
| 1175 | } | |
| 1176 | } | |
| 1177 | ||
| 1178 | function v cmn_wordWr ap(str, in tWidth, st rBreak, cu t) { | |
| 1179 | try { | |
| 1180 | // Takes a st ring that exceeds a set length and inser ts word wr ap | |
| 1181 | va r m = ((ar guments.le ngth >= 2) ? argumen ts[1] : 75 ) | |
| 1182 | va r b = ((ar guments.le ngth >= 3) ? argumen ts[2] : '\ n') | |
| 1183 | va r c = ((ar guments.le ngth >= 4) ? argumen ts[3] : fa lse) | |
| 1184 | ||
| 1185 | va r i, j, l, s, r | |
| 1186 | ||
| 1187 | st r += '' | |
| 1188 | ||
| 1189 | if (m < 1) { | |
| 1190 | return s tr | |
| 1191 | } | |
| 1192 | ||
| 1193 | fo r (i = -1, l = (r = str.split( /\r\n|\n|\ r/)).lengt h; ++i < l ; r[i] += s) { | |
| 1194 | for (s = r[i], r[i ] = ''; | |
| 1195 | s.leng th > m; | |
| 1196 | r[i] + = s.slice( 0, j) + (( s = s.slic e(j)).leng th ? b : ' ')) { | |
| 1197 | j = c === 2 || (j = s.sl ice(0, m + 1).match( /\S*(\s)?$ /))[1] | |
| 1198 | ? m | |
| 1199 | : j.input.le ngth - j[0 ].length | | c === tr ue && m || | |
| 1200 | j.input.le ngth + (j = s.slice( m).match(/ ^\S*/))[0] .length | |
| 1201 | } | |
| 1202 | } | |
| 1203 | ||
| 1204 | re turn r.joi n('\n') | |
| 1205 | } | |
| 1206 | catch (err) { | |
| 1207 | al ert('Progr ess Note R ibbon Func tion Error (vcmn_word Wrap): ' + err.messa ge); | |
| 1208 | } | |
| 1209 | } | |
| 1210 | ||
| 1211 | function v cmn_ribbon ButtonSave ToVistA() { | |
| 1212 | try { | |
| 1213 | // Check the value of t he Integra tion Statu s Field, i f = 'OK', stop and e xit this s cript | |
| 1214 | va r vcmn_int egrationSt atus = Xrm .Page.getA ttribute(' ftp_integr ationstatu s').getVal ue(); | |
| 1215 | if (vcmn_int egrationSt atus == 'O K') { retu rn false; } | |
| 1216 | ||
| 1217 | // Prompt use r to sign the note | |
| 1218 | va r vcmn_sig nThisNote = Xrm.Page .getAttrib ute('ftp_s ignthisnot e').getVal ue(); | |
| 1219 | va r vcmn_sig nThisNoteF ailure = f alse; | |
| 1220 | if (vcmn_sig nThisNote == null) { | |
| 1221 | Xrm.Util ity.confir mDialog( | |
| 1222 | "Do you need t o sign thi s note?, S elect OK i f Yes, oth erwise CAN CEL.", | |
| 1223 | func tion () { | |
| 1224 | //Check if VIA Login cookie ex ist (not e xpired) | |
| 1225 | var vcmn_V iaLoginCoo kie = vcmn _getCookie ("viasessi onlink"); | |
| 1226 | //Prompt u ser to log in to VIA | |
| 1227 | if (vcmn_V iaLoginCoo kie == "") { | |
| 1228 | alert( "Your VIST A session has expire d. In orde r to sign this note, you must be logged into VISTA !"); | |
| 1229 | Xrm.Pa ge.ui.tabs .get('Tab_ VistALogin ').setVisi ble(true); | |
| 1230 | Xrm.Pa ge.ui.tabs .get('Tab_ VistALogin ').setFocu s(); | |
| 1231 | vcmn_s ignThisNot eFailure = true; | |
| 1232 | return ; | |
| 1233 | } | |
| 1234 | Xrm.Page.g etAttribut e('ftp_sig nthisnote' ).setValue (100000001 ); | |
| 1235 | }, | |
| 1236 | func tion () { | |
| 1237 | Xrm.Page.g etAttribut e('ftp_sig nthisnote' ).setValue (100000000 ); | |
| 1238 | } | |
| 1239 | ); | |
| 1240 | Xrm.Page .getAttrib ute('ftp_s ignthisnot e').setSub mitMode('a lways'); | |
| 1241 | } | |
| 1242 | ||
| 1243 | // Check for additional signers, if they ex ist, the u ser must b e logged i nto VIA to continue process. | |
| 1244 | // Additional Signature s must als o be in sy nc with ma tching Ses sion varia bles | |
| 1245 | ||
| 1246 | vc mn_AddlSig nersNameAr ray = null ; | |
| 1247 | vc mn_AddlSig nersIenArr ay = null; | |
| 1248 | ||
| 1249 | va r vcmn_sel ectedSigne rs = Xrm.P age.getAtt ribute('ft p_selected signers'). getValue() ; | |
| 1250 | if (vcmn_sel ectedSigne rs != null && vcmn_s electedSig ners != '' ) { | |
| 1251 | //Additi onal Signe rs exist i n CRM, ver ify sessio n variable s | |
| 1252 | var vcmn _selectedA rray = vcm n_selected Signers.sp lit('~~~') ; | |
| 1253 | var vcmn _selectedA rrayRecord Count = vc mn_selecte dArray.len gth; | |
| 1254 | if (vcmn _selectedA rrayRecord Count > 1) { | |
| 1255 | vcmn _AddlSigne rsNameArra y = vcmn_s electedArr ay; | |
| 1256 | } | |
| 1257 | ||
| 1258 | var vcmn _selectedI ENArray = ''; | |
| 1259 | var vcmn _selectedI ENArrayRec ordCount = 0; | |
| 1260 | var vcmn _progressN oteId = Xr m.Page.dat a.entity.g etId(); | |
| 1261 | ||
| 1262 | var vcmn _arrayMism atch = fal se; | |
| 1263 | ||
| 1264 | //Get No te's Brows er Local S torage Val ues | |
| 1265 | if (vcmn _progressN oteId != n ull && vcm n_progress NoteId != '') { | |
| 1266 | vcmn _localStor ageVarName = "PN" + vcmn_progr essNoteId; | |
| 1267 | var vcmn_local StorageStr ingValue = localStor age.getIte m(vcmn_loc alStorageV arName); | |
| 1268 | if ( vcmn_local StorageStr ingValue ! = null && vcmn_local StorageStr ingValue ! = '') { | |
| 1269 | vcmn_selec tedIENArra y = vcmn_l ocalStorag eStringVal ue.split(' ~~~'); | |
| 1270 | vcmn_selec tedIENArra yRecordCou nt = vcmn_ selectedIE NArray.len gth; | |
| 1271 | if (vcmn_s electedIEN ArrayRecor dCount > 1 ) { | |
| 1272 | vcmn_A ddlSigners IenArray = vcmn_sele ctedIENArr ay; | |
| 1273 | } | |
| 1274 | } | |
| 1275 | } | |
| 1276 | //Compar e CRM sign er array l ength with LocalStor age array length | |
| 1277 | if (vcmn _selectedA rrayRecord Count != v cmn_select edIENArray RecordCoun t) { vcmn_ arrayMisma tch = true ; } | |
| 1278 | ||
| 1279 | if (vcmn _arrayMism atch == tr ue) { | |
| 1280 | 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."); | |
| 1281 | vcmn _signThisN oteFailure = true; | |
| 1282 | } | |
| 1283 | else { | |
| 1284 | //Ch eck if VIA Login coo kie exist (not expir ed) | |
| 1285 | var vcmn_ViaLo ginCookie = vcmn_get Cookie("vi asessionli nk"); | |
| 1286 | if ( vcmn_ViaLo ginCookie == "") { | |
| 1287 | 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 !"); | |
| 1288 | Xrm.Page.u i.tabs.get ('Tab_Vist ALogin').s etVisible( true); | |
| 1289 | Xrm.Page.u i.tabs.get ('Tab_Vist ALogin').s etFocus(); | |
| 1290 | vcmn_signT hisNoteFai lure = tru e; | |
| 1291 | return; | |
| 1292 | } | |
| 1293 | } | |
| 1294 | } | |
| 1295 | ||
| 1296 | // Check if m arked as a workload encounter and if so enforce VI A Login | |
| 1297 | if (Xrm.Page .getAttrib ute('ftp_i sworkloade ncounter') .getValue( ) == true) { | |
| 1298 | //Check if VIA Log in cookie exist (not expired) | |
| 1299 | var vcmn _ViaLoginC ookie = vc mn_getCook ie("viases sionlink") ; | |
| 1300 | if (vcmn _ViaLoginC ookie == " ") { | |
| 1301 | 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!"); | |
| 1302 | Xrm. Page.ui.ta bs.get('Ta b_VistALog in').setVi sible(true ); | |
| 1303 | Xrm. Page.ui.ta bs.get('Ta b_VistALog in').setFo cus(); | |
| 1304 | vcmn _signThisN oteFailure = true; | |
| 1305 | retu rn; | |
| 1306 | } | |
| 1307 | } | |
| 1308 | ||
| 1309 | if (vcmn_sig nThisNoteF ailure == true) { | |
| 1310 | //****** Developer Bypass for no VISTA authentica tion****** | |
| 1311 | 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}") { | |
| 1312 | aler t("Develop er VISTA a uthenticat ion bypass applied!" ); | |
| 1313 | Xrm. Page.getAt tribute('f tp_signthi snote').se tValue(100 000001); | |
| 1314 | Xrm. Page.getAt tribute('f tp_signthi snote').se tSubmitMod e('always' ); | |
| 1315 | } | |
| 1316 | else { | |
| 1317 | retu rn false; | |
| 1318 | } | |
| 1319 | } | |
| 1320 | ||
| 1321 | // Save the c urrent CRM data | |
| 1322 | Xr m.Page.dat a.entity.s ave(); | |
| 1323 | // Display YE LLOW Progr ess.... | |
| 1324 | Xr m.Page.ui. setFormNot ification( "Verifying progress note data, please wa it..", "IN FO", "SAVE VISTA"); | |
| 1325 | ||
| 1326 | 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!'); | |
| 1327 | if (vcmn_con firmSaveTo Vista == f alse) { | |
| 1328 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 1329 | return f alse; | |
| 1330 | } | |
| 1331 | // Get regard ing data | |
| 1332 | va r vcmn_req uestId = X rm.Page.ge tAttribute ('regardin gobjectid' ).getValue (); | |
| 1333 | if (vcmn_req uestId == null) { | |
| 1334 | 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 !'); | |
| 1335 | Xrm.Page .getContro l('regardi ngobjectid ').setFocu s(); | |
| 1336 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 1337 | return f alse; | |
| 1338 | } | |
| 1339 | // Verify tha t the rega rdingid is of type ' incident' | |
| 1340 | if (vcmn_req uestId[0]. entityType != 'incid ent') { | |
| 1341 | 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!') ; | |
| 1342 | Xrm.Page .getContro l('regardi ngobjectid ').setFocu s(); | |
| 1343 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 1344 | return f alse; | |
| 1345 | } | |
| 1346 | ||
| 1347 | // Preserved Variables | |
| 1348 | va r vcmn_vet eranId = n ull; //Fr om request customeri d | |
| 1349 | va r vcmn_vet eranFirstN ame = ''; | |
| 1350 | va r vcmn_vet eranLastNa me = ''; | |
| 1351 | va r vcmn_SSN = ''; | |
| 1352 | va r vcmn_DOB = ''; | |
| 1353 | ||
| 1354 | va r vcmn_req uestData = vcmn_getS ingleEntit yDataSync( 'IncidentS et', 'Cust omerId', v cmn_reques tId[0].id) ; | |
| 1355 | if (vcmn_req uestData ! = null) { | |
| 1356 | if (vcmn _requestDa ta.d.Custo merId != n ull) { | |
| 1357 | vcmn _veteranId = vcmn_re questData. d.Customer Id; | |
| 1358 | //Ve rify that the custom erid is of type cont act | |
| 1359 | if ( vcmn_veter anId.Logic alName != 'contact') { | |
| 1360 | 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!') ; | |
| 1361 | Xrm.Page.u i.clearFor mNotificat ion("SAVEV ISTA"); | |
| 1362 | return fal se; | |
| 1363 | } | |
| 1364 | } | |
| 1365 | } | |
| 1366 | if (vcmn_vet eranId == null) { | |
| 1367 | alert('T he related request d oes not ha ve a veter an/contact assigned, the note cannot be created in VistA/CPR S!'); | |
| 1368 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 1369 | return f alse; | |
| 1370 | } | |
| 1371 | ||
| 1372 | 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); | |
| 1373 | if (vcmn_con tactData ! = null) { | |
| 1374 | if (vcmn _contactDa ta.d.First Name != nu ll) { vcmn _veteranFi rstName = vcmn_conta ctData.d.F irstName; } | |
| 1375 | if (vcmn _contactDa ta.d.LastN ame != nul l) { vcmn_ veteranLas tName = vc mn_contact Data.d.Las tName; } | |
| 1376 | if (vcmn _contactDa ta.d.ftp_D ateofBirth != null) { vcmn_DOB = vcmn_co ntactData. d.ftp_Date ofBirth; } | |
| 1377 | if (vcmn _contactDa ta.d.Gover nmentId != null) { v cmn_SSN = vcmn_conta ctData.d.G overnmentI d; } | |
| 1378 | } | |
| 1379 | ||
| 1380 | // **WORKLOAD ENCOUNTER ** | |
| 1381 | vc mn_matchLo okupId = v cmn_SSN; | |
| 1382 | // ********** ********** *** | |
| 1383 | ||
| 1384 | // Perform MV I Search | |
| 1385 | vc mn_unatten dedMviSear ch(vcmn_ve teranFirst Name, vcmn _veteranLa stName, vc mn_DOB, vc mn_SSN); | |
| 1386 | } | |
| 1387 | catch (err) { | |
| 1388 | al ert('Progr ess Note R ibbon Func tion Error (vcmn_ribb onButtonSa veToVistA) : ' + err. message); | |
| 1389 | Xr m.Page.ui. clearFormN otificatio n("SAVEVIS TA"); | |
| 1390 | } | |
| 1391 | } | |
| 1392 | ||
| 1393 | function v cmn_ribbon ButtonSave ToVistA_wi th_ICN(vcm n_patientI CN) { | |
| 1394 | try { | |
| 1395 | // ******Deve loper Bypa ss for mis sing ICN** **** | |
| 1396 | if (vcmn_pat ientICN == '' || vcm n_patientI CN == null ) { | |
| 1397 | if ((Xrm .Page.cont ext.getUse rId()).toU pperCase() == "{CA50 0504-CBC5- E511-8173- 000C2941CE 19}") { | |
| 1398 | aler t("Develop er ICN byp ass applie d!"); | |
| 1399 | vcmn _patientIC N = "12345 6V123456"; | |
| 1400 | } | |
| 1401 | } | |
| 1402 | ||
| 1403 | // Verify Pat ient ICN | |
| 1404 | if (vcmn_pat ientICN == '' || vcm n_patientI CN == null ) { | |
| 1405 | 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! '); | |
| 1406 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 1407 | return f alse; | |
| 1408 | } | |
| 1409 | ||
| 1410 | // Get regard ing data | |
| 1411 | va r vcmn_req uestId = X rm.Page.ge tAttribute ('regardin gobjectid' ).getValue (); | |
| 1412 | ||
| 1413 | // Preserved Variables | |
| 1414 | va r vcmn_vet eranId = n ull; //Fr om request customeri d | |
| 1415 | va r vcmn_vet eranName = ''; | |
| 1416 | va r vcmn_vet eranFirstN ame = ''; | |
| 1417 | va r vcmn_vet eranLastNa me = ''; | |
| 1418 | va r vcmn_vet eranMiddle Name = ''; | |
| 1419 | ||
| 1420 | va r vcmn_req uestData = vcmn_getS ingleEntit yDataSync( 'IncidentS et', 'Cust omerId', v cmn_reques tId[0].id) ; | |
| 1421 | if (vcmn_req uestData ! = null) { | |
| 1422 | if (vcmn _requestDa ta.d.Custo merId != n ull) { | |
| 1423 | vcmn _veteranId = vcmn_re questData. d.Customer Id; | |
| 1424 | //Ve rify that the custom erid is of type cont act | |
| 1425 | if ( vcmn_veter anId.Logic alName != 'contact') { | |
| 1426 | 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!') ; | |
| 1427 | Xrm.Page.u i.clearFor mNotificat ion("SAVEV ISTA"); | |
| 1428 | return fal se; | |
| 1429 | } | |
| 1430 | } | |
| 1431 | } | |
| 1432 | if (vcmn_vet eranId == null) { | |
| 1433 | alert('T he related request d oes not ha ve a veter an/contact assigned, the note cannot be created in VistA/CPR S!'); | |
| 1434 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 1435 | return f alse; | |
| 1436 | } | |
| 1437 | ||
| 1438 | va r vcmn_con tactData = vcmn_getS ingleEntit yDataSync( 'ContactSe t', 'FullN ame, First Name, Last Name, Midd leName', v cmn_vetera nId.Id); | |
| 1439 | if (vcmn_con tactData ! = null) { | |
| 1440 | if (vcmn _contactDa ta.d.FullN ame != nul l) { vcmn_ veteranNam e = vcmn_c ontactData .d.FullNam e; } | |
| 1441 | if (vcmn _contactDa ta.d.First Name != nu ll) { vcmn _veteranFi rstName = vcmn_conta ctData.d.F irstName; } | |
| 1442 | if (vcmn _contactDa ta.d.LastN ame != nul l) { vcmn_ veteranLas tName = vc mn_contact Data.d.Las tName; } | |
| 1443 | if (vcmn _contactDa ta.d.Middl eName != n ull) { vcm n_veteranM iddleName = vcmn_con tactData.d .MiddleNam e; } | |
| 1444 | } | |
| 1445 | ||
| 1446 | // Get user d ata | |
| 1447 | va r vcmn_crm UserId = X rm.Page.ge tAttribute ('ownerid' ).getValue (); | |
| 1448 | va r vcmn_use rDomainId = ''; | |
| 1449 | va r vcmn_use rFirstName = ''; | |
| 1450 | va r vcmn_use rLastName = ''; | |
| 1451 | va r vcmn_use rMiddleNam e = ''; | |
| 1452 | va r vcmn_use rSiteId = ''; | |
| 1453 | ||
| 1454 | if (vcmn_crm UserId != null) { | |
| 1455 | //Verify the owner type | |
| 1456 | if (vcmn _crmUserId [0].entity Type != 's ystemuser' ) { | |
| 1457 | 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 !'); | |
| 1458 | Xrm. Page.ui.cl earFormNot ification( "SAVEVISTA "); | |
| 1459 | retu rn false; | |
| 1460 | } | |
| 1461 | ||
| 1462 | var vcmn _userData = vcmn_get SingleEnti tyDataSync ('SystemUs erSet', 'D omainName, FirstName , LastName , MiddleNa me, ftp_Fa cilitySite Id', vcmn_ crmUserId[ 0].id); | |
| 1463 | if (vcmn _userData != null) { | |
| 1464 | if ( vcmn_userD ata.d.Doma inName != null) { vc mn_userDom ainId = vc mn_userDat a.d.Domain Name; } | |
| 1465 | if ( vcmn_userD ata.d.Firs tName != n ull) { vcm n_userFirs tName = vc mn_userDat a.d.FirstN ame; } | |
| 1466 | if ( vcmn_userD ata.d.Last Name != nu ll) { vcmn _userLastN ame = vcmn _userData. d.LastName ; } | |
| 1467 | if ( vcmn_userD ata.d.Midd leName != null) { vc mn_userMid dleName = vcmn_userD ata.d.Midd leName; } | |
| 1468 | if ( vcmn_userD ata.d.ftp_ FacilitySi teId != nu ll) { vcmn _userSiteI d = vcmn_u serData.d. ftp_Facili tySiteId.I d; } | |
| 1469 | } | |
| 1470 | } | |
| 1471 | el se { | |
| 1472 | 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!'); | |
| 1473 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 1474 | return f alse; | |
| 1475 | } | |
| 1476 | ||
| 1477 | // Verify tha t the curr ent owner and the cu rrent user is the sa me person, if not do not proce ed | |
| 1478 | if ((vcmn_cr mUserId[0] .id).toUpp erCase() ! = (Xrm.Pag e.context. getUserId( )).toUpper Case()) { | |
| 1479 | 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!'); | |
| 1480 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 1481 | return f alse; | |
| 1482 | } | |
| 1483 | va r vcmn_Not eUserTeam = "NONE"; | |
| 1484 | // Check Team membershi p | |
| 1485 | if (vcmn_Use rHasTeam(" Pharmacy", Xrm.Page. context.ge tUserId()) ) { vcmn_N oteUserTea m = "PHARM ACY"; } | |
| 1486 | if (vcmn_Use rHasTeam(" CCA Team", Xrm.Page. context.ge tUserId()) ) { vcmn_N oteUserTea m = "CCA"; } | |
| 1487 | if (vcmn_Use rHasTeam(" TAN", Xrm. Page.conte xt.getUser Id())) { v cmn_NoteUs erTeam = " TAN"; } | |
| 1488 | // **TEMP, ve rify these team valu es that th ey are cor rect **FUT URE NEED** | |
| 1489 | if (vcmn_Use rHasTeam(" PACT User" , Xrm.Page .context.g etUserId() )) { vcmn_ NoteUserTe am = "PACT "; } | |
| 1490 | if (vcmn_Use rHasTeam(" MSA User", Xrm.Page. context.ge tUserId()) ) { vcmn_N oteUserTea m = "MSA"; } | |
| 1491 | ||
| 1492 | // Verify Tea m Value, t hat one ha s been ass igned | |
| 1493 | if (vcmn_Not eUserTeam == "NONE") { | |
| 1494 | 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 !'); | |
| 1495 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 1496 | return f alse; | |
| 1497 | } | |
| 1498 | ||
| 1499 | // Get reques t form con tent | |
| 1500 | va r vcmn_not eDescripti on = Xrm.P age.getAtt ribute('ft p_notedeta il').getVa lue(); | |
| 1501 | if (vcmn_not eDescripti on == null || vcmn_n oteDescrip tion == '' ) { | |
| 1502 | alert('T he note de scription field is e mpty, the note canno t be creat ed in Vist A/CPRS!'); | |
| 1503 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 1504 | return f alse; | |
| 1505 | } | |
| 1506 | ||
| 1507 | if (Xrm.Page .getAttrib ute('ftp_i sworkloade ncounter') .getValue( ) != true) { | |
| 1508 | //Using new hospit al locatio n and loca l notes lo okup field s | |
| 1509 | var vcmn _localTitl e = Xrm.Pa ge.getAttr ibute('ftp _localnote title').ge tValue(); | |
| 1510 | if (vcmn _localTitl e == null) { | |
| 1511 | aler t('The loc al note ti tle field is empty, the note c annot be c reated in VistA/CPRS !'); | |
| 1512 | Xrm. Page.ui.cl earFormNot ification( "SAVEVISTA "); | |
| 1513 | retu rn false; | |
| 1514 | } | |
| 1515 | else { v cmn_localT itle = vcm n_localTit le[0].name ; } | |
| 1516 | ||
| 1517 | vcmn_pat ientAssign edLocation = Xrm.Pag e.getAttri bute('ftp_ notehospit allocation ').getValu e(); | |
| 1518 | if (vcmn _patientAs signedLoca tion == nu ll) { | |
| 1519 | aler t('The hos pital loca tion field is empty, the note cannot be created in VistA/CPR S!'); | |
| 1520 | Xrm. Page.ui.cl earFormNot ification( "SAVEVISTA "); | |
| 1521 | retu rn false; | |
| 1522 | } | |
| 1523 | else { v cmn_patien tAssignedL ocation = vcmn_patie ntAssigned Location[0 ].name; } | |
| 1524 | } | |
| 1525 | ||
| 1526 | va r vcmn_cal lbackNumbe r = Xrm.Pa ge.getAttr ibute('ftp _callbackn umber').ge tValue(); | |
| 1527 | if (vcmn_cal lbackNumbe r == null || vcmn_ca llbackNumb er == '') { | |
| 1528 | alert('T he callbac k number f ield is em pty, the n ote cannot be create d in VistA /CPRS!'); | |
| 1529 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 1530 | return f alse; | |
| 1531 | } | |
| 1532 | va r vcmn_rea sonForRequ est = Xrm. Page.getAt tribute('f tp_reasonf orrequest' ).getValue (); | |
| 1533 | if (vcmn_rea sonForRequ est == nul l) { | |
| 1534 | alert('T he reason for reques t field is empty, th e note can not be cre ated in Vi stA/CPRS!' ); | |
| 1535 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 1536 | return f alse; | |
| 1537 | } | |
| 1538 | ||
| 1539 | va r vcmn_enc ounterCode = 'NEW'; | |
| 1540 | ||
| 1541 | va r vcmn_sig nThisNote = Xrm.Page .getAttrib ute('ftp_s ignthisnot e').getVal ue(); | |
| 1542 | if (vcmn_sig nThisNote == 1000000 01) { vcmn _signThisN ote = true ; } else { vcmn_sign ThisNote = false; } | |
| 1543 | ||
| 1544 | // Get Progre ss Note Gu id/Id | |
| 1545 | va r vcmn_not eId = Xrm. Page.data. entity.get Id(); | |
| 1546 | ||
| 1547 | // Get Create d On Date & Convert format | |
| 1548 | va r vcmn_cre atedOnDate = vcmn_co nvertCrmDa teToVistAD ate(Xrm.Pa ge.getAttr ibute('cre atedon').g etValue()) ; | |
| 1549 | if (vcmn_cre atedOnDate == null) { | |
| 1550 | alert('T he CRM cre atedon fie ld is empt y, the not e cannot b e created in VistA/C PRS!'); | |
| 1551 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 1552 | return f alse; | |
| 1553 | } | |
| 1554 | ||
| 1555 | // Get User E ntry Date | |
| 1556 | va r vcmn_use rEntryDate = vcmn_co nvertCrmDa teToVistAD ate(Xrm.Pa ge.getAttr ibute('ftp _userentry date').get Value()); | |
| 1557 | if (vcmn_use rEntryDate == null) { vcmn_use rEntryDate = vcmn_cr eatedOnDat e; } | |
| 1558 | ||
| 1559 | // Get Facili ty and loo kup facili ty number and HL7 UR L | |
| 1560 | va r vcmn_fac ilityCode = ''; | |
| 1561 | va r vcmn_sit eHL7Listen erAddress = ''; | |
| 1562 | va r vcmn_pat ientFacili ty = Xrm.P age.getAtt ribute('ft p_patientf acility'). getValue() ; | |
| 1563 | if (vcmn_pat ientFacili ty == null ) { | |
| 1564 | alert('T he CRM pat ient facil ity field is empty, the note c annot be c reated in VistA/CPRS !'); | |
| 1565 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 1566 | return f alse; | |
| 1567 | } | |
| 1568 | el se { | |
| 1569 | var vcmn _facilityD ata = vcmn _getSingle EntityData Sync('ftp_ facilitySe t', 'ftp_f acilitycod e, ftp_hl7 listener', vcmn_pati entFacilit y[0].id); | |
| 1570 | if (vcmn _facilityD ata.d.ftp_ facilityco de != null ) { | |
| 1571 | vcmn _facilityC ode = vcmn _facilityD ata.d.ftp_ facilityco de; | |
| 1572 | } | |
| 1573 | else { | |
| 1574 | 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!') ; | |
| 1575 | Xrm. Page.ui.cl earFormNot ification( "SAVEVISTA "); | |
| 1576 | retu rn false; | |
| 1577 | } | |
| 1578 | ||
| 1579 | if (vcmn _facilityD ata.d.ftp_ hl7listene r != null) { | |
| 1580 | var vcmn_siteH L7Listener Address = vcmn_facil ityData.d. ftp_hl7lis tener; | |
| 1581 | } | |
| 1582 | else { | |
| 1583 | 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!'); | |
| 1584 | Xrm. Page.ui.cl earFormNot ification( "SAVEVISTA "); | |
| 1585 | retu rn false; | |
| 1586 | } | |
| 1587 | } | |
| 1588 | ||
| 1589 | va r vcmn_ori ginatorID = ''; | |
| 1590 | va r vcmn_use rSiteNo = ''; | |
| 1591 | ||
| 1592 | // Lookup the Facility/ Site # | |
| 1593 | if (vcmn_use rSiteId != null && v cmn_userSi teId != '' ) { | |
| 1594 | var vcmn _facilityD ata = vcmn _getSingle EntityData Sync('ftp_ facilitySe t', 'ftp_f acilitycod e', vcmn_u serSiteId) ; | |
| 1595 | if (vcmn _facilityD ata != nul l) { | |
| 1596 | if ( vcmn_facil ityData.d. ftp_facili tycode != null) { vc mn_userSit eNo = vcmn _facilityD ata.d.ftp_ facilityco de; } | |
| 1597 | } | |
| 1598 | } | |
| 1599 | ||
| 1600 | // Validate r equired Vi sta Lookup info | |
| 1601 | 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) { | |
| 1602 | //Abort process, m issing inf o | |
| 1603 | 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 !'); | |
| 1604 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 1605 | return f alse; | |
| 1606 | } | |
| 1607 | ||
| 1608 | if (Xrm.Page .getAttrib ute('ftp_i sworkloade ncounter') .getValue( ) != true) { | |
| 1609 | if (vcmn _IsProduct ionEnviron ment == fa lse) { | |
| 1610 | //Pr ovide the option to search for Lori Nich olls, site # 613 | |
| 1611 | var vcmn_imper sonateProm ptString = "**THIS I S A VISTA USER SEARC H TEST PRO MPT** \n" + | |
| 1612 | "If you wo uld like t o imperson ate the us er: \n" + | |
| 1613 | "Lori Nich olls (613) \n" + | |
| 1614 | "Select OK . Otherwi se, select CANCEL."; | |
| 1615 | var vcmn_confi rmImperson ateVistaUs er = confi rm(vcmn_im personateP romptStrin g); | |
| 1616 | if ( vcmn_confi rmImperson ateVistaUs er == true ) { | |
| 1617 | vcmn_userF irstName = "Lori"; | |
| 1618 | vcmn_userL astName = "Nicholls" ; | |
| 1619 | vcmn_userS iteNo = "6 13"; | |
| 1620 | } | |
| 1621 | } | |
| 1622 | ||
| 1623 | var vcmn _vistauser sData = vc mn_getVist aUsersData (vcmn_user FirstName, vcmn_user LastName, vcmn_userS iteNo, fal se); | |
| 1624 | ||
| 1625 | //Check vista user s data con tent | |
| 1626 | 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) { | |
| 1627 | //Ab ort proces s, missing info | |
| 1628 | aler t('Unable to obtain Vista User Data, the note cann ot be crea ted in Vis tA/CPRS!') ; | |
| 1629 | Xrm. Page.ui.cl earFormNot ification( "SAVEVISTA "); | |
| 1630 | retu rn false; | |
| 1631 | } | |
| 1632 | ||
| 1633 | var vcmn _selectedU serFirstNa me = ''; | |
| 1634 | var vcmn _selectedU serMiddleN ame = ''; | |
| 1635 | var vcmn _selectedU serLastNam e = ''; | |
| 1636 | var vcmn _selectedU serSuffix = ''; | |
| 1637 | var vcmn _selectedU serDisplay Name = ''; | |
| 1638 | var vcmn _selectedU serTitle = ''; | |
| 1639 | var vcmn _userIsSel ected = fa lse; | |
| 1640 | ||
| 1641 | if (vcmn _vistauser sData.Data .length > 1) { | |
| 1642 | 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! "); | |
| 1643 | for (var i = 0 ; i <= vcm n_vistause rsData.Dat a.length - 1; i++) { | |
| 1644 | var vcmn_c urrentUser FirstName = ''; | |
| 1645 | var vcmn_c urrentUser MiddleName = ''; | |
| 1646 | var vcmn_c urrentUser LastName = ''; | |
| 1647 | var vcmn_c urrentUser Suffix = ' '; | |
| 1648 | var vcmn_c urrentUser DisplayNam e = ''; | |
| 1649 | var vcmn_c urrentUser Title = '' ; | |
| 1650 | if (vcmn_v istausersD ata.Data[i ].FirstNam e != null) { vcmn_cu rrentUserF irstName = vcmn_vist ausersData .Data[i].F irstName; } | |
| 1651 | if (vcmn_v istausersD ata.Data[i ].MiddleNa me != null ) { vcmn_c urrentUser MiddleName = vcmn_vi stausersDa ta.Data[i] .MiddleNam e; } | |
| 1652 | if (vcmn_v istausersD ata.Data[i ].LastName != null) { vcmn_cur rentUserLa stName = v cmn_vistau sersData.D ata[i].Las tName; } | |
| 1653 | if (vcmn_v istausersD ata.Data[i ].Suffix ! = null) { vcmn_curre ntUserSuff ix = vcmn_ vistausers Data.Data[ i].Suffix; } | |
| 1654 | if (vcmn_v istausersD ata.Data[i ].DisplayN ame != nul l) { vcmn_ currentUse rDisplayNa me = vcmn_ vistausers Data.Data[ i].Display Name; } | |
| 1655 | if (vcmn_v istausersD ata.Data[i ].Title != null) { v cmn_curren tUserTitle = vcmn_vi stausersDa ta.Data[i] .Title; } | |
| 1656 | //Prompt u ser about this vista user reco rd | |
| 1657 | var vcmn_u serPromptS tring = "C lick OK, t o select t his user. Otherwise CANCEL \n " + | |
| 1658 | "\n Fi rst Name: " + vcmn_c urrentUser FirstName + | |
| 1659 | "\n Mi ddle Name: " + vcmn_ currentUse rMiddleNam e + | |
| 1660 | "\n La st Name: " + vcmn_cu rrentUserL astName + | |
| 1661 | "\n Su ffix: " + vcmn_curre ntUserSuff ix + | |
| 1662 | "\n Di splay Name : " + vcmn _currentUs erDisplayN ame + | |
| 1663 | "\n Ti tle: " + v cmn_curren tUserTitle ; | |
| 1664 | ||
| 1665 | var vcmn_c onfirmSele ctVistaUse r = confir m(vcmn_use rPromptStr ing); | |
| 1666 | if (vcmn_c onfirmSele ctVistaUse r == true) { | |
| 1667 | vcmn_u serIsSelec ted = true ; | |
| 1668 | vcmn_s electedUse rFirstName = vcmn_cu rrentUserF irstName; | |
| 1669 | vcmn_s electedUse rMiddleNam e = vcmn_c urrentUser MiddleName ; | |
| 1670 | vcmn_s electedUse rLastName = vcmn_cur rentUserLa stName; | |
| 1671 | vcmn_s electedUse rSuffix = vcmn_curre ntUserSuff ix; | |
| 1672 | vcmn_s electedUse rDisplayNa me = vcmn_ currentUse rDisplayNa me; | |
| 1673 | vcmn_s electedUse rTitle = v cmn_curren tUserTitle ; | |
| 1674 | break; | |
| 1675 | } | |
| 1676 | } | |
| 1677 | } | |
| 1678 | else { | |
| 1679 | //Se lect data from the f irst recor d | |
| 1680 | vcmn _userIsSel ected = tr ue; | |
| 1681 | if ( vcmn_vista usersData. Data[0].Fi rstName != null) { v cmn_select edUserFirs tName = vc mn_vistaus ersData.Da ta[0].Firs tName; } | |
| 1682 | if ( vcmn_vista usersData. Data[0].Mi ddleName ! = null) { vcmn_selec tedUserMid dleName = vcmn_vista usersData. Data[0].Mi ddleName; } | |
| 1683 | if ( vcmn_vista usersData. Data[0].La stName != null) { vc mn_selecte dUserLastN ame = vcmn _vistauser sData.Data [0].LastNa me; } | |
| 1684 | if ( vcmn_vista usersData. Data[0].Su ffix != nu ll) { vcmn _selectedU serSuffix = vcmn_vis tausersDat a.Data[0]. Suffix; } | |
| 1685 | if ( vcmn_vista usersData. Data[0].Di splayName != null) { vcmn_sele ctedUserDi splayName = vcmn_vis tausersDat a.Data[0]. DisplayNam e; } | |
| 1686 | if ( vcmn_vista usersData. Data[0].Ti tle != nul l) { vcmn_ selectedUs erTitle = vcmn_vista usersData. Data[0].Ti tle; } | |
| 1687 | } | |
| 1688 | ||
| 1689 | //Check if a user was select ed | |
| 1690 | if (vcmn _userIsSel ected == f alse) { | |
| 1691 | aler t('A user was not se lected fro m the prev ious promp ts, the no te cannot be created in VistA/ CPRS!'); | |
| 1692 | Xrm. Page.ui.cl earFormNot ification( "SAVEVISTA "); | |
| 1693 | retu rn false; | |
| 1694 | } | |
| 1695 | ||
| 1696 | //Execut e Integrat ion | |
| 1697 | 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); | |
| 1698 | ||
| 1699 | } | |
| 1700 | el se { | |
| 1701 | //Execut e workload encounter note inte gration st eps | |
| 1702 | vcmn_pre pWorkloadE ncounterIn tegrationS tep01(); | |
| 1703 | } | |
| 1704 | } | |
| 1705 | catch (err) { | |
| 1706 | al ert('Progr ess Note R ibbon Func tion Error (vcmn_ribb onButtonSa veToVistA_ with_ICN): ' + err.m essage); | |
| 1707 | Xr m.Page.ui. clearFormN otificatio n("SAVEVIS TA"); | |
| 1708 | } | |
| 1709 | } | |
| 1710 | ||
| 1711 | function v cmn_prepWo rkloadEnco unterInteg rationStep 01() { | |
| 1712 | try { | |
| 1713 | // Verify Not e Title | |
| 1714 | va r vcmn_Not eTitleIEN = Xrm.Page .getAttrib ute('ftp_s electedwor kloadnotet itleid').g etValue(); | |
| 1715 | if (vcmn_Not eTitleIEN == null || vcmn_Note TitleIEN = = '') { | |
| 1716 | alert('T he selecte d note tit le field i s empty, t he note ca nnot be cr eated in V istA/CPRS! '); | |
| 1717 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 1718 | return f alse; | |
| 1719 | } | |
| 1720 | // Verify Loc ation | |
| 1721 | va r vcmn_Loc ationIEN = Xrm.Page. getAttribu te('ftp_se lectedwork loadlocati onid').get Value(); | |
| 1722 | if (vcmn_Loc ationIEN = = null || vcmn_Locat ionIEN == '') { | |
| 1723 | alert('T he selecte d location field is empty, 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 | // Verify pat ient id | |
| 1728 | if (vcmn_mat chLookupId == null | | vcmn_mat chLookupId == '') { | |
| 1729 | alert('T he veteran /patient d oes not ha ve a SSN, the note c annot be c reated in VistA/CPRS !'); | |
| 1730 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 1731 | return f alse; | |
| 1732 | } | |
| 1733 | ||
| 1734 | // Get the cu rrent CRM User's ass igned site /facility | |
| 1735 | va r vcmn_use rSiteId = ""; | |
| 1736 | ||
| 1737 | va r vcmn_use rData = vc mn_getSing leEntityDa taSync('Sy stemUserSe t', 'ftp_F acilitySit eId', Xrm. Page.conte xt.getUser Id()); | |
| 1738 | if (vcmn_use rData != n ull) { | |
| 1739 | if (vcmn _userData. d.ftp_Faci litySiteId != null) { | |
| 1740 | vcmn _userSiteI d = vcmn_u serData.d. ftp_Facili tySiteId.I d; | |
| 1741 | } | |
| 1742 | } | |
| 1743 | ||
| 1744 | // Lookup the Facility/ Site # | |
| 1745 | if (vcmn_use rSiteId != null && v cmn_userSi teId != '' ) { | |
| 1746 | var vcmn _facilityD ata = vcmn _getSingle EntityData Sync('ftp_ facilitySe t', 'ftp_f acilitycod e', vcmn_u serSiteId) ; | |
| 1747 | if (vcmn _facilityD ata != nul l) { | |
| 1748 | if ( vcmn_facil ityData.d. ftp_facili tycode != null) { vc mn_ViaLogi nFacility = vcmn_fac ilityData. d.ftp_faci litycode; } | |
| 1749 | } | |
| 1750 | } | |
| 1751 | ||
| 1752 | // Check if V IA Login c ookie exis t (not exp ired) | |
| 1753 | va r vcmn_Via LoginCooki e = vcmn_g etCookie(" viasession link"); | |
| 1754 | if (vcmn_Via LoginCooki e != null && vcmn_Vi aLoginCook ie != '') { | |
| 1755 | var vcmn _cookiearr ay = vcmn_ ViaLoginCo okie.split ("~~~~", 2 ); | |
| 1756 | vcmn_Via LoginToken = vcmn_co okiearray[ 0]; | |
| 1757 | vcmn_Via LoginName = vcmn_coo kiearray[1 ]; | |
| 1758 | } | |
| 1759 | el se { | |
| 1760 | 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!") ; | |
| 1761 | Xrm.Page .ui.tabs.g et('Tab_Vi stALogin') .setVisibl e(true); | |
| 1762 | Xrm.Page .ui.tabs.g et('Tab_Vi stALogin') .setFocus( ); | |
| 1763 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 1764 | return; | |
| 1765 | } | |
| 1766 | ||
| 1767 | // Lookup Pat ient Id us ing VIA 'm atch' serv ice | |
| 1768 | 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); | |
| 1769 | } | |
| 1770 | catch (err) { | |
| 1771 | al ert('Progr ess Note R ibbon Func tion Error (vcmn_prep WorkloadEn counterInt egrationSt ep01): ' + err.messa ge); | |
| 1772 | Xr m.Page.ui. clearFormN otificatio n("SAVEVIS TA"); | |
| 1773 | } | |
| 1774 | } | |
| 1775 | ||
| 1776 | function v cmn_prepWo rkloadEnco unterInteg rationStep 01_respons e(vcmn_err or, vcmn_m atchrespon se) { | |
| 1777 | try { | |
| 1778 | // Check for non VIA se rvice erro r | |
| 1779 | if (vcmn_err or != null ) { | |
| 1780 | 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!") ; | |
| 1781 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 1782 | return f alse; | |
| 1783 | } | |
| 1784 | el se { | |
| 1785 | //Test f or VIA Ser vice Error | |
| 1786 | if (vcmn _matchresp onse.getEl ementsByTa gName("fau lt").lengt h > 0) { | |
| 1787 | 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 !"); | |
| 1788 | Xrm. Page.ui.cl earFormNot ification( "SAVEVISTA "); | |
| 1789 | retu rn false; | |
| 1790 | } | |
| 1791 | //Get VI A service Response | |
| 1792 | if (vcmn _matchresp onse.getEl ementsByTa gName("pat ients")[0] ) { | |
| 1793 | var vcmn_match Array = vc mn_matchre sponse.get ElementsBy TagName("p atients")[ 0].childNo des; | |
| 1794 | //ch ildNodes[4 ] holds th e localPid /IEN value | |
| 1795 | vcmn _ViaPatien tId = vcmn _matchArra y[0].child Nodes[4].t extContent ; | |
| 1796 | } | |
| 1797 | else { | |
| 1798 | 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 !"); | |
| 1799 | Xrm. Page.ui.cl earFormNot ification( "SAVEVISTA "); | |
| 1800 | retu rn false; | |
| 1801 | } | |
| 1802 | } | |
| 1803 | ||
| 1804 | // Verify Inp atient | |
| 1805 | if (Xrm.Page .getAttrib ute('ftp_w orkloadinp atient').g etValue() == true) { | |
| 1806 | vcmn_Via InPatient = "1"; | |
| 1807 | } | |
| 1808 | el se { | |
| 1809 | vcmn_Via InPatient = "0"; | |
| 1810 | } | |
| 1811 | ||
| 1812 | // Verify CPT Code & De scription | |
| 1813 | va r vcmn_Crm CptCode = Xrm.Page.g etAttribut e('ftp_cpt code').get Value(); | |
| 1814 | if (vcmn_Crm CptCode == null) { | |
| 1815 | alert('T he CPT Cod e field is empty, th e note can not be cre ated in Vi stA/CPRS!' ); | |
| 1816 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 1817 | return f alse; | |
| 1818 | } | |
| 1819 | el se { | |
| 1820 | var vcmn _cptData = vcmn_getS ingleEntit yDataSync( 'ftp_cptco deSet', 'f tp_amadesc ription', vcmn_CrmCp tCode[0].i d); | |
| 1821 | if (vcmn _cptData.d .ftp_amade scription != null) { | |
| 1822 | vcmn _ViaCptDes cription = (vcmn_cpt Data.d.ftp _amadescri ption).rep lace(";", "\;"); | |
| 1823 | vcmn _ViaCptCod e = vcmn_C rmCptCode[ 0].name; | |
| 1824 | } | |
| 1825 | else { | |
| 1826 | aler t('The CPT Code is m issing the AMA Descr iption, th e note can not be cre ated in Vi stA/CPRS!' ); | |
| 1827 | Xrm. Page.ui.cl earFormNot ification( "SAVEVISTA "); | |
| 1828 | retu rn false; | |
| 1829 | } | |
| 1830 | } | |
| 1831 | ||
| 1832 | // Combine CP T Code and Descripti on | |
| 1833 | va r vcmn_Cpt Combined = ''; | |
| 1834 | if (vcmn_Via CptCode.le ngth > 0 & & vcmn_Via CptDescrip tion.lengt h > 0) { | |
| 1835 | vcmn_Cpt Combined = vcmn_ViaC ptCode + " ^" + vcmn_ ViaCptDesc ription; | |
| 1836 | } | |
| 1837 | ||
| 1838 | // Verify Dia gnosis Cod e & Descri ption | |
| 1839 | va r vcmn_Crm DiagnosisC ode = Xrm. Page.getAt tribute('f tp_diagnos iscode').g etValue(); | |
| 1840 | if (vcmn_Crm DiagnosisC ode == nul l) { | |
| 1841 | alert('T he Primary Diagnosis Code fiel d is empty , the note cannot be created i n VistA/CP RS!'); | |
| 1842 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 1843 | return f alse; | |
| 1844 | } | |
| 1845 | ||
| 1846 | if (vcmn_Crm DiagnosisC ode != nul l && vcmn_ CrmDiagnos isCode != '') { | |
| 1847 | var vcmn _diagnosis Data = vcm n_getSingl eEntityDat aSync('ftp _diagnosis codeSet', 'ftp_descr iption', v cmn_CrmDia gnosisCode [0].id); | |
| 1848 | if (vcmn _diagnosis Data.d.ftp _descripti on != null ) { | |
| 1849 | vcmn _ViaDiagno sisDescrip tion = (vc mn_diagnos isData.d.f tp_descrip tion).repl ace(";", " \;"); | |
| 1850 | vcmn _ViaDiagno sisCode = vcmn_CrmDi agnosisCod e[0].name; | |
| 1851 | } | |
| 1852 | } | |
| 1853 | ||
| 1854 | // Combine Di agnosis Co de and Des cription a nd mark as PRIMARY ( ^1) | |
| 1855 | va r vcmn_Dia gnosisComb ined = ''; | |
| 1856 | if (vcmn_Via DiagnosisC ode != nul l && vcmn_ ViaDiagnos isDescript ion != nul l) { | |
| 1857 | if (vcmn _ViaDiagno sisCode.le ngth > 0 & & vcmn_Via DiagnosisD escription .length > 0) { | |
| 1858 | vcmn _Diagnosis Combined = vcmn_ViaD iagnosisCo de + "^" + vcmn_ViaD iagnosisDe scription + "^1"; | |
| 1859 | } | |
| 1860 | } | |
| 1861 | ||
| 1862 | // Get Second ary Diagno sis Codes | |
| 1863 | va r vcmn_Crm SecondaryD iagnosis = Xrm.Page. getAttribu te('ftp_se lectedseco ndarydiagn osiscodes' ).getValue (); | |
| 1864 | if (vcmn_Crm SecondaryD iagnosis ! = null && vcmn_CrmSe condaryDia gnosis != '') { | |
| 1865 | if (vcmn _Diagnosis Combined ! = '') { | |
| 1866 | vcmn _Diagnosis Combined = vcmn_Diag nosisCombi ned + ";" + vcmn_Crm SecondaryD iagnosis; | |
| 1867 | } | |
| 1868 | else { v cmn_Diagno sisCombine d = vcmn_C rmSecondar yDiagnosis ; } | |
| 1869 | } | |
| 1870 | ||
| 1871 | // Get eSigna ture code | |
| 1872 | 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 !"); | |
| 1873 | if (vcmn_eSi gnatureCod e == null || vcmn_eS ignatureCo de == "" | | vcmn_eSi gnatureCod e == "unde fined") { | |
| 1874 | alert('T he eSignat ure Code e ntered is invalid, t he note ca nnot be cr eated in V istA/CPRS! '); | |
| 1875 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 1876 | return f alse; | |
| 1877 | } | |
| 1878 | ||
| 1879 | // Get User E ntry Date | |
| 1880 | va r vcmn_cre atedOnDate = vialib_ convertToS tringDateT ime(Xrm.Pa ge.getAttr ibute('cre atedon').g etValue()) ; | |
| 1881 | va r vcmn_use rEntryDate = null; | |
| 1882 | if (Xrm.Page .getAttrib ute('ftp_u serentryda te').getVa lue() != n ull) { | |
| 1883 | vcmn_use rEntryDate = vialib_ convertToS tringDateT ime(Xrm.Pa ge.getAttr ibute('ftp _userentry date').get Value()); | |
| 1884 | } | |
| 1885 | if (vcmn_use rEntryDate == null) { vcmn_use rEntryDate = vcmn_cr eatedOnDat e; } | |
| 1886 | ||
| 1887 | // Reformat N ote Descri ption as n eeded to h andle long lines of text (Word Wrap) | |
| 1888 | va r vcmn_not eDescripti on = Xrm.P age.getAtt ribute('ft p_notedeta il').getVa lue(); | |
| 1889 | va r vcmn_Not eText = vc mn_noteDes cription; | |
| 1890 | va r vcmn_Rev isedNoteTe xt = ""; | |
| 1891 | // Do Breakdo wn of line s | |
| 1892 | va r vcmn_Tex tLines = v cmn_NoteTe xt.split(' \n'); | |
| 1893 | if (vcmn_Tex tLines.len gth > 0) { | |
| 1894 | //Reform at text | |
| 1895 | for (var i = 0; i < vcmn_Tex tLines.len gth; i++) { | |
| 1896 | //Te st for a l ong line | |
| 1897 | if ( vcmn_TextL ines[i].le ngth > vcm n_WordWrap Limit) { | |
| 1898 | //Break do wn line | |
| 1899 | var vcmn_N ewString = vcmn_word Wrap(vcmn_ TextLines[ i], vcmn_W ordWrapLim it, '\n'); | |
| 1900 | //Add revi sed text b ack | |
| 1901 | vcmn_Revis edNoteText = vcmn_Re visedNoteT ext + vcmn _NewString + "\n"; //Add back the CR/LF used to s plit on | |
| 1902 | } | |
| 1903 | else { | |
| 1904 | //Add text to new no te | |
| 1905 | vcmn_Revis edNoteText = vcmn_Re visedNoteT ext + vcmn _TextLines [i] + "\n" ; //Add ba ck the CR/ LF used to split on | |
| 1906 | } | |
| 1907 | } | |
| 1908 | } | |
| 1909 | if (vcmn_Rev isedNoteTe xt != "" & & vcmn_Rev isedNoteTe xt != null ) { | |
| 1910 | vcmn_not eDescripti on = vcmn_ RevisedNot eText; | |
| 1911 | } | |
| 1912 | ||
| 1913 | // Add list o f addition al signer names to N ote Text i f they exi sts | |
| 1914 | if (vcmn_Add lSignersNa meArray != null && v cmn_AddlSi gnersIenAr ray != nul l) { | |
| 1915 | //Create text stri ngs from a dditional signers ar ray | |
| 1916 | var vcmn _SignerNam es = "\nAd ditional N ote Signer s\n" + "-- ---------- ---------- -------\n" ; | |
| 1917 | for (var i = 0; i <= vcmn_Ad dlSignersN ameArray.l ength - 1; i++) { | |
| 1918 | if ( i >= 1) { | |
| 1919 | var vcmn_s ingleSigne rName = vc mn_AddlSig nersNameAr ray[i].spl it("___"); | |
| 1920 | vcmn_Signe rNames = v cmn_Signer Names + vc mn_singleS ignerName[ 1] + "\n"; | |
| 1921 | } | |
| 1922 | } | |
| 1923 | //Add to Note Desc ription | |
| 1924 | vcmn_not eDescripti on = vcmn_ noteDescri ption + vc mn_SignerN ames; | |
| 1925 | } | |
| 1926 | va r vcmn_Not eTitleIEN = Xrm.Page .getAttrib ute('ftp_s electedwor kloadnotet itleid').g etValue(); | |
| 1927 | va r vcmn_Loc ationIEN = Xrm.Page. getAttribu te('ftp_se lectedwork loadlocati onid').get Value(); | |
| 1928 | ||
| 1929 | // Create tex t strings from addit ional sign ers array | |
| 1930 | va r vcmn_Sig nerIEN = " "; | |
| 1931 | if (vcmn_Add lSignersIe nArray != null) { | |
| 1932 | for (var i = 0; i <= vcmn_Ad dlSignersI enArray.le ngth - 1; i++) { | |
| 1933 | if ( i == 1) { vcmn_Signe rIEN = vcm n_AddlSign ersIenArra y[i]; } | |
| 1934 | if ( i > 1) { v cmn_Signer IEN = vcmn _SignerIEN + "," + v cmn_AddlSi gnersIenAr ray[i]; } | |
| 1935 | } | |
| 1936 | } | |
| 1937 | ||
| 1938 | // Execute VI A saveNote AndEncount er Service | |
| 1939 | 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_CptComb ined, vcmn _Diagnosis Combined, vcmn_eSign atureCode, vcmn_Sign erIEN, 'E' , vcmn_sav eNoteAndEn counter_re sponse) | |
| 1940 | } | |
| 1941 | catch (err) { | |
| 1942 | al ert('Progr ess Note R ibbon Func tion Error (vcmn_prep WorkloadEn counterInt egrationSt ep01_respo nse): ' + err.messag e); | |
| 1943 | Xr m.Page.ui. clearFormN otificatio n("SAVEVIS TA"); | |
| 1944 | } | |
| 1945 | } | |
| 1946 | ||
| 1947 | function v cmn_saveNo teAndEncou nter_respo nse(vcmn_e rrorThrown , vcmn_req uestRespon se, vcmn_n oteText) { | |
| 1948 | //Proc ess Note a nd Encount er Respons e | |
| 1949 | try { | |
| 1950 | if (vcmn_err orThrown ! = null) { | |
| 1951 | //Write Error | |
| 1952 | Xrm.Page .getAttrib ute('ftp_i ntegration status').s etValue('E RROR'); | |
| 1953 | Xrm.Page .getAttrib ute('ftp_i ntegration status').s etSubmitMo de('always '); | |
| 1954 | Xrm.Page .getAttrib ute('ftp_i ntegration error').se tValue(Str ing(vcmn_e rrorThrown )); | |
| 1955 | Xrm.Page .getAttrib ute('ftp_i ntegration error').se tSubmitMod e('always' ); | |
| 1956 | Xrm.Page .getAttrib ute('ftp_i ntegration date').set Value(new Date()); | |
| 1957 | Xrm.Page .getAttrib ute('ftp_i ntegration date').set SubmitMode ('always') ; | |
| 1958 | Xrm.Page .getAttrib ute('ftp_i ntegration noteid').s etValue('' ); | |
| 1959 | Xrm.Page .getAttrib ute('ftp_i ntegration noteid').s etSubmitMo de('always '); | |
| 1960 | 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. '); | |
| 1961 | Xrm.Page .getContro l('ftp_int egrationer ror').setF ocus(); | |
| 1962 | Xrm.Page .data.enti ty.save(); | |
| 1963 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 1964 | return f alse; | |
| 1965 | } | |
| 1966 | el se { | |
| 1967 | //Write web servic e response Success o r Failure | |
| 1968 | if (vcmn _requestRe sponse.get ElementsBy TagName("f ault").len gth > 0) { | |
| 1969 | //Wr ite Failur e entry | |
| 1970 | Xrm. Page.getAt tribute('f tp_integra tionstatus ').setValu e('ERROR') ; | |
| 1971 | Xrm. Page.getAt tribute('f tp_integra tionstatus ').setSubm itMode('al ways'); | |
| 1972 | Xrm. Page.getAt tribute('f tp_integra tionerror' ).setValue ("Service Error: " + vcmn_requ estRespons e.getEleme ntsByTagNa me("fault" )[0].textC ontent); | |
| 1973 | Xrm. Page.getAt tribute('f tp_integra tionerror' ).setSubmi tMode('alw ays'); | |
| 1974 | Xrm. Page.getAt tribute('f tp_integra tiondate') .setValue( new Date() ); | |
| 1975 | Xrm. Page.getAt tribute('f tp_integra tiondate') .setSubmit Mode('alwa ys'); | |
| 1976 | Xrm. Page.getAt tribute('f tp_integra tionnoteid ').setValu e(''); | |
| 1977 | Xrm. Page.getAt tribute('f tp_integra tionnoteid ').setSubm itMode('al ways'); | |
| 1978 | 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.'); | |
| 1979 | Xrm. Page.getCo ntrol('ftp _integrati onerror'). setFocus() ; | |
| 1980 | Xrm. Page.data. entity.sav e(); | |
| 1981 | Xrm. Page.ui.cl earFormNot ification( "SAVEVISTA "); | |
| 1982 | retu rn false; | |
| 1983 | } | |
| 1984 | else { | |
| 1985 | //Te st for dat a | |
| 1986 | if ( vcmn_reque stResponse .getElemen tsByTagNam e("ns2:sav eNoteAndEn counterRes ponse")[0] ) { | |
| 1987 | //Sucessfu ll creatio n of workl oad encoun ter note | |
| 1988 | Xrm.Page.g etAttribut e('ftp_not edetail'). setValue(v cmn_noteTe xt); | |
| 1989 | Xrm.Page.g etAttribut e('ftp_not edetail'). setSubmitM ode('alway s'); | |
| 1990 | Xrm.Page.g etAttribut e('ftp_int egrationst atus').set Value('OK' ); | |
| 1991 | Xrm.Page.g etAttribut e('ftp_int egrationst atus').set SubmitMode ('always') ; | |
| 1992 | Xrm.Page.g etAttribut e('ftp_int egrationer ror').setV alue(null) ; | |
| 1993 | Xrm.Page.g etAttribut e('ftp_int egrationer ror').setS ubmitMode( 'always'); | |
| 1994 | Xrm.Page.g etAttribut e('ftp_int egrationda te').setVa lue(new Da te()); | |
| 1995 | Xrm.Page.g etAttribut e('ftp_int egrationda te').setSu bmitMode(' always'); | |
| 1996 | 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); | |
| 1997 | Xrm.Page.g etAttribut e('ftp_int egrationno teid').set SubmitMode ('always') ; | |
| 1998 | //****UPDA TE e-Sign attributes | |
| 1999 | Xrm.Page.g etAttribut e('ftp_iss igned').se tValue(tru e); | |
| 2000 | Xrm.Page.g etAttribut e('ftp_iss igned').se tSubmitMod e('always' ); | |
| 2001 | Xrm.Page.g etAttribut e('ftp_sig neddate'). setValue(n ew Date()) ; | |
| 2002 | Xrm.Page.g etAttribut e('ftp_sig neddate'). setSubmitM ode('alway s'); | |
| 2003 | //******** ********** ********** | |
| 2004 | Xrm.Page.g etControl( 'ftp_integ rationstat us').setFo cus(); | |
| 2005 | 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!'); | |
| 2006 | Xrm.Page.u i.clearFor mNotificat ion("SAVEV ISTA"); | |
| 2007 | Xrm.Page.d ata.entity .save(); | |
| 2008 | ||
| 2009 | if (vcmn_l ocalStorag eVarName ! = "" && vc mn_localSt orageVarNa me != null ) { | |
| 2010 | //Clea r existing session s torage var iable. | |
| 2011 | localS torage.rem oveItem(vc mn_localSt orageVarNa me); | |
| 2012 | } | |
| 2013 | } | |
| 2014 | else { | |
| 2015 | //Write No Data Fail ure | |
| 2016 | Xrm.Page.g etAttribut e('ftp_int egrationst atus').set Value('ERR OR'); | |
| 2017 | Xrm.Page.g etAttribut e('ftp_int egrationst atus').set SubmitMode ('always') ; | |
| 2018 | 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 !"); | |
| 2019 | Xrm.Page.g etAttribut e('ftp_int egrationer ror').setS ubmitMode( 'always'); | |
| 2020 | Xrm.Page.g etAttribut e('ftp_int egrationda te').setVa lue(new Da te()); | |
| 2021 | Xrm.Page.g etAttribut e('ftp_int egrationda te').setSu bmitMode(' always'); | |
| 2022 | Xrm.Page.g etAttribut e('ftp_int egrationno teid').set Value(''); | |
| 2023 | Xrm.Page.g etAttribut e('ftp_int egrationno teid').set SubmitMode ('always') ; | |
| 2024 | alert('The workload encounter note creat ion in Vis tA/CPRS fa iled!\nPle ase see th e integrat ion error field for details.') ; | |
| 2025 | Xrm.Page.g etControl( 'ftp_integ rationerro r').setFoc us(); | |
| 2026 | Xrm.Page.d ata.entity .save(); | |
| 2027 | Xrm.Page.u i.clearFor mNotificat ion("SAVEV ISTA"); | |
| 2028 | return fal se; | |
| 2029 | } | |
| 2030 | } | |
| 2031 | } | |
| 2032 | } | |
| 2033 | catch (err) { | |
| 2034 | al ert('Progr ess Note R ibbon Func tion Error (vcmn_save NoteAndEnc ounter_res ponse): ' + err.mess age); | |
| 2035 | Xr m.Page.ui. clearFormN otificatio n("SAVEVIS TA"); | |
| 2036 | } | |
| 2037 | } | |
| 2038 | ||
| 2039 | function v cmn_getVis taUsersDat a(vcmn_use rFirstName , vcmn_use rLastName, vcmn_user SiteNo, vc mn_noFilte r) { | |
| 2040 | try { | |
| 2041 | va r vcmn_jso nData = nu ll; | |
| 2042 | $. ajax({ | |
| 2043 | type: "G ET", | |
| 2044 | url: vcm n_VistaUse rsURLbase + vcmn_use rFirstName + "/" + v cmn_userLa stName + " /" + vcmn_ userSiteNo + "?noFil ter=" + vc mn_noFilte r, | |
| 2045 | contentT ype: "appl ication/js on; charse t=utf-8", | |
| 2046 | dataType : "json", | |
| 2047 | success: function (data) { | |
| 2048 | vcmn _jsonData = data; | |
| 2049 | }, | |
| 2050 | error: f unction (j qXHR, text Status, er rorThrown) { | |
| 2051 | //Sy stem Error | |
| 2052 | vcmn _jsonData = null; | |
| 2053 | }, | |
| 2054 | async: f alse, | |
| 2055 | cache: f alse | |
| 2056 | }) ; | |
| 2057 | re turn vcmn_ jsonData; | |
| 2058 | } | |
| 2059 | catch (err) { | |
| 2060 | al ert('Progr ess Note R ibbon Func tion Error (vcmn_getV istaUsersD ata): ' + err.messag e); | |
| 2061 | re turn null; | |
| 2062 | } | |
| 2063 | } | |
| 2064 | ||
| 2065 | 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) { | |
| 2066 | try { | |
| 2067 | // Reformat N ote Descri ption as n eeded to h andle long lines of text (Word Wrap) | |
| 2068 | va r vcmn_Not eText = vc mn_noteDes cription; | |
| 2069 | va r vcmn_Rev isedNoteTe xt = ""; | |
| 2070 | // Do Breakdo wn of line s | |
| 2071 | va r vcmn_Tex tLines = v cmn_NoteTe xt.split(' \n'); | |
| 2072 | if (vcmn_Tex tLines.len gth > 0) { | |
| 2073 | //Reform at text | |
| 2074 | for (var i = 0; i < vcmn_Tex tLines.len gth; i++) { | |
| 2075 | //Te st for a l ong line | |
| 2076 | if ( vcmn_TextL ines[i].le ngth > vcm n_WordWrap Limit) { | |
| 2077 | //Break do wn line | |
| 2078 | var vcmn_N ewString = vcmn_word Wrap(vcmn_ TextLines[ i], vcmn_W ordWrapLim it, '\n'); | |
| 2079 | //Add revi sed text b ack | |
| 2080 | vcmn_Revis edNoteText = vcmn_Re visedNoteT ext + vcmn _NewString + "\n"; //Add back the CR/LF used to s plit on | |
| 2081 | } | |
| 2082 | else { | |
| 2083 | //Add text to new no te | |
| 2084 | vcmn_Revis edNoteText = vcmn_Re visedNoteT ext + vcmn _TextLines [i] + "\n" ; //Add ba ck the CR/ LF used to split on | |
| 2085 | } | |
| 2086 | } | |
| 2087 | } | |
| 2088 | if (vcmn_Rev isedNoteTe xt != "" & & vcmn_Rev isedNoteTe xt != null ) { | |
| 2089 | vcmn_not eDescripti on = vcmn_ RevisedNot eText; | |
| 2090 | } | |
| 2091 | ||
| 2092 | // Add list o f addition al signer names to N ote Text i f they exi sts | |
| 2093 | if (vcmn_Add lSignersNa meArray != null && v cmn_AddlSi gnersIenAr ray != nul l) { | |
| 2094 | //Create text stri ngs from a dditional signers ar ray | |
| 2095 | var vcmn _SignerNam es = "\nAd ditional N ote Signer s\n" + "-- ---------- ---------- -------\n" ; | |
| 2096 | for (var i = 0; i <= vcmn_Ad dlSignersN ameArray.l ength - 1; i++) { | |
| 2097 | if ( i >= 1) { | |
| 2098 | var vcmn_s ingleSigne rName = vc mn_AddlSig nersNameAr ray[i].spl it("___"); | |
| 2099 | vcmn_Signe rNames = v cmn_Signer Names + vc mn_singleS ignerName[ 1] + "\n"; | |
| 2100 | } | |
| 2101 | } | |
| 2102 | //Add to Note Desc ription | |
| 2103 | vcmn_not eDescripti on = vcmn_ noteDescri ption + vc mn_SignerN ames; | |
| 2104 | } | |
| 2105 | ||
| 2106 | va r vcmn_vis itNumber = 'NEW'; | |
| 2107 | va r vcmn_cli entName = "FTPCRM"; | |
| 2108 | va r vcmn_For mat = "JSO N"; | |
| 2109 | va r vcmn_pat ientIdenti fierType = "ICN"; | |
| 2110 | va r vcmn_doc umentAvail abilitySta tus = "AV" ; //Histo rical Note only at t his time | |
| 2111 | va r vcmn_ori ginatorCom binedMiddl e = ""; | |
| 2112 | if (vcmn_ori ginatorMid dleName != '' && vcm n_originat orMiddleNa me != null ) { vcmn_o riginatorC ombinedMid dle = vcmn _originato rMiddleNam e; } | |
| 2113 | if (vcmn_ori ginatorSuf fix != '' && vcmn_or iginatorSu ffix != nu ll) { | |
| 2114 | if (vcmn _originato rCombinedM iddle != ' ') { | |
| 2115 | vcmn _originato rCombinedM iddle = vc mn_origina torCombine dMiddle + " " + vcmn _originato rSuffix; | |
| 2116 | } | |
| 2117 | else { | |
| 2118 | vcmn _originato rCombinedM iddle = vc mn_origina torSuffix; | |
| 2119 | } | |
| 2120 | } | |
| 2121 | ||
| 2122 | va r vcmn_req uestJSON = { | |
| 2123 | "ClientN ame": vcmn _clientNam e, | |
| 2124 | "Format" : vcmn_For mat, | |
| 2125 | "Facilit ySiteID": vcmn_facil itySiteId, | |
| 2126 | "SiteHL7 ListenerAd dress": vc mn_siteHL7 ListenerAd dress, | |
| 2127 | "VisitNu mber": vcm n_visitNum ber, | |
| 2128 | "IsSigne dNote": vc mn_signThi sNote, | |
| 2129 | "Patient AdmitDate" : vcmn_pat ientAdmitD ate, | |
| 2130 | "Patient LastName": vcmn_pati entLastNam e, | |
| 2131 | "Patient FirstName" : vcmn_pat ientFirstN ame, | |
| 2132 | "Patient Identifier ": vcmn_pa tientICN, | |
| 2133 | "Patient Identifier Type": vcm n_patientI dentifierT ype, | |
| 2134 | "Patient AssignedLo cation": v cmn_patien tAssignedL ocation, | |
| 2135 | "NoteTex t": vcmn_n oteDescrip tion, | |
| 2136 | "Origina torID": vc mn_origina torID, | |
| 2137 | "Origina torFirstNa me": vcmn_ originator FirstName, | |
| 2138 | "Origina torMiddleN ame": vcmn _originato rCombinedM iddle, | |
| 2139 | "Origina torLastNam e": vcmn_o riginatorL astName, | |
| 2140 | "Documen tFileName" : vcmn_loc alTitle, | |
| 2141 | "Documen tAvailabil ityStatus" : vcmn_doc umentAvail abilitySta tus, | |
| 2142 | "Activit yDate": vc mn_activit yDate | |
| 2143 | }; | |
| 2144 | ||
| 2145 | va r vcmn_req uestRespon se = ""; | |
| 2146 | ||
| 2147 | $. ajax({ | |
| 2148 | type: "P OST", | |
| 2149 | url: vcm n_NoteWrit eUrl, | |
| 2150 | data: JS ON.stringi fy(vcmn_re questJSON) , | |
| 2151 | contentT ype: "appl ication/js on; charse t=utf-8", | |
| 2152 | dataType : "json", | |
| 2153 | success: function (data) { | |
| 2154 | var vcmn_newda ta = data; | |
| 2155 | vcmn _requestRe sponse = v cmn_newdat a; | |
| 2156 | vcmn _vistAInte grationReq uest_respo nse(null, vcmn_reque stResponse , vcmn_not eDescripti on); | |
| 2157 | }, | |
| 2158 | error: f unction (j qXHR, text Status, er rorThrown) { | |
| 2159 | //Sy stem Error | |
| 2160 | vcmn _vistAInte grationReq uest_respo nse(errorT hrown, nul l, vcmn_no teDescript ion); | |
| 2161 | }, | |
| 2162 | async: f alse, | |
| 2163 | cache: f alse | |
| 2164 | }) ; | |
| 2165 | } | |
| 2166 | catch (err) { | |
| 2167 | al ert('Progr ess Note R ibbon Func tion Error (vcmn_exec uteVistAIn tegrationR equest): ' + err.mes sage); | |
| 2168 | Xr m.Page.ui. clearFormN otificatio n("SAVEVIS TA"); | |
| 2169 | } | |
| 2170 | } | |
| 2171 | ||
| 2172 | function v cmn_vistAI ntegration Request_re sponse(vcm n_errorThr own, vcmn_ requestRes ponse, vcm n_noteDesc ription) { | |
| 2173 | try { | |
| 2174 | // Process In tegration Request Re sponse | |
| 2175 | if (vcmn_err orThrown ! = null) { | |
| 2176 | //Write Error | |
| 2177 | Xrm.Page .getAttrib ute('ftp_i ntegration status').s etValue('E RROR'); | |
| 2178 | Xrm.Page .getAttrib ute('ftp_i ntegration status').s etSubmitMo de('always '); | |
| 2179 | Xrm.Page .getAttrib ute('ftp_i ntegration error').se tValue(Str ing(vcmn_e rrorThrown )); | |
| 2180 | Xrm.Page .getAttrib ute('ftp_i ntegration error').se tSubmitMod e('always' ); | |
| 2181 | Xrm.Page .getAttrib ute('ftp_i ntegration date').set Value(new Date()); | |
| 2182 | Xrm.Page .getAttrib ute('ftp_i ntegration date').set SubmitMode ('always') ; | |
| 2183 | Xrm.Page .getAttrib ute('ftp_i ntegration noteid').s etValue('' ); | |
| 2184 | Xrm.Page .getAttrib ute('ftp_i ntegration noteid').s etSubmitMo de('always '); | |
| 2185 | alert('T he note cr eation in VistA/CPRS failed!\n Please see the integ ration err or field f or details .'); | |
| 2186 | Xrm.Page .getContro l('ftp_int egrationer ror').setF ocus(); | |
| 2187 | Xrm.Page .data.enti ty.save(); | |
| 2188 | Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA"); | |
| 2189 | return f alse; | |
| 2190 | } | |
| 2191 | el se { | |
| 2192 | //Write web servic e response Success o r Failure | |
| 2193 | if (vcmn _requestRe sponse.Err orOccurred == false) { | |
| 2194 | //Ca ll Additio nal Signer s & Finali ze Note fu nction | |
| 2195 | vcmn _finalizeN oteCreatio n(vcmn_req uestRespon se.Status, vcmn_requ estRespons e.Data, vc mn_noteDes cription) | |
| 2196 | } | |
| 2197 | else { | |
| 2198 | //Wr ite Failur e entry | |
| 2199 | Xrm. Page.getAt tribute('f tp_integra tionstatus ').setValu e(vcmn_req uestRespon se.Status) ; | |
| 2200 | Xrm. Page.getAt tribute('f tp_integra tionstatus ').setSubm itMode('al ways'); | |
| 2201 | Xrm. Page.getAt tribute('f tp_integra tionerror' ).setValue (vcmn_requ estRespons e.ErrorMes sage + " DebugInfo: " + vcmn_r equestResp onse.Debug Info); | |
| 2202 | Xrm. Page.getAt tribute('f tp_integra tionerror' ).setSubmi tMode('alw ays'); | |
| 2203 | Xrm. Page.getAt tribute('f tp_integra tiondate') .setValue( new Date() ); | |
| 2204 | Xrm. Page.getAt tribute('f tp_integra tiondate') .setSubmit Mode('alwa ys'); | |
| 2205 | Xrm. Page.getAt tribute('f tp_integra tionnoteid ').setValu e(''); | |
| 2206 | Xrm. Page.getAt tribute('f tp_integra tionnoteid ').setSubm itMode('al ways'); | |
| 2207 | aler t('The not e creation in VistA/ CPRS faile d!\nPlease see the i ntegration error fie ld for det ails.'); | |
| 2208 | Xrm. Page.getCo ntrol('ftp _integrati onerror'). setFocus() ; | |
| 2209 | Xrm. Page.data. entity.sav e(); | |
| 2210 | Xrm. Page.ui.cl earFormNot ification( "SAVEVISTA "); | |
| 2211 | retu rn false; | |
| 2212 | } | |
| 2213 | } | |
| 2214 | } | |
| 2215 | catch (err) { | |
| 2216 | al ert('Progr ess Note R ibbon Func tion Error (vcmn_vist AIntegrati onRequest_ response): ' + err.m essage); | |
| 2217 | Xr m.Page.ui. clearFormN otificatio n("SAVEVIS TA"); | |
| 2218 | } | |
| 2219 | } | |
| 2220 | ||
| 2221 | function v cmn_finali zeNoteCrea tion(vcmn_ integratio nStatus, v cmn_integr ationNoteI d, vcmn_no teDescript ion) { | |
| 2222 | //The Note was s ucessfully created i n Vista/CP RS, add ad ditional s igners if needed | |
| 2223 | try { | |
| 2224 | // Determine if additio nal signer s exists | |
| 2225 | if (vcmn_Add lSignersNa meArray != null && v cmn_AddlSi gnersIenAr ray != nul l) { | |
| 2226 | //Get th e current CRM User's assigned site/facil ity | |
| 2227 | var vcmn _userSiteI d = ""; | |
| 2228 | var vcmn _UserSiteN o = ""; | |
| 2229 | var vcmn _duz = ""; | |
| 2230 | var vcmn _providern ame = ""; | |
| 2231 | ||
| 2232 | var vcmn _userData = vcmn_get SingleEnti tyDataSync ('SystemUs erSet', 'f tp_Facilit ySiteId', Xrm.Page.c ontext.get UserId()); | |
| 2233 | if (vcmn _userData != null) { | |
| 2234 | if ( vcmn_userD ata.d.ftp_ FacilitySi teId != nu ll) { | |
| 2235 | vcmn_userS iteId = vc mn_userDat a.d.ftp_Fa cilitySite Id.Id; | |
| 2236 | } | |
| 2237 | } | |
| 2238 | ||
| 2239 | //Lookup the Facil ity/Site # | |
| 2240 | if (vcmn _userSiteI d != null && vcmn_us erSiteId ! = '') { | |
| 2241 | var vcmn_facil ityData = vcmn_getSi ngleEntity DataSync(' ftp_facili tySet', 'f tp_facilit ycode', vc mn_userSit eId); | |
| 2242 | if ( vcmn_facil ityData != null) { | |
| 2243 | if (vcmn_f acilityDat a.d.ftp_fa cilitycode != null) { vcmn_Use rSiteNo = vcmn_facil ityData.d. ftp_facili tycode; } | |
| 2244 | } | |
| 2245 | } | |
| 2246 | ||
| 2247 | //Check if VIA Log in cookie exist (not expired) | |
| 2248 | var vcmn _ViaLoginC ookie = vc mn_getCook ie("viases sionlink") ; | |
| 2249 | if (vcmn _ViaLoginC ookie != n ull && vcm n_ViaLogin Cookie != '') { | |
| 2250 | var vcmn_cooki earray = v cmn_ViaLog inCookie.s plit("~~~~ ", 2); | |
| 2251 | vcmn _duz = vcm n_cookiear ray[0]; | |
| 2252 | vcmn _providern ame = vcmn _cookiearr ay[1]; | |
| 2253 | } | |
| 2254 | ||
| 2255 | //Create text stri ngs from a dditional signers ar ray | |
| 2256 | var vcmn _SignerIEN = ""; | |
| 2257 | for (var i = 0; i <= vcmn_Ad dlSignersI enArray.le ngth - 1; i++) { | |
| 2258 | if ( i == 1) { vcmn_Signe rIEN = vcm n_AddlSign ersIenArra y[i]; } | |
| 2259 | if ( i > 1) { v cmn_Signer IEN = vcmn _SignerIEN + " " + v cmn_AddlSi gnersIenAr ray[i]; } | |
| 2260 | } | |
| 2261 | ||
| 2262 | //Create the Addit ional Sign ers | |
| 2263 | var vcmn _viaSigner s = new Ob ject(); | |
| 2264 | vcmn_via Signers.Pr oviderName = vcmn_pr ovidername ; | |
| 2265 | vcmn_via Signers.Du z = vcmn_d uz; | |
| 2266 | vcmn_via Signers.Lo ginSiteCod e = vcmn_U serSiteNo; | |
| 2267 | vcmn_via Signers.Ta rget = vcm n_integrat ionNoteId; | |
| 2268 | vcmn_via Signers.Su pplemental Parameters = vcmn_Si gnerIEN; | |
| 2269 | ||
| 2270 | $.ajax({ | |
| 2271 | type : "POST", | |
| 2272 | url: vcmn_AddS ignersUrl, | |
| 2273 | data : JSON.str ingify(vcm n_viaSigne rs), | |
| 2274 | cont entType: " applicatio n/json; ch arset=utf- 8", | |
| 2275 | data Type: "jso n", | |
| 2276 | succ ess: funct ion (data) { | |
| 2277 | vcmn_viaSi gnersRespo nse = JSON .stringify (data.Data ); | |
| 2278 | //Test for Failure | |
| 2279 | if (vcmn_v iaSignersR esponse.Er rorOccurre d == true) { | |
| 2280 | 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!"); | |
| 2281 | } | |
| 2282 | }, | |
| 2283 | erro r: functio n (jqXHR, textStatus , errorThr own) { | |
| 2284 | //System E rror | |
| 2285 | 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!"); | |
| 2286 | }, | |
| 2287 | asyn c: false, | |
| 2288 | cach e: false | |
| 2289 | }); | |
| 2290 | ||
| 2291 | if (vcmn _localStor ageVarName != "" && vcmn_local StorageVar Name != nu ll) { | |
| 2292 | //Cl ear existi ng session storage v ariable. | |
| 2293 | loca lStorage.r emoveItem( vcmn_local StorageVar Name); | |
| 2294 | } | |
| 2295 | } | |
| 2296 | ||
| 2297 | // Perform st andard for m updates to signify completio n | |
| 2298 | // Write Succ ess entry | |
| 2299 | Xr m.Page.get Attribute( 'ftp_noted etail').se tValue(vcm n_noteDesc ription); | |
| 2300 | Xr m.Page.get Attribute( 'ftp_noted etail').se tSubmitMod e('always' ); | |
| 2301 | Xr m.Page.get Attribute( 'ftp_integ rationstat us').setVa lue(vcmn_i ntegration Status); | |
| 2302 | Xr m.Page.get Attribute( 'ftp_integ rationstat us').setSu bmitMode(' always'); | |
| 2303 | Xr m.Page.get Attribute( 'ftp_integ rationerro r').setVal ue(null); | |
| 2304 | Xr m.Page.get Attribute( 'ftp_integ rationerro r').setSub mitMode('a lways'); | |
| 2305 | Xr m.Page.get Attribute( 'ftp_integ rationdate ').setValu e(new Date ()); | |
| 2306 | Xr m.Page.get Attribute( 'ftp_integ rationdate ').setSubm itMode('al ways'); | |
| 2307 | Xr m.Page.get Attribute( 'ftp_integ rationnote id').setVa lue(vcmn_i ntegration NoteId); | |
| 2308 | Xr m.Page.get Attribute( 'ftp_integ rationnote id').setSu bmitMode(' always'); | |
| 2309 | Xr m.Page.get Control('f tp_integra tionstatus ').setFocu s(); | |
| 2310 | 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!'); | |
| 2311 | Xr m.Page.ui. clearFormN otificatio n("SAVEVIS TA"); | |
| 2312 | Xr m.Page.dat a.entity.s ave(); | |
| 2313 | } | |
| 2314 | catch (err) { | |
| 2315 | al ert('Progr ess Note R ibbon Func tion Error (vcmn_fina lizeNoteCr eation): ' + err.mes sage); | |
| 2316 | Xr m.Page.ui. clearFormN otificatio n("SAVEVIS TA"); | |
| 2317 | } | |
| 2318 | } | |
| 2319 | ||
| 2320 | function v cmn_getCoo kie(cname) { | |
| 2321 | try { | |
| 2322 | va r name = c name + "=" ; | |
| 2323 | va r ca = doc ument.cook ie.split(' ;'); | |
| 2324 | fo r (var i = 0; i < ca .length; i ++) { | |
| 2325 | var c = ca[i]; | |
| 2326 | while (c .charAt(0) == ' ') { | |
| 2327 | c = c.substrin g(1); | |
| 2328 | } | |
| 2329 | if (c.in dexOf(name ) == 0) { | |
| 2330 | retu rn c.subst ring(name. length, c. length); | |
| 2331 | } | |
| 2332 | } | |
| 2333 | re turn ""; | |
| 2334 | } | |
| 2335 | catch (err) { | |
| 2336 | al ert('Progr ess Note R ibbon Func tion Error (vcmn_getC ookie): ' + err.mess age); | |
| 2337 | } | |
| 2338 | } | |
| 2339 | ||
| 2340 | function v cmn_initVi aDropdownC ontrols() { | |
| 2341 | //Init ialize VIA DropDown Controls | |
| 2342 | //Func tion is tr iggered by The VistA Login Con trol and o nchange of Facility attribute | |
| 2343 | try { | |
| 2344 | // *Xrm.Page. getControl ("WebResou rce_Hospit alLocation ").setSrc( Xrm.Page.g etControl( "WebResour ce_Hospita lLocation" ).getSrc() ); | |
| 2345 | // *Xrm.Page. getControl ("WebResou rce_LocalN otesTitle" ).setSrc(X rm.Page.ge tControl(" WebResourc e_LocalNot esTitle"). getSrc()); | |
| 2346 | Xr m.Page.get Control("W ebResource _ViaWorklo adLookup") .setSrc(Xr m.Page.get Control("W ebResource _ViaWorklo adLookup") .getSrc()) ; | |
| 2347 | 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()); | |
| 2348 | } | |
| 2349 | catch (err) { | |
| 2350 | al ert('Progr ess Note V IA Login F unction Er ror(vcmn_i nitViaDrop downContro ls): ' + e rr.message ); | |
| 2351 | } | |
| 2352 | } | |
| 2353 | ||
| 2354 | function v cmn_facili tyGroupDef ault_respo nse(vcmn_f acilityGro upData, vc mn_lastSki p, vcmn_fa cilitySite Id) { | |
| 2355 | try { | |
| 2356 | // vcmn_lastS kip is the starting point in t he result (use if mo re than 50 records) //Not used in this s cenario | |
| 2357 | fo r (var i = 0; i <= v cmn_facili tyGroupDat a.d.result s.length - 1; i++) { | |
| 2358 | //Get Va lues and W rite to Pr ogress Not e if a new Note | |
| 2359 | if (Xrm. Page.ui.ge tFormType( ) == 1) { | |
| 2360 | if ( vcmn_facil ityGroupDa ta.d.resul ts[i].ftp_ localnotes title != n ull) { | |
| 2361 | Xrm.Page.g etAttribut e("ftp_loc alnotestit le").setVa lue(vcmn_f acilityGro upData.d.r esults[i]. ftp_localn otestitle) ; | |
| 2362 | Xrm.Page.g etAttribut e('ftp_loc alnotestit le').setSu bmitMode(' always'); | |
| 2363 | } | |
| 2364 | if ( vcmn_facil ityGroupDa ta.d.resul ts[i].ftp_ hospitallo cation != null) { | |
| 2365 | Xrm.Page.g etAttribut e("ftp_hos pitallocat ion").setV alue(vcmn_ facilityGr oupData.d. results[i] .ftp_hospi tallocatio n); | |
| 2366 | Xrm.Page.g etAttribut e('ftp_hos pitallocat ion').setS ubmitMode( 'always'); | |
| 2367 | } | |
| 2368 | if ( vcmn_facil ityGroupDa ta.d.resul ts[i].ftp_ viaworkloa dencounter locationde fault != n ull) { | |
| 2369 | //Verify t hat the te xt contain s the doub le tilde ~ ~ | |
| 2370 | if (vcmn_f acilityGro upData.d.r esults[i]. ftp_viawor kloadencou nterlocati ondefault. indexOf("~ ~") >= 0) { | |
| 2371 | //Spli t on ~~ | |
| 2372 | var vc mn_encount erLocation Array = vc mn_facilit yGroupData .d.results [i].ftp_vi aworkloade ncounterlo cationdefa ult.split( "~~", 2); | |
| 2373 | if (vc mn_encount erLocation Array.leng th > 1) { | |
| 2374 | if (vcmn_enc ounterLoca tionArray[ 0] != null && vcmn_e ncounterLo cationArra y[0] != '' && vcmn_e ncounterLo cationArra y[1] != nu ll && vcmn _encounter LocationAr ray[1] != '') { | |
| 2375 | Xrm.Page .getAttrib ute("ftp_s electedwor kloadlocat ionid").se tValue(vcm n_encounte rLocationA rray[0]); | |
| 2376 | Xrm.Page .getAttrib ute("ftp_s electedwor kloadlocat ionid").se tSubmitMod e('always' ); | |
| 2377 | Xrm.Page .getAttrib ute("ftp_s electedwor kloadlocat iontext"). setValue(v cmn_encoun terLocatio nArray[1]) ; | |
| 2378 | Xrm.Page .getAttrib ute("ftp_s electedwor kloadlocat iontext"). setSubmitM ode('alway s'); | |
| 2379 | } | |
| 2380 | } | |
| 2381 | } | |
| 2382 | } | |
| 2383 | if ( vcmn_facil ityGroupDa ta.d.resul ts[i].ftp_ viaworkloa dencounter notetitled efault != null) { | |
| 2384 | //Verify t hat the te xt contain s the doub le tilde ~ ~ | |
| 2385 | if (vcmn_f acilityGro upData.d.r esults[i]. ftp_viawor kloadencou nternoteti tledefault .indexOf(" ~~") >= 0) { | |
| 2386 | //Spli t on ~~ | |
| 2387 | var vc mn_encount erNoteTitl eArray = v cmn_facili tyGroupDat a.d.result s[i].ftp_v iaworkload encountern otetitlede fault.spli t("~~", 2) ; | |
| 2388 | if (vc mn_encount erNoteTitl eArray.len gth > 1) { | |
| 2389 | if (vcmn_enc ounterNote TitleArray [0] != nul l && vcmn_ encounterN oteTitleAr ray[0] != '' && vcmn _encounter NoteTitleA rray[1] != null && v cmn_encoun terNoteTit leArray[1] != '') { | |
| 2390 | Xrm.Page .getAttrib ute("ftp_s electedwor kloadnotet itleid").s etValue(vc mn_encount erNoteTitl eArray[0]) ; | |
| 2391 | Xrm.Page .getAttrib ute("ftp_s electedwor kloadnotet itleid").s etSubmitMo de('always '); | |
| 2392 | Xrm.Page .getAttrib ute("ftp_s electedwor kloadnotet itletext") .setValue( vcmn_encou nterNoteTi tleArray[1 ]); | |
| 2393 | Xrm.Page .getAttrib ute("ftp_s electedwor kloadnotet itletext") .setSubmit Mode('alwa ys'); | |
| 2394 | } | |
| 2395 | } | |
| 2396 | } | |
| 2397 | } | |
| 2398 | } | |
| 2399 | //Store the Id for the match ing Facili ty Group D efault, us ed later t o update f requently used value s. | |
| 2400 | if (vcmn _facilityG roupData.d .results[i ].ftp_faci litygroupd efaultId ! = null) { | |
| 2401 | vcmn _facilityG roupDefaul tId = vcmn _facilityG roupData.d .results[i ].ftp_faci litygroupd efaultId; | |
| 2402 | } | |
| 2403 | break; | |
| 2404 | } | |
| 2405 | } | |
| 2406 | catch (err) { | |
| 2407 | al ert('Progr ess Note F orm Load S cript Func tion Error (vcmn_faci lityGroupD efault_res ponse): ' + err.mess age); | |
| 2408 | } | |
| 2409 | } | |
| 2410 | ||
| 2411 | function v cmn_buildQ ueryFilter (field, va lue, and) { | |
| 2412 | try { | |
| 2413 | if (value == '') { | |
| 2414 | if (and) { | |
| 2415 | retu rn " and " + field + " eq null "; | |
| 2416 | } else { | |
| 2417 | retu rn field + " eq null "; | |
| 2418 | } | |
| 2419 | } | |
| 2420 | el se { | |
| 2421 | if (and) { | |
| 2422 | retu rn " and " + field + " eq '" + value + " '"; | |
| 2423 | } else { | |
| 2424 | retu rn field + " eq '" + value + " '"; | |
| 2425 | } | |
| 2426 | } | |
| 2427 | } | |
| 2428 | catch (err) { | |
| 2429 | al ert('Progr ess Note R ibbon Func tion Error (vcmn_buil dQueryFilt er): ' + e rr.message ); | |
| 2430 | Xr m.Page.ui. clearFormN otificatio n("SAVEVIS TA"); | |
| 2431 | } | |
| 2432 | } | |
| 2433 | ||
| 2434 | function v cmn_unatte ndedMviSea rch(firstn ame, lastn ame, dobda te, ssn) { | |
| 2435 | try { | |
| 2436 | va r filter = ""; | |
| 2437 | va r filterPr efix = "$s elect=*&$f ilter="; | |
| 2438 | va r edipi = ""; | |
| 2439 | va r dobstrin g = ""; | |
| 2440 | if (dobdate != null) { | |
| 2441 | dobstrin g = dobdat e; | |
| 2442 | } | |
| 2443 | ||
| 2444 | if (ssn != " " && ssn ! = null) { | |
| 2445 | ssn = ss n.replace( /-/g, ""); | |
| 2446 | } | |
| 2447 | ||
| 2448 | // if we have edipi, se arch using just it | |
| 2449 | if (edipi != "") { | |
| 2450 | filter = vcmn_buil dQueryFilt er("crme_E DIPI", edi pi, false) ; | |
| 2451 | filter + = vcmn_bui ldQueryFil ter("crme_ ClassCode" , 'MIL', t rue); | |
| 2452 | filter + = vcmn_bui ldQueryFil ter("crme_ SearchType ", 'Search ByIdentifi er', true) ; | |
| 2453 | ||
| 2454 | //set se arch type as unatten ded | |
| 2455 | filter + = " and cr me_IsAtten ded eq fal se"; | |
| 2456 | } | |
| 2457 | el se { | |
| 2458 | //otherw ise search using las tname, fir stname, ss n, dob | |
| 2459 | filter = vcmn_buil dQueryFilt er("crme_L astName", lastname, false); // assuming l astname wi ll never b e blank | |
| 2460 | ||
| 2461 | if (firs tname != " " && first name != nu ll) { | |
| 2462 | filt er += vcmn _buildQuer yFilter("c rme_FirstN ame", firs tname, tru e); | |
| 2463 | } | |
| 2464 | ||
| 2465 | if (ssn != "" && s sn != null ) { | |
| 2466 | filt er += vcmn _buildQuer yFilter("c rme_SSN", ssn, true) ; | |
| 2467 | } | |
| 2468 | ||
| 2469 | if (dobs tring != " ") { | |
| 2470 | filt er += " an d crme_DOB String eq '" + dobst ring + "'" ; | |
| 2471 | } | |
| 2472 | filter + = vcmn_bui ldQueryFil ter("crme_ SearchType ", 'Search ByFilter', true); | |
| 2473 | ||
| 2474 | //set se arch type as attende d (for now ) | |
| 2475 | filter + = " and cr me_IsAtten ded eq tru e"; | |
| 2476 | } | |
| 2477 | ||
| 2478 | fi lter = enc odeURIComp onent(filt er); | |
| 2479 | fi lter = fil terPrefix + filter; | |
| 2480 | 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); | |
| 2481 | } | |
| 2482 | catch (err) { | |
| 2483 | al ert('Progr ess Note R ibbon Func tion Error (vcmn_unat tendedMviS earch): ' + err.mess age); | |
| 2484 | Xr m.Page.ui. clearFormN otificatio n("SAVEVIS TA"); | |
| 2485 | } | |
| 2486 | } | |
| 2487 | ||
| 2488 | function v cmn_unatte ndedMviSea rchCallbac k(returnDa ta) { | |
| 2489 | try { | |
| 2490 | if (returnDa ta != null && return Data.lengt h >= 1) { | |
| 2491 | // check for excep tions 1st | |
| 2492 | 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.")) { | |
| 2493 | //do nothing, pass empty ICN | |
| 2494 | vcmn _ribbonBut tonSaveToV istA_with_ ICN(""); | |
| 2495 | } | |
| 2496 | else { | |
| 2497 | var patientMvi Identifier = returnD ata[0].crm e_PatientM viIdentifi er == null ? "" : re turnData[0 ].crme_Pat ientMviIde ntifier; | |
| 2498 | if ( patientMvi Identifier != "") { | |
| 2499 | var idpart s = patien tMviIdenti fier.split ("^"); | |
| 2500 | ||
| 2501 | if (idpart s.length > 0) { | |
| 2502 | var na tionalId = idparts[0 ]; | |
| 2503 | _icn = nationalI d; | |
| 2504 | //Pass on the IC N and cont inue valid ation | |
| 2505 | vcmn_r ibbonButto nSaveToVis tA_with_IC N(_icn); | |
| 2506 | } | |
| 2507 | } | |
| 2508 | } | |
| 2509 | } | |
| 2510 | el se { | |
| 2511 | //Return empty ICN | |
| 2512 | vcmn_rib bonButtonS aveToVistA _with_ICN( ""); | |
| 2513 | } | |
| 2514 | } | |
| 2515 | catch (err) { | |
| 2516 | al ert('Progr ess Note R ibbon Func tion Error (vcmn_unat tendedMviS earchCallb ack): ' + err.messag e); | |
| 2517 | Xr m.Page.ui. clearFormN otificatio n("SAVEVIS TA"); | |
| 2518 | } | |
| 2519 | } | |
| 2520 | ||
| 2521 | function v cmn_unatte ndedMviSea rchComplet e() { | |
| 2522 | //do n othing | |
| 2523 | } | |
| 2524 | ||
| 2525 | function v cmn_buildQ ueryFilter SCD(field, value, an d) { | |
| 2526 | try { | |
| 2527 | if (value == '') { | |
| 2528 | if (and) { | |
| 2529 | retu rn " and " + field + " eq null "; | |
| 2530 | } else { | |
| 2531 | retu rn field + " eq null "; | |
| 2532 | } | |
| 2533 | } | |
| 2534 | el se { | |
| 2535 | if (and) { | |
| 2536 | retu rn " and " + field + " eq '" + value + " '"; | |
| 2537 | } else { | |
| 2538 | retu rn field + " eq '" + value + " '"; | |
| 2539 | } | |
| 2540 | } | |
| 2541 | } | |
| 2542 | catch (err) { | |
| 2543 | al ert('Progr ess Note F orm Load S cript Func tion Error (vcmn_buil dQueryFilt erSCD): ' + err.mess age); | |
| 2544 | Xr m.Page.ui. clearFormN otificatio n("SAVEVIS TA"); | |
| 2545 | } | |
| 2546 | } | |
| 2547 | ||
| 2548 | function v cmn_unatte ndedMviSea rchSCD(fir stname, la stname, do bdate, ssn ) { | |
| 2549 | try { | |
| 2550 | va r filter = ""; | |
| 2551 | va r filterPr efix = "$s elect=*&$f ilter="; | |
| 2552 | va r edipi = ""; | |
| 2553 | va r dobstrin g = ""; | |
| 2554 | if (dobdate != null) { | |
| 2555 | dobstrin g = dobdat e; | |
| 2556 | } | |
| 2557 | ||
| 2558 | if (ssn != " " && ssn ! = null) { | |
| 2559 | ssn = ss n.replace( /-/g, ""); | |
| 2560 | } | |
| 2561 | ||
| 2562 | // if we have edipi, se arch using just it | |
| 2563 | if (edipi != "") { | |
| 2564 | filter = vcmn_buil dQueryFilt erSCD("crm e_EDIPI", edipi, fal se); | |
| 2565 | filter + = vcmn_bui ldQueryFil terSCD("cr me_ClassCo de", 'MIL' , true); | |
| 2566 | filter + = vcmn_bui ldQueryFil terSCD("cr me_SearchT ype", 'Sea rchByIdent ifier', tr ue); | |
| 2567 | ||
| 2568 | //set se arch type as unatten ded | |
| 2569 | filter + = " and cr me_IsAtten ded eq fal se"; | |
| 2570 | } | |
| 2571 | el se { | |
| 2572 | //otherw ise search using las tname, fir stname, ss n, dob | |
| 2573 | filter = vcmn_buil dQueryFilt erSCD("crm e_LastName ", lastnam e, false); //assumin g lastname will neve r be blank | |
| 2574 | ||
| 2575 | if (firs tname != " " && first name != nu ll) { | |
| 2576 | filt er += vcmn _buildQuer yFilterSCD ("crme_Fir stName", f irstname, true); | |
| 2577 | } | |
| 2578 | ||
| 2579 | if (ssn != "" && s sn != null ) { | |
| 2580 | filt er += vcmn _buildQuer yFilterSCD ("crme_SSN ", ssn, tr ue); | |
| 2581 | } | |
| 2582 | ||
| 2583 | if (dobs tring != " ") { | |
| 2584 | filt er += " an d crme_DOB String eq '" + dobst ring + "'" ; | |
| 2585 | } | |
| 2586 | filter + = vcmn_bui ldQueryFil terSCD("cr me_SearchT ype", 'Sea rchByFilte r', true); | |
| 2587 | ||
| 2588 | //set se arch type as attende d (for now ) | |
| 2589 | filter + = " and cr me_IsAtten ded eq tru e"; | |
| 2590 | } | |
| 2591 | ||
| 2592 | fi lter = enc odeURIComp onent(filt er); | |
| 2593 | fi lter = fil terPrefix + filter; | |
| 2594 | 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) ; | |
| 2595 | } | |
| 2596 | catch (err) { | |
| 2597 | al ert('Progr ess Note F orm Load S cript Func tion Error (vcmn_unat tendedMviS earchSCD): ' + err.m essage); | |
| 2598 | } | |
| 2599 | } | |
| 2600 | ||
| 2601 | function v cmn_unatte ndedMviSea rchCallbac kSCD(retur nData) { | |
| 2602 | try { | |
| 2603 | if (returnDa ta != null && return Data.lengt h >= 1) { | |
| 2604 | // check for excep tions 1st | |
| 2605 | 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.")) { | |
| 2606 | //do nothing, pass empty ICN | |
| 2607 | vcmn _getServic eConnected Disabiliti es(""); | |
| 2608 | } | |
| 2609 | else { | |
| 2610 | var patientMvi Identifier = returnD ata[0].crm e_PatientM viIdentifi er == null ? "" : re turnData[0 ].crme_Pat ientMviIde ntifier; | |
| 2611 | if ( patientMvi Identifier != "") { | |
| 2612 | var idpart s = patien tMviIdenti fier.split ("^"); | |
| 2613 | ||
| 2614 | if (idpart s.length > 0) { | |
| 2615 | var na tionalId = idparts[0 ]; | |
| 2616 | _icn = nationalI d; | |
| 2617 | //Pass on the IC N and cont inue with SCD | |
| 2618 | vcmn_g etServiceC onnectedDi sabilities (_icn); | |
| 2619 | } | |
| 2620 | } | |
| 2621 | } | |
| 2622 | } | |
| 2623 | el se { | |
| 2624 | //Return empty ICN | |
| 2625 | vcmn_get ServiceCon nectedDisa bilities(" "); | |
| 2626 | } | |
| 2627 | } | |
| 2628 | catch (err) { | |
| 2629 | al ert('Progr ess Note F orm Load S cript Func tion Error (vcmn_unat tendedMviS earchCallb ackSCD): ' + err.mes sage); | |
| 2630 | } | |
| 2631 | } | |
| 2632 | ||
| 2633 | //Standalo ne form lo ad functio ns | |
| 2634 | function v cmn_secure ProgressNo te() { | |
| 2635 | try { | |
| 2636 | // Disable al l form att ributes if form is o pened by a user who does not o wn the pro gress note | |
| 2637 | // Only handl e forms in create st ate | |
| 2638 | if (Xrm.Page .ui.getFor mType() != 2) { retu rn false; } //2 = CR M Update S tatus | |
| 2639 | // Get the cu rrent owne r of the r ecord and compare to the curre nt user | |
| 2640 | va r vcmn_rec ordOwnerId = Xrm.Pag e.getAttri bute('owne rid').getV alue(); | |
| 2641 | // 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 | |
| 2642 | if ((vcmn_re cordOwnerI d[0].id).t oUpperCase () != (Xrm .Page.cont ext.getUse rId()).toU pperCase() ) { | |
| 2643 | Xrm.Page .data.enti ty.attribu tes.forEac h(function (attribut e, index) { | |
| 2644 | var control = Xrm.Page.g etControl( attribute. getName()) ; | |
| 2645 | if ( control) { | |
| 2646 | control.se tDisabled( true) | |
| 2647 | } | |
| 2648 | }); | |
| 2649 | } | |
| 2650 | } | |
| 2651 | catch (err) { | |
| 2652 | al ert('Progr ess Note F orm Load F unction Er ror(vcmn_s ecureProgr essNote): ' + err.me ssage); | |
| 2653 | } | |
| 2654 | } | |
| 2655 | ||
| 2656 | function v cmn_initFi nancialDis claimer() { | |
| 2657 | //This function is used to initialze the Finan cial Discl aimer tab on the pro gress note form | |
| 2658 | try { | |
| 2659 | va r vcmn_isR eadDisclai mer = Xrm. Page.getAt tribute("f tp_isreadd isclaimer" ).getValue (); | |
| 2660 | va r vcmn_res ponseToDis claimer = Xrm.Page.g etAttribut e("ftp_isd isclaimerr ead").getV alue(); | |
| 2661 | Xr m.Page.get Attribute( "ftp_patie ntcallersr easonfordi sagreeing" ).setSubmi tMode("alw ays"); | |
| 2662 | if (vcmn_isR eadDisclai mer == tru e && vcmn_ responseTo Disclaimer == true) { | |
| 2663 | Xrm.Page .ui.tabs.g et("Tab_Fi nancialDis claimer"). setVisible (true); | |
| 2664 | Xrm.Page .getAttrib ute("ftp_i spatientag ree").setR equiredLev el("requir ed"); | |
| 2665 | var vcmn _isPatient Agree = Xr m.Page.get Attribute( "ftp_ispat ientagree" ).getValue (); | |
| 2666 | if (vcmn _isPatient Agree == f alse) { | |
| 2667 | Xrm. Page.getAt tribute("f tp_patient callersrea sonfordisa greeing"). setRequire dLevel("re quired"); | |
| 2668 | Xrm. Page.getCo ntrol("ftp _patientca llersreaso nfordisagr eeing").se tVisible(t rue); | |
| 2669 | } | |
| 2670 | else { X rm.Page.ge tControl(" ftp_patien tcallersre asonfordis agreeing") .setVisibl e(false); } | |
| 2671 | } | |
| 2672 | } | |
| 2673 | catch (err) { | |
| 2674 | al ert('Progr ess Note F inancial D isclaimer Function E rror(vcmn_ initFinanc ialDisclai mer): ' + err.messag e); | |
| 2675 | } | |
| 2676 | } | |
| 2677 | ||
| 2678 | //Standalo ne form at tribute on change ev ent functi ons | |
| 2679 | function v cmn_needTo ReadDiscla imer_OnCha nge() { | |
| 2680 | //This function is used to display t he Financi al Disclai mer prompt | |
| 2681 | try { | |
| 2682 | va r vcmn_isR eadDisclai mer = Xrm. Page.getAt tribute("f tp_isreadd isclaimer" ).getValue (); | |
| 2683 | if (vcmn_isR eadDisclai mer == tru e) { | |
| 2684 | //Financ ial Discla imer is ne eded | |
| 2685 | 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.") ; | |
| 2686 | if (vcmn _responseT oDisclaime r == true) { | |
| 2687 | Xrm. Page.ui.ta bs.get("Ta b_Financia lDisclaime r").setVis ible(true) ; | |
| 2688 | Xrm. Page.getAt tribute("f tp_isdiscl aimerread" ).setValue (true); | |
| 2689 | Xrm. Page.getAt tribute("f tp_isdiscl aimerread" ).setSubmi tMode("alw ays"); | |
| 2690 | Xrm. Page.getAt tribute("f tp_ispatie ntagree"). setRequire dLevel("re quired"); | |
| 2691 | //Se t Default Value to N ot Agreein g and Requ ire Reason for disag reeing | |
| 2692 | Xrm. Page.getAt tribute("f tp_ispatie ntagree"). setValue(f alse); | |
| 2693 | Xrm. Page.getAt tribute("f tp_ispatie ntagree"). setSubmitM ode("alway s"); | |
| 2694 | Xrm. Page.getAt tribute("f tp_patient callersrea sonfordisa greeing"). setRequire dLevel("re quired"); | |
| 2695 | Xrm. Page.getCo ntrol("ftp _patientca llersreaso nfordisagr eeing").se tVisible(t rue); | |
| 2696 | Xrm. Page.getCo ntrol("ftp _patientca llersreaso nfordisagr eeing").se tFocus(); | |
| 2697 | } | |
| 2698 | else { | |
| 2699 | Xrm. Page.ui.ta bs.get("Ta b_Financia lDisclaime r").setVis ible(false ); | |
| 2700 | Xrm. Page.getAt tribute("f tp_isdiscl aimerread" ).setValue (false); | |
| 2701 | Xrm. Page.getAt tribute("f tp_isdiscl aimerread" ).setSubmi tMode("alw ays"); | |
| 2702 | Xrm. Page.getAt tribute("f tp_ispatie ntagree"). setRequire dLevel("no ne"); | |
| 2703 | Xrm. Page.getAt tribute("f tp_patient callersrea sonfordisa greeing"). setRequire dLevel("no ne"); | |
| 2704 | Xrm. Page.getCo ntrol("ftp _patientca llersreaso nfordisagr eeing").se tVisible(f alse); | |
| 2705 | } | |
| 2706 | } | |
| 2707 | el se { | |
| 2708 | //No Fin ancial Dis claimer ne eded (Hid e Financia l Disclaim er section ) | |
| 2709 | Xrm.Page .ui.tabs.g et("Tab_Fi nancialDis claimer"). setVisible (false); | |
| 2710 | Xrm.Page .getAttrib ute("ftp_i spatientag ree").setR equiredLev el("none") ; | |
| 2711 | Xrm.Page .getAttrib ute("ftp_p atientcall ersreasonf ordisagree ing").setR equiredLev el("none") ; | |
| 2712 | Xrm.Page .getContro l("ftp_pat ientcaller sreasonfor disagreein g").setVis ible(false ); | |
| 2713 | } | |
| 2714 | } | |
| 2715 | catch (err) { | |
| 2716 | al ert('Progr ess Note F inancial D isclaimer Function E rror(vcmn_ needToRead Disclaimer _OnChange) : ' + err. message); | |
| 2717 | } | |
| 2718 | } | |
| 2719 | ||
| 2720 | function v cmn_isPati entInAgree ment_OnCha nge() { | |
| 2721 | try { | |
| 2722 | va r vcmn_isP atientAgre e = Xrm.Pa ge.getAttr ibute("ftp _ispatient agree").ge tValue(); | |
| 2723 | if (vcmn_isP atientAgre e == false ) { | |
| 2724 | Xrm.Page .getAttrib ute("ftp_p atientcall ersreasonf ordisagree ing").setR equiredLev el("requir ed"); | |
| 2725 | Xrm.Page .getContro l("ftp_pat ientcaller sreasonfor disagreein g").setVis ible(true) ; | |
| 2726 | } | |
| 2727 | el se { | |
| 2728 | Xrm.Page .getAttrib ute("ftp_p atientcall ersreasonf ordisagree ing").setR equiredLev el("none") ; | |
| 2729 | Xrm.Page .getAttrib ute("ftp_p atientcall ersreasonf ordisagree ing").setV alue(null) ; | |
| 2730 | Xrm.Page .getContro l("ftp_pat ientcaller sreasonfor disagreein g").setVis ible(false ); | |
| 2731 | //Update Note | |
| 2732 | vcmn_app endNoteFin ancialDisc laimer_OnC hange(); | |
| 2733 | } | |
| 2734 | } | |
| 2735 | catch (err) { | |
| 2736 | al ert('Progr ess Note F inancial D isclaimer Function E rror(vcmn_ isPatientI nAgreement _OnChange) : ' + err. message); | |
| 2737 | } | |
| 2738 | } | |
| 2739 | ||
| 2740 | function v cmn_append NoteFinanc ialDisclai mer_OnChan ge() { | |
| 2741 | //This function adds Finan cial Discl aimer text to the en d of the N ote | |
| 2742 | try { | |
| 2743 | // Get Curren t Note Tex t | |
| 2744 | va r vcmn_cur rentNoteTe xt = Xrm.P age.getAtt ribute('ft p_notedeta il').getVa lue(); | |
| 2745 | if (vcmn_cur rentNoteTe xt == null ) { vcmn_c urrentNote Text = ""; } | |
| 2746 | // Create new Financial Disclaime r Text | |
| 2747 | va r vcmn_fin ancialDisc laimerText = ""; | |
| 2748 | ||
| 2749 | va r vcmn_sta ndardText = "\n\nFIN ANCIAL DIS CLAIMER\n" + | |
| 2750 | "------- ---------- ---------- ---------- ---------- ---------- ---------- ---\n" + | |
| 2751 | "The fol lowing dis claimer wa s read to the caller :\n" + | |
| 2752 | "Patient was instr ucted, 'Th is is not an authori zation for VA\n" + | |
| 2753 | "Payment and also 'To have h ospital co ntact the nearest VA \n" + | |
| 2754 | "Facilit y for tran sfer upon stabilizat ion.\n"; | |
| 2755 | va r vcmn_ter minationTe xt = "\n-- ---------- ---------- ---------- ---------- ---------- ---------- --------\n "; | |
| 2756 | ||
| 2757 | va r vcmn_isR eadDisclai mer = Xrm. Page.getAt tribute("f tp_isreadd isclaimer" ).getValue (); | |
| 2758 | va r vcmn_res ponseToDis claimer = Xrm.Page.g etAttribut e("ftp_isd isclaimerr ead").getV alue(); | |
| 2759 | if (vcmn_isR eadDisclai mer == tru e && vcmn_ responseTo Disclaimer == true) { | |
| 2760 | var vcmn _isPatient Agree = Xr m.Page.get Attribute( "ftp_ispat ientagree" ).getValue (); | |
| 2761 | if (vcmn _isPatient Agree == t rue) { | |
| 2762 | vcmn _financial Disclaimer Text = vcm n_standard Text + | |
| 2763 | "\nPatient /Caller ag rees with plan." + v cmn_termin ationText; | |
| 2764 | } | |
| 2765 | else { | |
| 2766 | var vcmn_reaso nForDisagr eeing = Xr m.Page.get Attribute( "ftp_patie ntcallersr easonfordi sagreeing" ).getValue (); | |
| 2767 | if ( vcmn_reaso nForDisagr eeing == n ull) { vcm n_reasonFo rDisagreei ng = ""; } | |
| 2768 | vcmn _financial Disclaimer Text = vcm n_standard Text + | |
| 2769 | "\nPatient /Caller do es not agr ee with th e plan bec ause:\n" + | |
| 2770 | vcmn_reaso nForDisagr eeing + vc mn_termina tionText; | |
| 2771 | } | |
| 2772 | } | |
| 2773 | ||
| 2774 | // Append to existing N ote | |
| 2775 | Xr m.Page.get Attribute( 'ftp_noted etail').se tValue(vcm n_currentN oteText + vcmn_finan cialDiscla imerText); | |
| 2776 | Xr m.Page.get Attribute( 'ftp_noted etail').se tSubmitMod e('always' ); | |
| 2777 | } | |
| 2778 | catch (err) { | |
| 2779 | al ert('Progr ess Note F inancial D isclaimer Function E rror(vcmn_ appendNote FinancialD isclaimer_ OnChange): ' + err.m essage); | |
| 2780 | } | |
| 2781 | } | |
| 2782 | ||
| 2783 | function f req_button Action(fre q_buttonNa me) { | |
| 2784 | try { | |
| 2785 | // Frequently Used butt on pressed , validate Facility Group Defa ults | |
| 2786 | if (vcmn_fac ilityGroup DefaultId == null) { | |
| 2787 | alert("C rm Facilit y Group De fault has not been c onfigured. Please de fine for y our Group and Facili ty to util ize this f unctionali ty!"); | |
| 2788 | return f alse; | |
| 2789 | } | |
| 2790 | if (freq_but tonName != null && f req_button Name != un defined && freq_butt onName != "") { | |
| 2791 | //Verify button na me and tak e action a ccordingly | |
| 2792 | if (freq _buttonNam e == "Freq UsedNoteTi tleButton" ) { | |
| 2793 | //No te Title b utton clic ked | |
| 2794 | var freq_ViaNo teTitleIEN = Xrm.Pag e.getAttri bute("ftp_ selectedwo rkloadnote titleid"). getValue() ; | |
| 2795 | var freq_ViaNo teTitleDes cription = Xrm.Page. getAttribu te("ftp_se lectedwork loadnoteti tletext"). getValue() ; | |
| 2796 | if ( freq_ViaNo teTitleIEN == null | | freq_Via NoteTitleI EN == "" | | freq_Via NoteTitleD escription == null | | freq_Via NoteTitleD escription == "") { | |
| 2797 | alert("The selected Note Title is not va lid, it ca n not be a dded to th e Frequent ly Used Li st!"); | |
| 2798 | return fal se; | |
| 2799 | } | |
| 2800 | //Pr ompt User to add Not e Title | |
| 2801 | var freq_AddCo nfirm = fa lse; | |
| 2802 | Xrm. Utility.co nfirmDialo g("Are you sure you want to ad d " + freq _ViaNoteTi tleDescrip tion + " (" + freq_ ViaNoteTit leIEN + ") to the F requently Used Note Title List ?", | |
| 2803 | function ( ) { freq_A ddConfirm = true; }, | |
| 2804 | function ( ) { freq_A ddConfirm = false; } | |
| 2805 | ); | |
| 2806 | if ( freq_AddCo nfirm == f alse) { re turn false ; } | |
| 2807 | ||
| 2808 | //Ge t Existing Frequentl y Used Not e Title Li st | |
| 2809 | var freq_frequ entlyUsedN oteTitles = null; | |
| 2810 | var freq_facil ityGroupDe faultData = vcmn_get SingleEnti tyDataSync ('ftp_faci litygroupd efaultSet' , 'ftp_fre quentlyuse dnotetitle s', vcmn_f acilityGro upDefaultI d); | |
| 2811 | if ( freq_facil ityGroupDe faultData != null) { | |
| 2812 | if (freq_f acilityGro upDefaultD ata.d.ftp_ frequently usednoteti tles != nu ll) { | |
| 2813 | freq_f requentlyU sedNoteTit les = freq _facilityG roupDefaul tData.d.ft p_frequent lyusednote titles; | |
| 2814 | } | |
| 2815 | } | |
| 2816 | var freq_newNo teTitle = freq_ViaNo teTitleIEN + "~~" + freq_ViaNo teTitleDes cription; | |
| 2817 | if ( freq_frequ entlyUsedN oteTitles != null && freq_freq uentlyUsed NoteTitles != "") { | |
| 2818 | //Test for duplicate s | |
| 2819 | var freq_n oteTitleEx ist = freq _frequentl yUsedNoteT itles.inde xOf(freq_n ewNoteTitl e); | |
| 2820 | if (freq_n oteTitleEx ist != -1) { | |
| 2821 | alert( "The selec ted Note T itle alrea dy exist o n the Freq uently Use d List"); | |
| 2822 | return false; | |
| 2823 | } | |
| 2824 | } | |
| 2825 | ||
| 2826 | //Up date exist ing CRM Fa cility Gro up Default entity re cord | |
| 2827 | //Cr eate the F acility Gr oup Defaul t object | |
| 2828 | var freq_facil ityGroupDe faultItem = new Obje ct(); | |
| 2829 | if ( freq_frequ entlyUsedN oteTitles == null || freq_freq uentlyUsed NoteTitles == "") { | |
| 2830 | //Add as f irst item | |
| 2831 | freq_facil ityGroupDe faultItem. ftp_freque ntlyusedno tetitles = freq_newN oteTitle; | |
| 2832 | } | |
| 2833 | else { | |
| 2834 | //Combine with exist ing item | |
| 2835 | freq_facil ityGroupDe faultItem. ftp_freque ntlyusedno tetitles = freq_freq uentlyUsed NoteTitles + "^^" + freq_newNo teTitle; | |
| 2836 | } | |
| 2837 | //ma ke it a js on object | |
| 2838 | var jsonEntity = JSON.st ringify(fr eq_facilit yGroupDefa ultItem); | |
| 2839 | ||
| 2840 | $.aj ax({ | |
| 2841 | type: "POS T", | |
| 2842 | contentTyp e: "applic ation/json ; charset= utf-8", | |
| 2843 | datatype: "json", | |
| 2844 | url: vcmn_ serverUrl + vcmn_crm OdataEndPo int + "/" + 'ftp_fac ilitygroup defaultSet ' + "(guid '" + vcmn_ facilityGr oupDefault Id + "')", | |
| 2845 | data: json Entity, | |
| 2846 | beforeSend : function (XMLHttpR equest) { | |
| 2847 | XMLHtt pRequest.s etRequestH eader("X-H TTP-Method ", "MERGE" ); | |
| 2848 | }, | |
| 2849 | success: f unction (t extStatus, XmlHttpRe quest) { | |
| 2850 | alert( "The Selec ted Note T itle was a dded succe ssfully to the Frequ ently Used List."); | |
| 2851 | }, | |
| 2852 | error: fun ction (Xml HttpReques t, textSta tus, error Thrown) { | |
| 2853 | alert( 'Ajax Erro r in Updat e of Crm F acility Gr oup Defaul t entity: ' + errorT hrown); | |
| 2854 | } | |
| 2855 | }); | |
| 2856 | } | |
| 2857 | else if (freq_butt onName == "FreqUsedL ocationBut ton") { | |
| 2858 | //Lo cation but ton clicke d | |
| 2859 | var freq_ViaLo cationIEN = Xrm.Page .getAttrib ute("ftp_s electedwor kloadlocat ionid").ge tValue(); | |
| 2860 | var freq_ViaLo cationDesc ription = Xrm.Page.g etAttribut e("ftp_sel ectedworkl oadlocatio ntext").ge tValue(); | |
| 2861 | if ( freq_ViaLo cationIEN == null || freq_ViaL ocationIEN == "" || freq_ViaLo cationDesc ription == null || f req_ViaLoc ationDescr iption == "") { | |
| 2862 | alert("The selected Location i s not vali d, it can not be add ed to the Frequently Used List !"); | |
| 2863 | return fal se; | |
| 2864 | } | |
| 2865 | //Pr ompt User to add Loc ation | |
| 2866 | var freq_AddCo nfirm = fa lse; | |
| 2867 | Xrm. Utility.co nfirmDialo g("Are you sure you want to ad d " + freq _ViaLocati onDescript ion + " ( " + freq_V iaLocation IEN + ") to the Fre quently Us ed Locatio n List?", | |
| 2868 | function ( ) { freq_A ddConfirm = true; }, | |
| 2869 | function ( ) { freq_A ddConfirm = false; } | |
| 2870 | ); | |
| 2871 | if ( freq_AddCo nfirm == f alse) { re turn false ; } | |
| 2872 | ||
| 2873 | //Ge t Existing Frequentl y Used Loc ation List | |
| 2874 | var freq_frequ entlyUsedL ocations = null; | |
| 2875 | var freq_facil ityGroupDe faultData = vcmn_get SingleEnti tyDataSync ('ftp_faci litygroupd efaultSet' , 'ftp_fre quentlyuse dlocations ', vcmn_fa cilityGrou pDefaultId ); | |
| 2876 | if ( freq_facil ityGroupDe faultData != null) { | |
| 2877 | if (freq_f acilityGro upDefaultD ata.d.ftp_ frequently usedlocati ons != nul l) { | |
| 2878 | freq_f requentlyU sedLocatio ns = freq_ facilityGr oupDefault Data.d.ftp _frequentl yusedlocat ions; | |
| 2879 | } | |
| 2880 | } | |
| 2881 | var freq_newLo cation = f req_ViaLoc ationIEN + "~~" + fr eq_ViaLoca tionDescri ption; | |
| 2882 | if ( freq_frequ entlyUsedL ocations ! = null && freq_frequ entlyUsedL ocations ! = "") { | |
| 2883 | //Test for duplicate s | |
| 2884 | var freq_l ocationExi st = freq_ frequently UsedLocati ons.indexO f(freq_new Location); | |
| 2885 | if (freq_l ocationExi st != -1) { | |
| 2886 | alert( "The selec ted Locati on already exist on the Freque ntly Used List"); | |
| 2887 | return false; | |
| 2888 | } | |
| 2889 | } | |
| 2890 | ||
| 2891 | //Up date exist ing CRM Fa cility Gro up Default entity re cord | |
| 2892 | //Cr eate the F acility Gr oup Defaul t object | |
| 2893 | var freq_facil ityGroupDe faultItem = new Obje ct(); | |
| 2894 | if ( freq_frequ entlyUsedL ocations = = null || freq_frequ entlyUsedL ocations = = "") { | |
| 2895 | //Add as f irst item | |
| 2896 | freq_facil ityGroupDe faultItem. ftp_freque ntlyusedlo cations = freq_newLo cation; | |
| 2897 | } | |
| 2898 | else { | |
| 2899 | //Combine with exist ing item | |
| 2900 | freq_facil ityGroupDe faultItem. ftp_freque ntlyusedlo cations = freq_frequ entlyUsedL ocations + "^^" + fr eq_newLoca tion; | |
| 2901 | } | |
| 2902 | //ma ke it a js on object | |
| 2903 | var jsonEntity = JSON.st ringify(fr eq_facilit yGroupDefa ultItem); | |
| 2904 | ||
| 2905 | $.aj ax({ | |
| 2906 | type: "POS T", | |
| 2907 | contentTyp e: "applic ation/json ; charset= utf-8", | |
| 2908 | datatype: "json", | |
| 2909 | url: vcmn_ serverUrl + vcmn_crm OdataEndPo int + "/" + 'ftp_fac ilitygroup defaultSet ' + "(guid '" + vcmn_ facilityGr oupDefault Id + "')", | |
| 2910 | data: json Entity, | |
| 2911 | beforeSend : function (XMLHttpR equest) { | |
| 2912 | XMLHtt pRequest.s etRequestH eader("X-H TTP-Method ", "MERGE" ); | |
| 2913 | }, | |
| 2914 | success: f unction (t extStatus, XmlHttpRe quest) { | |
| 2915 | alert( "The Selec ted Locati on was add ed success fully to t he Frequen tly Used L ist."); | |
| 2916 | }, | |
| 2917 | error: fun ction (Xml HttpReques t, textSta tus, error Thrown) { | |
| 2918 | alert( 'Ajax Erro r in Updat e of Crm F acility Gr oup Defaul t entity: ' + errorT hrown); | |
| 2919 | } | |
| 2920 | }); | |
| 2921 | } | |
| 2922 | else { | |
| 2923 | aler t("The Fre quently Us ed button named '" + freq_butt onName + " ' has not been defin ed in this applicati on, please contact y our system administr ator!"); | |
| 2924 | retu rn false; | |
| 2925 | } | |
| 2926 | } | |
| 2927 | el se { | |
| 2928 | alert("T he Frequen tly Used b utton in u se has bee n defined incorrectl y, please contact yo ur system administra tor!"); | |
| 2929 | return f alse; | |
| 2930 | } | |
| 2931 | } | |
| 2932 | catch (err) { | |
| 2933 | al ert('Progr ess Note F requently Used Butto n Script F unction Er ror(freq_b uttonActio n): ' + er r.message) ; | |
| 2934 | } | |
| 2935 | } | |
| 2936 | ||
| 2937 | ||
| 2938 | function v cmn_execut eCrmOdataG etRequest( vcmn_jsonQ uery, vcmn _aSync, vc mn_aSyncCa llback, vc mn_skipCou nt, vcmn_o ptionArray ) { | |
| 2939 | //This function executes a CRM Odata web servi ce call to retrieve Crm data | |
| 2940 | //*vcm n_jsonQuer y* - a pro perly form atted CRM Odata Quer y string ( required) | |
| 2941 | //*vcm n_aSync* - specify ' true' to e xecute asy nchronousl y otherwis e 'false' (required) | |
| 2942 | //*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 '') | |
| 2943 | //*vcm n_skipCoun t* - Initi al setting is always '0', incr ements by 50 per CRM SDK Odata standards (required ) | |
| 2944 | //*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) | |
| 2945 | try { | |
| 2946 | va r vcmn_ent ityData = null; | |
| 2947 | $. ajax({ | |
| 2948 | type: 'G ET', | |
| 2949 | contentT ype: 'appl ication/js on; charse t=utf-8', | |
| 2950 | datatype : 'json', | |
| 2951 | url: vcm n_jsonQuer y, | |
| 2952 | beforeSe nd: functi on (XMLHtt pRequest) { | |
| 2953 | XMLH ttpRequest .setReques tHeader('A ccept', 'a pplication /json'); | |
| 2954 | }, | |
| 2955 | success: function (data, tex tStatus, X mlHttpRequ est) { | |
| 2956 | vcmn _entityDat a = data; | |
| 2957 | if ( vcmn_aSync == true) { | |
| 2958 | vcmn_aSync Callback(v cmn_entity Data, vcmn _skipCount , vcmn_opt ionArray); | |
| 2959 | } | |
| 2960 | }, | |
| 2961 | error: f unction (X MLHttpRequ est, textS tatus, err orThrown) { | |
| 2962 | aler t('Fail: A jax Error in vcmn_ex ecuteCrmOd ataGetRequ est: ' + e rrorThrown + " Reque st: " + vc mn_jsonQue ry); | |
| 2963 | }, | |
| 2964 | async: v cmn_aSync, | |
| 2965 | cache: f alse | |
| 2966 | }) ; | |
| 2967 | re turn vcmn_ entityData ; | |
| 2968 | } | |
| 2969 | catch (err) { | |
| 2970 | al ert('An er ror occure d in the v cmn_execut eCrmOdataG etRequest function. Error Det ail Messag e: ' + err ); | |
| 2971 | } | |
| 2972 | } | |
| 2973 | ||
| 2974 | 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) { | |
| 2975 | //This function returns a CRM JSON d ataset for all entit y records matching c riteria pr ovided Asy ncronously | |
| 2976 | //*vcm n_entitySe tName* - i s the name of the en tity set e .g 'Contac tSet' | |
| 2977 | //*vcm n_attribut eSet* - i s a string containin g the Crm Attributes to retrie ve e.g. 'F irstName, LastName, Telephone1 , EMailAdd ress1' | |
| 2978 | //*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 | |
| 2979 | //*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' | |
| 2980 | //*vcm n_sortDire ction* - i s a string specifyin g the sort as Ascend ing or Des cending e. g. 'asc' o r 'desc' | |
| 2981 | //*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) | |
| 2982 | //*vcm n_aSyncCal lback* - i s the name of the fu nction to call when returning the result | |
| 2983 | //*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 | |
| 2984 | ||
| 2985 | try { | |
| 2986 | 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; | |
| 2987 | vc mn_execute CrmOdataGe tRequest(v cmn_jsonQu ery, true, vcmn_aSyn cCallback, vcmn_skip Count, vcm n_optionAr ray); | |
| 2988 | } | |
| 2989 | catch (err) { | |
| 2990 | al ert('An er ror occure d in the v cmn_getMul tipleEntit yDataAsync function. Error De tail Messa ge: ' + er r); | |
| 2991 | } | |
| 2992 | } | |
| 2993 | ||
| 2994 | function v cmn_getSin gleEntityD ataSync(vc mn_entityS etName, vc mn_attribu teSet, vcm n_entityId ) { | |
| 2995 | //This function returns a CRM JSON d ataset for a single entity rec ord based on the ent ity id pro vided Sync ronously | |
| 2996 | //*vcm n_entitySe tName* - i s the name of the en tity set e .g 'Contac tSet' | |
| 2997 | //*vcm n_attribut eSet* - i s a string containin g the Crm Attributes to retrie ve e.g. 'F irstName, LastName, Telephone1 , EMailAdd ress1' | |
| 2998 | //*vcm n_entityId * - is the Guid for the entity record | |
| 2999 | ||
| 3000 | try { | |
| 3001 | va r vcmn_ent ityIdNoBra cket = vcm n_entityId .replace(/ ({|})/g, ' '); | |
| 3002 | va r vcmn_sel ectString = '(guid' + "'" + vc mn_entityI dNoBracket + "'" + ' )?$select= ' + vcmn_a ttributeSe t; | |
| 3003 | va r vcmn_jso nQuery = v cmn_server Url + vcmn _crmOdataE ndPoint + '/' + vcmn _entitySet Name + vcm n_selectSt ring; | |
| 3004 | va r vcmn_ent ityData = vcmn_execu teCrmOdata GetRequest (vcmn_json Query, fal se, '', 0, null); | |
| 3005 | re turn vcmn_ entityData ; | |
| 3006 | } | |
| 3007 | catch (err) { | |
| 3008 | al ert('An er ror occure d in the v cmn_getSin gleEntityD ataSync fu nction. E rror Detai l Message: ' + err); | |
| 3009 | } | |
| 3010 | } | |
| 3011 | ||
| 3012 | 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) { | |
| 3013 | //This function returns a CRM JSON d ataset for all entit y records matching c riteria pr ovided Syn cronously | |
| 3014 | //*vcm n_entitySe tName* - i s the name of the en tity set e .g 'Contac tSet' | |
| 3015 | //*vcm n_attribut eSet* - i s a string containin g the Crm Attributes to retrie ve e.g. 'F irstName, LastName, Telephone1 , EMailAdd ress1' | |
| 3016 | //*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 | |
| 3017 | //*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' | |
| 3018 | //*vcm n_sortDire ction* - i s a string specifyin g the sort as Ascend ing or Des cending e. g. 'asc' o r 'desc' | |
| 3019 | //*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) | |
| 3020 | ||
| 3021 | try { | |
| 3022 | 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; | |
| 3023 | va r vcmn_ent ityData = vcmn_execu teCrmOdata GetRequest (vcmn_json Query, fal se, '', vc mn_skipCou nt, null); | |
| 3024 | re turn vcmn_ entityData ; | |
| 3025 | } | |
| 3026 | catch (err) { | |
| 3027 | al ert('An er ror occure d in the v cmn_getMul tipleEntit yDataSync function. Error Det ail Messag e: ' + err ); | |
| 3028 | } | |
| 3029 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.