874. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 10/3/2017 11:16:02 AM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

874.1 Files compared

# Location File Last Modified
1 ehmp.zip\ehmp\ehmp\product\production\vx-sync\tests\unittests\endpoints\clinical-object clinical-object-endpoint-spec.js Mon Jul 10 17:46:22 2017 UTC
2 ehmp.zip\ehmp\ehmp\product\production\vx-sync\tests\unittests\endpoints\clinical-object clinical-object-endpoint-spec.js Mon Oct 2 20:05:37 2017 UTC

874.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 5 848
Changed 4 8
Inserted 0 0
Removed 0 0

874.3 Comparison options

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

874.4 Active regular expressions

No regular expressions were active.

874.5 Comparison detail

  1   'use stric t';
  2  
  3   require('. ./../../.. /env-setup ');
  4  
  5   var log =  require(gl obal.VX_DU MMIES + 'd ummy-logge r');
  6   var config  = require (global.VX _ROOT + 'w orker-conf ig');
  7   var Clinic alObjectAP I = requir e(global.V X_ENDPOINT S + 'clini cal-object /clinical- object-end point');
  8   var JdsCli entDummy =  require(g lobal.VX_D UMMIES + ' jds-client -dummy');
  9   var PjdsCl ient = req uire(globa l.VX_DUMMI ES + 'pjds -client-du mmy');
  10   var val =  require(gl obal.VX_UT ILS + 'obj ect-utils' ).getPrope rty;
  11  
  12   // NOTE: b e sure nex t lines ar e commente d out befo re pushing
  13   // var log Util = req uire(globa l.VX_UTILS  + 'log');
  14   // log = l ogUtil._cr eateLogger ({
  15   //     nam e: 'clinic al-object- endpoint',
  16   //     lev el: 'debug ',
  17   //     chi ld: logUti l._createL ogger
  18   // });
  19  
  20   // Stolen  from solr- record-sto rage-handl er-spec
  21   //-------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
  22   // Create  the enviro nment vari able neede d for the  tests.
  23   //
  24   // config:  The confi guration s ettings to  be used.
  25   // solrErr orResponse : The valu e to retur n as the S OLR error  response i f the meth od solr.ad d
  26   //                      method c alled.
  27   // publish Response:  The error  response f or the pub lishRouter .publish f unction
  28   // returns : The fill ed out env ironment v ariable.
  29   //-------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
  30   function c reateEnvir onment(con fig, solrE rrorRespon se, publis hErrorResp onse) {
  31       var en vironment  = {
  32           jd s: new Jds ClientDumm y(log, con fig),
  33           pj ds: new Pj dsClient(l og, config ),
  34           me trics: log ,
  35           pu blisherRou ter: {
  36                'publish ': jasmine .createSpy ().andCall Fake(funct ion (job,  callback)  {
  37                    call back(publi shErrorRes ponse || n ull, [1]);
  38                })
  39           },
  40           so lr: {
  41                'add': f unction (s olrDoc, ca llback) {
  42                    call back(solrE rrorRespon se);
  43                }
  44           }
  45       };
  46  
  47       enviro nment.publ isherRoute r.childIns tance = fu nction ()  {
  48           re turn envir onment.pub lisherRout er;
  49       };
  50  
  51       spyOn( environmen t.solr, 'a dd').andCa llThrough( );
  52       spyOn( environmen t.publishe rRouter, ' childInsta nce').andC allThrough ();
  53       spyOn( environmen t.pjds, 'c reateClini calObject' ).andCallT hrough();
  54  
  55       return  environme nt;
  56   }
  57  
  58  
  59   describe(' clinical-o bject-endp oint.js',  function ( ) {
  60       var re c = requir e(global.V X_TESTS +  'data/clin ical-objec ts/ehmp-ac tivity.jso n');
  61  
  62       descri be('handle ClinicalOb jectPost',  function  () {
  63           va r request  = {
  64                headers:  {
  65                    'x-s ession-id' : 'session Id',
  66                    'x-r equest-id' : 'request Id'
  67                },
  68                body: nu ll
  69           };
  70           va r res = {
  71                status:  jasmine.cr eateSpy(). andCallFak e(function  () {
  72                    retu rn res;
  73                }),
  74                json: ja smine.crea teSpy(),
  75                setHeade r: jasmine .createSpy ()
  76           };
  77  
  78           it ('Returns  success if  all steps  required  to process  a clinica l object c omplete (H appy Path) ', functio n () {
  79                var done  = false;
  80                var envi ronment =  createEnvi ronment(co nfig, null );
  81                var reco rd = JSON. parse(JSON .stringify (rec));
  82                record.s toreToSolr  = true;
  83                var req  = JSON.par se(JSON.st ringify(re quest));
  84                req.get  = jasmine. createSpy( ).andCallF ake(functi on (proper ty){
  85                    if ( property = == 'host')  {
  86                          return(' IP             ');
  87                    }
  88                });
  89                req.body  = record;
  90                runs(fun ction () {
  91                    Clin icalObject API._handl eClinicalO bjectPost( log, confi g, environ ment, req,  res, func tion () {
  92                         // figure  out pjds c all as wel l
  93                         expect(env ironment.p ublisherRo uter.publi sh).toHave BeenCalled ();
  94                         expect(env ironment.s olr.add).t oHaveBeenC alled();
  95                         expect(res .status).t oHaveBeenC alledWith( 201);
  96                         expect(res .json).toH aveBeenCal ledWith({' status': ' OK'});
  97                         done = tru e;
  98                    });
  99                });
  100                waitsFor (function  () {
  101                    retu rn done;
  102                });
  103  
  104           }) ;
  105           it ('Returns  an error i f validati on fails',  function  () {
  106                var done  = false;
  107                var envi ronment =  createEnvi ronment(co nfig, null );
  108                var reco rd = JSON. parse(JSON .stringify (rec));
  109                record.s toreToSolr  = true;
  110                delete r ecord.uid;
  111                var req  = JSON.par se(JSON.st ringify(re quest));
  112                req.get  = jasmine. createSpy( ).andCallF ake(functi on (proper ty){
  113                    if ( property = == 'host')  {
  114                          return(' IP             ');
  115                    }
  116                });
  117                req.body  = record;
  118                runs(fun ction () {
  119                    Clin icalObject API._handl eClinicalO bjectPost( log, confi g, environ ment, req,  res, func tion () {
  120                         // figure  out pjds c all as wel l
  121                         expect(env ironment.p ublisherRo uter.publi sh).not.to HaveBeenCa lled();
  122                         expect(env ironment.s olr.add).n ot.toHaveB eenCalled( );
  123                         expect(res .status).t oHaveBeenC alledWith( 400);
  124                         expect(res .json).toH aveBeenCal led();
  125                         done = tru e;
  126                    });
  127                });
  128                waitsFor (function  () {
  129                    retu rn done;
  130                });
  131           }) ;
  132           it ('Returns  an error i f unable t o store to  pJDS (and  does not  execute an ymore func tions)', f unction ()  {
  133                var done  = false;
  134                var envi ronment =  createEnvi ronment(co nfig, null );
  135                environm ent.pjds._ setRespons eData('Err or connect ing to pJD S');
  136                var reco rd = JSON. parse(JSON .stringify (rec));
  137                record.s toreToSolr  = true;
  138                var req  = JSON.par se(JSON.st ringify(re quest));
  139                req.get  = jasmine. createSpy( ).andCallF ake(functi on (proper ty){
  140                    if ( property = == 'host')  {
  141                          return(' IP             ');
  142                    }
  143                });
  144                req.body  = record;
  145                runs(fun ction () {
  146                    Clin icalObject API._handl eClinicalO bjectPost( log, confi g, environ ment, req,  res, func tion () {
  147                         expect(env ironment.p jds.create ClinicalOb ject).toHa veBeenCall ed();
  148                         expect(env ironment.p ublisherRo uter.publi sh).not.to HaveBeenCa lled();
  149                         expect(env ironment.s olr.add).n ot.toHaveB eenCalled( );
  150                         expect(res .status).t oHaveBeenC alledWith( 500);
  151                         expect(res .json).toH aveBeenCal led();
  152                         done = tru e;
  153                    });
  154                });
  155                waitsFor (function  () {
  156                    retu rn done;
  157                });
  158           }) ;
  159           it ('Returns  an error i f unable t o publishT oActivityM anagementA ndStoreToS olr', func tion () {
  160                var done  = false;
  161                var envi ronment =  createEnvi ronment(co nfig, null , 'activit y error');
  162                var reco rd = JSON. parse(JSON .stringify (rec));
  163                record.s toreToSolr  = true;
  164                var req  = JSON.par se(JSON.st ringify(re quest));
  165                req.get  = jasmine. createSpy( ).andCallF ake(functi on (proper ty){
  166                    if ( property = == 'host')  {
  167                          return(' IP             ');
  168                    }
  169                });
  170                req.body  = record;
  171                runs(fun ction () {
  172                    Clin icalObject API._handl eClinicalO bjectPost( log, confi g, environ ment, req,  res, func tion () {
  173                         // figure  out pjds c all as wel l
  174                         expect(env ironment.p ublisherRo uter.publi sh).toHave BeenCalled ();
  175                         expect(env ironment.s olr.add).t oHaveBeenC alled();
  176                         expect(res .status).t oHaveBeenC alledWith( 500);
  177                         expect(res .json).toH aveBeenCal led();
  178                         done = tru e;
  179                    });
  180                });
  181                waitsFor (function  () {
  182                    retu rn done;
  183                });
  184           }) ;
  185       });
  186  
  187       descri be('valida teRequest' , function  () {
  188           it ('Returns  no error i f the reco rd is vali d (Happy P ath)', fun ction () {
  189                var reco rd = JSON. parse(JSON .stringify (rec));
  190                var resu lt = Clini calObjectA PI._valida teRequest( record);
  191                expect(r esult).toB e(null);
  192           }) ;
  193           it ('Returns  an error i f no recor d is passe d', functi on () {
  194                var reco rd = null;
  195                var resu lt = Clini calObjectA PI._valida teRequest( record);
  196                expect(r esult).toE qual(['No  data provi ded']);
  197           }) ;
  198           it ('Returns  an error i f a root l evel attri bute does  not exist' , function  () {
  199                var reco rd = JSON. parse(JSON .stringify (rec));
  200                delete r ecord.uid;
  201                var resu lt = Clini calObjectA PI._valida teRequest( record);
  202                expect(r esult).toE qual(['Req uired fiel d uid is m issing']);
  203  
  204                delete r ecord.doma in;
  205                result =  ClinicalO bjectAPI._ validateRe quest(reco rd);
  206                expect(r esult).toE qual(['Req uired fiel d uid is m issing', ' Required f ield domai n is missi ng']);
  207           }) ;
  208           it ('Returns  an error i f a visit  level attr ibute does  not exist ', functio n () {
  209                var reco rd = JSON. parse(JSON .stringify (rec));
  210                delete r ecord.visi t.dateTime ;
  211                var resu lt = Clini calObjectA PI._valida teRequest( record);
  212                expect(r esult).toE qual(['Req uired fiel d visit.da teTime is  missing']) ;
  213  
  214                delete r ecord.visi t.location ;
  215                result =  ClinicalO bjectAPI._ validateRe quest(reco rd);
  216                expect(r esult).toE qual(['Req uired fiel d visit.lo cation is  missing',  'Required  field visi t.dateTime  is missin g']);
  217           }) ;
  218       });
  219  
  220       descri be('storeT oPJDS', fu nction ()  {
  221           it ('Stores a  record to  pJDS if t he record  is valid ( Happy Path )', functi on () {
  222                var done  = false;
  223                var envi ronment =  createEnvi ronment(co nfig, null );
  224                var reco rd = JSON. parse(JSON .stringify (rec));
  225                runs(fun ction () {
  226                    Clin icalObject API._store ToPJDS(log , environm ent, confi g, record,  function  (error) {
  227                         expect(err or).toBeFa lsy();
  228                         expect(env ironment.p jds.create ClinicalOb ject).toHa veBeenCall ed();
  229                         done = tru e;
  230                    });
  231  
  232                });
  233                waitsFor (function  () {
  234                    retu rn done;
  235                });
  236           }) ;
  237           it ('Returns  an error i f it is un able to st ore to pJD S', functi on () {
  238                var done  = false;
  239                var envi ronment =  createEnvi ronment(co nfig, null );
  240                environm ent.pjds._ setRespons eData('Err or connect ing to pJD S');
  241                var reco rd = JSON. parse(JSON .stringify (rec));
  242                runs(fun ction () {
  243                    Clin icalObject API._store ToPJDS(log , environm ent, confi g, record,  function  (error) {
  244                         expect(err or).toBeTr uthy();
  245                         expect(env ironment.p jds.create ClinicalOb ject).toHa veBeenCall ed();
  246                         done = tru e;
  247                    });
  248  
  249                });
  250                waitsFor (function  () {
  251                    retu rn done;
  252                });
  253           }) ;
  254       });
  255  
  256       descri be('publis hToActivit yManagemen tAndStoreT oSolr', fu nction ()  {
  257           it ('Publishe s to Activ ity Manage ment and S OLR if the  record is  valid (Ha ppy Path)' , function  () {
  258                var done  = false;
  259                var envi ronment =  createEnvi ronment(co nfig, null );
  260                var reco rd = JSON. parse(JSON .stringify (rec));
  261                record.s toreToSolr  = true;
  262                runs(fun ction () {
  263                    Clin icalObject API._publi shToActivi tyManageme ntAndStore ToSolr(log , environm ent, confi g, {}, rec ord, funct ion (error ) {
  264                         expect(err or).toBeFa lsy();
  265                         expect(env ironment.p ublisherRo uter.publi sh).toHave BeenCalled ();
  266                         expect(env ironment.s olr.add).t oHaveBeenC alled();
  267                         done = tru e;
  268                    });
  269  
  270                });
  271                waitsFor (function  () {
  272                    retu rn done;
  273                });
  274           }) ;
  275           it ('Attempts  to store  to SOLR if  it is una ble to pub lish to ac tivity man agement',  function ( ) {
  276                var done  = false;
  277                var envi ronment =  createEnvi ronment(co nfig, null , 'activit y error');
  278                var reco rd = JSON. parse(JSON .stringify (rec));
  279                record.s toreToSolr  = true;
  280                runs(fun ction () {
  281                    Clin icalObject API._publi shToActivi tyManageme ntAndStore ToSolr(log , environm ent, confi g, {}, rec ord, funct ion (error ) {
  282                         log.debug( 'error rec eived: %j' , error);
  283                         expect(err or).toBeTr uthy();
  284                         expect(err or.length) .toBe(1);
  285                         expect(err or[0]).toB e('activit y error');
  286                         expect(env ironment.p ublisherRo uter.publi sh).toHave BeenCalled ();
  287                         expect(env ironment.s olr.add).t oHaveBeenC alled();
  288                         done = tru e;
  289                    });
  290  
  291                });
  292                waitsFor (function  () {
  293                    retu rn done;
  294                });
  295           }) ;
  296           it ('Returns  errors fro m SOLR if  SOLR is in  error', f unction ()  {
  297                var done  = false;
  298                var envi ronment =  createEnvi ronment(co nfig, 'sol r error');
  299                var reco rd = JSON. parse(JSON .stringify (rec));
  300                record.s toreToSolr  = true;
  301                runs(fun ction () {
  302                    Clin icalObject API._publi shToActivi tyManageme ntAndStore ToSolr(log , environm ent, confi g, {}, rec ord, funct ion (error ) {
  303                         log.debug( 'error rec eived: %j' , error);
  304                         expect(err or).toBeTr uthy();
  305                         expect(err or.length) .toBe(1);
  306                         expect(val (error[0],  'type')). toBe('tran sient-exce ption');
  307                         expect(env ironment.p ublisherRo uter.publi sh).toHave BeenCalled ();
  308                         expect(env ironment.s olr.add).t oHaveBeenC alled();
  309                         done = tru e;
  310                    });
  311  
  312                });
  313                waitsFor (function  () {
  314                    retu rn done;
  315                });
  316           }) ;
  317           it ('Returns  errors fro m activity  managemen t and SOLR  if they a re both in  error', f unction ()  {
  318                var done  = false;
  319                var envi ronment =  createEnvi ronment(co nfig, 'sol r error',  'activity  error');
  320                var reco rd = JSON. parse(JSON .stringify (rec));
  321                record.s toreToSolr  = true;
  322                runs(fun ction () {
  323                    Clin icalObject API._publi shToActivi tyManageme ntAndStore ToSolr(log , environm ent, confi g, {}, rec ord, funct ion (error ) {
  324                         log.debug( 'error rec eived: %j' , error);
  325                         expect(err or).toBeTr uthy();
  326                         expect(err or.length) .toBe(2);
  327                         expect(err or[0]).toB e('activit y error');
  328                         expect(val (error[1],  'type')). toBe('tran sient-exce ption');
  329                         expect(env ironment.p ublisherRo uter.publi sh).toHave BeenCalled ();
  330                         expect(env ironment.s olr.add).t oHaveBeenC alled();
  331                         done = tru e;
  332                    });
  333  
  334                });
  335                waitsFor (function  () {
  336                    retu rn done;
  337                });
  338           }) ;
  339       });
  340  
  341       descri be('publis hActivity' , function  () {
  342           it ('Correctl y puts a j ob on the  activity m anagement  tube if th e record i s valid (H appy Path) ', functio n () {
  343                var done  = false;
  344                var envi ronment =  createEnvi ronment(co nfig, null );
  345                var reco rd = JSON. parse(JSON .stringify (rec));
  346                runs(fun ction () {
  347                    Clin icalObject API._publi shActivity (log, envi ronment, { }, record,  function  (error) {
  348                         expect(err or).toBeFa lsy();
  349                         expect(env ironment.p ublisherRo uter.publi sh).toHave BeenCalled ();
  350                         done = tru e;
  351                    });
  352  
  353                });
  354                waitsFor (function  () {
  355                    retu rn done;
  356                });
  357           }) ;
  358           it ('Returns  an error i f it unabl e to put a  job on th e activity  managemen t tube', f unction ()  {
  359                var done  = false;
  360                var envi ronment =  createEnvi ronment(co nfig, null , 'error') ;
  361                var reco rd = JSON. parse(JSON .stringify (rec));
  362                runs(fun ction () {
  363                    Clin icalObject API._publi shActivity (log, envi ronment, { }, record,  function  (error) {
  364                         expect(err or).toBeTr uthy();
  365                         expect(env ironment.p ublisherRo uter.publi sh).toHave BeenCalled ();
  366                         done = tru e;
  367                    });
  368  
  369                });
  370                waitsFor (function  () {
  371                    retu rn done;
  372                });
  373           }) ;
  374       });
  375  
  376       descri be('storeT oSolr', fu nction ()  {
  377           it ('Correctl y stores t o Solr if  the record  is valid  (Happy Pat h)', funct ion () {
  378                var done  = false;
  379                var envi ronment =  createEnvi ronment(co nfig, null );
  380                var reco rd = JSON. parse(JSON .stringify (rec));
  381                record.s toreToSolr  = true;
  382                runs(fun ction () {
  383                    Clin icalObject API._store ToSolr(log , environm ent, confi g, record,  function  (error) {
  384                         expect(err or).toBeFa lsy();
  385                         expect(env ironment.s olr.add).t oHaveBeenC alled();
  386                         done = tru e;
  387                    });
  388  
  389                });
  390                waitsFor (function  () {
  391                    retu rn done;
  392                });
  393           }) ;
  394           it ('Does not  store to  SOLR if th e storeToS olr flag i s not pass ed', funct ion () {
  395                var done  = false;
  396                var envi ronment =  createEnvi ronment(co nfig, null );
  397                var reco rd = JSON. parse(JSON .stringify (rec));
  398                runs(fun ction () {
  399                    Clin icalObject API._store ToSolr(log , environm ent, confi g, record,  function  (error) {
  400                         expect(err or).toBeFa lsy();
  401                         expect(env ironment.s olr.add).n ot.toHaveB eenCalled( );
  402                         done = tru e;
  403                    });
  404  
  405                });
  406                waitsFor (function  () {
  407                    retu rn done;
  408                });
  409           }) ;
  410           it ('Returns  an error i f it is un able to st ore to SOL R', functi on () {
  411                var done  = false;
  412                var envi ronment =  createEnvi ronment(co nfig, 'Sol r is Down' );
  413                var reco rd = JSON. parse(JSON .stringify (rec));
  414                record.s toreToSolr  = true;
  415                runs(fun ction () {
  416                    Clin icalObject API._store ToSolr(log , environm ent, confi g, record,  function  (error) {
  417                         expect(val (error, 't ype')).toB e('transie nt-excepti on');
  418                         expect(env ironment.s olr.add).t oHaveBeenC alled();
  419                         done = tru e;
  420                    });
  421  
  422                });
  423                waitsFor (function  () {
  424                    retu rn done;
  425                });
  426           }) ;
  427       });
  428   });