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