Produced by Araxis Merge on 6/22/2018 1:29:28 PM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | v1603_release_60.zip\CRM_solutions\VCCMResources.zip\WebResources | ftp_ViaServiceLibraryjsViaServiceLibraryjsA18A07F9-F9E3-E611-944A-0050568D743D | Tue May 22 14:39:24 2018 UTC |
| 2 | v1603_release_60.zip\CRM_solutions\VCCMResources.zip\WebResources | ftp_ViaServiceLibraryjsViaServiceLibraryjsA18A07F9-F9E3-E611-944A-0050568D743D | Wed Jun 20 15:35:08 2018 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 1744 |
| Changed | 1 | 2 |
| Inserted | 0 | 0 |
| Removed | 0 | 0 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | //ViaServi ceLibrary. js | |
| 2 | //Contains functions that inte ract with the VIA Se rvices | |
| 3 | ||
| 4 | var vialib _soapHeade rStartText = "<soape nv:Envelop e xmlns:so apenv='htt p://schema s.xmlsoap. org/soap/e nvelope/' " + | |
| 5 | "xmlns:ser ='http:// URL /'><soapen v:Header/> <soapenv:B ody>"; | |
| 6 | var vialib _soapHeade rEndText = "</soapen v:Body></s oapenv:Env elope>"; | |
| 7 | ||
| 8 | function v ialib_logi nVIA(viali b_requesti ngApp, via lib_consum ingAppToke n, vialib_ consumingA ppPassword , vialib_b aseService EndpointUr l, vialib_ accessCode , vialib_v erifyCode, vialib_si teCode, vi alib_respo nseCallbac k) { | |
| 9 | //This function is used to perform a login to VIA and re turns an o bject cont aining the DUZ/Token and Full Name plus other data | |
| 10 | //vial ib_request ingApp: Th is is the VIA Applic ation Code | |
| 11 | //vial ib_consumi ngAppToken : This is the VIA Ap plication Token | |
| 12 | //vial ib_consumi ngAppPassw ord: This is the VIA Applicati on Passwor d | |
| 13 | //vial ib_baseSer viceEndpoi ntUrl: Thi st is the VIA Servic e URL | |
| 14 | //vial ib_accessC ode: This is the VIA /VistA Use rId | |
| 15 | //vial ib_verifyC ode: This is the VIA /VistA Pas sword | |
| 16 | //vial ib_siteCod e: This is the Facil ity Number /Id e.g. 5 16 represe nting the facility t he VIA/Vis tA user be longs to | |
| 17 | //vial ib_respons eCallback: This is t he name of the funct ion to ret urn the qu ery result to | |
| 18 | ||
| 19 | //Retu rn Values: | |
| 20 | //1. e rror text (null when no error) | |
| 21 | //2. t he VIA Ser vice data object ret urned (nul l when err or occured ) | |
| 22 | ||
| 23 | try { | |
| 24 | // Construct Login Soap message | |
| 25 | va r vialib_s oapMessage = vialib_ soapHeader StartText + "<ser:lo ginVIA>" + "<queryBe an>" + | |
| 26 | "<reques tingApp>" + vialib_e ncodeStrin g(vialib_r equestingA pp) + "</r equestingA pp>" + | |
| 27 | "<cons umingAppTo ken>" + vi alib_encod eString(vi alib_consu mingAppTok en) + "</c onsumingAp pToken>" + | |
| 28 | "<cons umingAppPa ssword>" + vialib_en codeString (vialib_co nsumingApp Password) + "</consu mingAppPas sword>" + "</queryBe an>" + | |
| 29 | "<access Code>" + v ialib_enco deString(v ialib_acce ssCode) + "</accessC ode>" + | |
| 30 | "<veri fyCode>" + vialib_en codeString (vialib_ve rifyCode) + "</verif yCode>" + | |
| 31 | "<siteCo de>" + via lib_siteCo de + "</si teCode>" + | |
| 32 | "</ser:l oginVIA>" + vialib_s oapHeaderE ndText; | |
| 33 | ||
| 34 | // Call VIA S ervices | |
| 35 | va r vialib_l oginRespon se = null; | |
| 36 | $. ajax({ | |
| 37 | url: via lib_baseSe rviceEndpo intUrl + " /EmrServic e", | |
| 38 | type: "P OST", | |
| 39 | datatype : "xml", | |
| 40 | data: vi alib_soapM essage, | |
| 41 | contentT ype: "text /xml; char set=\'utf- 8'", | |
| 42 | dataType : "xml", | |
| 43 | success: function (data) { | |
| 44 | vial ib_loginRe sponse = d ata; | |
| 45 | vial ib_respons eCallback( null, vial ib_loginRe sponse); | |
| 46 | }, | |
| 47 | error: f unction (j qXHR, text Status, er rorThrown) { | |
| 48 | //Sy stem Error | |
| 49 | vial ib_respons eCallback( textStatus , errorThr own.messag e); | |
| 50 | }, | |
| 51 | async: f alse, | |
| 52 | cache: f alse | |
| 53 | }) ; | |
| 54 | } | |
| 55 | catch (err) { | |
| 56 | // Return fun ction erro r to callb ack functi on | |
| 57 | vi alib_respo nseCallbac k("ViaServ iceLibrary .js Functi on Error(v ialib_logi nVIA): " + err.messa ge, null); | |
| 58 | } | |
| 59 | } | |
| 60 | ||
| 61 | function v ialib_getN oteTitles( vialib_req uestingApp , vialib_c onsumingAp pToken, vi alib_consu mingAppPas sword, via lib_baseSe rviceEndpo intUrl, vi alib_provi derName, v ialib_Duz, vialib_lo ginSiteCod e, vialib_ Target, vi alib_Direc tion, vial ib_respons eCallback, vialib_ex ternalObje ct) { | |
| 62 | //This function is used to retrieve VIA Note T itles, use d in the N otes Write process | |
| 63 | //vial ib_request ingApp: Th is is the VIA Applic ation Code | |
| 64 | //vial ib_consumi ngAppToken : This is the VIA Ap plication Token | |
| 65 | //vial ib_consumi ngAppPassw ord: This is the VIA Applicati on Passwor d | |
| 66 | //vial ib_baseSer viceEndpoi ntUrl: Thi st is the VIA Servic e URL | |
| 67 | //vial ib_provide rName: Thi s is the f ull VIA/Vi stA userna me as retu rned by th e loginVIA service | |
| 68 | //vial ib_Duz: Th is is the VIA sessio n/token as returned by the log inVIA serv ice | |
| 69 | //vial ib_loginSi teCode: Th is is the facility i d e.g. 516 as a text string | |
| 70 | //vial ib_Target: This is t he search parameter leave as b lank for a ll or a si ngle lette r for note titles st arting wit h that let ter | |
| 71 | //vial ib_Directi on: This i s the sort order 1=A SC -1=DESC | |
| 72 | //vial ib_respons eCallback: This is t he name of the funct ion to ret urn the qu ery result to | |
| 73 | //vial ib_externa lObject: T his is an external o bject not used by th is functio n. This ob ject can b e returned to the re sponse fun ction if n eeded | |
| 74 | ||
| 75 | //Retu rn Values: | |
| 76 | //1. e rror text (null when no error) | |
| 77 | //2. t he VIA Ser vice data object ret urned (nul l when err or occured ) | |
| 78 | //3. t he externa lObject | |
| 79 | ||
| 80 | try { | |
| 81 | // Construct getNoteTit les Soap m essage | |
| 82 | va r vialib_s oapMessage = vialib_ soapHeader StartText + "<ser:ge tNoteTitle s>" + "<qu eryBean>" + | |
| 83 | "<reques tingApp>" + vialib_e ncodeStrin g(vialib_r equestingA pp) + "</r equestingA pp>" + | |
| 84 | "<cons umingAppTo ken>" + vi alib_encod eString(vi alib_consu mingAppTok en) + "</c onsumingAp pToken>" + | |
| 85 | "<cons umingAppPa ssword>" + vialib_en codeString (vialib_co nsumingApp Password) + "</consu mingAppPas sword>" + | |
| 86 | "<provid er>" + "<n ame>" + vi alib_encod eString(vi alib_provi derName) + "</name>" + "<login SiteCode>" + vialib_ loginSiteC ode + "</l oginSiteCo de>" + | |
| 87 | "<userId >" + viali b_encodeSt ring(viali b_Duz) + " </userId>" + "</prov ider>" + | |
| 88 | "<target >" + encod eXml(viali b_Target) + "</targe t>" + "<di rection>" + vialib_D irection + "</direct ion>" + "< /queryBean >" + | |
| 89 | "</ser:g etNoteTitl es>" + via lib_soapHe aderEndTex t; | |
| 90 | ||
| 91 | // Call VIA S ervices | |
| 92 | va r vialib_n otetitlesR esponse = null; | |
| 93 | $. ajax({ | |
| 94 | url: via lib_baseSe rviceEndpo intUrl + " /EmrServic e", | |
| 95 | type: "P OST", | |
| 96 | datatype : "xml", | |
| 97 | data: vi alib_soapM essage, | |
| 98 | contentT ype: "text /xml; char set=\'utf- 8'", | |
| 99 | dataType : "xml", | |
| 100 | success: function (data) { | |
| 101 | vial ib_notetit lesRespons e = data; | |
| 102 | vial ib_respons eCallback( null, vial ib_notetit lesRespons e, vialib_ externalOb ject); | |
| 103 | }, | |
| 104 | error: f unction (j qXHR, text Status, er rorThrown) { | |
| 105 | //Sy stem Error | |
| 106 | vial ib_respons eCallback( textStatus , errorThr own.messag e, vialib_ externalOb ject); | |
| 107 | }, | |
| 108 | async: t rue, | |
| 109 | cache: f alse | |
| 110 | }) ; | |
| 111 | } | |
| 112 | catch (err) { | |
| 113 | // Return fun ction erro r to callb ack functi on | |
| 114 | vi alib_respo nseCallbac k("ViaServ iceLibrary .js Functi on Error(v ialib_getN oteTitles) : " + err. message, n ull, viali b_external Object); | |
| 115 | } | |
| 116 | } | |
| 117 | ||
| 118 | function v ialib_getL ocations(v ialib_requ estingApp, vialib_co nsumingApp Token, via lib_consum ingAppPass word, vial ib_baseSer viceEndpoi ntUrl, via lib_provid erName, vi alib_Duz, vialib_log inSiteCode , vialib_T arget, via lib_Direct ion, viali b_response Callback, vialib_ext ernalObjec t) { | |
| 119 | //This function is used to retrieve VIA Locati ons, used in the Not es Write p rocess | |
| 120 | //vial ib_request ingApp: Th is is the VIA Applic ation Code | |
| 121 | //vial ib_consumi ngAppToken : This is the VIA Ap plication Token | |
| 122 | //vial ib_consumi ngAppPassw ord: This is the VIA Applicati on Passwor d | |
| 123 | //vial ib_baseSer viceEndpoi ntUrl: Thi st is the VIA Servic e URL | |
| 124 | //vial ib_provide rName: Thi s is the f ull VIA/Vi stA userna me as retu rned by th e loginVIA service | |
| 125 | //vial ib_Duz: Th is is the VIA sessio n/token as returned by the log inVIA serv ice | |
| 126 | //vial ib_loginSi teCode: Th is is the facility i d e.g. 516 as a text string | |
| 127 | //vial ib_Target: This is t he search parameter leave as b lank for a ll or a si ngle lette r for note titles st arting wit h that let ter | |
| 128 | //vial ib_Directi on: This i s the sort order 1=A SC -1=DESC | |
| 129 | //vial ib_respons eCallback: This is t he name of the funct ion to ret urn the qu ery result to | |
| 130 | //vial ib_externa lObject: T his is an external o bject not used by th is functio n. This ob ject can b e returned to the re sponse fun ction if n eeded | |
| 131 | ||
| 132 | //Retu rn Values: | |
| 133 | //1. e rror text (null when no error) | |
| 134 | //2. t he VIA Ser vice data object ret urned (nul l when err or occured ) | |
| 135 | //3. t he externa lObject | |
| 136 | ||
| 137 | try { | |
| 138 | // Construct getLocatio ns Soap me ssage | |
| 139 | va r vialib_s oapMessage = vialib_ soapHeader StartText + "<ser:ge tLocations >" + "<que ryBean>" + | |
| 140 | "<reques tingApp>" + vialib_e ncodeStrin g(vialib_r equestingA pp) + "</r equestingA pp>" + | |
| 141 | "<cons umingAppTo ken>" + vi alib_encod eString(vi alib_consu mingAppTok en) + "</c onsumingAp pToken>" + | |
| 142 | "<cons umingAppPa ssword>" + vialib_en codeString (vialib_co nsumingApp Password) + "</consu mingAppPas sword>" + | |
| 143 | "<provid er>" + "<n ame>" + vi alib_encod eString(vi alib_provi derName) + "</name>" + "<login SiteCode>" + vialib_ loginSiteC ode + "</l oginSiteCo de>" + | |
| 144 | "<userId >" + viali b_encodeSt ring(viali b_Duz) + " </userId>" + "</prov ider>" + | |
| 145 | "<target >" + encod eXml(viali b_Target) + "</targe t>" + "<di rection>" + vialib_D irection + "</direct ion>" + "< /queryBean >" + | |
| 146 | "</ser:g etLocation s>" + vial ib_soapHea derEndText ; | |
| 147 | ||
| 148 | // Call VIA S ervices | |
| 149 | va r vialib_l ocationsRe sponse = n ull; | |
| 150 | $. ajax({ | |
| 151 | url: via lib_baseSe rviceEndpo intUrl + " /EmrServic e", | |
| 152 | type: "P OST", | |
| 153 | datatype : "xml", | |
| 154 | data: vi alib_soapM essage, | |
| 155 | contentT ype: "text /xml; char set=\'utf- 8'", | |
| 156 | dataType : "xml", | |
| 157 | success: function (data) { | |
| 158 | vial ib_locatio nsResponse = data; | |
| 159 | vial ib_respons eCallback( null, vial ib_locatio nsResponse , vialib_e xternalObj ect); | |
| 160 | }, | |
| 161 | error: f unction (j qXHR, text Status, er rorThrown) { | |
| 162 | //Sy stem Error | |
| 163 | vial ib_respons eCallback( textStatus , errorThr own.messag e, vialib_ externalOb ject); | |
| 164 | }, | |
| 165 | async: t rue, | |
| 166 | cache: f alse | |
| 167 | }) ; | |
| 168 | } | |
| 169 | catch (err) { | |
| 170 | // Return fun ction erro r to callb ack functi on | |
| 171 | vi alib_respo nseCallbac k("ViaServ iceLibrary .js Functi on Error(v ialib_getL ocations): " + err.m essage, nu ll, vialib _externalO bject); | |
| 172 | } | |
| 173 | } | |
| 174 | ||
| 175 | function v ialib_writ eNote(vial ib_request ingApp, vi alib_consu mingAppTok en, vialib _consuming AppPasswor d, vialib_ baseServic eEndpointU rl, vialib _providerN ame, viali b_Duz, via lib_loginS iteCode, v ialib_note TitleIen, vialib_loc ationIen, vialib_enc ounterDate , vialib_e ncounterTy pe, vialib _patientId , vialib_n oteText, v ialib_resp onseCallba ck) { | |
| 176 | //This function is used to create a new note i n VistA/CP RS | |
| 177 | //vial ib_request ingApp: Th is is the VIA Applic ation Code | |
| 178 | //vial ib_consumi ngAppToken : This is the VIA Ap plication Token | |
| 179 | //vial ib_consumi ngAppPassw ord: This is the VIA Applicati on Passwor d | |
| 180 | //vial ib_baseSer viceEndpoi ntUrl: Thi st is the VIA Servic e URL | |
| 181 | //vial ib_provide rName: Thi s is the f ull VIA/Vi stA userna me as retu rned by th e loginVIA service | |
| 182 | //vial ib_Duz: Th is is the VIA sessio n/token as returned by the log inVIA serv ice | |
| 183 | //vial ib_loginSi teCode: Th is is the facility i d e.g. 516 as a text string | |
| 184 | //vial ib_noteTit leIen: Thi s is the I EN for the Note Titl e | |
| 185 | //vial ib_locatio nIen: This is the IE N for the Location | |
| 186 | //vial ib_encount erDate: Th is is the encounter date, a da tetime str ing format ted in a V istA/VIA d atetime fo rmat | |
| 187 | //vial ib_encount erType: Th is is the encounter type A-His torical, E -Non-Histo rical | |
| 188 | //vial ib_patient Id: This i s the pati ent identi fier | |
| 189 | //vial ib_noteTex t: This is the text for the no te | |
| 190 | //vial ib_respons eCallback: This is t he name of the funct ion to ret urn the qu ery result to | |
| 191 | ||
| 192 | //Retu rn Values: | |
| 193 | //1. e rror text (null when no error) | |
| 194 | //2. t he VIA Ser vice data object ret urned (nul l when err or occured ) | |
| 195 | ||
| 196 | try { | |
| 197 | // Construct writeNote Soap messa ge | |
| 198 | va r vialib_s oapMessage = vialib_ soapHeader StartText + "<ser:wr iteNote>" + | |
| 199 | "<titleI EN>" + via lib_noteTi tleIen + " </titleIEN >" + | |
| 200 | "<encoun terString> " + vialib _locationI en + ";" + vialib_en counterDat e + ";" + vialib_enc ounterType + "</enco unterStrin g>" + | |
| 201 | "<text>" + vialib_ encodeStri ng(vialib_ noteText) + "</text> " + | |
| 202 | "<queryB ean>" + | |
| 203 | "<patien t>" + "<lo calPid>" + vialib_pa tientId + "</localPi d>" + "</p atient>" + | |
| 204 | "<provid er>" + "<n ame>" + vi alib_encod eString(vi alib_provi derName) + "</name>" + "<login SiteCode>" + vialib_ loginSiteC ode + "</l oginSiteCo de>" + | |
| 205 | "<userId >" + viali b_encodeSt ring(viali b_Duz) + " </userId>" + "</prov ider>" + | |
| 206 | "<record SiteCode>" + vialib_ loginSiteC ode + "</r ecordSiteC ode>" + | |
| 207 | "<reques tingApp>" + vialib_e ncodeStrin g(vialib_r equestingA pp) + "</r equestingA pp>" + | |
| 208 | "<cons umingAppTo ken>" + vi alib_encod eString(vi alib_consu mingAppTok en) + "</c onsumingAp pToken>" + | |
| 209 | "<cons umingAppPa ssword>" + vialib_en codeString (vialib_co nsumingApp Password) + "</consu mingAppPas sword>" + | |
| 210 | "</query Bean>" + | |
| 211 | "</ser:w riteNote>" + vialib_ soapHeader EndText; | |
| 212 | ||
| 213 | // Call VIA S ervices | |
| 214 | va r vialib_w riteNoteRe sponse = n ull; | |
| 215 | $. ajax({ | |
| 216 | url: via lib_baseSe rviceEndpo intUrl + " /EmrServic e", | |
| 217 | type: "P OST", | |
| 218 | datatype : "xml", | |
| 219 | data: vi alib_soapM essage, | |
| 220 | contentT ype: "text /xml; char set=\'utf- 8'", | |
| 221 | dataType : "xml", | |
| 222 | success: function (data) { | |
| 223 | vial ib_writeNo teResponse = data; | |
| 224 | vial ib_respons eCallback( null, vial ib_writeNo teResponse ); | |
| 225 | }, | |
| 226 | error: f unction (j qXHR, text Status, er rorThrown) { | |
| 227 | //Sy stem Error | |
| 228 | vial ib_respons eCallback( textStatus , errorThr own.messag e); | |
| 229 | }, | |
| 230 | async: t rue, | |
| 231 | cache: f alse | |
| 232 | }) ; | |
| 233 | } | |
| 234 | catch (err) { | |
| 235 | // Return fun ction erro r to callb ack functi on | |
| 236 | vi alib_respo nseCallbac k("ViaServ iceLibrary .js Functi on Error(v ialib_writ eNote): " + err.mess age, null) ; | |
| 237 | } | |
| 238 | } | |
| 239 | ||
| 240 | function v ialib_matc h(vialib_r equestingA pp, vialib _consuming AppToken, vialib_con sumingAppP assword, v ialib_base ServiceEnd pointUrl, vialib_pro viderName, vialib_Du z, vialib_ loginSiteC ode, viali b_Target, vialib_res ponseCallb ack) { | |
| 241 | //This function is used to get a lis t of patie nts matchi ng target entered | |
| 242 | //vial ib_request ingApp: Th is is the VIA Applic ation Code | |
| 243 | //vial ib_consumi ngAppToken : This is the VIA Ap plication Token | |
| 244 | //vial ib_consumi ngAppPassw ord: This is the VIA Applicati on Passwor d | |
| 245 | //vial ib_baseSer viceEndpoi ntUrl: Thi st is the VIA Servic e URL | |
| 246 | //vial ib_provide rName: Thi s is the f ull VIA/Vi stA userna me as retu rned by th e loginVIA service | |
| 247 | //vial ib_Duz: Th is is the VIA sessio n/token as returned by the log inVIA serv ice | |
| 248 | //vial ib_loginSi teCode: Th is is the facility i d e.g. 516 as a text string | |
| 249 | //vial ib_Target: This is t he search parameter which shou ld be: SS N or LAST, FIRST or LXXXX (fir st letter of last na me followe d by last four digit s of SSN) | |
| 250 | //vial ib_respons eCallback: This is t he name of the funct ion to ret urn the qu ery result to | |
| 251 | ||
| 252 | //Retu rn Values: | |
| 253 | //1. e rror text (null when no error) | |
| 254 | //2. t he VIA Ser vice data object ret urned (nul l when err or occured ) | |
| 255 | ||
| 256 | try { | |
| 257 | // Construct match Soap message | |
| 258 | va r vialib_s oapMessage = vialib_ soapHeader StartText + "<ser:ma tch>" + "< queryBean> " + | |
| 259 | "<reques tingApp>" + vialib_e ncodeStrin g(vialib_r equestingA pp) + "</r equestingA pp>" + | |
| 260 | "<cons umingAppTo ken>" + vi alib_encod eString(vi alib_consu mingAppTok en) + "</c onsumingAp pToken>" + | |
| 261 | "<cons umingAppPa ssword>" + vialib_en codeString (vialib_co nsumingApp Password) + "</consu mingAppPas sword>" + | |
| 262 | "<provid er>" + "<n ame>" + vi alib_encod eString(vi alib_provi derName) + "</name>" + "<login SiteCode>" + vialib_ loginSiteC ode + "</l oginSiteCo de>" + | |
| 263 | "<userId >" + viali b_encodeSt ring(viali b_Duz) + " </userId>" + "</prov ider>" + | |
| 264 | "<target >" + encod eXml(viali b_Target) + "</targe t>" + "</q ueryBean>" + | |
| 265 | "</ser:m atch>" + v ialib_soap HeaderEndT ext; | |
| 266 | ||
| 267 | // Call VIA S ervices | |
| 268 | va r vialib_m atchRespon se = null; | |
| 269 | $. ajax({ | |
| 270 | url: via lib_baseSe rviceEndpo intUrl + " /EmrServic e", | |
| 271 | type: "P OST", | |
| 272 | datatype : "xml", | |
| 273 | data: vi alib_soapM essage, | |
| 274 | contentT ype: "text /xml; char set=\'utf- 8'", | |
| 275 | dataType : "xml", | |
| 276 | success: function (data) { | |
| 277 | vial ib_matchRe sponse = d ata; | |
| 278 | vial ib_respons eCallback( null, vial ib_matchRe sponse); | |
| 279 | }, | |
| 280 | error: f unction (j qXHR, text Status, er rorThrown) { | |
| 281 | //Sy stem Error | |
| 282 | vial ib_respons eCallback( textStatus , errorThr own.messag e); | |
| 283 | }, | |
| 284 | async: t rue, | |
| 285 | cache: f alse | |
| 286 | }) ; | |
| 287 | } | |
| 288 | catch (err) { | |
| 289 | // Return fun ction erro r to callb ack functi on | |
| 290 | vi alib_respo nseCallbac k("ViaServ iceLibrary .js Functi on Error(v ialib_matc h): " + er r.message, null); | |
| 291 | } | |
| 292 | } | |
| 293 | ||
| 294 | function v ialib_save NoteAndEnc ounter(via lib_reques tingApp, v ialib_cons umingAppTo ken, viali b_consumin gAppPasswo rd, vialib _baseServi ceEndpoint Url, viali b_provider Name, vial ib_Duz, vi alib_login SiteCode, vialib_not eTitleIen, vialib_lo cationIen, vialib_pa tientId, v ialib_note Text, vial ib_startDa te, vialib _patientLo calSiteNo, vialib_In patient, v ialib_CptA rrayText, vialib_Dia gnosisArra yText, via lib_eSignC ode, viali b_signingP roviders, vialib_ser viceCatego ry, vialib _visitRela ted, viali b_response Callback) { | |
| 295 | //This function is used to create a new note a nd encount er in Vist A/CPRS | |
| 296 | //vial ib_request ingApp: Th is is the VIA Applic ation Code | |
| 297 | //vial ib_consumi ngAppToken : This is the VIA Ap plication Token | |
| 298 | //vial ib_consumi ngAppPassw ord: This is the VIA Applicati on Passwor d | |
| 299 | //vial ib_baseSer viceEndpoi ntUrl: Thi st is the VIA Servic e URL | |
| 300 | //vial ib_provide rName: Thi s is the f ull VIA/Vi stA userna me as retu rned by th e loginVIA service | |
| 301 | //vial ib_Duz: Th is is the VIA sessio n/token as returned by the log inVIA serv ice | |
| 302 | //vial ib_loginSi teCode: Th is is the facility i d e.g. 516 as a text string | |
| 303 | //vial ib_noteTit leIen: Thi s is the I EN for the Note Titl e | |
| 304 | //vial ib_locatio nIen: This is the IE N for the Location | |
| 305 | //vial ib_patient Id: This i s the pati ent identi fier | |
| 306 | //vial ib_noteTex t: This is the text for the no te | |
| 307 | //vial ib_startDa te: This i s the note date | |
| 308 | //vial ib_patient LocalSiteN o: This is the patie nt's local Site/Faci lity No e. g. 613 as a text str ing | |
| 309 | //vial ib_Inpatie nt: Inpati ent = 1, N ot Inpatie nt = 0 | |
| 310 | //vial ib_CptArra yText: Thi s is the s tring pass ed as <pro cedures>, is made up of CPT Co des and De scription formatted per specs | |
| 311 | //vial ib_Diagnos isArrayTex t: This is the strin g passed a s <diagnos es>, is ma de up of D iagnosis C odes and D escription formatted per specs | |
| 312 | //vial ib_eSignCo de: The eS ignature C ode (A uni que signat ure code a ssigned in Vista to the VIA lo gged in us er. (Not the IEN or DUZ value s)) | |
| 313 | //vial ib_signing Providers: The IENs for additi onal signe rs/provide rs. A com ma delimit ed string of IENs | |
| 314 | //vial ib_service Category: A, H or E | |
| 315 | //vial ib_visitRe lated: Is a list of values sep arated by comma, e.g . 'SC,CV,A O' (Servi ce Connect ed, Combat Veteran, Agent Oran ge) | |
| 316 | //vial ib_respons eCallback: This is t he name of the funct ion to ret urn the qu ery result to | |
| 317 | ||
| 318 | //Retu rn Values: | |
| 319 | //1. e rror text (null when no error) | |
| 320 | //2. t he VIA Ser vice data object ret urned (nul l when err or occured ) | |
| 321 | ||
| 322 | try { | |
| 323 | // Construct saveNoteAn dEncounter Soap mess age | |
| 324 | // NOTE: Adde d default of '<visit RelatedTos >SC</visit RelatedTos >' below, to correct service i ssue per J essica Rom eroll 02/1 6/2017 | |
| 325 | // NOTE: The above row, has now b een update d to be a parameter consiting of a list of values separated by comma | |
| 326 | ||
| 327 | // ********** ********** ********** ********** ********** ********** ********** ********** ********** ********** ********* | |
| 328 | va r vialib_n oteDescrip tion = via lib_noteTe xt; | |
| 329 | // Reformat N ote Descri ption for VIA Note a nd Encount er web ser vice to ha ndle line feed and c arriage re turn | |
| 330 | // Replace al l \n and \ r occurren ces with | | |
| 331 | vi alib_noteD escription = vialib_ noteDescri ption.repl ace(/\n/g, "|"); | |
| 332 | vi alib_noteD escription = vialib_ noteDescri ption.repl ace(/\r/g, "|"); | |
| 333 | ||
| 334 | va r vialib_s tartDateSt ring = ""; | |
| 335 | // If there i s a start date, then create th e start da te string | |
| 336 | if (vialib_s tartDate ! = "" && vi alib_start Date != nu ll) { | |
| 337 | vialib_s tartDateSt ring = "<s tartDate>" + vialib_ startDate + "</start Date>" | |
| 338 | } | |
| 339 | // ********** ********** ********** ********** ********** ********** ********** ********** ********** ********** ********* | |
| 340 | ||
| 341 | va r vialib_s oapMessage = vialib_ soapHeader StartText + "<ser:sa veNoteAndE ncounter>" + | |
| 342 | "<noteAn dEncounter >" + | |
| 343 | "<locati onIen>" + vialib_loc ationIen + "</locati onIen>" + | |
| 344 | "<noteTi tleIen>" + vialib_no teTitleIen + "</note TitleIen>" + | |
| 345 | "<servic eCategory> " + vialib _encodeStr ing(vialib _serviceCa tegory) + "</service Category>" + | |
| 346 | "<proced ures>" + v ialib_enco deString(v ialib_CptA rrayText) + "</proce dures>" + | |
| 347 | "<diagno ses>" + vi alib_encod eString(vi alib_Diagn osisArrayT ext) + "</ diagnoses> " + | |
| 348 | "<noteBo dy>" + via lib_encode String(via lib_noteDe scription) + "</note Body>" + | |
| 349 | "<eSig>" + vialib_ encodeStri ng(vialib_ eSignCode) + "</eSig >" + | |
| 350 | "<provid ers>" + vi alib_signi ngProvider s + "</pro viders>" + | |
| 351 | "<visitR elatedTos> " + vialib _visitRela ted + "</v isitRelate dTos>" + | |
| 352 | "</noteA ndEncounte r>" + | |
| 353 | "<queryB ean>" + | |
| 354 | "<patien t>" + "<lo calPid>" + vialib_pa tientId + "</localPi d>" + "<lo calSiteId> " + vialib _patientLo calSiteNo + "</local SiteId>" + | |
| 355 | "<inPati ent>" + vi alib_Inpat ient + "</ inPatient> " + "</pat ient>" + | |
| 356 | "<provid er>" + "<n ame>" + vi alib_encod eString(vi alib_provi derName) + "</name>" + "<login SiteCode>" + vialib_ loginSiteC ode + "</l oginSiteCo de>" + | |
| 357 | "<userId >" + viali b_encodeSt ring(viali b_Duz) + " </userId>" + "</prov ider>" + | |
| 358 | "<record SiteCode>" + vialib_ loginSiteC ode + "</r ecordSiteC ode>" + | |
| 359 | "<reques tingApp>" + vialib_e ncodeStrin g(vialib_r equestingA pp) + "</r equestingA pp>" + | |
| 360 | "<cons umingAppTo ken>" + vi alib_encod eString(vi alib_consu mingAppTok en) + "</c onsumingAp pToken>" + | |
| 361 | "<cons umingAppPa ssword>" + vialib_en codeString (vialib_co nsumingApp Password) + "</consu mingAppPas sword>" + | |
| 362 | vialib_s tartDateSt ring + | |
| 363 | "</query Bean>" + | |
| 364 | "</ser:s aveNoteAnd Encounter> " + vialib _soapHeade rEndText; | |
| 365 | ||
| 366 | // Call VIA S ervices | |
| 367 | va r vialib_s aveNoteAnd EncounterR esponse = null; | |
| 368 | $. ajax({ | |
| 369 | url: via lib_baseSe rviceEndpo intUrl + " /TiuNotesS ervice", | |
| 370 | type: "P OST", | |
| 371 | datatype : "xml", | |
| 372 | data: vi alib_soapM essage, | |
| 373 | contentT ype: "text /xml; char set=\'utf- 8'", | |
| 374 | dataType : "xml", | |
| 375 | success: function (data) { | |
| 376 | vial ib_saveNot eAndEncoun terRespons e = data; | |
| 377 | vial ib_respons eCallback( null, vial ib_saveNot eAndEncoun terRespons e, vialib_ noteText); | |
| 378 | }, | |
| 379 | error: f unction (j qXHR, text Status, er rorThrown) { | |
| 380 | //Sy stem Error | |
| 381 | vial ib_respons eCallback( textStatus , errorThr own.messag e, vialib_ noteText); | |
| 382 | }, | |
| 383 | async: t rue, | |
| 384 | cache: f alse | |
| 385 | }) ; | |
| 386 | } | |
| 387 | catch (err) { | |
| 388 | // Return fun ction erro r to callb ack functi on | |
| 389 | vi alib_respo nseCallbac k("ViaServ iceLibrary .js Functi on Error(v ialib_save NoteAndEnc ounter): " + err.mes sage, null ); | |
| 390 | } | |
| 391 | } | |
| 392 | ||
| 393 | function v ialib_getN ote(vialib _requestin gApp, vial ib_consumi ngAppToken , vialib_c onsumingAp pPassword, vialib_ba seServiceE ndpointUrl , vialib_p roviderNam e, vialib_ Duz, viali b_loginSit eCode, via lib_search NoteId, vi alib_searc hSiteId, v ialib_sear chPatientI d, vialib_ searchPati entSiteId, vialib_re sponseCall back) { | |
| 394 | //This function is used to retrieve an existin g VIA Note | |
| 395 | //vial ib_request ingApp: Th is is the VIA Applic ation Code | |
| 396 | //vial ib_consumi ngAppToken : This is the VIA Ap plication Token | |
| 397 | //vial ib_consumi ngAppPassw ord: This is the VIA Applicati on Passwor d | |
| 398 | //vial ib_baseSer viceEndpoi ntUrl: Thi st is the VIA Servic e URL | |
| 399 | //vial ib_provide rName: Thi s is the f ull VIA/Vi stA userna me as retu rned by th e loginVIA service | |
| 400 | //vial ib_Duz: Th is is the VIA sessio n/token as returned by the log inVIA serv ice | |
| 401 | //vial ib_loginSi teCode: Th is is the facility i d e.g. 516 as a text string | |
| 402 | //vial ib_searchN oteId: Thi s is the N ote Id/Ite m Id for a n existing note | |
| 403 | //vial ib_searchS iteId: Thi s is the S ite Id/rec ordSiteCod e that the note is a ssociated with | |
| 404 | //vial ib_searchP atientId: This is th e Patient Id | |
| 405 | //vial ib_searchP atientSite Id: This i s the Pati ent's loca l Site Id e.g. 613 a s a text s tring | |
| 406 | //vial ib_respons eCallback: This is t he name of the funct ion to ret urn the qu ery result to | |
| 407 | ||
| 408 | //Retu rn Values: | |
| 409 | //1. e rror text (null when no error) | |
| 410 | //2. t he VIA Ser vice data object ret urned (nul l when err or occured ) | |
| 411 | ||
| 412 | try { | |
| 413 | // Construct getNote So ap message | |
| 414 | va r vialib_s oapMessage = vialib_ soapHeader StartText + "<ser:ge tNote>" + "<queryBea n>" + | |
| 415 | "<reques tingApp>" + vialib_e ncodeStrin g(vialib_r equestingA pp) + "</r equestingA pp>" + | |
| 416 | "<cons umingAppTo ken>" + vi alib_encod eString(vi alib_consu mingAppTok en) + "</c onsumingAp pToken>" + | |
| 417 | "<cons umingAppPa ssword>" + vialib_en codeString (vialib_co nsumingApp Password) + "</consu mingAppPas sword>" + | |
| 418 | "<provid er>" + "<n ame>" + vi alib_encod eString(vi alib_provi derName) + "</name>" + "<login SiteCode>" + vialib_ loginSiteC ode + "</l oginSiteCo de>" + | |
| 419 | "<userId >" + viali b_encodeSt ring(viali b_Duz) + " </userId>" + "</prov ider>" + | |
| 420 | "<itemId >" + viali b_searchNo teId + "</ itemId>" + | |
| 421 | "<record SiteCode>" + vialib_ encodeStri ng(vialib_ searchSite Id) + "</r ecordSiteC ode>" + | |
| 422 | "<patien t>" + "<lo calPid>" + vialib_se archPatien tId + "</l ocalPid>" + "<localS iteId>" + vialib_sea rchPatient SiteId + " </localSit eId>" + "< /patient>" + | |
| 423 | "</query Bean>" + | |
| 424 | "</ser:g etNote>" + vialib_so apHeaderEn dText; | |
| 425 | ||
| 426 | // Call VIA S ervices | |
| 427 | va r vialib_n oteRespons e = null; | |
| 428 | $. ajax({ | |
| 429 | url: via lib_baseSe rviceEndpo intUrl + " /EmrServic e", | |
| 430 | type: "P OST", | |
| 431 | datatype : "xml", | |
| 432 | data: vi alib_soapM essage, | |
| 433 | contentT ype: "text /xml; char set=\'utf- 8'", | |
| 434 | dataType : "xml", | |
| 435 | success: function (data) { | |
| 436 | vial ib_noteRes ponse = da ta; | |
| 437 | vial ib_respons eCallback( null, vial ib_noteRes ponse); | |
| 438 | }, | |
| 439 | error: f unction (j qXHR, text Status, er rorThrown) { | |
| 440 | //Sy stem Error | |
| 441 | vial ib_respons eCallback( textStatus , errorThr own.messag e); | |
| 442 | }, | |
| 443 | async: t rue, | |
| 444 | cache: f alse | |
| 445 | }) ; | |
| 446 | } | |
| 447 | catch (err) { | |
| 448 | // Return fun ction erro r to callb ack functi on | |
| 449 | vi alib_respo nseCallbac k("ViaServ iceLibrary .js Functi on Error(v ialib_getN ote): " + err.messag e, null); | |
| 450 | } | |
| 451 | } | |
| 452 | ||
| 453 | function v ialib_cprs UserLookup (vialib_re questingAp p, vialib_ consumingA ppToken, v ialib_cons umingAppPa ssword, vi alib_baseS erviceEndp ointUrl, v ialib_prov iderName, vialib_Duz , vialib_l oginSiteCo de, vialib _Target, v ialib_resp onseCallba ck, vialib _externalO bject) { | |
| 454 | //This function is used to retrieve VIA Users | |
| 455 | //vial ib_request ingApp: Th is is the VIA Applic ation Code | |
| 456 | //vial ib_consumi ngAppToken : This is the VIA Ap plication Token | |
| 457 | //vial ib_consumi ngAppPassw ord: This is the VIA Applicati on Passwor d | |
| 458 | //vial ib_baseSer viceEndpoi ntUrl: Thi st is the VIA Servic e URL | |
| 459 | //vial ib_provide rName: Thi s is the f ull VIA/Vi stA userna me as retu rned by th e loginVIA service | |
| 460 | //vial ib_Duz: Th is is the VIA sessio n/token as returned by the log inVIA serv ice | |
| 461 | //vial ib_loginSi teCode: Th is is the facility i d e.g. 516 as a text string | |
| 462 | //vial ib_Target: This is t he search parameter usually co nsist of l astname, f irstname ( does parti al lastnam e search) | |
| 463 | //vial ib_respons eCallback: This is t he name of the funct ion to ret urn the qu ery result to | |
| 464 | //vial ib_externa lObject: T his is an external o bject not used by th is functio n. This ob ject can b e returned to the re sponse fun ction if n eeded | |
| 465 | ||
| 466 | //Retu rn Values: | |
| 467 | //1. e rror text (null when no error) | |
| 468 | //2. t he VIA Ser vice data object ret urned (nul l when err or occured ) | |
| 469 | //3. t he externa lObject | |
| 470 | ||
| 471 | try { | |
| 472 | // Construct cprsUserLo okup Soap message | |
| 473 | va r vialib_s oapMessage = vialib_ soapHeader StartText + "<ser:cp rsUserLook up>" + "<q ueryBean>" + | |
| 474 | "<reques tingApp>" + vialib_e ncodeStrin g(vialib_r equestingA pp) + "</r equestingA pp>" + | |
| 475 | "<cons umingAppTo ken>" + vi alib_encod eString(vi alib_consu mingAppTok en) + "</c onsumingAp pToken>" + | |
| 476 | "<cons umingAppPa ssword>" + vialib_en codeString (vialib_co nsumingApp Password) + "</consu mingAppPas sword>" + | |
| 477 | "<provid er>" + "<n ame>" + vi alib_encod eString(vi alib_provi derName) + "</name>" + "<login SiteCode>" + vialib_ loginSiteC ode + "</l oginSiteCo de>" + | |
| 478 | "<userId >" + viali b_encodeSt ring(viali b_Duz) + " </userId>" + "</prov ider>" + | |
| 479 | "<target >" + encod eXml(viali b_Target) + "</targe t>" + "</q ueryBean>" + | |
| 480 | "</ser:c prsUserLoo kup>" + vi alib_soapH eaderEndTe xt; | |
| 481 | ||
| 482 | // Call VIA S ervices | |
| 483 | va r vialib_u serlookupR esponse = null; | |
| 484 | $. ajax({ | |
| 485 | url: via lib_baseSe rviceEndpo intUrl + " /EmrServic e", | |
| 486 | type: "P OST", | |
| 487 | datatype : "xml", | |
| 488 | data: vi alib_soapM essage, | |
| 489 | contentT ype: "text /xml; char set=\'utf- 8'", | |
| 490 | dataType : "xml", | |
| 491 | success: function (data) { | |
| 492 | vial ib_userloo kupRespons e = data; | |
| 493 | vial ib_respons eCallback( null, vial ib_userloo kupRespons e, vialib_ externalOb ject); | |
| 494 | }, | |
| 495 | error: f unction (j qXHR, text Status, er rorThrown) { | |
| 496 | //Sy stem Error | |
| 497 | vial ib_respons eCallback( textStatus , errorThr own.messag e, vialib_ externalOb ject); | |
| 498 | }, | |
| 499 | async: t rue, | |
| 500 | cache: f alse | |
| 501 | }) ; | |
| 502 | } | |
| 503 | catch (err) { | |
| 504 | // Return fun ction erro r to callb ack functi on | |
| 505 | vi alib_respo nseCallbac k("ViaServ iceLibrary .js Functi on Error(v ialib_cprs UserLookup ): " + err .message, null, vial ib_externa lObject); | |
| 506 | } | |
| 507 | } | |
| 508 | ||
| 509 | function v ialib_sign Note(viali b_requesti ngApp, via lib_consum ingAppToke n, vialib_ consumingA ppPassword , vialib_b aseService EndpointUr l, vialib_ providerNa me, vialib _Duz, vial ib_loginSi teCode, vi alib_noteI EN, vialib _eSig, via lib_respon seCallback ) { | |
| 510 | //This function is used to sign an e xisting no te in Vist A/CPRS | |
| 511 | //vial ib_request ingApp: Th is is the VIA Applic ation Code | |
| 512 | //vial ib_consumi ngAppToken : This is the VIA Ap plication Token | |
| 513 | //vial ib_consumi ngAppPassw ord: This is the VIA Applicati on Passwor d | |
| 514 | //vial ib_baseSer viceEndpoi ntUrl: Thi st is the VIA Servic e URL | |
| 515 | //vial ib_provide rName: Thi s is the f ull VIA/Vi stA userna me as retu rned by th e loginVIA service | |
| 516 | //vial ib_Duz: Th is is the VIA sessio n/token as returned by the log inVIA serv ice | |
| 517 | //vial ib_loginSi teCode: Th is is the facility i d e.g. 516 as a text string | |
| 518 | //vial ib_noteIEN : This is the existi ng note id as string | |
| 519 | //vial ib_eSig: T his is the esignatur e code for the curre nt logged in user as string | |
| 520 | //vial ib_respons eCallback: This is t he name of the funct ion to ret urn the qu ery result to | |
| 521 | ||
| 522 | //Retu rn Values: | |
| 523 | //1. e rror text (null when no error) | |
| 524 | //2. t he VIA Ser vice data object ret urned (nul l when err or occured ) | |
| 525 | ||
| 526 | try { | |
| 527 | // Construct writeNote Soap messa ge | |
| 528 | va r vialib_s oapMessage = vialib_ soapHeader StartText + "<ser:si gnNote>" + | |
| 529 | "<noteIE N>" + vial ib_encodeS tring(vial ib_noteIEN ) + "</not eIEN>" + | |
| 530 | "<userDU Z>" + vial ib_encodeS tring(vial ib_Duz) + "</userDUZ >" + | |
| 531 | "<esig>" + vialib_ encodeStri ng(vialib_ eSig) + "< /esig>" + | |
| 532 | "<queryB ean>" + | |
| 533 | "<provid er>" + "<n ame>" + vi alib_encod eString(vi alib_provi derName) + "</name>" + "<login SiteCode>" + vialib_ loginSiteC ode + "</l oginSiteCo de>" + | |
| 534 | "<userId >" + viali b_encodeSt ring(viali b_Duz) + " </userId>" + "</prov ider>" + | |
| 535 | "<record SiteCode>" + vialib_ loginSiteC ode + "</r ecordSiteC ode>" + | |
| 536 | "<reques tingApp>" + vialib_e ncodeStrin g(vialib_r equestingA pp) + "</r equestingA pp>" + | |
| 537 | "<cons umingAppTo ken>" + vi alib_encod eString(vi alib_consu mingAppTok en) + "</c onsumingAp pToken>" + | |
| 538 | "<cons umingAppPa ssword>" + vialib_en codeString (vialib_co nsumingApp Password) + "</consu mingAppPas sword>" + | |
| 539 | "</query Bean>" + | |
| 540 | "</ser:s ignNote>" + vialib_s oapHeaderE ndText; | |
| 541 | ||
| 542 | // Call VIA S ervices | |
| 543 | va r vialib_s ignNoteRes ponse = nu ll; | |
| 544 | $. ajax({ | |
| 545 | url: via lib_baseSe rviceEndpo intUrl + " /EmrServic e", | |
| 546 | type: "P OST", | |
| 547 | datatype : "xml", | |
| 548 | data: vi alib_soapM essage, | |
| 549 | contentT ype: "text /xml; char set=\'utf- 8'", | |
| 550 | dataType : "xml", | |
| 551 | success: function (data) { | |
| 552 | vial ib_signNot eResponse = data; | |
| 553 | vial ib_respons eCallback( null, vial ib_signNot eResponse) ; | |
| 554 | }, | |
| 555 | error: f unction (j qXHR, text Status, er rorThrown) { | |
| 556 | //Sy stem Error | |
| 557 | vial ib_respons eCallback( textStatus , errorThr own.messag e); | |
| 558 | }, | |
| 559 | async: t rue, | |
| 560 | cache: f alse | |
| 561 | }) ; | |
| 562 | } | |
| 563 | catch (err) { | |
| 564 | // Return fun ction erro r to callb ack functi on | |
| 565 | vi alib_respo nseCallbac k("ViaServ iceLibrary .js Functi on Error(v ialib_sign Note): " + err.messa ge, null); | |
| 566 | } | |
| 567 | } | |
| 568 | ||
| 569 | function v ialib_isVa lidEsig(vi alib_reque stingApp, vialib_con sumingAppT oken, vial ib_consumi ngAppPassw ord, viali b_baseServ iceEndpoin tUrl, vial ib_provide rName, via lib_Duz, v ialib_logi nSiteCode, vialib_cr iteria, vi alib_respo nseCallbac k, vialib_ externalOb ject) { | |
| 570 | //This function is used to retrieve VIA Note T itles, use d in the N otes Write process | |
| 571 | //vial ib_request ingApp: Th is is the VIA Applic ation Code | |
| 572 | //vial ib_consumi ngAppToken : This is the VIA Ap plication Token | |
| 573 | //vial ib_consumi ngAppPassw ord: This is the VIA Applicati on Passwor d | |
| 574 | //vial ib_baseSer viceEndpoi ntUrl: Thi st is the VIA Servic e URL | |
| 575 | //vial ib_provide rName: Thi s is the f ull VIA/Vi stA userna me as retu rned by th e loginVIA service | |
| 576 | //vial ib_Duz: Th is is the VIA sessio n/token as returned by the log inVIA serv ice | |
| 577 | //vial ib_loginSi teCode: Th is is the facility i d e.g. 516 as a text string | |
| 578 | //vial ib_criteri a: This is the user- provided e Signature code to ch eck | |
| 579 | //vial ib_respons eCallback: This is t he name of the funct ion to ret urn the qu ery result to | |
| 580 | //vial ib_externa lObject: T his is an external o bject not used by th is functio n. This ob ject can b e returned to the re sponse fun ction if n eeded | |
| 581 | ||
| 582 | //Retu rn Values: | |
| 583 | //1. e rror text (null when no error) | |
| 584 | //2. t he VIA Ser vice data object ret urned (nul l when err or occured ). UserTO profile is returned, if esigna ture is va lid. | |
| 585 | //3. t he externa lObject | |
| 586 | ||
| 587 | try { | |
| 588 | // Construct getNoteTit les Soap m essage | |
| 589 | va r vialib_s oapMessage = vialib_ soapHeader StartText + | |
| 590 | "<ser:is ValidEsig> " + | |
| 591 | "<qu eryBean>" + | |
| 592 | "<requesti ngApp>" + vialib_enc odeString( vialib_req uestingApp ) + "</req uestingApp >" + | |
| 593 | "<consumin gAppToken> " + vialib _encodeStr ing(vialib _consuming AppToken) + "</consu mingAppTok en>" + | |
| 594 | "<consumin gAppPasswo rd>" + via lib_encode String(via lib_consum ingAppPass word) + "< /consuming AppPasswor d>" + | |
| 595 | "<provider >" + | |
| 596 | "<name >" + viali b_encodeSt ring(viali b_provider Name) + "< /name>" + | |
| 597 | "<logi nSiteCode> " + vialib _loginSite Code + "</ loginSiteC ode>" + | |
| 598 | "<user Id>" + via lib_encode String(via lib_Duz) + "</userId >" + | |
| 599 | "</provide r>" + | |
| 600 | "<criteria >" + encod eXml(viali b_criteria ) + "</cri teria>" + | |
| 601 | "</q ueryBean>" + | |
| 602 | "</ser:i sValidEsig >" + | |
| 603 | vialib_s oapHeaderE ndText; | |
| 604 | ||
| 605 | // Call VIA S ervices | |
| 606 | va r vialib_i sValidEsig Response = null; | |
| 607 | $. ajax({ | |
| 608 | url: via lib_baseSe rviceEndpo intUrl + " /EmrServic e", | |
| 609 | type: "P OST", | |
| 610 | datatype : "xml", | |
| 611 | data: vi alib_soapM essage, | |
| 612 | contentT ype: "text /xml; char set=\'utf- 8'", | |
| 613 | dataType : "xml", | |
| 614 | success: function (data) { | |
| 615 | vial ib_isValid EsigRespon se = data; | |
| 616 | vial ib_respons eCallback( null, vial ib_isValid EsigRespon se, vialib _externalO bject); | |
| 617 | }, | |
| 618 | error: f unction (j qXHR, text Status, er rorThrown) { | |
| 619 | //Sy stem Error | |
| 620 | vial ib_respons eCallback( textStatus , errorThr own.messag e, vialib_ externalOb ject); | |
| 621 | }, | |
| 622 | async: t rue, | |
| 623 | cache: f alse | |
| 624 | }) ; | |
| 625 | } | |
| 626 | catch (err) { | |
| 627 | // Return fun ction erro r to callb ack functi on | |
| 628 | vi alib_respo nseCallbac k("ViaServ iceLibrary .js Functi on Error(v ialib_getN oteTitles) : " + err. message, n ull, viali b_external Object); | |
| 629 | } | |
| 630 | } | |
| 631 | ||
| 632 | function v ialib_getV isits(vial ib_request ingApp, vi alib_consu mingAppTok en, vialib _consuming AppPasswor d, vialib_ baseServic eEndpointU rl, vialib _providerN ame, viali b_Duz, via lib_loginS iteCode, v ialib_sele ctPatientI d, vialib_ selectPati entSiteId, vialib_se lectPatien tMpiPid, v ialib_Dire ction, via lib_startD ate, viali b_endDate, vialib_re sponseCall back) { | |
| 633 | //This function is used to get a lis t of visit s associat ed with a patient wi thin a dat e range | |
| 634 | //vial ib_request ingApp: Th is is the VIA Applic ation Code | |
| 635 | //vial ib_consumi ngAppToken : This is the VIA Ap plication Token | |
| 636 | //vial ib_consumi ngAppPassw ord: This is the VIA Applicati on Passwor d | |
| 637 | //vial ib_baseSer viceEndpoi ntUrl: Thi st is the VIA Servic e URL | |
| 638 | //vial ib_provide rName: Thi s is the f ull VIA/Vi stA userna me as retu rned by th e loginVIA service | |
| 639 | //vial ib_Duz: Th is is the VIA sessio n/token as returned by the log inVIA serv ice | |
| 640 | //vial ib_loginSi teCode: Th is is the facility i d e.g. 516 as a text string | |
| 641 | //vial ib_selectP atientId: This is th e Patient Id | |
| 642 | //vial ib_selectP atientSite Id: This i s the Pati ent's loca l Site Id e.g. 613 a s a text s tring | |
| 643 | //vial ib_selectP atientMpiP id: This i s the Pati ent's mpiP id, retrie ved from ' VIA select service' | |
| 644 | //vial ib_Directi on: This i s the sort order 1=A SC -1=DESC | |
| 645 | //vial ib_startDa te: This i s the from date in a range for mat as yyy ymmdd | |
| 646 | //vial ib_endDate : This is the to dat e in a ran ge format as yyyymmd d | |
| 647 | //vial ib_respons eCallback: This is t he name of the funct ion to ret urn the qu ery result to | |
| 648 | ||
| 649 | //Retu rn Values: | |
| 650 | //1. e rror text (null when no error) | |
| 651 | //2. t he VIA Ser vice data object ret urned (nul l when err or occured ) | |
| 652 | ||
| 653 | try { | |
| 654 | // Construct getVisits Soap messa ge | |
| 655 | va r vialib_s oapMessage = vialib_ soapHeader StartText + "<ser:ge tVisits>" + "<queryB ean>" + | |
| 656 | "<reques tingApp>" + vialib_e ncodeStrin g(vialib_r equestingA pp) + "</r equestingA pp>" + | |
| 657 | "<cons umingAppTo ken>" + vi alib_encod eString(vi alib_consu mingAppTok en) + "</c onsumingAp pToken>" + | |
| 658 | "<cons umingAppPa ssword>" + vialib_en codeString (vialib_co nsumingApp Password) + "</consu mingAppPas sword>" + | |
| 659 | "<provid er>" + "<n ame>" + vi alib_encod eString(vi alib_provi derName) + "</name>" + "<login SiteCode>" + vialib_ loginSiteC ode + "</l oginSiteCo de>" + | |
| 660 | "<userId >" + viali b_encodeSt ring(viali b_Duz) + " </userId>" + "</prov ider>" + | |
| 661 | "<patien t>" + "<lo calPid>" + vialib_se lectPatien tId + "</l ocalPid>" + | |
| 662 | "<localS iteId>" + vialib_sel ectPatient SiteId + " </localSit eId>" + | |
| 663 | "<mpiPid >" + viali b_selectPa tientMpiPi d + "</mpi Pid>" + "< /patient>" + | |
| 664 | "<direct ion>" + vi alib_Direc tion + "</ direction> " + | |
| 665 | "<startD ate>" + vi alib_start Date + "</ startDate> " + | |
| 666 | "<endDat e>" + vial ib_endDate + "</endD ate>" + | |
| 667 | "</query Bean>" + | |
| 668 | "</ser:g etVisits>" + vialib_ soapHeader EndText; | |
| 669 | ||
| 670 | // Call VIA S ervices | |
| 671 | va r vialib_g etVisitsRe sponse = n ull; | |
| 672 | $. ajax({ | |
| 673 | url: via lib_baseSe rviceEndpo intUrl + " /EmrServic e", | |
| 674 | type: "P OST", | |
| 675 | datatype : "xml", | |
| 676 | data: vi alib_soapM essage, | |
| 677 | contentT ype: "text /xml; char set=\'utf- 8'", | |
| 678 | dataType : "xml", | |
| 679 | success: function (data) { | |
| 680 | vial ib_getVisi tsResponse = data; | |
| 681 | vial ib_respons eCallback( null, vial ib_getVisi tsResponse ); | |
| 682 | }, | |
| 683 | error: f unction (j qXHR, text Status, er rorThrown) { | |
| 684 | //Sy stem Error | |
| 685 | vial ib_respons eCallback( textStatus , errorThr own.messag e); | |
| 686 | }, | |
| 687 | async: t rue, | |
| 688 | cache: f alse | |
| 689 | }) ; | |
| 690 | } | |
| 691 | catch (err) { | |
| 692 | // Return fun ction erro r to callb ack functi on | |
| 693 | vi alib_respo nseCallbac k("ViaServ iceLibrary .js Functi on Error(v ialib_getV isits): " + err.mess age, null) ; | |
| 694 | } | |
| 695 | } | |
| 696 | ||
| 697 | function v ialib_sele ct(vialib_ requesting App, viali b_consumin gAppToken, vialib_co nsumingApp Password, vialib_bas eServiceEn dpointUrl, vialib_pr oviderName , vialib_D uz, vialib _loginSite Code, vial ib_selectP atientId, vialib_sel ectPatient SiteId, vi alib_respo nseCallbac k) { | |
| 698 | //This function is used to select th e patient specified and get a detailed P atientTO o bject | |
| 699 | //vial ib_request ingApp: Th is is the VIA Applic ation Code | |
| 700 | //vial ib_consumi ngAppToken : This is the VIA Ap plication Token | |
| 701 | //vial ib_consumi ngAppPassw ord: This is the VIA Applicati on Passwor d | |
| 702 | //vial ib_baseSer viceEndpoi ntUrl: Thi st is the VIA Servic e URL | |
| 703 | //vial ib_provide rName: Thi s is the f ull VIA/Vi stA userna me as retu rned by th e loginVIA service | |
| 704 | //vial ib_Duz: Th is is the VIA sessio n/token as returned by the log inVIA serv ice | |
| 705 | //vial ib_loginSi teCode: Th is is the facility i d e.g. 516 as a text string | |
| 706 | //vial ib_selectP atientId: This is th e Patient Id | |
| 707 | //vial ib_selectP atientSite Id: This i s the Pati ent's loca l Site Id e.g. 613 a s a text s tring | |
| 708 | //vial ib_respons eCallback: This is t he name of the funct ion to ret urn the qu ery result to | |
| 709 | ||
| 710 | //Retu rn Values: | |
| 711 | //1. e rror text (null when no error) | |
| 712 | //2. t he VIA Ser vice data object ret urned (nul l when err or occured ) | |
| 713 | ||
| 714 | try { | |
| 715 | // Construct select Soa p message | |
| 716 | va r vialib_s oapMessage = vialib_ soapHeader StartText + "<ser:se lect>" + " <queryBean >" + | |
| 717 | "<reques tingApp>" + vialib_e ncodeStrin g(vialib_r equestingA pp) + "</r equestingA pp>" + | |
| 718 | "<cons umingAppTo ken>" + vi alib_encod eString(vi alib_consu mingAppTok en) + "</c onsumingAp pToken>" + | |
| 719 | "<cons umingAppPa ssword>" + vialib_en codeString (vialib_co nsumingApp Password) + "</consu mingAppPas sword>" + | |
| 720 | "<provid er>" + "<n ame>" + vi alib_encod eString(vi alib_provi derName) + "</name>" + "<login SiteCode>" + vialib_ loginSiteC ode + "</l oginSiteCo de>" + | |
| 721 | "<userId >" + viali b_encodeSt ring(viali b_Duz) + " </userId>" + "</prov ider>" + | |
| 722 | "<patien t>" + "<lo calPid>" + vialib_se lectPatien tId + "</l ocalPid>" + "<localS iteId>" + vialib_sel ectPatient SiteId + " </localSit eId>" + "< /patient>" + | |
| 723 | "</query Bean>" + | |
| 724 | "</ser:s elect>" + vialib_soa pHeaderEnd Text; | |
| 725 | ||
| 726 | // Call VIA S ervices | |
| 727 | va r vialib_s electRespo nse = null ; | |
| 728 | $. ajax({ | |
| 729 | url: via lib_baseSe rviceEndpo intUrl + " /EmrServic e", | |
| 730 | type: "P OST", | |
| 731 | datatype : "xml", | |
| 732 | data: vi alib_soapM essage, | |
| 733 | contentT ype: "text /xml; char set=\'utf- 8'", | |
| 734 | dataType : "xml", | |
| 735 | success: function (data) { | |
| 736 | vial ib_selectR esponse = data; | |
| 737 | vial ib_respons eCallback( null, vial ib_selectR esponse); | |
| 738 | }, | |
| 739 | error: f unction (j qXHR, text Status, er rorThrown) { | |
| 740 | //Sy stem Error | |
| 741 | vial ib_respons eCallback( textStatus , errorThr own.messag e); | |
| 742 | }, | |
| 743 | async: t rue, | |
| 744 | cache: f alse | |
| 745 | }) ; | |
| 746 | } | |
| 747 | catch (err) { | |
| 748 | // Return fun ction erro r to callb ack functi on | |
| 749 | vi alib_respo nseCallbac k("ViaServ iceLibrary .js Functi on Error(v ialib_sele ct): " + e rr.message , null); | |
| 750 | } | |
| 751 | } | |
| 752 | ||
| 753 | ||
| 754 | //Related utility fu nctions | |
| 755 | function v ialib_form atTwoDigit s(vialib_n umberToFor mat) { | |
| 756 | //This function takes an i nteger and reformats it with a '0' prefi x if the v alue is le ss than 10 | |
| 757 | //vial ib_numberT oFormat is the integ er value | |
| 758 | try { | |
| 759 | va r vialib_p refixValue = "0"; | |
| 760 | if (vialib_n umberToFor mat < 10) { return ( vialib_pre fixValue + vialib_nu mberToForm at.toStrin g()); } | |
| 761 | el se { retur n vialib_n umberToFor mat.toStri ng(); } | |
| 762 | } | |
| 763 | catch (err) { | |
| 764 | // Display er ror | |
| 765 | al ert("ViaSe rviceLibra ry.js Func tion Error (vialib_fo rmatTwoDig its): " + err.messag e); | |
| 766 | re turn null; | |
| 767 | } | |
| 768 | } | |
| 769 | ||
| 770 | function v ialib_conv ertToVista DateTime(v ialib_date timeToConv ert) { | |
| 771 | //This function takes a Ja vaScript D ateTime Ob ject and r eformats i t for use as a Vista /VIA datet ime value | |
| 772 | //vial ib_datetim eToConvert : This is a JavaScri pt datetim e object e .g. (new D ate()) | |
| 773 | try { | |
| 774 | va r vialib_d ay = viali b_formatTw oDigits(vi alib_datet imeToConve rt.getDate ()); | |
| 775 | va r vialib_m onth = via lib_format TwoDigits( vialib_dat etimeToCon vert.getMo nth() + 1) ; | |
| 776 | va r vialib_y ear = (via lib_dateti meToConver t.getFullY ear() - 17 00).toStri ng(); | |
| 777 | va r vialib_h our = vial ib_formatT woDigits(v ialib_date timeToConv ert.getHou rs()); | |
| 778 | va r vialib_m inute = vi alib_forma tTwoDigits (vialib_da tetimeToCo nvert.getM inutes()); | |
| 779 | va r vialib_s econd = vi alib_forma tTwoDigits (vialib_da tetimeToCo nvert.getS econds()); | |
| 780 | va r vialib_v istaDateTi me = (vial ib_year + vialib_mon th + viali b_day + ". " + vialib _hour + vi alib_minut e + vialib _second); | |
| 781 | re turn viali b_vistaDat eTime; | |
| 782 | } | |
| 783 | catch (err) { | |
| 784 | // Display er ror | |
| 785 | al ert("ViaSe rviceLibra ry.js Func tion Error (vialib_co nvertToVis taDateTime ): " + err .message); | |
| 786 | re turn null; | |
| 787 | } | |
| 788 | } | |
| 789 | ||
| 790 | function v ialib_conv ertToStrin gDateTime( vialib_dat etimeToCon vert) { | |
| 791 | //This function takes a Ja vaScript D ateTime Ob ject and r eformats i t as a str ing date i n the form at yyyymmd d.hhmmss | |
| 792 | //vial ib_datetim eToConvert : This is a JavaScri pt datetim e object e .g. (new D ate()) | |
| 793 | try { | |
| 794 | va r vialib_d ay = viali b_formatTw oDigits(vi alib_datet imeToConve rt.getDate ()); | |
| 795 | va r vialib_m onth = via lib_format TwoDigits( vialib_dat etimeToCon vert.getMo nth() + 1) ; | |
| 796 | va r vialib_y ear = (via lib_dateti meToConver t.getFullY ear()).toS tring(); | |
| 797 | va r vialib_h our = vial ib_formatT woDigits(v ialib_date timeToConv ert.getHou rs()); | |
| 798 | va r vialib_m inute = vi alib_forma tTwoDigits (vialib_da tetimeToCo nvert.getM inutes()); | |
| 799 | va r vialib_s econd = vi alib_forma tTwoDigits (vialib_da tetimeToCo nvert.getS econds()); | |
| 800 | va r vialib_s tringDateT ime = (via lib_year + vialib_mo nth + vial ib_day + " ." + viali b_hour + v ialib_minu te + viali b_second); | |
| 801 | re turn viali b_stringDa teTime; | |
| 802 | } | |
| 803 | catch (err) { | |
| 804 | // Display er ror | |
| 805 | al ert("ViaSe rviceLibra ry.js Func tion Error (vialib_co nvertToStr ingDateTim e): " + er r.message) ; | |
| 806 | re turn null; | |
| 807 | } | |
| 808 | } | |
| 809 | ||
| 810 | function v ialib_enco deString(v ialib_unen codedStrin g) { | |
| 811 | if (vi alib_unenc odedString == undefi ned || via lib_unenco dedString == null || vialib_un encodedStr ing == '') { return ''; } | |
| 812 | //This function takes a st ring and e ncodes for use in XM L | |
| 813 | try { | |
| 814 | re turn viali b_unencode dString.re place(/&/g , '&') | |
| 815 | .repl ace(/</g, '<') | |
| 816 | .repl ace(/>/g, '>') | |
| 817 | .repl ace(/"/g, '"') | |
| 818 | .repl ace(/'/g, '''); | |
| 819 | } | |
| 820 | catch (err) { | |
| 821 | // Display Er ror | |
| 822 | al ert("ViaSe rviceLibra ry.js Func tion Error (vialib_en codeString ): " + err .message); | |
| 823 | re turn null; | |
| 824 | } | |
| 825 | } | |
| 826 | ||
| 827 | function v ialib_decr yptService Connector( vialib_con nectorArra y, vialib_ connectorV alue) { | |
| 828 | var vi alib_decry ptedString = ""; | |
| 829 | if (vi alib_conne ctorArray != null && vialib_co nnectorArr ay != "") { | |
| 830 | va r vialib_n ewArray = vialib_con nectorArra y.toString ().split(' ,'); | |
| 831 | vi alib_newAr ray.revers e(); | |
| 832 | fo r (i = 0; i < vialib _newArray. length; i+ +) { | |
| 833 | var vial ib_curChar = ""; | |
| 834 | if (i == 0) { | |
| 835 | vial ib_curChar = vialib_ newArray[i ] - vialib _connector Value; | |
| 836 | } | |
| 837 | else { | |
| 838 | vial ib_curChar = vialib_ newArray[i ] - (i + v ialib_conn ectorValue ); | |
| 839 | } | |
| 840 | vialib_d ecryptedSt ring = via lib_decryp tedString + String.f romCharCod e(vialib_c urChar); | |
| 841 | } | |
| 842 | } | |
| 843 | return vialib_de cryptedStr ing; | |
| 844 | } | |
| 845 | ||
| 846 | var xml_en code_map = { | |
| 847 | '&': ' &', | |
| 848 | '"': ' "', | |
| 849 | '<': ' <', | |
| 850 | '>': ' >', | |
| 851 | '/': ' \' | |
| 852 | }; | |
| 853 | ||
| 854 | var xml_de code_map = { | |
| 855 | '& ': '&', | |
| 856 | '" ;': '"', | |
| 857 | '<' : '<', | |
| 858 | '>' : '>', | |
| 859 | '\ ': '/' | |
| 860 | }; | |
| 861 | ||
| 862 | function e ncodeXml(s tring) { | |
| 863 | return string.re place(/([\ &"<>])/g, function ( str, item) { | |
| 864 | re turn xml_e ncode_map[ item]; | |
| 865 | }); | |
| 866 | }; | |
| 867 | ||
| 868 | function d ecodeXml(s tring) { | |
| 869 | return string.re place(/(&q uot;|<| >|& )/g, | |
| 870 | func tion (str, item) { | |
| 871 | return xml _decode_ma p[item]; | |
| 872 | }); | |
| 873 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.