887. EPMO Open Source Coordination Office Redaction File Detail Report

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.

887.1 Files compared

# Location File Last Modified
1 ehmp.zip\ehmp\ehmp\product\production\vx-sync\tests\unittests\handlers\osync\sync sync-spec.js Mon Jul 10 17:46:22 2017 UTC
2 ehmp.zip\ehmp\ehmp\product\production\vx-sync\tests\unittests\handlers\osync\sync sync-spec.js Mon Oct 2 20:06:03 2017 UTC

887.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 3 1544
Changed 2 6
Inserted 0 0
Removed 0 0

887.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

887.4 Active regular expressions

No regular expressions were active.

887.5 Comparison detail

  1   'use stric t';
  2  
  3   require('. ./../../.. /../env-se tup');
  4  
  5   var reques t = requir e('request ');
  6   var log =  require(gl obal.VX_DU MMIES + 'd ummy-logge r');
  7   var result sLog = req uire(globa l.VX_DUMMI ES + 'dumm y-logger') ;
  8   var handle r = requir e(global.V X_HANDLERS  + 'osync/ sync/sync' );
  9   var storeP atientInfo ToResultsL og = requi re(global. VX_HANDLER S + 'osync /sync/sync ')._storeP atientInfo ToResultsL og;
  10   var Publis herRouterD ummy = req uire(globa l.VX_DUMMI ES + 'publ isherRoute rDummy');
  11   var Publis herDummy =  require(g lobal.VX_D UMMIES + ' publisherD ummy');
  12   var should SyncPatien t = requir e(global.V X_HANDLERS  + 'osync/ sync/sync' )._shouldS yncPatient ;
  13   var JdsCli entDummy =  require(g lobal.VX_D UMMIES + ' jds-client -dummy');
  14   var blackl istUtils =  require(g lobal.OSYN C_UTILS +  'blacklist -utils');
  15   var _ = re quire('und erscore');
  16   var val =  require(gl obal.VX_UT ILS + 'obj ect-utils' ).getPrope rty;
  17   var nock =  require(' nock');
  18  
  19   // NOTE: b e sure nex t line is  commented  out before  pushing
  20   // log = r equire('bu nyan').cre ateLogger( {
  21   //     nam e: 'sync-s pec',
  22   //     lev el: 'debug '
  23   // });
  24  
  25   //-------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---
  26   // This me thod creat es an inst ance of th e config.o sync secti on of the  config fil e.
  27   //
  28   // returns : The conf ig.osync s ettings to  be used i n the test s.
  29   //-------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---
  30   function c reateoSync Config() {
  31       var os yncConfig  = {
  32             syncUrl: ' http:// IP             /sync/doLo ad',
  33             statusUrl:  'http:// IP             /sync/stat us'
  34       };
  35  
  36       return  osyncConf ig;
  37   }
  38  
  39   //-------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----
  40   // This me thod creat es an inst ance of th e environm ent variab le.
  41   //
  42   // osyncCo nfig: The  osync sect ion of the  config (w orker-conf ig.json)
  43   // returns : The envi ronment va riable.
  44   //-------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----
  45   function c reateEnvir onment(osy ncConfig)  {
  46       var en vironment  = {
  47           me trics: log ,
  48           re sultsLog:  resultsLog ,
  49           pu blisherRou ter: new P ublisherRo uterDummy( log, osync Config, Pu blisherDum my),
  50           pj ds: {child Instance:  function() {}},
  51           jd s: new Jds ClientDumm y(log, osy ncConfig),
  52           va lidPatient sLog: {
  53                info: ja smine.crea teSpy()
  54           }
  55       };
  56  
  57       spyOn( environmen t.resultsL og, 'info' ).andCallT hrough();
  58  
  59       return  environme nt;
  60   }
  61  
  62   describe(' sync handl er unit te st', funct ion() {
  63       descri be('sync.h andle erro r conditio ns for job s passed i n', functi on() {
  64           it ('error co ndition: i ncorrect j ob type (e mpty)', fu nction() {
  65                var done  = false;
  66  
  67                runs(fun ction() {
  68                    var  job = {};
  69                    var  config = n ull;
  70                    var  environmen t = null;
  71                    hand ler(log, c onfig, env ironment,  job, funct ion(error)  {
  72                         done = tru e;
  73                         expect(err or).toBe(' sync.valid ate: Could  not find  job type') ;
  74                    });
  75                });
  76  
  77                waitsFor (function( ) {
  78                    retu rn done;
  79                }, 'Call back not c alled', 10 0);
  80           }) ;
  81  
  82           it ('error co ndition: i ncorrect j ob type (w rong type) ', functio n() {
  83                var done  = false;
  84  
  85                runs(fun ction() {
  86                    var  job = {
  87                         'type': 'B OGUS'
  88                    };
  89                    var  osyncConfi g = null;
  90                    var  environmen t = null;
  91                    hand ler(log, o syncConfig , environm ent, job,  function(e rror) {
  92                         done = tru e;
  93                         expect(err or).toBe(' sync.valid ate: job t ype was no t sync');
  94                    });
  95                });
  96  
  97                waitsFor (function( ) {
  98                    retu rn done;
  99                }, 'Call back not c alled', 10 0);
  100           }) ;
  101  
  102           it ('error co ndition: i ncorrect j ob source  (empty)',  function()  {
  103                var done  = false;
  104  
  105                runs(fun ction() {
  106                    var  job = {
  107                         'type': 's ync'
  108                    };
  109                    var  osyncConfi g = null;
  110                    var  environmen t = null;
  111                    hand ler(log, o syncConfig , environm ent, job,  function(e rror) {
  112                         done = tru e;
  113                         expect(err or).toBe(' sync.valid ate: Could  not find  job source ');
  114                    });
  115                });
  116  
  117                waitsFor (function( ) {
  118                    retu rn done;
  119                }, 'Call back not c alled', 10 0);
  120           }) ;
  121  
  122           it ('error co ndition: i ncorrect j ob source  (wrong sou rce)', fun ction() {
  123                var done  = false;
  124  
  125                runs(fun ction() {
  126                    var  job = {
  127                         'type': 's ync',
  128                         'source':  'bogus'
  129                    };
  130                    var  osyncConfi g = null;
  131                    var  environmen t = null;
  132                    hand ler(log, o syncConfig , environm ent, job,  function(e rror) {
  133                         done = tru e;
  134                         expect(err or).toBe(' sync.valid ate: job s ource was  not "appoi ntments" ,  "admissio ns" or "pa tient list s"');
  135                    });
  136                });
  137  
  138                waitsFor (function( ) {
  139                    retu rn done;
  140                }, 'Call back not c alled', 10 0);
  141           }) ;
  142  
  143           it ('error co ndition: i ncorrect j ob patient s (empty)' , function () {
  144                var done  = false;
  145  
  146                runs(fun ction() {
  147                    var  job = {
  148                         'type': 's ync',
  149                         'source':  'appointme nts'
  150                    };
  151                    var  osyncConfi g = null;
  152                    var  environmen t = null;
  153                    hand ler(log, o syncConfig , environm ent, job,  function(e rror) {
  154                         done = tru e;
  155                         expect(err or).toBe(' sync.valid ate: Could  not find  job patien t');
  156                    });
  157                });
  158  
  159                waitsFor (function( ) {
  160                    retu rn done;
  161                }, 'Call back not c alled', 10 0);
  162           }) ;
  163  
  164           it ('error co ndition: p atient mis sing icn a nd dfn', f unction()  {
  165                var done  = false;
  166  
  167                runs(fun ction() {
  168                    var  job = {
  169                         'type': 's ync',
  170                         'source':  'appointme nts',
  171                         'patient':  {}
  172                    };
  173                    var  osyncConfi g = null;
  174                    var  environmen t = null;
  175                    hand ler(log, o syncConfig , environm ent, job,  function(e rror) {
  176                         done = tru e;
  177                         expect(err or).toBe(' sync.valid ate: Missi ng dfn and  icn for p atient');
  178                    });
  179                });
  180  
  181                waitsFor (function( ) {
  182                    retu rn done;
  183                }, 'Call back not c alled', 10 0);
  184           }) ;
  185       });
  186  
  187       descri be('sync.h andle erro r conditio ns for con figuration  passed in ', functio n() {
  188           it ('error co ndition: c onfig miss ing', func tion() {
  189                var done  = false;
  190  
  191                runs(fun ction() {
  192                    var  job = {
  193                         'type': 's ync',
  194                         'source':  'appointme nts',
  195                         'patient':  {
  196                             'ien':  '9E7A;123 4'
  197                         }
  198                    };
  199                    var  osyncConfi g = null;
  200                    var  environmen t = null;
  201                    hand ler(log, o syncConfig , environm ent, job,  function(e rror) {
  202                         done = tru e;
  203                         expect(err or).toBe(' sync.valid ateConfig:  Configura tion canno t be null' );
  204                    });
  205                });
  206  
  207                waitsFor (function( ) {
  208                    retu rn done;
  209                }, 'Call back not c alled', 10 0);
  210           }) ;
  211  
  212           it ('error co ndition: c onfig miss ing syncUr l', functi on() {
  213                var done  = false;
  214  
  215                runs(fun ction() {
  216                    var  job = {
  217                         'type': 's ync',
  218                         'source':  'appointme nts',
  219                         'patient':  {
  220                             'ien':  '9E7A;123 4'
  221                         }
  222                    };
  223                    var  osyncConfi g = {};
  224                    var  environmen t = null;
  225                    hand ler(log, o syncConfig , environm ent, job,  function(e rror) {
  226                         done = tru e;
  227                         expect(err or).toBe(' sync.valid ateConfig:  syncUrl c annot be n ull');
  228                    });
  229                });
  230  
  231                waitsFor (function( ) {
  232                    retu rn done;
  233                }, 'Call back not c alled', 10 0);
  234           }) ;
  235       });
  236  
  237       descri be('send s ync reques t', functi on() {
  238           be foreEach(f unction()  {
  239                spyOn(re quest, 'ge t').andCal lFake(func tion(syncU rl, callba ck) {
  240                    call back(null,  {
  241                         statusCode : 200
  242                    }, {
  243                         syncStatus : {}
  244                    });
  245                    retu rn {
  246                         on: functi on() {}
  247                    };
  248                });
  249           }) ;
  250  
  251           it ('verify p id and pri ority set  correctly  when syncP riority is  missing f rom config ', functio n() {
  252                var done  = false;
  253  
  254                runs(fun ction() {
  255                    var  job = {
  256                         type: 'syn c',
  257                         source: 'a ppointment s',
  258                         siteId: '9 E7A',
  259                         patient: {
  260                             dfn: ' 1234'
  261                         }
  262                    };
  263  
  264                    var  osyncConfi g = create oSyncConfi g();
  265                    var  environmen t = create Environmen t(osyncCon fig);
  266                    envi ronment.jd s._setResp onseData([ null], [{
  267                         statusCode : 404
  268                    }],  [null]);
  269  
  270                    spyO n(blacklis tUtils, 'i sBlackList edPatient' ).andCallF ake(functi on(log, co nfig, pati entId, sit eId, callb ack) {
  271                         callback(n ull, false );
  272                    });
  273  
  274                    hand ler(log, o syncConfig , environm ent, job,  function(e rror, data ) {
  275                         expect(err or).toBeFa lsy();
  276                         expect(dat a).toBeFal sy();
  277                         expect(val (environme nt, ['resu ltsLog', ' info', 'ca lls', '0',  'args', ' 0'])).toCo ntain('{"s iteId":"9E 7A","patie nt":{"dfn" :"1234"}," source":"a ppointment s","syncDa te"');
  278                         expect(val (request,  ['get', 'c alls', '0' , 'args',  '0', 'url' ])).toBe(o syncConfig .syncUrl);
  279                         expect(val (request,  ['get', 'c alls', '0' , 'args',  '0', 'qs',  'pid'])). toBe('9E7A ;1234');
  280                         expect(val (request,  ['get', 'c alls', '0' , 'args',  '0', 'qs',  'priority '])).toBe( 50);
  281                         expect(val (environme nt, ['vali dPatientsL og', 'info ', 'calls' , '0', 'ar gs', '0']) ).toContai n(JSON.str ingify({
  282                             'siteI d': job.si teId,
  283                             'patie nt': job.p atient,
  284                             'sourc e': job.so urce
  285                         }));
  286                         done = tru e;
  287                    });
  288                });
  289  
  290                waitsFor (function( ) {
  291                    retu rn done;
  292                }, 'Call back not c alled', 10 0);
  293           }) ;
  294  
  295           it ('verify i cn and pri ority set  correctly  when syncP riority is  set in co nfig', fun ction() {
  296                var done  = false;
  297  
  298                runs(fun ction() {
  299                    var  job = {
  300                         type: 'syn c',
  301                         source: 'a ppointment s',
  302                         patient: {
  303                             ien: ' 10110V0048 77'
  304                         }
  305                    };
  306                    var  osyncConfi g = create oSyncConfi g();
  307                    osyn cConfig.sy ncPriority  = 80;
  308                    var  environmen t = create Environmen t(osyncCon fig);
  309                    envi ronment.jd s._setResp onseData([ null], [{
  310                         statusCode : 404
  311                    }],  [null]);
  312  
  313                    spyO n(blacklis tUtils, 'i sBlackList edPatient' ).andCallF ake(functi on(log, co nfig, pati entId, sit eId, callb ack) {
  314                         callback(n ull, false );
  315                    });
  316  
  317                    hand ler(log, o syncConfig , environm ent, job,  function(e rror, data ) {
  318                         expect(err or).toBeFa lsy();
  319                         expect(dat a).toBeFal sy();
  320                         expect(val (environme nt, ['resu ltsLog', ' info', 'ca lls', '0',  'args', ' 0'])).toCo ntain('{"p atient":{" ien":"1011 0V004877"} ,"source": "appointme nts","sync Date"');
  321                         expect(val (request,  ['get', 'c alls', '0' , 'args',  '0', 'url' ])).toBe(o syncConfig .syncUrl);
  322                         expect(val (request,  ['get', 'c alls', '0' , 'args',  '0', 'qs',  'icn'])). toBe('1011 0V004877') ;
  323                         expect(val (request,  ['get', 'c alls', '0' , 'args',  '0', 'qs',  'priority '])).toBe( 80);
  324                         expect(val (environme nt, ['vali dPatientsL og', 'info ', 'calls' , '0', 'ar gs', '0']) ).toContai n(JSON.str ingify({
  325                             'siteI d': job.si teId,
  326                             'patie nt': job.p atient,
  327                             'sourc e': job.so urce
  328                         }));
  329                         done = tru e;
  330                    });
  331                });
  332  
  333                waitsFor (function( ) {
  334                    retu rn done;
  335                }, 'Call back not c alled', 10 0);
  336           }) ;
  337  
  338           it ('verify p riority se t correctl y when syn cPriority  is less th an 1 and i s set in c onfig', fu nction() {
  339                var done  = false;
  340  
  341                runs(fun ction() {
  342                    var  job = {
  343                         type: 'syn c',
  344                         source: 'a ppointment s',
  345                         patient: {
  346                             ien: ' 10110V0048 77'
  347                         }
  348                    };
  349                    var  osyncConfi g = create oSyncConfi g();
  350                    osyn cConfig.sy ncPriority  = -10;
  351                    var  environmen t = create Environmen t(osyncCon fig);
  352                    envi ronment.jd s._setResp onseData([ null], [{
  353                         statusCode : 404
  354                    }],  [null]);
  355  
  356                    spyO n(blacklis tUtils, 'i sBlackList edPatient' ).andCallF ake(functi on(log, co nfig, pati entId, sit eId, callb ack) {
  357                         callback(n ull, false );
  358                    });
  359  
  360                    hand ler(log, o syncConfig , environm ent, job,  function(e rror, data ) {
  361                         expect(err or).toBeFa lsy();
  362                         expect(dat a).toBeFal sy();
  363                         expect(val (environme nt, ['resu ltsLog', ' info', 'ca lls', '0',  'args', ' 0'])).toCo ntain('{"p atient":{" ien":"1011 0V004877"} ,"source": "appointme nts","sync Date"');
  364                         expect(val (request,  ['get', 'c alls', '0' , 'args',  '0', 'url' ])).toBe(o syncConfig .syncUrl);
  365                         expect(val (request,  ['get', 'c alls', '0' , 'args',  '0', 'qs',  'icn'])). toBe('1011 0V004877') ;
  366                         expect(val (request,  ['get', 'c alls', '0' , 'args',  '0', 'qs',  'priority '])).toBe( 1);
  367                         expect(val (environme nt, ['vali dPatientsL og', 'info ', 'calls' , '0', 'ar gs', '0']) ).toContai n(JSON.str ingify({
  368                             'siteI d': job.si teId,
  369                             'patie nt': job.p atient,
  370                             'sourc e': job.so urce
  371                         }));
  372                         done = tru e;
  373                    });
  374                });
  375  
  376                waitsFor (function( ) {
  377                    retu rn done;
  378                }, 'Call back not c alled', 10 0);
  379           }) ;
  380  
  381           it ('verify p riority se t correctl y when syn cPriority  is greater  than 100  and is set  in config ', functio n() {
  382                var done  = false;
  383  
  384                runs(fun ction() {
  385                    var  job = {
  386                         type: 'syn c',
  387                         source: 'a ppointment s',
  388                         patient: {
  389                             ien: ' 10110V0048 77'
  390                         }
  391                    };
  392                    var  osyncConfi g = create oSyncConfi g();
  393                    osyn cConfig.sy ncPriority  = 200;
  394                    var  environmen t = create Environmen t(osyncCon fig);
  395                    envi ronment.jd s._setResp onseData([ null], [{
  396                         statusCode : 404
  397                    }],  [null]);
  398  
  399                    spyO n(blacklis tUtils, 'i sBlackList edPatient' ).andCallF ake(functi on(log, co nfig, pati entId, sit eId, callb ack) {
  400                         callback(n ull, false );
  401                    });
  402  
  403                    hand ler(log, o syncConfig , environm ent, job,  function(e rror, data ) {
  404                         expect(err or).toBeFa lsy();
  405                         expect(dat a).toBeFal sy();
  406                         expect(val (environme nt, ['resu ltsLog', ' info', 'ca lls', '0',  'args', ' 0'])).toCo ntain('{"p atient":{" ien":"1011 0V004877"} ,"source": "appointme nts","sync Date"');
  407                         expect(val (request,  ['get', 'c alls', '0' , 'args',  '0', 'url' ])).toBe(o syncConfig .syncUrl);
  408                         expect(val (request,  ['get', 'c alls', '0' , 'args',  '0', 'qs',  'icn'])). toBe('1011 0V004877') ;
  409                         expect(val (request,  ['get', 'c alls', '0' , 'args',  '0', 'qs',  'priority '])).toBe( 100);
  410                         expect(val (environme nt, ['vali dPatientsL og', 'info ', 'calls' , '0', 'ar gs', '0']) ).toContai n(JSON.str ingify({
  411                             'siteI d': job.si teId,
  412                             'patie nt': job.p atient,
  413                             'sourc e': job.so urce
  414                         }));
  415                         done = tru e;
  416                    });
  417                });
  418  
  419                waitsFor (function( ) {
  420                    retu rn done;
  421                }, 'Call back not c alled', 10 0);
  422  
  423  
  424           }) ;
  425       });
  426  
  427       descri be('sync.h andle with  reference Info', fun ction() {
  428           it ('verify r eferenceIn fo is pass ed into ht tp header  when calli ng sync re quest endp oint', fun ction() {
  429                var done  = false;
  430  
  431                var refe renceInfo  = {
  432                    'ses sionId':'t est sessio n id',
  433                    'uti lityType': 'osync-tes t'
  434                };
  435  
  436                  nock('http :// IP             ').get('/s ync/doLoad ?icn=10110 V004877&pr iority=80' ).reply(20 0, functio n() {
  437                    var  headers =  val(this,  ['req', 'h eaders']);
  438                    expe ct(headers ).toEqual( jasmine.ob jectContai ning({
  439                         host: jasm ine.any(St ring),
  440                         'x-session -id': refe renceInfo. sessionId,
  441                         'x-request -id': jasm ine.any(St ring),
  442                         'x-utility -type': re ferenceInf o.utilityT ype
  443                    }));
  444                });
  445  
  446                runs(fun ction() {
  447                    var  job = {
  448                         type: 'syn c',
  449                         source: 'a ppointment s',
  450                         patient: {
  451                             ien: ' 10110V0048 77'
  452                         },
  453                         referenceI nfo: refer enceInfo
  454                    };
  455                    var  osyncConfi g = create oSyncConfi g();
  456                    osyn cConfig.sy ncPriority  = 80;
  457                    var  environmen t = create Environmen t(osyncCon fig);
  458                    envi ronment.jd s._setResp onseData([ null], [{
  459                         statusCode : 404
  460                    }],  [null]);
  461  
  462                    spyO n(blacklis tUtils, 'i sBlackList edPatient' ).andCallF ake(functi on(log, co nfig, pati entId, sit eId, callb ack) {
  463                         callback(n ull, false );
  464                    });
  465  
  466                    hand ler(log, o syncConfig , environm ent, job,  function(e rror, data ) {
  467                         expect(err or).toBeFa lsy();
  468                         expect(dat a).toBeFal sy();
  469                         done = tru e;
  470                    });
  471                });
  472  
  473                waitsFor (function( ) {
  474                    retu rn done;
  475                }, 'Call back not c alled', 10 0);
  476           }) ;
  477       });
  478  
  479       descri be('sync.h andle: non -sync path s', functi on() {
  480           va r job = {
  481                type: 's ync',
  482                source:  'appointme nts',
  483                patient:  {
  484                    ien:  '10110V00 4877'
  485                }
  486           };
  487  
  488           va r done = f alse;
  489  
  490           it ('return e rror when  shouldSync Patient re turns erro r', functi on() {
  491                var osyn cConfig =  createoSyn cConfig();
  492                var envi ronment =  createEnvi ronment(os yncConfig) ;
  493                environm ent.jds._s etResponse Data([null ], [{
  494                    stat usCode: 50 0
  495                }], [nul l]);
  496  
  497                spyOn(bl acklistUti ls, 'isBla ckListedPa tient').an dCallFake( function(l og, config , patientI d, siteId,  callback)  {
  498                    call back(null,  false);
  499                });
  500  
  501                handler( log, osync Config, en vironment,  job, func tion(error , data) {
  502                    expe ct(error). toBeTruthy ();
  503                    expe ct(data).t oBeFalsy() ;
  504                    expe ct(_.isEmp ty(val(env ironment,  ['resultsL og', 'info ', 'calls' ]))).toBe( true);
  505                    done  = true;
  506                });
  507           }) ;
  508           it ('does not  call sync  when shou ldSyncPati ent return s false',  function()  {
  509                var osyn cConfig =  createoSyn cConfig();
  510                var envi ronment =  createEnvi ronment(os yncConfig) ;
  511  
  512                spyOn(bl acklistUti ls, 'isBla ckListedPa tient').an dCallFake( function(l og, config , patientI d, siteId,  callback)  {
  513                    call back(null,  true);
  514                });
  515  
  516                handler( log, osync Config, en vironment,  job, func tion(error , data) {
  517                    expe ct(error). toBeFalsy( );
  518                    expe ct(data).t oBeTruthy( );
  519                    expe ct(_.isEmp ty(val(env ironment,  ['resultsL og', 'info ', 'calls' ]))).toBe( true);
  520                    done  = true;
  521                });
  522           }) ;
  523       });
  524  
  525       descri be('Testin g: storePa tientInfoT oResultsLo g', functi on() {
  526           it ('Verify t hat it cor rectly wri tes to res ultsLog',  function()  {
  527                var done  = false;
  528  
  529                runs(fun ction() {
  530                    var  job = {
  531                         type: 'syn c',
  532                         source: 'a ppointment s',
  533                         siteId: '9 E7A',
  534                         patient: {
  535                             dfn: ' 1234'
  536                         }
  537                    };
  538  
  539                    var  osyncConfi g = create oSyncConfi g();
  540                    var  environmen t = create Environmen t(osyncCon fig);
  541                    stor ePatientIn foToResult sLog(log,  environmen t, job, fu nction(err or) {
  542                         expect(err or).toBeFa lsy();
  543                         expect(env ironment.r esultsLog. info.calls [0].args[0 ]).toConta in('{"site Id":"9E7A" ,"patient" :{"dfn":"1 234"},"sou rce":"appo intments", "syncDate" ');
  544                         done = tru e;
  545                    });
  546                });
  547  
  548                waitsFor (function( ) {
  549                    retu rn done;
  550                }, 'Call back not c alled', 10 0);
  551           }) ;
  552       });
  553  
  554       descri be('should SyncPatien t', functi on() {
  555           va r job = {
  556                type: 's ync',
  557                source:  'appointme nts',
  558                siteId:  '9E7A',
  559                patient:  {
  560                    dfn:  '1234'
  561                }
  562           };
  563  
  564           va r patientI dentifier  = {
  565                type: 'p id',
  566                value: ' 9E7A;1234'
  567           };
  568  
  569           it ('Normal p ath: sync  patient (p atient has  not been  previously  synced)',  function( ) {
  570                var conf ig = creat eoSyncConf ig();
  571                var envi ronment =  createEnvi ronment(co nfig);
  572                environm ent.jds._s etResponse Data([null ], [{
  573                    stat usCode: 40 4
  574                }], [nul l]);
  575  
  576                spyOn(bl acklistUti ls, 'isBla ckListedPa tient').an dCallFake( function(l og, config , patientI d, siteId,  callback)  {
  577                    call back(null,  false);
  578                });
  579  
  580                var done  = false;
  581  
  582                runs(fun ction() {
  583                    shou ldSyncPati ent(log, c onfig, env ironment,  job, patie ntIdentifi er, functi on(error,  result) {
  584                         expect(err or).toBeFa lsy();
  585                         expect(res ult).toBe( true);
  586                         done = tru e;
  587                    });
  588                });
  589  
  590                waitsFor (function( ) {
  591                    retu rn done;
  592                });
  593           }) ;
  594           it ('Normal p ath: sync  patient (s ync status  shows pre vious sync  is comple ted with e rror', fun ction() {
  595                var conf ig = creat eoSyncConf ig();
  596                var envi ronment =  createEnvi ronment(co nfig);
  597                environm ent.jds._s etResponse Data([null ], [{
  598                    stat usCode: 20 0
  599                }], [{
  600                    sync Completed:  true,
  601                    hasE rror: true
  602                }]);
  603  
  604                spyOn(bl acklistUti ls, 'isBla ckListedPa tient').an dCallFake( function(l og, config , patientI d, siteId,  callback)  {
  605                    call back(null,  false);
  606                });
  607  
  608                var done  = false;
  609  
  610                runs(fun ction() {
  611                    shou ldSyncPati ent(log, c onfig, env ironment,  job, patie ntIdentifi er, functi on(error,  result) {
  612                         expect(err or).toBeFa lsy();
  613                         expect(res ult).toBe( true);
  614                         done = tru e;
  615                    });
  616                });
  617  
  618                waitsFor (function( ) {
  619                    retu rn done;
  620                });
  621           }) ;
  622           it ('Normal p ath: sync  patient (s ync status  shows pre vious sync  is in pro gress with  error', f unction()  {
  623                var conf ig = creat eoSyncConf ig();
  624                var envi ronment =  createEnvi ronment(co nfig);
  625                environm ent.jds._s etResponse Data([null ], [{
  626                    stat usCode: 20 0
  627                }], [{
  628                    sync Completed:  false,
  629                    hasE rror: true
  630                }]);
  631  
  632                spyOn(bl acklistUti ls, 'isBla ckListedPa tient').an dCallFake( function(l og, config , patientI d, siteId,  callback)  {
  633                    call back(null,  false);
  634                });
  635  
  636                var done  = false;
  637  
  638                runs(fun ction() {
  639                    shou ldSyncPati ent(log, c onfig, env ironment,  job, patie ntIdentifi er, functi on(error,  result) {
  640                         expect(err or).toBeFa lsy();
  641                         expect(res ult).toBe( true);
  642                         done = tru e;
  643                    });
  644                });
  645  
  646                waitsFor (function( ) {
  647                    retu rn done;
  648                });
  649           }) ;
  650           it ('Normal p ath: don\' t sync pat ient (sync  status sh ows previo us sync wa s complete d and is n ot in erro r state)',  function( ) {
  651                var conf ig = creat eoSyncConf ig();
  652                var envi ronment =  createEnvi ronment(co nfig);
  653                environm ent.jds._s etResponse Data([null ], [{
  654                    stat usCode: 20 0
  655                }], [{
  656                    sync Completed:  true
  657                }]);
  658  
  659                spyOn(bl acklistUti ls, 'isBla ckListedPa tient').an dCallFake( function(l og, config , patientI d, siteId,  callback)  {
  660                    call back(null,  false);
  661                });
  662  
  663                var done  = false;
  664  
  665                runs(fun ction() {
  666                    shou ldSyncPati ent(log, c onfig, env ironment,  job, patie ntIdentifi er, functi on(error,  result) {
  667                         expect(err or).toBeFa lsy();
  668                         expect(res ult).toBe( false);
  669                         done = tru e;
  670                    });
  671                });
  672  
  673                waitsFor (function( ) {
  674                    retu rn done;
  675                });
  676           }) ;
  677           it ('Normal p ath: don\' t sync (sy nc status  shows prev ious sync  in progres s)', funct ion() {
  678                var conf ig = creat eoSyncConf ig();
  679                var envi ronment =  createEnvi ronment(co nfig);
  680                environm ent.jds._s etResponse Data([null ], [{
  681                    stat usCode: 20 0
  682                }], [{
  683                    sync Completed:  false
  684                }]);
  685  
  686                spyOn(bl acklistUti ls, 'isBla ckListedPa tient').an dCallFake( function(l og, config , patientI d, siteId,  callback)  {
  687                    call back(null,  false);
  688                });
  689  
  690                var done  = false;
  691  
  692                runs(fun ction() {
  693                    shou ldSyncPati ent(log, c onfig, env ironment,  job, patie ntIdentifi er, functi on(error,  result) {
  694                         expect(err or).toBeFa lsy();
  695                         expect(res ult).toBe( false);
  696                         done = tru e;
  697                    });
  698                });
  699  
  700                waitsFor (function( ) {
  701                    retu rn done;
  702                });
  703           }) ;
  704           it ('Normal p ath: don\' t sync (pa tient is o n blacklis t)', funct ion() {
  705                var conf ig = creat eoSyncConf ig();
  706                var envi ronment =  createEnvi ronment(co nfig);
  707  
  708                spyOn(bl acklistUti ls, 'isBla ckListedPa tient').an dCallFake( function(l og, config , patientI d, siteId,  callback)  {
  709                    call back(null,  true);
  710                });
  711  
  712                var done  = false;
  713  
  714                runs(fun ction() {
  715                    shou ldSyncPati ent(log, c onfig, env ironment,  job, patie ntIdentifi er, functi on(error,  result) {
  716                         expect(err or).toBeFa lsy();
  717                         expect(res ult).toBe( false);
  718                         done = tru e;
  719                    });
  720                });
  721  
  722                waitsFor (function( ) {
  723                    retu rn done;
  724                });
  725           }) ;
  726           it ('Error pa th: error  from jds',  function( ) {
  727                var conf ig = creat eoSyncConf ig();
  728                var envi ronment =  createEnvi ronment(co nfig);
  729                environm ent.jds._s etResponse Data(['err or'], [nul l], [null] );
  730  
  731                spyOn(bl acklistUti ls, 'isBla ckListedPa tient').an dCallFake( function(l og, config , patientI d, siteId,  callback)  {
  732                    call back(null,  false);
  733                });
  734  
  735                var done  = false;
  736  
  737                runs(fun ction() {
  738                    shou ldSyncPati ent(log, c onfig, env ironment,  job, patie ntIdentifi er, functi on(error,  result) {
  739                         expect(err or).toBeTr uthy();
  740                         expect(res ult).toBeF alsy();
  741                         done = tru e;
  742                    });
  743                });
  744  
  745                waitsFor (function( ) {
  746                    retu rn done;
  747                });
  748           }) ;
  749           it ('Error pa th: unexpe cted respo nse from j ds', funct ion() {
  750                var conf ig = creat eoSyncConf ig();
  751                var envi ronment =  createEnvi ronment(co nfig);
  752                environm ent.jds._s etResponse Data([null ], [{
  753                    stat usCode: 50 0
  754                }], [nul l]);
  755  
  756                spyOn(bl acklistUti ls, 'isBla ckListedPa tient').an dCallFake( function(l og, config , patientI d, siteId,  callback)  {
  757                    call back(null,  false);
  758                });
  759  
  760                var done  = false;
  761  
  762                runs(fun ction() {
  763                    shou ldSyncPati ent(log, c onfig, env ironment,  job, patie ntIdentifi er, functi on(error,  result) {
  764                         expect(err or).toBeTr uthy();
  765                         expect(res ult).toBeF alsy();
  766                         done = tru e;
  767                    });
  768                });
  769  
  770                waitsFor (function( ) {
  771                    retu rn done;
  772                });
  773           }) ;
  774       });
  775   });