Produced by Araxis Merge on 10/4/2017 8:04:33 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 | rdk.zip\rdk\product\production\rdk\src\handler\common | util-spec.js | Mon Aug 28 19:41:48 2017 UTC |
| 2 | rdk.zip\rdk\product\production\rdk\src\handler\common | util-spec.js | Tue Oct 3 18:07:31 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 9 | 752 |
| Changed | 8 | 30 |
| 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 | var _ = re quire('lod ash'); | |
| 4 | var bunyan = require ('bunyan') ; | |
| 5 | var clinci alObjectsS ubsystem = require(' ../../subs ystems/cli nical-obje cts/clinic al-objects -subsystem '); | |
| 6 | var activi tyEventPro cess = req uire('../. ./resource s/activity management /activitie s/eventpro cessor/act ivity-even t-process- resource') ; | |
| 7 | var rdk = require('. ./../core/ rdk'); | |
| 8 | var pidVal idator = r dk.utils.p idValidato r; | |
| 9 | var bunyan = require ('bunyan') ; | |
| 10 | ||
| 11 | var logger = sinon.s tub(bunyan .createLog ger({ | |
| 12 | name: 'util-spec .js' | |
| 13 | })); | |
| 14 | ||
| 15 | var util = require(' ./util'); | |
| 16 | ||
| 17 | var testJo b = { | |
| 18 | type: 'activity- management -event', | |
| 19 | patien tIdentifie r: { | |
| 20 | ty pe: 'pid', | |
| 21 | va lue: '9E7A ;3' | |
| 22 | }, | |
| 23 | jpid: '39b4d293- 90dc-442c- aa9c-4c581 91340ea', | |
| 24 | rootJo bId: '1', | |
| 25 | dataDo main: 'ord er-lab', | |
| 26 | data: {}, | |
| 27 | record : { | |
| 28 | ui d: 'urn:va :ehmp:9E7A ;3:de305d5 4-75b4-431 b-adb2-eb6 b9e546014' , | |
| 29 | pi d: '9E7A;3 ', | |
| 30 | pa tientUid: 'urn:va:pa tient:9E7A :3:3', | |
| 31 | au thorUid: ' urn:va:use r:9E7A:123 ', | |
| 32 | do main: 'ord er', | |
| 33 | su bDomain: ' consult', | |
| 34 | vi sit: { | |
| 35 | location : 'urn:va: location:9 E7A:1', | |
| 36 | serviceC ategory: ' E', | |
| 37 | dateTime : '2016020 3153000' | |
| 38 | }, | |
| 39 | eh mpState: ' active', | |
| 40 | di splayName: '', | |
| 41 | re ferenceId: 'urn:va:e hmp-activi ty:9E7A:3: 0e55ec7b-0 1a2-44e3-8 67a-343eb3 3f035d', | |
| 42 | da ta: '', | |
| 43 | ki nd: 'Labor atory', | |
| 44 | si teId: '9E7 A' | |
| 45 | } | |
| 46 | }; | |
| 47 | ||
| 48 | ||
| 49 | var config = { | |
| 50 | 'rdk': { | |
| 51 | pr otocol: 'h ttp', | |
| 52 | host: ' IP ', | |
| 53 | activityPo rt: PORT , | |
| 54 | writePort: PORT , | |
| 55 | ti meout: 600 00, | |
| 56 | accessCode : ' REDACT ', | |
| 57 | verifyCode : ' REDACTED ', | |
| 58 | ac tivityURI: '/resourc e/activiti es/startac tivityeven t', | |
| 59 | wr iteURI: '/ resource/w rite-healt h-data/pat ient' | |
| 60 | }, | |
| 61 | 'jdsSe rver': { | |
| 62 | 'baseUrl': 'http:// IP ', | |
| 63 | 't imeout': 1 20000 | |
| 64 | }, | |
| 65 | 'gener alPurposeJ dsServer': { | |
| 66 | 'baseUrl': 'http:// IP ', | |
| 67 | 'u rlLengthLi mit': 120 | |
| 68 | }, | |
| 69 | 'jbpm' : { | |
| 70 | 'baseUrl': 'http:// IP ', | |
| 71 | 'a piPath': ' /business- central/re st', | |
| 72 | 'a dminUser': { | |
| 73 | 'username' : ' RED A CTED ', | |
| 74 | 'password' : ' REDACTED ' | |
| 75 | }, | |
| 76 | 'n urseUser': { | |
| 77 | 'username' : ' REDACTED ', | |
| 78 | 'password' : ' REDACTED ' | |
| 79 | }, | |
| 80 | 'h ealthcheck Endpoint': '/history /instances ' | |
| 81 | }, | |
| 82 | 'oracl edb': { | |
| 83 | 'a ctivityDat abase': { | |
| 84 | 'user': ' REDACTED ', | |
| 85 | 'password' : ' REDACTED ', | |
| 86 | 'connectSt ring': ' IP /xe' | |
| 87 | } | |
| 88 | } | |
| 89 | }; | |
| 90 | ||
| 91 | var activi tyRequestT ype = 'act ivity-mana gement-eve nt'; | |
| 92 | ||
| 93 | var activi tyEventPro cessResour ceResponse = { | |
| 94 | 'name' : 'host-lo gger', | |
| 95 | 'hostn ame': 'rdk -jrobinson -master', | |
| 96 | 'pid': 7919, | |
| 97 | 'level ': 50, | |
| 98 | 'messa ge': 'No m atches', | |
| 99 | 'statu s': 200, | |
| 100 | 'msg': '', | |
| 101 | 'time' : '2016-05 -16T13:44: 19.270Z', | |
| 102 | 'v': 0 | |
| 103 | }; | |
| 104 | ||
| 105 | var mockCl inicalObje ct = { | |
| 106 | 'items ': [{ | |
| 107 | 'u id': 'urn: va:ehmp:9E 7A;3:de305 d54-75b4-4 31b-adb2-e b6b9e54601 4', | |
| 108 | 'r eferenceId ': 'urn:va :ehmp-acti vity:9E7A: 3:0e55ec7b -01a2-44e3 -867a-343e b33f035d', | |
| 109 | 'd ata': { | |
| 110 | 'activit y': { | |
| 111 | 'dep loymentId' : 'VistaCo re:Order', | |
| 112 | 'pro cessDefini tionId': ' Order:Requ est', | |
| 113 | 'pro cessInstan ceId': 123 , | |
| 114 | 'sta te': 'draf t', | |
| 115 | 'ini tiator': ' urn:va:use r:9E7A:123 ', | |
| 116 | 'tim eStamp': ' 2016042000 0000', | |
| 117 | 'urg ency': 'Ur gent', | |
| 118 | 'ass ignTo': 'M y Teams', | |
| 119 | 'rou tingCode': '' | |
| 120 | }, | |
| 121 | 'signals ': [], | |
| 122 | 'request s': [{ | |
| 123 | 'tas kInstanceI d': '1234' , | |
| 124 | 'urg encyId': ' 10', | |
| 125 | 'urg ency': 'Ur gent', | |
| 126 | 'ear liestDate' : '2016032 9000000', | |
| 127 | 'lat estDate': '201604200 00000', | |
| 128 | 'tit le': 'Post procedure follow-up ', | |
| 129 | 'ass ignTo': 'M y Teams', | |
| 130 | 'req uest': 'Th is is my r equest', | |
| 131 | 'sub mittedBy': 'urn:va:u ser:9E7A:1 23', | |
| 132 | 'sub mittedTime Stamp': '2 0160420000 000', | |
| 133 | 'vis it': { | |
| 134 | 'location' : 'urn:va: location:[ site]:[IEN ]', | |
| 135 | 'serviceCa tegory': ' PSB', | |
| 136 | 'dateTime' : '2016010 1080000' | |
| 137 | } | |
| 138 | }] | |
| 139 | } | |
| 140 | }] | |
| 141 | }; | |
| 142 | ||
| 143 | describe(' handler-ut il-spec.js ', functio n() { | |
| 144 | ||
| 145 | var mo ckActivity EventProce ss; | |
| 146 | before Each(funct ion() { | |
| 147 | lo gger._leve l = 50; | |
| 148 | mo ckActivity EventProce ss = sinon .stub(acti vityEventP rocess, 's tartActivi tyEvent', function(r eq, res) { | |
| 149 | return n ull, activ ityEventPr ocessResou rceRespons e; | |
| 150 | }) ; | |
| 151 | }); | |
| 152 | ||
| 153 | afterE ach(functi on() { | |
| 154 | mo ckActivity EventProce ss.restore (); | |
| 155 | lo gger._leve l = 40; | |
| 156 | }); | |
| 157 | ||
| 158 | descri be('isVali dRequest', function( ) { | |
| 159 | it ('throws a n error if job is nu ll', funct ion() { | |
| 160 | var job = null; | |
| 161 | util.isV alidReques t(job, act ivityReque stType, lo gger, func tion(error , result) { | |
| 162 | expe ct(error). to.eql('Jo b was empt y, null, o r undefine d'); | |
| 163 | }); | |
| 164 | }) ; | |
| 165 | ||
| 166 | it ('throws a n error if given inc orrect job type', fu nction() { | |
| 167 | var badT ypeJob = { | |
| 168 | type : 'definit ely-not-an -activity- management -event' | |
| 169 | }; | |
| 170 | util.isV alidReques t(badTypeJ ob, activi tyRequestT ype, logge r, functio n(error, r esult) { | |
| 171 | expe ct(error). to.eql('In correct jo b type'); | |
| 172 | }); | |
| 173 | }) ; | |
| 174 | ||
| 175 | it ('throws a n error if job recor d is undef ined', fun ction() { | |
| 176 | var badR ecordJob = { | |
| 177 | type : testJob. type | |
| 178 | }; | |
| 179 | util.isV alidReques t(badRecor dJob, acti vityReques tType, log ger, funct ion(error, result) { | |
| 180 | expe ct(error). to.eql('po st data is undefined !'); | |
| 181 | }); | |
| 182 | }) ; | |
| 183 | ||
| 184 | it ('throws a n error if job recor d is empty ', functio n() { | |
| 185 | var badR ecordJob = { | |
| 186 | reco rd: {} | |
| 187 | }; | |
| 188 | badRecor dJob.type = testJob. type; | |
| 189 | util.isV alidReques t(badRecor dJob, acti vityReques tType, log ger, funct ion(error, result) { | |
| 190 | expe ct(error). to.eql('po st data is empty'); | |
| 191 | }); | |
| 192 | }) ; | |
| 193 | ||
| 194 | it ('Passes v alidation' , function () { | |
| 195 | util.isV alidReques t(testJob, activityR equestType , logger, function(e rror, resu lt) { | |
| 196 | expe ct(error). to.eql(nul l); | |
| 197 | }); | |
| 198 | }) ; | |
| 199 | }); | |
| 200 | ||
| 201 | descri be('setupI dLogger', function() { | |
| 202 | it ('does not modify th e logger w hen an inv alid job i s passed', function( ) { | |
| 203 | var orig inalLogger = { | |
| 204 | chil d: sinon.s py() | |
| 205 | }; | |
| 206 | var test Logger = u til.setupI dLogger(nu ll, origin alLogger); | |
| 207 | expect(t estLogger) .to.eql(or iginalLogg er); | |
| 208 | expect(t estLogger. child.call ed).to.be. false(); | |
| 209 | }) ; | |
| 210 | ||
| 211 | it ('creates a logger w ith reques tId and si d when ava ilable', f unction() { | |
| 212 | var logg erTestJob = _.cloneD eep(testJo b); | |
| 213 | _.assign (loggerTes tJob, { | |
| 214 | 'ref erenceInfo ': { | |
| 215 | 'requestId ': 'abc', | |
| 216 | 'sessionId ': '123' | |
| 217 | } | |
| 218 | }); | |
| 219 | var dumm yLogger = { | |
| 220 | chil d: functio n() {} | |
| 221 | }; | |
| 222 | var chil dStub = si non.stub(d ummyLogger , 'child', function( childObj) { | |
| 223 | retu rn childOb j; | |
| 224 | }); | |
| 225 | util.set upIdLogger (loggerTes tJob, dumm yLogger); | |
| 226 | expect(c hildStub.c alledOnce) .to.be.tru e(); | |
| 227 | expect(c hildStub.c alledWith( { | |
| 228 | 'req uestId': ' abc', | |
| 229 | 'sid ': '123' | |
| 230 | })).to.b e.true(); | |
| 231 | }) ; | |
| 232 | ||
| 233 | it ('creates a logger w ithout req uestId and sid when unavailabl e', functi on() { | |
| 234 | var logg erTestJob = _.cloneD eep(testJo b); | |
| 235 | ||
| 236 | var dumm yLogger = { | |
| 237 | chil d: functio n() {} | |
| 238 | }; | |
| 239 | var chil dStub = si non.stub(d ummyLogger , 'child', function( childObj) { | |
| 240 | retu rn childOb j; | |
| 241 | }); | |
| 242 | util.set upIdLogger (loggerTes tJob, dumm yLogger); | |
| 243 | expect(c hildStub.c alledOnce) .to.be.tru e(); | |
| 244 | expect(c hildStub.c alledWith( { | |
| 245 | 'req uestId': u ndefined, | |
| 246 | 'sid ': undefin ed | |
| 247 | })).to.b e.true(); | |
| 248 | }) ; | |
| 249 | }); | |
| 250 | ||
| 251 | descri be('isVPRO bject ', f unction() { | |
| 252 | it ('Should r eturn true ', functio n() { | |
| 253 | var uid = 'urn:va: order:9E7A ;3:de305d5 4-75b4-431 b-adb2-eb6 b9e546014' ; | |
| 254 | expect(u til.isVPRO bject(uid, activityR equestType , logger)) .to.eql(tr ue); | |
| 255 | }) ; | |
| 256 | ||
| 257 | it ('Should r eturn fals e', functi on() { | |
| 258 | var uid = 'urn:va: ehmp:9E7A; 3:de305d54 -75b4-431b -adb2-eb6b 9e546014'; | |
| 259 | expect(u til.isVPRO bject(uid, activityR equestType , logger)) .to.eql(fa lse); | |
| 260 | }) ; | |
| 261 | }); | |
| 262 | ||
| 263 | descri be('findCl inicalObje ct ', func tion() { | |
| 264 | it ('Should r eturn null , {} becau se there w ere no cli nical obje cts found. ', functio n() { | |
| 265 | var mock ClincialOb jectsSubsy stem = sin on.stub(cl incialObje ctsSubsyst em, 'find' , function (logger, a ppConfig, model, loa dReference , callback ) { | |
| 266 | retu rn callbac k(['Clinic al Object Not Found' ]); | |
| 267 | }); | |
| 268 | util.fin dClinicalO bject(test Job.record .reference Id, testJo b.record.p atientUid, config, a ctivityReq uestType, logger, tr ue, functi on(error, result) { | |
| 269 | expe ct(error). to.eql(nul l); | |
| 270 | expe ct(result) .to.eql({} ); | |
| 271 | }); | |
| 272 | mockClin cialObject sSubsystem .restore() ; | |
| 273 | }) ; | |
| 274 | ||
| 275 | it ('Should r eturn erro r null bec ause there was an er ror other than clini cal object not found .', functi on() { | |
| 276 | var mock ClincialOb jectsSubsy stem = sin on.stub(cl incialObje ctsSubsyst em, 'find' , function (logger, a ppConfig, model, loa dReference , callback ) { | |
| 277 | retu rn callbac k('Oracle is not res ponding'); | |
| 278 | }); | |
| 279 | util.fin dClinicalO bject(test Job.record .reference Id, testJo b.record.p atientUid, config, a ctivityReq uestType, logger, tr ue, functi on(error, result) { | |
| 280 | expe ct(error). to.eql('Or acle is no t respondi ng'); | |
| 281 | expe ct(result) .to.eql(nu ll); | |
| 282 | }); | |
| 283 | mockClin cialObject sSubsystem .restore() ; | |
| 284 | }) ; | |
| 285 | ||
| 286 | it ('Should r eturn null , {notes:[ ]} because response. items is n ull', func tion() { | |
| 287 | var mock ClincialOb jectsSubsy stem = sin on.stub(cl incialObje ctsSubsyst em, 'find' , function (logger, a ppConfig, model, loa dReference , callback ) { | |
| 288 | retu rn callbac k(null, { | |
| 289 | 'items': n ull | |
| 290 | }); | |
| 291 | }); | |
| 292 | util.fin dClinicalO bject(test Job.record .reference Id, testJo b.record.p atientUid, config, a ctivityReq uestType, logger, tr ue, functi on(error, result) { | |
| 293 | expe ct(error). to.eql(nul l); | |
| 294 | expe ct(result) .to.eql({ | |
| 295 | 'notes': [ ] | |
| 296 | }); | |
| 297 | }); | |
| 298 | mockClin cialObject sSubsystem .restore() ; | |
| 299 | }) ; | |
| 300 | ||
| 301 | it ('Should r eturn null , {notes:[ ]} because response. items is u ndefined', function( ) { | |
| 302 | var mock ClincialOb jectsSubsy stem = sin on.stub(cl incialObje ctsSubsyst em, 'find' , function (logger, a ppConfig, model, loa dReference , callback ) { | |
| 303 | retu rn callbac k(null, { | |
| 304 | 'items': u ndefined | |
| 305 | }); | |
| 306 | }); | |
| 307 | util.fin dClinicalO bject(test Job.record .reference Id, testJo b.record.p atientUid, config, a ctivityReq uestType, logger, tr ue, functi on(error, result) { | |
| 308 | expe ct(error). to.eql(nul l); | |
| 309 | expe ct(result) .to.eql({ | |
| 310 | 'notes': [ ] | |
| 311 | }); | |
| 312 | }); | |
| 313 | mockClin cialObject sSubsystem .restore() ; | |
| 314 | }) ; | |
| 315 | ||
| 316 | it ('Should r eturn succ ess', func tion() { | |
| 317 | var mock ClincialOb jectsSubsy stem = sin on.stub(cl incialObje ctsSubsyst em, 'find' , function (logger, a ppConfig, model, loa dReference , callback ) { | |
| 318 | retu rn callbac k(null, mo ckClinical Object); | |
| 319 | }); | |
| 320 | util.fin dClinicalO bject(test Job.record .reference Id, testJo b.record.p atientUid, config, a ctivityReq uestType, logger, tr ue, functi on(error, result) { | |
| 321 | expe ct(error). to.eql(nul l); | |
| 322 | expe ct(result[ 0].referen ceId).to.e ql('urn:va :ehmp-acti vity:9E7A: 3:0e55ec7b -01a2-44e3 -867a-343e b33f035d') ; | |
| 323 | }); | |
| 324 | mockClin cialObject sSubsystem .restore() ; | |
| 325 | }) ; | |
| 326 | }); | |
| 327 | ||
| 328 | descri be('buildC linicalObj ect', func tion() { | |
| 329 | it ('Should h ave a doma in of labo ratory', f unction() { | |
| 330 | var mock IsPrimaryS ite = sino n.stub(pid Validator, 'isPrimar ySite', fu nction() { | |
| 331 | retu rn true; | |
| 332 | }); | |
| 333 | var clon edJob = _. cloneDeep( testJob); | |
| 334 | clonedJo b.dataDoma in = 'orde r'; | |
| 335 | var resp onse = uti l.buildCli nicalObjec t(clonedJo b, logger) ; | |
| 336 | expect(r esponse.su bDomain).t o.eql('lab oratory'); | |
| 337 | mockIsPr imarySite. restore(); | |
| 338 | }) ; | |
| 339 | ||
| 340 | it ('Should h ave a doma in of lab- order', fu nction() { | |
| 341 | var mock IsPrimaryS ite = sino n.stub(pid Validator, 'isPrimar ySite', fu nction() { | |
| 342 | retu rn true; | |
| 343 | }); | |
| 344 | var resp onse = uti l.buildCli nicalObjec t(testJob, logger); | |
| 345 | expect(r esponse.su bDomain).t o.eql('ord er-lab'); | |
| 346 | mockIsPr imarySite. restore(); | |
| 347 | }) ; | |
| 348 | ||
| 349 | it ('Should n ot set a s ubDomain w hen not pr ovided a k ind', func tion() { | |
| 350 | var mock IsPrimaryS ite = sino n.stub(pid Validator, 'isPrimar ySite', fu nction() { | |
| 351 | retu rn true; | |
| 352 | }); | |
| 353 | var clon edJob = _. cloneDeep( testJob); | |
| 354 | clonedJo b.dataDoma in = 'orde r'; | |
| 355 | delete c lonedJob.r ecord.kind ; | |
| 356 | var resp onse = uti l.buildCli nicalObjec t(clonedJo b, logger) ; | |
| 357 | expect(_ .get(respo nse, 'subD omain', 'I NVALID')). to.eql('IN VALID'); | |
| 358 | mockIsPr imarySite. restore(); | |
| 359 | }) ; | |
| 360 | it ('Should n ot set a s ubDomain w hen provid ed invalid kind valu e', functi on() { | |
| 361 | var mock IsPrimaryS ite = sino n.stub(pid Validator, 'isPrimar ySite', fu nction() { | |
| 362 | retu rn true; | |
| 363 | }); | |
| 364 | var clon edJob = _. cloneDeep( testJob); | |
| 365 | clonedJo b.dataDoma in = 'orde r'; | |
| 366 | clonedJo b.record.k ind = ['ba d', 'data' ]; | |
| 367 | var resp onse = uti l.buildCli nicalObjec t(clonedJo b, logger) ; | |
| 368 | expect(_ .get(respo nse, 'subD omain', 'I NVALID')). to.eql('IN VALID'); | |
| 369 | mockIsPr imarySite. restore(); | |
| 370 | }) ; | |
| 371 | }); | |
| 372 | ||
| 373 | descri be('constr uctPatient Uid', func tion() { | |
| 374 | va r pid = 'u rn:va:pati ent:9E7A:3 :3'; | |
| 375 | it ('Should b e a pid Ui d', functi on() { | |
| 376 | var mock IsPrimaryS ite = sino n.stub(pid Validator, 'isPrimar ySite', fu nction() { | |
| 377 | retu rn true; | |
| 378 | }); | |
| 379 | util.con structPati entUid(pid , logger); | |
| 380 | mockIsPr imarySite. restore(); | |
| 381 | }) ; | |
| 382 | ||
| 383 | it ('Should b e an ICN U id', funct ion() { | |
| 384 | var mock IsPrimaryS ite = sino n.stub(pid Validator, 'isPrimar ySite', fu nction() { | |
| 385 | retu rn false; | |
| 386 | }); | |
| 387 | util.con structPati entUid(pid , logger); | |
| 388 | mockIsPr imarySite. restore(); | |
| 389 | }) ; | |
| 390 | }); | |
| 391 | }); |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.