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.
| # | 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 | ReceivedNwHINDocumentSummaryReport.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 | 459 |
| 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.Str ingValuesT ype; | |||||
| 12 | import gov .va.med.nh in.adapter .audit.Sum maryFields Type; | |||||
| 13 | import gov .va.nvap.c ommon.date .Gregorian DateUtil; | |||||
| 14 | import gov .va.nvap.c ommon.sort .BubbleSor tListMap; | |||||
| 15 | import gov .va.nvap.c ommon.vali dation.Nul lChecker; | |||||
| 16 | import gov .va.nvap.p rivacy.Org anizationT ype; | |||||
| 17 | import gov .va.nvap.s ervice.ada pter.audit .AdapterAu ditManager ; | |||||
| 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.helper. document.D ocumentHel per; | |||||
| 22 | import gov .va.nvap.w eb.helper. facility.F acilityHel per; | |||||
| 23 | import gov .va.nvap.w eb.helper. privacy.Co nsentManag ementHelpe r; | |||||
| 24 | import gov .va.nvap.w eb.helper. report.Rep ortHelper; | |||||
| 25 | import gov .va.nvap.w eb.util.xl s.ExcelExp orter; | |||||
| 26 | import jav a.io.IOExc eption; | |||||
| 27 | import jav a.io.Strin gWriter; | |||||
| 28 | import jav a.util.Arr ayList; | |||||
| 29 | import jav a.util.Dat e; | |||||
| 30 | import jav a.util.Lin kedHashMap ; | |||||
| 31 | import jav a.util.Lis t; | |||||
| 32 | import jav a.util.Map ; | |||||
| 33 | import jav a.util.log ging.Level ; | |||||
| 34 | import jav a.util.log ging.Logge r; | |||||
| 35 | import jav ax.ejb.EJB ; | |||||
| 36 | import jav ax.servlet .ServletEx ception; | |||||
| 37 | import jav ax.servlet .http.Http ServletReq uest; | |||||
| 38 | import jav ax.servlet .http.Http ServletRes ponse; | |||||
| 39 | import jav ax.servlet .http.Http Session; | |||||
| 40 | import org .apache.po i.ss.userm odel.Workb ook; | |||||
| 41 | import org .json.JSON Exception; | |||||
| 42 | import org .json.JSON Object; | |||||
| 43 | ||||||
| 44 | public cla ss Receive dNwHINDocu mentSummar yReport ex tends Resp onseDispat cherHttpSe rvlet { | |||||
| 45 | ||||||
| 46 | privat e static f inal long serialVers ionUID = 3 7215033550 79491829L; | |||||
| 47 | privat e AdapterA uditManage r adapterA uditManage r; | |||||
| 48 | ||||||
| 49 | @O verride | |||||
| 50 | pr otected vo id unspeci fied(final HttpServl etRequest request, | |||||
| 51 | final HttpServle tResponse response) throws Ser vletExcept ion, | |||||
| 52 | IOExce ption { | |||||
| 53 | fina l HttpSess ion sessio n = reques t.getSessi on(false); | |||||
| 54 | sess ion.remove Attribute( "results") ; | |||||
| 55 | Re portHelper .setDefaul tSearchDat es(session ); | |||||
| 56 | requ est.setAtt ribute("fa cilities", this.getF acilityHel per().getA llVistAFac ilities()) ; | |||||
| 57 | th is.getRepo rtHelper() .getReceiv edDocsOrgL ists(reque st); | |||||
| 58 | ||||||
| 59 | this .forward(r equest, re sponse, "s how"); | |||||
| 60 | } | |||||
| 61 | ||||||
| 62 | @EJB(b eanInterfa ce = Adapt erAuditMan ager.class , mappedNa me = "Adap terAuditMa nager") | |||||
| 63 | pu blic void setAdapter AuditManag er( | |||||
| 64 | final AdapterAud itManager adapterAud itManager) { | |||||
| 65 | this .adapterAu ditManager = adapter AuditManag er; | |||||
| 66 | } | |||||
| 67 | ||||||
| 68 | /** | |||||
| 69 | * Get the c onsent man agement he lper from Spring. | |||||
| 70 | * / | |||||
| 71 | pu blic Conse ntManageme ntHelper g etCmsHelpe r() { | |||||
| 72 | fina l ConsentM anagementH elper cmsH elper = th is.getBean ("cmsHelpe r", | |||||
| 73 | ConsentM anagementH elper.clas s); | |||||
| 74 | retu rn cmsHelp er; | |||||
| 75 | } | |||||
| 76 | ||||||
| 77 | /* * | |||||
| 78 | * Get the d ocument he lper from Spring. | |||||
| 79 | * / | |||||
| 80 | pu blic Docum entHelper getDocumen tHelper() { | |||||
| 81 | retu rn this.ge tBean("ada pterDocume ntHelper", DocumentH elper.clas s); | |||||
| 82 | } | |||||
| 83 | ||||||
| 84 | /* * | |||||
| 85 | * Get the e xcel expor ter class from Sprin g. | |||||
| 86 | * | |||||
| 87 | * @return t he excel e xporter ob ject | |||||
| 88 | * / | |||||
| 89 | pu blic Excel Exporter g etExcelExp orter() { | |||||
| 90 | fina l ExcelExp orter exce lExporter = this.get Bean("exce lExporter" , | |||||
| 91 | ExcelExp orter.clas s); | |||||
| 92 | retu rn excelEx porter; | |||||
| 93 | } | |||||
| 94 | ||||||
| 95 | /* * | |||||
| 96 | * Get the f acility he lper from Spring. | |||||
| 97 | * / | |||||
| 98 | pu blic Facil ityHelper getFacilit yHelper() { | |||||
| 99 | retu rn this.ge tBean("fac ilityHelpe r", Facili tyHelper.c lass); | |||||
| 100 | } | |||||
| 101 | ||||||
| 102 | pu blic Repor tHelper ge tReportHel per() { | |||||
| 103 | fina l ReportHe lper repor tHelper = this.getBe an("report Helper", | |||||
| 104 | ReportHe lper.class ); | |||||
| 105 | retu rn reportH elper; | |||||
| 106 | } | |||||
| 107 | ||||||
| 108 | privat e Facility DAO getFac ilityDAO() { | |||||
| 109 | re turn this. getBean("F acilityDAO ", Facilit yDAO.class ); | |||||
| 110 | } | |||||
| 111 | ||||||
| 112 | ||||||
| 113 | public void doSe arch(final HttpServl etRequest request, | |||||
| 114 | final HttpServle tResponse response) throws IOE xception, ServletExc eption{ | |||||
| 115 | fi nal HttpSe ssion sess ion = requ est.getSes sion(false ); | |||||
| 116 | ||||||
| 117 | se ssion.setA ttribute(" results", encodeInto JSON(getRe sults(requ est, false ))); | |||||
| 118 | ||||||
| 119 | th is.forward (request, response, "searchRes ultsJSON") ; | |||||
| 120 | ||||||
| 121 | } | |||||
| 122 | ||||||
| 123 | /** | |||||
| 124 | * Ret urns searc h results of request parameter or defaul t values i f blank. F or excel c alls adds oid value to result map to be output on | |||||
| 125 | * exc el downloa d | |||||
| 126 | * @pa ram reques t | |||||
| 127 | * @pa ram called ForExcel | |||||
| 128 | * @re turn | |||||
| 129 | * @th rows Audit Exception | |||||
| 130 | */ | |||||
| 131 | privat e SearchRe sultsPacka ge getResu lts(final HttpServle tRequest r equest, Bo olean call edForExcel ) throws A uditExcept ion { | |||||
| 132 | ||||||
| 133 | // p repare aud it summary and retri eve web se rvices res ponse | |||||
| 134 | GetA uditsSumma ryResponse getAudits SummaryRes ponse = pr epareAudit Summary(re quest); | |||||
| 135 | ||||||
| 136 | fina l List<Map <String, O bject>> re sults = ne w ArrayLis t<Map<Stri ng, Object >>(); | |||||
| 137 | long totalCoun t = 0l; | |||||
| 138 | fina l AuditSum mariesType auditSumm ariesType = getAudit sSummaryRe sponse | |||||
| 139 | .getAudi tSummaries (); | |||||
| 140 | ||||||
| 141 | Li st<AuditSu mmaryType> auditSumm ary = new ArrayList< AuditSumma ryType>(); | |||||
| 142 | if ( auditSumma riesType ! = null) { | |||||
| 143 | auditS ummary = a uditSummar iesType.ge tAuditSumm ary(); | |||||
| 144 | } | |||||
| 145 | for (final Aud itSummaryT ype auditS ummaryType 2 : auditS ummary) { | |||||
| 146 | final AuditSumma ryType aud itSummaryT ype = audi tSummaryTy pe2; | |||||
| 147 | ||||||
| 148 | final Map<String , Object> resultMap = new Link edHashMap< String, Ob ject>(); | |||||
| 149 | final long count = auditSu mmaryType. getCount() ; | |||||
| 150 | final SummaryFie ldsType su mmaryField s = auditS ummaryType | |||||
| 151 | .getSummar yFields(); | |||||
| 152 | final List<Strin g> summary Field = su mmaryField s.getSumma ryField(); | |||||
| 153 | ||||||
| 154 | if (Nu llChecker. isEmpty(su mmaryField )) { | |||||
| 155 | continue ; | |||||
| 156 | } | |||||
| 157 | ||||||
| 158 | if (su mmaryField .size() < 4) { | |||||
| 159 | continue ; | |||||
| 160 | } | |||||
| 161 | ||||||
| 162 | Organi zationType organizat ionType = null; | |||||
| 163 | if (Nu llChecker. isNotEmpty (summaryFi eld.get(0) )) { | |||||
| 164 | organiza tionType = (this.get CmsHelper( ) | |||||
| 165 | .g etOrganiza tionByHome CommunityI d(summaryF ield.get(0 ) | |||||
| 166 | .repla ce("urn:oi d:", ""))) ; | |||||
| 167 | ||||||
| 168 | //ad ds oid to result map to be add ed to exce l export, not includ ed in web output | |||||
| 169 | if(c alledForEx cel){ | |||||
| 170 | if (!NullC hecker.isN ullOrEmpty (organizat ionType)) { | |||||
| 171 | resultMap. put("oid", ReportDat aProcessor .nullEmpty ReplaceWit hUnknown(o rganizatio nType.getO rgOid())); | |||||
| 172 | } else { | |||||
| 173 | result Map.put("o id", "Unkn own"); | |||||
| 174 | } | |||||
| 175 | } | |||||
| 176 | } | |||||
| 177 | ||||||
| 178 | if (!N ullChecker .isNullOrE mpty(organ izationTyp e)) { | |||||
| 179 | resultMa p.put("par tnerOrg", ReportData Processor | |||||
| 180 | .n ullEmptyRe placeWithU nknown(org anizationT ype | |||||
| 181 | .getOr gName())); | |||||
| 182 | } else { | |||||
| 183 | resultMa p.put("par tnerOrg", ReportData Processor | |||||
| 184 | .n ullEmptyRe placeWithU nknown(sum maryField. get(3))); | |||||
| 185 | } | |||||
| 186 | // Ext ract value | |||||
| 187 | final String ada pterVAFaci lity = sum maryField. get(1); | |||||
| 188 | ||||||
| 189 | String vaFacilit y = ""; | |||||
| 190 | if (Re portDataPr ocessor.is ValidStati on(adapter VAFacility )) { | |||||
| 191 | vaFacili ty = this. getFacilit yHelper() | |||||
| 192 | .g etFacility NameByStat ionId(adap terVAFacil ity); | |||||
| 193 | if (Null Checker.is Empty(vaFa cility)) { | |||||
| 194 | vaFacility = summary Field.get( 2); | |||||
| 195 | } | |||||
| 196 | } else { | |||||
| 197 | vaFacili ty = summa ryField.ge t(2); | |||||
| 198 | } | |||||
| 199 | result Map.put("v aFacility" , | |||||
| 200 | ReportData Processor. fixStation (vaFacilit y)); | |||||
| 201 | if (!Nul lChecker.i sNullOrEmp ty(adapter VAFacility )) { | |||||
| 202 | resu ltMap.put( "vaFacilit yNumber", ReportData Processor | |||||
| 203 | .nullE mptyReplac eWithUnkno wn(adapter VAFacility )); | |||||
| 204 | } | |||||
| 205 | ||||||
| 206 | result Map.put("t otal", cou nt); | |||||
| 207 | result s.add(resu ltMap); | |||||
| 208 | totalC ount += co unt; | |||||
| 209 | ||||||
| 210 | } | |||||
| 211 | // sort resul t list and combine i nto transp ort packag e | |||||
| 212 | Se archResult sPackage p ackagedRes ults = new SearchRes ultsPackag e( sortRes ults(resul ts,request ), totalCo unt); | |||||
| 213 | ||||||
| 214 | retu rn package dResults; | |||||
| 215 | } | |||||
| 216 | ||||||
| 217 | /** | |||||
| 218 | * Sor t data usi ng table s pecific co lumns | |||||
| 219 | * @pa ram unSort edData | |||||
| 220 | * @pa ram reques t | |||||
| 221 | * @re turn | |||||
| 222 | */ | |||||
| 223 | privat e List<Map <String,Ob ject>> sor tResults(L ist<Map<St ring,Objec t>> unSort edData, Ht tpServletR equest req uest){ | |||||
| 224 | fi nal Bubble SortListMa p bSorter = new Bubb leSortList Map(); | |||||
| 225 | 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]" ); | |||||
| 226 | fi nal boolea n sortAsce nding = re quest.getP arameter(" order[0][d ir]") == n ull ? !"de sc".equals IgnoreCase (request.g etParamete r("sortOrd er")) : | |||||
| 227 | !"desc ".equalsIg noreCase(r equest.get Parameter( "order[0][ dir]")); | |||||
| 228 | ||||||
| 229 | ||||||
| 230 | if ("0".equal s(sortValu e)){ | |||||
| 231 | sortValu e = "partn erOrg"; | |||||
| 232 | } else if (" 1".equals( sortValue) ){ | |||||
| 233 | sortValu e = "vaFac ility"; | |||||
| 234 | } else if (" 2".equals( sortValue) ){ | |||||
| 235 | sortValu e = "vaFac ilityNumbe r"; | |||||
| 236 | } else if (" 3".equals( sortValue) ){ | |||||
| 237 | sortValu e = "total "; | |||||
| 238 | } else { | |||||
| 239 | sortValu e = "partn erOrg"; | |||||
| 240 | } | |||||
| 241 | re turn bSort er.sortByC olumn(unSo rtedData,s ortValue, sortAscend ing); | |||||
| 242 | } | |||||
| 243 | ||||||
| 244 | ||||||
| 245 | /** | |||||
| 246 | * Add s all requ est parame ters to Au ditSummary and calls for respo nse | |||||
| 247 | * @pa ram reques t | |||||
| 248 | * @re turn | |||||
| 249 | * @th rows Audit Exception | |||||
| 250 | */ | |||||
| 251 | privat e GetAudit sSummaryRe sponse pre pareAuditS ummary(fin al HttpSer vletReques t request) throws Au ditExcepti on{ | |||||
| 252 | ||||||
| 253 | fina l Date sd = ReportHe lper.getSt artDate(re quest.getP arameter(" startDate" )); | |||||
| 254 | fina l Date ed = ReportHe lper.getEn dDate(requ est.getPar ameter("en dDate")); | |||||
| 255 | fi nal String userId = request.ge tParameter ("userId") ; | |||||
| 256 | ||||||
| 257 | fi nal int pa tientTypes = (reques t.getParam eter("pati entTypes") != null) | |||||
| 258 | ? In teger.pars eInt(reque st.getPara meter("pat ientTypes" )) : 1; | |||||
| 259 | ||||||
| 260 | fi nal String externalP artnerOrg = (request .getParame ter("organ ization") != null) | |||||
| 261 | ? reques t.getParam eter("orga nization") : ""; | |||||
| 262 | ||||||
| 263 | fi nal String patientFa cility = ( request.ge tParameter ("facility ") != null ) | |||||
| 264 | ? reques t.getParam eter("faci lity") : " "; | |||||
| 265 | ||||||
| 266 | fina l GetAudit sSummary g etAuditsSu mmary = ne w GetAudit sSummary() ; | |||||
| 267 | ||||||
| 268 | // s tart time | |||||
| 269 | if ( NullChecke r.isNotEmp ty(sd)) { | |||||
| 270 | getAud itsSummary .setFromDa te(Gregori anDateUtil | |||||
| 271 | .getGregor ianCalenda rByDate(sd )); | |||||
| 272 | } | |||||
| 273 | // t o time | |||||
| 274 | if ( NullChecke r.isNotEmp ty(ed)) { | |||||
| 275 | getAud itsSummary .setToDate (Gregorian DateUtil | |||||
| 276 | .getGregor ianCalenda rByDate(ed )); | |||||
| 277 | } | |||||
| 278 | // Set User I D | |||||
| 279 | if (NullChec ker.isNotE mpty(userI d)) { | |||||
| 280 | final St ringValues Type userI dValue = n ew StringV aluesType( ); | |||||
| 281 | userIdVa lue.getVal ue().add(u serId); | |||||
| 282 | userIdVa lue.setNot In(false); | |||||
| 283 | getAudit sSummary.s etUserIds( userIdValu e); | |||||
| 284 | } | |||||
| 285 | fina l ActionVa luesType a ctionValue sType = ne w ActionVa luesType() ; | |||||
| 286 | fina l List<Act ionType> a ctiontype = actionVa luesType.g etValue(); | |||||
| 287 | acti ontype.add (ActionTyp e.RETRIEVE _DOCUMENT_ OUT); | |||||
| 288 | acti onValuesTy pe.setNotI n(false); | |||||
| 289 | getA uditsSumma ry.setActi ons(action ValuesType ); | |||||
| 290 | getA uditsSumma ry.setPati entTypes(p atientType s); | |||||
| 291 | ||||||
| 292 | ||||||
| 293 | // p atient pre ferred fac ility | |||||
| 294 | if ( !NullCheck er.isNullO rEmpty(pat ientFacili ty)) { | |||||
| 295 | ||||||
| 296 | final StringValu esType pat ientFacily Number = n ew StringV aluesType( ); | |||||
| 297 | patien tFacilyNum ber.setNot In(false); | |||||
| 298 | final List<Strin g> patient FacilyNumb erList = p atientFaci lyNumber | |||||
| 299 | .getValue( ); | |||||
| 300 | patien tFacilyNum berList.ad d(patientF acility); | |||||
| 301 | getAud itsSummary .setPatien tFacilityN umbers(pat ientFacily Number); | |||||
| 302 | } | |||||
| 303 | ||||||
| 304 | if ( !NullCheck er.isNullO rEmpty(ext ernalPartn erOrg) | |||||
| 305 | && !exte rnalPartne rOrg.equal s("externa l")) { | |||||
| 306 | final StringValu esType rem oteOrganiz ationIds = new Strin gValuesTyp e(); | |||||
| 307 | remote Organizati onIds.setN otIn(false ); | |||||
| 308 | final List<Strin g> remoteO rganizatio nIdsList = remoteOrg anizationI ds | |||||
| 309 | .getValue( ); | |||||
| 310 | remote Organizati onIdsList. add(extern alPartnerO rg.replace ("%", | |||||
| 311 | "urn:oid:" )); | |||||
| 312 | getAud itsSummary .setRemote Organizati onIds(remo teOrganiza tionIds); | |||||
| 313 | } | |||||
| 314 | ||||||
| 315 | // g roup by | |||||
| 316 | fina l GroupByF ieldsType groupByFie ldsType = new GroupB yFieldsTyp e(); | |||||
| 317 | fina l List<Fie ldType> fi eldTypeLis t = groupB yFieldsTyp e | |||||
| 318 | .getGrou pByField() ; | |||||
| 319 | fiel dTypeList. add(FieldT ype.REMOTE _ORGANIZAT ION_ID); | |||||
| 320 | fiel dTypeList. add(FieldT ype.PATIEN T_FACILITY _NUMBER); | |||||
| 321 | fiel dTypeList. add(FieldT ype.PATIEN T_FACILITY _NAME); | |||||
| 322 | fiel dTypeList. add(FieldT ype.REMOTE _ORGANIZAT ION_NAME); | |||||
| 323 | getA uditsSumma ry.setGrou pByFields( groupByFie ldsType); | |||||
| 324 | ||||||
| 325 | // w eb service s response | |||||
| 326 | GetA uditsSumma ryResponse getAudits SummaryRes ponse; | |||||
| 327 | try { | |||||
| 328 | getAud itsSummary Response = this.adap terAuditMa nager | |||||
| 329 | .getAuditS ummary(get AuditsSumm ary); | |||||
| 330 | ||||||
| 331 | return g etAuditsSu mmaryRespo nse; | |||||
| 332 | ||||||
| 333 | } catch (fin al AuditEx ception e) { | |||||
| 334 | throw new AuditE xception() ; | |||||
| 335 | } | |||||
| 336 | } | |||||
| 337 | ||||||
| 338 | /** | |||||
| 339 | * 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. | |||||
| 340 | * Obj ect Name i s "data" | |||||
| 341 | * | |||||
| 342 | * @pa ram search Results | |||||
| 343 | * @re turn | |||||
| 344 | */ | |||||
| 345 | privat e String e ncodeIntoJ SON(Search ResultsPac kage searc hResults) { | |||||
| 346 | St ring jsonS tring = "" ; | |||||
| 347 | ||||||
| 348 | tr y { | |||||
| 349 | StringWr iter json = new Stri ngWriter() ; | |||||
| 350 | JSONObje ct obj = n ew JSONObj ect(); | |||||
| 351 | List<Lis t> data = new ArrayL ist<List>( ); | |||||
| 352 | ||||||
| 353 | if(searc hResults.g etSearchRe sults() != null){ | |||||
| 354 | for (Map<Strin g, Object> row : sea rchResults .getSearch Results()) { | |||||
| 355 | List<Strin g> dataIte m = new Ar rayList<St ring>(); | |||||
| 356 | ||||||
| 357 | for (Strin g key : ro w.keySet() ) { | |||||
| 358 | dataIt em.add(row .get(key). toString() ); | |||||
| 359 | } | |||||
| 360 | data.add(d ataItem); | |||||
| 361 | } | |||||
| 362 | } | |||||
| 363 | obj.put( "data", da ta); | |||||
| 364 | ||||||
| 365 | obj.writ e(json); | |||||
| 366 | ||||||
| 367 | jsonStri ng = json. toString() ; | |||||
| 368 | } catch (JSO NException ex) { | |||||
| 369 | Logger.g etLogger(R eceivedNwH INDocument SummaryRep ort.class. getName()) .log(Level .SEVERE, n ull, ex); | |||||
| 370 | } | |||||
| 371 | re turn jsonS tring; | |||||
| 372 | } | |||||
| 373 | ||||||
| 374 | /** | |||||
| 375 | * 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 | |||||
| 376 | * Res ponseDispa tcherHttpS ervlet to call this method bas ed on the http param eters. | |||||
| 377 | * | |||||
| 378 | * @pa ram reques t HTTP Req uest | |||||
| 379 | * @pa ram respon se HTTP Re sponse | |||||
| 380 | * @th rows Servl etExceptio n | |||||
| 381 | * @th rows IOExc eption | |||||
| 382 | */ | |||||
| 383 | public void expo rtToExcel( final Http ServletReq uest reque st, | |||||
| 384 | fi nal HttpSe rvletRespo nse respon se) throws ServletEx ception, | |||||
| 385 | IO Exception { | |||||
| 386 | ||||||
| 387 | // results) | |||||
| 388 | Se archResult sPackage p ackagedRes ults = get Results(re quest, tru e); | |||||
| 389 | fi nal List<M ap<String, Object>> results = packagedRe sults.getS earchResul ts(); | |||||
| 390 | ||||||
| 391 | // Create a map of key which is based on t he result data key a nd the | |||||
| 392 | // heading v alue | |||||
| 393 | fi nal Map<St ring, Stri ng> receiv edNwhinDoc umentMap = new Linke dHashMap<S tring, Str ing>(); | |||||
| 394 | ||||||
| 395 | // Generate filters. | |||||
| 396 | fi nal Map<St ring, List <Object>> filterMap = new Link edHashMap< String, Li st<Object> >(); | |||||
| 397 | fi nal Linked HashMap<St ring, Obje ct> filter s = new Li nkedHashMa p<String, Object>(); | |||||
| 398 | ||||||
| 399 | fi lters.put( "Start Dat e", this.g etReportHe lper().get FormattedD ate(Report Helper.get StartDate( request.ge tParameter ("startDat e")))); | |||||
| 400 | fi lters.put( "End Date" , this.get ReportHelp er().getFo rmattedDat e(ReportHe lper.getSt artDate(re quest.getP arameter(" endDate")) )); | |||||
| 401 | fi lters.put( "User ID", request.g etParamete r("userId" )); | |||||
| 402 | fi lters.put( "Patient P referred F acility", ExcelExpor ter.getPat ientPrefer redFacilit yFilter(ge tFacilityD AO(), requ est.getPar ameter("fa cility"))) ; | |||||
| 403 | fi lters.put( "eHealth E xchange Or ganization ", ExcelEx porter.get FilterValu e(request. getParamet er("organi zationName "))); | |||||
| 404 | Ex celExporte r.populate FilterMapF orExport(r equest, fi lters, fil terMap, re quest.getP arameter(" patientTyp es")); | |||||
| 405 | ||||||
| 406 | fi nal Object receivedN whinDocume ntCount = packagedRe sults.getT otalCount( ); | |||||
| 407 | fi nal Map<St ring, List <Object>> optionalRo ws = new L inkedHashM ap<String, List<Obje ct>>(); | |||||
| 408 | fi nal List<O bject> rec eivedNwhin DocumentRo w = new Ar rayList<Ob ject>(); | |||||
| 409 | re ceivedNwhi nDocumentR ow.add("") ; | |||||
| 410 | re ceivedNwhi nDocumentR ow.add("") ; | |||||
| 411 | re ceivedNwhi nDocumentR ow.add("") ; | |||||
| 412 | re ceivedNwhi nDocumentR ow.add(rec eivedNwhin DocumentCo unt); | |||||
| 413 | op tionalRows .put("Tota l", receiv edNwhinDoc umentRow); | |||||
| 414 | // Create th e options selected l ist | |||||
| 415 | ||||||
| 416 | if (NullChec ker.isNull OrEmpty(re sults)) { | |||||
| 417 | received NwhinDocum entMap.put ("", "No r ecords wer e found.") ; | |||||
| 418 | } else { | |||||
| 419 | // The h eading is used to cr eate the c olumn head ers and th e key is u sed | |||||
| 420 | // to pu ll the dat a from the results | |||||
| 421 | received NwhinDocum entMap.put ("partnerO rg", "eHea lth Exchan ge Organiz ation"); | |||||
| 422 | received NwhinDocum entMap.put ("vaFacili ty", "Pati ent Prefer red Facili ty"); | |||||
| 423 | received NwhinDocum entMap.put ("vaFacili tyNumber", "Patient Preferred Facility S tation ID" ); | |||||
| 424 | received NwhinDocum entMap.put ("oid", "O ID"); | |||||
| 425 | received NwhinDocum entMap.put ("total", "Total"); | |||||
| 426 | } | |||||
| 427 | ||||||
| 428 | // Create wo rkbook | |||||
| 429 | fi nal String title = " Received e Health Exc hange Docu ments Summ ary Report "; | |||||
| 430 | fi nal Workbo ok wb = th is.getExce lExporter( ).exportTo Excel(titl e, title, receivedNw hinDocumen tMap, resu lts, filte rMap, opti onalRows); | |||||
| 431 | ||||||
| 432 | // Write Exc el to Stre am | |||||
| 433 | th is.getExce lExporter( ).writeExc elToStream ("Received _eHealth_E xchange_Do cuments_Su mmary_Repo rt", wb, r esponse); | |||||
| 434 | } | |||||
| 435 | ||||||
| 436 | /** | |||||
| 437 | * Cla ss specifi c to this report for mat, putti ng the sea rchresult list and t otal count long toge ther | |||||
| 438 | * All owing ease of parame ter passin g. | |||||
| 439 | */ | |||||
| 440 | privat e class Se archResult sPackage { | |||||
| 441 | ||||||
| 442 | pr ivate Lis t<Map<Stri ng, Object >> searchR esults = n ew ArrayLi st<>(); | |||||
| 443 | pr ivate fina l long to talCount; | |||||
| 444 | ||||||
| 445 | pu blic Searc hResultsPa ckage(List <Map<Strin g, Object> > searchRe sults, lon g totalCou nt) { | |||||
| 446 | this.sea rchResults = searchR esults; | |||||
| 447 | this.tot alCount = totalCount ; | |||||
| 448 | } | |||||
| 449 | ||||||
| 450 | pu blic List< Map<String , Object>> getSearch Results() { | |||||
| 451 | return s earchResul ts; | |||||
| 452 | } | |||||
| 453 | ||||||
| 454 | pu blic long getTotalCo unt() { | |||||
| 455 | return t otalCount; | |||||
| 456 | } | |||||
| 457 | } | |||||
| 458 | ||||||
| 459 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.