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

4320.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 PatientDiscoveryReport.java Fri Apr 21 20:15:58 2017 UTC

4320.2 Comparison summary

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

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

4320.4 Active regular expressions

No regular expressions were active.

4320.5 Comparison detail

        1   /*
        2    * To chan ge this te mplate, ch oose Tools  | Templat es
        3    * and ope n the temp late in th e editor.
        4    */
        5   package go v.va.nvap. web.report ;
        6  
        7   import gov .va.med.nh in.adapter .audit.Act ionType;
        8   import gov .va.med.nh in.adapter .audit.Act ionValuesT ype;
        9   import gov .va.med.nh in.adapter .audit.Aud itType;
        10   import gov .va.med.nh in.adapter .audit.Fie ldType;
        11   import gov .va.med.nh in.adapter .audit.Get Audits;
        12   import gov .va.med.nh in.adapter .audit.Get AuditsResp onse;
        13   import gov .va.med.nh in.adapter .audit.Pag eInfoType;
        14   import gov .va.med.nh in.adapter .audit.Sor tDirection ;
        15   import gov .va.med.nh in.adapter .audit.Sor tFieldType ;
        16   import gov .va.med.nh in.adapter .audit.Sor tFieldsTyp e;
        17   import gov .va.med.nh in.adapter .audit.Str ingValuesT ype;
        18   import gov .va.nvap.c ommon.date .Gregorian DateUtil;
        19   import gov .va.nvap.c ommon.vali dation.Nul lChecker;
        20   import gov .va.nvap.s ervice.ada pter.audit .AdapterAu ditManager ;
        21   import gov .va.nvap.s ervice.aud it.AuditEx ception;
        22   import gov .va.nvap.s ervice.pdq .PdqServic e;
        23   import gov .va.nvap.w eb.app.Res ponseDispa tcherHttpS ervlet;
        24   import gov .va.nvap.w eb.dao.Use rDocumentD AO;
        25   import gov .va.nvap.w eb.helper. privacy.Co nsentManag ementHelpe r;
        26   import gov .va.nvap.w eb.helper. report.Rep ortHelper;
        27   import gov .va.nvap.w eb.patient .ExcelGene ratorThrea d;
        28   import gov .va.nvap.w eb.user.Us erHelper;
        29   import gov .va.nvap.w eb.util.da te.DateUti l;
        30   import gov .va.nvap.w eb.util.xl s.CsvExpor ter;
        31   import gov .va.nvap.w eb.util.xl s.ExcelExp orter;
        32  
        33   import jav a.io.IOExc eption;
        34   import jav a.io.Strin gWriter;
        35   import jav a.util.Arr ayList;
        36   import jav a.util.Cal endar;
        37   import jav a.util.Dat e;
        38   import jav a.util.Has hMap;
        39   import jav a.util.Has hSet;
        40   import jav a.util.Lin kedHashMap ;
        41   import jav a.util.Lis t;
        42   import jav a.util.Map ;
        43   import jav a.util.log ging.Level ;
        44   import jav a.util.log ging.Logge r;
        45   import jav ax.ejb.EJB ;
        46  
        47   import jav ax.servlet .ServletEx ception;
        48   import jav ax.servlet .http.Http ServletReq uest;
        49   import jav ax.servlet .http.Http ServletRes ponse;
        50   import jav ax.servlet .http.Http Session;
        51   import org .apache.po i.ss.userm odel.Workb ook;
        52   import org .json.JSON Exception;
        53   import org .json.JSON Object;
        54  
        55   /**
        56    * @author  Asha Amri traj ajaxe d by Raul  Alfaro
        57    */
        58   public cla ss Patient DiscoveryR eport exte nds Respon seDispatch erHttpServ let {
        59  
        60           /* *
        61            *
        62            * /
        63           pr ivate stat ic final l ong serial VersionUID  = -861467 3990226997 234L;
        64       privat e AdapterA uditManage r adapterA uditManage r;
        65       @EJB(b eanInterfa ce = PdqSe rvice.clas s, mappedN ame = "Pdq Service")
        66       PdqSer vice pdqSe rvice;
        67  
        68       privat e final St ring REPOR T_TITLE =  "Patient D iscovery A udit Detai l Report";
        69  
        70           pu blic Conse ntManageme ntHelper g etCmsHelpe r() {
        71                    fina l ConsentM anagementH elper cmsH elper = th is.getBean ("cmsHelpe r",
        72                                      ConsentM anagementH elper.clas s);
        73                    retu rn cmsHelp er;
        74           }
        75  
        76       privat e ReportHe lper getRe portHelper () {
        77           re turn this. getBean("r eportHelpe r", Report Helper.cla ss);
        78       }
        79  
        80  
        81           @O verride
        82           pr otected vo id unspeci fied(final  HttpServl etRequest  request,
        83                             final  HttpServle tResponse  response)  throws Ser vletExcept ion,
        84                             IOExce ption {
        85                    fina l HttpSess ion sessio n = reques t.getSessi on(false);
        86  
        87                    sess ion.remove Attribute( "patientDi scoveryQue ryICN");
        88                    sess ion.remove Attribute( "results") ;
        89  
        90           Re portHelper .setDefaul tSearchDat es(session );
        91           th is.getRepo rtHelper() .getOrgLis ts(request , this.get CmsHelper( ));
        92  
        93                    this .forward(r equest, re sponse, "s how");
        94           }
        95  
        96       /**
        97        * Mai n search f unction re turns json  results u se primari ly for dat atables.
        98        * @pa ram reques t
        99        * @pa ram respon se
        100        * @th rows IOExc eption
        101        * @th rows Servl etExceptio n
        102        */
        103       public  void doSe arch(final  HttpServl etRequest  request,
        104                             final  HttpServle tResponse  response)  throws IOE xception,  ServletExc eption{
        105  
        106           fi nal HttpSe ssion sess ion = requ est.getSes sion(false );
        107  
        108           se ssion.setA ttribute(" results",  encodeInto JSON(getRe sults(requ est, false , false),  request.ge tParameter ("draw"))) ;
        109  
        110           th is.forward (request,  response,  "searchRes ultsJSON") ;
        111  
        112       }
        113  
        114       /**
        115        * Pul l required  data usin g request  to gather  query para meters, Bo olean repr esents if  all data s hould
        116        * be  returned
        117        * @pa ram reques t
        118        * @pa ram getALL
        119        * @re turn
        120        * @th rows Audit Exception
        121        */
        122       public  SummaryPa ckage getR esults(fin al HttpSer vletReques t request,  boolean g etALL, boo lean expor ting) thro ws AuditEx ception {
        123  
        124           fi nal GetAud its getAud itsRequest  = prepare AuditParam eters(requ est, getAL L);
        125  
        126           fi nal int re cordsPerPa ge = (requ est.getPar ameter("le ngth")!=nu ll) ?
        127                    Inte ger.parseI nt(request .getParame ter("lengt h")) : 25;
        128  
        129           Lo ng totalCo unt = new  Long(0);
        130  
        131           //  TODO: Ana nd Sastry  / Weimin S hi - FIX I NTEGRATION  08/29/201 1 - END
        132           fi nal List<M ap<String,  Object>>  results =  new ArrayL ist<Map<St ring, Obje ct>>();
        133           tr y {
        134                final Ge tAuditsRes ponse quer yResponse  = this.ada pterAuditM anager
        135                         .getAudits (getAudits Request);
        136                if(query Response.g etPageInfo () != null ) {
        137                    tota lCount = e xporting ?  0 : new L ong(queryR esponse.ge tPageInfo( ).getTotal Size());
        138                }
        139  
        140                long rea lPatientMe ssages = 0 ;
        141                long rea lPatientFa ils = 0;
        142                long rea lPatientMa tches = 0;
        143                long tes tPatientMe ssages = 0 ;
        144                long tes tPatientFa ils = 0;
        145                long tes tPatientMa tches = 0;
        146                HashSet< String> un iqueRealPa tients = n ew HashSet <String>() ;
        147                HashSet< String> un iqueTestPa tients = n ew HashSet <String>() ;
        148  
        149                if (Null Checker.is NotEmpty(q ueryRespon se)
        150                         && NullChe cker.isNot Empty(quer yResponse. getAudits( ))
        151                         && NullChe cker.isNot Empty(quer yResponse. getAudits( ).getAudit ())) {
        152                    fina l List<Aud itType> au ditTypeLis t = queryR esponse.ge tAudits(). getAudit() ;
        153                    //gr ab datatab les parame ter for pa ge length
        154                    int  pageSize =  recordsPe rPage;
        155                    for  (final Aud itType aud itType : a uditTypeLi st) {
        156                         final Map< String, Ob ject> resu ltMap = ne w LinkedHa shMap<Stri ng, Object >();
        157                         String exp lanationOf Failure =  "N/A";
        158                         String pat ientFirstN ame = "";
        159                         String pat ientLastNa me = "";
        160                         String pat ientMiddle Name = "";
        161                         String pat ientSSN =  "";
        162                         Boolean mv iFindMatch Failed = n ull;
        163  
        164                         String det ails = Rep ortDataPro cessor.nul lEmptyRepl aceWithUnk nown(audit Type.getDe tails());
        165                         if (detail s.startsWi th("QUERY  FAILED"))  {
        166                             explan ationOfFai lure = "MV I: Query F ailed";
        167                             mviFin dMatchFail ed = true;
        168                         } else if  (details.s tartsWith( "MATCH FAI LED")) {
        169                             explan ationOfFai lure = "MV I: Match N ot Found";
        170                             mviFin dMatchFail ed = true;
        171                         } else if  (details.s tartsWith( "AMBIGUOUS  FAILED"))  {
        172                             explan ationOfFai lure = "MV I: Ambiguo us Match";
        173                             mviFin dMatchFail ed = true;
        174                         } else if  (details.s tartsWith( "MATCH FOU ND")) {
        175                             mviFin dMatchFail ed = false ;
        176                         } else if  (details.s tartsWith( "FAILURE -  PARTNER D ID NOT RES POND WITH  PATIENT IN FORMATION  ")) {
        177                             explan ationOfFai lure = "Pa rtner did  not respon d with pat ient infor mation";
        178                             detail s = detail s.substrin g("FAILURE  - PARTNER  DID NOT R ESPOND WIT H PATIENT  INFORMATIO N ".length ());
        179                         } else if  (details.s tartsWith( "FAILURE -  OUTBOUND  PD: PARTNE R OUTBOUND  PD HAS BE EN DISABLE D. ")) {
        180                             explan ationOfFai lure = "Ou tbound PD:  Partner o utbound PD  has been  disabled";
        181                             detail s = detail s.substrin g("FAILURE  - OUTBOUN D PD: PART NER OUTBOU ND PD HAS  BEEN DISAB LED. ".len gth());
        182                         } else if  (details.s tartsWith( "FAILURE -  OUTBOUND  PD: PARTNE R IS NOT R EGISTERED  WITH THE S YSTEM. "))  {
        183                             explan ationOfFai lure = "Ou tbound PD:  Partner i s not regi stered wit h the syst em";
        184                             detail s = detail s.substrin g("FAILURE  - OUTBOUN D PD: PART NER IS NOT  REGISTERE D WITH THE  SYSTEM. " .length()) ;
        185                         }
        186                         resultMap. put("failu reExplanat ion", expl anationOfF ailure);
        187  
        188                         ReportHelp er reportH elper = ge tReportHel per();
        189                         if (Boolea n.TRUE.equ als(mviFin dMatchFail ed)) {
        190                             patien tFirstName  = getRepo rtHelper() .extractFr omDetails( details, " FIRSTNAME" );
        191                             patien tLastName  = reportHe lper.extra ctFromDeta ils(detail s, "LASTNA ME");
        192                             patien tMiddleNam e = report Helper.ext ractFromDe tails(deta ils, "MIDD LENAME");
        193                             patien tSSN = rep ortHelper. extractFro mDetails(d etails, "S SN");
        194                         }
        195                         if (patien tSSN.lengt h() == 0)  {
        196                             patien tSSN = aud itType.get PatientSSN ();
        197                         }
        198  
        199                         // SSN
        200                         ReportData Processor. addSsnToRe sultMap(re sultMap, p atientSSN) ;
        201  
        202                         boolean is TestPatien t = this.g etReportHe lper().isT estPatient (resultMap .get("ssn" ).toString ());
        203  
        204                         if (NullCh ecker.isNo tEmpty(pat ientSSN))  {
        205                             if (is TestPatien t) {
        206                                 if  (!uniqueT estPatient s.contains (patientSS N)) {
        207                                      uniqueTe stPatients .add(patie ntSSN);
        208                                 }
        209                             } else  {
        210                                 if  (!uniqueR ealPatient s.contains (patientSS N)) {
        211                                      uniqueRe alPatients .add(patie ntSSN);
        212                                 }
        213                             }
        214                         }
        215  
        216                         if (pageSi ze == -1 | | (testPat ientMessag es + realP atientMess ages) < pa geSize) {
        217                             if (is TestPatien t) {
        218                                 te stPatientM essages++;
        219                                 if  (Boolean. TRUE.equal s(mviFindM atchFailed )) {
        220                                      testPati entFails++ ;
        221                                 }  else if (B oolean.FAL SE.equals( mviFindMat chFailed))  {
        222                                      testPati entMatches ++;
        223                                 }
        224                             } else  {
        225                                 re alPatientM essages++;
        226                                 if  (Boolean. TRUE.equal s(mviFindM atchFailed )) {
        227                                      realPati entFails++ ;
        228                                 }  else if (B oolean.FAL SE.equals( mviFindMat chFailed))  {
        229                                      realPati entMatches ++;
        230                                 }
        231                             }
        232                         }
        233  
        234                         // First n ame.
        235                         if (patien tFirstName .length()  == 0) {
        236                             patien tFirstName  = ReportD ataProcess or.nullEmp tyReplaceW ithUnknown (auditType .getPatien tGivenName ());
        237                         }
        238                         resultMap. put("first Name", pat ientFirstN ame);
        239  
        240                         // Middle  name.
        241                         if (patien tMiddleNam e.length()  == 0) {
        242                             patien tMiddleNam e =  Repor tDataProce ssor.nullE mptyReplac eWithUnkno wn(auditTy pe.getPati entMiddleN ame());
        243                         }
        244                         if ("Unkno wn".equals IgnoreCase (patientMi ddleName))  {
        245                             patien tMiddleNam e = "";
        246                         }
        247                         resultMap. put("middl eName", pa tientMiddl eName);
        248  
        249                         // Last na me.
        250                         if (patien tLastName. length() = = 0) {
        251                             patien tLastName  = ReportDa taProcesso r.nullEmpt yReplaceWi thUnknown( auditType. getPatient LastName() );
        252                         }
        253                         resultMap. put("lastN ame", pati entLastNam e);
        254  
        255                         resultMap. put("icn",  ReportDat aProcessor .nullEmpty ReplaceWit hUnknown(a uditType.g etPatientI d()));
        256                         resultMap. put("audit Time", Gre gorianDate Util.getDa teFromGreg orianCalen dar(auditT ype.getAud itTime())) ;
        257                         resultMap. put("audit TimeFormat ted",
        258                                 th is.getRepo rtHelper()
        259                                 .g etFormatte dDateTime(
        260                                 Gr egorianDat eUtil
        261                                 .g etDateFrom GregorianC alendar(au ditType
        262                                 .g etAuditTim e())));
        263                         resultMap. put("userI d", Report DataProces sor
        264                                 .n ullEmptyRe placeWithU nknown(aud itType
        265                                 .g etUserId() ));
        266                         resultMap. put("purpo seForUse",  ReportDat aProcessor
        267                                 .n ullEmptyRe placeWithU nknown(aud itType
        268                                 .g etPurposeF orUse()));
        269                         resultMap. put("facil ityOid", R eportDataP rocessor.n ullEmptyRe placeWithU nknown(aud itType.get Organizati onId()));
        270                         resultMap. put("organ izationNam e", this.g etReportHe lper().fin dOrganizat ionByOid(a uditType.g etOrganiza tionId(),  auditType. getOrganiz ationName( )));
        271  
        272                         // if
        273                         // (NullCh ecker.isNu llOrEmpty( auditType. getOrganiz ationId()) )
        274                         // {
        275                         // logger. warning("R emoteOrgan izationId  Id is null /empty for  audit rec ord["
        276                         // + audit Type.getAu ditId() +  "], audit  details["+
        277                         // auditTy pe.getDeta ils() + "] ");
        278                         // }
        279                         resultMap. put("remot eFacilityO id", Repor tDataProce ssor.nullE mptyReplac eWithUnkno wn(auditTy pe.getRemo teOrganiza tionId())) ;
        280                         resultMap. put("remot eOrganizat ionName",  this.getRe portHelper ().findOrg anizationB yOid(audit Type.getRe moteOrgani zationId() , auditTyp e.getRemot eOrganizat ionName()) );
        281                         /*
        282                          * if
        283                          * (NullCh ecker.isNu llOrEmpty( auditType. getOrganiz ationId(
        284                          * ))) { L ogger.warn ing(
        285                          * "Organi zation Id  is null/em pty for au dit record [" +
        286                          * auditTy pe.getAudi tId() + "] , audit de tails["+
        287                          * auditTy pe.getDeta ils() + "] "); } resu ltMap.put(
        288                          * "facili ty", this. getCmsHelp er()
        289                          * .getOrg anizationB yHomeCommu nityId(
        290                          * auditTy pe.getOrga nizationId ())); if
        291                          * (NullCh ecker.isNu llOrEmpty
        292                          * (auditT ype.getOrg anizationI d())) { Lo gger.warni ng(
        293                          * "Remote Organizati onId Id is  null/empt y for audi t record["
        294                          * + audit Type.getAu ditId() +  "], audit  details["+
        295                          * auditTy pe.getDeta ils() + "] "); } resu ltMap.put(
        296                          * "remote Facility",  this.getC msHelper()
        297                          * .getOrg anizationB yHomeCommu nityId(
        298                          * auditTy pe.getRemo teOrganiza tionId())) ;
        299                          */
        300                         if (NullCh ecker.isNo tEmpty(aud itType.get Action()))  {
        301                             result Map.put("m essage", a uditType.g etAction() .name());
        302                         }
        303  
        304                         details =  processDat ails(detai ls);
        305  
        306                         resultMap. put("detai ls", detai ls);
        307  
        308                         results.ad d(resultMa p);
        309                    }
        310  
        311                    /*
        312                     * i f (NullChe cker.isNul lOrEmpty(a uditType.g etOrganiza tionId(
        313                     * ) )) { Logge r.warning(
        314                     * " Organizati on Id is n ull/empty  for audit  record[" +
        315                     * a uditType.g etAuditId( ) + "], au dit detail s["+
        316                     * a uditType.g etDetails( ) + "]");  } resultMa p.put( "fa cility",
        317                     * t his.getCms Helper() . getOrganiz ationByHom eCommunity Id(
        318                     * a uditType.g etOrganiza tionId())) ; if
        319                     * ( NullChecke r.isNullOr Empty (aud itType.get Organizati onId())) {
        320                     * L ogger.warn ing(
        321                     * " RemoteOrga nizationId  Id is nul l/empty fo r audit re cord[" +
        322                     * a uditType.g etAuditId( ) + "], au dit detail s["+
        323                     * a uditType.g etDetails( ) + "]");  } resultMa p.put(
        324                     * " remoteFaci lity", thi s.getCmsHe lper()
        325                     * . getOrganiz ationByHom eCommunity Id(
        326                     * a uditType.g etRemoteOr ganization Id()));
        327                     */
        328                }
        329                //set th ese outsid e of the n ull checke r just in  case we ge t an empty  response  we still d isplay cou nts
        330                //put al l paramete rs togethe r into nea t package
        331                SummaryP ackage fin ishedPacka ge = new S ummaryPack age();
        332  
        333                finished Package.se tResults(r esults);
        334                finished Package.se tRealPatie ntMessages (realPatie ntMessages );
        335                finished Package.se tRealPatie ntFails(re alPatientF ails);
        336                finished Package.se tRealPatie ntMatches( realPatien tMatches);
        337                finished Package.se tTestPatie ntMessages (testPatie ntMessages );
        338                finished Package.se tTestPatie ntFails(te stPatientF ails);
        339                finished Package.se tTestPatie ntMatches( testPatien tMatches);
        340                finished Package.se tUniqueRea lPatients( uniqueReal Patients.s ize());
        341                finished Package.se tUniqueTes tPatients( uniqueTest Patients.s ize());
        342                finished Package.se tTotalCoun t(totalCou nt);
        343                return f inishedPac kage;
        344  
        345           }  catch (fin al AuditEx ception ex ) {
        346                throw ne w AuditExc eption();
        347           }
        348  
        349       }
        350  
        351       /**
        352        * Tak es paramet er request  and pulls  all the v ariables n eeded for  query sear ch, using  default va lues
        353        * whe re applica ble
        354        * @pa ram reques t
        355        * @pa ram getALL
        356        * @re turn
        357        */
        358       public  GetAudits  prepareAu ditParamet ers(HttpSe rvletReque st request , Boolean  getALL){
        359           fi nal HttpSe ssion sess ion = requ est.getSes sion(false );
        360  
        361           fi nal String  icn = (St ring) sess ion
        362                    .get Attribute( "patientDi scoveryQue ryICN");
        363           fi nal String  ssn = req uest.getPa rameter("s sn");
        364           fi nal String  lastName  = request. getParamet er("lastNa me");
        365           fi nal String  firstName  = request .getParame ter("first Name");
        366           fi nal String  patientDi scoveryUse rId = requ est.getPar ameter("us erId");
        367           fi nal Date s d = Report Helper.get StartDate( request.ge tParameter ("startDat e"));
        368           Da te ed = Re portHelper .getEndDat e(request. getParamet er("endDat e"));
        369           fi nal String  organizat ion = requ est.getPar ameter("or ganization ");
        370           St ring mpiMa tch = (req uest.getPa rameter("m piMatch")! =null)?
        371                    requ est.getPar ameter("mp iMatch") :  "ALL";
        372           fi nal int pa tientTypes  = (reques t.getParam eter("pati entTypes")  != null)  ?
        373                    Inte ger.parseI nt(request .getParame ter("patie ntTypes"))  : 1; //de fault to r eal patien ts as is s hown on th e form
        374           in t recordsP erPage = ( request.ge tParameter ("length") !=null) ?
        375                    Inte ger.parseI nt(request .getParame ter("lengt h")) : 25;
        376           fi nal int pa geNumber =  (request. getParamet er("start" ) != null) ?
        377                Integer. parseInt(r equest.get Parameter( "start"))/ Integer.pa rseInt(req uest.getPa rameter("l ength")) :  0;
        378  
        379           if (getALL){
        380                recordsP erPage = - 1;
        381           }
        382  
        383           //  sort
        384           St ring patie ntDiscover ySortValue  = getSort ColumnValu e(request. getParamet er("order[ 0][column] "));
        385           St ring patie ntDiscover ySortDirec tion = req uest.getPa rameter("o rder[0][di r]");
        386  
        387           // if called  by export  button, so rt values  are passed  under dif ferent par am
        388           if (patientDi scoverySor tValue ==  null || pa tientDisco verySortDi rection ==  null){
        389                patientD iscoverySo rtValue =  getSortCol umnValue(r equest.get Parameter( "sortBy")) ;
        390                patientD iscoverySo rtDirectio n = reques t.getParam eter("sort Order");
        391           }
        392  
        393           if  (mpiMatch .equalsIgn oreCase("a ll")) {
        394                mpiMatch  = null;
        395           }
        396  
        397           fi nal GetAud its getAud itsRequest  = new Get Audits();
        398           if  (NullChec ker.isNotE mpty(sd))  {
        399                getAudit sRequest.s etFromDate (Gregorian DateUtil
        400                         .getGregor ianCalenda rByDate(sd ));
        401           }
        402           if  (NullChec ker.isNotE mpty(ed))  {
        403                if (ed.e quals(sd))  {
        404                    ed =  DateUtil. addTime(ed , Calendar .HOUR, 24) ;
        405                }
        406                getAudit sRequest.s etToDate(G regorianDa teUtil
        407                         .getGregor ianCalenda rByDate(ed ));
        408           }
        409  
        410           //  Set Patie nt Types
        411           ge tAuditsReq uest.setPa tientTypes (patientTy pes);
        412  
        413           //  Set Patie nt Ids
        414           if  (NullChec ker.isNotE mpty(icn))  {
        415                final St ringValues Type patie ntIds = ne w StringVa luesType() ;
        416                patientI ds.getValu e().add(ic n);
        417                patientI ds.setNotI n(false);
        418                getAudit sRequest.s etPatientI ds(patient Ids);
        419           }
        420           //  Set SSN
        421           if  (NullChec ker.isNotE mpty(ssn))  {
        422                String[]  ssns = ss n.split(", ");
        423                final St ringValues Type patie ntSSNs = n ew StringV aluesType( );
        424                for (Str ing ssnEnt ry : ssns)  {
        425                    pati entSSNs.ge tValue().a dd(ssnEntr y);
        426                }
        427                patientS SNs.setNot In(false);
        428                getAudit sRequest.s etPatientS SNs(patien tSSNs);
        429           }
        430           //  Set Last  Name
        431           if  (NullChec ker.isNotE mpty(lastN ame)) {
        432                final St ringValues Type patie ntLastName s = new St ringValues Type();
        433                patientL astNames.g etValue(). add(lastNa me);
        434                patientL astNames.s etNotIn(fa lse);
        435                getAudit sRequest.s etPatientL astNames(p atientLast Names);
        436           }
        437           //  Set First  Name
        438           if  (NullChec ker.isNotE mpty(first Name)) {
        439                final St ringValues Type patie ntFirstNam es = new S tringValue sType();
        440                patientF irstNames. getValue() .add(first Name);
        441                patientF irstNames. setNotIn(f alse);
        442                getAudit sRequest.s etPatientG ivenNames( patientFir stNames);
        443           }
        444           //  Set User  ID
        445           if  (NullChec ker.isNotE mpty(patie ntDiscover yUserId))  {
        446                final St ringValues Type userI d = new St ringValues Type();
        447                userId.g etValue(). add(patien tDiscovery UserId);
        448                userId.s etNotIn(fa lse);
        449                getAudit sRequest.s etUserIds( userId);
        450           }
        451           //  Set Organ ization Id s
        452           fi nal String ValuesType  orgTypes  = new Stri ngValuesTy pe();
        453           if  (NullChec ker.isNotE mpty(organ ization))  {
        454                orgTypes .getValue( ).add(orga nization);
        455           }
        456           or gTypes.set NotIn(fals e);
        457           ge tAuditsReq uest.setRe moteOrgani zationIds( orgTypes);
        458           ge tAuditsReq uest.setOr ganization Ids(orgTyp es);
        459  
        460           //  sorting
        461           if  (NullChec ker.isNotE mpty(patie ntDiscover ySortValue )) {
        462                final So rtFieldTyp e sortFiel d = new So rtFieldTyp e();
        463                sortFiel d.setField (FieldType .fromValue (patientDi scoverySor tValue));
        464                if ("DES C".equalsI gnoreCase( patientDis coverySort Direction) ) {
        465                    sort Field.setD irection(S ortDirecti on.DESC);
        466                } else {
        467                    sort Field.setD irection(S ortDirecti on.ASC);
        468                }
        469                final So rtFieldsTy pe sortFie ldsType =  new SortFi eldsType() ;
        470                sortFiel dsType.get SortField( ).add(sort Field);
        471                getAudit sRequest.s etSortFiel ds(sortFie ldsType);
        472           }
        473  
        474           //  Set Actio n Types
        475           fi nal Action ValuesType  actionsTy pe = new A ctionValue sType();
        476           ac tionsType. getValue() .add(Actio nType.ANNO UNCE);
        477           ac tionsType. getValue() .add(Actio nType.CHEC K_POLICY);
        478           ac tionsType. getValue() .add(Actio nType.MPI_ FIND_MATCH );
        479           ac tionsType. getValue() .add(Actio nType.ADD_ PATIENT_CO RRELATION) ;
        480           ac tionsType. setNotIn(f alse);
        481           ge tAuditsReq uest.setAc tions(acti onsType);
        482           //  Set MPI M atch
        483           if  ("all".eq uals(mpiMa tch) || Nu llChecker. isEmpty(mp iMatch)) {
        484                getAudit sRequest.s etDetails( null);
        485           }  else {
        486                getAudit sRequest.s etDetails( mpiMatch);
        487           }
        488  
        489  
        490           // Set Page I nformation
        491           fi nal PageIn foType pag eInfoType  = new Page InfoType() ;
        492  
        493           pa geInfoType .setPageNu mber(pageN umber);
        494           pa geInfoType .setPageSi ze(records PerPage);
        495           ge tAuditsReq uest.setPa geInfo(pag eInfoType) ;
        496  
        497           re turn getAu ditsReques t;
        498       }
        499  
        500       /**
        501        * Ret urns appro priate sor t field va lue based  on column  number sel ected
        502        * @pa ram colNum ber
        503        * @re turn
        504        */
        505       privat e String g etSortColu mnValue(St ring colNu mber){
        506           St ring sortV alue = "";
        507  
        508           if ("0".equal s(colNumbe r)) {
        509                sortValu e = "audit Time";
        510           }  else if (" 1".equals( colNumber) ){
        511                sortValu e = "patie ntSSN";
        512           }  else if (" 2".equals( colNumber) ){
        513                sortValu e = "patie ntLastName ";
        514           }  else if (" 3".equals( colNumber) ){
        515                sortValu e = "patie ntGivenNam e";
        516           }  else if (" 4".equals( colNumber) ){
        517                sortValu e = "patie ntMiddleNa me";
        518           }  else if (" 5".equals( colNumber) ){
        519                sortValu e = "organ izationNam e";
        520           }  else if (" 6".equals( colNumber) ){
        521                sortValu e = "purpo seForUse";
        522           }  else if (" 7".equals( colNumber) ){
        523                sortValu e = "remot eOrganizat ionName";
        524           }  else if (" 8".equals( colNumber) ){
        525                sortValu e = "actio n";
        526           }  else {
        527                sortValu e = "patie ntLastName ";
        528           }
        529           re turn sortV alue;
        530       }
        531  
        532       /**
        533        * Pro cesses Det ails prope rty as fol lows:
        534        * - M asks SSN
        535        * - R eplaces "M OTHERSMAID ENNAME" wi th "MMN"
        536        * @pa ram detail s Details  property o f AuditTyp e
        537        * @re turn Proce ssed Detai ls propert y string
        538        */
        539       privat e String p rocessData ils(String  details)  {
        540           //  Mask SSN
        541           in t pos1 = d etails.ind exOf("SSN= ");
        542           in t pos2;
        543           St ring ssn;
        544           if  (pos1 !=   -1) {
        545                pos2 = d etails.ind exOf(",",  pos1);
        546                if (pos2  != -1) {
        547                    ssn  = details. substring( pos1 + 4,  pos2).trim ();
        548                    if ( ssn.length () > 0) {
        549                         details =  details.su bstring(0,  pos1 + 4)  + ReportD ataProcess or.maskSsn (ssn) + de tails.subs tring(pos2 );
        550                    }
        551                }
        552           }
        553           //  Replace " MOTHERSMAI DENNAME" w ith "MMN"
        554           if  (details. contains(" MOTHERSMAI DENNAME=") ) {
        555                details  = details. replace("M OTHERSMAID ENNAME=",  "MMN=");
        556           }
        557           re turn detai ls;
        558       }
        559  
        560       /**
        561        * Cha nge result set into j son string  object to  be return ed for dat atables. S ince pagin g isnt use d
        562        * for  this part icular pag e, draw is  optional.  Total is  used to de termine ne xt page bu tton disab le
        563        * @pa ram search Results
        564        * @re turn
        565        */
        566       privat e String e ncodeIntoJ SON(Summar yPackage r esultPacka ge, String  draw) {
        567           St ring jsonS tring = "" ;
        568  
        569           tr y {
        570                StringWr iter json  = new Stri ngWriter() ;
        571                JSONObje ct obj = n ew JSONObj ect();
        572                List<Lis t> data =  new ArrayL ist<List>( );
        573  
        574                for (Map <String, O bject> row  : resultP ackage.get Results())  {
        575                    List <String> d ataItem =  new ArrayL ist<String >();
        576  
        577                    data Item.add(r ow.get("au ditTimeFor matted").t oString()) ;
        578                    data Item.add(r ow.get("ss nMasked"). toString() );
        579                    data Item.add(r ow.get("la stName").t oString()) ;
        580                    data Item.add(r ow.get("fi rstName"). toString() );
        581                    data Item.add(r ow.get("mi ddleName") .toString( ));
        582                    data Item.add(r ow.get("or ganization Name").toS tring());
        583                    data Item.add(r ow.get("pu rposeForUs e").toStri ng());
        584                    data Item.add(r ow.get("re moteOrgani zationName ").toStrin g());
        585                    data Item.add(r ow.get("me ssage").to String());
        586                    data Item.add(r ow.get("fa ilureExpla nation").t oString()) ;
        587                    data Item.add(r ow.get("de tails").to String());
        588  
        589                    //ad d unmasked  ssn for l inkToPatie nts, does  not appear  as table  column
        590                    data Item.add(r ow.get("ss n").toStri ng());
        591                    data .add(dataI tem);
        592                }
        593  
        594                obj.put( "data", da ta);
        595                obj.put( "recordsTo tal", resu ltPackage. getTotalCo unt());
        596                obj.put( "recordsFi ltered", r esultPacka ge.getTota lCount());
        597                obj.put( "draw", dr aw);
        598  
        599                //Add al l the calc ulated val ues to jso n obj to b e displaye d on page.
        600  
        601                obj.put( "realPatie ntMessages ",resultPa ckage.getR ealPatient Messages() );
        602                obj.put( "realPatie ntFails",r esultPacka ge.getReal PatientFai ls());
        603                obj.put( "realPatie ntMatches" ,resultPac kage.getRe alPatientM atches());
        604                obj.put( "testPatie ntMessages ",resultPa ckage.getT estPatient Messages() );
        605                obj.put( "testPatie ntFails",r esultPacka ge.getTest PatientFai ls());
        606                obj.put( "testPatie ntMatches" ,resultPac kage.getTe stPatientM atches());
        607                obj.put( "uniqueRea lPatients" ,resultPac kage.getUn iqueRealPa tients());
        608                obj.put( "uniqueTes tPatients" ,resultPac kage.getUn iqueTestPa tients());
        609  
        610                obj.writ e(json);
        611  
        612                jsonStri ng = json. toString() ;
        613           }  catch (JSO NException  ex) {
        614                Logger.g etLogger(P atientDisc overySumma ryReport.c lass.getNa me()).log( Level.SEVE RE, null,  ex);
        615           }
        616  
        617           re turn jsonS tring;
        618       }
        619  
        620       public  void expo rtToCsv(fi nal HttpSe rvletReque st request ,
        621           fi nal HttpSe rvletRespo nse respon se) throws  ServletEx ception, I OException  {
        622  
        623           Ma p<String,  String> cs vReportMap  = new Lin kedHashMap <>();
        624           cs vReportMap .put("Date  Received  (CT)", "au ditTimeFor matted");
        625           cs vReportMap .put("SSN" , "ssn");
        626           cs vReportMap .put("Pati ent Last N ame", "las tName");
        627           cs vReportMap .put("Pati ent First  Name", "fi rstName");
        628           cs vReportMap .put("Pati ent Middle  Name", "m iddleName" );
        629           cs vReportMap .put("Send er", "orga nizationNa me");
        630           cs vReportMap .put("Send er OID", " facilityOi d");
        631           cs vReportMap .put("Purp ose of Use ", "purpos eForUse");
        632           cs vReportMap .put("Rece iver", "re moteOrgani zationName ");
        633           cs vReportMap .put("Rece iver OID",  "remoteFa cilityOid" );
        634           cs vReportMap .put("Mess age", "mes sage");
        635           cs vReportMap .put("Expl anation of  Failure",  "failureE xplanation ");
        636           cs vReportMap .put("Deta ils", "det ails");
        637  
        638           in t minimumT hreshold =  Integer.p arseInt((S tring) thi s.getServl etContext( ).getAttri bute("sche duledExpor tMin"));
        639           in t total =  Integer.pa rseInt(req uest.getPa rameter("t otalRows") );
        640  
        641           // Start a sc heduled ex port with  its own th read if gr eater than  the minim um thresho ld
        642           if  (total >=  minimumTh reshold) {
        643                ExcelGen eratorThre ad csvGenT hread = ne w ExcelGen eratorThre ad("csvGen Thread");
        644                csvGenTh read.setDo cumentType ("csv");
        645                csvGenTh read.setRe portMap(cs vReportMap );
        646                csvGenTh read.setTi tle(REPORT _TITLE);
        647                csvGenTh read.setUs erId(UserH elper.getU serName(re quest));
        648                csvGenTh read.setAd apterAudit Manager(ad apterAudit Manager);
        649                csvGenTh read.setRe portHelper (getReport Helper());
        650                csvGenTh read.setUs erDocument Dao(getUse rDocumentD AO());
        651  
        652                // Set s earch attr ibutes for  getting a udit resul ts
        653                HttpSess ion sessio n = reques t.getSessi on(false);
        654                csvGenTh read.setAt tributes(m apSessionA ttributes( session, r equest));
        655  
        656                csvGenTh read.start ();
        657           }
        658           // Otherwise  generate a nd downloa d the expo rt directl y
        659           el se {
        660                List<Map <String, O bject>> re sults;
        661                PatientD iscoveryRe port.Summa ryPackage  packedResu lts;
        662                packedRe sults = th is.getResu lts(reques t, true, t rue);
        663                results  = packedRe sults.getR esults();
        664  
        665                CsvExpor ter csvExp orter = ne w CsvExpor ter();
        666                csvExpor ter.export ToCSV(resp onse, REPO RT_TITLE.r eplace(" " , "_"), re sults, (Li nkedHashMa p<String,  String>) c svReportMa p);
        667           }
        668       }
        669  
        670       /**
        671        * Exp ort to exc el - This  method is  called whe n the user  clicks on  the excel
        672        * ico n in the J SP. Reflec tion is us ed in the  ResponseDi spatcherHt tpServlet
        673        * to  call this  method bas ed on the  http param eters.
        674        *
        675        * @pa ram reques t HTTP Req uest
        676        * @pa ram respon se HTTP Re sponse
        677        * @th rows Servl etExceptio n
        678        * @th rows IOExc eption
        679        */
        680       public  void expo rtToExcel( final Http ServletReq uest reque st, final  HttpServle tResponse  response)  throws Ser vletExcept ion, IOExc eption {
        681  
        682           // Get the se ssion fina l
        683           Ht tpSession  session =  request.ge tSession(f alse);
        684  
        685           //       Crea te a map o f key whic h is based  on the re sult data  key and th e
        686           //       head ing value  The headin g is used  to create  the column  headers a nd the
        687           //       key  is used to  pull the  data from  the result s
        688           fi nal Map<St ring, Stri ng> patien tDiscovery Map = new  LinkedHash Map<String , String>( );
        689  
        690           //  Set the o ptional ro ws
        691           fi nal Date s tartDate =  ReportHel per.getSta rtDate(req uest.getPa rameter("s tartDate") );
        692           Da te endDate  = ReportH elper.getE ndDate(req uest.getPa rameter("e ndDate"));
        693           St ring patie ntMpiResPm pi = (requ est.getPar ameter("mp iMatch")!= null)?
        694                    requ est.getPar ameter("mp iMatch") :  "ALL";
        695  
        696           if  (patientM piResPmpi. equalsIgno reCase("al l")) {
        697                patientM piResPmpi  = null;
        698           }
        699  
        700           //  Generate  filters.
        701           fi nal Map<St ring, List <Object>>  filterMap  = new Link edHashMap< String, Li st<Object> >();
        702           fi nal Linked HashMap<St ring, Obje ct> filter s = new Li nkedHashMa p<String,  Object>();
        703  
        704           fi lters.put( "Start Dat e", this.g etReportHe lper().get FormattedD ate(startD ate));
        705           fi lters.put( "End Date" , this.get ReportHelp er().getFo rmattedDat e(endDate) );
        706           fi lters.put( "SSN", req uest.getPa rameter("s sn"));
        707           fi lters.put( "Last Name ", request .getParame ter("lastN ame"));
        708           fi lters.put( "First Nam e", reques t.getParam eter("firs tName"));
        709           fi lters.put( "User ID",  request.g etParamete r("userId" ));
        710           fi lters.put( "MPI Resul ts", Excel Exporter.g etFilterVa lue(patien tMpiResPmp i));
        711           fi lters.put( "eHealth E xchange Or g", ExcelE xporter.ge tFilterVal ue(request .getParame ter("organ izationNam e")));
        712           Ex celExporte r.populate FilterMapF orExport(r equest, fi lters, fil terMap, re quest.getP arameter(" patientTyp es"));
        713  
        714           pa tientDisco veryMap.pu t("auditTi meFormatte d", "Date  Received ( CT)");
        715           pa tientDisco veryMap.pu t("ssn", " SSN");
        716           pa tientDisco veryMap.pu t("lastNam e", "Patie nt Last Na me");
        717           pa tientDisco veryMap.pu t("firstNa me", "Pati ent First  Name");
        718           pa tientDisco veryMap.pu t("middleN ame", "Pat ient Middl e Name");
        719           pa tientDisco veryMap.pu t("organiz ationName" , "Sender" );
        720           pa tientDisco veryMap.pu t("facilit yOid", "Se nder OID") ;
        721           pa tientDisco veryMap.pu t("purpose ForUse", " Purpose of  Use");
        722           pa tientDisco veryMap.pu t("remoteO rganizatio nName", "R eceiver");
        723           pa tientDisco veryMap.pu t("remoteF acilityOid ", "Receiv er OID");
        724           pa tientDisco veryMap.pu t("message ", "Messag e");
        725           pa tientDisco veryMap.pu t("failure Explanatio n", "Expla nation of  Failure");
        726           pa tientDisco veryMap.pu t("details ", "Detail s");
        727  
        728           in t minimumT hreshold =  Integer.p arseInt((S tring) thi s.getServl etContext( ).getAttri bute("sche duledExpor tMin"));
        729           in t total =  Integer.pa rseInt(req uest.getPa rameter("t otalRows") );
        730  
        731           // Start a sc heduled ex port with  its own th read if gr eater than  the minim um thresho ld
        732           if  (total >=  minimumTh reshold) {
        733                ExcelGen eratorThre ad exGenTh read = new  ExcelGene ratorThrea d("exGenTh read");
        734                exGenThr ead.setFil terMap(fil terMap);
        735                exGenThr ead.setRep ortMap(pat ientDiscov eryMap);
        736                exGenThr ead.setHas OptionalRo ws(true);
        737                exGenThr ead.setOpt ionalRowsM ap(createO ptionalRow sMap(Integ er.valueOf (request.g etParamete r("patient Types")))) ;
        738  
        739                // Set n ames for E xcel gener ator threa d
        740                exGenThr ead.setTit le(REPORT_ TITLE);
        741                exGenThr ead.setExc elExporter (this.getE xcelExport er());
        742                exGenThr ead.setAda pterAuditM anager(ada pterAuditM anager);
        743                exGenThr ead.setRep ortHelper( getReportH elper());
        744                exGenThr ead.setUse rId(UserHe lper.getUs erName(req uest));
        745                exGenThr ead.setUse rDocumentD ao(getUser DocumentDA O());
        746  
        747                // Set s earch attr ibutes for  getting a udit resul ts
        748                exGenThr ead.setAtt ributes(ma pSessionAt tributes(s ession, re quest));
        749  
        750                exGenThr ead.start( );
        751           }
        752           // Otherwise  generate a nd downloa d the expo rt directl y
        753           el se {
        754                // Creat e workbook
        755                final St ring title  = REPORT_ TITLE;
        756  
        757                List<Map <String, O bject>> re sults;
        758                PatientD iscoveryRe port.Summa ryPackage  packedResu lts;
        759                packedRe sults = th is.getResu lts(reques t, true, t rue);
        760                results  = packedRe sults.getR esults();
        761  
        762                final Wo rkbook wb  = this.get ExcelExpor ter().expo rtToExcel( title, tit le, patien tDiscovery Map, resul ts, filter Map, null) ;
        763  
        764                // Write  Excel wor kbook to S tream
        765                this.get ExcelExpor ter().writ eExcelToSt ream(REPOR T_TITLE.re place(" ",  "_"), wb,  response) ;
        766           }
        767       }
        768  
        769       privat e Map<Stri ng, Object > mapSessi onAttribut es(HttpSes sion sessi on,HttpSer vletReques t request  ) {
        770           Ma p<String,  Object> at tributes =  new HashM ap<String,  Object>() ;
        771  
        772           St ring mpiMa tch = (req uest.getPa rameter("m piMatch")! =null)?
        773                    requ est.getPar ameter("mp iMatch") :  "ALL";
        774  
        775           if  (mpiMatch .equalsIgn oreCase("a ll")) {
        776                mpiMatch  = null;
        777           }
        778  
        779           at tributes.p ut("icn",  (String) s ession
        780                    .get Attribute( "patientDi scoveryQue ryICN"));
        781           at tributes.p ut("ssn",  request.ge tParameter ("ssn"));
        782           at tributes.p ut("lastNa me", reque st.getPara meter("las tName"));
        783           at tributes.p ut("firstN ame", requ est.getPar ameter("fi rstName")) ;
        784           at tributes.p ut("userId ", request .getParame ter("userI d"));
        785  
        786           //  Add 24 ho urs to end  date if s ame as sta rt date
        787           Da te startDa te = Repor tHelper.ge tStartDate (request.g etParamete r("startDa te"));
        788           Da te endDate  = ReportH elper.getE ndDate(req uest.getPa rameter("e ndDate"));
        789           if  (NullChec ker.isNotE mpty(endDa te)) {
        790                if (endD ate.equals (startDate )) {
        791                    endD ate = Date Util.addTi me(endDate , Calendar .HOUR, 24) ;
        792                }
        793           }
        794           at tributes.p ut("startD ate", star tDate);
        795           at tributes.p ut("endDat e", endDat e);
        796  
        797           //  Set both  sender and  receiver  org to the  organizat ion entere d
        798           at tributes.p ut("organi zation", r equest.get Parameter( "organizat ion"));
        799           at tributes.p ut("remote Organizati on", (Stri ng) sessio n
        800                    .get Attribute( "patientDi scoveryQue ryOrganiza tion"));
        801  
        802           at tributes.p ut("mpiMat ch", mpiMa tch);
        803           at tributes.p ut("patien tTypes", I nteger.par seInt(requ est.getPar ameter("pa tientTypes ")));
        804           //  sort
        805           fi nal String  patientDi scoverySor tValue = g etSortColu mnValue(re quest.getP arameter(" sortBy"));
        806           fi nal String  patientDi scoverySor tDirection  = request .getParame ter("sortO rder");
        807  
        808           at tributes.p ut("sortVa lue", pati entDiscove rySortValu e);
        809           at tributes.p ut("sortDi rection",  patientDis coverySort Direction) ;
        810  
        811           //  Set Actio n Types
        812           fi nal Action ValuesType  actionsTy pe = new A ctionValue sType();
        813           ac tionsType. getValue() .add(Actio nType.ANNO UNCE);
        814           ac tionsType. getValue() .add(Actio nType.CHEC K_POLICY);
        815           ac tionsType. getValue() .add(Actio nType.MPI_ FIND_MATCH );
        816           ac tionsType. getValue() .add(Actio nType.ADD_ PATIENT_CO RRELATION) ;
        817           ac tionsType. setNotIn(f alse);
        818           at tributes.p ut("action sType", ac tionsType) ;
        819  
        820           re turn attri butes;
        821       }
        822  
        823       Map<St ring, Stri ng> create OptionalRo wsMap(int  patientTyp es) {
        824           Ma p<String,  String> op tionalRows Map = new  LinkedHash Map<String , String>( );
        825  
        826           if  (patientT ypes == 1)  {
        827                optional RowsMap.pu t("uniqueR ealPatient s", "Uniqu e patients ");
        828                optional RowsMap.pu t("realPat ientMessag es", "Tota l messages ");
        829                optional RowsMap.pu t("realPat ientFails" , "Match f ailures");
        830                optional RowsMap.pu t("realPat ientMatche s", "Match es found") ;
        831           }  else if (p atientType s == 2) {
        832                optional RowsMap.pu t("uniqueT estPatient s", "Uniqu e patients ");
        833                optional RowsMap.pu t("testPat ientMessag es", "Tota l messages ");
        834                optional RowsMap.pu t("testPat ientFails" , "Match f ailures");
        835                optional RowsMap.pu t("testPat ientMatche s", "Match es found") ;
        836           }  else {
        837                optional RowsMap.pu t("uniqueR ealPatient s", "Uniqu e real pat ients");
        838                optional RowsMap.pu t("realPat ientMessag es", "Tota l messages  for real  patients") ;
        839                optional RowsMap.pu t("realPat ientFails" , "Match f ailures fo r real pat ients");
        840                optional RowsMap.pu t("realPat ientMatche s", "Match es found f or real pa tients");
        841  
        842                optional RowsMap.pu t("", "");
        843  
        844                optional RowsMap.pu t("uniqueT estPatient s", "Uniqu e test pat ients");
        845                optional RowsMap.pu t("testPat ientMessag es", "Tota l messages  for test  patients") ;
        846                optional RowsMap.pu t("testPat ientFails" , "Match f ailures fo r test pat ients");
        847                optional RowsMap.pu t("testPat ientMatche s", "Match es found f or test pa tients");
        848           }
        849  
        850           re turn optio nalRowsMap ;
        851       }
        852  
        853       /**
        854        * Get  the excel  exporter  class from  Spring.
        855        *
        856        * @re turn the e xcel expor ter object
        857        */
        858       public  ExcelExpo rter getEx celExporte r() {
        859           fi nal ExcelE xporter ex celExporte r = this.g etBean("ex celExporte r",
        860                    Exce lExporter. class);
        861           re turn excel Exporter;
        862       }
        863  
        864       privat e UserDocu mentDAO ge tUserDocum entDAO() {
        865           re turn this. getBean("U serDocumen tDAO", Use rDocumentD AO.class);
        866       }
        867  
        868       @EJB(b eanInterfa ce = Adapt erAuditMan ager.class , mappedNa me = "Adap terAuditMa nager")
        869       public  void setA dapterAudi tManager(
        870                final Ad apterAudit Manager ad apterAudit Manager) {
        871           th is.adapter AuditManag er = adapt erAuditMan ager;
        872       }
        873  
        874       /*
        875       Class  used to br ing summar y informat ion togeth er to aide  in passin g paramete rs and avo id using s ession
        876       */
        877       privat e class Su mmaryPacka ge{
        878  
        879           Li st<Map<Str ing, Objec t>> result s = new Ar rayList<Ma p<String,  Object>>() ;
        880           lo ng realPat ientMessag es = 0;
        881           lo ng realPat ientFails  = 0;
        882           lo ng realPat ientMatche s = 0;
        883           lo ng testPat ientMessag es = 0;
        884           lo ng testPat ientFails  = 0;
        885           lo ng testPat ientMatche s = 0;
        886           lo ng uniqueR ealPatient s = 0;
        887           lo ng uniqueT estPatient s = 0;
        888           Lo ng totalCo unt;
        889  
        890            p ublic List <Map<Strin g, Object> > getResul ts() {
        891                return r esults;
        892           }
        893  
        894           pu blic void  setResults (List<Map< String, Ob ject>> res ults) {
        895                this.res ults = res ults;
        896           }
        897  
        898           pu blic long  getRealPat ientMessag es() {
        899                return r ealPatient Messages;
        900           }
        901  
        902           pu blic void  setRealPat ientMessag es(long re alPatientM essages) {
        903                this.rea lPatientMe ssages = r ealPatient Messages;
        904           }
        905  
        906           pu blic long  getRealPat ientFails( ) {
        907                return r ealPatient Fails;
        908           }
        909  
        910           pu blic void  setRealPat ientFails( long realP atientFail s) {
        911                this.rea lPatientFa ils = real PatientFai ls;
        912           }
        913  
        914           pu blic long  getRealPat ientMatche s() {
        915                return r ealPatient Matches;
        916           }
        917  
        918           pu blic void  setRealPat ientMatche s(long rea lPatientMa tches) {
        919                this.rea lPatientMa tches = re alPatientM atches;
        920           }
        921  
        922           pu blic long  getTestPat ientMessag es() {
        923                return t estPatient Messages;
        924           }
        925  
        926           pu blic void  setTestPat ientMessag es(long te stPatientM essages) {
        927                this.tes tPatientMe ssages = t estPatient Messages;
        928           }
        929  
        930           pu blic long  getTestPat ientFails( ) {
        931                return t estPatient Fails;
        932           }
        933  
        934           pu blic void  setTestPat ientFails( long testP atientFail s) {
        935                this.tes tPatientFa ils = test PatientFai ls;
        936           }
        937  
        938           pu blic long  getTestPat ientMatche s() {
        939                return t estPatient Matches;
        940           }
        941  
        942           pu blic void  setTestPat ientMatche s(long tes tPatientMa tches) {
        943                this.tes tPatientMa tches = te stPatientM atches;
        944           }
        945  
        946           pu blic long  getUniqueR ealPatient s() {
        947                return u niqueRealP atients;
        948           }
        949  
        950           pu blic void  setUniqueR ealPatient s(int uniq ueRealPati ents) {
        951                this.uni queRealPat ients = un iqueRealPa tients;
        952           }
        953  
        954           pu blic long  getUniqueT estPatient s() {
        955                return u niqueTestP atients;
        956           }
        957  
        958           pu blic void  setUniqueT estPatient s(int uniq ueTestPati ents) {
        959                this.uni queTestPat ients = un iqueTestPa tients;
        960           }
        961  
        962           pu blic Long  getTotalCo unt() {
        963                return t otalCount;
        964           }
        965  
        966           pu blic void  setTotalCo unt(Long t otalCount)  {
        967                this.tot alCount =  totalCount ;
        968           }
        969       }
        970   }