4319. EPMO Open Source Coordination Office Redaction File Detail Report

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

4319.1 Files compared

# Location File Last Modified
1 Fri Jun 9 19:51:28 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\report OptInSummaryReport.java Fri Apr 21 20:03:30 2017 UTC

4319.2 Comparison summary

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

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

4319.4 Active regular expressions

No regular expressions were active.

4319.5 Comparison detail

        1   package go v.va.nvap. web.report ;
        2  
        3   import gov .va.nvap.c ommon.sort .BubbleSor tListMap;
        4   import gov .va.nvap.c ommon.vali dation.Nul lChecker;
        5   import gov .va.nvap.p rivacy.Con sentType;
        6   import gov .va.nvap.w eb.dao.Act iveConsent SummaryDAO ;
        7   import gov .va.nvap.w eb.app.Res ponseDispa tcherHttpS ervlet;
        8   import gov .va.nvap.w eb.consent .audit.Act iveConsent Summary;
        9   import gov .va.nvap.w eb.dao.Fac ilityDAO;
        10   import gov .va.nvap.w eb.helper. report.Rep ortHelper;
        11   import gov .va.nvap.w eb.util.xl s.ExcelExp orter;
        12   import jav a.io.IOExc eption;
        13   import jav a.io.Strin gWriter;
        14   import jav a.text.Par seExceptio n;
        15   import jav a.util.Arr ayList;
        16   import jav a.util.Arr ays;
        17   import jav a.util.Has hMap;
        18   import jav a.util.Lin kedHashMap ;
        19   import jav a.util.Lis t;
        20   import jav a.util.Map ;
        21   import jav a.util.log ging.Level ;
        22   import jav a.util.log ging.Logge r;
        23   import jav ax.servlet .ServletEx ception;
        24   import jav ax.servlet .http.Http ServletReq uest;
        25   import jav ax.servlet .http.Http ServletRes ponse;
        26   import jav ax.servlet .http.Http Session;
        27   import org .apache.po i.ss.userm odel.Workb ook;
        28   import org .json.JSON Exception;
        29   import org .json.JSON Object;
        30  
        31   /**
        32    * This se rvlet hand les the su mmary Opt- In Patient s report.
        33    * 
        34    * @since  12/04/2014
        35    * @author  Irakli Ka kushadze
        36    */
        37   public cla ss OptInSu mmaryRepor t extends  ResponseDi spatcherHt tpServlet  {
        38  
        39       /**
        40        *
        41        */
        42       privat e static f inal long  serialVers ionUID = - 3952503136 988071993L ;
        43  
        44       public  void doSe arch(HttpS ervletRequ est reques t, HttpSer vletRespon se respons e)
        45           th rows Servl etExceptio n, IOExcep tion, Pars eException  {
        46           fi nal HttpSe ssion sess ion = requ est.getSes sion(false );
        47  
        48           //  Perform t he search.
        49           Li st<List<St ring>> sea rchRespons e = getRes ults(reque st).result s;
        50  
        51           //  Generate  JSON resul ts.
        52           se ssion.setA ttribute(" results",  encodeInto JSON(searc hResponse) );
        53  
        54           //  Forward t he respons e.
        55           th is.forward (request,  response,  "searchRes ultsJSON") ;
        56       }
        57  
        58       public  void expo rtToExcel( final Http ServletReq uest reque st,
        59           fi nal HttpSe rvletRespo nse respon se) throws  ServletEx ception, I OException  {
        60           // Get the re sults from  the adapt er with th e paginato r set to - 1 (all //   results) 
        61           Pa ckedResult s packedRe sults = th is.getResu lts(reques t);
        62           fi nal List<L ist<String >> results  = packedR esults.res ults;
        63           //  Create a  map of key  which is  based on t he resultr equest dat a key and  the headin g value 
        64           // The headin g is used  to create  the column  headers a nd the
        65           // key is use d to pull  the data f rom the re sults 
        66           fi nal Map<St ring, Stri ng> report Map = new  LinkedHash Map<String , String>( );
        67           if  (NullChec ker.isNull OrEmpty(re sults)) {
        68                reportMa p.put("",  "No record s were fou nd.");
        69           }  else {
        70                reportMa p.put("Aut henticatin g Facility ", "Authen ticating F acility");
        71                reportMa p.put("eHe alth Excha nge Author izations",  "eHealth  Exchange A uthorizati ons");
        72                reportMa p.put("SSA  Authoriza tions", "S SA Authori zations");
        73                reportMa p.put("Fac ility Tota l", "Facil ity Total" );
        74           }
        75           
        76           // Remap the  results to  List<Map< String,Obj ect>> so i t can be p assed to e xport clas s.
        77           Li st<Map<Str ing, Objec t>> result sMap = new  ArrayList <Map<Strin g, Object> >();
        78           fo r (List<St ring> list Entry : re sults) {
        79                Map<Stri ng, Object > mapEntry  = new Lin kedHashMap <String, O bject>();
        80                mapEntry .put("Auth enticating  Facility" , listEntr y.get(0));
        81                mapEntry .put("eHea lth Exchan ge Authori zations",  listEntry. get(1));
        82                mapEntry .put("SSA  Authorizat ions", lis tEntry.get (2));
        83                mapEntry .put("Faci lity Total ", listEnt ry.get(3)) ;
        84                resultsM ap.add(map Entry);
        85           }
        86           
        87           fi nal Map<St ring, List <Object>>  optionalRo ws = new L inkedHashM ap<String,  List<Obje ct>>();
        88           op tionalRows .put("Tota l", packed Results.to tals);
        89  
        90           //  Generate  filters.
        91           fi nal Map<St ring, List <Object>>  filterMap  = new Link edHashMap< String, Li st<Object> >();
        92           Li nkedHashMa p<String,  Object> fi lters = ne w LinkedHa shMap<Stri ng, Object >();
        93  
        94           St ring facil ityNames =  ExcelExpo rter.getFa cilitiesFi lter(this. getFacilit yDAO(), re quest.getP arameter(" stationNum bers"));
        95           fi lters.put( "Authentic ating Faci lity", fac ilityNames );
        96           Ex celExporte r.populate FilterMapF orExport(r equest, fi lters, fil terMap, re quest.getP arameter(" patientTyp es"));
        97  
        98           //  Create wo rkbook
        99           fi nal String  title = " Opt-In Pat ients Summ ary Report ";
        100           fi nal Workbo ok wb = th is.getExce lExporter( ).exportTo Excel(titl e, title,  reportMap,  resultsMa p, filterM ap, option alRows);
        101  
        102           //  Write Exc el to Stre am
        103           th is.getExce lExporter( ).writeExc elToStream ("Opt-In_P atients_Su mmary_Repo rt", wb, r esponse);
        104       }
        105  
        106       @Overr ide
        107       protec ted void u nspecified (HttpServl etRequest  request, H ttpServlet Response r esponse) t hrows Serv letExcepti on, IOExce ption {
        108           th is.forward (request,  response,  "searchFor m"); 
        109       }
        110  
        111       /**
        112        * Get s ActiveCo nsentSumma ryDAO clas s from Spr ing.
        113        *
        114        * @re turn Activ eConsentSu mmaryDAO o bject
        115        */
        116       privat e ActiveCo nsentSumma ryDAO getA ctiveConse ntSummaryD AO() {
        117           re turn this. getBean("A ctiveConse ntSummaryD AO", Activ eConsentSu mmaryDAO.c lass);
        118       }
        119  
        120       privat e Facility DAO getFac ilityDAO()  {
        121           re turn this. getBean("F acilityDAO ", Facilit yDAO.class );
        122       }
        123       
        124       /**
        125        * Get s ExcelExp orter clas s from Spr ing.
        126        *
        127        * @re turn Excel Exporter o bject
        128        */
        129       privat e ExcelExp orter getE xcelExport er() {
        130           re turn this. getBean("e xcelExport er", Excel Exporter.c lass);
        131       }
        132  
        133       privat e String e ncodeIntoJ SON(List<L ist<String >> searchR esponse) t hrows Pars eException  {
        134           St ring retur nValue = " ";
        135  
        136           tr y {
        137                StringWr iter json  = new Stri ngWriter() ;
        138                JSONObje ct obj = n ew JSONObj ect();
        139                List<Lis t> data =  new ArrayL ist<List>( );
        140  
        141                if (sear chResponse  != null)  {
        142                    for  (List<Stri ng> row :  searchResp onse) {
        143                         List<Strin g> dataIte m = new Ar rayList<St ring>();
        144  
        145                         for (Strin g cell : r ow) {
        146                             dataIt em.add(cel l);
        147                         }
        148  
        149                         data.add(d ataItem);
        150                    }
        151                }
        152                obj.put( "data", da ta);
        153  
        154                obj.writ e(json);
        155  
        156                returnVa lue = json .toString( );
        157           }  catch (JSO NException  ex) {
        158                Logger.g etLogger(O ptInSummar yReport.cl ass.getNam e()).log(L evel.SEVER E, null, e x);
        159           }
        160  
        161           re turn retur nValue;
        162       }
        163       
        164       /**
        165        * Gen erates the  summary r eport for  opted-in p atients, w hich is a  matrix of  String val ues. The f irst colum n contains  facility  names, and
        166        * the  last colu mn contain s totals f or each ro w. The las t row cont ains total s for each  authoriza tion type,  and the g rand total  in the
        167        * las t column.  The follow ing diagra m shows th e layout o f the repo rt:
        168        *
        169        * Fac ility1     [###]        [###]     ...    [# ##]     [r ow total]
        170        * Fac ility2     [###]        [###]     ...    [# ##]     [r ow total]
        171        * ...             ...          ...      ...     . ..           ... 
        172        * Fac ilityN     [###]        [###]     ...    [# ##]     [r ow total]
        173        * Tot al     [co l total] [ col total]  ... [col  total] [gr and total]
        174        *
        175        * @re turn List< List<Strin g>> Summar y report o f opted-in  patients.
        176        */
        177       privat e PackedRe sults getR esults(Htt pServletRe quest requ est) {
        178  
        179           Li st<List<St ring>> res ults = new  ArrayList <List<Stri ng>>();
        180           Pa ckedResult s endResul ts  = new  PackedResu lts();
        181           tr y {
        182                ActiveCo nsentSumma ryDAO dao  = this.get ActiveCons entSummary DAO();
        183  
        184                ActiveCo nsentSumma ryDAO.Summ aryRequest  searchReq uest = new  ActiveCon sentSummar yDAO().new  SummaryRe quest();
        185                searchRe quest.aggr egateAtFac ilityLevel  =  "true" .equals(re quest.getP arameter(" aggregateA tFacilityL evel"));
        186                searchRe quest.incl udeUnknown Visn = (re quest.getP arameter(" includeUnk nownVisn") ==null)?
        187                         false : "t rue".equal s(request. getParamet er("includ eUnknownVi sn"));
        188                searchRe quest.stat ionNumbers  = ReportH elper.getS tationNumb ersFromReq uest(reque st);
        189                
        190                List<Act iveConsent Summary> a ctiveConse ntSummaryL ist = dao. find(searc hRequest);
        191  
        192                if ((act iveConsent SummaryLis t != null)  && (activ eConsentSu mmaryList. size() > 0 )) {
        193                    List <ConsentTy pe> allowe dConsentTy pes = Arra ys.asList( ConsentTyp e.NW_HIN_A UTHORIZATI ON, Consen tType.SSA_ AUTHORIZAT ION);
        194                    Map< String, Lo ng> totals ByConsentT ype = new  HashMap<St ring, Long >();
        195                    List <String> r ow;
        196                    Map< String, Ma p<String,  Long>> map  = new Lin kedHashMap <String, M ap<String,  Long>>();
        197                    int  patientTyp es = NullC hecker.isN ullOrEmpty (request.g etParamete r("patient Types")) ?  1 : Integ er.parseIn t(request. getParamet er("patien tTypes"));
        198  
        199                    for  (ConsentTy pe allowed ConsentTyp e : allowe dConsentTy pes) {
        200                         totalsByCo nsentType. put(allowe dConsentTy pe.value() , new Long (0));
        201                    }
        202                    tota lsByConsen tType.put( "Total", n ew Long(0) );
        203  
        204                    for  (ActiveCon sentSummar y activeCo nsentSumma ry : activ eConsentSu mmaryList)  {
        205                         if (!map.c ontainsKey (activeCon sentSummar y.getFacil ityName()) ) {
        206                             map.pu t(activeCo nsentSumma ry.getFaci lityName() , new Hash Map<String , Long>()) ;
        207                         }
        208                         switch (pa tientTypes ) {
        209                             case 1 : // Real  patients o nly
        210                                 ma p.get(acti veConsentS ummary.get FacilityNa me()).put( activeCons entSummary .getOptinC onsentType ().getName (), active ConsentSum mary.getCo untReal()) ;
        211                                 br eak;
        212                             case 2 : // Test  patients o nly
        213                                 ma p.get(acti veConsentS ummary.get FacilityNa me()).put( activeCons entSummary .getOptinC onsentType ().getName (), (activ eConsentSu mmary.getT otal() - a ctiveConse ntSummary. getCountRe al()));
        214                                 br eak;
        215                             case 3 : // Both
        216                                 ma p.get(acti veConsentS ummary.get FacilityNa me()).put( activeCons entSummary .getOptinC onsentType ().getName (), active ConsentSum mary.getTo tal());
        217                                 br eak;
        218                         }
        219                    }
        220  
        221                    List <Map<Strin g, Object> > dataList  = new Arr ayList<Map <String, O bject>>();
        222                    for  (Map.Entry <String, M ap<String,  Long>> fa cility : m ap.entrySe t()) {
        223                         final Map< String, Ob ject> data Map = new  HashMap<St ring, Obje ct>();
        224                         dataMap.pu t("facilit y", facili ty.getKey( ));
        225                         long total  = 0;
        226                         for (Conse ntType all owedConsen tType : al lowedConse ntTypes) {
        227                             if (fa cility.get Value().co ntainsKey( allowedCon sentType.v alue())) {
        228                                 lo ng value =  facility. getValue() .get(allow edConsentT ype.value( ));
        229                                 da taMap.put( allowedCon sentType.g etValue(),  value);
        230                                 to tal += val ue;
        231                                 to talsByCons entType.pu t(allowedC onsentType .value(),  totalsByCo nsentType. get(allowe dConsentTy pe.value() ) + value) ;
        232                             } else  {
        233                                 da taMap.put( allowedCon sentType.g etValue(),  0L);
        234                             }
        235                         }
        236                         dataMap.pu t("total",  total);
        237                         totalsByCo nsentType. put("Total ", totalsB yConsentTy pe.get("To tal") + to tal);
        238                         dataList.a dd(dataMap );
        239                    }
        240                    
        241                    if ( dataList.s ize() > 1)  {
        242                         dataList =  sortResul ts(request , dataList );
        243                    }
        244                    
        245                    for  (Map<Strin g, Object>  dataMap :  dataList)  {
        246                         row = new  ArrayList< String>();
        247                         row.add((S tring) dat aMap.get(" facility") );
        248                         for (Conse ntType all owedConsen tType : al lowedConse ntTypes) {
        249                             row.ad d(dataMap. get(allowe dConsentTy pe.value() ).toString ());
        250                         }
        251                         row.add(da taMap.get( "total").t oString()) ;
        252                         results.ad d(row);
        253                    }
        254  
        255                    row  = new Arra yList<Stri ng>();
        256                    for  (ConsentTy pe allowed ConsentTyp e : allowe dConsentTy pes) {
        257                         row.add(to talsByCons entType.ge t(allowedC onsentType .value()). toString() );
        258                    }
        259                    row. add(totals ByConsentT ype.get("T otal").toS tring());
        260                    
        261                    endR esults.res ults = res ults;
        262                    endR esults.tot als = row;
        263                }
        264           }  catch (fin al Excepti on ex) {
        265                throw ne w RuntimeE xception(e x);
        266           }
        267           re turn endRe sults;
        268       }
        269       
        270       privat e List<Map <String, O bject>> so rtResults( HttpServle tRequest r equest, Li st<Map<Str ing, Objec t>> data)  {
        271  
        272           fi nal Bubble SortListMa p bSorter  = new Bubb leSortList Map();
        273           //  When expo rting, we' ll receive  sort fiel d and sort  order exp licitly in  the corre sponding p arams.
        274           St ring sortV alue = req uest.getPa rameter("o rder[0][co lumn]") ==  null ? re quest.getP arameter(" sortBy") :  request.g etParamete r("order[0 ][column]" );
        275           bo olean sort Ascending  = request. getParamet er("order[ 0][dir]")  == null ?  !"desc".eq ualsIgnore Case(reque st.getPara meter("sor tOrder"))
        276                    : !" desc".equa lsIgnoreCa se(request .getParame ter("order [0][dir]") );
        277           if  ("0".equa ls(sortVal ue)) {
        278                sortValu e = "facil ity";
        279           }  else if (" 1".equals( sortValue) ) {
        280                sortValu e = Consen tType.NW_H IN_AUTHORI ZATION.val ue();
        281           }  else if (" 2".equals( sortValue) ) {
        282                sortValu e = Consen tType.SSA_ AUTHORIZAT ION.value( );
        283           }  else if (" 3".equals( sortValue) ) {
        284                sortValu e = "total ";
        285           }  else {
        286                sortValu e = "facil ity";
        287           }
        288           re turn bSort er.sortByC olumn(data , sortValu e, sortAsc ending);
        289  
        290       }
        291       
        292       privat e class Pa ckedResult s{
        293           Li st<List<St ring>> res ults;
        294           Li st totals;
        295       }
        296  
        297   }