4254. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 6/9/2017 3:51:24 PM Eastern 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.

4254.1 Files compared

# Location File Last Modified
1 Fri Jun 9 19:51:24 2017 UTC
2 eHealth_Exch (eHealth Exchange Enhancements) Build 3 docs & code_May_2017.zip\VAP_CIF_CODE0502.zip\VAP_CIF_CODE0502\VAP_CIF_CODE0502\nvap-web\src\main\java\gov\va\nvap\web\announce BatchAnnounce.java Mon Jun 5 03:33:02 2017 UTC

4254.2 Comparison summary

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

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

4254.4 Active regular expressions

No regular expressions were active.

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