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 | PatientDiscoverySummaryReport.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 | 441 |
| 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. facility.F acilityHel per; | |||||
| 22 | import gov .va.nvap.w eb.helper. privacy.Co nsentManag ementHelpe r; | |||||
| 23 | import gov .va.nvap.w eb.helper. report.Rep ortHelper; | |||||
| 24 | import gov .va.nvap.w eb.util.xl s.ExcelExp orter; | |||||
| 25 | ||||||
| 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 | ||||||
| 37 | import jav ax.servlet .ServletEx ception; | |||||
| 38 | import jav ax.servlet .http.Http ServletReq uest; | |||||
| 39 | import jav ax.servlet .http.Http ServletRes ponse; | |||||
| 40 | import jav ax.servlet .http.Http Session; | |||||
| 41 | import org .apache.co mmons.lang .StringUti ls; | |||||
| 42 | import org .apache.po i.ss.userm odel.Workb ook; | |||||
| 43 | import org .json.JSON Exception; | |||||
| 44 | import org .json.JSON Object; | |||||
| 45 | ||||||
| 46 | /** | |||||
| 47 | * This cl ass handle s the sear ch page fo r Patient Discovery Summary re port. | |||||
| 48 | * | |||||
| 49 | * @author Irakli Ka kushadze, updated by Raul Alfa ro | |||||
| 50 | */ | |||||
| 51 | public cla ss Patient DiscoveryS ummaryRepo rt extends ResponseD ispatcherH ttpServlet { | |||||
| 52 | ||||||
| 53 | /* * | |||||
| 54 | * Serial UI D. | |||||
| 55 | * / | |||||
| 56 | pr ivate stat ic final l ong serial VersionUID = 1L; | |||||
| 57 | ||||||
| 58 | privat e AdapterA uditManage r adapterA uditManage r; | |||||
| 59 | ||||||
| 60 | @EJB(b eanInterfa ce = Adapt erAuditMan ager.class , mappedNa me = "Adap terAuditMa nager") | |||||
| 61 | public void setA dapterAudi tManager(f inal Adapt erAuditMan ager adapt erAuditMan ager) { | |||||
| 62 | th is.adapter AuditManag er = adapt erAuditMan ager; | |||||
| 63 | } | |||||
| 64 | ||||||
| 65 | /** | |||||
| 66 | * Get the conse nt managem ent helper from Spri ng. | |||||
| 67 | * @re turn Conse ntManageme ntHelper C onsent man agement he lper | |||||
| 68 | */ | |||||
| 69 | pu blic Conse ntManageme ntHelper g etCmsHelpe r() { | |||||
| 70 | retu rn this.ge tBean("cms Helper", C onsentMana gementHelp er.class); | |||||
| 71 | } | |||||
| 72 | ||||||
| 73 | /** | |||||
| 74 | * Get the facil ity helper from Spri ng. | |||||
| 75 | * @re turn Facil ityHelper helper | |||||
| 76 | */ | |||||
| 77 | pu blic Facil ityHelper getFacilit yHelper() { | |||||
| 78 | retu rn this.ge tBean("fac ilityHelpe r", Facili tyHelper.c lass); | |||||
| 79 | } | |||||
| 80 | ||||||
| 81 | privat e ReportHe lper getRe portHelper () { | |||||
| 82 | re turn this. getBean("r eportHelpe r", Report Helper.cla ss); | |||||
| 83 | } | |||||
| 84 | ||||||
| 85 | @Overr ide | |||||
| 86 | protec ted void u nspecified (final Htt pServletRe quest requ est, | |||||
| 87 | fi nal HttpSe rvletRespo nse respon se) throws ServletEx ception, | |||||
| 88 | IO Exception { | |||||
| 89 | ||||||
| 90 | Ht tpSession session = request.ge tSession(f alse); | |||||
| 91 | Re portHelper .setDefaul tSearchDat es(session ); | |||||
| 92 | re quest.setA ttribute(" facilities ", this.ge tFacilityH elper().ge tAllVistAF acilities( )); | |||||
| 93 | th is.getRepo rtHelper() .getOrgLis ts(request , this.get CmsHelper( )); | |||||
| 94 | ||||||
| 95 | th is.forward (request, response, "show"); | |||||
| 96 | } | |||||
| 97 | ||||||
| 98 | /** | |||||
| 99 | * | |||||
| 100 | * @pa ram reques t | |||||
| 101 | * @pa ram respon se | |||||
| 102 | * @th rows Servl etExceptio n | |||||
| 103 | * @th rows IOExc eption | |||||
| 104 | */ | |||||
| 105 | public void doSe arch(final HttpServl etRequest request, f inal HttpS ervletResp onse respo nse) throw s ServletE xception, IOExceptio n { | |||||
| 106 | fi nal HttpSe ssion sess ion = requ est.getSes sion(false ); | |||||
| 107 | ||||||
| 108 | se ssion.setA ttribute(" results", encodeInto JSON(getRe sults(requ est))); | |||||
| 109 | ||||||
| 110 | th is.forward (request, response, "searchRes ultsJSON") ; | |||||
| 111 | } | |||||
| 112 | ||||||
| 113 | /** | |||||
| 114 | * Ret urns searc h results and audit total pack aged toget her in a c lass | |||||
| 115 | * | |||||
| 116 | * @pa ram reques t | |||||
| 117 | * @re turn Searc hResultsPa ckage | |||||
| 118 | * @th rows Audit Exception | |||||
| 119 | */ | |||||
| 120 | privat e SearchRe sultsPacka ge getResu lts(final HttpServle tRequest r equest) th rows Audit Exception { | |||||
| 121 | ||||||
| 122 | fi nal Date s d = Report Helper.get StartDate( request.ge tParameter ("startDat e")); | |||||
| 123 | fi nal Date e d = Report Helper.get EndDate(re quest.getP arameter(" endDate")) ; | |||||
| 124 | fi nal String userId = request.ge tParameter ("userId") ; | |||||
| 125 | fi nal String organizat ion = (req uest.getPa rameter("o rganizatio n") != nul l) | |||||
| 126 | ? reques t.getParam eter("orga nization") : ""; | |||||
| 127 | fi nal String patientFa cility = ( request.ge tParameter ("facility ") != null ) | |||||
| 128 | ? reques t.getParam eter("faci lity") : " "; | |||||
| 129 | fi nal int pa tientTypes = (reques t.getParam eter("pati entTypes") != null) | |||||
| 130 | ? Intege r.parseInt (request.g etParamete r("patient Types")) : 1; | |||||
| 131 | ||||||
| 132 | fi nal GetAud itsSummary getAudits SummaryReq uest = new GetAudits Summary(); | |||||
| 133 | ||||||
| 134 | // Set start date | |||||
| 135 | if (NullChec ker.isNotE mpty(sd)) { | |||||
| 136 | getAudit sSummaryRe quest.setF romDate(Gr egorianDat eUtil.getG regorianCa lendarByDa te(sd)); | |||||
| 137 | } | |||||
| 138 | ||||||
| 139 | // Set end d ate | |||||
| 140 | if (NullChec ker.isNotE mpty(ed)) { | |||||
| 141 | getAudit sSummaryRe quest.setT oDate(Greg orianDateU til.getGre gorianCale ndarByDate (ed)); | |||||
| 142 | } | |||||
| 143 | ||||||
| 144 | // Set user ID | |||||
| 145 | if (NullChec ker.isNotE mpty(userI d)) { | |||||
| 146 | final St ringValues Type userI dValue = n ew StringV aluesType( ); | |||||
| 147 | userIdVa lue.getVal ue().add(u serId); | |||||
| 148 | userIdVa lue.setNot In(false); | |||||
| 149 | getAudit sSummaryRe quest.setU serIds(use rIdValue); | |||||
| 150 | } | |||||
| 151 | ||||||
| 152 | // Set patie nt preferr ed facilit y | |||||
| 153 | if (!NullChe cker.isNul lOrEmpty(p atientFaci lity)) { | |||||
| 154 | final St ringValues Type patie ntFacilyNu mber = new StringVal uesType(); | |||||
| 155 | patientF acilyNumbe r.setNotIn (false); | |||||
| 156 | final Li st<String> patientFa cilyNumber List = pat ientFacily Number.get Value(); | |||||
| 157 | patientF acilyNumbe rList.add( patientFac ility); | |||||
| 158 | getAudit sSummaryRe quest.setP atientFaci lityNumber s(patientF acilyNumbe r); | |||||
| 159 | } | |||||
| 160 | ||||||
| 161 | // Set partn er organiz ation | |||||
| 162 | fi nal String ValuesType orgTypes = new Stri ngValuesTy pe(); | |||||
| 163 | if (NullChec ker.isNotE mpty(organ ization)) { | |||||
| 164 | orgTypes .getValue( ).add(orga nization); | |||||
| 165 | } | |||||
| 166 | or gTypes.set NotIn(fals e); | |||||
| 167 | ge tAuditsSum maryReques t.setRemot eOrganizat ionIds(org Types); | |||||
| 168 | ge tAuditsSum maryReques t.setOrgan izationIds (orgTypes) ; | |||||
| 169 | ||||||
| 170 | // Set patie nt types | |||||
| 171 | ge tAuditsSum maryReques t.setPatie ntTypes(pa tientTypes ); | |||||
| 172 | ||||||
| 173 | // Set actio in types | |||||
| 174 | fi nal Action ValuesType actionsTy pe = new A ctionValue sType(); | |||||
| 175 | ac tionsType. getValue() .add(Actio nType.ANNO UNCE); | |||||
| 176 | ac tionsType. getValue() .add(Actio nType.CHEC K_POLICY); | |||||
| 177 | ac tionsType. getValue() .add(Actio nType.MPI_ FIND_MATCH ); | |||||
| 178 | ac tionsType. getValue() .add(Actio nType.ADD_ PATIENT_CO RRELATION) ; | |||||
| 179 | ac tionsType. setNotIn(f alse); | |||||
| 180 | ge tAuditsSum maryReques t.setActio ns(actions Type); | |||||
| 181 | ||||||
| 182 | // Group by | |||||
| 183 | fi nal GroupB yFieldsTyp e groupByF ieldsType = new Grou pByFieldsT ype(); | |||||
| 184 | fi nal List<F ieldType> fieldTypeL ist = grou pByFieldsT ype.getGro upByField( ); | |||||
| 185 | fi eldTypeLis t.add(Fiel dType.REMO TE_ORGANIZ ATION_ID); | |||||
| 186 | fi eldTypeLis t.add(Fiel dType.PATI ENT_FACILI TY_NUMBER) ; | |||||
| 187 | fi eldTypeLis t.add(Fiel dType.PATI ENT_FACILI TY_NAME); | |||||
| 188 | fi eldTypeLis t.add(Fiel dType.REMO TE_ORGANIZ ATION_NAME ); | |||||
| 189 | ge tAuditsSum maryReques t.setGroup ByFields(g roupByFiel dsType); | |||||
| 190 | ||||||
| 191 | Se archResult sPackage p ackagedRes ults; | |||||
| 192 | Li st<Map<Str ing, Objec t>> result s = new Ar rayList<Ma p<String, Object>>() ; | |||||
| 193 | ||||||
| 194 | lo ng totalCo unt = 0l; | |||||
| 195 | tr y { | |||||
| 196 | // Get s ummary lis t from Exc hange | |||||
| 197 | GetAudit sSummaryRe sponse get AuditsSumm aryRespons e = this.a dapterAudi tManager.g etAuditSum mary(getAu ditsSummar yRequest); | |||||
| 198 | ||||||
| 199 | // Const ruct resul ts for the jsp page | |||||
| 200 | final Au ditSummari esType aud itSummarie sType = ge tAuditsSum maryRespon se.getAudi tSummaries (); | |||||
| 201 | ||||||
| 202 | List<Aud itSummaryT ype> audit Summary = new ArrayL ist<AuditS ummaryType >(); | |||||
| 203 | if (audi tSummaries Type != nu ll) { | |||||
| 204 | audi tSummary = auditSumm ariesType. getAuditSu mmary(); | |||||
| 205 | } | |||||
| 206 | ||||||
| 207 | for (fin al AuditSu mmaryType auditSumma ryType : a uditSummar y) { | |||||
| 208 | ||||||
| 209 | fina l Map<Stri ng, Object > resultMa p = new Li nkedHashMa p<String, Object>(); | |||||
| 210 | ||||||
| 211 | fina l long cou nt = audit SummaryTyp e.getCount (); | |||||
| 212 | fina l SummaryF ieldsType summaryFie lds = audi tSummaryTy pe.getSumm aryFields( ); | |||||
| 213 | fina l List<Str ing> summa ryField = summaryFie lds.getSum maryField( ); | |||||
| 214 | ||||||
| 215 | if ( NullChecke r.isEmpty( summaryFie ld)) { | |||||
| 216 | continue; | |||||
| 217 | } | |||||
| 218 | ||||||
| 219 | if ( summaryFie ld.size() < 4) { | |||||
| 220 | continue; | |||||
| 221 | } | |||||
| 222 | ||||||
| 223 | // P artner org anization | |||||
| 224 | Orga nizationTy pe organiz ationType = null; | |||||
| 225 | if ( NullChecke r.isNotEmp ty(summary Field.get( 0))) { | |||||
| 226 | organizati onType = ( this.getCm sHelper(). getOrganiz ationByHom eCommunity Id(summary Field.get( 0).replace ("urn:oid: ", ""))); | |||||
| 227 | } | |||||
| 228 | if ( !NullCheck er.isNullO rEmpty(org anizationT ype)) { | |||||
| 229 | resultMap. put("partn erOrg", Re portDataPr ocessor.nu llEmptyRep laceWithUn known(orga nizationTy pe.getOrgN ame())); | |||||
| 230 | } el se { | |||||
| 231 | resultMap. put("partn erOrg", Re portDataPr ocessor.nu llEmptyRep laceWithUn known(summ aryField.g et(3))); | |||||
| 232 | } | |||||
| 233 | ||||||
| 234 | // P atient pre ferred fac ility | |||||
| 235 | fina l String a dapterVAFa cility = s ummaryFiel d.get(1); | |||||
| 236 | Stri ng vaFacil ity; | |||||
| 237 | if ( ReportData Processor. isValidSta tion(adapt erVAFacili ty)) { | |||||
| 238 | vaFacility = this.ge tFacilityH elper().ge tFacilityN ameByStati onId(adapt erVAFacili ty); | |||||
| 239 | if (NullCh ecker.isEm pty(vaFaci lity)) { | |||||
| 240 | vaFaci lity = sum maryField. get(2); | |||||
| 241 | } | |||||
| 242 | } el se { | |||||
| 243 | vaFacility = summary Field.get( 2); | |||||
| 244 | } | |||||
| 245 | resu ltMap.put( "vaFacilit y", Report DataProces sor.fixSta tion(vaFac ility)); | |||||
| 246 | ||||||
| 247 | // A udits coun t | |||||
| 248 | resu ltMap.put( "auditsCou nt", count ); | |||||
| 249 | ||||||
| 250 | // T he rest of the value s are simp ly copied from audit Summary, s ame order as they ap pear on da tatables. | |||||
| 251 | resu ltMap.put( "countUniq ueRealPati ents", Str ingUtils.i sNumeric(s ummaryFiel d.get(4)) ? Long.par seLong(sum maryField. get(4)) : 0); | |||||
| 252 | resu ltMap.put( "matchesFo undRealPat ients", St ringUtils. isNumeric( summaryFie ld.get(6)) ? Long.pa rseLong(su mmaryField .get(6)) : 0); | |||||
| 253 | resu ltMap.put( "matchFail sRealPatie nts", Stri ngUtils.is Numeric(su mmaryField .get(8)) ? Long.pars eLong(summ aryField.g et(8)) : 0 ); | |||||
| 254 | resu ltMap.put( "countUniq ueTestPati ents", Str ingUtils.i sNumeric(s ummaryFiel d.get(5)) ? Long.par seLong(sum maryField. get(5)) : 0); | |||||
| 255 | resu ltMap.put( "matchesFo undTestPat ients", St ringUtils. isNumeric( summaryFie ld.get(7)) ? Long.pa rseLong(su mmaryField .get(7)) : 0); | |||||
| 256 | resu ltMap.put( "matchFail sTestPatie nts", Stri ngUtils.is Numeric(su mmaryField .get(9)) ? Long.pars eLong(summ aryField.g et(9)) : 0 ); | |||||
| 257 | ||||||
| 258 | resu lts.add(re sultMap); | |||||
| 259 | tota lCount += count; | |||||
| 260 | } | |||||
| 261 | ||||||
| 262 | //sort a nd put eve verything together f or transpo rt package | |||||
| 263 | packaged Results = new Search ResultsPac kage( sort Results(re sults,requ est), tota lCount); | |||||
| 264 | ||||||
| 265 | } catch (fin al AuditEx ception ex ) { | |||||
| 266 | throw ne w AuditExc eption(); | |||||
| 267 | } | |||||
| 268 | re turn packa gedResults ; | |||||
| 269 | } | |||||
| 270 | ||||||
| 271 | /** | |||||
| 272 | * sor ts List<Ma p<String,O bject>> ba sed on map keys and request pa rameters. | |||||
| 273 | * @pa ram unsort edList | |||||
| 274 | * @pa ram reques t | |||||
| 275 | * @re turn | |||||
| 276 | */ | |||||
| 277 | privat e List<Map <String,Ob ject>> sor tResults(L ist<Map<St ring,Objec t>> unsort edList, Ht tpServletR equest req uest){ | |||||
| 278 | ||||||
| 279 | 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]" ); | |||||
| 280 | bo olean sort Ascending = request. getParamet er("order[ 0][dir]") == null ? !"desc".eq ualsIgnore Case(reque st.getPara meter("sor tOrder")) | |||||
| 281 | : !" desc".equa lsIgnoreCa se(request .getParame ter("order [0][dir]") ); | |||||
| 282 | ||||||
| 283 | if (unsortedL ist.size() > 1){ | |||||
| 284 | final Bu bbleSortLi stMap bSor ter = new BubbleSort ListMap(); | |||||
| 285 | ||||||
| 286 | if ("0". equals(sor tValue)){ | |||||
| 287 | sort Value = "p artnerOrg" ; | |||||
| 288 | } else i f ("1".equ als(sortVa lue)){ | |||||
| 289 | sort Value = "v aFacility" ; | |||||
| 290 | } else i f ("2".equ als(sortVa lue)){ | |||||
| 291 | sor tValue = " auditsCoun t"; | |||||
| 292 | } else i f ("3".equ als(sortVa lue)){ | |||||
| 293 | sort Value = "c ountUnique RealPatien ts"; | |||||
| 294 | } else i f ("4".equ als(sortVa lue)){ | |||||
| 295 | sort Value = "m atchesFoun dRealPatie nts"; | |||||
| 296 | } else i f ("5".equ als(sortVa lue)){ | |||||
| 297 | sort Value = "m atchFailsR ealPatient s"; | |||||
| 298 | } else i f ("6".equ als(sortVa lue)){ | |||||
| 299 | sort Value = "c ountUnique TestPatien ts"; | |||||
| 300 | } else i f ("7".equ als(sortVa lue)){ | |||||
| 301 | sort Value = "m atchesFoun dTestPatie nts"; | |||||
| 302 | } else i f ("8".equ als(sortVa lue)){ | |||||
| 303 | sort Value = "m atchFailsT estPatient s"; | |||||
| 304 | } else { | |||||
| 305 | sort Value = "p artnerOrg" ; | |||||
| 306 | } | |||||
| 307 | return b Sorter.sor tByColumn( unsortedLi st, sortVa lue, sortA scending); | |||||
| 308 | } else { | |||||
| 309 | return u nsortedLis t; | |||||
| 310 | } | |||||
| 311 | } | |||||
| 312 | ||||||
| 313 | /** | |||||
| 314 | * 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. | |||||
| 315 | * Obj ect Name i s "data" A dds object "totalCou nt" for to tal number of audits . | |||||
| 316 | * | |||||
| 317 | * @pa ram search Results | |||||
| 318 | * @re turn | |||||
| 319 | */ | |||||
| 320 | privat e String e ncodeIntoJ SON(Search ResultsPac kage searc hResults) { | |||||
| 321 | St ring jsonS tring = "" ; | |||||
| 322 | ||||||
| 323 | tr y { | |||||
| 324 | StringWr iter json = new Stri ngWriter() ; | |||||
| 325 | JSONObje ct obj = n ew JSONObj ect(); | |||||
| 326 | List<Lis t> data = new ArrayL ist<List>( ); | |||||
| 327 | ||||||
| 328 | for (Map <String, O bject> row : searchR esults.get SearchResu lts()) { | |||||
| 329 | List <String> d ataItem = new ArrayL ist<String >(); | |||||
| 330 | ||||||
| 331 | for (String ke y : row.ke ySet()) { | |||||
| 332 | dataItem.a dd(row.get (key).toSt ring()); | |||||
| 333 | } | |||||
| 334 | data .add(dataI tem); | |||||
| 335 | } | |||||
| 336 | ||||||
| 337 | obj.put( "data", da ta); | |||||
| 338 | ||||||
| 339 | obj.writ e(json); | |||||
| 340 | ||||||
| 341 | jsonStri ng = json. toString() ; | |||||
| 342 | } catch (JSO NException ex) { | |||||
| 343 | Logger.g etLogger(P atientDisc overySumma ryReport.c lass.getNa me()).log( Level.SEVE RE, null, ex); | |||||
| 344 | } | |||||
| 345 | re turn jsonS tring; | |||||
| 346 | } | |||||
| 347 | ||||||
| 348 | /** | |||||
| 349 | * Pul ls its own copy of o f the sear ch results and conve rts it to excel outp ut to be d ownloaded. | |||||
| 350 | * | |||||
| 351 | * @pa ram reques t | |||||
| 352 | * @pa ram respon se | |||||
| 353 | * @th rows Servl etExceptio n | |||||
| 354 | * @th rows IOExc eption | |||||
| 355 | */ | |||||
| 356 | public void expo rtToExcel( final Http ServletReq uest reque st, final HttpServle tResponse response) throws Ser vletExcept ion, IOExc eption { | |||||
| 357 | ||||||
| 358 | Se archResult sPackage r esults = g etResults( request); | |||||
| 359 | ||||||
| 360 | // Create a map of key which is based on t he result data key a nd the | |||||
| 361 | // heading v alue The h eading is used to cr eate the c olumn head ers and th e | |||||
| 362 | // key is us ed to pull the data from the r esults | |||||
| 363 | fi nal Map<St ring, Stri ng> patien tDiscovery Map = new LinkedHash Map<String , String>( ); | |||||
| 364 | ||||||
| 365 | // Generate filters. | |||||
| 366 | fi nal Map<St ring, List <Object>> filterMap = new Link edHashMap< String, Li st<Object> >(); | |||||
| 367 | fi nal Linked HashMap<St ring, Obje ct> filter s = new Li nkedHashMa p<String, Object>(); | |||||
| 368 | ||||||
| 369 | fi lters.put( "Start Dat e", reques t.getParam eter("star tDate")); | |||||
| 370 | fi lters.put( "End Date" , request. getParamet er("endDat e")); | |||||
| 371 | fi lters.put( "User ID", request.g etParamete r("userId" )); | |||||
| 372 | fi lters.put( "Patient P referred F acility", ExcelExpor ter.getPat ientPrefer redFacilit yFilter(ge tFacilityD AO(), requ est.getPar ameter("fa cility"))) ; | |||||
| 373 | fi lters.put( "eHealth E xchange Or ganization ", ExcelEx porter.get FilterValu e(request. getParamet er("organi zationName "))); | |||||
| 374 | Ex celExporte r.populate FilterMapF orExport(r equest, fi lters, fil terMap, re quest.getP arameter(" patientTyp es")); | |||||
| 375 | ||||||
| 376 | // Handle the calculati on of opti onal row t otals here . | |||||
| 377 | fi nal Map<St ring, List <Object>> optionalRo ws = new L inkedHashM ap<String, List<Obje ct>>(); | |||||
| 378 | Li st<Object> auditCoun t = new Ar rayList<Ob ject>(); | |||||
| 379 | au ditCount.a dd(results .getTotalC ount()); | |||||
| 380 | ||||||
| 381 | op tionalRows .put("Tota l Audits", auditCoun t); | |||||
| 382 | ||||||
| 383 | if (NullChec ker.isNull OrEmpty(re sults.getS earchResul ts())) { | |||||
| 384 | patientD iscoveryMa p.put("", "No record s were fou nd."); | |||||
| 385 | } else { | |||||
| 386 | patientD iscoveryMa p.put("par tnerOrg", "eHealth E xchange Or ganization "); | |||||
| 387 | patientD iscoveryMa p.put("vaF acility", "Patient P referred F acility"); | |||||
| 388 | patientD iscoveryMa p.put("aud itsCount", "Audits") ; | |||||
| 389 | patientD iscoveryMa p.put("cou ntUniqueRe alPatients ", "Unique Real Pati ents"); | |||||
| 390 | patientD iscoveryMa p.put("mat chesFoundR ealPatient s", "Match es Found f or Real Pa tients"); | |||||
| 391 | patientD iscoveryMa p.put("mat chFailsRea lPatients" , "Match F ails for R eal Patien ts"); | |||||
| 392 | patientD iscoveryMa p.put("cou ntUniqueTe stPatients ", "Unique Test Pati ents"); | |||||
| 393 | patientD iscoveryMa p.put("mat chesFoundT estPatient s", "Match es Found f or Test Pa tients"); | |||||
| 394 | patientD iscoveryMa p.put("mat chFailsTes tPatients" , "Match F ails for T est Patien ts"); | |||||
| 395 | } | |||||
| 396 | ||||||
| 397 | // Create wo rkbook | |||||
| 398 | fi nal String title = " Patient Di scovery Au dit Summar y Report"; | |||||
| 399 | fi nal Workbo ok wb = th is.getExce lExporter( ).exportTo Excel(titl e, title, patientDis coveryMap, results.g etSearchRe sults(), f ilterMap, optionalRo ws); | |||||
| 400 | ||||||
| 401 | // Write Exc el to Stre am | |||||
| 402 | th is.getExce lExporter( ).writeExc elToStream ("Patient_ Discovery_ Audit_Summ ary_Report ", wb, res ponse); | |||||
| 403 | } | |||||
| 404 | ||||||
| 405 | privat e Facility DAO getFac ilityDAO() { | |||||
| 406 | re turn this. getBean("F acilityDAO ", Facilit yDAO.class ); | |||||
| 407 | } | |||||
| 408 | ||||||
| 409 | /** | |||||
| 410 | * Get the excel exporter class from Spring. | |||||
| 411 | * | |||||
| 412 | * @re turn the e xcel expor ter object | |||||
| 413 | */ | |||||
| 414 | privat e ExcelExp orter getE xcelExport er() { | |||||
| 415 | re turn getBe an("excelE xporter", ExcelExpor ter.class) ; | |||||
| 416 | } | |||||
| 417 | ||||||
| 418 | /** | |||||
| 419 | * Cla ss specifi c to this report for mat, putti ng the sea rchresult list and t otal count long toge ther | |||||
| 420 | * All owing ease of parame ter passin g. | |||||
| 421 | */ | |||||
| 422 | privat e class Se archResult sPackage { | |||||
| 423 | ||||||
| 424 | pr ivate fina l List<Map <String, O bject>> se archResult s; | |||||
| 425 | pr ivate fina l long tot alCount; | |||||
| 426 | ||||||
| 427 | pu blic Searc hResultsPa ckage(List <Map<Strin g, Object> > searchRe sults, lon g totalCou nt) { | |||||
| 428 | this.sea rchResults = searchR esults; | |||||
| 429 | this.tot alCount = totalCount ; | |||||
| 430 | } | |||||
| 431 | ||||||
| 432 | pu blic List< Map<String , Object>> getSearch Results() { | |||||
| 433 | return s earchResul ts; | |||||
| 434 | } | |||||
| 435 | ||||||
| 436 | pu blic long getTotalCo unt() { | |||||
| 437 | return t otalCount; | |||||
| 438 | } | |||||
| 439 | } | |||||
| 440 | ||||||
| 441 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.