3920. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 6/9/2017 3:50:59 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.

3920.1 Files compared

# Location File Last Modified
1 Fri Jun 9 19:50:59 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-server\src\main\java\gov\va\nvap\server\service\privacy ExpiringConsentServiceImpl.java Fri Apr 21 20:03:28 2017 UTC

3920.2 Comparison summary

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

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

3920.4 Active regular expressions

No regular expressions were active.

3920.5 Comparison detail

        1   package go v.va.nvap. server.ser vice.priva cy;
        2  
        3   import gov .va.med.nh in.adapter .audit.Pag eInfoType;
        4   import gov .va.nvap.c ommon.vali dation.Nul lChecker;
        5   import gov .va.nvap.p rivacy.Con sentDirect iveDetaile dExpiratio nRequest;
        6   import gov .va.nvap.p rivacy.Con sentType;
        7   import gov .va.nvap.p rivacy.Exp iringConse ntConfigur ationRefer enceType;
        8   import gov .va.nvap.p rivacy.Exp iringConse ntConfigur ationReque st;
        9   import gov .va.nvap.p rivacy.Exp iringConse ntConfigur ationRespo nse;
        10   import gov .va.nvap.p rivacy.Exp iringConse ntLetterRe sponse;
        11   import gov .va.nvap.s erver.endp oint.psim. PersonServ iceInterfa ce;
        12   import gov .va.nvap.s erver.serv ice.privac y.emailer. Emailer;
        13   import gov .va.nvap.s erver.serv ice.privac y.pdf.PdfG enerator;
        14   import gov .va.nvap.s ervice.pdq .PatientDe mographics ;
        15   import gov .va.nvap.s ervice.pdq .PatientDe mographics Query;
        16   import gov .va.nvap.s ervice.pdq .PatientDe mographics Response;
        17   import gov .va.nvap.s ervice.pdq .PdqExcept ion;
        18   import gov .va.nvap.s ervice.pdq .PdqServic e;
        19   import gov .va.nvap.s ervice.pri vacy.Expir ingConsent Service;
        20   import gov .va.nvap.s vc.consent mgmt.PIPIn terface;
        21   import gov .va.nvap.s vc.consent mgmt.stub. data.Conse ntDirectiv e;
        22   import gov .va.nvap.s vc.consent mgmt.stub. data.Detai ledConsent Directive;
        23   import gov .va.nvap.s vc.consent mgmt.stub. data.Expir ingConsent Configurat ion;
        24   import gov .va.nvap.s vc.consent mgmt.stub. data.Facil ity;
        25   import jav a.io.ByteA rrayOutput Stream;
        26   import jav a.io.IOExc eption;
        27   import jav a.io.Input Stream;
        28   import jav a.text.Sim pleDateFor mat;
        29   import jav a.util.Arr ayList;
        30   import jav a.util.Col lection;
        31   import jav a.util.Dat e;
        32   import jav a.util.Has hMap;
        33   import jav a.util.Lis t;
        34   import jav a.util.Map ;
        35   import jav a.util.Sca nner;
        36   import jav a.util.log ging.Level ;
        37   import jav a.util.log ging.Logge r;
        38   import org .apache.co mmons.io.I OUtils;
        39   import org .dozer.Map per;
        40   import org .quartz.Cr onTrigger;
        41   import org .quartz.Sc heduler;
        42   import org .springfra mework.bea ns.factory .annotatio n.Autowire d;
        43   import org .springfra mework.bea ns.factory .annotatio n.Required ;
        44   import org .springfra mework.con text.Appli cationCont ext;
        45  
        46   /**
        47    *
        48    * @author  Zack Pete rson
        49    */
        50   public cla ss Expirin gConsentSe rviceImpl  implements  ExpiringC onsentServ ice {
        51  
        52       privat e static f inal Logge r logger =  Logger
        53           .g etLogger(E xpiringCon sentServic eImpl.clas s.getName( ));
        54  
        55       privat e PIPInter face pip;
        56       privat e Mapper m apper;
        57       privat e PersonSe rviceInter face perso nService;
        58       privat e PdqServi ce pdqServ ice;
        59  
        60       @Autow ired
        61       privat e Applicat ionContext  appContex t;
        62  
        63       @Overr ide
        64       public  ExpiringC onsentConf igurationR esponse
        65           ge tConfigura tion(Expir ingConsent Configurat ionRequest  configReq uest) {
        66  
        67           //  Get the a ctive cons ent config uration
        68           fi nal Expiri ngConsentC onfigurati on configu ration = p ip.getExpi ringConsen tConfigura tion();
        69  
        70           //  Convert t o referenc e type
        71           fi nal Expiri ngConsentC onfigurati onReferenc eType conf igReferenc e = this.m apper
        72                .map(con figuration , Expiring ConsentCon figuration ReferenceT ype.class) ;
        73  
        74           //  Make the  response
        75           Ex piringCons entConfigu rationResp onse respo nse = new  ExpiringCo nsentConfi gurationRe sponse();
        76           if  (configRe ference !=  null) {
        77                response .setConfig urationRef erence(con figReferen ce);
        78           }
        79           re turn respo nse;
        80       }
        81  
        82       @Overr ide
        83       public  void upda teConfigur ation(Expi ringConsen tConfigura tionReques t configRe quest) {
        84  
        85           fi nal Expiri ngConsentC onfigurati on configu ration
        86                = new Ex piringCons entConfigu ration(con figRequest .getFreque ncy(), con figRequest .getWindow (),
        87                    conf igRequest. getEmailAd dresses()) ;
        88  
        89           Sc heduler sc heduler =  (Scheduler ) appConte xt.getBean ("schedule Factory");
        90  
        91           //  Periods a ssume firs t instance  of time p eriod
        92           fi nal String  HOURLY_PR EFIX = "0  0 * ";
        93           fi nal String  MIDNIGHT_ PREFIX = " 0 0 0 ";
        94           fi nal String  DAILY = " * * ?";
        95           fi nal String  WEEKLY =  "? * 1";
        96           fi nal String  MONTHLY =  "1 * ?";
        97           fi nal String  YEARLY =  "1 1 ? *";
        98  
        99           //  Set job t rigger to  new time p eriod
        100           tr y {
        101                CronTrig ger trigge r = (CronT rigger) sc heduler.ge tTrigger(" expiringCo nsentCronT rigger", " DEFAULT");
        102  
        103                String c ronExpress ion;
        104                if (conf igRequest. getFrequen cy().equal s("HOURLY" )) {
        105                    cron Expression  = HOURLY_ PREFIX + D AILY;
        106                } else i f (configR equest.get Frequency( ).equals(" DAILY")) {
        107                    cron Expression  = MIDNIGH T_PREFIX +  DAILY;
        108                } else i f (configR equest.get Frequency( ).equals(" WEEKLY"))  {
        109                    cron Expression  = MIDNIGH T_PREFIX +  WEEKLY;
        110                } else i f (configR equest.get Frequency( ).equals(" MONTHLY"))  {
        111                    cron Expression  = MIDNIGH T_PREFIX +  MONTHLY;
        112                } else i f (configR equest.get Frequency( ).equals(" YEARLY"))  {
        113                    cron Expression  = MIDNIGH T_PREFIX +  YEARLY;
        114                } else {
        115                    // M onthly
        116                    cron Expression  = MIDNIGH T_PREFIX +  MONTHLY;
        117                    // E very 20 se conds
        118                    //cr onExpressi on = "0/20  * * * * ? ";
        119                }
        120  
        121                trigger. setCronExp ression(cr onExpressi on);
        122                schedule r.reschedu leJob("exp iringConse ntCronTrig ger", "DEF AULT", tri gger);
        123           }  catch (Exc eption ex)  {
        124                //TODO:  Handle exc eption
        125           }
        126  
        127           th is.pip.upd ateExpirin gConsentCo nfiguratio n(configur ation);
        128       }
        129  
        130       @Overr ide
        131       public  ExpiringC onsentLett erResponse  getReport Letters(Co nsentDirec tiveDetail edExpirati onRequest  configRequ est) throw s IOExcept ion {
        132           //  Set page  info to in clude all  results
        133  
        134           //  Get expir ing active  consent d irectives
        135           Pa geInfoType  pageInfo  = new Page InfoType() ;
        136           pa geInfo.set PageNumber (0);
        137           pa geInfo.set PageSize(- 1);
        138           co nfigReques t.setPageI nfo(pageIn fo);
        139  
        140           fi nal Simple DateFormat  letterFor mat = new  SimpleDate Format("MM /dd/yyyy") ;
        141           fi nal Collec tion<Detai ledConsent Directive>  consentDi rectives =  this.pip. getExpirin gPatientDe tailedCons entDirecti ves(config Request);
        142  
        143           fi nal ArrayL ist<HashMa p<String,  String>> r esults = n ew ArrayLi st<HashMap <String, S tring>>();
        144           St ring templ ate = conf igRequest. getTemplat e(); //we  need to mo d this for  the patie nt address  so that's  why we ar e grabbing  it here
        145           Fa cility fac  = this.pi p.getFacil ityByStati onId(confi gRequest.g etFacility Station()) ;
        146           fo r (final D etailedCon sentDirect ive cd : c onsentDire ctives) {
        147                if (Null Checker.is NotEmpty(c d)) {
        148                    // T emporary f ix to prin t out NwHI N Authoriz ations onl y
        149                    if ( NullChecke r.isEmpty( cd.getOpti nConsentTy pe())) {
        150                         continue;
        151                    }
        152                    if ( !cd.getOpt inConsentT ype().getN ame().equa ls("NwHIN  Authorizat ion")) {
        153                         continue;
        154                    }
        155                    fina l HashMap< String, St ring> resu ltMap = ne w HashMap< String, St ring>();
        156  
        157                    fina l String i en = cd.ge tPatientIe n();
        158                    // A ssumes tha t there is  only one  icn for ev ery ien
        159                    fina l String i cn = this. personServ ice.getCor relatedIds (ien).get( 0);
        160  
        161                    Pati entDemogra phicsQuery  demograph icsQuery =  new Patie ntDemograp hicsQuery( );
        162                    demo graphicsQu ery.setPat ientId(icn );
        163  
        164                    Pati entDemogra phicsRespo nse demogr aphicsResp onse;
        165  
        166                    try  {
        167                         demographi csResponse  = this.pd qService.g etPatientD emographic s(demograp hicsQuery) ;
        168                         final Pati entDemogra phics demo graphics =  demograph icsRespons e.getPatie ntDemograp hics();
        169                        
        170                         if (demogr aphics !=  null) {
        171                             try {
        172                                 re sultMap.pu t("[lastNa me]", demo graphics.g etLastName ());
        173                                 re sultMap.pu t("[firstN ame]", dem ographics. getFirstNa me());
        174                                 re sultMap.pu t("[middle Name]", de mographics .getMiddle Name());
        175  
        176                                 fi nal String  streetAdd ressLine1  = demograp hics.getSt reetAddres sLine1();
        177                                 fi nal String  streetAdd ressLine2  = demograp hics.getSt reetAddres sLine2();
        178                                 fi nal String  streetAdd ressLine3  = demograp hics.getSt reetAddres sLine3();
        179                                 fi nal String  city = de mographics .getReside nceCity();
        180                                 fi nal String  state = d emographic s.getResid enceState( );
        181                                 fi nal String  zip = dem ographics. getResiden ceZip4();
        182                                 St ring patie ntAddress  = streetAd dressLine1  + "\n";
        183                                 if  (streetAd dressLine2  != null & & !streetA ddressLine 2.equals(" ")) {
        184                                      patientA ddress +=  " " + stre etAddressL ine2 + "\n ";
        185                                 }
        186                                 if  (streetAd dressLine3  != null & & !streetA ddressLine 3.equals(" ")) {
        187                                      patientA ddress +=  " " + stre etAddressL ine3 + "\n ";
        188                                 }
        189                                 pa tientAddre ss += city  + ", " +  state + "  " + zip;
        190  
        191                                 // need to ac tually rep lace the s tring here  so the li ne breaks  work...
        192                                 re sultMap.pu t("[patien tAddress]" , patientA ddress);
        193  
        194                                 re sultMap.pu t("[facili tyName]",  fac.getFac ilityName( ));
        195                                 St ring addre ss1 = (fac .getAddres s() != nul l) ? fac.g etAddress( ) : "";
        196                                 re sultMap.pu t("[facili tyAddress1 ]", addres s1);
        197                                 St ring addre ss2 = (fac .getCity()  != null)  ? fac.getC ity() + ",  " : "";
        198                                 ad dress2 +=  (fac.getSt ate() != n ull) ? fac .getState( ) + " " :  "";
        199                                 ad dress2 +=  (fac.getPo stalCode()  != null)  ? fac.getP ostalCode( ) : "";
        200                                 re sultMap.pu t("[facili tyAddress2 ]", addres s2);
        201                                 St ring phone  = (fac.ge tPhone() ! = null) ?  fac.getPho ne() : "";
        202                                 if  (!NullChe cker.isNul lOrEmpty(p hone)) {
        203                                      phone =  "(" + phon e.substrin g(0, 3) +  ") " + pho ne.substri ng(3, 6) +  "-" + pho ne.substri ng(6);
        204                                 }
        205                                 re sultMap.pu t("[facili tyPhone]",  phone);
        206                             } catc h (Excepti on e) {
        207                                 re sultMap.cl ear();
        208                                 Ex piringCons entService Impl.logge r.log(Leve l.INFO, e. getMessage ());
        209                             }
        210                         }
        211                        
        212                         if (demogr aphics ==  null || re sultMap.si ze() == 0)  {
        213                             result Map.put("[ lastName]" , "[lastNa me]");
        214                             result Map.put("[ firstName] ", "[first Name]");
        215                             result Map.put("[ middleName ]", "[midd leName]");
        216                             result Map.put("[ patientAdd ress]", "[ patientAdd ress]");
        217  
        218                             // Thi s will be  changed to  an actual  address w hen availa ble
        219                             result Map.put("[ facilityNa me]", "VA  Office");
        220                             result Map.put("[ facilityAd dress1]",  "");
        221                             result Map.put("[ facilityAd dress2]",  "");
        222                             result Map.put("[ facilityPh one]", "") ;
        223                         }
        224  
        225                         //add all  the consen t attribut es to the  letter
        226                         resultMap. put("[date ]", new Si mpleDateFo rmat("MMMM  dd, yyyy" ).format(n ew Date()) );
        227                         resultMap. put("[expi rationDate ]", letter Format.for mat(cd.get Expiration Date()));
        228  
        229                         String sig nature = " The VLER H ealth Nati onal Progr am Office" ;
        230                         resultMap. put("[sign ature]", s ignature);
        231                        
        232                         results.ad d(resultMa p);
        233                    } ca tch (PdqEx ception e)  {
        234                         ExpiringCo nsentServi ceImpl.log ger.log(Le vel.INFO,
        235                             "Error  getting p atient dem ographics:  %s", e.ge tMessage() );
        236                    } ca tch (Excep tion e) {
        237                         ExpiringCo nsentServi ceImpl.log ger.log(Le vel.INFO,
        238                             "Error  processin g patient:  %s", e.ge tMessage() );
        239                    }
        240                }
        241           }
        242  
        243           In putStream  inputStrea m = null;
        244           St ring templ ateString  = "";
        245           tr y {
        246                inputStr eam = IOUt ils.toInpu tStream(te mplate, "U TF-8");
        247                template String = n ew Scanner (inputStre am, "UTF-8 ").useDeli miter("\\A ").next();
        248           }
        249           fi nally {
        250                try {
        251                    if ( inputStrea m != null)  {
        252                       i nputStream .close();
        253                    }
        254                }
        255                catch (E xception e ) {
        256  
        257                }
        258           }
        259  
        260           Pd fGenerator  pdfGenera tor = new  PdfGenerat or();
        261           By teArrayOut putStream  pdfStream  = pdfGener ator.creat e(template String, re sults, "ex piring");
        262  
        263           by te[] byteD ata = pdfS tream.toBy teArray();
        264  
        265           Ex piringCons entLetterR esponse re sponse = n ew Expirin gConsentLe tterRespon se();
        266           re sponse.set DownloadBy teArray(by teData);
        267  
        268           re turn respo nse;
        269       }
        270  
        271       @Overr ide
        272       public  void send Report(Exp iringConse ntConfigur ationReque st configR equest) {
        273  
        274           //  Get curre nt day win dow
        275           fi nal int wi ndow = Int eger.value Of(pip.get ExpiringCo nsentConfi guration() .getWindow ().toStrin g());
        276  
        277           Co nsentDirec tiveDetail edExpirati onRequest  cdExpReq =  new Conse ntDirectiv eDetailedE xpirationR equest();
        278           cd ExpReq.set DayRange(w indow);
        279           Pa geInfoType  pageInfo  = new Page InfoType() ;
        280           pa geInfo.set PageNumber (0);
        281           pa geInfo.set PageSize(- 1);
        282           cd ExpReq.set PageInfo(p ageInfo);
        283  
        284           //  Get expir ing active  consent d irectives
        285           fi nal Collec tion<Conse ntDirectiv e> consent Directives  = this.pi p.getExpir ingPatient ConsentDir ectives(nu ll, cdExpR eq);
        286  
        287           //  Expiring  Consent Co unters
        288           in t totalExp irations =  0;
        289           in t eheExpir ations = 0 ;
        290           in t ssaExpir ations = 0 ;
        291           in t eagExpir ations = 0 ;
        292           in t dasExpir ations = 0 ;
        293           in t mhvExpir ations = 0 ;
        294           in t unknownE xpirations  = 0;
        295  
        296           fi nal List<M ap<String,  Object>>  results =  new ArrayL ist<Map<St ring, Obje ct>>();
        297           fo r (final C onsentDire ctive cd :  consentDi rectives)  {
        298                if (Null Checker.is NotEmpty(c d)) {
        299  
        300                    tota lExpiratio ns++;
        301  
        302                    fina l Map<Stri ng, Object > resultMa p = new Ha shMap<Stri ng, Object >();
        303  
        304                    fina l String i en = cd.ge tPatientIe n();
        305                    // A ssumes tha t there is  only one  icn for ev ery ien
        306                    fina l String i cn = this. personServ ice.getCor relatedIds (ien).get( 0);
        307  
        308                    Pati entDemogra phicsQuery  demograph icsQuery =  new Patie ntDemograp hicsQuery( );
        309                    demo graphicsQu ery.setPat ientId(icn );
        310  
        311                    Pati entDemogra phicsRespo nse demogr aphicsResp onse = new  PatientDe mographics Response() ;
        312                    try  {
        313                         demographi csResponse  = this.pd qService.g etPatientD emographic s(demograp hicsQuery) ;
        314                         final Pati entDemogra phics demo graphics =  demograph icsRespons e.getPatie ntDemograp hics();
        315  
        316                         String ssn  = demogra phics.getS sn();
        317                         if (!ssn.e qualsIgnor eCase("Unk nown") &&  !ssn.isEmp ty()) {
        318                             ssn =  ssn.replac eAll("\\p{ Z}", "");
        319                             ssn =  ssn.substr ing(0, 3)  + "-"
        320                                 +  ssn.substr ing(3, 5)  + "-"
        321                                 +  ssn.substr ing(5, 9);
        322                         }
        323                         final Stri ng maskedP atientSSN  = "***-**"  + ssn.sub string(6);
        324                         resultMap. put("ssn",  maskedPat ientSSN);
        325                         resultMap. put("lastN ame", demo graphics.g etLastName ());
        326                         resultMap. put("first Name", dem ographics. getFirstNa me());
        327                         resultMap. put("middl eName", de mographics .getMiddle Name());
        328                    } ca tch (PdqEx ception e)  {
        329                         // TODO: H andle Exce ption
        330                    }
        331  
        332                    Stri ng consent Type = cd. getOptinCo nsentType( ).getName( );
        333  
        334                    // C ount for c onsent typ e
        335                    if ( consentTyp e.equals(C onsentType .NW_HIN_AU THORIZATIO N.value()) ) {
        336                         eheExpirat ions++;
        337                    } el se if (con sentType.e quals(Cons entType.SS A_AUTHORIZ ATION.valu e())) {
        338                         ssaExpirat ions++;
        339                    } el se if (con sentType.e quals(Cons entType.EA G_AUTHORIZ ATION.valu e())) {
        340                         eagExpirat ions++;
        341                    } el se if (con sentType.e quals(Cons entType.DA S_AUTHORIZ ATION.valu e())) {
        342                         dasExpirat ions++;
        343                    } el se if (con sentType.e quals(Cons entType.MH V_AUTHORIZ ATION.valu e())) {
        344                         mhvExpirat ions++;
        345                    } el se {
        346                         unknownExp irations++ ;
        347                    }
        348  
        349                    resu ltMap.put( "consentTy pe", conse ntType);
        350                    resu ltMap.put( "optInDate ", cd.getO ptinDate() );
        351                    resu ltMap.put( "expiratio nDate", cd .getExpira tionDate() );
        352  
        353                    resu lts.add(re sultMap);
        354                }
        355           }
        356  
        357           St ring bodyS tring = "" ;
        358           bo dyString =  "Consent  expiration  for the n ext " + wi ndow + " d ays:\n\n";
        359           if  (eheExpir ations > 0 ) {
        360                bodyStri ng += Cons entType.NW _HIN_AUTHO RIZATION.v alue() + "  expiratio ns: " + eh eExpiratio ns + "\n";
        361           }
        362           if  (ssaExpir ations > 0 ) {
        363                bodyStri ng += Cons entType.SS A_AUTHORIZ ATION.valu e() + " ex pirations:  " + ssaEx pirations  + "\n";
        364           }
        365           if  (eagExpir ations > 0 ) {
        366                bodyStri ng += Cons entType.EA G_AUTHORIZ ATION.valu e() + " ex pirations:  " + eagEx pirations  + "\n";
        367           }
        368           if  (dasExpir ations > 0 ) {
        369                bodyStri ng += Cons entType.DA S_AUTHORIZ ATION.valu e() + " ex pirations:  " + dasEx pirations  + "\n";
        370           }
        371           if  (mhvExpir ations > 0 ) {
        372                bodyStri ng += Cons entType.MH V_AUTHORIZ ATION.valu e() + " ex pirations:  " + mhvEx pirations  + "\n";
        373           }
        374           if  (unknownE xpirations  > 0) {
        375                bodyStri ng += "Unk nown Autho rization"  + ": " + u nknownExpi rations +  "\n";
        376           }
        377           bo dyString + = "Total e xpirations : " + tota lExpiratio ns + "\n";
        378  
        379           bo dyString + = "\nTo se e the curr ent full e xpiring co nsent repo rt, log on  to VAP "
        380                + "and f ollow the  following  link:\n";
        381  
        382           Ma p<String,  String> me ssageAttri butes = ne w HashMap< String, St ring>();
        383           me ssageAttri butes.put( "subject",  "VAP Expi ring Conse nt Report" );
        384           me ssageAttri butes.put( "body", bo dyString);
        385  
        386           Em ailer emai ler = new  Emailer();
        387           em ailer.emai lReport(pi p.getExpir ingConsent Configurat ion().getE mailAddres ses(),
        388                messageA ttributes,  results);
        389       }
        390  
        391       public  PIPInterf ace getPip () {
        392           re turn this. pip;
        393       }
        394  
        395       @Requi red
        396       public  void setP ersonServi ce(PersonS erviceInte rface pers onService)  {
        397           th is.personS ervice = p ersonServi ce;
        398       }
        399  
        400       @Requi red
        401       public  void setP dqService( PdqService  pdqServic e) {
        402           th is.pdqServ ice = pdqS ervice;
        403       }
        404  
        405       @Requi red
        406       public  void setP ip(PIPInte rface pip)  {
        407           th is.pip = p ip;
        408       }
        409  
        410       @Requi red
        411       public  void setM apper(fina l Mapper m apper) {
        412           th is.mapper  = mapper;
        413       }
        414  
        415   }