Produced by Araxis Merge on 10/3/2017 11:16:03 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\handlers\jmeadows-xform-domain-vpr | jmeadows-xform-domain-vpr-handler-spec.js | Mon Jul 10 17:46:22 2017 UTC |
| 2 | ehmp.zip\ehmp\ehmp\product\production\vx-sync\tests\unittests\handlers\jmeadows-xform-domain-vpr | jmeadows-xform-domain-vpr-handler-spec.js | Tue Oct 3 13:17:52 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 3 | 1630 |
| 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 | var _ = re quire('und erscore'); | |
| 5 | var util = require(' util'); | |
| 6 | var moment = require ('moment') ; | |
| 7 | ||
| 8 | var handle r = requir e(global.V X_HANDLERS + 'jmeado ws-xform-d omain-vpr/ jmeadows-x form-domai n-vpr-hand ler'); | |
| 9 | var log = require(gl obal.VX_DU MMIES + 'd ummy-logge r'); | |
| 10 | // Be sure next line s are comm ented out before pus hing | |
| 11 | // log = r equire('bu nyan').cre ateLogger( { | |
| 12 | // nam e: 'jmeado ws-xform-d omain-vpr- handler-sp ec', | |
| 13 | // lev el: 'debug ' | |
| 14 | // }); | |
| 15 | ||
| 16 | var jmeado wsVersion = '2.3.0'; | |
| 17 | var jmeado wsUnitPath = 'v2_3_0 '; | |
| 18 | var jmeado wsSoapPath = 'jmeado ws_v2_3_0' ; | |
| 19 | ||
| 20 | var mockCo nfig = { | |
| 21 | jmeado ws: { | |
| 22 | ve rsion: jme adowsVersi on, | |
| 23 | do mains: ['a llergy'] | |
| 24 | }, | |
| 25 | jds: { | |
| 26 | pr otocol: 'h ttp', | |
| 27 | host: ' IP ', | |
| 28 | port: PORT | |
| 29 | } | |
| 30 | }; | |
| 31 | ||
| 32 | var JdsCli entDummy = require(g lobal.VX_D UMMIES + ' jds-client -dummy'); | |
| 33 | var jdsCli entDummy = new JdsCl ientDummy( log, mockC onfig); | |
| 34 | ||
| 35 | var mockEn vironment = { | |
| 36 | publis herRouter: { | |
| 37 | pu blish: fun ction(jobs ToPublish, callback) { | |
| 38 | callback (null, 'su ccess'); | |
| 39 | } | |
| 40 | }, | |
| 41 | jds: j dsClientDu mmy | |
| 42 | }; | |
| 43 | var mockHa ndlerCallb ack = { | |
| 44 | callba ck: functi on() { | |
| 45 | // console.l og('callba ck'); | |
| 46 | // console.l og(error); | |
| 47 | // console.l og(respons e); | |
| 48 | } | |
| 49 | }; | |
| 50 | var dodIte ms = requi re('../../ ../data/se condary/'+ jmeadowsSo apPath+'/a llergySoap '); | |
| 51 | ||
| 52 | describe(' jmeadows-x form-domai n-vpr-hand ler', func tion() { | |
| 53 | ||
| 54 | descri be('xformI temCollect ion', func tion() { | |
| 55 | ||
| 56 | va r mockRequ estStampTi me = '2014 0113154827 .356'; | |
| 57 | ||
| 58 | va r allergyX former = r equire('.. /../../../ handlers/j meadows-xf orm-domain -vpr/'+jme adowsUnitP ath+'/jmea dows-aller gy-xformer '); | |
| 59 | va r labXform er = requi re('../../ ../../hand lers/jmead ows-xform- domain-vpr /'+jmeadow sUnitPath+ '/jmeadows -lab-xform er'); | |
| 60 | va r vitalXfo rmer = req uire('../. ./../../ha ndlers/jme adows-xfor m-domain-v pr/'+'v2_3 _3_0_2'+'/ jmeadows-v ital-xform er'); | |
| 61 | ||
| 62 | ||
| 63 | va r mockEdip i = '00000 099'; | |
| 64 | ||
| 65 | va r sampleDO DAllergy = { | |
| 66 | cdrEvent Id: 100000 1128, | |
| 67 | codes: [ { | |
| 68 | code : 7090000, | |
| 69 | syst em: 'DOD_A LLERGY_IEN ' | |
| 70 | }, { | |
| 71 | code : 'C003749 4', | |
| 72 | disp lay: 'Sodi um Chlorid e', | |
| 73 | syst em: 'UMLS' | |
| 74 | }], | |
| 75 | site: { | |
| 76 | agen cy: 'DOD', | |
| 77 | moni ker: 'NH G reat Lakes IL/0056', | |
| 78 | name : 'AHLTA', | |
| 79 | site Code: '2.1 6.840.1.11 3883.3.42. 126.100001 .13' | |
| 80 | }, | |
| 81 | sourcePr otocol: 'D ODADAPTER' , | |
| 82 | allergyN ame: 'SODI UM CHLORID E {Class}' , | |
| 83 | uid: 'ur n:va:aller gy:DOD:000 00099:1000 001128', | |
| 84 | comment: 'Nausea' | |
| 85 | }; | |
| 86 | ||
| 87 | va r sampleVP RAllergy = { | |
| 88 | products : [{ | |
| 89 | name : 'SODIUM CHLORIDE { Class}' | |
| 90 | }], | |
| 91 | summary: 'SODIUM C HLORIDE {C lass}', | |
| 92 | codes: [ { | |
| 93 | code : 7090000, | |
| 94 | syst em: 'DOD_A LLERGY_IEN ' | |
| 95 | }, { | |
| 96 | code : 'C003749 4', | |
| 97 | disp lay: 'Sodi um Chlorid e', | |
| 98 | syst em: 'urn:o id:2.16.84 0.1.113883 .6.86' | |
| 99 | }], | |
| 100 | comments : [{ | |
| 101 | comm ent: 'Naus ea' | |
| 102 | }], | |
| 103 | facility Name: 'DOD ', | |
| 104 | facility Code: 'DOD ', | |
| 105 | kind: 'A llergy/Adv erse React ion', | |
| 106 | uid: 'ur n:va:aller gy:DOD:000 00099:1000 001128', | |
| 107 | pid: 'DO D;00000099 ', | |
| 108 | stampTim e: '201401 13154827.3 56' | |
| 109 | }; | |
| 110 | ||
| 111 | va r sampleDo dLab = { | |
| 112 | 'cdrEven tId': '100 0010437', | |
| 113 | 'codes': [{ | |
| 114 | 'cod e': '6827' , | |
| 115 | 'dis play': nul l, | |
| 116 | 'sys tem': 'DOD _NCID' | |
| 117 | }, { | |
| 118 | 'cod e': '2823- 3', | |
| 119 | 'dis play': 'Po tassium [M oles/volum e] in Seru m or Plasm a', | |
| 120 | 'sys tem': 'LOI NC' | |
| 121 | }], | |
| 122 | 'patient Id': null, | |
| 123 | 'patient Name': nul l, | |
| 124 | 'site': { | |
| 125 | 'age ncy': 'DOD ', | |
| 126 | 'dmi sId': null , | |
| 127 | 'end points': [ ], | |
| 128 | 'id' : null, | |
| 129 | 'mon iker': 'NH Great Lak es IL/0056 ', | |
| 130 | 'nam e': 'AHLTA ', | |
| 131 | 'per missions': [], | |
| 132 | 'reg ion': null , | |
| 133 | 'sit eCode': '2 .16.840.1. 113883.3.4 2.126.1000 01.13', | |
| 134 | 'sta tus': null | |
| 135 | }, | |
| 136 | 'sourceP rotocol': 'DODADAPTE R', | |
| 137 | 'accessi on': '1305 05 BCH 165 9^CH', | |
| 138 | 'comment ': '3001 G REENBAY RO AD ATTENTI ON LABORAT ORY SERVIC ES NORTH C HICAGO, IL 60064 55 6 = NORTH CHICAGO VE TERAN\'S A DMINISTRAT ION HOSP T est perfor med at:', | |
| 139 | 'facilit yName': 'N H Great La kes IL/005 6', | |
| 140 | 'hiLoFla g': 'Highe r Than Nor mal', | |
| 141 | 'orderDa te': 13677 63000000, | |
| 142 | 'orderId ': '215754 6463', | |
| 143 | 'printNa me': null, | |
| 144 | 'referen ceRange': '3.5-4.7', | |
| 145 | 'result' : '5.4', | |
| 146 | 'resultD ate': 1367 755560000, | |
| 147 | 'resultS tatus': nu ll, | |
| 148 | 'specime n': 'PLASM A', | |
| 149 | 'station Number': n ull, | |
| 150 | 'testId' : null, | |
| 151 | 'testNam e': 'Potas sium, Seru m or Plasm a Quantita tive', | |
| 152 | 'units': 'mmol/L', | |
| 153 | 'verifie dBy': '' | |
| 154 | }; | |
| 155 | ||
| 156 | va r sampleDO DVitals = [ | |
| 157 | { 'cdr EventId' : '10000005 82', | |
| 158 | 'cod es' : [ { 'code' : ' 959595', ' display' : null, 'sy stem' : 'D OD_NCID' } ], | |
| 159 | 'pat ientId' : null, | |
| 160 | 'pat ientName' : null, | |
| 161 | 'sit e' : { 'ag ency' : 'D OD', 'dmis Id' : null , 'endpoin ts' : [ ], 'id' : nu ll, | |
| 162 | 'mo niker' : ' Tripler AM C, HI', 'n ame' : 'AH LTA', 'per missions' : [ ], 're gion' : nu ll, | |
| 163 | 'si teCode' : '2.16.840. 1.113883.3 .42.126.10 0001.13', 'status' : null | |
| 164 | }, | |
| 165 | 'sou rceProtoco l' : 'DODA DAPTER', | |
| 166 | 'dat eTimeTaken ' : 141515 2140000, | |
| 167 | 'qua lifiers' : null, | |
| 168 | 'rat e' : '0/10 ', | |
| 169 | 'uni ts' : 'Adu lt', | |
| 170 | 'uni tsCode' : '9170', | |
| 171 | 'vit alType' : 'PAIN', | |
| 172 | 'vit alsIEN' : '215758433 1' | |
| 173 | }, | |
| 174 | { 'cdr EventId' : '10000005 82', | |
| 175 | 'cod es' : [ { 'code' : ' 2051', 'di splay' : n ull, 'syst em' : 'DOD _NCID' } ] , | |
| 176 | 'pat ientId' : null, | |
| 177 | 'pat ientName' : null, | |
| 178 | 'sit e' : { 'ag ency' : 'D OD', 'dmis Id' : null , 'endpoin ts' : [ ], 'id' : nu ll, | |
| 179 | 'mo niker' : ' Tripler AM C, HI', 'n ame' : 'AH LTA', 'per missions' : [ ], 're gion' : nu ll, | |
| 180 | 'si teCode' : '2.16.840. 1.113883.3 .42.126.10 0001.13', 'status' : null | |
| 181 | }, | |
| 182 | 'sou rceProtoco l' : 'DODA DAPTER', | |
| 183 | 'dat eTimeTaken ' : 141515 2140000, | |
| 184 | 'qua lifiers' : null, | |
| 185 | 'rat e' : '70', | |
| 186 | 'uni ts' : '/mi n', | |
| 187 | 'uni tsCode' : '1762', | |
| 188 | 'vit alType' : 'PULSE', | |
| 189 | 'vit alsIEN' : '215758433 1' | |
| 190 | } | |
| 191 | ]; | |
| 192 | ||
| 193 | ||
| 194 | va r sampleIt emCollecti on = | |
| 195 | [ | |
| 196 | null , { | |
| 197 | site: { | |
| 198 | agency : 'VA', | |
| 199 | monike r: 'VA', | |
| 200 | name: 'VA', | |
| 201 | siteCo de: 'VA' | |
| 202 | }, | |
| 203 | allergyNam e: 'Connec tion unava ilable.' | |
| 204 | }, { | |
| 205 | site: { | |
| 206 | agency : 'DOD', | |
| 207 | monike r: 'DODADA PTER_SOURC E_STATUS_R EPORT', | |
| 208 | name: 'DODADAPTE R_SOURCE_S TATUS_REPO RT', | |
| 209 | siteCo de: 'DOD' | |
| 210 | }, | |
| 211 | allergyNam e: '<div c lass=\'tit le\'>Sourc e Status L ist<\/div> <table><th ead><th sc ope=\'col\ ' class=\' table-head er\'>Sourc e Name<\/t h><th scop e=\'col\' class=\'ta ble-header \'>Source Status<\/t h><\/thead ><tbody><t r class=\' even\'><td >AHLTA<\/t d><td>UNKN OWN, IN_PR OGRESS, CO MPLETE<\/t d><\/tr><t r class=\' odd\'><td> SHARE: PO RTSMOUTH<\ /td><td>UN KNOWN, IN_ PROGRESS, COMPLETE_W ITH_ERRORS <\/td><\/t r><tr clas s=\'even\' ><td>VA<\/ td><td>UP, IN_PROGRE SS, COMPLE TE<\/td><\ /tr><\/tbo dy><\/tabl e><br/><br /><div cla ss=\'title \'>Errors< \/div><tab le><thead> <th scope= \'col\' co lspan=\'2\ ' class=\' table-head er\'>Error Code<\/th ><\/thead> <tr class= \'even\'>< td align=\ 'center\'> <div style =\'margin: 10px;backg round-colo r:red;widt h:15px;\'> <\/div><\/ td><td>XDS Repository Error<\/td ><\/tr><\/ tbody><\/t able>' | |
| 212 | }, | |
| 213 | samp leDODAller gy | |
| 214 | ]; | |
| 215 | ||
| 216 | de scribe('No rmal path' , function () { | |
| 217 | var vprI tems = han dler._step s._xformIt emCollecti on(log, 'a llergy', s ampleItemC ollection, mockEdipi , allergyX former, mo ckRequestS tampTime); | |
| 218 | ||
| 219 | it('resu lt include s sample V PR allergy ', functio n() { | |
| 220 | expe ct(vprItem s).toConta in(sampleV PRAllergy) ; | |
| 221 | }); | |
| 222 | ||
| 223 | it('resu lt include s stampTim e', functi on() { | |
| 224 | expe ct(vprItem s[0].stamp Time).toBe Truthy(); | |
| 225 | }); | |
| 226 | ||
| 227 | it('excl udes null items and items that lack cdrE ventId (su ch as DOD Adaptor St atus Repor t)', funct ion() { | |
| 228 | expe ct(vprItem s.length). toEqual(1) ; | |
| 229 | }); | |
| 230 | }) ; | |
| 231 | de scribe('Er ror path: unable to transform record', f unction() { | |
| 232 | it('Erro r is logge d when lab is missin g orderDat e', functi on() { | |
| 233 | dele te sampleD odLab.orde rDate; | |
| 234 | spyO n(log, 'er ror'); | |
| 235 | ||
| 236 | var vprItems = handler._ steps._xfo rmItemColl ection(log , 'lab', [ sampleDodL ab], mockE dipi, labX former, mo ckRequestS tampTime); | |
| 237 | expe ct(log.err or).toHave BeenCalled (); | |
| 238 | expe ct(_.isEmp ty(vprItem s)).toBe(t rue); | |
| 239 | }); | |
| 240 | }) ; | |
| 241 | ||
| 242 | de scribe('No rmal Path with multi ple vitals , same cdr EventId', function() { | |
| 243 | it('incl udes two v itals with unique ui ds', funct ion() { | |
| 244 | var vprItems = handler._ steps._xfo rmItemColl ection(log , 'vital', sampleDOD Vitals, mo ckEdipi, v italXforme r, mockReq uestStampT ime); | |
| 245 | expe ct(vprItem s.length). toEqual(2) ; | |
| 246 | expe ct(vprItem s.map(func tion(vprRe cord){retu rn vprReco rd.uid}).s ort()).toE qual(['urn :va:vital: DOD:000000 99:1000000 582-2051', 'urn:va:v ital:DOD:0 0000099:10 00000582-9 59595'].so rt()) | |
| 247 | }); | |
| 248 | }) ; | |
| 249 | }); | |
| 250 | ||
| 251 | descri be('getDem ographicsI cnFromJds' , function () { | |
| 252 | va r jdsClien tDummy = n ew JdsClie ntDummy(lo g, mockCon fig); | |
| 253 | ||
| 254 | it ('Good res ponse path ', functio n() { | |
| 255 | var done = false; | |
| 256 | ||
| 257 | var expe ctedJdsRes ponse = { | |
| 258 | stat usCode: 20 0, | |
| 259 | }; | |
| 260 | var expe ctedJdsRes ult = { | |
| 261 | jpid : 'aaa-aaa aa-aaaaaaa aaaa', | |
| 262 | pati entIdentif iers: [ | |
| 263 | '10108V420 871' | |
| 264 | ] | |
| 265 | }; | |
| 266 | ||
| 267 | jdsClien tDummy._se tResponseD ata(null, expectedJd sResponse, expectedJ dsResult); | |
| 268 | ||
| 269 | handler. _steps._ge tDemograph icsIcnFrom Jds('DOD;0 000000003' , log, jds ClientDumm y, functio n(error, r esponse) { | |
| 270 | expe ct(error). toBeFalsy( ); | |
| 271 | expe ct(respons e).toBeTru thy(); | |
| 272 | expe ct(respons e).toEqual ('10108V42 0871'); | |
| 273 | done = true; | |
| 274 | }); | |
| 275 | }) ; | |
| 276 | ||
| 277 | it ('Error co ndition: N o icn foun d', functi on() { | |
| 278 | var done = false; | |
| 279 | ||
| 280 | var expe ctedJdsRes ponse = { | |
| 281 | stat usCode: 20 0, | |
| 282 | }; | |
| 283 | var expe ctedJdsRes ult = { | |
| 284 | jpid : 'aaa-aaa aa-aaaaaaa aaaa', | |
| 285 | pati entIdentif iers: [ | |
| 286 | 'DOD;00000 00003' | |
| 287 | ] | |
| 288 | }; | |
| 289 | ||
| 290 | jdsClien tDummy._se tResponseD ata(null, expectedJd sResponse, expectedJ dsResult); | |
| 291 | ||
| 292 | handler. _steps._ge tDemograph icsIcnFrom Jds('DOD;0 000000003' , log, jds ClientDumm y, functio n(error, r esponse) { | |
| 293 | expe ct(error). toBeTruthy (); | |
| 294 | expe ct(error). toEqual('N oIcnFound' ); | |
| 295 | expe ct(respons e).toBeFal sy(); | |
| 296 | done = true; | |
| 297 | }); | |
| 298 | }) ; | |
| 299 | it ('Error co ndition: J DS error', function( ) { | |
| 300 | var done = false; | |
| 301 | ||
| 302 | var expe ctedJdsRes ponse = nu ll; | |
| 303 | var expe ctedJdsRes ult = {}; | |
| 304 | ||
| 305 | jdsClien tDummy._se tResponseD ata({}, ex pectedJdsR esponse, e xpectedJds Result); | |
| 306 | ||
| 307 | handler. _steps._ge tDemograph icsIcnFrom Jds('DOD;0 000000003' , log, jds ClientDumm y, functio n(error, r esponse) { | |
| 308 | expe ct(error). toBeTruthy (); | |
| 309 | expe ct(respons e).toBeFal sy(); | |
| 310 | expe ct(error). toEqual('F ailedJdsEr ror'); | |
| 311 | done = true; | |
| 312 | }); | |
| 313 | }) ; | |
| 314 | it ('Error co ndition: N o response ', functio n() { | |
| 315 | var done = false; | |
| 316 | ||
| 317 | var expe ctedJdsRes ponse = nu ll; | |
| 318 | var expe ctedJdsRes ult = {}; | |
| 319 | ||
| 320 | jdsClien tDummy._se tResponseD ata(null, expectedJd sResponse, expectedJ dsResult); | |
| 321 | ||
| 322 | handler. _steps._ge tDemograph icsIcnFrom Jds('DOD;0 000000003' , log, jds ClientDumm y, functio n(error, r esponse) { | |
| 323 | expe ct(error). toBeTruthy (); | |
| 324 | expe ct(respons e).toBeFal sy(); | |
| 325 | expe ct(error). toEqual('F ailedJdsNo Response') ; | |
| 326 | done = true; | |
| 327 | }); | |
| 328 | }) ; | |
| 329 | it ('Error co ndition: W rong statu s code', f unction() { | |
| 330 | var done = false; | |
| 331 | ||
| 332 | var expe ctedJdsRes ponse = { | |
| 333 | stat usCode: 40 4, | |
| 334 | }; | |
| 335 | var expe ctedJdsRes ult = {}; | |
| 336 | ||
| 337 | jdsClien tDummy._se tResponseD ata(null, expectedJd sResponse, expectedJ dsResult); | |
| 338 | ||
| 339 | handler. _steps._ge tDemograph icsIcnFrom Jds('DOD;0 000000003' , log, jds ClientDumm y, functio n(error, r esponse) { | |
| 340 | expe ct(error). toBeTruthy (); | |
| 341 | expe ct(respons e).toBeFal sy(); | |
| 342 | expe ct(error). toEqual('F ailedJdsWr ongStatusC ode'); | |
| 343 | done = true; | |
| 344 | }); | |
| 345 | }) ; | |
| 346 | it ('Error co ndition: N o jpid', f unction() { | |
| 347 | var done = false; | |
| 348 | ||
| 349 | var expe ctedJdsRes ponse = { | |
| 350 | stat usCode: 20 0, | |
| 351 | }; | |
| 352 | var expe ctedJdsRes ult = { | |
| 353 | pati entIdentif iers: [ | |
| 354 | 'DOD;00000 00003' | |
| 355 | ] | |
| 356 | }; | |
| 357 | ||
| 358 | jdsClien tDummy._se tResponseD ata(null, expectedJd sResponse, expectedJ dsResult); | |
| 359 | ||
| 360 | handler. _steps._ge tDemograph icsIcnFrom Jds('DOD;0 000000003' , log, jds ClientDumm y, functio n(error, r esponse) { | |
| 361 | expe ct(error). toBeTruthy (); | |
| 362 | expe ct(respons e).toBeFal sy(); | |
| 363 | expe ct(error). toEqual('F ailedNoJpi dInResult' ); | |
| 364 | done = true; | |
| 365 | }); | |
| 366 | }) ; | |
| 367 | }); | |
| 368 | ||
| 369 | descri be('handle ', functio n() { | |
| 370 | be foreEach(f unction() { | |
| 371 | spyOn(mo ckHandlerC allback, ' callback') ; | |
| 372 | }) ; | |
| 373 | ||
| 374 | it ('error co ndition: i ncorrect j ob type', function() { | |
| 375 | var done = false; | |
| 376 | ||
| 377 | runs(fun ction() { | |
| 378 | var job = {}; | |
| 379 | job. type = 'hd r-xform-vp r'; | |
| 380 | job. record = { }; | |
| 381 | //jo b.record.d ata = {}; | |
| 382 | //jo b.record.d ata.items = {}; | |
| 383 | job. jpid = 'aa a-aaaaa-aa aaaaaaaaa' ; | |
| 384 | ||
| 385 | job. patientIde ntifier = { | |
| 386 | type: 'icn ', | |
| 387 | value: '00 000V00000' | |
| 388 | }; | |
| 389 | ||
| 390 | //sp yOn(mockHa ndlerCallb ack, 'call back'); | |
| 391 | ||
| 392 | hand ler(log, m ockConfig, mockEnvir onment, jo b, functio n() { | |
| 393 | done = tru e; | |
| 394 | mockHandle rCallback. callback() ; | |
| 395 | }); | |
| 396 | }); | |
| 397 | ||
| 398 | waitsFor (function( ) { | |
| 399 | retu rn done; | |
| 400 | }, 'Call back not c alled', 10 0); | |
| 401 | ||
| 402 | runs(fun ction() { | |
| 403 | expe ct(mockHan dlerCallba ck.callbac k).toHaveB eenCalled( ); | |
| 404 | }); | |
| 405 | }) ; | |
| 406 | it ('error co ndition: w rong patie nt identif ier', func tion() { | |
| 407 | var done = false; | |
| 408 | runs(fun ction() { | |
| 409 | var job = {}; | |
| 410 | job. type = 'jm eadows-xfo rm-allergy -vpr'; | |
| 411 | job. dataDomain = 'allerg y'; | |
| 412 | job. record = d odItems; / /{}; | |
| 413 | //jo b.record.d ata = {}; | |
| 414 | //jo b.record.d ata.items = dodItems ; | |
| 415 | job. requestSta mpTime = ' 2014010212 0059.000'; | |
| 416 | job. jpid = 'aa a-aaaaa-aa aaaaaaaaa' ; | |
| 417 | job. icn = '000 00V00000'; | |
| 418 | ||
| 419 | job. patientIde ntifier = { | |
| 420 | type: 'pid ', | |
| 421 | value: '9E 7A;3' | |
| 422 | }; | |
| 423 | ||
| 424 | //sp yOn(mockHa ndlerCallb ack, 'call back'); | |
| 425 | ||
| 426 | hand ler(log, m ockConfig, mockEnvir onment, jo b, functio n() { | |
| 427 | done = tru e; | |
| 428 | mockHandle rCallback. callback() ; | |
| 429 | }); | |
| 430 | ||
| 431 | wait sFor(funct ion() { | |
| 432 | return don e; | |
| 433 | }, ' Callback n ot called' , 100); | |
| 434 | ||
| 435 | runs (function( ) { | |
| 436 | expect(moc kHandlerCa llback.cal lback).toH aveBeenCal led(); | |
| 437 | }); | |
| 438 | }); | |
| 439 | }) ; | |
| 440 | it ('error co ndition: i nvalid dom ain type', function( ) { | |
| 441 | var done = false; | |
| 442 | runs(fun ction() { | |
| 443 | var job = {}; | |
| 444 | job. type = 'jm eadows-xfo rm-allergy -vpr'; | |
| 445 | job. dataDomain = 'fake d omain'; | |
| 446 | job. record = d odItems; / /{}; | |
| 447 | //jo b.record.d ata = {}; | |
| 448 | job. requestSta mpTime = ' 2014010212 0059.000'; | |
| 449 | //jo b.record.d ata.items = dodItems ; | |
| 450 | job. jpid = 'aa a-aaaaa-aa aaaaaaaaa' ; | |
| 451 | ||
| 452 | job. patientIde ntifier = { | |
| 453 | type: 'edi pi', | |
| 454 | value: '00 00096' | |
| 455 | }; | |
| 456 | ||
| 457 | //sp yOn(mockHa ndlerCallb ack, 'call back'); | |
| 458 | ||
| 459 | hand ler(log, m ockConfig, mockEnvir onment, jo b, functio n() { | |
| 460 | done = tru e; | |
| 461 | mockHandle rCallback. callback() ; | |
| 462 | }); | |
| 463 | }); | |
| 464 | ||
| 465 | waitsFor (function( ) { | |
| 466 | retu rn done; | |
| 467 | }, 'Call back not c alled', 10 0); | |
| 468 | ||
| 469 | runs(fun ction() { | |
| 470 | expe ct(mockHan dlerCallba ck.callbac k).toHaveB eenCalled( ); | |
| 471 | }); | |
| 472 | }) ; | |
| 473 | de scribe('tr ansformati on and job creation' , function () { | |
| 474 | beforeEa ch(functio n() { | |
| 475 | spyO n(mockEnvi ronment.pu blisherRou ter, 'publ ish').andC allThrough (); | |
| 476 | spyO n(jdsClien tDummy, 's aveSyncSta tus').andC allThrough (); | |
| 477 | }); | |
| 478 | ||
| 479 | it('shou ld publish a separat e job for each trans formed dat a item fro m sample d ata', func tion() { | |
| 480 | log. debug('jme adows-xfor m-domain-v pr-handler -spec: *** ** STARTIN G TEST NOW ********' ); | |
| 481 | ||
| 482 | var job = {}; | |
| 483 | job. type = 'jm eadows-xfo rm-allergy -vpr'; | |
| 484 | job. dataDomain = 'allerg y'; | |
| 485 | job. record = d odItems; / /{}; | |
| 486 | //jo b.record.d ata = {}; | |
| 487 | //jo b.record.d ata.items = dodItems ; | |
| 488 | job. requestSta mpTime = ' 2014010212 0059.000'; | |
| 489 | job. jpid = 'aa a-aaaaa-aa aaaaaaaaa' ; | |
| 490 | job. icn = '9E7 A;3'; | |
| 491 | job. patientIde ntifier = { | |
| 492 | type: 'pid ', | |
| 493 | value: 'DO D;00001' | |
| 494 | }; | |
| 495 | job. referenceI nfo = { | |
| 496 | sessionId: 'sessionI d', | |
| 497 | requestId: 'requestI d' | |
| 498 | }; | |
| 499 | ||
| 500 | var expectedJd sResponse = { | |
| 501 | statusCode : 200 | |
| 502 | }; | |
| 503 | jdsC lientDummy ._setRespo nseData(nu ll, expect edJdsRespo nse, null) ; | |
| 504 | ||
| 505 | var finished = false; | |
| 506 | var actualErro r; | |
| 507 | var actualResp onse; | |
| 508 | runs (function( ) { | |
| 509 | handler(lo g, mockCon fig, mockE nvironment , job, fun ction(erro r, respons e) { | |
| 510 | actual Error = er ror; | |
| 511 | actual Response = response; | |
| 512 | finish ed = true; | |
| 513 | }); | |
| 514 | }); | |
| 515 | ||
| 516 | wait sFor(funct ion() { | |
| 517 | return fin ished; | |
| 518 | }, ' Call to ha ndler fail ed to retu rn in time .', 1000); | |
| 519 | ||
| 520 | runs (function( ) { | |
| 521 | log.debug( 'jmeadows- xform-doma in-vpr-han dler-spec: ***** DON E WAITING ********') ; | |
| 522 | ||
| 523 | //Get info rmation ab out calls made to pu blisherRou ter.publis h | |
| 524 | //-------- ---------- ---------- ---------- ---------- ---------- -- | |
| 525 | var publis hCalls = m ockEnviron ment.publi sherRouter .publish.c alls; | |
| 526 | log.debug( 'jmeadows- xform-doma in-vpr-han dler-spec: publishCa lls: %j', publishCal ls); | |
| 527 | ||
| 528 | expect(pub lishCalls[ 0].args[0] .length).t oEqual(3); | |
| 529 | ||
| 530 | log.debug( 'jmeadows- xform-doma in-vpr-han dler-spec: ***** AFT ER TEST NO W ******** '); | |
| 531 | ||
| 532 | //Get jobs published and compa re them to expected jobs | |
| 533 | var jobsPu blished = publishCal ls[0].args [0]; | |
| 534 | var expect edJobs = [ { | |
| 535 | 'type' : 'event-p rioritizat ion-reques t', | |
| 536 | 'patie ntIdentifi er': { | |
| 537 | 't ype': 'pid ', | |
| 538 | 'v alue': 'DO D;00001' | |
| 539 | }, | |
| 540 | 'jpid' : 'aaa-aaa aa-aaaaaaa aaaa', | |
| 541 | 'dataD omain': 'a llergy', | |
| 542 | 'recor d': { | |
| 543 | 'p roducts': [{ | |
| 544 | 'name': 'Tetracycl ines' | |
| 545 | }] , | |
| 546 | 's ummary': ' Tetracycli nes', | |
| 547 | 'c odes': [{ | |
| 548 | 'code': '7000', | |
| 549 | 'system' : 'DOD_ALL ERGY_IEN' | |
| 550 | }] , | |
| 551 | 'c omments': [{ | |
| 552 | 'comment ': 'Rash' | |
| 553 | }] , | |
| 554 | 'f acilityNam e': 'DOD', | |
| 555 | 'f acilityCod e': 'DOD', | |
| 556 | 'k ind': 'All ergy/Adver se Reactio n', | |
| 557 | 'u id': 'urn: va:allergy :DOD:00001 :100001034 1', | |
| 558 | 'p id': 'DOD; 00001', | |
| 559 | 's tampTime': '20140102 120059.000 ' | |
| 560 | }, | |
| 561 | 'refer enceInfo': { | |
| 562 | 's essionId': 'sessionI d', | |
| 563 | 'r equestId': 'requestI d' | |
| 564 | } | |
| 565 | }, { | |
| 566 | 'type' : 'event-p rioritizat ion-reques t', | |
| 567 | 'patie ntIdentifi er': { | |
| 568 | 't ype': 'pid ', | |
| 569 | 'v alue': 'DO D;00001' | |
| 570 | }, | |
| 571 | 'jpid' : 'aaa-aaa aa-aaaaaaa aaaa', | |
| 572 | 'dataD omain': 'a llergy', | |
| 573 | 'recor d': { | |
| 574 | 'p roducts': [{ | |
| 575 | 'name': 'Penicilli ns' | |
| 576 | }] , | |
| 577 | 's ummary': ' Penicillin s', | |
| 578 | 'c odes': [{ | |
| 579 | 'code': '1000', | |
| 580 | 'system' : 'DOD_ALL ERGY_IEN' | |
| 581 | }, { | |
| 582 | 'code': 'C0220892' , | |
| 583 | 'display ': 'Penici llin', | |
| 584 | 'system' : 'urn:oid :2.16.840. 1.113883.6 .86' | |
| 585 | }] , | |
| 586 | 'c omments': [{ | |
| 587 | 'comment ': 'Vomiti ng' | |
| 588 | }] , | |
| 589 | 'f acilityNam e': 'DOD', | |
| 590 | 'f acilityCod e': 'DOD', | |
| 591 | 'k ind': 'All ergy/Adver se Reactio n', | |
| 592 | 'u id': 'urn: va:allergy :DOD:00001 :100001034 0', | |
| 593 | 'p id': 'DOD; 00001', | |
| 594 | 's tampTime': '20140102 120059.000 ' | |
| 595 | }, | |
| 596 | 'refer enceInfo': { | |
| 597 | 's essionId': 'sessionI d', | |
| 598 | 'r equestId': 'requestI d' | |
| 599 | } | |
| 600 | }, { | |
| 601 | 'type' : 'event-p rioritizat ion-reques t', | |
| 602 | 'patie ntIdentifi er': { | |
| 603 | 't ype': 'pid ', | |
| 604 | 'v alue': 'DO D;00001' | |
| 605 | }, | |
| 606 | 'jpid' : 'aaa-aaa aa-aaaaaaa aaaa', | |
| 607 | 'dataD omain': 'a llergy', | |
| 608 | 'recor d': { | |
| 609 | 'p roducts': [{ | |
| 610 | 'name': 'Iodine Co ntaining A gents' | |
| 611 | }] , | |
| 612 | 's ummary': ' Iodine Con taining Ag ents', | |
| 613 | 'c odes': [{ | |
| 614 | 'code': '29000', | |
| 615 | 'system' : 'DOD_ALL ERGY_IEN' | |
| 616 | }] , | |
| 617 | 'c omments': [{ | |
| 618 | 'comment ': 'Nausea ' | |
| 619 | }] , | |
| 620 | 'f acilityNam e': 'DOD', | |
| 621 | 'f acilityCod e': 'DOD', | |
| 622 | 'k ind': 'All ergy/Adver se Reactio n', | |
| 623 | 'u id': 'urn: va:allergy :DOD:00001 :100001034 2', | |
| 624 | 'p id': 'DOD; 00001', | |
| 625 | 's tampTime': '20140102 120059.000 ' | |
| 626 | }, | |
| 627 | 'refer enceInfo': { | |
| 628 | 's essionId': 'sessionI d', | |
| 629 | 'r equestId': 'requestI d' | |
| 630 | } | |
| 631 | }]; | |
| 632 | ||
| 633 | var jobIds = _.every (jobsPubli shed, func tion(job) { | |
| 634 | return _.has(job , 'jobId') ; | |
| 635 | }); | |
| 636 | ||
| 637 | expect(job Ids).toBe( true); | |
| 638 | ||
| 639 | jobsPublis hed = _.ma p(jobsPubl ished, fun ction(job) { | |
| 640 | delete job.jobId ; | |
| 641 | delete job.times tamp; | |
| 642 | return job; | |
| 643 | }); | |
| 644 | expect(job sPublished ).toEqual( expectedJo bs); | |
| 645 | }); | |
| 646 | }); | |
| 647 | }) ; | |
| 648 | ||
| 649 | de scribe('de mographics transform ation path way', func tion() { | |
| 650 | ||
| 651 | var mock Config2 = { | |
| 652 | jmea dows: { | |
| 653 | version: " 2.3.3.0.2" , | |
| 654 | domains: [ 'demograph ics'] | |
| 655 | }, | |
| 656 | jds: { | |
| 657 | protocol: 'http', | |
| 658 | host: ' IP ', | |
| 659 | port: PORT | |
| 660 | } | |
| 661 | }; | |
| 662 | ||
| 663 | var jdsC lientDummy = new Jds ClientDumm y(log, moc kConfig2); | |
| 664 | ||
| 665 | var mock Environmen t = { | |
| 666 | publ isherRoute r: { | |
| 667 | publish: f unction(jo bsToPublis h, callbac k) { | |
| 668 | callba ck(null, ' success'); | |
| 669 | } | |
| 670 | }, | |
| 671 | jds: jdsClient Dummy | |
| 672 | }; | |
| 673 | ||
| 674 | beforeEa ch(functio n() { | |
| 675 | spyO n(handler. _steps, '_ getDemogra phicsIcnFr omJds').an dCallThrou gh(); | |
| 676 | spyO n(mockEnvi ronment.pu blisherRou ter, 'publ ish').andC allThrough (); | |
| 677 | }); | |
| 678 | ||
| 679 | it('ensu re getDemo graphicsIc nFromJds c alled', fu nction() { | |
| 680 | var expectedJd sResponse = [{ | |
| 681 | statusCode : 200, | |
| 682 | }, { | |
| 683 | statusCode : 200 | |
| 684 | }]; | |
| 685 | var expectedJd sResult = { | |
| 686 | jpid: 'aaa -aaaaa-aaa aaaaaaaa', | |
| 687 | patientIde ntifiers: [ | |
| 688 | '10108 V420871' | |
| 689 | ] | |
| 690 | }; | |
| 691 | jdsC lientDummy ._setRespo nseData(nu ll, expect edJdsRespo nse, expec tedJdsResu lt); | |
| 692 | ||
| 693 | var job = {}; | |
| 694 | job. type = 'jm eadows-xfo rm-demogra phics-vpr' ; | |
| 695 | job. dataDomain = 'demogr aphics'; | |
| 696 | job. record = [ { | |
| 697 | cdrEventId : '1000000 0' | |
| 698 | }]; | |
| 699 | job. requestSta mpTime = ' 2014010212 0059.000'; | |
| 700 | job. jpid = 'aa a-aaaaa-aa aaaaaaaaa' ; | |
| 701 | job. patientIde ntifier = { | |
| 702 | type: 'pid ', | |
| 703 | value: 'DO D;00000000 3' | |
| 704 | }; | |
| 705 | ||
| 706 | var finished = false; | |
| 707 | var actualErro r; | |
| 708 | var actualResp onse; | |
| 709 | runs (function( ) { | |
| 710 | handler(lo g, mockCon fig2, mock Environmen t, job, fu nction(err or, respon se) { | |
| 711 | actual Error = er ror; | |
| 712 | actual Response = response; | |
| 713 | finish ed = true; | |
| 714 | }); | |
| 715 | }); | |
| 716 | ||
| 717 | wait sFor(funct ion() { | |
| 718 | return fin ished; | |
| 719 | }, ' Call to ha ndler fail ed to retu rn in time .', 1000); | |
| 720 | ||
| 721 | runs (function( ) { | |
| 722 | log.debug( 'jmeadows- xform-doma in-vpr-han dler-spec: ***** DON E WAITING ********') ; | |
| 723 | ||
| 724 | //Get info rmation ab out calls made to ha ndler._get Demographi csIcnFromJ ds | |
| 725 | //-------- ---------- ---------- ---------- ---------- ---------- -- | |
| 726 | // var get IcnCalls = handler._ steps._get Demographi csIcnFromJ ds;//.call s; | |
| 727 | // console .log(getIc nCalls); | |
| 728 | // expect( getIcnCall s[0].args[ 0].length) .toEqual(1 ); | |
| 729 | ||
| 730 | //Get info rmation ab out calls made to pu blisherRou ter.publis h | |
| 731 | //-------- ---------- ---------- ---------- ---------- ---------- -- | |
| 732 | var publis hCalls = m ockEnviron ment.publi sherRouter .publish.c alls; | |
| 733 | log.debug( 'jmeadows- xform-doma in-vpr-han dler-spec: publishCa lls: %j', publishCal ls); | |
| 734 | ||
| 735 | expect(pub lishCalls[ 0].args[0] .length).t oEqual(1); | |
| 736 | ||
| 737 | log.debug( 'jmeadows- xform-doma in-vpr-han dler-spec: ***** AFT ER TEST NO W ******** '); | |
| 738 | ||
| 739 | //Get jobs published and compa re them to expected jobs | |
| 740 | var jobsPu blished = publishCal ls[0].args [0]; | |
| 741 | expect(job sPublished ).toBeTrut hy(); | |
| 742 | expect(job sPublished [0].type). toEqual('e vent-prior itization- request'); | |
| 743 | expect(job sPublished [0].record ).toBeTrut hy(); | |
| 744 | ||
| 745 | //This is how we kno w _getDemo graphicsIc nFromJds w as called | |
| 746 | expect(job sPublished [0].record .icn).toBe Truthy(); | |
| 747 | }); | |
| 748 | }); | |
| 749 | }) ; | |
| 750 | }); | |
| 751 | ||
| 752 | descri be('Ensure transform ations set required fields', f unction() { | |
| 753 | va r mockEdip i = '00001 '; | |
| 754 | va r mockCdrE ventId = ' 100000000' ; | |
| 755 | va r mockDodL abOrderDat e = '11824 35900000'; | |
| 756 | ||
| 757 | va r jmeadows Domains = require(gl obal.VX_RO OT + 'work er-config' ).jmeadows .domains; | |
| 758 | ||
| 759 | va r jmeadows DomainsToV pr = { | |
| 760 | encounte r: 'visit' , | |
| 761 | consult: 'document ', | |
| 762 | progress Note: 'doc ument', | |
| 763 | discharg eSummary: 'document' , | |
| 764 | medicati on: 'med', | |
| 765 | radiolog y: 'image' , | |
| 766 | demograp hics: 'pat ient' | |
| 767 | }; | |
| 768 | ||
| 769 | va r allXform ers = _.ma p(jmeadows Domains, f unction(do main) { | |
| 770 | return r equire(uti l.format(g lobal.VX_H ANDLERS + '/jmeadows -xform-dom ain-vpr/'+ jmeadowsUn itPath+'/j meadows-%s -xformer', domain)); | |
| 771 | }) ; | |
| 772 | va r vprObjec ts = _.map (allXforme rs, functi on(xformer ) { | |
| 773 | return x former(log , { | |
| 774 | acce ssion: 'TE ST ACC^ESS ION', //La bs only | |
| 775 | orde rDate: moc kDodLabOrd erDate, // Labs only | |
| 776 | resu ltDate: mo ckDodLabOr derDate, / /Labs only | |
| 777 | code s: [{ //La bs only | |
| 778 | code: '202 15', | |
| 779 | system: 'D OD_NCID' | |
| 780 | }], | |
| 781 | cdrE ventId: mo ckCdrEvent Id | |
| 782 | }, mockE dipi); | |
| 783 | }) ; | |
| 784 | ||
| 785 | _. each(jmead owsDomains , function (jmeadowsD omain, ind ex) { | |
| 786 | var vprO bject = vp rObjects[i ndex]; | |
| 787 | var vprD omain = jm eadowsDoma insToVpr[j meadowsDom ain] || jm eadowsDoma in; | |
| 788 | var expe ctUid; | |
| 789 | ||
| 790 | if (vprD omain === 'lab') { | |
| 791 | var expectDodV prLabObser ved = mome nt(mockDod LabOrderDa te, 'x').f ormat('YYY YMMDDHHmms s'); | |
| 792 | expe ctUid = 'u rn:va:lab: DOD:00001: ' + expect DodVprLabO bserved + '_TEST-ACC -ESSION_20 215'; | |
| 793 | } else i f (vprDoma in === 'pa tient') { | |
| 794 | expe ctUid = 'u rn:va:' + vprDomain + ':DOD:' + mockEdip i + ':' + mockEdipi; | |
| 795 | } else { | |
| 796 | expe ctUid = 'u rn:va:' + vprDomain + ':DOD:' + mockEdip i + ':' + mockCdrEve ntId; | |
| 797 | } | |
| 798 | it('Chec k DOD ' + jmeadowsDo main + ' t o VPR tran sformation for corre ct uid', f unction() { | |
| 799 | if ( _.isArray( vprObject) ) { | |
| 800 | expect(vpr Object.len gth).toBeG reaterThan (0); | |
| 801 | expect(vpr Object[0]. uid).toEqu al(expectU id); | |
| 802 | } el se { | |
| 803 | expect(vpr Object.uid ).toEqual( expectUid) ; | |
| 804 | } | |
| 805 | }); | |
| 806 | it('Chec k DOD ' + jmeadowsDo main + ' t o VPR tran sformation for corre ct pid', f unction() { | |
| 807 | if ( _.isArray( vprObject) ) { | |
| 808 | expect(vpr Object.len gth).toBeG reaterThan (0); | |
| 809 | expect(vpr Object[0]. pid).toEqu al('DOD;' + mockEdip i); | |
| 810 | } el se { | |
| 811 | expect(vpr Object.pid ).toEqual( 'DOD;' + m ockEdipi); | |
| 812 | } | |
| 813 | }); | |
| 814 | //stampT ime is ano ther requi red field, but it is added by | |
| 815 | //jmeado ws-xform-d omain-vpr- handler.xf ormItemCol lection (t ested abov e) | |
| 816 | //instea d of the i ndividual transforme rs | |
| 817 | }) ; | |
| 818 | }); | |
| 819 | }); |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.