Produced by Araxis Merge on 6/9/2017 3:51:27 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.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | Fri Jun 9 19:51:27 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 | DisclosureSummaryReport.java | Fri Apr 21 20:03:30 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 0 | 0 |
| Changed | 0 | 0 |
| Inserted | 1 | 489 |
| Removed | 0 | 0 |
| 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 |
No regular expressions were active.
| 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 itSummarie sType; | |||||
| 6 | import gov .va.med.nh in.adapter .audit.Aud itSummaryT ype; | |||||
| 7 | import gov .va.med.nh in.adapter .audit.Fie ldType; | |||||
| 8 | import gov .va.med.nh in.adapter .audit.Get AuditsSumm ary; | |||||
| 9 | import gov .va.med.nh in.adapter .audit.Get AuditsSumm aryRespons e; | |||||
| 10 | import gov .va.med.nh in.adapter .audit.Gro upByFields Type; | |||||
| 11 | import gov .va.med.nh in.adapter .audit.Pag eInfoType; | |||||
| 12 | import gov .va.med.nh in.adapter .audit.Str ingValuesT ype; | |||||
| 13 | import gov .va.med.nh in.adapter .audit.Sum maryFields Type; | |||||
| 14 | import gov .va.nvap.c ommon.date .Gregorian DateUtil; | |||||
| 15 | import gov .va.nvap.c ommon.sort .BubbleSor tListMap; | |||||
| 16 | import gov .va.nvap.c ommon.vali dation.Nul lChecker; | |||||
| 17 | import gov .va.nvap.p rivacy.Org anizationT ype; | |||||
| 18 | import gov .va.nvap.s ervice.ada pter.audit .AdapterAu ditManager ; | |||||
| 19 | import gov .va.nvap.s ervice.ada pter.audit .DirectAud itManager; | |||||
| 20 | import gov .va.nvap.s ervice.ada pter.audit .DirectSer viceEndpoi nt; | |||||
| 21 | import gov .va.nvap.s ervice.ada pter.audit .DirectSer viceExcept ion; | |||||
| 22 | import gov .va.nvap.s ervice.aud it.AuditEx ception; | |||||
| 23 | import gov .va.nvap.w eb.app.Res ponseDispa tcherHttpS ervlet; | |||||
| 24 | import gov .va.nvap.w eb.dao.Fac ilityDAO; | |||||
| 25 | import gov .va.nvap.w eb.helper. facility.F acilityHel per; | |||||
| 26 | import gov .va.nvap.w eb.helper. privacy.Co nsentManag ementHelpe r; | |||||
| 27 | import gov .va.nvap.w eb.helper. report.Rep ortHelper; | |||||
| 28 | import gov .va.nvap.w eb.util.xl s.ExcelExp orter; | |||||
| 29 | ||||||
| 30 | import jav a.io.IOExc eption; | |||||
| 31 | import jav a.io.Strin gWriter; | |||||
| 32 | import jav a.util.Arr ayList; | |||||
| 33 | import jav a.util.Dat e; | |||||
| 34 | import jav a.util.Lin kedHashMap ; | |||||
| 35 | import jav a.util.Lis t; | |||||
| 36 | import jav a.util.Map ; | |||||
| 37 | import jav a.util.log ging.Level ; | |||||
| 38 | import jav a.util.log ging.Logge r; | |||||
| 39 | import jav ax.ejb.EJB ; | |||||
| 40 | ||||||
| 41 | import jav ax.servlet .ServletEx ception; | |||||
| 42 | import jav ax.servlet .http.Http ServletReq uest; | |||||
| 43 | import jav ax.servlet .http.Http ServletRes ponse; | |||||
| 44 | import jav ax.servlet .http.Http Session; | |||||
| 45 | ||||||
| 46 | import org .apache.po i.ss.userm odel.Workb ook; | |||||
| 47 | import org .json.JSON Exception; | |||||
| 48 | import org .json.JSON Object; | |||||
| 49 | ||||||
| 50 | /** | |||||
| 51 | * Disclos ures Summa ry Report search ser vlet | |||||
| 52 | */ | |||||
| 53 | public cla ss Disclos ureSummary Report ext ends Respo nseDispatc herHttpSer vlet { | |||||
| 54 | /** | |||||
| 55 | * Ser ial UID. | |||||
| 56 | */ | |||||
| 57 | privat e static f inal long serialVers ionUID = 3 7215033550 79491829L; | |||||
| 58 | ||||||
| 59 | privat e AdapterA uditManage r adapterA uditManage r; | |||||
| 60 | privat e final Di rectAuditM anager dir ectAuditMa nager = ne w DirectSe rviceEndpo int(); | |||||
| 61 | ||||||
| 62 | @Overr ide | |||||
| 63 | protec ted void u nspecified (final Htt pServletRe quest requ est, final HttpServl etResponse response) throws Se rvletExcep tion, IOEx ception { | |||||
| 64 | ||||||
| 65 | fi nal HttpSe ssion sess ion = requ est.getSes sion(false ); | |||||
| 66 | se ssion.remo veAttribut e("results "); | |||||
| 67 | Re portHelper .setDefaul tSearchDat es(session ); | |||||
| 68 | re quest.setA ttribute(" facilities ", getFaci lityHelper ().getAllV istAFacili ties()); | |||||
| 69 | ge tReportHel per().getO rgLists(re quest, thi s.getCmsHe lper()); | |||||
| 70 | ||||||
| 71 | th is.forward (request, response, "show"); | |||||
| 72 | } | |||||
| 73 | ||||||
| 74 | ||||||
| 75 | privat e ConsentM anagementH elper getC msHelper() { | |||||
| 76 | re turn this. getBean("c msHelper", ConsentMa nagementHe lper.class ); | |||||
| 77 | } | |||||
| 78 | ||||||
| 79 | privat e Facility Helper get FacilityHe lper() { | |||||
| 80 | re turn this. getBean("f acilityHel per", Faci lityHelper .class); | |||||
| 81 | } | |||||
| 82 | ||||||
| 83 | privat e ReportHe lper getRe portHelper () { | |||||
| 84 | re turn this. getBean("r eportHelpe r", Report Helper.cla ss); | |||||
| 85 | } | |||||
| 86 | ||||||
| 87 | privat e Facility DAO getFac ilityDAO() { | |||||
| 88 | re turn this. getBean("F acilityDAO ", Facilit yDAO.class ); | |||||
| 89 | } | |||||
| 90 | ||||||
| 91 | privat e ExcelExp orter getE xcelExport er() { | |||||
| 92 | re turn this. getBean("e xcelExport er", Excel Exporter.c lass); | |||||
| 93 | } | |||||
| 94 | ||||||
| 95 | @EJB(b eanInterfa ce = Adapt erAuditMan ager.class , mappedNa me = "Adap terAuditMa nager") | |||||
| 96 | public void setA dapterAudi tManager( | |||||
| 97 | final Ad apterAudit Manager ad apterAudit Manager) { | |||||
| 98 | th is.adapter AuditManag er = adapt erAuditMan ager; | |||||
| 99 | } | |||||
| 100 | ||||||
| 101 | /** | |||||
| 102 | * | |||||
| 103 | * @pa ram reques t | |||||
| 104 | * @pa ram respon se | |||||
| 105 | * @th rows Servl etExceptio n | |||||
| 106 | * @th rows IOExc eption | |||||
| 107 | */ | |||||
| 108 | public void doSe arch(final HttpServl etRequest request, f inal HttpS ervletResp onse respo nse) throw s ServletE xception, IOExceptio n { | |||||
| 109 | fi nal HttpSe ssion sess ion = requ est.getSes sion(false ); | |||||
| 110 | ||||||
| 111 | se ssion.setA ttribute(" results", encodeInto JSON(getRe sults(requ est))); | |||||
| 112 | ||||||
| 113 | th is.forward (request, response, "searchRes ultsJSON") ; | |||||
| 114 | } | |||||
| 115 | ||||||
| 116 | /** | |||||
| 117 | * Ret urns searc h results map and to tal count packaged t ogether in SearchRes ultsPackag e class. i f request parameters are not p assed, | |||||
| 118 | * def ault value s are used for searc h results. | |||||
| 119 | * | |||||
| 120 | * @pa ram reques t | |||||
| 121 | * @re turn | |||||
| 122 | * @th rows Servl etExceptio n | |||||
| 123 | */ | |||||
| 124 | privat e SearchRe sultsPacka ge getResu lts(final HttpServle tRequest r equest) | |||||
| 125 | throws S ervletExce ption { | |||||
| 126 | ||||||
| 127 | fi nal String source = (request.g etParamete r("source" ) != null) | |||||
| 128 | ? re quest.getP arameter(" source") : "Exchange "; | |||||
| 129 | fi nal Date s d = Report Helper.get StartDate( request.ge tParameter ("startDat e")); | |||||
| 130 | fi nal Date e d = Report Helper.get EndDate(re quest.getP arameter(" endDate")) ; | |||||
| 131 | fi nal String userId = ""; | |||||
| 132 | fi nal String organizat ion = (req uest.getPa rameter("o rganizatio n") != nul l) | |||||
| 133 | ? re quest.getP arameter(" organizati on") : "ex ternal"; | |||||
| 134 | fi nal String patientFa cility = ( request.ge tParameter ("facility ") != null ) | |||||
| 135 | ? re quest.getP arameter(" facility") : ""; | |||||
| 136 | fi nal int pa tientTypes = (reques t.getParam eter("pati entTypes") != null) | |||||
| 137 | ? In teger.pars eInt(reque st.getPara meter("pat ientTypes" )) : 1; | |||||
| 138 | ||||||
| 139 | fi nal GetAud itsSummary getAudits Summary = new GetAud itsSummary (); | |||||
| 140 | ||||||
| 141 | // start tim e | |||||
| 142 | if (NullChec ker.isNotE mpty(sd)) { | |||||
| 143 | getAudit sSummary.s etFromDate (Gregorian DateUtil | |||||
| 144 | .getGregor ianCalenda rByDate(sd )); | |||||
| 145 | } | |||||
| 146 | // to time | |||||
| 147 | if (NullChec ker.isNotE mpty(ed)) { | |||||
| 148 | getAudit sSummary.s etToDate(G regorianDa teUtil | |||||
| 149 | .getGregor ianCalenda rByDate(ed )); | |||||
| 150 | } | |||||
| 151 | // Set User I D | |||||
| 152 | if (NullChec ker.isNotE mpty(userI d)) { | |||||
| 153 | final St ringValues Type userI dValue = n ew StringV aluesType( ); | |||||
| 154 | userIdVa lue.getVal ue().add(u serId); | |||||
| 155 | userIdVa lue.setNot In(false); | |||||
| 156 | getAudit sSummary.s etUserIds( userIdValu e); | |||||
| 157 | } | |||||
| 158 | ge tAuditsSum mary.setPa tientTypes (patientTy pes); | |||||
| 159 | ||||||
| 160 | // action ty pe | |||||
| 161 | fi nal Action ValuesType actionVal uesType = new Action ValuesType (); | |||||
| 162 | fi nal List<A ctionType> actiontyp e = action ValuesType .getValue( ); | |||||
| 163 | ac tiontype.a dd(ActionT ype.RETRIE VE_DOCUMEN T); | |||||
| 164 | ac tionValues Type.setNo tIn(false) ; | |||||
| 165 | ge tAuditsSum mary.setAc tions(acti onValuesTy pe); | |||||
| 166 | ||||||
| 167 | // patient p referred f acility | |||||
| 168 | if (!NullChe cker.isNul lOrEmpty(p atientFaci lity)) { | |||||
| 169 | ||||||
| 170 | final St ringValues Type patie ntFacilyNu mber = new StringVal uesType(); | |||||
| 171 | patientF acilyNumbe r.setNotIn (false); | |||||
| 172 | final Li st<String> patientFa cilyNumber List = pat ientFacily Number | |||||
| 173 | .getValue( ); | |||||
| 174 | patientF acilyNumbe rList.add( patientFac ility); | |||||
| 175 | getAudit sSummary.s etPatientF acilityNum bers(patie ntFacilyNu mber); | |||||
| 176 | } | |||||
| 177 | ||||||
| 178 | if (!NullChe cker.isNul lOrEmpty(o rganizatio n) | |||||
| 179 | && ! organizati on.equals( "external" )) { | |||||
| 180 | final St ringValues Type organ izationIds = new Str ingValuesT ype();// g etAuditsSu mmary.getR emoteOrgan izationIds (); | |||||
| 181 | organiza tionIds.se tNotIn(fal se); | |||||
| 182 | final Li st<String> organizat ionIdsList = organiz ationIds.g etValue(); | |||||
| 183 | organiza tionIdsLis t | |||||
| 184 | .add(organ ization.re place("%", "urn:oid: ")); | |||||
| 185 | getAudit sSummary.s etOrganiza tionIds(or ganization Ids); | |||||
| 186 | } else { | |||||
| 187 | // input orgs are empty - in tent is to retrieve all orgs e xcept VA | |||||
| 188 | final St ringValues Type organ izationIds = new Str ingValuesT ype(); | |||||
| 189 | organiza tionIds.se tNotIn(tru e); | |||||
| 190 | organiza tionIds.ge tValue().a dd( | |||||
| 191 | this.getCm sHelper(). getComplet eHomeCommu nityId()); | |||||
| 192 | getAudit sSummary.s etOrganiza tionIds(or ganization Ids); | |||||
| 193 | } | |||||
| 194 | ||||||
| 195 | // group by | |||||
| 196 | fi nal GroupB yFieldsTyp e groupByF ieldsType = new Grou pByFieldsT ype(); | |||||
| 197 | fi nal List<F ieldType> fieldTypeL ist = grou pByFieldsT ype | |||||
| 198 | .get GroupByFie ld(); | |||||
| 199 | fi eldTypeLis t.add(Fiel dType.ORGA NIZATION_I D); | |||||
| 200 | fi eldTypeLis t.add(Fiel dType.PATI ENT_FACILI TY_NUMBER) ; | |||||
| 201 | fi eldTypeLis t.add(Fiel dType.PATI ENT_FACILI TY_NAME); | |||||
| 202 | fi eldTypeLis t.add(Fiel dType.ORGA NIZATION_N AME); | |||||
| 203 | ge tAuditsSum mary.setGr oupByField s(groupByF ieldsType) ; | |||||
| 204 | ||||||
| 205 | // Set Page informatio n | |||||
| 206 | fi nal PageIn foType pag eInfoType = new Page InfoType() ; | |||||
| 207 | pa geInfoType .setPageSi ze(-1); | |||||
| 208 | ge tAuditsSum mary.setPa geInfo(pag eInfoType) ; | |||||
| 209 | ||||||
| 210 | // web servi ces respon se | |||||
| 211 | Ge tAuditsSum maryRespon se getAudi tsSummaryR esponse; | |||||
| 212 | tr y { | |||||
| 213 | if (sour ce.equals( "Direct")) { | |||||
| 214 | getA uditsSumma ryResponse = this.di rectAuditM anager.get AuditSumma ry(getAudi tsSummary) ; | |||||
| 215 | } else { | |||||
| 216 | getA uditsSumma ryResponse = this.ad apterAudit Manager.ge tAuditSumm ary(getAud itsSummary ); | |||||
| 217 | } | |||||
| 218 | } catch (fin al AuditEx ception e) { | |||||
| 219 | throw ne w AuditExc eption(); | |||||
| 220 | } catch (fin al DirectS erviceExce ption ex) { | |||||
| 221 | throw ne w DirectSe rviceExcep tion(); | |||||
| 222 | } | |||||
| 223 | ||||||
| 224 | fi nal List<M ap<String, Object>> results = new ArrayL ist<Map<St ring, Obje ct>>(); | |||||
| 225 | lo ng totalCo unt = 0l; | |||||
| 226 | fi nal AuditS ummariesTy pe auditSu mmariesTyp e = getAud itsSummary Response | |||||
| 227 | .get AuditSumma ries(); | |||||
| 228 | Li st<AuditSu mmaryType> auditSumm ary = new ArrayList< AuditSumma ryType>(); | |||||
| 229 | if (auditSum mariesType != null) { | |||||
| 230 | auditSum mary = aud itSummarie sType.getA uditSummar y(); | |||||
| 231 | } | |||||
| 232 | fo r (final A uditSummar yType audi tSummaryTy pe2 : audi tSummary) { | |||||
| 233 | final Au ditSummary Type audit SummaryTyp e = auditS ummaryType 2; | |||||
| 234 | ||||||
| 235 | final Ma p<String, Object> re sultMap = new Linked HashMap<St ring, Obje ct>(); | |||||
| 236 | final lo ng count = auditSumm aryType.ge tCount(); | |||||
| 237 | final Su mmaryField sType summ aryFields = auditSum maryType | |||||
| 238 | .getSummar yFields(); | |||||
| 239 | final Li st<String> summaryFi eld = summ aryFields. getSummary Field(); | |||||
| 240 | ||||||
| 241 | Organiza tionType o rganizatio nType = nu ll; | |||||
| 242 | if (Null Checker.is Empty(summ aryField)) { | |||||
| 243 | cont inue; | |||||
| 244 | } | |||||
| 245 | ||||||
| 246 | if (sour ce.equals( "Direct")) { | |||||
| 247 | if ( summaryFie ld.size() < 1) { | |||||
| 248 | continue; | |||||
| 249 | } | |||||
| 250 | resu ltMap.put( "partnerOr g", summar yField.get (0)); | |||||
| 251 | } else { | |||||
| 252 | if ( summaryFie ld.size() < 4) { | |||||
| 253 | continue; | |||||
| 254 | } | |||||
| 255 | ||||||
| 256 | if ( NullChecke r.isNotEmp ty(summary Field.get( 0))) { | |||||
| 257 | organizati onType = ( this.getCm sHelper() | |||||
| 258 | .g etOrganiza tionByHome CommunityI d(summaryF ield.get(0 ) | |||||
| 259 | .rep lace("urn: oid:", "") )); | |||||
| 260 | } | |||||
| 261 | ||||||
| 262 | if ( !NullCheck er.isNullO rEmpty(org anizationT ype)) { | |||||
| 263 | ||||||
| 264 | resultMap. put("partn erOrg", Re portDataPr ocessor | |||||
| 265 | .n ullEmptyRe placeWithU nknown(org anizationT ype | |||||
| 266 | .get OrgName()) ); | |||||
| 267 | } el se { | |||||
| 268 | resultMap. put("partn erOrg", Re portDataPr ocessor | |||||
| 269 | .n ullEmptyRe placeWithU nknown(sum maryField. get(3))); | |||||
| 270 | } | |||||
| 271 | ||||||
| 272 | // E xtract val ue | |||||
| 273 | fina l String a dapterVAFa cility = s ummaryFiel d.get(1); | |||||
| 274 | Stri ng vaFacil ity; | |||||
| 275 | if ( ReportData Processor. isValidSta tion(adapt erVAFacili ty)) { | |||||
| 276 | vaFacility = this.ge tFacilityH elper() | |||||
| 277 | .g etFacility NameByStat ionId(adap terVAFacil ity); | |||||
| 278 | if (NullCh ecker.isEm pty(vaFaci lity)) { | |||||
| 279 | vaFaci lity = sum maryField. get(2); | |||||
| 280 | } | |||||
| 281 | } el se { | |||||
| 282 | vaFacility = summary Field.get( 2); | |||||
| 283 | } | |||||
| 284 | ||||||
| 285 | resu ltMap.put( "vaFacilit y", | |||||
| 286 | Report DataProces sor.fixSta tion(vaFac ility)); | |||||
| 287 | ||||||
| 288 | fina l String a dapterVAFa cilityNumb er = summa ryField.ge t(1); | |||||
| 289 | if ( !NullCheck er.isNullO rEmpty(ada pterVAFaci lityNumber )) { | |||||
| 290 | resultMap. put("vaFac ilityNumbe r", | |||||
| 291 | Report DataProces sor.fixSta tion(summa ryField.ge t(1))); | |||||
| 292 | } el se { | |||||
| 293 | resultMap. put("vaFac ilityNumbe r", | |||||
| 294 | Report DataProces sor.fixSta tion("Unav ailable")) ; | |||||
| 295 | } | |||||
| 296 | } | |||||
| 297 | resultMa p.put("tot al", count ); | |||||
| 298 | results. add(result Map); | |||||
| 299 | totalCou nt += coun t; | |||||
| 300 | ||||||
| 301 | } | |||||
| 302 | // sort and r eturn pack aged data | |||||
| 303 | re turn new S earchResul tsPackage( sortResul ts(results , request) , totalCou nt, source ); | |||||
| 304 | } | |||||
| 305 | ||||||
| 306 | ||||||
| 307 | /** | |||||
| 308 | * sor ts values of List<Ma p<String,O bject>> ke ys based o n request parameters | |||||
| 309 | * @pa ram unsort edList | |||||
| 310 | * @pa ram reques t | |||||
| 311 | * @re turn | |||||
| 312 | */ | |||||
| 313 | privat e List<Map <String,Ob ject>> sor tResults(L ist<Map<St ring,Objec t>> unsort edList, Ht tpServletR equest req uest){ | |||||
| 314 | ||||||
| 315 | if (unsortedL ist.isEmpt y()){ | |||||
| 316 | return u nsortedLis t; | |||||
| 317 | } | |||||
| 318 | ||||||
| 319 | ||||||
| 320 | St ring selec tedSource = (request .getParame ter("sourc e") != nul l) | |||||
| 321 | ? re quest.getP arameter(" source") : "Exchange "; | |||||
| 322 | St ring sortV alue = req uest.getPa rameter("o rder[0][co lumn]") == null ? re quest.getP arameter(" sortBy") : request.g etParamete r("order[0 ][column]" ); | |||||
| 323 | bo olean sort Ascending = request. getParamet er("order[ 0][dir]") == null ? !"desc".eq ualsIgnore Case(reque st.getPara meter("sor tOrder")) : | |||||
| 324 | !"desc". equalsIgno reCase(req uest.getPa rameter("o rder[0][di r]")); | |||||
| 325 | fi nal Bubble SortListMa p bSorter = new Bubb leSortList Map(); | |||||
| 326 | ||||||
| 327 | if ("Exchange ".equals(s electedSou rce)){ | |||||
| 328 | if("0".e quals(sort Value)){ | |||||
| 329 | sort Value = "p artnerOrg" ; | |||||
| 330 | } else i f ("1".equ als(sortVa lue)){ | |||||
| 331 | sort Value = "v aFacility" ; | |||||
| 332 | } else i f ("2".equ als(sortVa lue)){ | |||||
| 333 | sort Value = "v aFacilityN umber"; | |||||
| 334 | } else i f ("3".equ als(sortVa lue)){ | |||||
| 335 | sort Value = "t otal"; | |||||
| 336 | } else { | |||||
| 337 | sort Value = "p artnerOrg" ; | |||||
| 338 | } | |||||
| 339 | } else { | |||||
| 340 | if("0".e quals(sort Value)){ | |||||
| 341 | sort Value = "p artnerOrg" ; | |||||
| 342 | } else i f ("1".equ als(sortVa lue)){ | |||||
| 343 | sort Value = "t otal"; | |||||
| 344 | } else { | |||||
| 345 | sort Value = "p artnerOrg" ; | |||||
| 346 | } | |||||
| 347 | } | |||||
| 348 | ||||||
| 349 | re turn bSort er.sortByC olumn(unso rtedList, sortValue, sortAscen ding); | |||||
| 350 | } | |||||
| 351 | ||||||
| 352 | ||||||
| 353 | /** | |||||
| 354 | * Sea rches its own copy o f search r esults, an d converts into exce l download file. | |||||
| 355 | * | |||||
| 356 | * @pa ram reques t | |||||
| 357 | * @pa ram respon se | |||||
| 358 | * @th rows Servl etExceptio n | |||||
| 359 | * @th rows IOExc eption | |||||
| 360 | */ | |||||
| 361 | public void expo rtToExcel( final Http ServletReq uest reque st, | |||||
| 362 | final Ht tpServletR esponse re sponse) th rows Servl etExceptio n, | |||||
| 363 | IOExcept ion { | |||||
| 364 | ||||||
| 365 | Se archResult sPackage r esults = g etResults( request); | |||||
| 366 | ||||||
| 367 | // Create a map of key which is based on t he result data key a nd the | |||||
| 368 | // heading v alue | |||||
| 369 | // The headi ng is used to create the colum n headers and the ke y is used | |||||
| 370 | // to pull t he data fr om the res ults | |||||
| 371 | fi nal Map<St ring, Stri ng> disclo sureSummar yMap = new LinkedHas hMap<Strin g, String> (); | |||||
| 372 | if ("Exchang e".equals( results.ge tSource()) ) { | |||||
| 373 | disclosu reSummaryM ap.put("pa rtnerOrg", "eHealth Exchange O rganizatio n"); | |||||
| 374 | disclosu reSummaryM ap.put("va Facility", "Patient Preferred Facility") ; | |||||
| 375 | disclosu reSummaryM ap.put("va FacilityNu mber", "Pa tient Pref erred Faci lity Stati on ID"); | |||||
| 376 | } else { | |||||
| 377 | disclosu reSummaryM ap.put("pa rtnerOrg", "Direct E ndpoint"); | |||||
| 378 | } | |||||
| 379 | di sclosureSu mmaryMap.p ut("total" , "Total") ; | |||||
| 380 | ||||||
| 381 | // Generate filters. | |||||
| 382 | fi nal Map<St ring, List <Object>> filterMap = new Link edHashMap< String, Li st<Object> >(); | |||||
| 383 | Li nkedHashMa p<String, Object> fi lters = ne w LinkedHa shMap<Stri ng, Object >(); | |||||
| 384 | ||||||
| 385 | St ring orgNa me = (Stri ng) reques t.getParam eter("orga nizationNa me"); | |||||
| 386 | if (NullChec ker.isNull OrEmpty(or gName)) { | |||||
| 387 | orgName = "ALL"; | |||||
| 388 | } | |||||
| 389 | fi nal String source = results.ge tSource(); | |||||
| 390 | fi lters.put( "Disclosur e Source", source); | |||||
| 391 | fi lters.put( "Start Dat e", reques t.getParam eter("star tDate")); | |||||
| 392 | fi lters.put( "End Date" ,request.g etParamete r("endDate ")); | |||||
| 393 | if ("exchang e".equals( source.toL owerCase() )) { | |||||
| 394 | filters. put("Patie nt Preferr ed Facilit y", ExcelE xporter.ge tPatientPr eferredFac ilityFilte r(getFacil ityDAO(), request.ge tParameter ("facility "))); | |||||
| 395 | filters. put("eHeal th Exchang e Organiza tion", org Name); | |||||
| 396 | ExcelExp orter.popu lateFilter MapForExpo rt(request , filters, filterMap , request. getParamet er("patien tTypes")); | |||||
| 397 | } else { | |||||
| 398 | ExcelExp orter.popu lateFilter MapForExpo rt(request , filters, filterMap , ""); | |||||
| 399 | } | |||||
| 400 | ||||||
| 401 | // Create th e optional data rows | |||||
| 402 | Ma p<String, List<Objec t>> option alRows = n ull; | |||||
| 403 | if ( results .getTotalC ount() > 0 ) { | |||||
| 404 | final Ob ject discl osureDocum entCount = results.g etTotalCou nt(); | |||||
| 405 | optional Rows = new LinkedHas hMap<Strin g, List<Ob ject>>(); | |||||
| 406 | final Li st<Object> disclosur eDocumentR ow = new A rrayList<O bject>(); | |||||
| 407 | if ("exc hange".equ als(source .toLowerCa se())) { | |||||
| 408 | disc losureDocu mentRow.ad d(""); | |||||
| 409 | disc losureDocu mentRow.ad d(""); | |||||
| 410 | } | |||||
| 411 | disclosu reDocument Row.add(di sclosureDo cumentCoun t); | |||||
| 412 | optional Rows.put(" Total", di sclosureDo cumentRow) ; | |||||
| 413 | } | |||||
| 414 | ||||||
| 415 | // Create th e workbook | |||||
| 416 | fi nal String title = " Disclosure s Summary Report"; | |||||
| 417 | fi nal Workbo ok wb = th is.getExce lExporter( ).exportTo Excel(titl e, title, disclosure SummaryMap , results. getSearchR esults(), filterMap, optionalR ows); | |||||
| 418 | ||||||
| 419 | // Write Exc el to Stre am | |||||
| 420 | th is.getExce lExporter( ).writeExc elToStream ("Disclosu res_Summar y_Report", wb, respo nse); | |||||
| 421 | } | |||||
| 422 | ||||||
| 423 | /** | |||||
| 424 | * Con verts Sear chResutlsP ackge to j son string Changing List<Map<S tring,Obje ct>> to a json array with each map being its own a rray. | |||||
| 425 | * Obj ect Name i s "data" A dds object "totalCou nt" for to tal number of audits . | |||||
| 426 | * | |||||
| 427 | * @pa ram search Results | |||||
| 428 | * @re turn | |||||
| 429 | */ | |||||
| 430 | privat e String e ncodeIntoJ SON(Search ResultsPac kage searc hResults) { | |||||
| 431 | St ring jsonS tring = "" ; | |||||
| 432 | ||||||
| 433 | tr y { | |||||
| 434 | StringWr iter json = new Stri ngWriter() ; | |||||
| 435 | JSONObje ct obj = n ew JSONObj ect(); | |||||
| 436 | List<Lis t> data = new ArrayL ist<List>( ); | |||||
| 437 | ||||||
| 438 | for (Map <String, O bject> row : searchR esults.get SearchResu lts()) { | |||||
| 439 | List <String> d ataItem = new ArrayL ist<String >(); | |||||
| 440 | ||||||
| 441 | for (String ke y : row.ke ySet()) { | |||||
| 442 | dataItem.a dd(row.get (key).toSt ring()); | |||||
| 443 | } | |||||
| 444 | data .add(dataI tem); | |||||
| 445 | } | |||||
| 446 | ||||||
| 447 | obj.put( "data", da ta); | |||||
| 448 | ||||||
| 449 | obj.put( "source", searchResu lts.getSou rce()); | |||||
| 450 | ||||||
| 451 | obj.writ e(json); | |||||
| 452 | ||||||
| 453 | jsonStri ng = json. toString() ; | |||||
| 454 | } catch (JSO NException ex) { | |||||
| 455 | Logger.g etLogger(P atientDisc overySumma ryReport.c lass.getNa me()).log( Level.SEVE RE, null, ex); | |||||
| 456 | } | |||||
| 457 | re turn jsonS tring; | |||||
| 458 | } | |||||
| 459 | ||||||
| 460 | /** | |||||
| 461 | * Cla ss specifi c to this report for mat, putti ng the sea rchresult list and t otal count long toge ther | |||||
| 462 | * All owing ease of parame ter passin g. | |||||
| 463 | */ | |||||
| 464 | privat e class Se archResult sPackage { | |||||
| 465 | ||||||
| 466 | pr ivate fina l List<Map <String, O bject>> se archResult s; | |||||
| 467 | pr ivate fina l long tot alCount; | |||||
| 468 | pr ivate fina l String s ource; | |||||
| 469 | ||||||
| 470 | pu blic Searc hResultsPa ckage(List <Map<Strin g, Object> > searchRe sults, lon g totalCou nt, String sourcePar am) { | |||||
| 471 | this.sea rchResults = searchR esults; | |||||
| 472 | this.tot alCount = totalCount ; | |||||
| 473 | this.sou rce = sour ceParam; | |||||
| 474 | } | |||||
| 475 | ||||||
| 476 | pu blic List< Map<String , Object>> getSearch Results() { | |||||
| 477 | return s earchResul ts; | |||||
| 478 | } | |||||
| 479 | ||||||
| 480 | pu blic long getTotalCo unt() { | |||||
| 481 | return t otalCount; | |||||
| 482 | } | |||||
| 483 | ||||||
| 484 | pu blic Strin g getSourc e() { | |||||
| 485 | return s ource; | |||||
| 486 | } | |||||
| 487 | ||||||
| 488 | } | |||||
| 489 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.