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

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

4313.2 Comparison summary

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

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

4313.4 Active regular expressions

No regular expressions were active.

4313.5 Comparison detail

        1   package go v.va.nvap. web.report ;
        2  
        3   import gov .va.med.nh in.adapter .audit.Act ionType;
        4   import gov .va.med.nh in.adapter .audit.Act ionValuesT ype;
        5   import gov .va.med.nh in.adapter .audit.Aud itType;
        6   import gov .va.med.nh in.adapter .audit.Fie ldType;
        7   import gov .va.med.nh in.adapter .audit.Get Audits;
        8   import gov .va.med.nh in.adapter .audit.Get AuditsResp onse;
        9   import gov .va.med.nh in.adapter .audit.Pag eInfoType;
        10   import gov .va.med.nh in.adapter .audit.Sor tDirection ;
        11   import gov .va.med.nh in.adapter .audit.Sor tFieldType ;
        12   import gov .va.med.nh in.adapter .audit.Sor tFieldsTyp e;
        13   import gov .va.med.nh in.adapter .audit.Str ingValuesT ype;
        14   import gov .va.nvap.c ommon.date .Gregorian DateUtil;
        15   import gov .va.nvap.c ommon.vali dation.Nul lChecker;
        16   import gov .va.nvap.s ervice.ada pter.audit .AdapterAu ditManager ;
        17   import gov .va.nvap.s ervice.ada pter.doc.A dapterExce ption;
        18   import gov .va.nvap.s ervice.aud it.AuditEx ception;
        19   import gov .va.nvap.w eb.app.Res ponseDispa tcherHttpS ervlet;
        20   import gov .va.nvap.w eb.dao.Fac ilityDAO;
        21   import gov .va.nvap.w eb.dao.Use rDocumentD AO;
        22   import gov .va.nvap.w eb.helper. document.D ocumentHel per;
        23   import gov .va.nvap.w eb.helper. facility.F acilityHel per;
        24   import gov .va.nvap.w eb.helper. privacy.Co nsentManag ementHelpe r;
        25   import gov .va.nvap.w eb.helper. report.Rep ortHelper;
        26   import gov .va.nvap.w eb.patient .ExcelGene ratorThrea d;
        27   import gov .va.nvap.w eb.user.Us erHelper;
        28   import gov .va.nvap.w eb.util.Pa ginator;
        29   import gov .va.nvap.w eb.util.xl s.CsvExpor ter;
        30   import gov .va.nvap.w eb.util.xl s.ExcelExp orter;
        31   import jav a.io.IOExc eption;
        32   import jav a.util.Arr ayList;
        33   import jav a.util.Dat e;
        34   import jav a.util.Has hMap;
        35   import jav a.util.Lin kedHashMap ;
        36   import jav a.util.Lis t;
        37   import jav a.util.Map ;
        38   import jav ax.ejb.EJB ;
        39   import jav ax.servlet .ServletEx ception;
        40   import jav ax.servlet .http.Http ServletReq uest;
        41   import jav ax.servlet .http.Http ServletRes ponse;
        42   import jav ax.servlet .http.Http Session;
        43  
        44   /**
        45    * @author  Asha Amri traj
        46    */
        47   public cla ss Inbound DocumentRe portResult s extends  ResponseDi spatcherHt tpServlet  {
        48           /* *
        49            *  Serial UI D.
        50            * /
        51           pr ivate stat ic final l ong serial VersionUID  = -568337 6066034657 44L;
        52  
        53           pr ivate Adap terAuditMa nager adap terAuditMa nager;
        54  
        55       public  void expo rtToCsv(fi nal HttpSe rvletReque st request ,
        56           fi nal HttpSe rvletRespo nse respon se) throws  ServletEx ception, I OException  {
        57  
        58           fi nal List<M ap<String,  Object>>  results =  this.getRe sults(
        59                request. getSession (), new Pa ginator(th is.getRepo rtHelper() .getConsen tDirective sReportCap AsInt()));
        60  
        61           Cs vExporter  csvExporte r = new Cs vExporter( );
        62  
        63           Ma p<String,  String> cs vReportMap  = new Lin kedHashMap <String, S tring>();
        64  
        65           cs vReportMap .put("SSN" , "ssn");
        66           cs vReportMap .put("Pati ent Last N ame", "las tName");
        67           cs vReportMap .put("Pati ent First  Name", "fi rstName");
        68           cs vReportMap .put("Date  Received  (CT)", "au ditTimeFor matted");
        69           cs vReportMap .put("Docu ment Title ", "docume ntTitle");
        70           cs vReportMap .put("Pati ent Prefer red Facili ty", "pati entFacilit yName");
        71           cs vReportMap .put("Pati ent Prefer red Facili ty Station  ID", "pat ientFacili tyNumber") ;
        72           cs vReportMap .put("eHea lth Exchan ge Organiz ation", "r emoteOrgan izationNam e");
        73           cs vReportMap .put("OID" , "remoteO rganizatio nId");
        74           cs vReportMap .put("User  ID", "use rId");
        75           cs vReportMap .put("User  Facility  Code", "us erFacility Code");
        76           cs vReportMap .put("User  Facility" , "userFac ilityName" );
        77           cs vReportMap .put("Purp ose of Use ", "purpos eForUse");
        78           cs vReportMap .put("User  Role", "r oleName");
        79  
        80           cs vExporter. exportToCS V(response , "Receive d_eHealth_ Exchange_D ocuments_D etail_Repo rt", resul ts, (Linke dHashMap<S tring, Str ing>) csvR eportMap);
        81       }
        82  
        83       /**
        84        * Exp ort to exc el - This  method is  called whe n the user  clicks on  the excel  icon in t he JSP. Re flection i s used in  the
        85        * Res ponseDispa tcherHttpS ervlet to  call this  method bas ed on the  http param eters.
        86        *
        87        * @pa ram reques t HTTP Req uest
        88        * @pa ram respon se HTTP Re sponse
        89        * @th rows Servl etExceptio n
        90        * @th rows IOExc eption
        91        */
        92       public  void expo rtToExcel( final Http ServletReq uest reque st,
        93           fi nal HttpSe rvletRespo nse respon se) throws  ServletEx ception,
        94           IO Exception  {
        95           Ex celGenerat orThread e xGenThread  = new Exc elGenerato rThread("e xGenThread ");
        96  
        97           //  Get the s ession
        98           fi nal HttpSe ssion sess ion = requ est.getSes sion(false );
        99  
        100                    // C reate a ma p of key w hich is ba sed on the  result da ta key and  the
        101           //  heading v alue
        102           //  The headi ng is used  to create  the colum n headers  and the ke y is used
        103           //  to pull t he data fr om the res ults
        104           fi nal Map<St ring, Stri ng> inboun dDocumentM ap = new L inkedHashM ap<String,  String>() ;
        105  
        106           fi nal Object  startDate Str = sess ion.getAtt ribute("in boundDocum entQuerySt artDate");
        107           fi nal Object  endDateSt r = sessio n.getAttri bute("inbo undDocumen tQueryEndD ate");
        108  
        109           //  Generate  filters.
        110           fi nal Map<St ring, List <Object>>  filterMap  = new Link edHashMap< String, Li st<Object> >();
        111           fi nal Linked HashMap<St ring, Obje ct> filter s = new Li nkedHashMa p<String,  Object>();
        112  
        113           fi lters.put( "SSN", ses sion.getAt tribute("i nboundDocu mentQueryS SN"));
        114           fi lters.put( "Last Name ", session .getAttrib ute("inbou ndDocument QueryLastN ame"));
        115           fi lters.put( "First Nam e", sessio n.getAttri bute("inbo undDocumen tQueryFirs tName"));
        116           fi lters.put( "User ID",  session.g etAttribut e("inbound DocumentQu eryUserId" ));
        117           fi lters.put( "Start Dat e", this.g etReportHe lper().get FormattedD ate((Date)  startDate Str));
        118           fi lters.put( "End Date" , this.get ReportHelp er().getFo rmattedDat e((Date) e ndDateStr) );
        119           fi lters.put( "Purpose o f Use", Ex celExporte r.getFilte rValue(ses sion.getAt tribute("p urposeOfUs e")));
        120           fi lters.put( "Patient P referred F acility",  ExcelExpor ter.getPat ientPrefer redFacilit yFilter(ge tFacilityD AO(), (Str ing) sessi on.getAttr ibute("inb oundDocume ntQueryFac ility")));
        121           fi lters.put( "eHealth E xchange Or g", ExcelE xporter.ge tFilterVal ue(session .getAttrib ute("inbou ndDocument QueryRemot eOrgName") ));
        122           Ex celExporte r.populate FilterMapF orExport(r equest, fi lters, fil terMap, se ssion.getA ttribute(" patientTyp es").toStr ing());
        123           ex GenThread. setFilterM ap(filterM ap);
        124  
        125           in boundDocum entMap.put ("ssn", "S SN");
        126           in boundDocum entMap.put ("lastName ", "Patien t Last Nam e");
        127           in boundDocum entMap.put ("firstNam e", "Patie nt First N ame");
        128           in boundDocum entMap.put ("auditTim eFormatted ", "Date R eceived (C T)");
        129           in boundDocum entMap.put ("document Title", "D ocument Ti tle");
        130           in boundDocum entMap.put ("patientF acilityNam e", "Patie nt Preferr ed Facilit y");
        131           in boundDocum entMap.put ("patientF acilityNum ber", "Pat ient Prefe rred Facil ity Statio n ID");
        132           in boundDocum entMap.put ("remoteOr ganization Name", "eH ealth Exch ange Organ ization");
        133           in boundDocum entMap.put ("remoteOr ganization Id", "OID" );
        134           in boundDocum entMap.put ("userId",  "User ID" );
        135           in boundDocum entMap.put ("userFaci lityCode",  "User Fac ility Code ");
        136           in boundDocum entMap.put ("userFaci lityName",  "User Fac ility");
        137           in boundDocum entMap.put ("userName ", "User N ame");
        138           in boundDocum entMap.put ("purposeO fUse", "Pu rpose of U se");
        139           in boundDocum entMap.put ("roleName ", "User R ole");
        140           ex GenThread. setReportM ap(inbound DocumentMa p);
        141  
        142           //  Set names  for Excel  generator  thread
        143           ex GenThread. setTitle(" Received e Health Exc hange Docu ments Deta iled Repor t");
        144  
        145           ex GenThread. setExcelEx porter(thi s.getExcel Exporter() );
        146           ex GenThread. setAdapter AuditManag er(adapter AuditManag er);
        147           ex GenThread. setReportH elper(getR eportHelpe r());
        148           ex GenThread. setFacilit yHelper(ge tFacilityH elper());
        149           ex GenThread. setUserId( UserHelper .getUserNa me(request ));
        150           ex GenThread. setUserDoc umentDao(g etUserDocu mentDAO()) ;
        151  
        152           //  Set searc h attribut es for get ting audit  results
        153           ex GenThread. setAttribu tes(mapSes sionAttrib utes(sessi on));
        154  
        155           ex GenThread. start();
        156  
        157           th is.forward (request,  response,  "show");
        158       }
        159  
        160       privat e Map<Stri ng, Object > mapSessi onAttribut es(HttpSes sion sessi on) {
        161           Ma p<String,  Object> at tributes =  new HashM ap<String,  Object>() ;
        162  
        163           at tributes.p ut("ssn",  (String) s ession
        164                    .get Attribute( "inboundDo cumentQuer ySSN"));
        165           at tributes.p ut("lastNa me", (Stri ng) sessio n
        166                    .get Attribute( "inboundDo cumentQuer yLastName" ));
        167           at tributes.p ut("firstN ame", (Str ing) sessi on
        168                    .get Attribute( "inboundDo cumentQuer yFirstName "));
        169           at tributes.p ut("userId ", (String ) session
        170                    .get Attribute( "inboundDo cumentQuer yUserId")) ;
        171           at tributes.p ut("startD ate", (Dat e) session .getAttrib ute("inbou ndDocument QueryStart Date"));
        172           at tributes.p ut("endDat e", (Date)  session.g etAttribut e("inbound DocumentQu eryEndDate "));
        173           at tributes.p ut("facili ty", (Stri ng) sessio n.getAttri bute("inbo undDocumen tQueryFaci lity"));
        174           at tributes.p ut("purpos eOfUse", ( String) se ssion.getA ttribute(" purposeOfU se"));
        175           at tributes.p ut("remote Organizati on", (Stri ng) sessio n
        176                    .get Attribute( "inboundDo cumentQuer yRemoteOrg anization" ));
        177           at tributes.p ut("patien tTypes", ( Integer) s ession.get Attribute( "patientTy pes"));
        178           //  sort
        179           at tributes.p ut("sortVa lue", (Str ing) sessi on
        180                    .get Attribute( "inboundSo rtValue")) ;
        181           at tributes.p ut("sortDi rection",  (String) s ession
        182                    .get Attribute( "inboundSo rtDirectio n"));
        183  
        184           //  Set Actio n Types
        185           fi nal Action ValuesType  actionsTy pe = new A ctionValue sType();
        186           ac tionsType. getValue() .add(Actio nType.RETR IEVE_DOCUM ENT_OUT);
        187           at tributes.p ut("action sType", ac tionsType) ;
        188  
        189           re turn attri butes;
        190       }
        191  
        192           pu blic Conse ntManageme ntHelper g etCmsHelpe r() {
        193                    fina l ConsentM anagementH elper cmsH elper = th is.getBean ("cmsHelpe r",
        194                                      ConsentM anagementH elper.clas s);
        195                    retu rn cmsHelp er;
        196           }
        197  
        198           pu blic Docum entHelper  getDocumen tHelper()  {
        199                    retu rn this.ge tBean("ada pterDocume ntHelper",  DocumentH elper.clas s);
        200           }
        201  
        202           /* *
        203            *  Get the e xcel expor ter class  from Sprin g.
        204            *
        205            *  @return t he excel e xporter ob ject
        206            * /
        207           pu blic Excel Exporter g etExcelExp orter() {
        208                    fina l ExcelExp orter exce lExporter  = this.get Bean("exce lExporter" ,
        209                                      ExcelExp orter.clas s);
        210                    retu rn excelEx porter;
        211           }
        212  
        213       public  FacilityH elper getF acilityHel per() {
        214           fi nal Facili tyHelper f acilityHel per = this .getBean(" facilityHe lper",
        215                Facility Helper.cla ss);
        216           re turn facil ityHelper;
        217       }
        218  
        219           pu blic Repor tHelper ge tReportHel per() {
        220                    fina l ReportHe lper repor tHelper =  this.getBe an("report Helper",
        221                                      ReportHe lper.class );
        222                    retu rn reportH elper;
        223           }
        224  
        225           pr ivate List <Map<Strin g, Object> > getResul ts(final H ttpSession  session,  final Pagi nator pagi nator) thr ows AuditE xception {
        226                    fina l String s sn = (Stri ng) sessio n
        227                                      .getAttr ibute("inb oundDocume ntQuerySSN ");
        228                    fina l String l astName =  (String) s ession
        229                                      .getAttr ibute("inb oundDocume ntQueryLas tName");
        230                    fina l String f irstName =  (String)  session
        231                                      .getAttr ibute("inb oundDocume ntQueryFir stName");
        232           fi nal String  userId =  (String) s ession
        233                    .get Attribute( "inboundDo cumentQuer yUserId");
        234                    fina l Date sd  = (Date) s ession
        235                                      .getAttr ibute("inb oundDocume ntQuerySta rtDate");
        236                    fina l Date ed  = (Date) s ession
        237                                      .getAttr ibute("inb oundDocume ntQueryEnd Date");
        238                    fina l String f acility =  (String) s ession
        239                                      .getAttr ibute("inb oundDocume ntQueryFac ility");
        240                    fina l String p urposeOfUs e = (Strin g) session
        241                                      .getAttr ibute("pur poseOfUse" );
        242                    fina l String r emoteOrgan ization =  (String) s ession
        243                                      .getAttr ibute("inb oundDocume ntQueryRem oteOrganiz ation");
        244                    fina l int pati entTypes =  (Integer)  session.g etAttribut e("patient Types");
        245                    // s ort
        246                    fina l String i nboundSort Value = (S tring) ses sion
        247                                      .getAttr ibute("inb oundSortVa lue");
        248                    fina l String i nboundSort Direction  = (String)  session
        249                                      .getAttr ibute("inb oundSortDi rection");
        250  
        251                    fina l GetAudit s getAudit sRequest =  new GetAu dits();
        252                    if ( NullChecke r.isNotEmp ty(sd)) {
        253                             getAud itsRequest .setFromDa te(Gregori anDateUtil
        254                                               .getGregor ianCalenda rByDate(sd ));
        255                    }
        256                    if ( NullChecke r.isNotEmp ty(ed)) {
        257                             getAud itsRequest .setToDate (Gregorian DateUtil
        258                                               .getGregor ianCalenda rByDate(ed ));
        259                    }
        260  
        261           //  Set Patie nt Types
        262           ge tAuditsReq uest.setPa tientTypes (patientTy pes);
        263  
        264                    /*
        265                     * / / Set Pati ent Ids if  (NullChec ker.isNotE mpty(icn))  { final
        266                     * S tringValue sType pati entIds = n ew StringV aluesType( );
        267                     * p atientIds. getValue() .add(icn);  patientId s.setNotIn (false);
        268                     * g etAuditsRe quest.setP atientIds( patientIds ); }
        269                     */
        270                    // S et SSN
        271                    if ( NullChecke r.isNotEmp ty(ssn)) {
        272                             final  StringValu esType pat ientSSNs =  new Strin gValuesTyp e();
        273                             patien tSSNs.getV alue().add (ssn);
        274                             patien tSSNs.setN otIn(false );
        275                             getAud itsRequest .setPatien tSSNs(pati entSSNs);
        276                    }
        277                    // S et Last Na me
        278                    if ( NullChecke r.isNotEmp ty(lastNam e)) {
        279                             final  StringValu esType pat ientLastNa mes = new  StringValu esType();
        280                             patien tLastNames .getValue( ).add(last Name);
        281                             patien tLastNames .setNotIn( false);
        282                             getAud itsRequest .setPatien tLastNames (patientLa stNames);
        283                    }
        284                    // S et First N ame
        285                    if ( NullChecke r.isNotEmp ty(firstNa me)) {
        286                             final  StringValu esType pat ientFirstN ames = new  StringVal uesType();
        287                             patien tFirstName s.getValue ().add(fir stName);
        288                             patien tFirstName s.setNotIn (false);
        289                             getAud itsRequest .setPatien tGivenName s(patientF irstNames) ;
        290                    }
        291                    // S et User ID
        292           if  (NullChec ker.isNotE mpty(userI d)) {
        293                final St ringValues Type userI dValue = n ew StringV aluesType( );
        294                userIdVa lue.getVal ue().add(u serId);
        295                userIdVa lue.setNot In(false);
        296                getAudit sRequest.s etUserIds( userIdValu e);
        297           }
        298                    // S et Purpose  of Use
        299                    if ( !NullCheck er.isNullO rEmpty(pur poseOfUse)  ) {
        300                             final  StringValu esType pur poseForUse s = new St ringValues Type();
        301                             purpos eForUses.g etValue(). add(purpos eOfUse);
        302                             purpos eForUses.s etNotIn(fa lse);
        303                             getAud itsRequest .setPurpos eForUses(p urposeForU ses);
        304                    }
        305  
        306                    // S et Facilit y Ids
        307                    if ( NullChecke r.isNotEmp ty(facilit y)) {
        308                             final  StringValu esType fac ilityIds =  new Strin gValuesTyp e();
        309                             facili tyIds.setN otIn(false );
        310                             facili tyIds.getV alue().add (facility) ;
        311                             getAud itsRequest .setPatien tFacilityN umbers(fac ilityIds);
        312                    }
        313  
        314                    /*
        315                     * / / Set Orga nization I ds final S tringValue sType orga nizationId s = new
        316                     * S tringValue sType(); o rganizatio nIds.setNo tIn(false) ;
        317                     * g etAuditsRe quest.setO rganizatio nIds(organ izationIds );
        318                     */
        319  
        320                    // S et Remote  Organizati on Ids
        321                    if ( NullChecke r.isNotEmp ty(remoteO rganizatio n)) {
        322                             final  StringValu esType rem oteOrganiz ationIds =  new Strin gValuesTyp e();
        323                             remote Organizati onIds.setN otIn(false );
        324                             remote Organizati onIds.getV alue().add (remoteOrg anization) ;
        325                             getAud itsRequest .setRemote Organizati onIds(remo teOrganiza tionIds);
        326                    }
        327  
        328                    // s orting
        329                    if ( NullChecke r.isNotEmp ty(inbound SortValue) ) {
        330                             final  SortFieldT ype sortFi eld = new  SortFieldT ype();
        331                             sortFi eld.setFie ld(FieldTy pe.fromVal ue(inbound SortValue) );
        332                             if ("D ESC".equal sIgnoreCas e(inboundS ortDirecti on)) {
        333                                      sortFiel d.setDirec tion(SortD irection.D ESC);
        334                             } else  {
        335                                      sortFiel d.setDirec tion(SortD irection.A SC);
        336                             }
        337                             final  SortFields Type sortF ieldsType  = new Sort FieldsType ();
        338                             sortFi eldsType.g etSortFiel d().add(so rtField);
        339                             getAud itsRequest .setSortFi elds(sortF ieldsType) ;
        340                    }
        341  
        342                    // S et Actions
        343                    fina l ActionVa luesType a ctionsType  = new Act ionValuesT ype();
        344                    acti onsType.ge tValue().a dd(ActionT ype.RETRIE VE_DOCUMEN T_OUT);
        345                    getA uditsReque st.setActi ons(action sType);
        346  
        347                    // S et Page in formation
        348                    fina l PageInfo Type pageI nfoType =  new PageIn foType();
        349                    page InfoType.s etPageNumb er(paginat or.getCurr entPage()) ;
        350                    page InfoType.s etPageSize (paginator .getRecord sPerPage() );
        351                    getA uditsReque st.setPage Info(pageI nfoType);
        352  
        353                    fina l List<Map <String, O bject>> re sults = ne w ArrayLis t<Map<Stri ng, Object >>();
        354           Ge tAuditsRes ponse quer yResponse  = new GetA uditsRespo nse();
        355                    try  {
        356                             try {
        357                    quer yResponse  = this.ada pterAuditM anager.get Audits(get AuditsRequ est);
        358                } catch( Exception  e) {
        359                    thro w new Audi tException ();
        360                }
        361  
        362                             if (Nu llChecker. isNotEmpty (queryResp onse)
        363                                               && NullChe cker.isNot Empty(quer yResponse. getAudits( ))
        364                                               && NullChe cker.isNot Empty(quer yResponse. getAudits( )
        365                                                                .get Audit()))  {
        366                                      final Li st<AuditTy pe> auditT ypeList =  queryRespo nse.getAud its()
        367                                                       .g etAudit();
        368                                      int page Size = pag inator.get RecordsPer Page();
        369                    Faci lityHelper  facilityH elper = th is.getFaci lityHelper ();
        370                    Stri ng userIdS tring;
        371                                      for (fin al AuditTy pe auditTy pe : audit TypeList)  {
        372                                               // final S tring pati entId = au ditType.ge tPatientId ();
        373  
        374                                               // final P atientDemo graphicsQu ery patien tDemograph icsQuery =
        375                                               // new Pat ientDemogr aphicsQuer y();
        376                                               // patient Demographi csQuery.se tPatientId (patientId );
        377                                               // final P atientDemo graphicsRe sponse res ponse =
        378                                               // this.pd qService
        379                                               // .getPat ientDemogr aphics(pat ientDemogr aphicsQuer y);
        380  
        381                                               final Map< String, Ob ject> resu ltMap = ne w HashMap< String, Ob ject>();
        382  
        383                                               ReportData Processor. addSsnToRe sultMap(re sultMap, a uditType.g etPatientS SN());
        384  
        385                                               resultMap. put("patie ntICN", Re portDataPr ocessor
        386                                                                .nul lEmptyRepl aceWithUnk nown(audit Type
        387                                                                                  .getPati entId()));
        388  
        389                                               // A) Repl ace this w ith B
        390                                               resultMap. put("audit Time", Gre gorianDate Util
        391                                                                .get DateFromGr egorianCal endar(audi tType
        392                                                                                  .getAudi tTime()));
        393  
        394                                               // B) The  following  logic coul d supplant  the previ ous one, A
        395                                               resultMap. put("audit TimeFormat ted", this .getReport Helper().g etFormatte dDateTime( GregorianD ateUtil
        396                                                                .get DateFromGr egorianCal endar(audi tType
        397                                                                                  .getAudi tTime()))) ;
        398  
        399                                               resultMap. put("purpo seForUse",  ReportDat aProcessor
        400                                                                .nul lEmptyRepl aceWithUnk nown(audit Type
        401                                                                                  .getPurp oseForUse( )));
        402  
        403                         resultMap. put("userF acilityCod e", "");
        404                         resultMap. put("userF acilityNam e", "");
        405  
        406                         userIdStri ng = Repor tDataProce ssor.nullE mptyReplac eWithUnkno wn(auditTy pe.getUser Id()).repl ace(" ? ",  " ");
        407                         resultMap. put("userI d", userId String);
        408  
        409                         //Parse th e user id  field for  facility c ode and us er name.
        410                         if (userId String.sub string(0,4 ).matches( "^\\d{3}:" )){
        411                             result Map.put("u serFacilit yCode", us erIdString .substring (0,3));
        412                             result Map.put("u serFacilit yName", fa cilityHelp er.getFaci lityNameBy StationId( userIdStri ng.substri ng(0,3)));
        413                         }
        414  
        415                         if (userId String.ind exOf("CN=" ) > 0){
        416                             result Map.put("u serName",u serIdStrin g.substrin g((userIdS tring.inde xOf("CN=")  + 3),
        417                                 us erIdString .indexOf(" ,", userId String.ind exOf("CN=" ))));
        418                         }
        419  
        420                                               // resultM ap.put("pa tient",
        421                                               // respons e.getPatie ntDemograp hics());
        422  
        423                                               resultMap. put("lastN ame", Repo rtDataProc essor
        424                                                                .nul lEmptyRepl aceWithUnk nown(audit Type
        425                                                                                  .getPati entLastNam e()));
        426                                               resultMap. put("first Name", Rep ortDataPro cessor
        427                                                                .nul lEmptyRepl aceWithUnk nown(audit Type
        428                                                                                  .getPati entGivenNa me()));
        429                                               resultMap. put("patie ntFacility Name", Rep ortDataPro cessor
        430                                                                .fix Station(au ditType.ge tPatientFa cilityName ()));
        431                                               resultMap. put("patie ntFacility Number", R eportDataP rocessor
        432                                                                .nul lEmptyRepl aceWithUnk nown(audit Type
        433                                                                                  .getPati entFacilit yNumber()) );
        434  
        435                         resultMap. put("remot eOrganizat ionName",  this.getRe portHelper ().findOrg anizationB yOid(audit Type.getRe moteOrgani zationId() , auditTyp e.getRemot eOrganizat ionName()) );
        436  
        437                         resultMap. put("remot eOrganizat ionId", Re portDataPr ocessor
        438                                                                .nul lEmptyRepl aceWithUnk nown(audit Type
        439                                                                                  .getRemo teOrganiza tionId())) ;
        440                                               /*
        441                                                * resultM ap.put( "r emoteFacil ity", this .getCmsHel per()
        442                                                * .getOrg anizationB yHomeCommu nityId(
        443                                                * auditTy pe.getRemo teOrganiza tionId())) ;
        444                                                * resultM ap.put("re moteDocRep ositoryId" ,
        445                                                * auditTy pe.getRemo teDocument Repository Id());
        446                                                */
        447  
        448                                               resultMap. put("docum entId", Re portDataPr ocessor
        449                                                                .nul lEmptyRepl aceWithUnk nown(audit Type
        450                                                                                  .getDocu mentId())) ;
        451                                               resultMap. put("docum entTitle",  ReportDat aProcessor
        452                                                                .nul lEmptyRepl aceWithUnk nown(audit Type
        453                                                                                  .getDocu mentTitle( )));
        454                                               resultMap. put("roleN ame", Repo rtDataProc essor
        455                                                                .nul lEmptyRepl aceWithUnk nown(audit Type
        456                                                                                  .getRole Name()));
        457                                               results.ad d(resultMa p);
        458                                      }
        459  
        460                                      // TODO:  Move sett ing of ses sion varia bles to a  different  method
        461                                      // Check  if any of  the patie nt match c riteria ex ists
        462                                      if (Null Checker.is NotEmpty(s sn)
        463                                                       ||  NullCheck er.isNotEm pty(lastNa me)
        464                                                       ||  NullCheck er.isNotEm pty(firstN ame)) {
        465                                               // Default  to unknow n
        466                                               String res ultIcn = " ";
        467                                               if (NullCh ecker.isNo tEmpty(aud itTypeList )) {
        468                                                       fi nal AuditT ype result  = auditTy peList.get (0);
        469                                                       re sultIcn =  result.get PatientId( );
        470  
        471                                                       if  (NullChec ker.isNotE mpty(resul tIcn)) {
        472                                                                for  (final Aud itType aud itType : a uditTypeLi st) {
        473                                                                         if (!r esultIcn.e quals(audi tType.getP atientId() )) {
        474                                                                                  resultIc n = "Multi ple ICNs";
        475                                                                                  break;
        476                                                                         }
        477                                                                }
        478                                                       }  else if (N ullChecker .isNotEmpt y(result
        479                                                                         .getPa tientGiven Name())
        480                                                                         && Nul lChecker.i sNotEmpty( result
        481                                                                                           .getPatien tLastName( ))
        482                                                                         && Nul lChecker.i sNotEmpty( result
        483                                                                                           .getPatien tSSN())) {
        484                                                                fina l String p atientGive nName = re sult
        485                                                                                  .getPati entGivenNa me();
        486                                                                fina l String p atientLast Name = res ult
        487                                                                                  .getPati entLastNam e();
        488                                                                fina l String p atientSsn  = result.g etPatientS SN();
        489                                                                bool ean multip leIcns = f alse;
        490                                                                for  (final Aud itType aud itType : a uditTypeLi st) {
        491                                                                         if (!p atientGive nName.equa ls(auditTy pe
        492                                                                                           .getPatien tGivenName ())
        493                                                                                           || !patien tLastName. equals(aud itType
        494                                                                                                            .get PatientLas tName())
        495                                                                                           || !patien tSsn.equal s(auditTyp e
        496                                                                                                            .get PatientSSN ())) {
        497                                                                                  multiple Icns = tru e;
        498                                                                                  break;
        499                                                                         }
        500                                                                }
        501                                                                if ( multipleIc ns) {
        502                                                                         result Icn = "Mul tiple ICNs ";
        503                                                                } el se {
        504                                                                         result Icn = this .getReport Helper().r esolveICN(
        505                                                                                           result.get PatientGiv enName(),
        506                                                                                           result.get PatientLas tName(),
        507                                                                                           result.get PatientSSN ());
        508                                                                }
        509                                                       }
        510                                               } else if  (NullCheck er.isNotEm pty(ssn)
        511                                                                && N ullChecker .isNotEmpt y(lastName )
        512                                                                && N ullChecker .isNotEmpt y(firstNam e)) {
        513                                                       //  Try to ge t from wha t was type d
        514                                                       re sultIcn =  this.getRe portHelper ().resolve ICN(
        515                                                                         firstN ame, lastN ame, ssn);
        516                                               }
        517                                               // Set in  Session
        518                                               if (NullCh ecker.isEm pty(result Icn)) {
        519                                                       re sultIcn =  "Unknown";
        520                                               }
        521                                               session.se tAttribute ("inboundD ocumentQue ryICN", re sultIcn);
        522                                      }
        523                                      //return  results;
        524                             }
        525                    } ca tch (final  AuditExce ption ex)  {
        526                             throw  new AuditE xception(e x);
        527                    } //  catch (fi nal PdqExc eption ex)  {
        528                             // thr ow new Run timeExcept ion(ex);
        529                    // }
        530  
        531                    retu rn results ;
        532           }
        533  
        534           pr ivate bool ean isPagi natorPrese nt(final H ttpSession  session)  {
        535                    retu rn !NullCh ecker.isNu llOrEmpty( session.ge tAttribute ("paginato r"));
        536           }
        537  
        538           pu blic void  next(final  HttpServl etRequest  request,
        539                             final  HttpServle tResponse  response)  throws Ser vletExcept ion,
        540                             IOExce ption {
        541                    fina l HttpSess ion sessio n = reques t.getSessi on(false);
        542                    if ( this.isPag inatorPres ent(sessio n)) {
        543                             final  Paginator  paginator  = (Paginat or) sessio n
        544                                               .getAttrib ute("pagin ator");
        545                             pagina tor.next(r equest);
        546                             sessio n.setAttri bute("pagi nator", pa ginator);
        547                             sessio n.setAttri bute("inbo undDocumen tResults",
        548                                               this.getRe sults(sess ion, pagin ator));
        549                             this.f orward(req uest, resp onse, "sho w");
        550                    } el se {
        551                             this.f orward(req uest, resp onse, "nos how");
        552                    }
        553           }
        554  
        555           pu blic void  prev(final  HttpServl etRequest  request,
        556                             final  HttpServle tResponse  response)  throws Ser vletExcept ion,
        557                             IOExce ption {
        558                    fina l HttpSess ion sessio n = reques t.getSessi on(false);
        559                    if ( this.isPag inatorPres ent(sessio n)) {
        560                             final  Paginator  paginator  = (Paginat or) sessio n
        561                                               .getAttrib ute("pagin ator");
        562                             pagina tor.previo us(request );
        563                             sessio n.setAttri bute("pagi nator", pa ginator);
        564                             sessio n.setAttri bute("inbo undDocumen tResults",
        565                                               this.getRe sults(sess ion, pagin ator));
        566                             this.f orward(req uest, resp onse, "sho w");
        567                    } el se {
        568                             this.f orward(req uest, resp onse, "nos how");
        569                    }
        570           }
        571  
        572           @E JB(beanInt erface = A dapterAudi tManager.c lass, mapp edName = " AdapterAud itManager" )
        573           pu blic void  setAdapter AuditManag er(
        574                             final  AdapterAud itManager  adapterAud itManager)  {
        575                    this .adapterAu ditManager  = adapter AuditManag er;
        576           }
        577  
        578           @O verride
        579           pr otected vo id unspeci fied(final  HttpServl etRequest  request,
        580                             final  HttpServle tResponse  response)  throws Ser vletExcept ion,
        581                             IOExce ption {
        582                    fina l HttpSess ion sessio n = reques t.getSessi on(false);
        583  
        584                    // s ort
        585                    fina l String i nboundSort Value = re quest
        586                                      .getPara meter("inb oundSortVa lue");
        587                    fina l String i nboundSort Direction  = request
        588                                      .getPara meter("inb oundSortDi rection");
        589                    sess ion.setAtt ribute("in boundSortV alue", inb oundSortVa lue);
        590                    sess ion.setAtt ribute("in boundSortD irection",  inboundSo rtDirectio n);
        591  
        592                    if ( this.isPag inatorPres ent(sessio n)) {
        593                             Pagina tor pagina tor = (Pag inator) se ssion.getA ttribute(" paginator" );
        594                             if (Nu llChecker. isEmpty(pa ginator))  {
        595                                      paginato r = new Pa ginator(0) ;
        596                                      session. setAttribu te("pagina tor", pagi nator);
        597                             }
        598                             pagina tor.reset( );
        599                             sessio n.setAttri bute("inbo undDocumen tResults",
        600                                               this.getRe sults(sess ion, pagin ator));
        601                             this.f orward(req uest, resp onse, "sho w");
        602                    } el se {
        603                             this.f orward(req uest, resp onse, "nos how");
        604                    }
        605           }
        606  
        607           pu blic void  view(final  HttpServl etRequest  request,
        608                             final  HttpServle tResponse  response)  throws Ser vletExcept ion,
        609                             IOExce ption {
        610                    fina l HttpSess ion sessio n = reques t.getSessi on(false);
        611                    fina l String i cn = reque st.getPara meter("icn ");
        612                    fina l String d ocumentUni queId = re quest
        613                                      .getPara meter("doc umentUniqu eId");
        614                    fina l String s tyleSheetV iewType =  request
        615                                      .getPara meter("sty leSheetVie wType");
        616  
        617                    Stri ng documen t = null;
        618                    try  {
        619                             docume nt = this. getDocumen tHelper(). getDocumen t(icn,
        620                                               documentUn iqueId, Us erHelper.g etUserName (request),
        621                                               this.getCm sHelper(). getComplet eHomeCommu nityId());
        622                    } ca tch (final  AdapterEx ception ex ) {
        623                             throw  new Servle tException (ex);
        624                    }
        625  
        626                    sess ion.setAtt ribute("ic n", icn);
        627                    sess ion.setAtt ribute("do cumentUniq ueId", doc umentUniqu eId);
        628                    sess ion.setAtt ribute("do cument", d ocument);
        629                    sess ion.setAtt ribute("is XmlViewEna bled", thi s.getDocum entHelper( )
        630                                      .isXmlVi ewEnabled( ));
        631  
        632                    if ( "xml".equa ls(styleSh eetViewTyp e)) {
        633                             docume nt = docum ent
        634                                               .replaceAl l(
        635                                                                "<?x ml-stylesh eet type=\ "text/xsl\ " href=\"C CD.xsl\"?> ",
        636                                                                "");
        637                             respon se.setCont entType("t ext/xml;ch arset=UTF- 8");
        638                             respon se.getWrit er().write (document) ;
        639                    } el se {
        640                             // Upd ate sessio n in the d ocument
        641                             final  String htm l = this.g etDocument Helper().g etHtml(doc ument,
        642                                               styleSheet ViewType);
        643  
        644                             sessio n.setAttri bute("upda tedDocumen t", html);
        645                             this.f orward(req uest, resp onse, "sho wInboundDo cumentRepo rtDocument ");
        646                    }
        647           }
        648  
        649       privat e Facility DAO getFac ilityDAO()  {
        650           re turn this. getBean("F acilityDAO ", Facilit yDAO.class );
        651       }
        652  
        653       privat e UserDocu mentDAO ge tUserDocum entDAO() {
        654           re turn this. getBean("U serDocumen tDAO", Use rDocumentD AO.class);
        655       }
        656   }