Produced by Araxis Merge on 10/3/2017 11:16:02 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 | ehmp.zip\ehmp\ehmp\product\production\vx-sync\tests\integrationtests\handlers\store-record-request | store-record-request-handler-itest-spec.js | Tue Jan 10 16:20:50 2017 UTC |
| 2 | ehmp.zip\ehmp\ehmp\product\production\vx-sync\tests\integrationtests\handlers\store-record-request | store-record-request-handler-itest-spec.js | Tue Oct 3 12:53:16 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 3 | 930 |
| Changed | 2 | 8 |
| Inserted | 0 | 0 |
| Removed | 0 | 0 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | 'use stric t'; | |
| 2 | ||
| 3 | require('. ./../../.. /env-setup '); | |
| 4 | ||
| 5 | var _ = re quire('und erscore'); | |
| 6 | var handle = require (global.VX _HANDLERS + 'store-r ecord-requ est/store- record-req uest-handl er'); | |
| 7 | var JdsCli ent = requ ire(global .VX_SUBSYS TEMS + 'jd s/jds-clie nt'); | |
| 8 | var wConfi g = requir e(global.V X_ROOT + ' worker-con fig'); | |
| 9 | var val = require(gl obal.VX_UT ILS + 'obj ect-utils' ).getPrope rty; | |
| 10 | ||
| 11 | var log = require(gl obal.VX_DU MMIES + 'd ummy-logge r'); | |
| 12 | // log = r equire('bu nyan').cre ateLogger( { | |
| 13 | // nam e: 'store- record-req uest-handl er', | |
| 14 | // lev el: 'debug ' | |
| 15 | // }); | |
| 16 | ||
| 17 | describe(' store-reco rd-request -handler.j s', functi on() { | |
| 18 | ||
| 19 | var se tUpconfig = { | |
| 20 | jd s: _.defau lts(wConfi g.jds, { | |
| 21 | protocol : 'http', | |
| 22 | host: ' IP ', | |
| 23 | port: PORT | |
| 24 | }) | |
| 25 | }; | |
| 26 | ||
| 27 | var se tUpEnviron ment = { | |
| 28 | jd s: new Jds Client(log , log, set Upconfig), | |
| 29 | }; | |
| 30 | ||
| 31 | var se tupForTest = functio n(testPati entIdentif ier, metas tampToStor e) { | |
| 32 | va r deleteFi nished, st orePatient Finished, syncStatus Finished = false; | |
| 33 | ||
| 34 | va r testPid = testPati entIdentif ier.value; | |
| 35 | ||
| 36 | va r identifi erToStore = { | |
| 37 | 'patient Identifier s': [testP id] | |
| 38 | }; | |
| 39 | ||
| 40 | ru ns(functio n() { | |
| 41 | setUpEnv ironment.j ds.deleteP atientByPi d(testPid, function( ) { | |
| 42 | dele teFinished = true; | |
| 43 | }); | |
| 44 | }) ; | |
| 45 | wa itsFor(fun ction() { | |
| 46 | return d eleteFinis hed; | |
| 47 | }) ; | |
| 48 | ru ns(functio n() { | |
| 49 | setUpEnv ironment.j ds.storePa tientIdent ifier(iden tifierToSt ore, funct ion(error, response) { | |
| 50 | expe ct(error). toBeFalsy( ); | |
| 51 | expe ct(respons e).toBeTru thy(); | |
| 52 | expe ct(val(res ponse, 'st atusCode') ).toEqual( 201); | |
| 53 | stor ePatientFi nished = t rue; | |
| 54 | }); | |
| 55 | }) ; | |
| 56 | wa itsFor(fun ction() { | |
| 57 | return s torePatien tFinished; | |
| 58 | }) ; | |
| 59 | ru ns(functio n() { | |
| 60 | setUpEnv ironment.j ds.saveSyn cStatus(me tastampToS tore, test PatientIde ntifier, f unction(er ror, respo nse) { | |
| 61 | expe ct(error). toBeFalsy( ); | |
| 62 | expe ct(val(res ponse, 'st atusCode') ).toBe(200 ); | |
| 63 | sync StatusFini shed = tru e; | |
| 64 | }); | |
| 65 | }) ; | |
| 66 | wa itsFor(fun ction() { | |
| 67 | return s yncStatusF inished; | |
| 68 | }) ; | |
| 69 | }; | |
| 70 | ||
| 71 | var te arDownAfte rTest = fu nction(tes tPatientId entifier) { | |
| 72 | va r cleanUpF inished = false; | |
| 73 | ru ns(functio n() { | |
| 74 | setUpEnv ironment.j ds.deleteP atientByPi d(testPati entIdentif ier.value, function( ) { | |
| 75 | clea nUpFinishe d = true; | |
| 76 | }); | |
| 77 | }) ; | |
| 78 | wa itsFor(fun ction() { | |
| 79 | return c leanUpFini shed; | |
| 80 | }) ; | |
| 81 | }; | |
| 82 | ||
| 83 | descri be('handle ()', funct ion() { | |
| 84 | ||
| 85 | va r config = { | |
| 86 | jds: _.d efaults(wC onfig.jds, { | |
| 87 | prot ocol: 'htt p', | |
| 88 | host: ' IP ', | |
| 89 | port: PORT | |
| 90 | }) | |
| 91 | }; | |
| 92 | ||
| 93 | it ('handles a store-re cord-reque st job', f unction() { | |
| 94 | ||
| 95 | var reco rdUid = 'u rn:va:alle rgy:9E7A:1 23456:0654 321'; | |
| 96 | var alle rgyMetaSta mp = { | |
| 97 | 'icn ': '9E7A;1 23456', | |
| 98 | 'sta mpTime': ' 2015011913 5618', | |
| 99 | 'sou rceMetaSta mp': { | |
| 100 | '9E7A': { | |
| 101 | 'pid': '9E7A;123 456', | |
| 102 | 'local Id': '1234 56', | |
| 103 | 'stamp Time': '20 1501191356 18', | |
| 104 | 'domai nMetaStamp ': { | |
| 105 | 'a llergy': { | |
| 106 | 'domain' : 'allergy ', | |
| 107 | 'stampTi me': '2015 0119135618 ', | |
| 108 | 'eventMe taStamp': { | |
| 109 | 'urn :va:allerg y:9E7A:123 456:065432 1': { | |
| 110 | 'stampTime ': '201501 19135618' | |
| 111 | } | |
| 112 | } | |
| 113 | } | |
| 114 | } | |
| 115 | } | |
| 116 | } | |
| 117 | }; | |
| 118 | var alle rgyRecord = { | |
| 119 | ente red: '2007 12171513', | |
| 120 | faci lityCode: '500', | |
| 121 | faci lityName: 'CAMP MAST ER', | |
| 122 | hist orical: tr ue, | |
| 123 | kind : 'Allergy /Adverse R eaction', | |
| 124 | last UpdateTime : 20150119 135618, | |
| 125 | loca lId: '874' , | |
| 126 | mech anism: 'AL LERGY', | |
| 127 | orig inatorName : 'PROVIDE R,ONE', | |
| 128 | prod ucts: ['CH OCOLATE'], | |
| 129 | reac tions: ['D IARRHEA'], | |
| 130 | refe rence: '3; GMRD(120.8 2,', | |
| 131 | stam pTime: 201 5011913561 8, | |
| 132 | summ ary: 'CHOC OLATE', | |
| 133 | type Name: 'DRU G, FOOD', | |
| 134 | uid: recordUid , | |
| 135 | veri fied: '200 7121715135 4', | |
| 136 | veri fierName: '<auto-ver ified>', | |
| 137 | pid: '9E7A;123 456', | |
| 138 | code sCode: ['C 0008299'], | |
| 139 | code sSystem: [ 'urn:oid:2 .16.840.1. 113883.6.8 6'], | |
| 140 | code sDisplay: ['Chocolat e'], | |
| 141 | drug Classes: [ ], | |
| 142 | comm ents: [] | |
| 143 | }; | |
| 144 | ||
| 145 | var pati entIdentif ier = { | |
| 146 | 'typ e': 'pid', | |
| 147 | 'val ue': '9E7A ;123456' | |
| 148 | }; | |
| 149 | ||
| 150 | var stor ageJob = { | |
| 151 | 'pat ientIdenti fier': pat ientIdenti fier, | |
| 152 | 'rec ord': alle rgyRecord, | |
| 153 | 'jpi d': '21EC2 020-3AEA-4 069-A2DD-0 8002B30309 D', | |
| 154 | 'typ e': 'store -record-re quest' | |
| 155 | }; | |
| 156 | ||
| 157 | setupFor Test(patie ntIdentifi er, allerg yMetaStamp ); | |
| 158 | ||
| 159 | var jdsC lient = ne w JdsClien t(log, log , config); | |
| 160 | var envi ronment = { | |
| 161 | jds: jdsClient , | |
| 162 | publ isherRoute r: { | |
| 163 | publish: f unction(jo b, callbac k) { | |
| 164 | callba ck(); | |
| 165 | } | |
| 166 | }, | |
| 167 | metr ics: log, | |
| 168 | solr : { | |
| 169 | add: funct ion(record , callback ) { | |
| 170 | callba ck(); | |
| 171 | } | |
| 172 | } | |
| 173 | }; | |
| 174 | ||
| 175 | var fini shed = fal se; | |
| 176 | runs(fun ction() { | |
| 177 | hand le(log, co nfig, envi ronment, s torageJob, function( error, res ult) { | |
| 178 | expect(err or).toBeNu ll(); | |
| 179 | expect(res ult).toEqu al('succes s'); | |
| 180 | finished = true; | |
| 181 | }, f unction() {}); | |
| 182 | }); | |
| 183 | ||
| 184 | waitsFor (function( ) { | |
| 185 | retu rn finishe d; | |
| 186 | }); | |
| 187 | ||
| 188 | var fini shed2 = fa lse; | |
| 189 | //Verify record wa s actually stored | |
| 190 | runs(fun ction() { | |
| 191 | jdsC lient.getP atientData ByUid(reco rdUid, fun ction(erro r, respons e) { | |
| 192 | expect(val (response, 'statusCo de')).toEq ual(200); | |
| 193 | finished2 = true; | |
| 194 | }); | |
| 195 | }); | |
| 196 | waitsFor (function( ) { | |
| 197 | retu rn finishe d2; | |
| 198 | }); | |
| 199 | ||
| 200 | var fini shed4 = fa lse; | |
| 201 | //Verify record wa s marked a s stored i n metastam p | |
| 202 | runs(fun ction() { | |
| 203 | jdsC lient.getS yncStatus( patientIde ntifier, f unction(er ror, respo nse, resul t) { | |
| 204 | expect(val (response, 'statusCo de')).toEq ual(200); | |
| 205 | expect(val (result, ' completedS tamp')).to BeTruthy() ; | |
| 206 | expect(val (result, ' inProgress ')).toBeFa lsy(); | |
| 207 | finished4 = true; | |
| 208 | }); | |
| 209 | }); | |
| 210 | waitsFor (function( ) { | |
| 211 | retu rn finishe d4; | |
| 212 | }); | |
| 213 | ||
| 214 | var fini shed3 = fa lse; | |
| 215 | //Clean up the rec ord | |
| 216 | runs(fun ction() { | |
| 217 | jdsC lient.dele tePatientD ataByUid(r ecordUid, function(e rror, resp onse) { | |
| 218 | expect(val (response, 'statusCo de')).toEq ual(200); | |
| 219 | finished3 = true; | |
| 220 | }); | |
| 221 | }); | |
| 222 | waitsFor (function( ) { | |
| 223 | retu rn finishe d3; | |
| 224 | }); | |
| 225 | ||
| 226 | tearDown AfterTest( patientIde ntifier); | |
| 227 | }) ; | |
| 228 | ||
| 229 | it ('handles an unsolic ited updat e marking a record a s deleted' , function () { | |
| 230 | ||
| 231 | var reco rdUid = 'u rn:va:alle rgy:WXYZ:1 23456:0654 321'; | |
| 232 | var alle rgyMetaSta mp = { | |
| 233 | 'icn ': 'WXYZ;1 23456', | |
| 234 | 'sta mpTime': ' 2015011913 5618', | |
| 235 | 'sou rceMetaSta mp': { | |
| 236 | 'WXYZ': { | |
| 237 | 'pid': 'WXYZ;123 456', | |
| 238 | 'local Id': '1234 56', | |
| 239 | 'stamp Time': '20 1501191356 18', | |
| 240 | 'domai nMetaStamp ': { | |
| 241 | 'a llergy': { | |
| 242 | 'domain' : 'allergy ', | |
| 243 | 'stampTi me': '2015 0119135618 ', | |
| 244 | 'eventMe taStamp': { | |
| 245 | 'urn :va:allerg y:WXYZ:123 456:065432 1': { | |
| 246 | 'stampTime ': '201501 19135618' | |
| 247 | } | |
| 248 | } | |
| 249 | } | |
| 250 | } | |
| 251 | } | |
| 252 | } | |
| 253 | }; | |
| 254 | var alle rgyRecord = { | |
| 255 | ente red: '2007 12171513', | |
| 256 | faci lityCode: '500', | |
| 257 | faci lityName: 'CAMP MAST ER', | |
| 258 | hist orical: tr ue, | |
| 259 | kind : 'Allergy /Adverse R eaction', | |
| 260 | last UpdateTime : 20150119 135618, | |
| 261 | loca lId: '874' , | |
| 262 | mech anism: 'AL LERGY', | |
| 263 | orig inatorName : 'PROVIDE R,ONE', | |
| 264 | prod ucts: ['CH OCOLATE'], | |
| 265 | reac tions: ['D IARRHEA'], | |
| 266 | refe rence: '3; GMRD(120.8 2,', | |
| 267 | stam pTime: 201 5011913561 8, | |
| 268 | summ ary: 'CHOC OLATE', | |
| 269 | type Name: 'DRU G, FOOD', | |
| 270 | uid: recordUid , | |
| 271 | veri fied: '200 7121715135 4', | |
| 272 | veri fierName: '<auto-ver ified>', | |
| 273 | pid: 'WXYZ;123 456', | |
| 274 | code sCode: ['C 0008299'], | |
| 275 | code sSystem: [ 'urn:oid:2 .16.840.1. 113883.6.8 6'], | |
| 276 | code sDisplay: ['Chocolat e'], | |
| 277 | drug Classes: [ ], | |
| 278 | comm ents: [] | |
| 279 | }; | |
| 280 | ||
| 281 | var pati entIdentif ier = { | |
| 282 | 'typ e': 'pid', | |
| 283 | 'val ue': 'WXYZ ;123456' | |
| 284 | }; | |
| 285 | ||
| 286 | var stor ageJob = { | |
| 287 | 'pat ientIdenti fier': pat ientIdenti fier, | |
| 288 | 'rec ord': alle rgyRecord, | |
| 289 | 'jpi d': '21EC2 020-3AEA-4 069-A2DD-0 8002B30309 D', | |
| 290 | 'typ e': 'store -record-re quest' | |
| 291 | }; | |
| 292 | ||
| 293 | setupFor Test(patie ntIdentifi er, allerg yMetaStamp ); | |
| 294 | var jdsC lient = ne w JdsClien t(log, log , config); | |
| 295 | var envi ronment = { | |
| 296 | jds: jdsClient , | |
| 297 | publ isherRoute r: { | |
| 298 | publish: f unction(jo b, callbac k) { | |
| 299 | callba ck(); | |
| 300 | } | |
| 301 | }, | |
| 302 | metr ics: log, | |
| 303 | solr : { | |
| 304 | add: funct ion(record , callback ) { | |
| 305 | callba ck(); | |
| 306 | } | |
| 307 | } | |
| 308 | }; | |
| 309 | ||
| 310 | //store new allerg y record | |
| 311 | var fini shed = fal se; | |
| 312 | runs(fun ction() { | |
| 313 | hand le(log, co nfig, envi ronment, s torageJob, function( error, res ult) { | |
| 314 | expect(err or).toBeNu ll(); | |
| 315 | expect(res ult).toEqu al('succes s'); | |
| 316 | finished = true; | |
| 317 | }, f unction() {}); | |
| 318 | }); | |
| 319 | ||
| 320 | waitsFor (function( ) { | |
| 321 | retu rn finishe d; | |
| 322 | }); | |
| 323 | ||
| 324 | var fini shed4 = fa lse; | |
| 325 | //Verify record wa s marked a s stored i n metastam p | |
| 326 | //Check the stampT ime | |
| 327 | runs(fun ction() { | |
| 328 | jdsC lient.getS yncStatus( patientIde ntifier, f unction(er ror, respo nse, resul t) { | |
| 329 | expect(val (response, 'statusCo de')).toEq ual(200); | |
| 330 | expect(val (result, ' completedS tamp')).to BeTruthy() ; | |
| 331 | expect(val (result, ' inProgress ')).toBeFa lsy(); | |
| 332 | expect(val (result, [ 'completed Stamp', 's ourceMetaS tamp', 'WX YZ', 'stam pTime'])). toEqual(al lergyRecor d.stampTim e); | |
| 333 | finished4 = true; | |
| 334 | }); | |
| 335 | }); | |
| 336 | waitsFor (function( ) { | |
| 337 | retu rn finishe d4; | |
| 338 | }); | |
| 339 | ||
| 340 | var dele tedAllergy MetaStamp = { | |
| 341 | 'icn ': 'WXYZ;1 23456', | |
| 342 | 'sta mpTime': ' 2015042112 6625', | |
| 343 | 'sou rceMetaSta mp': { | |
| 344 | 'WXYZ': { | |
| 345 | 'pid': 'WXYZ;123 456', | |
| 346 | 'local Id': '1234 56', | |
| 347 | 'stamp Time': '20 1504211266 25', | |
| 348 | 'domai nMetaStamp ': { | |
| 349 | 'a llergy': { | |
| 350 | 'domain' : 'allergy ', | |
| 351 | 'stampTi me': '2015 0421126625 ', | |
| 352 | 'eventMe taStamp': { | |
| 353 | 'urn :va:allerg y:WXYZ:123 456:065432 1': { | |
| 354 | 'stampTime ': '201504 21126625' | |
| 355 | } | |
| 356 | } | |
| 357 | } | |
| 358 | } | |
| 359 | } | |
| 360 | } | |
| 361 | }; | |
| 362 | var dele tedAllergy Record = { | |
| 363 | 'uid ': recordU id, | |
| 364 | 'sta mpTime': 2 0150421126 625, | |
| 365 | 'pid ': patient Identifier .value, | |
| 366 | 'rem oved': tru e | |
| 367 | }; | |
| 368 | var stor ageJob2 = { | |
| 369 | 'pat ientIdenti fier': pat ientIdenti fier, | |
| 370 | 'rec ord': dele tedAllergy Record, | |
| 371 | 'jpi d': '21EC2 020-BEEF-B EEF-BEEF-0 8002B30309 D', | |
| 372 | 'typ e': 'store -record-re quest' | |
| 373 | }; | |
| 374 | //Update metastamp with new metastamp for the de leted reco rd | |
| 375 | var upda teMetastam pFinished = false; | |
| 376 | runs(fun ction() { | |
| 377 | envi ronment.jd s.saveSync Status(del etedAllerg yMetaStamp , patientI dentifier, function( error, res ponse) { | |
| 378 | expect(err or).toBeFa lsy(); | |
| 379 | expect(val (response, 'statusCo de')).toBe (200); | |
| 380 | updateMeta stampFinis hed = true ; | |
| 381 | }); | |
| 382 | }); | |
| 383 | waitsFor (function( ) { | |
| 384 | retu rn updateM etastampFi nished; | |
| 385 | }); | |
| 386 | ||
| 387 | //Update the recor d with the deleted r ecord | |
| 388 | var fini shed5 = fa lse; | |
| 389 | runs(fun ction() { | |
| 390 | hand le(log, co nfig, envi ronment, s torageJob2 , function (error, re sult) { | |
| 391 | expect(err or).toBeNu ll(); | |
| 392 | expect(res ult).toEqu al('succes s'); | |
| 393 | finished5 = true; | |
| 394 | }, f unction() {}); | |
| 395 | }); | |
| 396 | ||
| 397 | waitsFor (function( ) { | |
| 398 | retu rn finishe d5; | |
| 399 | }); | |
| 400 | ||
| 401 | var fini shed6 = fa lse; | |
| 402 | //Verify metaStamp was updat ed with th e deleted record | |
| 403 | //Check the stampT ime | |
| 404 | runs(fun ction() { | |
| 405 | jdsC lient.getS yncStatus( patientIde ntifier, f unction(er ror, respo nse, resul t) { | |
| 406 | expect(val (response, 'statusCo de')).toEq ual(200); | |
| 407 | expect(val (result, ' completedS tamp')).to BeTruthy() ; | |
| 408 | expect(val (result, ' inProgress ')).toBeFa lsy(); | |
| 409 | expect(val (result, [ 'completed Stamp', 's ourceMetaS tamp', 'WX YZ', 'stam pTime'])). toEqual(de letedAller gyRecord.s tampTime); | |
| 410 | finished6 = true; | |
| 411 | }); | |
| 412 | }); | |
| 413 | waitsFor (function( ) { | |
| 414 | retu rn finishe d6; | |
| 415 | }); | |
| 416 | ||
| 417 | var fini shed7 = fa lse; | |
| 418 | //Verify old recor d was upda ted with d eleted rec ord | |
| 419 | runs(fun ction() { | |
| 420 | jdsC lient.getP atientData ByUid(reco rdUid, fun ction(erro r, respons e, result) { | |
| 421 | expect(val (response, 'statusCo de')).toEq ual(200); | |
| 422 | expect(val (result, [ 'data', 'i tems', 0, 'removed'] )).toBe(tr ue); | |
| 423 | finished7 = true; | |
| 424 | }); | |
| 425 | }); | |
| 426 | waitsFor (function( ) { | |
| 427 | retu rn finishe d7; | |
| 428 | }); | |
| 429 | ||
| 430 | tearDown AfterTest( patientIde ntifier); | |
| 431 | }) ; | |
| 432 | it ('throws a n error fo r jobs wit h missing records or records m issing dat a', functi on() { | |
| 433 | var jdsC lient = ne w JdsClien t(log, log , config); | |
| 434 | var envi ronment = { | |
| 435 | jds: jdsClient , | |
| 436 | publ isherRoute r: { | |
| 437 | publish: f unction() {} | |
| 438 | }, | |
| 439 | metr ics: log, | |
| 440 | solr : { | |
| 441 | add: funct ion() {} | |
| 442 | } | |
| 443 | }; | |
| 444 | ||
| 445 | var fini shed = fal se; | |
| 446 | var brok enJob = { | |
| 447 | 'pat ientIdenti fier': { | |
| 448 | type: 'pid ', | |
| 449 | value: 'BL AH;123456' | |
| 450 | }, | |
| 451 | 'rec ord': {}, | |
| 452 | 'jpi d': '21EC2 020-3AEA-4 069-A2DD-0 8002B30309 D', | |
| 453 | 'typ e': 'store -record-re quest' | |
| 454 | }; | |
| 455 | runs(fun ction() { | |
| 456 | hand le(log, co nfig, envi ronment, b rokenJob, function(e rror, resu lt) { | |
| 457 | expect(err or).not.to BeNull(); | |
| 458 | expect(val (error, 'm essage')). toEqual('M issing UID '); | |
| 459 | expect(res ult).toBeU ndefined() ; | |
| 460 | finished = true; | |
| 461 | }, f unction() {}); | |
| 462 | }); | |
| 463 | ||
| 464 | waitsFor (function( ) { | |
| 465 | retu rn finishe d; | |
| 466 | }); | |
| 467 | }) ; | |
| 468 | }); | |
| 469 | }); |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.