Produced by Araxis Merge on 10/3/2017 11:16:04 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\unittests\utils\middleware | patient-identifier-middleware-spec.js | Fri Jun 23 16:16:10 2017 UTC |
| 2 | ehmp.zip\ehmp\ehmp\product\production\vx-sync\tests\unittests\utils\middleware | patient-identifier-middleware-spec.js | Mon Oct 2 20:06:56 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 3 | 2382 |
| Changed | 2 | 4 |
| 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 | ||
| 7 | var DummyR equest = r equire('.. /../../fra mes/dummy- request'); | |
| 8 | var DummyR esponse = require('. ./../../fr ames/dummy -response' ); | |
| 9 | ||
| 10 | var JdsCli entDummy = require(g lobal.VX_D UMMIES + ' jds-client -dummy'); | |
| 11 | ||
| 12 | var log = require(gl obal.VX_DU MMIES + 'd ummy-logge r'); | |
| 13 | var config = { | |
| 14 | 'vista Sites': { | |
| 15 | '9 E7A': { | |
| 16 | 'name': 'panorama' , | |
| 17 | 'station Number': 5 00 | |
| 18 | }, | |
| 19 | 'C 877': { | |
| 20 | 'name': 'kodak', | |
| 21 | 'station Number': 5 00 | |
| 22 | } | |
| 23 | }, | |
| 24 | 'hdr': { | |
| 25 | 'o perationMo de': 'REQ/ RES' | |
| 26 | } | |
| 27 | }; | |
| 28 | ||
| 29 | // NOTE: b e sure nex t lines ar e commente d out befo re pushing | |
| 30 | // log = r equire('bu nyan').cre ateLogger( { | |
| 31 | // nam e: 'patien t-identifi er-middlew are-spec', | |
| 32 | // lev el: 'debug ' | |
| 33 | // }); | |
| 34 | ||
| 35 | var option s = { | |
| 36 | 'log': log, | |
| 37 | 'confi g': config , | |
| 38 | 'jdsCl ient': {} | |
| 39 | }; | |
| 40 | ||
| 41 | var Patien tIdentifie rMiddlewar e = requir e(global.V X_UTILS + 'middlewar e/patient- identifier -middlewar e'); | |
| 42 | ||
| 43 | var mockId entifierDa ta = requi re(global. VX_ROOT + 'mocks/jds /jds-mock- identifier -data'); | |
| 44 | ||
| 45 | var verify PatientExi sts = Pati entIdentif ierMiddlew are._tests ._verifyPa tientExist s; | |
| 46 | var valida tePatientI dentifier = PatientI dentifierM iddleware. _tests._va lidatePati entIdentif ier; | |
| 47 | var getJPI D = Patien tIdentifie rMiddlewar e._tests._ getJPID; | |
| 48 | var resolv eJPID = Pa tientIdent ifierMiddl eware._tes ts._resolv eJPID; | |
| 49 | var create JPID = Pat ientIdenti fierMiddle ware._test s._createJ PID; | |
| 50 | ||
| 51 | var KNOWN_ IDENTIFIER = { | |
| 52 | 'type' : 'pid', | |
| 53 | 'value ': 'ABCD;0 ' | |
| 54 | }; | |
| 55 | ||
| 56 | var UNKNOW N_IDENTIFI ER = { | |
| 57 | 'type' : 'pid', | |
| 58 | 'value ': 'ABCD;4 ' | |
| 59 | }; | |
| 60 | ||
| 61 | var SEPARA TED_IDENTI FIER = { | |
| 62 | 'type' : 'pid', | |
| 63 | 'value ': 'ABCD;1 9' | |
| 64 | }; | |
| 65 | ||
| 66 | describe(' middleware /patient-i dentifier- middleware .js', func tion() { | |
| 67 | descri be('verify PatientExi sts()', fu nction() { | |
| 68 | it ('If patie nt identif ier is not a pid the n continue without c hecking if patient i s in jds.' , function () { | |
| 69 | var resp onse = new DummyResp onse(); | |
| 70 | var next = jasmine .createSpy (); | |
| 71 | ||
| 72 | verifyPa tientExist s.call(opt ions, {pat ientIdenti fier: {typ e: 'icn', value: '10 108V420871 '}}, respo nse, next) ; | |
| 73 | ||
| 74 | expect(r esponse.st atusCode). toBeFalsy( ); | |
| 75 | expect(n ext).toHav eBeenCalle d(); | |
| 76 | }) ; | |
| 77 | ||
| 78 | it ('If jds r eturns a s earch erro r then rej ect reques t.', funct ion() { | |
| 79 | var jdsC alled = fa lse; | |
| 80 | var resp onse = new DummyResp onse(); | |
| 81 | var next = jasmine .createSpy (); | |
| 82 | var opts = _.clone (options); | |
| 83 | opts.jds Client.get Operationa lDataPtSel ectByPid = jasmine.c reateSpy() .andCallFa ke(functio n(pid, cal lback) { | |
| 84 | call back('Conn ection ref used', { | |
| 85 | 'statusCod e': 500 | |
| 86 | }); | |
| 87 | jdsC alled = tr ue; | |
| 88 | }); | |
| 89 | ||
| 90 | runs(fun ction() { | |
| 91 | veri fyPatientE xists.call (opts, {pa tientIdent ifier: {ty pe: 'pid', value: '9 E7A;3'}}, response, next); | |
| 92 | }); | |
| 93 | ||
| 94 | waitsFor (function( ) { | |
| 95 | retu rn jdsCall ed; | |
| 96 | }); | |
| 97 | ||
| 98 | runs(fun ction() { | |
| 99 | expe ct(respons e.statusCo de).toBe(4 00); | |
| 100 | expe ct(respons e.response ).toBe('Un able to ch eck if pat ient exist s in Jds.' ); | |
| 101 | expe ct(next).n ot.toHaveB eenCalled( ); | |
| 102 | }); | |
| 103 | }) ; | |
| 104 | ||
| 105 | it ('If jds r eturns an invalid re sponse the n reject r equest.', function() { | |
| 106 | var jdsC alled = fa lse; | |
| 107 | var resp onse = new DummyResp onse(); | |
| 108 | var next = jasmine .createSpy (); | |
| 109 | var opts = _.clone (options); | |
| 110 | opts.jds Client.get Operationa lDataPtSel ectByPid = jasmine.c reateSpy() .andCallFa ke(functio n(pid, cal lback) { | |
| 111 | call back(null, { | |
| 112 | 'statusCod e': 200 | |
| 113 | }, { data: {}}) ; | |
| 114 | jdsC alled = tr ue; | |
| 115 | }); | |
| 116 | ||
| 117 | runs(fun ction() { | |
| 118 | veri fyPatientE xists.call (opts, {pa tientIdent ifier: {ty pe: 'pid', value: '9 E7A;3'}}, response, next); | |
| 119 | }); | |
| 120 | ||
| 121 | waitsFor (function( ) { | |
| 122 | retu rn jdsCall ed; | |
| 123 | }); | |
| 124 | ||
| 125 | runs(fun ction() { | |
| 126 | expe ct(respons e.statusCo de).toBe(4 00); | |
| 127 | expe ct(respons e.response ).toBe('Un able to ch eck if pat ient exist s in Jds.' ); | |
| 128 | expe ct(next).n ot.toHaveB eenCalled( ); | |
| 129 | }); | |
| 130 | }) ; | |
| 131 | ||
| 132 | it ('If patie nt is not in jds the n reject r equest.', function() { | |
| 133 | var jdsC alled = fa lse; | |
| 134 | var resp onse = new DummyResp onse(); | |
| 135 | var next = jasmine .createSpy (); | |
| 136 | var opts = _.clone (options); | |
| 137 | opts.jds Client.get Operationa lDataPtSel ectByPid = jasmine.c reateSpy() .andCallFa ke(functio n(pid, cal lback) { | |
| 138 | call back(null, { | |
| 139 | 'statusCod e': 200 | |
| 140 | }, { data: {tot alItems: 0 }}); | |
| 141 | jdsC alled = tr ue; | |
| 142 | }); | |
| 143 | ||
| 144 | runs(fun ction() { | |
| 145 | veri fyPatientE xists.call (opts, {pa tientIdent ifier: {ty pe: 'pid', value: '9 E7A;3'}}, response, next); | |
| 146 | }); | |
| 147 | ||
| 148 | waitsFor (function( ) { | |
| 149 | retu rn jdsCall ed; | |
| 150 | }); | |
| 151 | ||
| 152 | runs(fun ction() { | |
| 153 | expe ct(respons e.statusCo de).toBe(4 00); | |
| 154 | expe ct(respons e.response ).toBe('Pa tient does not exist in Jds.') ; | |
| 155 | expe ct(next).n ot.toHaveB eenCalled( ); | |
| 156 | }); | |
| 157 | }) ; | |
| 158 | ||
| 159 | it ('If patie nt is in j ds then co ntinue pro cessing re quest.', f unction() { | |
| 160 | var jdsC alled = fa lse; | |
| 161 | var resp onse = new DummyResp onse(); | |
| 162 | var next = jasmine .createSpy (); | |
| 163 | var opts = _.clone (options); | |
| 164 | opts.jds Client.get Operationa lDataPtSel ectByPid = jasmine.c reateSpy() .andCallFa ke(functio n(pid, cal lback) { | |
| 165 | call back(null, { | |
| 166 | 'statusCod e': 200 | |
| 167 | }, { data: {tot alItems: 1 }}); | |
| 168 | jdsC alled = tr ue; | |
| 169 | }); | |
| 170 | ||
| 171 | runs(fun ction() { | |
| 172 | veri fyPatientE xists.call (opts, {pa tientIdent ifier: {ty pe: 'pid', value: '9 E7A;3'}}, response, next); | |
| 173 | }); | |
| 174 | ||
| 175 | waitsFor (function( ) { | |
| 176 | retu rn jdsCall ed; | |
| 177 | }); | |
| 178 | ||
| 179 | runs(fun ction() { | |
| 180 | expe ct(respons e.statusCo de).toBeFa lsy(); | |
| 181 | expe ct(next).t oHaveBeenC alled(); | |
| 182 | }); | |
| 183 | }) ; | |
| 184 | }); | |
| 185 | ||
| 186 | descri be('valida tePatientI dentifier ()', funct ion() { | |
| 187 | it ('Rejects requests w ithout a v alid query parameter ', functio n() { | |
| 188 | var resp onse = new DummyResp onse(); | |
| 189 | validate PatientIde ntifier.ca ll(options , new Dumm yRequest() , response , function () {}); | |
| 190 | expect(r esponse.st atusCode). toEqual(40 0); | |
| 191 | expect(r esponse.re sponse).to Equal('Ple ase provid e one vali d patient identifier .'); | |
| 192 | }) ; | |
| 193 | ||
| 194 | it ('Rejects requests w ith too ma ny paramet ers', func tion() { | |
| 195 | var requ estParamet ers = { | |
| 196 | 'pid ': '9E7A;3 ', | |
| 197 | 'icn ': '10108V 420871' | |
| 198 | }; | |
| 199 | var resp onse = new DummyResp onse(); | |
| 200 | validate PatientIde ntifier.ca ll(options , new Dumm yRequest(r equestPara meters), r esponse, f unction() {}); | |
| 201 | expect(r esponse.st atusCode). toEqual(40 0); | |
| 202 | expect(r esponse.re sponse).to Equal('Ple ase limit your reque st to one patient id entifier.' ); | |
| 203 | }) ; | |
| 204 | ||
| 205 | it ('Rejects empty para meters', f unction() { | |
| 206 | var requ estParamet ers = { | |
| 207 | 'pid ': '' | |
| 208 | }; | |
| 209 | var resp onse = new DummyResp onse(); | |
| 210 | validate PatientIde ntifier.ca ll(options , new Dumm yRequest(r equestPara meters), r esponse, f unction() {}); | |
| 211 | expect(r esponse.st atusCode). toEqual(40 0); | |
| 212 | expect(r esponse.re sponse).to Equal('No value was given for the query parameter' ); | |
| 213 | }) ; | |
| 214 | ||
| 215 | it ('Rejects invalid PI Ds', funct ion() { | |
| 216 | var requ estParamet ers = { | |
| 217 | 'pid ': '10108V 420871' | |
| 218 | }; | |
| 219 | var resp onse = new DummyResp onse(); | |
| 220 | validate PatientIde ntifier.ca ll(options , new Dumm yRequest(r equestPara meters), r esponse, f unction() {}); | |
| 221 | expect(r esponse.st atusCode). toEqual(40 0); | |
| 222 | expect(r esponse.re sponse).to Equal('The value for patient i d type was not in a valid form at'); | |
| 223 | }) ; | |
| 224 | ||
| 225 | it ('Rejects invalid IC Ns', funct ion() { | |
| 226 | var requ estParamet ers = { | |
| 227 | 'icn ': '9E7A;3 ' | |
| 228 | }; | |
| 229 | var resp onse = new DummyResp onse(); | |
| 230 | validate PatientIde ntifier.ca ll(options , new Dumm yRequest(r equestPara meters), r esponse, f unction() {}); | |
| 231 | expect(r esponse.st atusCode). toEqual(40 0); | |
| 232 | expect(r esponse.re sponse).to Equal('The value for patient i d type was not in a valid form at'); | |
| 233 | }) ; | |
| 234 | ||
| 235 | it ('Appends a PID pati entIdentif ier json p roperty to valid req uest objec ts', funct ion() { | |
| 236 | var requ est = new DummyReque st({ | |
| 237 | 'pid ': '9E7A;3 ' | |
| 238 | }); | |
| 239 | var resp onse = new DummyResp onse(); | |
| 240 | validate PatientIde ntifier.ca ll(options , request, response, function( ) {}); | |
| 241 | var pati entIdentif ierObj = r equest.pat ientIdenti fier; | |
| 242 | expect(p atientIden tifierObj. type).toEq ual('pid') ; | |
| 243 | expect(p atientIden tifierObj. value).toE qual('9E7A ;3'); | |
| 244 | }) ; | |
| 245 | ||
| 246 | xi t('Appends an PID pa tientIdent ifier json property to valid r equest obj ects when receiving an ICN', f unction() { | |
| 247 | var requ est = new DummyReque st({ | |
| 248 | 'icn ': '10108V 420871' | |
| 249 | }); | |
| 250 | var resp onse = new DummyResp onse(); | |
| 251 | var next = jasmine .createSpy (); | |
| 252 | var opts = _.clone (options); | |
| 253 | opts.jds Client.get Operationa lDataPtSel ectByIcn = jasmine.c reateSpy() .andCallFa ke(functio n(icn, cal lback) { | |
| 254 | var retObj = { | |
| 255 | 'data': { | |
| 256 | 'items ': [{ | |
| 257 | 'p id': '9E7A ;3' | |
| 258 | }, { | |
| 259 | 'p id': 'C877 ;3' | |
| 260 | }] | |
| 261 | } | |
| 262 | }; | |
| 263 | ||
| 264 | call back(null, { | |
| 265 | 'statusCod e': 200 | |
| 266 | }, r etObj); | |
| 267 | }); | |
| 268 | ||
| 269 | validate PatientIde ntifier.ca ll(opts, r equest, re sponse, fu nction() { }); | |
| 270 | var pati entIdentif ierObj = r equest.pat ientIdenti fier; | |
| 271 | expect(p atientIden tifierObj. type).toEq ual('pid') ; | |
| 272 | expect(p atientIden tifierObj. value).toE qual('9E7A ;3'); | |
| 273 | }) ; | |
| 274 | ||
| 275 | it ('Appends an ICN pat ientIdenti fier json property t o valid re quest obje cts becaus e it fails to look u p pid', fu nction() { | |
| 276 | var requ est = new DummyReque st({ | |
| 277 | 'icn ': '10108V 420871' | |
| 278 | }); | |
| 279 | var resp onse = new DummyResp onse(); | |
| 280 | var next = jasmine .createSpy (); | |
| 281 | var opts = _.clone (options); | |
| 282 | opts.jds Client.get Operationa lDataPtSel ectByIcn = jasmine.c reateSpy() .andCallFa ke(functio n(icn, cal lback) { | |
| 283 | call back('Fail ed to retr ieve patie nt', { | |
| 284 | 'statusCod e': 404 | |
| 285 | }, n ull); | |
| 286 | }); | |
| 287 | ||
| 288 | validate PatientIde ntifier.ca ll(opts, r equest, re sponse, fu nction() { }); | |
| 289 | var pati entIdentif ierObj = r equest.pat ientIdenti fier; | |
| 290 | expect(p atientIden tifierObj. type).toEq ual('icn') ; | |
| 291 | expect(p atientIden tifierObj. value).toE qual('1010 8V420871') ; | |
| 292 | }) ; | |
| 293 | ||
| 294 | it ('Appends an ICN pat ientIdenti fier json property t o valid re quest obje cts becaus e no pids are availa ble', func tion() { | |
| 295 | var requ est = new DummyReque st({ | |
| 296 | 'icn ': '10108V 420871' | |
| 297 | }); | |
| 298 | var resp onse = new DummyResp onse(); | |
| 299 | var next = jasmine .createSpy (); | |
| 300 | var opts = _.clone (options); | |
| 301 | opts.jds Client.get Operationa lDataPtSel ectByIcn = jasmine.c reateSpy() .andCallFa ke(functio n(icn, cal lback) { | |
| 302 | var retObj = { | |
| 303 | 'data': { | |
| 304 | 'items ': [] | |
| 305 | } | |
| 306 | }; | |
| 307 | ||
| 308 | call back(null, { | |
| 309 | 'statusCod e': 200 | |
| 310 | }, r etObj); | |
| 311 | }); | |
| 312 | ||
| 313 | validate PatientIde ntifier.ca ll(opts, r equest, re sponse, fu nction() { }); | |
| 314 | var pati entIdentif ierObj = r equest.pat ientIdenti fier; | |
| 315 | expect(p atientIden tifierObj. type).toEq ual('icn') ; | |
| 316 | expect(p atientIden tifierObj. value).toE qual('1010 8V420871') ; | |
| 317 | }) ; | |
| 318 | }); | |
| 319 | ||
| 320 | descri be('getJPI D()', func tion() { | |
| 321 | it ('Appends the JPID f or a known patient i dentifier to the req uest', fun ction() { | |
| 322 | var requ est = { | |
| 323 | 'pat ientIdenti fier': KNO WN_IDENTIF IER | |
| 324 | }; | |
| 325 | var resp onse = new DummyResp onse(); | |
| 326 | var next = jasmine .createSpy (); | |
| 327 | var opts = _.clone (options); | |
| 328 | opts.jds Client.get PatientIde ntifier = jasmine.cr eateSpy(). andCallFak e(function (job, call back) { | |
| 329 | var retObj = { | |
| 330 | 'jpid': mo ckIdentifi erData.ide ntifierToJ pidMap[job .patientId entifier.v alue] | |
| 331 | }; | |
| 332 | call back(null, { | |
| 333 | 'statusCod e': 200 | |
| 334 | }, r etObj); | |
| 335 | }); | |
| 336 | ||
| 337 | runs(fun ction() { | |
| 338 | getJ PID.call(o pts, reque st, respon se, next); | |
| 339 | }); | |
| 340 | ||
| 341 | waitsFor (function( ) { | |
| 342 | retu rn next.ca llCount > 0; | |
| 343 | }); | |
| 344 | ||
| 345 | runs(fun ction() { | |
| 346 | expe ct(request .jpid).toE qual('21EC 2020-3AEA- 4069-A2DD- 08002B3030 9D'); | |
| 347 | }); | |
| 348 | }) ; | |
| 349 | ||
| 350 | it ('Appends false for an unknown patient i dentifier' , function () { | |
| 351 | var requ est = { | |
| 352 | 'pat ientIdenti fier': UNK NOWN_IDENT IFIER | |
| 353 | }; | |
| 354 | var resp onse = new DummyResp onse(); | |
| 355 | var next = jasmine .createSpy (); | |
| 356 | var opts = _.clone (options); | |
| 357 | opts.jds Client.get PatientIde ntifier = jasmine.cr eateSpy(). andCallFak e(function (job, call back) { | |
| 358 | call back(404, { | |
| 359 | 'statusCod e': 404 | |
| 360 | }, ' Patient no t found'); | |
| 361 | }); | |
| 362 | ||
| 363 | runs(fun ction() { | |
| 364 | getJ PID.call(o pts, reque st, respon se, next); | |
| 365 | }); | |
| 366 | ||
| 367 | waitsFor (function( ) { | |
| 368 | retu rn next.ca llCount > 0; | |
| 369 | }); | |
| 370 | ||
| 371 | runs(fun ction() { | |
| 372 | expe ct(request .jpid).toB e(false); | |
| 373 | }); | |
| 374 | }) ; | |
| 375 | ||
| 376 | it ('Error fr om JDS', f unction() { | |
| 377 | var done ; | |
| 378 | var requ est = { | |
| 379 | 'pat ientIdenti fier': UNK NOWN_IDENT IFIER | |
| 380 | }; | |
| 381 | var resp onse = new DummyResp onse(); | |
| 382 | spyOn(re sponse, 's tatus').an dCallThrou gh(); | |
| 383 | spyOn(re sponse, 'j son').andC allFake(fu nction(){ | |
| 384 | done = true; | |
| 385 | }); | |
| 386 | var next = jasmine .createSpy (); | |
| 387 | var opts = _.clone (options); | |
| 388 | opts.jds Client.get PatientIde ntifier = jasmine.cr eateSpy(). andCallFak e(function (job, call back) { | |
| 389 | call back('Erro r!', null, null); | |
| 390 | }); | |
| 391 | ||
| 392 | runs(fun ction() { | |
| 393 | getJ PID.call(o pts, reque st, respon se, next); | |
| 394 | }); | |
| 395 | ||
| 396 | waitsFor (function( ) { | |
| 397 | retu rn done; | |
| 398 | }); | |
| 399 | ||
| 400 | runs(fun ction() { | |
| 401 | expe ct(respons e.status). toHaveBeen CalledWith (500); | |
| 402 | }); | |
| 403 | }) ; | |
| 404 | ||
| 405 | }); | |
| 406 | ||
| 407 | descri be('resolv eJPID()', function() { | |
| 408 | va r jpid = ' 21EC2020-3 AEA-4069-A 2DD-DDDDDD DDDDDD'; | |
| 409 | va r identifi ers = ['00 0000V11111 1', 'ABCD; 19', 'DOD; 1111111']; | |
| 410 | va r idObject s = [{ | |
| 411 | ty pe: 'icn', | |
| 412 | va lue: '0000 00V111111' | |
| 413 | }, { | |
| 414 | ty pe: 'pid', | |
| 415 | va lue: 'ABCD ;19' | |
| 416 | }, { | |
| 417 | ty pe: 'pid', | |
| 418 | va lue: 'DOD; 1111111' | |
| 419 | }]; | |
| 420 | it ('Normal p ath: jpid already pr esent', fu nction() { | |
| 421 | var requ est = { | |
| 422 | 'pat ientIdenti fier': SEP ARATED_IDE NTIFIER | |
| 423 | }; | |
| 424 | var resp onse = {}; | |
| 425 | var opts = _.clone (options); | |
| 426 | opts.get JPID = fun ction(req, res, next ){ | |
| 427 | req. jpid = jpi d; | |
| 428 | req. identifier s = identi fiers; | |
| 429 | next (); | |
| 430 | }; | |
| 431 | ||
| 432 | var done = false; | |
| 433 | ||
| 434 | runs(fun ction() { | |
| 435 | reso lveJPID.ca ll(opts, r equest, re sponse, fu nction() { | |
| 436 | expect(req uest.jpid) .toBeTruth y(); | |
| 437 | expect(req uest.jpid) .toEqual(j pid); | |
| 438 | expect(req uest.ident ifiers).to Contain('0 00000V1111 11'); | |
| 439 | expect(req uest.ident ifiers).to Contain('D OD;1111111 '); | |
| 440 | expect(req uest.ident ifiers).to Contain('A BCD;19'); | |
| 441 | done = tru e; | |
| 442 | }); | |
| 443 | }); | |
| 444 | ||
| 445 | waitsFor (function( ) { | |
| 446 | retu rn done; | |
| 447 | }); | |
| 448 | }) ; | |
| 449 | ||
| 450 | it ('Normal p ath: jpid query retu rns 200', function() { | |
| 451 | var requ est = { | |
| 452 | 'pat ientIdenti fier': SEP ARATED_IDE NTIFIER | |
| 453 | }; | |
| 454 | var resp onse = {}; | |
| 455 | var opts = _.clone (options); | |
| 456 | opts.get JPID = get JPID; | |
| 457 | opts.cre ateJPID = createJPID ; | |
| 458 | ||
| 459 | opts.mvi Client = { | |
| 460 | look upWithDemo graphics: function(p atientIden tifier, de mographics , callback ) { | |
| 461 | return cal lback(null , {ids: id Objects} ) ; | |
| 462 | } | |
| 463 | }; | |
| 464 | ||
| 465 | var jdsC lientDummy = new Jds ClientDumm y(log, { | |
| 466 | jds: {} | |
| 467 | }); | |
| 468 | ||
| 469 | jdsClien tDummy._se tResponseD ata([null, null, nul l, null],[ {statusCod e: 404}, { statusCode : 200}, {s tatusCode: 201}, {st atusCode: 200}], [nu ll, null, null, { | |
| 470 | jpid : jpid, | |
| 471 | pati entIdentif iers: [req uest.patie ntIdentifi er.value] | |
| 472 | }]); | |
| 473 | ||
| 474 | opts.jds Client = j dsClientDu mmy; | |
| 475 | var done = false; | |
| 476 | ||
| 477 | runs(fun ction() { | |
| 478 | reso lveJPID.ca ll(opts, r equest, re sponse, fu nction() { | |
| 479 | expect(req uest.jpid) .toBeTruth y(); | |
| 480 | expect(req uest.jpid) .toEqual(j pid); | |
| 481 | expect(req uest.ident ifiers).to Contain(re quest.pati entIdentif ier.value) ; | |
| 482 | expect(req uest.ident ifiers).no t.toContai n('000000V 111111'); | |
| 483 | expect(req uest.ident ifiers).no t.toContai n('DOD;111 1111'); | |
| 484 | done = tru e; | |
| 485 | }); | |
| 486 | }); | |
| 487 | ||
| 488 | waitsFor (function( ) { | |
| 489 | retu rn done; | |
| 490 | }); | |
| 491 | }) ; | |
| 492 | it ('Normal p ath: jpid query retu rns 400', function() { | |
| 493 | var requ est = { | |
| 494 | 'pat ientIdenti fier': SEP ARATED_IDE NTIFIER | |
| 495 | }; | |
| 496 | var resp onse = {}; | |
| 497 | var opts = _.clone (options); | |
| 498 | var getJ PIDcalls = 0; | |
| 499 | opts.get JPID = fun ction(req, res, next ){ | |
| 500 | if(! getJPIDcal ls){ | |
| 501 | req.jpid = false; | |
| 502 | getJPIDcal ls++; | |
| 503 | } el se { | |
| 504 | req.jpid = jpid; | |
| 505 | req.identi fiers = [r equest.pat ientIdenti fier.value ]; | |
| 506 | } | |
| 507 | next (); | |
| 508 | }; | |
| 509 | opts.cre ateJPID = createJPID ; | |
| 510 | ||
| 511 | opts.mvi Client = { | |
| 512 | look upWithDemo graphics: function(p atientIden tifier, de mographics , callback ) { | |
| 513 | return cal lback(null , {ids: id Objects} ) ; | |
| 514 | } | |
| 515 | }; | |
| 516 | ||
| 517 | var jdsC lientDummy = new Jds ClientDumm y(log, { | |
| 518 | jds: {} | |
| 519 | }); | |
| 520 | ||
| 521 | jdsClien tDummy._se tResponseD ata([null, null, nul l],[{statu sCode: 400 }, {status Code: 201} , {statusC ode: 200}] , [null, n ull, { | |
| 522 | jpid : jpid, | |
| 523 | pati entIdentif iers: iden tifiers | |
| 524 | }]); | |
| 525 | ||
| 526 | opts.jds Client = j dsClientDu mmy; | |
| 527 | var done = false; | |
| 528 | ||
| 529 | runs(fun ction() { | |
| 530 | reso lveJPID.ca ll(opts, r equest, re sponse, fu nction() { | |
| 531 | expect(req uest.jpid) .toBeTruth y(); | |
| 532 | expect(req uest.jpid) .toEqual(j pid); | |
| 533 | expect(req uest.ident ifiers).to Contain(re quest.pati entIdentif ier.value) ; | |
| 534 | expect(req uest.ident ifiers).no t.toContai n('000000V 111111'); | |
| 535 | expect(req uest.ident ifiers).no t.toContai n('DOD;111 1111'); | |
| 536 | done = tru e; | |
| 537 | }); | |
| 538 | }); | |
| 539 | ||
| 540 | waitsFor (function( ) { | |
| 541 | retu rn done; | |
| 542 | }); | |
| 543 | }) ; | |
| 544 | it ('Normal p ath: jpid query retu rns 201 an d no confl ict when r e-associat ing pid to jpid', fu nction() { | |
| 545 | var requ est = { | |
| 546 | 'pat ientIdenti fier': SEP ARATED_IDE NTIFIER | |
| 547 | }; | |
| 548 | var resp onse = {}; | |
| 549 | var opts = _.clone (options); | |
| 550 | opts.get JPID = get JPID; | |
| 551 | opts.cre ateJPID = createJPID ; | |
| 552 | ||
| 553 | opts.mvi Client = { | |
| 554 | look upWithDemo graphics: function(p atientIden tifier, de mographics , callback ) { | |
| 555 | return cal lback(null , {ids: id Objects} ) ; | |
| 556 | } | |
| 557 | }; | |
| 558 | ||
| 559 | var jdsC lientDummy = new Jds ClientDumm y(log, { | |
| 560 | jds: {} | |
| 561 | }); | |
| 562 | ||
| 563 | jdsClientD ummy._setR esponseDat a([null, n ull, null] ,[{statusC ode: 404}, {statusCo de: 201, h eaders: {l ocation:'h ttp:// IP /vpr/jpid' +jpid}}, { statusCode : 201}, {s tatusCode: 200}], [n ull, null, null, {jp id: jpid, patientIde ntifiers: identifier s}]); | |
| 564 | ||
| 565 | opts.jds Client = j dsClientDu mmy; | |
| 566 | var done = false; | |
| 567 | ||
| 568 | runs(fun ction() { | |
| 569 | reso lveJPID.ca ll(opts, r equest, re sponse, fu nction() { | |
| 570 | expect(req uest.jpid) .toBeTruth y(); | |
| 571 | expect(req uest.jpid) .toEqual(j pid); | |
| 572 | expect(req uest.ident ifiers).to Contain(re quest.pati entIdentif ier.value) ; | |
| 573 | expect(req uest.ident ifiers).to Contain('0 00000V1111 11'); | |
| 574 | expect(req uest.ident ifiers).to Contain('D OD;1111111 '); | |
| 575 | done = tru e; | |
| 576 | }); | |
| 577 | }); | |
| 578 | ||
| 579 | waitsFor (function( ) { | |
| 580 | retu rn done; | |
| 581 | }); | |
| 582 | }) ; | |
| 583 | it ('Normal p ath: jpid query retu rns 201 an d conflict when re-a ssociating pid to jp id', funct ion() { | |
| 584 | var requ est = { | |
| 585 | 'pat ientIdenti fier': SEP ARATED_IDE NTIFIER | |
| 586 | }; | |
| 587 | var resp onse = {}; | |
| 588 | var opts = _.clone (options); | |
| 589 | ||
| 590 | opts.get JPID = get JPID; | |
| 591 | opts.cre ateJPID = createJPID ; | |
| 592 | ||
| 593 | opts.mvi Client = { | |
| 594 | look upWithDemo graphics: function(p atientIden tifier, de mographics , callback ) { | |
| 595 | return cal lback(null , {ids: id Objects} ) ; | |
| 596 | } | |
| 597 | }; | |
| 598 | ||
| 599 | var jdsC lientDummy = new Jds ClientDumm y(log, { | |
| 600 | jds: {} | |
| 601 | }); | |
| 602 | ||
| 603 | jdsClientD ummy._setR esponseDat a([null, n ull, null, null, nul l],[{statu sCode:404} ,{statusCo de: 201, h eaders: {l ocation:'h ttp:// IP /vpr/jpid' +jpid}}, { statusCode : 400}, {s tatusCode: 201}, {sta tusCode:20 0}], [null ,null, nul l, null, { jpid: jpid , patientI dentifiers :[request. patientIde ntifier.va lue]}]); | |
| 604 | ||
| 605 | opts.jds Client = j dsClientDu mmy; | |
| 606 | var done = false; | |
| 607 | ||
| 608 | runs(fun ction() { | |
| 609 | reso lveJPID.ca ll(opts, r equest, re sponse, fu nction() { | |
| 610 | expect(req uest.jpid) .toBeTruth y(); | |
| 611 | expect(req uest.jpid) .toEqual(j pid); | |
| 612 | expect(req uest.ident ifiers).to Contain(re quest.pati entIdentif ier.value) ; | |
| 613 | expect(req uest.ident ifiers).no t.toContai n('000000V 111111'); | |
| 614 | expect(req uest.ident ifiers).no t.toContai n('DOD;111 1111'); | |
| 615 | done = tru e; | |
| 616 | }); | |
| 617 | }); | |
| 618 | ||
| 619 | waitsFor (function( ) { | |
| 620 | retu rn done; | |
| 621 | }); | |
| 622 | }) ; | |
| 623 | it ('Normal p ath (edge case): cor responding ids looku p returns no ids', f unction(){ | |
| 624 | var requ est = { | |
| 625 | 'pat ientIdenti fier': SEP ARATED_IDE NTIFIER | |
| 626 | }; | |
| 627 | var resp onse = {}; | |
| 628 | var opts = _.clone (options); | |
| 629 | opts.get JPID = get JPID; | |
| 630 | opts.cre ateJPID = createJPID ; | |
| 631 | ||
| 632 | opts.mvi Client = { | |
| 633 | look upWithDemo graphics: function(p atientIden tifier, de mographics , callback ) { | |
| 634 | return cal lback(null , null); | |
| 635 | } | |
| 636 | }; | |
| 637 | ||
| 638 | var jdsC lientDummy = new Jds ClientDumm y(log, { | |
| 639 | jds: {} | |
| 640 | }); | |
| 641 | ||
| 642 | jdsClien tDummy._se tResponseD ata([null, null, nul l],[{statu sCode: 404 }, {status Code: 201} , {statusC ode: 200}] , [null, n ull, { | |
| 643 | jpid : jpid, | |
| 644 | pati entIdentif iers: [req uest.patie ntIdentifi er.value] | |
| 645 | }]); | |
| 646 | ||
| 647 | opts.jds Client = j dsClientDu mmy; | |
| 648 | var done = false; | |
| 649 | ||
| 650 | runs(fun ction() { | |
| 651 | reso lveJPID.ca ll(opts, r equest, re sponse, fu nction() { | |
| 652 | expect(req uest.jpid) .toBeTruth y(); | |
| 653 | expect(req uest.jpid) .toEqual(j pid); | |
| 654 | expect(req uest.ident ifiers).to Contain(re quest.pati entIdentif ier.value) ; | |
| 655 | expect(req uest.ident ifiers).no t.toContai n('000000V 111111'); | |
| 656 | expect(req uest.ident ifiers).no t.toContai n('DOD;111 1111'); | |
| 657 | done = tru e; | |
| 658 | }); | |
| 659 | }); | |
| 660 | ||
| 661 | waitsFor (function( ) { | |
| 662 | retu rn done; | |
| 663 | }); | |
| 664 | }) ; | |
| 665 | it ('Error pa th: corres ponding id s lookup r eturns err or', funct ion(){ | |
| 666 | var requ est = { | |
| 667 | 'pat ientIdenti fier': SEP ARATED_IDE NTIFIER | |
| 668 | }; | |
| 669 | var done = false; | |
| 670 | var resp onse = { | |
| 671 | stat us: functi on(){ | |
| 672 | return thi s; | |
| 673 | }, | |
| 674 | json : function (){ | |
| 675 | expect(req uest.jpid) .toBeFalsy (); | |
| 676 | expect(req uest.ident ifiers).to BeFalsy(); | |
| 677 | expect(res ponse.stat us).toHave BeenCalled With(400); | |
| 678 | done = tru e; | |
| 679 | return thi s; | |
| 680 | } | |
| 681 | }; | |
| 682 | var opts = _.clone (options); | |
| 683 | opts.get JPID = get JPID; | |
| 684 | opts.cre ateJPID = createJPID ; | |
| 685 | ||
| 686 | spyOn(re sponse, 's tatus').an dCallThrou gh(); | |
| 687 | spyOn(re sponse, 'j son').andC allThrough (); | |
| 688 | ||
| 689 | opts.mvi Client = { | |
| 690 | look upWithDemo graphics: function(p atientIden tifier, de mographics , callback ) { | |
| 691 | return cal lback({err or: 'ERROR !'}, null) ; | |
| 692 | } | |
| 693 | }; | |
| 694 | ||
| 695 | var jdsC lientDummy = new Jds ClientDumm y(log, { | |
| 696 | jds: {} | |
| 697 | }); | |
| 698 | ||
| 699 | jdsClien tDummy._se tResponseD ata([null] ,[{statusC ode: 404}] , [null]); | |
| 700 | ||
| 701 | opts.jds Client = j dsClientDu mmy; | |
| 702 | ||
| 703 | runs(fun ction() { | |
| 704 | reso lveJPID.ca ll(opts, r equest, re sponse, fu nction() { | |
| 705 | //Should e rror out | |
| 706 | }); | |
| 707 | }); | |
| 708 | ||
| 709 | waitsFor (function( ) { | |
| 710 | retu rn done; | |
| 711 | }); | |
| 712 | }) ; | |
| 713 | it ('Error pa th: jpid q uery retur ns error', function( ){ | |
| 714 | var requ est = { | |
| 715 | 'pat ientIdenti fier': SEP ARATED_IDE NTIFIER | |
| 716 | }; | |
| 717 | var done = false; | |
| 718 | var resp onse = { | |
| 719 | stat us: functi on(){ | |
| 720 | return thi s; | |
| 721 | }, | |
| 722 | json : function (){ | |
| 723 | expect(req uest.jpid) .toBeFalsy (); | |
| 724 | expect(req uest.ident ifiers).to BeFalsy(); | |
| 725 | expect(res ponse.stat us).toHave BeenCalled With(400); | |
| 726 | done = tru e; | |
| 727 | return thi s; | |
| 728 | } | |
| 729 | }; | |
| 730 | var opts = _.clone (options); | |
| 731 | opts.get JPID = get JPID; | |
| 732 | opts.cre ateJPID = createJPID ; | |
| 733 | ||
| 734 | spyOn(re sponse, 's tatus').an dCallThrou gh(); | |
| 735 | spyOn(re sponse, 'j son').andC allThrough (); | |
| 736 | ||
| 737 | opts.mvi Client = { | |
| 738 | look upWithDemo graphics: function(p atientIden tifier, de mographics , callback ) { | |
| 739 | return cal lback(null , {ids: id Objects}); | |
| 740 | } | |
| 741 | }; | |
| 742 | ||
| 743 | var jdsC lientDummy = new Jds ClientDumm y(log, { | |
| 744 | jds: {} | |
| 745 | }); | |
| 746 | ||
| 747 | jdsClien tDummy._se tResponseD ata([null, {error: ' ERROR!'}], [{statusCo de: 404}, null], [nu ll, null]) ; | |
| 748 | ||
| 749 | opts.jds Client = j dsClientDu mmy; | |
| 750 | ||
| 751 | runs(fun ction() { | |
| 752 | reso lveJPID.ca ll(opts, r equest, re sponse, fu nction() { | |
| 753 | //Should e rror out | |
| 754 | }); | |
| 755 | }); | |
| 756 | ||
| 757 | waitsFor (function( ) { | |
| 758 | retu rn done; | |
| 759 | }); | |
| 760 | }) ; | |
| 761 | it ('Error pa th: jpid q uery retur ns null re sponse', f unction(){ | |
| 762 | var requ est = { | |
| 763 | 'pat ientIdenti fier': SEP ARATED_IDE NTIFIER | |
| 764 | }; | |
| 765 | var done = false; | |
| 766 | var resp onse = { | |
| 767 | stat us: functi on(){ | |
| 768 | return thi s; | |
| 769 | }, | |
| 770 | json : function (){ | |
| 771 | expect(req uest.jpid) .toBeFalsy (); | |
| 772 | expect(req uest.ident ifiers).to BeFalsy(); | |
| 773 | expect(res ponse.stat us).toHave BeenCalled With(400); | |
| 774 | done = tru e; | |
| 775 | return thi s; | |
| 776 | } | |
| 777 | }; | |
| 778 | var opts = _.clone (options); | |
| 779 | opts.get JPID = get JPID; | |
| 780 | opts.cre ateJPID = createJPID ; | |
| 781 | ||
| 782 | spyOn(re sponse, 's tatus').an dCallThrou gh(); | |
| 783 | spyOn(re sponse, 'j son').andC allThrough (); | |
| 784 | ||
| 785 | opts.mvi Client = { | |
| 786 | look upWithDemo graphics: function(p atientIden tifier, de mographics , callback ) { | |
| 787 | return cal lback(null , {ids: id Objects}); | |
| 788 | } | |
| 789 | }; | |
| 790 | ||
| 791 | var jdsC lientDummy = new Jds ClientDumm y(log, { | |
| 792 | jds: {} | |
| 793 | }); | |
| 794 | ||
| 795 | jdsClien tDummy._se tResponseD ata([null, null],[{s tatusCode: 404}, nul l], [null, null]); | |
| 796 | ||
| 797 | opts.jds Client = j dsClientDu mmy; | |
| 798 | ||
| 799 | runs(fun ction() { | |
| 800 | reso lveJPID.ca ll(opts, r equest, re sponse, fu nction() { | |
| 801 | //Should e rror out | |
| 802 | }); | |
| 803 | }); | |
| 804 | ||
| 805 | waitsFor (function( ) { | |
| 806 | retu rn done; | |
| 807 | }); | |
| 808 | }) ; | |
| 809 | it ('Error pa th: jpid q uery retur ns unexpec ted respon se', funct ion(){ | |
| 810 | var requ est = { | |
| 811 | 'pat ientIdenti fier': SEP ARATED_IDE NTIFIER | |
| 812 | }; | |
| 813 | var done = false; | |
| 814 | var resp onse = { | |
| 815 | stat us: functi on(){ | |
| 816 | return thi s; | |
| 817 | }, | |
| 818 | json : function (){ | |
| 819 | expect(req uest.jpid) .toBeFalsy (); | |
| 820 | expect(req uest.ident ifiers).to BeFalsy(); | |
| 821 | expect(res ponse.stat us).toHave BeenCalled With(400); | |
| 822 | done = tru e; | |
| 823 | return thi s; | |
| 824 | } | |
| 825 | }; | |
| 826 | var opts = _.clone (options); | |
| 827 | opts.get JPID = get JPID; | |
| 828 | opts.cre ateJPID = createJPID ; | |
| 829 | ||
| 830 | spyOn(re sponse, 's tatus').an dCallThrou gh(); | |
| 831 | spyOn(re sponse, 'j son').andC allThrough (); | |
| 832 | ||
| 833 | opts.mvi Client = { | |
| 834 | look upWithDemo graphics: function(p atientIden tifier, de mographics , callback ) { | |
| 835 | return cal lback(null , {ids: id Objects}); | |
| 836 | } | |
| 837 | }; | |
| 838 | ||
| 839 | var jdsC lientDummy = new Jds ClientDumm y(log, { | |
| 840 | jds: {} | |
| 841 | }); | |
| 842 | ||
| 843 | jdsClien tDummy._se tResponseD ata([null, null],[{s tatusCode: 404}, {st atusCode: 500}], [nu ll, null]) ; | |
| 844 | ||
| 845 | opts.jds Client = j dsClientDu mmy; | |
| 846 | ||
| 847 | runs(fun ction() { | |
| 848 | reso lveJPID.ca ll(opts, r equest, re sponse, fu nction() { | |
| 849 | //Should e rror out | |
| 850 | }); | |
| 851 | }); | |
| 852 | ||
| 853 | waitsFor (function( ) { | |
| 854 | retu rn done; | |
| 855 | }); | |
| 856 | }) ; | |
| 857 | it ('Error pa th: jds.st orePatient Identifier returns e rror', fun ction(){ | |
| 858 | var requ est = { | |
| 859 | 'pat ientIdenti fier': SEP ARATED_IDE NTIFIER | |
| 860 | }; | |
| 861 | var done = false; | |
| 862 | var resp onse = { | |
| 863 | stat us: functi on(){ | |
| 864 | return thi s; | |
| 865 | }, | |
| 866 | json : function (){ | |
| 867 | expect(req uest.jpid) .toBeFalsy (); | |
| 868 | expect(req uest.ident ifiers).to BeFalsy(); | |
| 869 | expect(res ponse.stat us).toHave BeenCalled With(400); | |
| 870 | done = tru e; | |
| 871 | return thi s; | |
| 872 | } | |
| 873 | }; | |
| 874 | var opts = _.clone (options); | |
| 875 | opts.get JPID = get JPID; | |
| 876 | opts.cre ateJPID = createJPID ; | |
| 877 | ||
| 878 | spyOn(re sponse, 's tatus').an dCallThrou gh(); | |
| 879 | spyOn(re sponse, 'j son').andC allThrough (); | |
| 880 | ||
| 881 | opts.mvi Client = { | |
| 882 | look upWithDemo graphics: function(p atientIden tifier, de mographics , callback ) { | |
| 883 | return cal lback(null , {ids: id Objects}); | |
| 884 | } | |
| 885 | }; | |
| 886 | ||
| 887 | var jdsC lientDummy = new Jds ClientDumm y(log, { | |
| 888 | jds: {} | |
| 889 | }); | |
| 890 | ||
| 891 | jdsClien tDummy._se tResponseD ata([null, null, {er ror:'ERROR !'}],[{sta tusCode: 4 04}, {stat usCode: 20 1}, null], [null, nu ll, null]) ; | |
| 892 | ||
| 893 | opts.jds Client = j dsClientDu mmy; | |
| 894 | ||
| 895 | runs(fun ction() { | |
| 896 | reso lveJPID.ca ll(opts, r equest, re sponse, fu nction() { | |
| 897 | //Should e rror out | |
| 898 | }); | |
| 899 | }); | |
| 900 | ||
| 901 | waitsFor (function( ) { | |
| 902 | retu rn done; | |
| 903 | }); | |
| 904 | }) ; | |
| 905 | it ('Error pa th: jds.st orePatient Identifier returns n ull respon se', funct ion(){ | |
| 906 | var requ est = { | |
| 907 | 'pat ientIdenti fier': SEP ARATED_IDE NTIFIER | |
| 908 | }; | |
| 909 | var done = false; | |
| 910 | var resp onse = { | |
| 911 | stat us: functi on(){ | |
| 912 | return thi s; | |
| 913 | }, | |
| 914 | json : function (){ | |
| 915 | expect(req uest.jpid) .toBeFalsy (); | |
| 916 | expect(req uest.ident ifiers).to BeFalsy(); | |
| 917 | expect(res ponse.stat us).toHave BeenCalled With(400); | |
| 918 | done = tru e; | |
| 919 | return thi s; | |
| 920 | } | |
| 921 | }; | |
| 922 | var opts = _.clone (options); | |
| 923 | opts.get JPID = get JPID; | |
| 924 | opts.cre ateJPID = createJPID ; | |
| 925 | ||
| 926 | spyOn(re sponse, 's tatus').an dCallThrou gh(); | |
| 927 | spyOn(re sponse, 'j son').andC allThrough (); | |
| 928 | ||
| 929 | opts.mvi Client = { | |
| 930 | look upWithDemo graphics: function(p atientIden tifier, de mographics , callback ) { | |
| 931 | return cal lback(null , {ids: id Objects}); | |
| 932 | } | |
| 933 | }; | |
| 934 | ||
| 935 | var jdsC lientDummy = new Jds ClientDumm y(log, { | |
| 936 | jds: {} | |
| 937 | }); | |
| 938 | ||
| 939 | jdsClien tDummy._se tResponseD ata([null, null, nul l],[{statu sCode: 404 }, {status Code: 201} , null], [ null, null , null]); | |
| 940 | ||
| 941 | opts.jds Client = j dsClientDu mmy; | |
| 942 | ||
| 943 | runs(fun ction() { | |
| 944 | reso lveJPID.ca ll(opts, r equest, re sponse, fu nction() { | |
| 945 | //Should e rror out | |
| 946 | }); | |
| 947 | }); | |
| 948 | ||
| 949 | waitsFor (function( ) { | |
| 950 | retu rn done; | |
| 951 | }); | |
| 952 | }) ; | |
| 953 | it ('Error pa th: jds.st orePatient Identifier returns u nexpected response', function( ){ | |
| 954 | var requ est = { | |
| 955 | 'pat ientIdenti fier': SEP ARATED_IDE NTIFIER | |
| 956 | }; | |
| 957 | var done = false; | |
| 958 | var resp onse = { | |
| 959 | stat us: functi on(){ | |
| 960 | return thi s; | |
| 961 | }, | |
| 962 | json : function (){ | |
| 963 | expect(req uest.jpid) .toBeFalsy (); | |
| 964 | expect(req uest.ident ifiers).to BeFalsy(); | |
| 965 | expect(res ponse.stat us).toHave BeenCalled With(400); | |
| 966 | done = tru e; | |
| 967 | return thi s; | |
| 968 | } | |
| 969 | }; | |
| 970 | var opts = _.clone (options); | |
| 971 | opts.get JPID = get JPID; | |
| 972 | opts.cre ateJPID = createJPID ; | |
| 973 | ||
| 974 | spyOn(re sponse, 's tatus').an dCallThrou gh(); | |
| 975 | spyOn(re sponse, 'j son').andC allThrough (); | |
| 976 | ||
| 977 | opts.mvi Client = { | |
| 978 | look upWithDemo graphics: function(p atientIden tifier, de mographics , callback ) { | |
| 979 | return cal lback(null , {ids: id Objects}); | |
| 980 | } | |
| 981 | }; | |
| 982 | ||
| 983 | var jdsC lientDummy = new Jds ClientDumm y(log, { | |
| 984 | jds: {} | |
| 985 | }); | |
| 986 | ||
| 987 | jdsClien tDummy._se tResponseD ata([null, null, nul l],[{statu sCode: 404 }, {status Code: 201} , {statusC ode: 500}] , [null, n ull, null] ); | |
| 988 | ||
| 989 | opts.jds Client = j dsClientDu mmy; | |
| 990 | ||
| 991 | runs(fun ction() { | |
| 992 | reso lveJPID.ca ll(opts, r equest, re sponse, fu nction() { | |
| 993 | //Should e rror out | |
| 994 | }); | |
| 995 | }); | |
| 996 | ||
| 997 | waitsFor (function( ) { | |
| 998 | retu rn done; | |
| 999 | }); | |
| 1000 | }) ; | |
| 1001 | }); | |
| 1002 | ||
| 1003 | descri be('create JPID()', f unction() { | |
| 1004 | it ('Does not alter a r equest\'s jpid prope rty if it is not fal se', funct ion() { | |
| 1005 | var requ est = new DummyReque st({}); | |
| 1006 | request. jpid = 'TE ST VALUE'; | |
| 1007 | var resp onse = new DummyResp onse(); | |
| 1008 | var next = jasmine .createSpy (); | |
| 1009 | ||
| 1010 | runs(fun ction() { | |
| 1011 | crea teJPID.cal l(options, request, response, next); | |
| 1012 | }); | |
| 1013 | ||
| 1014 | waitsFor (function( ) { | |
| 1015 | retu rn next.ca llCount > 0; | |
| 1016 | }, 'The JPID prope rty is not modified' , 100); | |
| 1017 | ||
| 1018 | runs(fun ction() { | |
| 1019 | expe ct(request .jpid).toE qual('TEST VALUE'); | |
| 1020 | }); | |
| 1021 | }) ; | |
| 1022 | ||
| 1023 | it ('Sets a r equest\'s jpid prope rty correc tly if a k nown ident ifier is s ubmitted', function( ) { | |
| 1024 | var requ est = new DummyReque st(); | |
| 1025 | request. jpid = fal se; | |
| 1026 | request. patientIde ntifier = KNOWN_IDEN TIFIER; | |
| 1027 | var resp onse = new DummyResp onse(); | |
| 1028 | var next = jasmine .createSpy (); | |
| 1029 | var opts = _.clone (options); | |
| 1030 | opts.jds Client = { | |
| 1031 | 'get PatientIde ntifier': jasmine.cr eateSpy(). andCallFak e(function (job, call back) { | |
| 1032 | var retObj = { | |
| 1033 | 'jpid' : mockIden tifierData .identifie rToJpidMap [job.patie ntIdentifi er.value] | |
| 1034 | }; | |
| 1035 | callback(n ull, { | |
| 1036 | 'statu sCode': 20 0 | |
| 1037 | }, retObj) ; | |
| 1038 | }), | |
| 1039 | 'sto rePatientI dentifier' : jasmine. createSpy( ).andCallF ake(functi on(job, ca llback) { | |
| 1040 | var retObj = { | |
| 1041 | 'jpid' : '21EC202 0-3AEA-406 9-A2DD-080 02B30309D' | |
| 1042 | }; | |
| 1043 | callback(n ull, {'sta tusCode':2 01}, retOb j); | |
| 1044 | }) | |
| 1045 | }; | |
| 1046 | opts.get JPID = get JPID; | |
| 1047 | ||
| 1048 | runs(fun ction() { | |
| 1049 | crea teJPID.cal l(opts, re quest, res ponse, nex t); | |
| 1050 | }); | |
| 1051 | ||
| 1052 | waitsFor (function( ) { | |
| 1053 | retu rn next.ca llCount > 0; | |
| 1054 | }); | |
| 1055 | ||
| 1056 | runs(fun ction() { | |
| 1057 | expe ct(request .jpid).toE qual('21EC 2020-3AEA- 4069-A2DD- 08002B3030 9D'); | |
| 1058 | }); | |
| 1059 | }) ; | |
| 1060 | ||
| 1061 | it ('Sets a r equest\'s jpid prope rty to a n ew JPID if an unknow n identifi er is subm itted', fu nction() { | |
| 1062 | var requ est = new DummyReque st(); | |
| 1063 | request. jpid = fal se; | |
| 1064 | request. patientIde ntifier = UNKNOWN_ID ENTIFIER; | |
| 1065 | var resp onse = new DummyResp onse(); | |
| 1066 | var next = jasmine .createSpy (); | |
| 1067 | var opts = _.clone (options); | |
| 1068 | opts.jds Client = { | |
| 1069 | 'get PatientIde ntifier': jasmine.cr eateSpy(). andCallFak e(function (job, call back) { | |
| 1070 | var retObj = { | |
| 1071 | 'jpid' : '21EC202 0-3AEA-406 9-A2DD-FFF FFFFFFFFF' | |
| 1072 | }; | |
| 1073 | callback(n ull, { | |
| 1074 | 'statu sCode': 20 0 | |
| 1075 | }, retObj) ; | |
| 1076 | }), | |
| 1077 | 'sto rePatientI dentifier' : jasmine. createSpy( ).andCallF ake(functi on(job, ca llback) { | |
| 1078 | var retObj = { | |
| 1079 | 'jpid' : '21EC202 0-3AEA-406 9-A2DD-FFF FFFFFFFFF' | |
| 1080 | }; | |
| 1081 | callback(n ull, {'sta tusCode':2 01}, retOb j); | |
| 1082 | }) | |
| 1083 | }; | |
| 1084 | opts.get JPID = get JPID; | |
| 1085 | ||
| 1086 | runs(fun ction() { | |
| 1087 | crea teJPID.cal l(opts, re quest, res ponse, nex t); | |
| 1088 | }); | |
| 1089 | ||
| 1090 | waitsFor (function( ) { | |
| 1091 | retu rn next.ca llCount > 0; | |
| 1092 | }); | |
| 1093 | ||
| 1094 | runs(fun ction() { | |
| 1095 | expe ct(request .jpid).toM atch(/[0-9 A-F]{8}(?: -[0-9A-F]{ 4}){3}-[0- 9A-F]{12}/ ); | |
| 1096 | expe ct(request .jpid).toN otMatch(/2 1EC2020-3A EA-4069-A2 DD-08002B3 0309D/); | |
| 1097 | expe ct(request .jpid).toN otMatch(/2 1EC2020-3A EA-4069-A2 DD-[A]{12} /); | |
| 1098 | expe ct(request .jpid).toN otMatch(/2 1EC2020-3A EA-4069-A2 DD-[B]{12} /); | |
| 1099 | expe ct(request .jpid).toN otMatch(/2 1EC2020-3A EA-4069-A2 DD-[C]{12} /); | |
| 1100 | }); | |
| 1101 | }) ; | |
| 1102 | ||
| 1103 | it ('Error pa th: error returned b y JDS', fu nction() { | |
| 1104 | var requ est = new DummyReque st(); | |
| 1105 | request. jpid = fal se; | |
| 1106 | request. patientIde ntifier = UNKNOWN_ID ENTIFIER; | |
| 1107 | var resp onse = new DummyResp onse(); | |
| 1108 | var next = jasmine .createSpy (); | |
| 1109 | var opts = _.clone (options); | |
| 1110 | opts.jds Client = { | |
| 1111 | 'sto rePatientI dentifier' : jasmine. createSpy( ).andCallF ake(functi on(job, ca llback) { | |
| 1112 | callback({ error:'ERR OR!'}, nul l); | |
| 1113 | }) | |
| 1114 | }; | |
| 1115 | ||
| 1116 | spyOn(re sponse, 's tatus').an dCallThrou gh(); | |
| 1117 | ||
| 1118 | opts.get JPID = get JPID; | |
| 1119 | ||
| 1120 | runs(fun ction() { | |
| 1121 | crea teJPID.cal l(opts, re quest, res ponse, nex t); | |
| 1122 | }); | |
| 1123 | ||
| 1124 | waitsFor (function( ) { | |
| 1125 | retu rn respons e.status.c allCount > 0; | |
| 1126 | }); | |
| 1127 | ||
| 1128 | runs(fun ction() { | |
| 1129 | expe ct(respons e.status). toHaveBeen CalledWith (400); | |
| 1130 | }); | |
| 1131 | }) ; | |
| 1132 | ||
| 1133 | it ('Error pa th: null r esponse re turned by JDS', func tion() { | |
| 1134 | var requ est = new DummyReque st(); | |
| 1135 | request. jpid = fal se; | |
| 1136 | request. patientIde ntifier = UNKNOWN_ID ENTIFIER; | |
| 1137 | var resp onse = new DummyResp onse(); | |
| 1138 | var next = jasmine .createSpy (); | |
| 1139 | var opts = _.clone (options); | |
| 1140 | opts.jds Client = { | |
| 1141 | 'sto rePatientI dentifier' : jasmine. createSpy( ).andCallF ake(functi on(job, ca llback) { | |
| 1142 | callback(n ull, null) ; | |
| 1143 | }) | |
| 1144 | }; | |
| 1145 | ||
| 1146 | spyOn(re sponse, 's tatus').an dCallThrou gh(); | |
| 1147 | ||
| 1148 | opts.get JPID = get JPID; | |
| 1149 | ||
| 1150 | runs(fun ction() { | |
| 1151 | crea teJPID.cal l(opts, re quest, res ponse, nex t); | |
| 1152 | }); | |
| 1153 | ||
| 1154 | waitsFor (function( ) { | |
| 1155 | retu rn respons e.status.c allCount > 0; | |
| 1156 | }); | |
| 1157 | ||
| 1158 | runs(fun ction() { | |
| 1159 | expe ct(respons e.status). toHaveBeen CalledWith (400); | |
| 1160 | }); | |
| 1161 | }) ; | |
| 1162 | ||
| 1163 | it ('Error pa th: unexpe cted respo nse return ed by JDS' , function () { | |
| 1164 | var requ est = new DummyReque st(); | |
| 1165 | request. jpid = fal se; | |
| 1166 | request. patientIde ntifier = UNKNOWN_ID ENTIFIER; | |
| 1167 | var resp onse = new DummyResp onse(); | |
| 1168 | var next = jasmine .createSpy (); | |
| 1169 | var opts = _.clone (options); | |
| 1170 | opts.jds Client = { | |
| 1171 | 'sto rePatientI dentifier' : jasmine. createSpy( ).andCallF ake(functi on(job, ca llback) { | |
| 1172 | callback(n ull, {stat usCode: 50 0}); | |
| 1173 | }) | |
| 1174 | }; | |
| 1175 | ||
| 1176 | spyOn(re sponse, 's tatus').an dCallThrou gh(); | |
| 1177 | ||
| 1178 | opts.get JPID = get JPID; | |
| 1179 | ||
| 1180 | runs(fun ction() { | |
| 1181 | crea teJPID.cal l(opts, re quest, res ponse, nex t); | |
| 1182 | }); | |
| 1183 | ||
| 1184 | waitsFor (function( ) { | |
| 1185 | retu rn respons e.status.c allCount > 0; | |
| 1186 | }); | |
| 1187 | ||
| 1188 | runs(fun ction() { | |
| 1189 | expe ct(respons e.status). toHaveBeen CalledWith (400); | |
| 1190 | }); | |
| 1191 | }) ; | |
| 1192 | }); | |
| 1193 | }); |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.