927. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 10/3/2017 11:16:05 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.

927.1 Files compared

# Location File Last Modified
1 ehmp.zip\ehmp\ehmp\product\production\vx-sync\utils unsubscribe-patients.js Tue Dec 15 14:05:18 2015 UTC
2 ehmp.zip\ehmp\ehmp\product\production\vx-sync\utils unsubscribe-patients.js Mon Oct 2 20:07:53 2017 UTC

927.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 2 330
Changed 1 2
Inserted 0 0
Removed 0 0

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

927.4 Active regular expressions

No regular expressions were active.

927.5 Comparison detail

  1   'use stric t';
  2  
  3   require('. ./env-setu p');
  4  
  5   var _ = re quire('und erscore');
  6   var async  = require( 'async');
  7   var reques t = requir e('request ');
  8   var yargs  = require( 'yargs');
  9   var fs = r equire('fs ');
  10  
  11   var config  = require (global.VX _ROOT + 'w orker-conf ig');
  12   var pidUti ls = requi re(global. VX_UTILS +  'patient- identifier -utils');
  13   var log =  require('b unyan').cr eateLogger ({
  14       name:  'unsubscri be-patient -util',
  15       level:  'trace'
  16   });
  17  
  18   var argv =  parseOpti ons(log);
  19  
  20   var option Config = _ .clone(con fig.syncRe questApi);
  21  
  22   //Default  to using V M sync end point
  23   if (!argv. local && ! argv.l) {
  24         optionConf ig.host =  ' IP        ';
  25   }
  26   log.debug( 'Using syn c endpoint  location:  ', option Config.hos t);
  27  
  28   log.info(' unsubscrib e-patient- util: Star ting proce ss...');
  29   getListOfP atients(lo g, argv, f unction(er r, patient s) {
  30       if (er r) {
  31           lo g.error(er r);
  32           lo g.info('un subscribe- patient-ut il: Error  encountere d when rea ding file. ');
  33           re turn;
  34       }
  35  
  36       log.tr ace('Got l ist of pat ients: ',  patients);
  37       log.tr ace('Now f iltering i nvalid pat ients...') ;
  38       patien ts = filte rInvalidIc nsOrPids(l og, patien ts);
  39  
  40       if (_. isEmpty(pa tients)) {
  41           lo g.error('N o valid PI Ds or ICNs  were prov ided!');
  42           re turn;
  43       }
  44  
  45       log.in fo('Unsubs cribing pa tients: ',  patients) ;
  46       sendUn subscribeR equests(lo g, optionC onfig, pat ients, fun ction(erro r) {
  47           if  (error) {
  48                log.erro r(error);
  49                log.info ('unsubscr ibe-patien t-util: Er ror encoun tered when  unsubscri bing.');
  50           }  else {
  51                log.info ('unsubscr ibe-patien t-util: Co mpleted su ccessfully .');
  52           }
  53       });
  54   });
  55  
  56   function p arseOption s(logger)  {
  57       var ar gv = yargs
  58           .c heck(funct ion(args)  {
  59                if ((!ar gs.patient  && !args. p && !args .file && ! args.f)) {
  60                    logg er.error(' You must s elect at l east one o ption. See  usage.');
  61                    retu rn false;
  62                }
  63                return t rue;
  64           })
  65           .o ption('p',  {
  66                alias: ' patient',
  67                describe : 'The pid  or icn to  unsubscri be. This c an appear  multiple t imes and a ll values  will be us ed. Can be  a comma-d elimited l ist.',
  68                type: 's tring'
  69           })
  70           .o ption('f',  {
  71                alias: ' file',
  72                describe : 'A path  to a plain -text file  containin g a comma  or newline  delimited  list of p atient ICN s or PIDs  to unsubsc ribe.',
  73                type: 's tring'
  74           })
  75           .o ption('l',  {
  76                alias: ' local',
  77                describe : 'Use thi s option i f you are  running VX -Sync loca lly on you r machine  (as oppose d to runni ng the VX- Sync VM).' ,
  78                type: 's tring'
  79           })
  80           .u sage('Usag e: ./unsub scribe-pat ients.sh - p <string>  -f <strin g>')
  81           .a rgv;
  82  
  83       return  argv;
  84   }
  85  
  86   function g etListOfPa tients(log ger, argv,  callback)  {
  87       logger .trace('ge tListOfPat ients(): e ntering me thod...');
  88       var pa tientArray  = [];
  89       if (ar gv.patient ) {
  90           pa tientArray  = patient Array.conc at(parsePa tients(arg v.patient) );
  91           lo gger.trace ('patientA rray after  extractin g patients  from \'pa tient\' ar gument: ',  patientAr ray);
  92       }
  93  
  94       if (ar gv.file) {
  95           fs .readFile( argv.file,  {
  96                encoding : 'utf8'
  97           },  function( err, data)  {
  98                if (!err ) {
  99                    pati entArray =  patientAr ray.concat (parsePati ents(data) );
  100                    logg er.trace(' patientArr ay after e xtracting  patients f rom file:  ', patient Array);
  101                }
  102                logger.t race('getL istOfPatie nts(): ret urning pat ientArray  through ca llback');
  103                callback (err, pati entArray);
  104           }) ;
  105       } else  {
  106           lo gger.trace ('getListO fPatients( ): returni ng patient Array thro ugh callba ck');
  107           ca llback(nul l, patient Array);
  108       }
  109   }
  110  
  111   function p arsePatien ts(patient s) {
  112       if (!_ .isArray(p atients))  {
  113           pa tients = [ patients];
  114       }
  115  
  116       //Sepa rate comma -delimited  string of  patient i ds into ar ray
  117       patien ts = _.fla tten(_.map (patients,  function( patient) {
  118           re turn _.wit hout(_.isS tring(pati ent) ? _.i nvoke(pati ent.split( ','), 'tri m') : [''] , '');
  119       }));
  120       //Sepa rate newli ne-delimit ed string  of patient  ids into  array
  121       patien ts = _.fla tten(_.map (patients,  function( patient) {
  122           re turn _.wit hout(_.isS tring(pati ent) ? _.i nvoke(pati ent.split( '\n'), 'tr im') : ['' ], '');
  123       }));
  124  
  125       return  patients;
  126   }
  127  
  128   function f ilterInval idIcnsOrPi ds(logger,  ids) {
  129       return  _.filter( ids, funct ion(id) {
  130           lo g.trace('_ .filter: ' , id);
  131           va r isIcn =  pidUtils.i sIcn(id);
  132           va r isPid =  pidUtils.i sPid(id);
  133           lo g.trace('i sIcn', isI cn);
  134           lo g.trace('i dPid', isP id);
  135           re turn isIcn  || isPid;
  136       });
  137   }
  138  
  139   function g etUnsyncRe quest(opti ons, patie nt) {
  140       var pa rameter =  (pidUtils. isIcn(pati ent)) ? 'i cn=' + pat ient : 'pi d=' + pati ent;
  141       return  {
  142           ur l: options .protocol  + '://' +  options.ho st + ':' +  options.p ort + opti ons.patien tUnsyncPat h + '?' +  parameter,
  143           me thod: opti ons.method
  144       };
  145   }
  146  
  147   function s endUnsubsc ribeReques ts(logger,  syncReqCo nfig, pati ents, call back) {
  148       async. each(patie nts, funct ion(patien t, stepCal lback) {
  149           va r unsyncRe quest = ge tUnsyncReq uest(syncR eqConfig,  patient);
  150           lo gger.info( 'sending u nsubscribe  request:  %s %s', un syncReques t.method,  unsyncRequ est.url);
  151           re quest(unsy ncRequest,  function( error, res ponse) {
  152                if (resp onse) {
  153                    logg er.debug(' Got respon se for ' +  patient +  ' : ' + r esponse.st atusCode);
  154                }
  155                stepCall back(error );
  156           }) ;
  157       }, fun ction(erro r) {
  158           ca llback(err or);
  159       });
  160   }
  161  
  162   module.exp orts._step s = {
  163       _parse Patients:  parsePatie nts,
  164       _filte rInvalidIc nsOrPids:  filterInva lidIcnsOrP ids,
  165       _getUn syncReques t: getUnsy ncRequest
  166   };