707. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 4/5/2017 4:26:31 PM 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.

707.1 Files compared

# Location File Last Modified
1 C:\working_scrub\Unredacted\VAP Code Base\VAP_Bld2_Source_Code_CIF_2017-02-14\nvap-web\src\main\java\gov\va\nvap\web\announce BatchAnnounce.java Wed Feb 1 18:37:28 2017 UTC
2 eHX-CIF.zip\eHX-CIF\VAP Code Base\VAP_Bld2_Source_Code_CIF_2017-02-14\nvap-web\src\main\java\gov\va\nvap\web\announce BatchAnnounce.java Mon Apr 3 14:10:35 2017 UTC

707.2 Comparison summary

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

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

707.4 Active regular expressions

No regular expressions were active.

707.5 Comparison detail

  1   /**
  2    *
  3    */
  4   package go v.va.nvap. web.announ ce;
  5  
  6   import gov .va.nvap.c ommon.date .DateUtil;
  7   import gov .va.nvap.c ommon.vali dation.Nul lChecker;
  8   import gov .va.nvap.p rivacy.Org anizationT ype;
  9   import gov .va.nvap.s ervice.pdq .PatientMa tchQuery;
  10   import gov .va.nvap.s ervice.pdq .PatientMa tchRespons e;
  11   import gov .va.nvap.s ervice.pdq .PatientPr ofile;
  12   import gov .va.nvap.s ervice.pdq .PdqServic e;
  13   import gov .va.nvap.s vc.consent mgmt.PIPIn terface;
  14   import gov .va.nvap.s vc.consent mgmt.stub. adapter.an nounce.dat a.Announce ment;
  15   import gov .va.nvap.s vc.consent mgmt.stub. adapter.an nounce.dat a.Announce mentBatchS ummary;
  16   import gov .va.nvap.s vc.consent mgmt.stub. adapter.an nounce.dat a.Announce mentOrg;
  17   import gov .va.nvap.s vc.consent mgmt.stub. adapter.an nounce.dat a.Announce rInterface ;
  18   import gov .va.nvap.s vc.consent mgmt.stub. adapter.an nounce.dat a.PatientC onsentBatc hAnnounce;
  19   import gov .va.nvap.s vc.consent mgmt.stub. data.Organ ization;
  20   import gov .va.nvap.w eb.app.Res ponseDispa tcherHttpS ervlet;
  21   import gov .va.nvap.w eb.helper. facility.F acilityHel per;
  22   import gov .va.nvap.w eb.helper. privacy.Co nsentManag ementHelpe r;
  23   import gov .va.nvap.w eb.util.fi le.FileUpl oadUtil;
  24   import gov .va.nvap.w eb.util.fi le.FileUpl oader;
  25  
  26   import jav a.io.IOExc eption;
  27   import jav a.text.Par seExceptio n;
  28   import jav a.util.Arr ayList;
  29   import jav a.util.Arr ays;
  30   import jav a.util.Cal endar;
  31   import jav a.util.Col lection;
  32   import jav a.util.Dat e;
  33   import jav a.util.Has hSet;
  34   import jav a.util.Lis t;
  35   import jav a.util.Loc ale;
  36   import jav a.util.Map ;
  37   import jav a.util.log ging.Level ;
  38   import jav a.util.log ging.Logge r;
  39  
  40   import jav ax.ejb.EJB ;
  41   import jav ax.servlet .ServletEx ception;
  42   import jav ax.servlet .http.Http ServletReq uest;
  43   import jav ax.servlet .http.Http ServletRes ponse;
  44   import jav ax.servlet .http.Http Session;
  45  
  46   import org .apache.co mmons.file upload.Fil eItem;
  47   import org .apache.co mmons.io.F ilenameUti ls;
  48  
  49   /**
  50    * @author   DN S      SCHRAS
  51    *
  52    */
  53   public cla ss BatchAn nounce ext ends Respo nseDispatc herHttpSer vlet {
  54  
  55       privat e static f inal Strin g FLOW_QUE RY = "quer y";
  56       privat e static f inal Strin g FLOW_RES ULT = "res ult";
  57       privat e static f inal Strin g FLOW_SUC CEED = "su cceed";
  58       /**
  59        *
  60        */
  61       privat e static f inal long  serialVers ionUID = - 3136937675 789090144L ;
  62       
  63       // Tog gles seque ntial vs.  fan-out im plementati on for bat ch announc e
  64       privat e static f inal boole an SEQUENT IAL_ANNOUN CE = false ;
  65       
  66       privat e static f inal int M AX_ANNOUNC EMENT_RETR IEVAL = 10 00000;
  67  
  68       @EJB(b eanInterfa ce = Annou ncerInterf ace.class,  mappedNam e = "Annou ncerServic e")
  69       privat e Announce rInterface  announcer ;
  70  
  71       @EJB(b eanInterfa ce = PdqSe rvice.clas s, mappedN ame = "Pdq Service")
  72       privat e PdqServi ce pdqServ ice;
  73  
  74       @EJB(b eanInterfa ce = PIPIn terface.cl ass, mappe dName = "P ipService" )
  75       privat e PIPInter face pip;
  76  
  77       public  void acce pt(final H ttpServlet Request re quest,
  78                final Ht tpServletR esponse re sponse) th rows Servl etExceptio n,
  79                IOExcept ion {
  80           fi nal HttpSe ssion sess ion = requ est.getSes sion(false );
  81  
  82           fi nal Patien tConsentBa tchAnnounc e batchAnn ouncer = t his.getBea n(
  83                    "bat chAnnounce r", Patien tConsentBa tchAnnounc e.class);
  84           ba tchAnnounc er.batchAn nounce(
  85                    (Str ing[]) ses sion.getAt tribute("b atchIds"),
  86                    requ est.getRem oteUser(),
  87                    this .getFacili tyHelper() .getFacilt yStationId ByUserId(
  88                             reques t.getRemot eUser()));
  89           th is.initAtt ributes(se ssion, nul l, null, f alse,
  90                    Batc hAnnounce. FLOW_SUCCE ED, "");
  91           se ssion.remo veAttribut e("batchId s");
  92           se ssion.remo veAttribut e("batchSu mmary");
  93           th is.forward (request,  response,  BatchAnnou nce.FLOW_S UCCEED);
  94       }
  95  
  96       public  void canc el(final H ttpServlet Request re quest,
  97                final Ht tpServletR esponse re sponse) th rows Servl etExceptio n,
  98                IOExcept ion {
  99           fi nal HttpSe ssion sess ion = requ est.getSes sion(false );
  100           fi nal String [] batchId sArray = ( String[])  session
  101                    .get Attribute( "batchIds" );
  102           if  (!NullChe cker.isNul lOrEmpty(b atchIdsArr ay)) {
  103                Collecti on<Announc ement> ann ouncements  = new Arr ayList<Ann ouncement> ();
  104                for (Str ing batchI d : batchI dsArray) {
  105                    anno uncements. addAll(thi s.announce r.getUnsch eduledAnno uncementsB yBatchId(b atchId, MA X_ANNOUNCE MENT_RETRI EVAL, 0));
  106                }
  107                for (Ann ouncement  announceme nt : annou ncements)  {
  108                    this .announcer .removeByA nnouncemen t(announce ment);
  109                }
  110                this.ann ouncer.rem oveAnnounc ementBatch es(Arrays. asList(bat chIdsArray ));
  111           }
  112           tr y {
  113                String s tartDate =  session.g etAttribut e("startDa te") == nu ll ? "" :  session.ge tAttribute ("startDat e").toStri ng();
  114                String e ndDate = s ession.get Attribute( "endDate")  == null ?  "" : sess ion.getAtt ribute("en dDate").to String();
  115                boolean  reannounce  = session .getAttrib ute("reann ounce") ==  null ? fa lse : (Boo lean) sess ion.getAtt ribute("re announce") ;
  116                this.ini tAttribute s(session,  startDate , endDate,  reannounc e, BatchAn nounce.FLO W_QUERY, " Batch Anno uncement h as been ca ncelled.") ;
  117           }  catch (Exc eption ex)  {
  118                String m sg = ex.ge tMessage() ;
  119           }
  120           th is.forward (request,  response,  BatchAnnou nce.FLOW_Q UERY);
  121       }
  122  
  123       public  ConsentMa nagementHe lper getCm sHelper()  {
  124           fi nal Consen tManagemen tHelper cm sHelper =  this.getBe an("cmsHel per",
  125                    Cons entManagem entHelper. class);
  126           re turn cmsHe lper;
  127       }
  128  
  129       /**
  130        * Get  the facil ity helper  from Spri ng.
  131        */
  132       public  FacilityH elper getF acilityHel per() {
  133           fi nal Facili tyHelper f acilityHel per = this .getBean(" facilityHe lper",
  134                    Faci lityHelper .class);
  135           re turn facil ityHelper;
  136       }
  137  
  138       privat e HashSet< String> ge tUploadedI ens(List<M ap<String,  String>>  listOfPati ents) {
  139           Ha shSet<Stri ng> upload edIens = n ew HashSet <String>() ;
  140           
  141           fo r (Map<Str ing, Strin g> patient  : listOfP atients) {
  142                final Pa tientMatch Query pati entSearchR equest = n ew Patient MatchQuery ();
  143                final Pa tientProfi le patient Profile =  new Patien tProfile() ;
  144                patientP rofile.set FirstName( patient.ge t("firstna me"));
  145                patientP rofile.set LastName(p atient.get ("lastname "));
  146                patientP rofile.set Ssn(patien t.get("ssn "));
  147                patientS earchReque st.setPati entProfile (patientPr ofile);
  148                
  149                try {
  150                    fina l PatientM atchRespon se patient SearchResp onse = thi s.pdqServi ce.searchP atient(pat ientSearch Request);
  151                    fina l List<Pat ientProfil e> patient s = patien tSearchRes ponse.getP atients(). getPatient Profile();
  152  
  153                    if ( patients.s ize() == 1 ) {
  154                         uploadedIe ns.add(pat ients.get( 0).getIcn( ));
  155                    }
  156                } catch  (Exception  e) {
  157                    // T ODO log?
  158                }
  159           }
  160           
  161           re turn uploa dedIens;
  162       }
  163       
  164       privat e void ini tAttribute s(final Ht tpSession  session,
  165                final St ring start Date, fina l String e ndDate,
  166                final bo olean rean nounce, fi nal String  flow, fin al String  outcome) {
  167                final Li st<Organiz ationType>  orgs = (L ist) this. getCmsHelp er().getAl lowedNonCo nsumerOnly Organizati ons();
  168           /*
  169            *  Collectio ns.sort((L ist) orgs,  new Compa rator<Orga nizationTy pe>() {
  170            *
  171            *  @Override  public in t compare( Organizati onType o1,  Organizat ionType
  172            *  o2) { ret urn o1.get OrgName(). compareTo( o2.getOrgN ame()); }  });
  173            * /
  174           se ssion.setA ttribute(" organizati ons", orgs );
  175           se ssion.setA ttribute(" startDate" , startDat e);
  176           se ssion.setA ttribute(" endDate",  endDate);
  177           se ssion.setA ttribute(" reannounce ", reannou nce);
  178           se ssion.setA ttribute(" flow", flo w);
  179           se ssion.setA ttribute(" outcome",  outcome);
  180       }
  181  
  182       privat e Date par seDate(fin al String  strDate, f inal boole an endOfDa y) {
  183           fi nal Date d ate = null ;
  184           if  ((null !=  strDate)  && (0 < st rDate.leng th())) {
  185                final St ring forma t = "%s "
  186                         + (endOfDa y ? "11:59 :59 PM" :  "00:00:00  AM");
  187                             // mat ches the d ate input  format
  188                // if (s trDate.mat ches("\\d{ 1,2}/\\d{1 ,2}/\\d{4} ")) {
  189                try {
  190                    retu rn DateUti l.parseDat eFromStrin g(String.f ormat(form at,
  191                             strDat e));
  192                } catch  (final Par seExceptio n ex) {
  193                    Logg er.getLogg er(BatchAn nounce.cla ss.getName ()).log(
  194                             Level. SEVERE, nu ll, ex);
  195                    thro w new Ille galArgumen tException (ex);
  196                }
  197                             // }
  198                // throw  new Illeg alArgument Exception( "Date must  be MM/dd/ yyyy");
  199           }
  200           re turn date;
  201       }
  202  
  203       public  void quer y(final Li st<FileIte m> fileIte ms, final  HttpServle tRequest r equest,
  204                final Ht tpServletR esponse re sponse) th rows Servl etExceptio n,
  205                IOExcept ion {
  206           
  207           fi nal HttpSe ssion sess ion = requ est.getSes sion(false );
  208           fi nal Map<St ring, Stri ng> formFi elds = Fil eUploadUti l.getFormF ields(file Items);
  209           fi nal String  orgIdsLis t = formFi elds.get(" remoteOrga nization") ;
  210           fi nal String  startDate Str = form Fields.get ("startDat e");
  211           fi nal String  endDateSt r = formFi elds.get(" endDate");
  212           fi nal boolea n reannoun ce = "rean nounce".eq uals(formF ields.get( "reannounc e"));
  213           fi nal String  batchAnno unceType =  formField s.get("bat chAnnounce Type");        
  214           St ring error Message =  "";
  215           St ring[] org Ids;
  216           Li st<String>  batchIds  = null;
  217           Li st<Announc ementBatch Summary> s ummary = n ull;
  218           
  219           if  (orgIdsLi st == null ) {
  220                errorMes sage = "No  patients  found for  criteria." ;
  221           }  else {
  222                orgIds =  orgIdsLis t.split(", ");
  223                
  224                if (batc hAnnounceT ype.equals ("1")) {
  225                    if ( this.valid ate(formFi elds, requ est, respo nse, "quer y")) {
  226                         Date endDa te;
  227                         if (NullCh ecker.isEm pty(endDat eStr)) {
  228                             endDat e = gov.va .nvap.web. util.date. DateUtil.a ddTime(new  Date(), C alendar.HO UR, 24);
  229                         } else {
  230                             endDat e = this.p arseDate(e ndDateStr,  true);
  231                         }
  232  
  233                         if (SEQUEN TIAL_ANNOU NCE) {
  234                             batchI ds = this. createBatc hSequentia l(orgIds,  request.ge tRemoteUse r(), 
  235                                      this.par seDate(sta rtDateStr,  false), e ndDate, re announce);
  236                         } else {
  237                             batchI ds = this. createBatc hConcurren t(orgIds,  request.ge tRemoteUse r(), 
  238                                      this.par seDate(sta rtDateStr,  false), e ndDate, re announce);
  239                         }
  240                        
  241                         summary =  this.annou ncer.getBa tchSummary (batchIds) ;
  242                         if (summar y.isEmpty( )) {
  243                             errorM essage = " No patient s found fo r criteria .";
  244                         }
  245                    } el se {
  246                         this.forwa rd(request , response , "validat e");
  247                         return;
  248                    }       
  249                } else {
  250                    fina l List<Fil eItem> fil esUploaded  = FileUpl oadUtil.ge tFilesUplo aded(fileI tems);
  251                    List <Map<Strin g, String> > listOfPa tients = n ull;
  252                    Hash Set<String > uploaded Iens;
  253                    File Item fileI tem = file sUploaded. get(0);
  254                    Stri ng fileNam e = Filena meUtils.ge tName(file Item.getNa me());
  255  
  256                    if ( !NullCheck er.isEmpty (fileName) ) {
  257                         try {
  258                             if (fi leName.toL owerCase(L ocale.ENGL ISH).endsW ith(".csv" )) {
  259                                 li stOfPatien ts = FileU ploader.re adCSV(file Item);
  260                             } else  if (fileN ame.toLowe rCase(Loca le.ENGLISH ).endsWith (".xls") | | fileName .toLowerCa se(Locale. ENGLISH).e ndsWith(". xlsx")) {
  261                                 li stOfPatien ts = FileU ploader.re adExcel(fi leItem);
  262                             }
  263                             if (li stOfPatien ts == null  || listOf Patients.i sEmpty())  {
  264                                 er rorMessage  = "Upload ed file do esn't cont ain any pa tients";
  265                             } else  {
  266                                 up loadedIens  = getUplo adedIens(l istOfPatie nts);
  267                                 
  268                                 if  (SEQUENTI AL_ANNOUNC E) {
  269                                      batchIds  = this.cr eateBatchS equential( orgIds, re quest.getR emoteUser( ), uploade dIens);
  270                                 }  else {
  271                                      batchIds  = this.cr eateBatchC oncurrent( orgIds, re quest.getR emoteUser( ), uploade dIens);
  272                                 }
  273  
  274                                 su mmary = th is.announc er.getBatc hSummary(b atchIds);
  275                                 if  (summary. isEmpty())  {
  276                                      errorMes sage = "Up loaded fil e doesn't  contain an y known pa tients.";
  277                                 }                                    
  278                             }
  279                         } catch (E xception e ) {
  280                             errorM essage = e .getMessag e();
  281                         }
  282                    }
  283                }
  284           }
  285  
  286           se ssion.setA ttribute(" batchIds",  batchIds  == null ?  null : bat chIds.toAr ray(new St ring[batch Ids.size() ]));
  287           se ssion.setA ttribute(" batchSumma ry", summa ry);
  288           se ssion.setA ttribute(" errorMessa ge", error Message);
  289  
  290           th is.initAtt ributes(se ssion, sta rtDateStr,  endDateSt r, reannou nce, Batch Announce.F LOW_RESULT , "");
  291           th is.forward (request,  response,  BatchAnnou nce.FLOW_R ESULT);
  292       }
  293       
  294       ArrayL ist<String > createBa tchSequent ial(String [] orgIds,  String us erId, Date  startDate , Date end Date, bool ean reanno unce) {
  295           Ar rayList<St ring> batc hIds = new  ArrayList <String>(o rgIds.leng th);
  296           fo r (final S tring orgO id : orgId s) {
  297                final Or ganization  organizat ion = this .pip.getOr ganization ByOid(orgO id);
  298                final St ring batch Id = this. announcer. createAnno uncementsB atch(organ ization, u serId, sta rtDate, en dDate, rea nnounce);
  299                batchIds .add(batch Id);
  300           }
  301           
  302           re turn batch Ids;
  303       }
  304       
  305       ArrayL ist<String > createBa tchSequent ial(String [] orgIds,  String us erId, Hash Set<String > uploaded Iens) {
  306           Ar rayList<St ring> batc hIds = new  ArrayList <String>(o rgIds.leng th);
  307           fo r (final S tring orgO id : orgId s) {
  308                final Or ganization  organizat ion = this .pip.getOr ganization ByOid(orgO id);
  309                final St ring batch Id = this. announcer. createAnno uncementsB atch(organ ization, u serId, upl oadedIens) ;
  310                batchIds .add(batch Id);
  311           }
  312           
  313           re turn batch Ids;
  314       }
  315       
  316       ArrayL ist<String > createBa tchConcurr ent(String [] orgIds,  String us erId, Date  startDate , Date end Date, bool ean reanno unce) {
  317           Ar rayList<St ring> batc hIds = new  ArrayList <String>() ;
  318           Co llection<O rganizatio n> organiz ations = n ew ArrayLi st<Organiz ation>();
  319           fo r (final S tring orgO id : orgId s) {
  320                final Or ganization  organizat ion = this .pip.getOr ganization ByOid(orgO id);
  321                organiza tions.add( organizati on);
  322           }
  323           
  324           St ring batch Id = this. announcer. createAnno uncementsB atch(organ izations,  userId, st artDate, e ndDate, re announce);
  325           Co llection<A nnouncemen t> announc ements = t his.announ cer.getUns cheduledAn nouncement sByBatchId (batchId,  MAX_ANNOUN CEMENT_RET RIEVAL, 0) ;
  326           fo r (Announc ement anno unce : ann ouncements ) {
  327                for (Org anization  org : orga nizations)  {
  328                    Anno uncementOr g announce Org = new  Announceme ntOrg();
  329                    anno unceOrg.se tAnnouncem ent(announ ce);
  330                    anno unceOrg.se tTargetOrg anization( org);
  331                    try  {
  332                         this.annou ncer.creat eAnnouncem entOrg(ann ounceOrg);
  333                    } ca tch (Excep tion ex) {
  334                         // Announc eOrg stora ge fail
  335                    }
  336                }
  337           }
  338           ba tchIds.add (batchId);
  339           re turn batch Ids;
  340       }
  341       
  342       ArrayL ist<String > createBa tchConcurr ent(String [] orgIds,  String us erId, Hash Set<String > uploaded Iens) {
  343           Ar rayList<St ring> batc hIds = new  ArrayList <String>(o rgIds.leng th);
  344           Co llection<O rganizatio n> organiz ations = n ew ArrayLi st<Organiz ation>();
  345           fo r (final S tring orgO id : orgId s) {
  346                final Or ganization  organizat ion = this .pip.getOr ganization ByOid(orgO id);
  347                organiza tions.add( organizati on);
  348           }
  349  
  350           St ring batch Id = this. announcer. createAnno uncementsB atch(organ izations,  userId, up loadedIens );
  351           Co llection<A nnouncemen t> announc ements = t his.announ cer.getUns cheduledAn nouncement sByBatchId (batchId,  MAX_ANNOUN CEMENT_RET RIEVAL, 0) ;
  352           fo r (Announc ement anno unce : ann ouncements ) {
  353                for (Org anization  org : orga nizations)  {
  354                    Anno uncementOr g announce Org = new  Announceme ntOrg();
  355                    anno unceOrg.se tAnnouncem ent(announ ce);
  356                    anno unceOrg.se tTargetOrg anization( org);
  357                    try  {
  358                         this.annou ncer.creat eAnnouncem entOrg(ann ounceOrg);
  359                    } ca tch (Excep tion ex) {
  360                         // Announc eOrg stora ge fail
  361                    }
  362                }
  363           }
  364           ba tchIds.add (batchId);
  365           re turn batch Ids;
  366       }
  367  
  368       /*
  369        * (no n-Javadoc)
  370        *
  371        * @se e gov.va.n vap.web.ap p.Response Dispatcher HttpServle t#unspecif ied
  372        * (ja vax.servle t.http.Htt pServletRe quest,
  373        * jav ax.servlet .http.Http ServletRes ponse)
  374        */
  375       @Overr ide
  376       protec ted void u nspecified (final Htt pServletRe quest requ est,
  377                final Ht tpServletR esponse re sponse) th rows Servl etExceptio n,
  378                IOExcept ion {
  379           fi nal HttpSe ssion sess ion = requ est.getSes sion(false );
  380           se ssion.remo veAttribut e("errorMe ssage");
  381           th is.initAtt ributes(se ssion, nul l, null, f alse,
  382                    Batc hAnnounce. FLOW_QUERY , "");
  383                   
  384           th is.forward (request,  response,  BatchAnnou nce.FLOW_Q UERY);
  385       }
  386  
  387   }