Produced by Araxis Merge on 7/3/2018 11:43:46 AM 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 | eHealth_v8.2.0_build_8.2.0.1.zip\NHIN_adapter\AdapterSubscriptionServiceTesterWEB\src\main\webapp\js | appSimulator.js | Tue Jun 26 18:12:59 2018 UTC |
| 2 | eHealth_v8.2.0_build_8.2.0.1.zip\NHIN_adapter\AdapterSubscriptionServiceTesterWEB\src\main\webapp\js | appSimulator.js | Sat Jun 30 13:07:57 2018 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 16 | 1446 |
| Changed | 15 | 30 |
| Inserted | 0 | 0 |
| Removed | 1 | 1 |
| 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 | var app = angular.mo dule('subs criptionSe rviceTeste rApp', []) ; | ||
| 2 | |||
| 3 | app.config (function () { | ||
| 4 | |||
| 5 | }); | ||
| 6 | |||
| 7 | app.contro ller('cont roller', f unction ($ scope, $in terval, $t imeout, $f ilter, $el ement) { | ||
| 8 | |||
| 9 | va r mockData ; | ||
| 10 | va r nhioMax = 20; | ||
| 11 | va r enableMo ckErrors = true; | ||
| 12 | va r mockErro rSeed = 30 ; | ||
| 13 | va r wsTimeou t = 1000; | ||
| 14 | |||
| 15 | $s cope.sites = [ | ||
| 16 | {id: "98 3", name: "983/CHYSH R"}, | ||
| 17 | {id: "98 4", name: "984/DAYTS HR"}, | ||
| 18 | {id: "55 5", name: "555/FunCa stle!"} | ||
| 19 | ]; | ||
| 20 | |||
| 21 | $s cope.patie nts = [ | ||
| 22 | {id: "10126389 24V546709" , name: "N WHINONE"} , | ||
| 23 | {id: "10126389 25V204624" , name: "N WHINTWO"} , | ||
| 24 | {id: "10126640 72V817050" , name: "N WHINTHREE" } , | ||
| 25 | {id: "10126641 14V661390" , name: "N WHINFOUR"} , | ||
| 26 | {id: "10126639 18V362378" , name: "N WHINFIVE"} , | ||
| 27 | {id: "10125816 76V377802" , name: "C HDRONE"} | ||
| 28 | ]; | ||
| 29 | $s cope.pous = [ | ||
| 30 | {id: "TREATMEN T", type: "Treatment "} , | ||
| 31 | {id: "COVERAGE ", type: " Coverage"} | ||
| 32 | ]; | ||
| 33 | |||
| 34 | $s cope.site = {id:"def ault",name :"Select S ite"}; | ||
| 35 | $s cope.patie nt = {id:" default",n ame:"Selec t Patient" }; | ||
| 36 | $s cope.pou = {id:"defa ult",type: "Select Pu rpose of U se"}; | ||
| 37 | |||
| 38 | $s cope.setSi te = funct ion(site){ | ||
| 39 | $sco pe.site=si te; | ||
| 40 | $sco pe.validat eStart(); | ||
| 41 | }; | ||
| 42 | $s cope.setPa tient = fu nction(pat ient){ | ||
| 43 | $sco pe.patient =patient; | ||
| 44 | $sco pe.validat eStart(); | ||
| 45 | }; | ||
| 46 | $s cope.setPo u = functi on(pou){ | ||
| 47 | $scope .pou=pou; | ||
| 48 | $scope .validateS tart(); | ||
| 49 | }; | ||
| 50 | |||
| 51 | $s cope.subsc ribe = fun ction(){ | ||
| 52 | |||
| 53 | if( $("#subscr ibeButton" ).hasClass ('disabled ')) { | ||
| 54 | return ; | ||
| 55 | } | ||
| 56 | |||
| 57 | mo ckData = u ndefined; | ||
| 58 | |||
| 59 | $s cope.docum entReferen ces = null ; | ||
| 60 | $s cope.nhioS tatuses = null; | ||
| 61 | $s cope.subsc riptionID = null; | ||
| 62 | $s cope.subsc riptionSta tus = null ; | ||
| 63 | $s cope.lastM odified = null; | ||
| 64 | $s cope.ETag = null; | ||
| 65 | |||
| 66 | $sco pe.announc e = $("#is Announce") .is(":chec ked"); | ||
| 67 | $sco pe.autoDR = $("#isDo cRetrieve" ).is(":che cked"); | ||
| 68 | $sco pe.useWebS ocket = $( "#isWebSoc ket").is(" :checked") ; | ||
| 69 | $sco pe.cleanup UI = true; | ||
| 70 | |||
| 71 | var req = crea teInitialS ubscriptio n($scope.p atient.id, $scope.sit e.id,$scop e.pou.id,$ scope.useW ebSocket,$ scope.anno unce,$scop e.autoDR); | ||
| 72 | |||
| 73 | $s cope.subsc riptionTim e = $filte r('date')( new Date() , 'yyyy-MM -ddTHH:mm: ss', 'UTC' ) + 'Z'; | ||
| 74 | |||
| 75 | $e lement.tri gger('star tSubscript ionEvent') ; | ||
| 76 | |||
| 77 | $s cope.httpP ostSubscri ptionMock( req).then( function(r esponse){ | ||
| 78 | $scope.s ubscriptio nLocation = response .headers[' Location'] ; | ||
| 79 | $scope.m onitorSubs criptionMo ck() | ||
| 80 | }) ; | ||
| 81 | } | ||
| 82 | |||
| 83 | $s cope.monit orSubscrip tionMock = function () { | ||
| 84 | |||
| 85 | $sc ope.httpGe tSubscript ionStatusM ock($scope .subscript ionLocatio n).then(fu nction(res ponse){ | ||
| 86 | |||
| 87 | $scop e.ETag = r esponse.he aders['ETa g']; | ||
| 88 | $scope. lastModifi ed = respo nse.header s['Last-Mo dified']; | ||
| 89 | |||
| 90 | var sub scription = response .data; | ||
| 91 | var nhi oStatuses = []; | ||
| 92 | |||
| 93 | for (va r i in sub scription. extension) { | ||
| 94 | var ext = sub scription. extension[ i]; | ||
| 95 | if (ext.ur l === 'htt p:// URL /Structure Definition /EHXSubscr iption/nhi oStatus') { | ||
| 96 | var nhioS tatus = ex t.extensio n; | ||
| 97 | var o = { }; | ||
| 98 | for (var j in nhioS tatus) { | ||
| 99 | var f ield = nhi oStatus[j] ; | ||
| 100 | switc h (field.u rl) { | ||
| 101 | c ase 'hcid' : | ||
| 102 | o.hcid = field.va lueString; | ||
| 103 | break; | ||
| 104 | |||
| 105 | c ase 'statu s': | ||
| 106 | o.statu s = field. valueCode; | ||
| 107 | break; | ||
| 108 | |||
| 109 | c ase 'type' : | ||
| 110 | o.stage = field.v alueCode; | ||
| 111 | break; | ||
| 112 | |||
| 113 | d efault: | ||
| 114 | break; | ||
| 115 | } | ||
| 116 | } | ||
| 117 | nhioStatu ses.push(o ); | ||
| 118 | $element. trigger('u pdateNhioS tatusesEve nt', o); | ||
| 119 | } | ||
| 120 | } | ||
| 121 | |||
| 122 | $scope. subscripti onStatus = subscript ion.status ; | ||
| 123 | $scope. nhioStatus es = nhioS tatuses; | ||
| 124 | $scope. subscripti onID = sub scription. id; | ||
| 125 | |||
| 126 | $elemen t.trigger( 'updateSta tusEvent', | ||
| 127 | {"eta g":$scope. ETag,"last Mod":$scop e.lastModi fied, | ||
| 128 | "su bStatus":$ scope.subs criptionSt atus, "sub Id":$scope .subscript ionID}); | ||
| 129 | |||
| 130 | $scope. httpGetDoc umentInfoM ock('/Adap terSubscri ptionServi ce/FHIR/Do cumentRefe rence?pati ent=Patien t/' + $sco pe.patient .id + '&_l astUpdated =>=' + $sc ope.subscr iptionTime ).then(fun ction(resp onse){ | ||
| 131 | |||
| 132 | va r bundle = response. data; | ||
| 133 | va r document References = []; | ||
| 134 | |||
| 135 | fo r (var i i n bundle.e ntry) { | ||
| 136 | var entr y = bundle .entry[i]. resource; | ||
| 137 | var hcid = ""; | ||
| 138 | for (var j in entr y.extensio n) { | ||
| 139 | var ext = entr y.extensio n[j]; | ||
| 140 | if (ext.ur l === "htt p:// URL /Structure Definition /EHXDocume nteReferen ce/homeCom munityId") { | ||
| 141 | hcid = ext .valueStri ng; | ||
| 142 | break; | ||
| 143 | } | ||
| 144 | } | ||
| 145 | var dr = {hcid:hci d,entry:en try}; | ||
| 146 | document References .push(dr); | ||
| 147 | $element .trigger(' updateDocR efEvent', dr); | ||
| 148 | } | ||
| 149 | $scope .documentR eferences = document References ; | ||
| 150 | }); | ||
| 151 | |||
| 152 | if($sc ope.subscr iptionStat us=="activ e"){ | ||
| 153 | $timeout ($scope.mo nitorSubsc riptionMoc k, wsTimeo ut); | ||
| 154 | }else { | ||
| 155 | if($scop e.cleanupU I){ | ||
| 156 | $scope.cle anupUI=fal se; | ||
| 157 | $timeout($ scope.moni torSubscri ptionMock, 100); | ||
| 158 | } | ||
| 159 | } | ||
| 160 | }); | ||
| 161 | |||
| 162 | }; | ||
| 163 | |||
| 164 | $s cope.valid ateStart = function( ){ | ||
| 165 | if($ scope.site .id != "de fault" && $scope.pat ient.id != "default" && $scope .pou.id != "default" ){ | ||
| 166 | $("#su bscribeBut ton").remo veClass('d isabled'); | ||
| 167 | } | ||
| 168 | }; | ||
| 169 | |||
| 170 | // ********* ********** ** MOCK HT TP ******* ********** *** | ||
| 171 | $s cope.httpP ostSubscri ptionMock = function (subscript ion){ | ||
| 172 | |||
| 173 | var subId = ge tRandGUID( ); | ||
| 174 | mock Data = { | ||
| 175 | "subId" : subId, | ||
| 176 | "patId" : $scope.p atient.id, | ||
| 177 | "subscri ption":sub scription, | ||
| 178 | "extData " : [] | ||
| 179 | }; | ||
| 180 | upda teSubscrip tionAfterP ostRespons e(subscrip tion, subI d); | ||
| 181 | var response = { | ||
| 182 | "headers ":createSu bscription ResponseHe ader(subId ), | ||
| 183 | "data":s ubscriptio n | ||
| 184 | }; | ||
| 185 | retu rn new Pro mise(funct ion(resolv e, reject) { | ||
| 186 | resolv e(response ); | ||
| 187 | }); | ||
| 188 | }; | ||
| 189 | $s cope.httpG etSubscrip tionStatus Mock = fun ction(subs criptionLo cation){ | ||
| 190 | |||
| 191 | var subscripti on = mockD ata.subscr iption ; | ||
| 192 | |||
| 193 | if(s ubscriptio n["status" ]=="reques ted"){ | ||
| 194 | subscr iption["st atus"]="ac tive"; | ||
| 195 | } | ||
| 196 | |||
| 197 | var isPd = $sc ope.announ ce; | ||
| 198 | var isDr = $sc ope.autoDR ; | ||
| 199 | |||
| 200 | var subId = mo ckData.sub Id; | ||
| 201 | var subCriteri a = subscr iption.cri teria; | ||
| 202 | var pid = subC riteria.su bstring(su bCriteria. lastIndexO f('/')+1); | ||
| 203 | |||
| 204 | var urlSta tus = 'htt p:// URL /Structure Definition /EHXSubscr iption/nhi oStatus'; | ||
| 205 | |||
| 206 | if(s ubscriptio n["status" ]!="off"){ | ||
| 207 | |||
| 208 | var nh ioExtCnt = countSubN hioStatusE xt(subscri ption); | ||
| 209 | if(nhi oExtCnt < nhioMax){ | ||
| 210 | |||
| 211 | var batc hCnt = get RandInt(3) +1; | ||
| 212 | batchCnt = nhioExt Cnt + batc hCnt > nhi oMax ? nhi oMax - nhi oExtCnt : batchCnt; | ||
| 213 | |||
| 214 | for(var i=0;i<batc hCnt;i++){ | ||
| 215 | var newHci d = getRan dHCID(); | ||
| 216 | var nhioSt atusExt = createNhio StatusExte nsion(newH cid, "NEW" , "STARTIN G"); | ||
| 217 | addNhioSta tusToSubsc ription(su bscription , nhioStat usExt); | ||
| 218 | mockData.e xtData.pus h({"hcid": newHcid}); | ||
| 219 | } | ||
| 220 | nhioExtC nt = count SubNhioSta tusExt(sub scription) ; | ||
| 221 | } | ||
| 222 | |||
| 223 | var ex tAry = get SubNhioSta tusExtAry( subscripti on); | ||
| 224 | for(n in extAry) { | ||
| 225 | |||
| 226 | var stat us = getNh ioStatusEx tStatus(ex tAry[n]); | ||
| 227 | var type = getNhio StatusExtT ype(extAry [n]); | ||
| 228 | var hcid = getNhio StatusExtH cid(extAry [n]); | ||
| 229 | |||
| 230 | if(statu s=="DONE") { | ||
| 231 | var extDat aObj = get ExtDataObj ByHcid(hci d); | ||
| 232 | if(extData Obj.docRef Ary == und efined){ | ||
| 233 | va r docRefCn t = coinFl ip()=="hea ds"?1:2; | ||
| 234 | ex tDataObj.d ocRefAry = createDoc RefAry(doc RefCnt, hc id, subId, pid); | ||
| 235 | } | ||
| 236 | } else { | ||
| 237 | if(coinFli p()=="head s"){ | ||
| 238 | in crementNhi oStatusExt Type(extAr y[n],isPd, isDr,enabl eMockError s); | ||
| 239 | } | ||
| 240 | } | ||
| 241 | } | ||
| 242 | } | ||
| 243 | va r response = { | ||
| 244 | "heade rs":create Subscripti onResponse Header(sub Id), | ||
| 245 | "data" :subscript ion | ||
| 246 | }; | ||
| 247 | re turn new P romise(fun ction(reso lve, rejec t) { | ||
| 248 | reso lve(respon se); | ||
| 249 | }) ; | ||
| 250 | } | ||
| 251 | $s cope.httpG etDocument InfoMock = function( docRefUrl) { | ||
| 252 | |||
| 253 | var subscripti on = mockD ata.subscr iption ; | ||
| 254 | var pid = docR efUrl.subs tring( doc RefUrl.las tIndexOf(' /')+1, doc RefUrl.las tIndexOf(" &")); | ||
| 255 | |||
| 256 | var allDocRefA ry = [] ; | ||
| 257 | |||
| 258 | var extAry = g etSubNhioS tatusExtAr y(subscrip tion); | ||
| 259 | var processing Complete = true; | ||
| 260 | for( n in extAr y){ | ||
| 261 | |||
| 262 | var st atus = get NhioStatus ExtStatus( extAry[n]) ; | ||
| 263 | var ty pe = getNh ioStatusEx tType(extA ry[n]); | ||
| 264 | |||
| 265 | var hc id = getNh ioStatusEx tHcid(extA ry[n]); | ||
| 266 | var ex tDataObj = getExtDat aObjByHcid (hcid); | ||
| 267 | |||
| 268 | if(sta tus=="DONE "&& extDat aObj.docRe fAry !== u ndefined){ | ||
| 269 | var docR efAry = ex tDataObj.d ocRefAry; | ||
| 270 | for(var x = 0 ; x< docRefAry. length; x+ +){ | ||
| 271 | allDocRefA ry.push(do cRefAry[x] ); | ||
| 272 | } | ||
| 273 | }else{ | ||
| 274 | processi ngComplete = false; | ||
| 275 | } | ||
| 276 | } | ||
| 277 | if(p rocessingC omplete){ | ||
| 278 | subscr iption["st atus"]="of f"; | ||
| 279 | $scope .subscript ionStatus = "off"; | ||
| 280 | } | ||
| 281 | |||
| 282 | var response = { | ||
| 283 | "data" :createMoc kResourceB undle(pid, allDocRefA ry) | ||
| 284 | } ; | ||
| 285 | re turn new P romise(fun ction(reso lve, rejec t) { | ||
| 286 | reso lve(respon se); | ||
| 287 | }) ; | ||
| 288 | }; | ||
| 289 | |||
| 290 | // TODO: clea n up each loops, ret urn false to break | ||
| 291 | // ********* ********** ** MOCK UT ILS / HELP ERS ****** ********** **** | ||
| 292 | fu nction get ExtDataObj ByHcid(hci d){ | ||
| 293 | var ret = null ; | ||
| 294 | $.ea ch(mockDat a.extData, function( i, v) { | ||
| 295 | if (v. hcid == hc id) { | ||
| 296 | ret = v; | ||
| 297 | } | ||
| 298 | }); | ||
| 299 | $.De ferred(); | ||
| 300 | retu rn ret == undefined ? null : r et; | ||
| 301 | } | ||
| 302 | fu nction get SubNhioSta tusExtAry( subscripti on){ | ||
| 303 | var ary = []; | ||
| 304 | $.ea ch(subscri ption.exte nsion, fun ction(i, v ) { | ||
| 305 | if (v.url == 'http:/ / URL /Structure Definition /EHXSubscr iption/nhi oStatus') { | ||
| 306 | ary.push (v.extensi on); | ||
| 307 | } | ||
| 308 | }); | ||
| 309 | $.De ferred(); | ||
| 310 | retu rn ary; | ||
| 311 | } | ||
| 312 | fu nction cou ntSubNhioS tatusExt(s ubscriptio n){ | ||
| 313 | var nhioStatus Cnt = 0 ; | ||
| 314 | $.ea ch(subscri ption.exte nsion, fun ction(i, v ) { | ||
| 315 | if (v.url == 'http:/ / URL /Structure Definition /EHXSubscr iption/nhi oStatus') { | ||
| 316 | nhioStat usCnt++; | ||
| 317 | } | ||
| 318 | }); | ||
| 319 | $.De ferred(); | ||
| 320 | retu rn nhioSta tusCnt; | ||
| 321 | } | ||
| 322 | fu nction get NhioStatus ExtType(nh ioStatusEx t){ | ||
| 323 | retu rn getNhio StatusExt( nhioStatus Ext,"type" ,"valueCod e"); | ||
| 324 | } | ||
| 325 | fu nction get NhioStatus ExtStatus( nhioStatus Ext){ | ||
| 326 | retu rn getNhio StatusExt( nhioStatus Ext,"statu s","valueC ode"); | ||
| 327 | } | ||
| 328 | fu nction get NhioStatus ExtHcid(nh ioStatusEx t){ | ||
| 329 | retu rn getNhio StatusExt( nhioStatus Ext,"hcid" ,"valueStr ing"); | ||
| 330 | } | ||
| 331 | fu nction get NhioStatus Ext(nhioSt atusExt,ur l,field){ | ||
| 332 | var ret ; | ||
| 333 | $.ea ch(nhioSta tusExt, fu nction(x, y) { | ||
| 334 | if (y. url == url ) { | ||
| 335 | ret = y[ field]; | ||
| 336 | } | ||
| 337 | }); | ||
| 338 | $.De ferred(); | ||
| 339 | retu rn ret; | ||
| 340 | } | ||
| 341 | |||
| 342 | fu nction upd ateNhioSta tusExtType (nhioStatu sExt,val){ | ||
| 343 | upda teNhioStat usExt(nhio StatusExt, "type","va lueCode",v al) | ||
| 344 | } | ||
| 345 | fu nction upd ateNhioSta tusExtStat us(nhioSta tusExt,val ){ | ||
| 346 | upda teNhioStat usExt(nhio StatusExt, "status"," valueCode" ,val) | ||
| 347 | } | ||
| 348 | fu nction upd ateNhioSta tusExt(nhi oStatusExt ,url,field ,val){ | ||
| 349 | $.ea ch(nhioSta tusExt, fu nction(x, y) { | ||
| 350 | if (y. url == url ) { | ||
| 351 | y[field] =val; | ||
| 352 | } | ||
| 353 | }); | ||
| 354 | $.De ferred(); | ||
| 355 | } | ||
| 356 | |||
| 357 | fu nction inc rementNhio StatusExtT ype(nhioSt atusExt,is Pd,isDr,en ableErrors ){ | ||
| 358 | |||
| 359 | if(g etNhioStat usExtStatu s(nhioStat usExt)=="D ONE"){ | ||
| 360 | return ; | ||
| 361 | } | ||
| 362 | |||
| 363 | var isError = false; | ||
| 364 | if(e nableError s){ | ||
| 365 | if(get RandInt(mo ckErrorSee d)+1==1){ | ||
| 366 | isError = true; | ||
| 367 | } | ||
| 368 | } | ||
| 369 | |||
| 370 | var type = get NhioStatus ExtType(nh ioStatusEx t); | ||
| 371 | |||
| 372 | if(i sPd){ | ||
| 373 | switch (type){ | ||
| 374 | case " STARTING": | ||
| 375 | updateNh ioStatusEx tType(nhio StatusExt, "ANNOUNCE" ); | ||
| 376 | updateNh ioStatusEx tStatus(nh ioStatusEx t,"PROCESS ING"); | ||
| 377 | return ; | ||
| 378 | case " ANNOUNCE": | ||
| 379 | if(isErr or){ | ||
| 380 | updateNhio StatusExtT ype(nhioSt atusExt,"A NNOUNCE_FA ILURE"); | ||
| 381 | }else{ | ||
| 382 | updateNhio StatusExtT ype(nhioSt atusExt,"A NNOUNCE_SU CCESS"); | ||
| 383 | } | ||
| 384 | return ; | ||
| 385 | case " ANNOUNCE_F AILURE": | ||
| 386 | updateNh ioStatusEx tStatus(nh ioStatusEx t,"DONE"); | ||
| 387 | return ; | ||
| 388 | }; | ||
| 389 | } | ||
| 390 | swit ch(type){ | ||
| 391 | case "STARTING ": | ||
| 392 | case "ANNOUNCE _SUCCESS": | ||
| 393 | update NhioStatus ExtType(nh ioStatusEx t,"DOCUMEN T_QUERY"); | ||
| 394 | update NhioStatus ExtStatus( nhioStatus Ext,"PROCE SSING"); | ||
| 395 | return ; | ||
| 396 | case "DOCUMENT _QUERY": | ||
| 397 | if(isE rror){ | ||
| 398 | updateNh ioStatusEx tType(nhio StatusExt, "DOCUMENT_ QUERY_FAIL URE"); | ||
| 399 | }else{ | ||
| 400 | updateNh ioStatusEx tType(nhio StatusExt, "DOCUMENT_ QUERY_SUCC ESS"); | ||
| 401 | if(!isDr ){ | ||
| 402 | updateNhio StatusExtS tatus(nhio StatusExt, "DONE"); | ||
| 403 | } | ||
| 404 | } | ||
| 405 | return ; | ||
| 406 | case "DOCUMENT _QUERY_FAI LURE": | ||
| 407 | update NhioStatus ExtStatus( nhioStatus Ext,"DONE" ); | ||
| 408 | return ; | ||
| 409 | }; | ||
| 410 | if(i sDr){ | ||
| 411 | switch (type){ | ||
| 412 | case " DOCUMENT_Q UERY_SUCCE SS": | ||
| 413 | updateNh ioStatusEx tType(nhio StatusExt, "DOCUMENT_ RETRIEVE") ; | ||
| 414 | return ; | ||
| 415 | case " DOCUMENT_R ETRIEVE": | ||
| 416 | if(isErr or){ | ||
| 417 | updateNhio StatusExtT ype(nhioSt atusExt,"D OCUMENT_RE TRIEVE_FAI LURE"); | ||
| 418 | }else{ | ||
| 419 | updateNhio StatusExtT ype(nhioSt atusExt,"D OCUMENT_RE TRIEVE_SUC CESS"); | ||
| 420 | } | ||
| 421 | return ; | ||
| 422 | case " DOCUMENT_R ETRIEVE_SU CCESS": | ||
| 423 | case " DOCUMENT_R ETRIEVE_FA ILURE": | ||
| 424 | updateNh ioStatusEx tStatus(nh ioStatusEx t,"DONE"); | ||
| 425 | return ; | ||
| 426 | }; | ||
| 427 | } | ||
| 428 | } | ||
| 429 | fu nction inc rementNhio StatusExtT ypeX(nhioS tatusExt,i sPd,isDr,e nableError ){ | ||
| 430 | |||
| 431 | var type = get NhioStatus ExtType(nh ioStatusEx t); | ||
| 432 | |||
| 433 | if(i sPd){ | ||
| 434 | switch (type){ | ||
| 435 | case " STARTING": | ||
| 436 | updateNh ioStatusEx tType(nhio StatusExt, "ANNOUNCE" ); | ||
| 437 | updateNh ioStatusEx tStatus(nh ioStatusEx t,"PROCESS ING"); | ||
| 438 | return ; | ||
| 439 | case " ANNOUNCE": | ||
| 440 | updateNh ioStatusEx tType(nhio StatusExt, "ANNOUNCE_ SUCCESS"); | ||
| 441 | return ; | ||
| 442 | case " ANNOUNCE_F AILURE": | ||
| 443 | updateNh ioStatusEx tStatus(nh ioStatusEx t,"DONE"); | ||
| 444 | return ; | ||
| 445 | }; | ||
| 446 | } | ||
| 447 | swit ch(type){ | ||
| 448 | case "STARTING ": | ||
| 449 | case "ANNOUNCE _SUCCESS": | ||
| 450 | update NhioStatus ExtType(nh ioStatusEx t,"DOCUMEN T_QUERY"); | ||
| 451 | update NhioStatus ExtStatus( nhioStatus Ext,"PROCE SSING"); | ||
| 452 | return ; | ||
| 453 | case "DOCUMENT _QUERY": | ||
| 454 | update NhioStatus ExtType(nh ioStatusEx t,"DOCUMEN T_QUERY_SU CCESS"); | ||
| 455 | if(!is Dr){ | ||
| 456 | updateNh ioStatusEx tStatus(nh ioStatusEx t,"DONE"); | ||
| 457 | } | ||
| 458 | return ; | ||
| 459 | case "DOCUMENT _QUERY_FAI LURE": | ||
| 460 | update NhioStatus ExtStatus( nhioStatus Ext,"DONE" ); | ||
| 461 | return ; | ||
| 462 | }; | ||
| 463 | if(i sDr){ | ||
| 464 | switch (type){ | ||
| 465 | case " DOCUMENT_Q UERY_SUCCE SS": | ||
| 466 | updateNh ioStatusEx tType(nhio StatusExt, "DOCUMENT_ RETRIEVE") ; | ||
| 467 | return ; | ||
| 468 | case " DOCUMENT_R ETRIEVE": | ||
| 469 | updateNh ioStatusEx tType(nhio StatusExt, "DOCUMENT_ RETRIEVE_S UCCESS"); | ||
| 470 | updateNh ioStatusEx tStatus(nh ioStatusEx t,"DONE"); | ||
| 471 | return ; | ||
| 472 | case " DOCUMENT_R ETRIEVE_FA ILURE": | ||
| 473 | updateNh ioStatusEx tStatus(nh ioStatusEx t,"DONE"); | ||
| 474 | return ; | ||
| 475 | }; | ||
| 476 | } | ||
| 477 | } | ||
| 478 | |||
| 479 | fu nction upd ateSubscri ptionAfter PostRespon se(subscri ption, sub Id){ | ||
| 480 | dele te subscri ption.chan nel["endpo int"]; | ||
| 481 | dele te subscri ption.chan nel["heade r"]; | ||
| 482 | dele te subscri ption.chan nel["paylo ad"]; | ||
| 483 | dele te subscri ption["con tact"]; | ||
| 484 | dele te subscri ption["end "]; | ||
| 485 | subs cription[" id"] = sub Id; | ||
| 486 | subscripti on["meta"] = createM etadata("h ttp:// URL /Structure Definition /EHXSubscr iption"); | ||
| 487 | } | ||
| 488 | fu nction add NhioStatus ToSubscrip tion(subsc ription, n hioStatus) { | ||
| 489 | subs cription.e xtension.p ush(nhioSt atus); | ||
| 490 | } | ||
| 491 | |||
| 492 | // ********* ********** ** MOCK SE TUP ****** ********** **** | ||
| 493 | fu nction cre ateMockRes ourceBundl e(pid,docR efAry){ | ||
| 494 | var timestamp = getTimes tamp(); | ||
| 495 | var lastUpdate dEnc = enc odeURIComp onent(time stamp); | ||
| 496 | var pidEnc = e ncodeURICo mponent("/ "+pid); | ||
| 497 | var bundleData = { | ||
| 498 | "entry": docRefAry, | ||
| 499 | "id": ge tRandGUID( ), | ||
| 500 | "link": [ | ||
| 501 | { | ||
| 502 | "r elation": "self", | ||
| 503 | "u rl": "http ://localho st:7001/Ad apterSubsc riptionSer vice/FHIR/ DocumentRe ference?_l astUpdated =" + lastU pdatedEnc + "&patien t=Patient" + pidEnc | ||
| 504 | } | ||
| 505 | ], | ||
| 506 | "meta": { | ||
| 507 | "l astUpdated ": timesta mp | ||
| 508 | }, | ||
| 509 | "resourceT ype": "Bun dle", | ||
| 510 | "total": d ocRefAry.l ength, | ||
| 511 | "type": "s earchset" | ||
| 512 | } ; | ||
| 513 | retu rn bundleD ata; | ||
| 514 | } | ||
| 515 | fu nction cre ateDocRefA ry(drCnt, xHcid, sub Id, patId) { | ||
| 516 | var code = "34 133-9"; | ||
| 517 | var display = "Summariza tion Of Ep isode" ; | ||
| 518 | var sysId = "u rn:oid:1.3 .6.1.4.1.1 9376.1.2.3 "; | ||
| 519 | var docRefAry = [ ]; | ||
| 520 | |||
| 521 | for( var i=0;i< drCnt;i++) { | ||
| 522 | var do cRefId = g etRandGUID (); | ||
| 523 | var do cUniqueId = getRandG UID(); | ||
| 524 | var do cRef = cre ateDocumen tReference Entry(xHci d, subId, patId, doc RefId, doc UniqueId, sysId, cod e, display , getTimes tamp()); | ||
| 525 | docRef Ary.push(d ocRef); | ||
| 526 | } | ||
| 527 | retu rn docRefA ry; | ||
| 528 | } | ||
| 529 | fu nction cre ateInitial Subscripti on(pid,sit eId,pouID, useWs,isAn nounce,isA utoDR){ | ||
| 530 | |||
| 531 | var req = { | ||
| 532 | resource Type: "Sub scription" , | ||
| 533 | // from Resource: id, meta, implicitRu les, and l anguage | ||
| 534 | // from DomainReso urce: text , containe d, extensi on, and mo difierExte nsion | ||
| 535 | status: "requested ", // R! requested | active | error | o ff | ||
| 536 | contact: [], // Co ntact deta ils for so urce (e.g. troublesh ooting) | ||
| 537 | end: nul l, // When to automa tically de lete the s ubscriptio n | ||
| 538 | reason: "Prefetch" , // R! D escription of why th is subscri ption was created | ||
| 539 | criteria : "Documen tReference ?patient=P atient/" + pid, // R ! Rule fo r server p ush criter ia | ||
| 540 | error: " <string>", // Latest error not e | ||
| 541 | channel: {// R! T he channel on which to report matches to the crite ria | ||
| 542 | type: useW s ? "webso cket" : "r est-hook", // R! re st-hook | websocket | email | sms | mess age | ||
| 543 | endp oint: !use Ws ? "http ://MOCK-HO ST:8090/on -notify" : null, // Where the channel po ints to | ||
| 544 | payload: null, // Mimetype t o send, or omit for no payload | ||
| 545 | header: !useWs ? [ "X-Transac tionID: DA S-09876543 21"] : nul l // Usage depends o n the chan nel type | ||
| 546 | }, | ||
| 547 | extensio n: [{ | ||
| 548 | url: "http :// URL /Structure Definition /EHXSubscr iption/ann ouncePatie nt", | ||
| 549 | valueBoole an: isAnno unce | ||
| 550 | }, { | ||
| 551 | url: "http :// URL /Structure Definition /EHXSubscr iption/aut oDocRetrie ve", | ||
| 552 | valueBoole an: isAuto DR | ||
| 553 | }, { | ||
| 554 | url: "http :// URL /Structure Definition /EHXSubscr iption/ass ertions", | ||
| 555 | extension: [{ | ||
| 556 | ur l: "userID ", | ||
| 557 | va lueString: siteId + ":user123" | ||
| 558 | }, { | ||
| 559 | ur l: "userNa me", | ||
| 560 | va lueString: "User 1-2 -3" | ||
| 561 | }, { | ||
| 562 | ur l: "system ID", | ||
| 563 | va lueString: "JLV" | ||
| 564 | }, { | ||
| 565 | ur l: "organi zationID", | ||
| 566 | va lueString: "2.16.840 .1.113883. 4.349.983" | ||
| 567 | }, { | ||
| 568 | ur l: "organi zationName ", | ||
| 569 | va lueString: "Departme nt of Vete rans Affai rs - CHYSH R" | ||
| 570 | }, { | ||
| 571 | ur l: "purpos eOfUse", | ||
| 572 | va lueString: pouID | ||
| 573 | }, { | ||
| 574 | ur l: "role", | ||
| 575 | va lueString: "11224700 3" | ||
| 576 | }] | ||
| 577 | }] | ||
| 578 | }; | ||
| 579 | retu rn req; | ||
| 580 | } | ||
| 581 | fu nction cre ateNhioSta tusExtensi on(hcid, s tatus, sta ge){ | ||
| 582 | var nhioStatus = { | ||
| 583 | "extensi on": [ | ||
| 584 | { | ||
| 585 | "u rl": "hcid ", | ||
| 586 | "v alueString ": hcid | ||
| 587 | }, | ||
| 588 | { | ||
| 589 | "u rl": "stat us", | ||
| 590 | "v alueCode": status | ||
| 591 | }, | ||
| 592 | { | ||
| 593 | "u rl": "type ", | ||
| 594 | "v alueCode": stage | ||
| 595 | } | ||
| 596 | ], | ||
| 597 | "url": "ht tp:// URL /Structure Definition /EHXSubscr iption/nhi oStatus" | ||
| 598 | } ; | ||
| 599 | retu rn nhioSta tus; | ||
| 600 | } | ||
| 601 | fu nction cre ateDocumen tReference Entry(hcid , subscrip tionId, pa tientId, d ocRefId, d ocUniqueId , systemId , codingCl s, codingD isplay, la stUpdated) { | ||
| 602 | |||
| 603 | var mockCoding = [{ | ||
| 604 | "code" : codingCl s, | ||
| 605 | "displ ay": codin gDisplay, | ||
| 606 | "syste m": "http: //loinc.or g" | ||
| 607 | }]; | ||
| 608 | var mockConten t = [{ | ||
| 609 | "attac hment": { | ||
| 610 | "content Type": "te xt/xml", | ||
| 611 | "hash": getRandomH ash(), | ||
| 612 | "languag e": "en-US ", | ||
| 613 | "size": getRandomF ileSize(), | ||
| 614 | "url": " Binary/" + docRefId | ||
| 615 | }, | ||
| 616 | "forma t": { | ||
| 617 | "code": "urn:ihe:p cc:xphr:20 07", | ||
| 618 | "display ": "HL7 CC D Document ", | ||
| 619 | "system" : systemId | ||
| 620 | } | ||
| 621 | } ]; | ||
| 622 | var mockExt = [ | ||
| 623 | { | ||
| 624 | "url": "ht tp:// URL /Structure Definition /EHXDocume nteReferen ce/homeCom munityId", | ||
| 625 | "valueSt ring": hci d | ||
| 626 | }, | ||
| 627 | { | ||
| 628 | "url": "ht tp:// URL /Structure Definition /EHXDocume nteReferen ce/reposit oryUniqueI d", | ||
| 629 | "valueSt ring": hci d.substrin g(hcid.ind exOf("oid: ")+4) | ||
| 630 | }, | ||
| 631 | { | ||
| 632 | "url": "ht tp:// URL /Structure Definition /EHXDocume nteReferen ce/documen tUniqueId" , | ||
| 633 | "valueSt ring": doc UniqueId | ||
| 634 | }, | ||
| 635 | { | ||
| 636 | "url": "ht tp:// URL /Structure Definition /EHXDocume nteReferen ce/subscri ption", | ||
| 637 | "valueRe ference": { | ||
| 638 | "reference ": "Subscr iption/" + subscript ionId | ||
| 639 | } | ||
| 640 | } | ||
| 641 | ]; | ||
| 642 | var mockMaster ID = {"val ue": docUn iqueId} ; | ||
| 643 | var mockSub = { "referen ce": "Pati ent/" + pa tientId} ; | ||
| 644 | var mockRsc = { "class": { "coding " : mockCo ding}, | ||
| 645 | "content ": mockCon tent, | ||
| 646 | "created ": "2017-0 1-01T20:31 :36-04:00" , | ||
| 647 | "descrip tion": "Su mmarizatio n Of Episo de", | ||
| 648 | "extensi on": mockE xt, | ||
| 649 | "id": do cRefId, | ||
| 650 | "masterI dentifier" : mockMast erID, | ||
| 651 | "meta": cr eateMetada ta("http:/ / URL /Structure Definition /EHXDocume ntReferenc e"), | ||
| 652 | "resourc eType": "D ocumentRef erence", | ||
| 653 | "subject ":mockSub, | ||
| 654 | "type": { "coding" : mockCod ing} | ||
| 655 | } ; | ||
| 656 | var mockEntry = { | ||
| 657 | "fullUrl ": "http:/ /localhost :7001/Adap terSubscri ptionServi ce/FHIR/Do cumentRefe rence/" + docRefId, | ||
| 658 | "resourc e" : mockR sc | ||
| 659 | } ; | ||
| 660 | retu rn mockEnt ry ; | ||
| 661 | } | ||
| 662 | fu nction cre ateMetadat a(url){ | ||
| 663 | var mockMeta = { | ||
| 664 | "lastUpd ated": get Timestamp( ), | ||
| 665 | "profile ": [ | ||
| 666 | url | ||
| 667 | ], | ||
| 668 | "versionId ": "0" | ||
| 669 | } ; | ||
| 670 | retu rn mockMet a; | ||
| 671 | } | ||
| 672 | fu nction cre ateSubscri ptionRespo nseHeader( subId){ | ||
| 673 | var header = { | ||
| 674 | 'ETag':' W/"0"', | ||
| 675 | "Last-Mo dified":ge tTimestamp (), | ||
| 676 | "Locatio n":"http:/ /localhost :7001/Adap terSubscri ptionServi ce/FHIR/Su bscription "+subId, | ||
| 677 | 'If-None -Match':'W /"149"' | ||
| 678 | }; | ||
| 679 | retu rn header; | ||
| 680 | } | ||
| 681 | |||
| 682 | // ********* ****** UTI LS / HELPE RS ******* ******** | ||
| 683 | fu nction get Timestamp( ){ | ||
| 684 | retu rn new Dat e().toISOS tring(); | ||
| 685 | } | ||
| 686 | fu nction get RandAryEle ment(ary){ | ||
| 687 | var randomIdx = Math.flo or(Math.ra ndom() * a ry.length) ; | ||
| 688 | retu rn ary[ran domIdx]; | ||
| 689 | } | ||
| 690 | fu nction get RandomFile Size(){ | ||
| 691 | retu rn Math.fl oor(Math.r andom() * 5000)+5000 ; | ||
| 692 | } | ||
| 693 | fu nction get RandSysID( ){ | ||
| 694 | var r = Math.f loor((1 + Math.rando m()) * 0x1 0000) | ||
| 695 | .toS tring(16) | ||
| 696 | .sub string(0,5 ); | ||
| 697 | retu rn "urn:oi d:1.3.6.1. 4.1." + r + ".1.2.3" ; | ||
| 698 | } | ||
| 699 | fu nction get RandHCID() { | ||
| 700 | var r = Math.f loor((1 + Math.rando m()) * 0x1 0000) | ||
| 701 | .toS tring(16) | ||
| 702 | .sub string(0,5 ); | ||
| 703 | retu rn "urn:oi d:2.16.840 .1.11." + r + ".17.8 .1"; | ||
| 704 | } | ||
| 705 | fu nction get RandGUID() { | ||
| 706 | func tion s4() { | ||
| 707 | return Math.floo r((1 + Mat h.random() ) * 0x1000 0) | ||
| 708 | .toStr ing(16) | ||
| 709 | .subst ring(1); | ||
| 710 | } | ||
| 711 | retu rn s4() + s4() + '-' + s4() + '-' + s4() + '-' + | ||
| 712 | s4() + '-' + s 4() + s4() + s4(); | ||
| 713 | } | ||
| 714 | fu nction get RandomHash () { | ||
| 715 | var text = ""; | ||
| 716 | var possible = "ABCDEFGH IJKLMNOPQR STUVWXYZab cdefghijkl mnopqrstuv wxyz012345 6789"; | ||
| 717 | |||
| 718 | for (var i = 0 ; i < 54; i++) | ||
| 719 | text + = possible .charAt(Ma th.floor(M ath.random () * possi ble.length )); | ||
| 720 | |||
| 721 | retu rn text+"= ="; | ||
| 722 | } | ||
| 723 | fu nction coi nFlip(){ | ||
| 724 | retu rn getRand Int(2)==0? "heads":"t ails"; | ||
| 725 | } | ||
| 726 | fu nction get RandInt(ma x){ | ||
| 727 | retu rn Math.fl oor(Math.r andom() * Math.floor (max)); | ||
| 728 | } | ||
| 729 | |||
| 730 | fu nction pri ntj(data){ | ||
| 731 | cons ole.log(JS ON.stringi fy(data,nu ll,"\t")); | ||
| 732 | } | ||
| 733 | }); | ||
| 734 | |||
| 735 | |||
| 736 | |||
| 737 | |||
| 738 | |||
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.