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 | ExpiringConsentReport.java | Fri Apr 21 20:15:58 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 0 | 0 |
| Changed | 0 | 0 |
| Inserted | 1 | 678 |
| 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.nvap.c ommon.vali dation.Nul lChecker; | |||||
| 4 | import gov .va.nvap.p rivacy.Con sentDirect iveDetaile dExpiratio nRequest; | |||||
| 5 | import gov .va.nvap.s ervice.ada pter.doc.A dapterExce ption; | |||||
| 6 | import gov .va.nvap.s vc.consent mgmt.stub. dao.MailTe mplateDAO; | |||||
| 7 | import gov .va.nvap.s vc.consent mgmt.stub. dao.Patien tConsentDi rDAO; | |||||
| 8 | import gov .va.nvap.s vc.consent mgmt.stub. data.Detai ledConsent Directive; | |||||
| 9 | import gov .va.nvap.w eb.app.Res ponseDispa tcherHttpS ervlet; | |||||
| 10 | import gov .va.nvap.w eb.dao.Fac ilityDAO; | |||||
| 11 | import gov .va.nvap.w eb.dao.Use rDocumentD AO; | |||||
| 12 | import gov .va.nvap.w eb.helper. document.D ocumentHel per; | |||||
| 13 | import gov .va.nvap.w eb.helper. facility.F acilityHel per; | |||||
| 14 | import gov .va.nvap.w eb.helper. privacy.Co nsentManag ementHelpe r; | |||||
| 15 | import gov .va.nvap.w eb.helper. report.Rep ortHelper; | |||||
| 16 | import gov .va.nvap.w eb.patient .ExcelGene ratorThrea d; | |||||
| 17 | import gov .va.nvap.w eb.user.Us erHelper; | |||||
| 18 | import gov .va.nvap.w eb.util.Co nstants; | |||||
| 19 | import gov .va.nvap.w eb.util.da te.DateUti l; | |||||
| 20 | import gov .va.nvap.w eb.util.xl s.CsvExpor ter; | |||||
| 21 | import gov .va.nvap.w eb.util.xl s.ExcelExp orter; | |||||
| 22 | import jav a.io.ByteA rrayInputS tream; | |||||
| 23 | ||||||
| 24 | import jav a.io.IOExc eption; | |||||
| 25 | import jav a.io.Outpu tStream; | |||||
| 26 | import jav a.io.Strin gWriter; | |||||
| 27 | import jav a.text.Dat eFormat; | |||||
| 28 | import jav a.text.Sim pleDateFor mat; | |||||
| 29 | import jav a.util.Arr ayList; | |||||
| 30 | import jav a.util.Cal endar; | |||||
| 31 | import jav a.util.Dat e; | |||||
| 32 | import jav a.util.Has hMap; | |||||
| 33 | import jav a.util.Lin kedHashMap ; | |||||
| 34 | import jav a.util.Lis t; | |||||
| 35 | import jav a.util.Map ; | |||||
| 36 | import jav a.util.log ging.Level ; | |||||
| 37 | import jav a.util.log ging.Logge r; | |||||
| 38 | ||||||
| 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 | import org .apache.po i.ss.userm odel.Workb ook; | |||||
| 44 | import org .json.JSON Exception; | |||||
| 45 | import org .json.JSON Object; | |||||
| 46 | ||||||
| 47 | public cla ss Expirin gConsentRe port exten ds Respons eDispatche rHttpServl et { | |||||
| 48 | ||||||
| 49 | /* * | |||||
| 50 | * Serial Ve rsion UID | |||||
| 51 | * / | |||||
| 52 | pr ivate stat ic final l ong serial VersionUID = -130363 8679062246 256L; | |||||
| 53 | ||||||
| 54 | /* * | |||||
| 55 | * Gets the consent ma nagement h elper from Spring. | |||||
| 56 | * / | |||||
| 57 | pr ivate Cons entManagem entHelper getCmsHelp er() { | |||||
| 58 | retu rn getBean ("cmsHelpe r", Consen tManagemen tHelper.cl ass); | |||||
| 59 | } | |||||
| 60 | ||||||
| 61 | /* * | |||||
| 62 | * Gets the facility h elper from Spring. | |||||
| 63 | * / | |||||
| 64 | pr ivate Faci lityHelper getFacili tyHelper() { | |||||
| 65 | retu rn getBean ("facility Helper", F acilityHel per.class) ; | |||||
| 66 | } | |||||
| 67 | ||||||
| 68 | privat e Map<Stri ng, String > getPreLo adValues() { | |||||
| 69 | re turn getCm sHelper(). getExpirin gConsentCo nfiguratio n(); | |||||
| 70 | } | |||||
| 71 | ||||||
| 72 | // When redi rected to the page b efore any actions | |||||
| 73 | @O verride | |||||
| 74 | pr otected vo id unspeci fied(final HttpServl etRequest request, | |||||
| 75 | final HttpServle tResponse response) throws Ser vletExcept ion, | |||||
| 76 | IOExce ption { | |||||
| 77 | fi nal HttpSe ssion sess ion = requ est.getSes sion(false ); | |||||
| 78 | fi nal int da yWindow = Integer.pa rseInt(thi s.getPreLo adValues() .get("wind ow")); | |||||
| 79 | ||||||
| 80 | se ssion.remo veAttribut e("results "); | |||||
| 81 | ||||||
| 82 | Da teFormat d ateFormat = new Simp leDateForm at("MM/dd/ yyyy"); | |||||
| 83 | Ca lendar cal endar = Ca lendar.get Instance() ; | |||||
| 84 | St ring start DateString = dateFor mat.format (calendar. getTime()) ; | |||||
| 85 | ca lendar.add (Calendar. DATE, dayW indow); | |||||
| 86 | St ring endDa teString = dateForma t.format(c alendar.ge tTime()); | |||||
| 87 | se ssion.setA ttribute(" startDateS tring", st artDateStr ing); | |||||
| 88 | se ssion.setA ttribute(" endDateStr ing", endD ateString) ; | |||||
| 89 | ||||||
| 90 | requ est.setAtt ribute("fa cilities", this.getF acilityHel per().getA llVistAFac ilities()) ; | |||||
| 91 | ||||||
| 92 | this .forward(r equest, re sponse, "s how"); | |||||
| 93 | } | |||||
| 94 | ||||||
| 95 | /** | |||||
| 96 | * Mai n search f unction re turns json results u se primari ly for dat atables. | |||||
| 97 | * @pa ram reques t | |||||
| 98 | * @pa ram respon se | |||||
| 99 | * @th rows IOExc eption | |||||
| 100 | * @th rows Servl etExceptio n | |||||
| 101 | */ | |||||
| 102 | public void doSe arch(final HttpServl etRequest request, | |||||
| 103 | final HttpServle tResponse response) throws IOE xception, ServletExc eption{ | |||||
| 104 | ||||||
| 105 | fi nal HttpSe ssion sess ion = requ est.getSes sion(false ); | |||||
| 106 | ||||||
| 107 | se ssion.setA ttribute(" results", encodeInto JSON(getRe sults(requ est), Long .parseLong (request.g etParamete r("draw")) )); | |||||
| 108 | ||||||
| 109 | th is.forward (request, response, "searchRes ultsJSON") ; | |||||
| 110 | ||||||
| 111 | } | |||||
| 112 | ||||||
| 113 | /** | |||||
| 114 | * Gat hers and a ssembles t he informa tion for t he Expirin g Consent Report. | |||||
| 115 | * | |||||
| 116 | * @pa ram sessio n the http session | |||||
| 117 | * @pa ram pagina tor the pa ginator fo r the expi ring conse nt report | |||||
| 118 | * @re turn a lis t of map o bjects wit h patient informatio n for the report | |||||
| 119 | */ | |||||
| 120 | privat e SearchPa ckage getR esults(Htt pServletRe quest requ est) { | |||||
| 121 | ||||||
| 122 | Pa tientConse ntDirDAO d ao = this. getPatient ConsentDir DAO(); | |||||
| 123 | Da te startDa te = Repor tHelper.ge tStartDate (request.g etParamete r("startDa te")); | |||||
| 124 | Da te endDate = ReportH elper.getE ndDate(req uest.getPa rameter("e ndDate")); | |||||
| 125 | fi nal Patien tConsentDi rDAO.Searc hRequest s earchReque st = new P atientCons entDirDAO( ).new Sear chRequest( ); | |||||
| 126 | ||||||
| 127 | se archReques t.startDat e = startD ate; | |||||
| 128 | se archReques t.endDate = endDate; | |||||
| 129 | se archReques t.stationN umbers = r equest.get Parameter( "stationNu mbers"); | |||||
| 130 | se archReques t.includeU nknownVisn = "true". equals(req uest.getPa rameter("i ncludeUnkn ownVisn")) ; | |||||
| 131 | se archReques t.consentT ypeName = request.ge tParameter ("consentT ypeName"); | |||||
| 132 | se archReques t.userId = request.g etParamete r("entered By"); | |||||
| 133 | ||||||
| 134 | fi nal String inboundSo rtValue = (request.g etParamete r("order[0 ][column]" )!=null) | |||||
| 135 | ? ge tSortValue (request.g etParamete r("order[0 ][column]" )) : getSo rtValue(re quest.getP arameter(" sortBy")); | |||||
| 136 | fi nal String inboundSo rtDirectio n = (reque st.getPara meter("ord er[0][dir] ")!=null) | |||||
| 137 | ?req uest.getPa rameter("o rder[0][di r]") : req uest.getPa rameter("s ortOrder") ; | |||||
| 138 | ||||||
| 139 | fi nal int pa tientTypes = Integer .parseInt( request.ge tParameter ("patientT ypes")); | |||||
| 140 | ||||||
| 141 | // if the par ameters do nt exist, return eve rything. T he paramet ers are au tomaticall y passed i f called | |||||
| 142 | // from searc h page. If else, its from an e xport so p rovide eve rything. | |||||
| 143 | fi nal int pa ge = (requ est.getPar ameter("st art") != n ull) | |||||
| 144 | ? In teger.pars eInt(reque st.getPara meter("sta rt"))/ Int eger.parse Int(reques t.getParam eter("leng th")) : 0; | |||||
| 145 | fi nal int pa geLength = (request. getParamet er("length ") != null ) | |||||
| 146 | ? In teger.pars eInt(reque st.getPara meter("len gth")) : - 1; | |||||
| 147 | ||||||
| 148 | se archReques t.patientT ypes = pat ientTypes; | |||||
| 149 | ||||||
| 150 | // For use i n sorting results | |||||
| 151 | if (NullChec ker.isNotE mpty(inbou ndSortValu e)) { | |||||
| 152 | searchRe quest.sort By = inbou ndSortValu e; | |||||
| 153 | } | |||||
| 154 | if (NullChec ker.isNotE mpty(inbou ndSortDire ction)) { | |||||
| 155 | searchRe quest.sort Order = in boundSortD irection; | |||||
| 156 | } | |||||
| 157 | ||||||
| 158 | se archReques t.fromPage = page; | |||||
| 159 | se archReques t.recordsP erPage = p ageLength; | |||||
| 160 | ||||||
| 161 | fi nal List<M ap<String, Object>> results = new ArrayL ist<Map<St ring, Obje ct>>(); | |||||
| 162 | Lo ng totalQu eryCount = 0L; | |||||
| 163 | Lo ng rowTota lForLetter s =0L; | |||||
| 164 | tr y { | |||||
| 165 | ||||||
| 166 | final Pa tientConse ntDirDAO.S earchRespo nse search Response = dao.find( searchRequ est); | |||||
| 167 | ||||||
| 168 | if (sear chResponse != null) { | |||||
| 169 | ||||||
| 170 | if ( (searchRes ponse.cons ents != nu ll) | |||||
| 171 | && (search Response.c onsents.si ze() > 0)) { | |||||
| 172 | ||||||
| 173 | rowTotalFo rLetters = searchRes ponse.coun t; | |||||
| 174 | int pageNu mber = pag e; | |||||
| 175 | int pageSi ze = pageL ength; | |||||
| 176 | int toPage = 0; | |||||
| 177 | ||||||
| 178 | if (pageNu mber <= 0) { | |||||
| 179 | toPage = pageSiz e; | |||||
| 180 | } else { | |||||
| 181 | toPage = (pageNu mber + 1) * pageSize ; | |||||
| 182 | } | |||||
| 183 | ||||||
| 184 | for (Detai ledConsent Directive detailedCo nsentRefer ence : sea rchRespons e.consents ) { | |||||
| 185 | final Map<String , Object> resultMap = new Hash Map<String , Object>( ); | |||||
| 186 | if (de tailedCons entReferen ce != null ) { | |||||
| 187 | Re portDataPr ocessor.ad dSsnToResu ltMap(resu ltMap, det ailedConse ntReferenc e.getSsn() ); | |||||
| 188 | re sultMap.pu t("lastNam e", detail edConsentR eference.g etLastName ()); | |||||
| 189 | re sultMap.pu t("firstNa me", detai ledConsent Reference. getFirstNa me()); | |||||
| 190 | re sultMap.pu t("middleN ame", deta iledConsen tReference .getMiddle Name()); | |||||
| 191 | St ring conse ntTypeName = detaile dConsentRe ference.ge tOptinCons entType(). getName(); | |||||
| 192 | if (consentT ypeName.co ntains("Nw HIN")) { | |||||
| 193 | consentT ypeName = consentTyp eName.repl ace("NwHIN ", Constan ts.getOrga nizationNa me()); | |||||
| 194 | } | |||||
| 195 | re sultMap.pu t("consent TypeName", consentTy peName); | |||||
| 196 | re sultMap.pu t("optInDa te", detai ledConsent Reference. getOptinDa te()); | |||||
| 197 | re sultMap.pu t("expirat ionDate", detailedCo nsentRefer ence.getEx pirationDa te()); | |||||
| 198 | re sultMap.pu t("facilit yName", de tailedCons entReferen ce.getFaci lityName() ); | |||||
| 199 | re sultMap.pu t("userId" , detailed ConsentRef erence.get UserId()); | |||||
| 200 | re sults.add( resultMap) ; | |||||
| 201 | } | |||||
| 202 | } | |||||
| 203 | } | |||||
| 204 | } | |||||
| 205 | ||||||
| 206 | final Pa tientConse ntDirDAO.S earchRespo nse search CountRespo nse = dao. findCount( searchRequ est); | |||||
| 207 | totalQue ryCount = searchCoun tResponse. count; | |||||
| 208 | ||||||
| 209 | } catch (fin al Excepti on ex) { | |||||
| 210 | throw ne w RuntimeE xception(e x); | |||||
| 211 | } | |||||
| 212 | // for expiri ng consent we need t o know if one statio nNumber wa s selected to allow pdf genera tion | |||||
| 213 | fi nal boolea n oneStati on = (!req uest.getPa rameter("s tationNumb ers").cont ains(",") && request .getParame ter("stati onNumbers" )!=null | |||||
| 214 | && ! request.ge tParameter ("stationN umbers").e quals("ALL ")) | |||||
| 215 | ? tr ue : false ; | |||||
| 216 | re turn new S earchPacka ge(results , totalQue ryCount, | |||||
| 217 | Cons tants.getE xpiredNoti ficationLe ttersMaxTi me(), | |||||
| 218 | Cons tants.getE xpiredNoti ficationPe rLetterTim e(), | |||||
| 219 | rowT otalForLet ters, oneS tation); | |||||
| 220 | } | |||||
| 221 | ||||||
| 222 | /** | |||||
| 223 | * tra nsforms pa cked resul ts into js on object string, in cluding an y addition al attribu tes that | |||||
| 224 | * may be needed on the vi ew such as draw, rec ordsTotal, etc. | |||||
| 225 | * @pa ram packed Results | |||||
| 226 | * @pa ram draw | |||||
| 227 | * @re turn | |||||
| 228 | */ | |||||
| 229 | privat e String e ncodeIntoJ SON(Search Package pa ckedResult s, Long dr aw){ | |||||
| 230 | St ring jsonS tring = "" ; | |||||
| 231 | ||||||
| 232 | Da teFormat d ateFormat = new Simp leDateForm at("MM/dd/ yyyy"); | |||||
| 233 | ||||||
| 234 | tr y { | |||||
| 235 | StringWr iter json = new Stri ngWriter() ; | |||||
| 236 | JSONObje ct obj = n ew JSONObj ect(); | |||||
| 237 | List<Lis t> data = new ArrayL ist<List>( ); | |||||
| 238 | ||||||
| 239 | for (Map <String, O bject> row : packedR esults.get Results()) { | |||||
| 240 | List <String> d ataItem = new ArrayL ist<String >(); | |||||
| 241 | ||||||
| 242 | data Item.add(r ow.get("ss nMasked"). toString() ); | |||||
| 243 | data Item.add(r ow.get("la stName").t oString()) ; | |||||
| 244 | data Item.add(r ow.get("fi rstName"). toString() ); | |||||
| 245 | ||||||
| 246 | if(r ow.get("mi ddleName") !=null){ | |||||
| 247 | dataItem.a dd(row.get ("middleNa me").toStr ing()); | |||||
| 248 | } el se { | |||||
| 249 | dataItem.a dd(""); | |||||
| 250 | } | |||||
| 251 | data Item.add(d ateFormat. format(row .get("optI nDate"))); | |||||
| 252 | data Item.add(d ateFormat. format(row .get("expi rationDate "))); | |||||
| 253 | data Item.add(r ow.get("co nsentTypeN ame").toSt ring()); | |||||
| 254 | data Item.add(r ow.get("us erId").toS tring()); | |||||
| 255 | data Item.add(r ow.get("fa cilityName ").toStrin g()); | |||||
| 256 | ||||||
| 257 | //ad d unmasked ssn for l inkToPatie nts, does not appear as table column | |||||
| 258 | data Item.add(r ow.get("ss n").toStri ng()); | |||||
| 259 | data .add(dataI tem); | |||||
| 260 | } | |||||
| 261 | ||||||
| 262 | obj.put( "data", da ta); | |||||
| 263 | obj.put( "draw", dr aw); | |||||
| 264 | obj.put( "recordsTo tal", pack edResults. getCount() ); | |||||
| 265 | obj.put( "recordsFi ltered",pa ckedResult s.getCount ()); | |||||
| 266 | obj.put( "expiredNo tification LettersMax Time", pac kedResults .getExpire dNotificat ionLetters MaxTime()) ; | |||||
| 267 | obj.put( "expiredNo tification PerLetterT ime", pack edResults. getExpired Notificati onPerLette rTime()); | |||||
| 268 | obj.put( "rowTotalF orLetters" , packedRe sults.getR owTotalFor Letters()) ; | |||||
| 269 | obj.put( "oneStatio nRequested ",packedRe sults.isOn lyOneStati onRequeste d()); | |||||
| 270 | ||||||
| 271 | obj.writ e(json); | |||||
| 272 | ||||||
| 273 | jsonStri ng = json. toString() ; | |||||
| 274 | } catch (JSO NException ex) { | |||||
| 275 | Logger.g etLogger(E xpiringCon sentReport .class.get Name()).lo g(Level.SE VERE, null , ex); | |||||
| 276 | } | |||||
| 277 | ||||||
| 278 | re turn jsonS tring; | |||||
| 279 | } | |||||
| 280 | ||||||
| 281 | /** | |||||
| 282 | * con verts the column num ber to the appropria te column sort value | |||||
| 283 | * @pa ram column Number | |||||
| 284 | * @re turn | |||||
| 285 | */ | |||||
| 286 | privat e String g etSortValu e(String c olumnNumbe r){ | |||||
| 287 | St ring sortV alue = ""; | |||||
| 288 | ||||||
| 289 | sw itch (Inte ger.parseI nt(columnN umber)){ | |||||
| 290 | case 0: | |||||
| 291 | sort Value = "p atientSSN" ; | |||||
| 292 | brea k; | |||||
| 293 | case 1: | |||||
| 294 | sort Value = "p atientLast Name"; | |||||
| 295 | brea k; | |||||
| 296 | case 2: | |||||
| 297 | sort Value = "p atientGive nName"; | |||||
| 298 | brea k; | |||||
| 299 | case 3: | |||||
| 300 | sort Value = "p atientMidd leName"; | |||||
| 301 | brea k; | |||||
| 302 | case 4: | |||||
| 303 | sort Value = "o ptInDate"; | |||||
| 304 | brea k; | |||||
| 305 | case 5: | |||||
| 306 | sort Value = "e xpirationD ate"; | |||||
| 307 | brea k; | |||||
| 308 | case 6: | |||||
| 309 | sort Value = "o ptInConsen tType"; | |||||
| 310 | brea k; | |||||
| 311 | case 7: | |||||
| 312 | sort Value = "u serId"; | |||||
| 313 | brea k; | |||||
| 314 | case 8: | |||||
| 315 | sort Value = "f acilityNam e"; | |||||
| 316 | brea k; | |||||
| 317 | } | |||||
| 318 | re turn sortV alue; | |||||
| 319 | } | |||||
| 320 | ||||||
| 321 | public void expo rtToExcel( final Http ServletReq uest reque st, | |||||
| 322 | fi nal HttpSe rvletRespo nse respon se) throws ServletEx ception, I OException { | |||||
| 323 | ||||||
| 324 | // Create a map of key which is based on t he result data key a nd the hea ding value | |||||
| 325 | // The headin g is used to create the column headers a nd the | |||||
| 326 | // key is use d to pull the data f rom the re sults | |||||
| 327 | fi nal Map<St ring, Stri ng> report Map = new LinkedHash Map<String , String>( ); | |||||
| 328 | ||||||
| 329 | // Generate filters. | |||||
| 330 | fi nal Map<St ring, List <Object>> filterMap = new Link edHashMap< String, Li st<Object> >(); | |||||
| 331 | fi nal Linked HashMap<St ring, Obje ct> filter s = new Li nkedHashMa p<String, Object>(); | |||||
| 332 | ||||||
| 333 | bo olean optI nReport = false; | |||||
| 334 | if (!NullChe cker.isNul lOrEmpty(r equest.get Parameter( "optInRepo rt"))) { | |||||
| 335 | optInRep ort = true ; | |||||
| 336 | } | |||||
| 337 | ||||||
| 338 | // Check if t his this i s an Expir ing Consen t report i n which ca se the | |||||
| 339 | // start date and end d ates MUST be present . Otherwis e this is an Opt In | |||||
| 340 | // report and dates CAN NOT be pro vided. | |||||
| 341 | if (!optInRe port) { | |||||
| 342 | filters. put("Start Date", th is.getRepo rtHelper() .getFormat tedDate(Re portHelper .getStartD ate(reques t.getParam eter("star tDate")))) ; | |||||
| 343 | filters. put("End D ate", this .getReport Helper().g etFormatte dDate(Repo rtHelper.g etEndDate( request.ge tParameter ("endDate" )))); | |||||
| 344 | } | |||||
| 345 | fi lters.put( "Entered B y", reques t.getParam eter("ente redBy")); | |||||
| 346 | St ring facil ityNames = ExcelExpo rter.getFa cilitiesFi lter(getFa cilityDAO( ), request .getParame ter("stati onNumbers" )); | |||||
| 347 | fi lters.put( "Authentic ating Faci lity", fac ilityNames ); | |||||
| 348 | fi lters.put( "Consent T ype", Exce lExporter. getConsent TypeFilter (request.g etParamete r("consent TypeName") )); | |||||
| 349 | Ex celExporte r.populate FilterMapF orExport(r equest, fi lters, fil terMap, re quest.getP arameter(" patientTyp es")); | |||||
| 350 | ||||||
| 351 | re portMap.pu t("ssn", " SSN"); | |||||
| 352 | re portMap.pu t("lastNam e", "Patie nt Last Na me"); | |||||
| 353 | re portMap.pu t("firstNa me", "Pati ent First Name"); | |||||
| 354 | re portMap.pu t("middleN ame", "Pat ient Middl e Name"); | |||||
| 355 | re portMap.pu t("optInDa te", "Opt In Date"); | |||||
| 356 | re portMap.pu t("expirat ionDate", "Expiratio n Date"); | |||||
| 357 | re portMap.pu t("consent TypeName", "Consent Type"); | |||||
| 358 | re portMap.pu t("userId" , "Entered By"); | |||||
| 359 | re portMap.pu t("facilit yName", "A uthenticat ing Facili ty"); | |||||
| 360 | ||||||
| 361 | in t minimumT hreshold = Integer.p arseInt((S tring) thi s.getServl etContext( ).getAttri bute("sche duledExpor tMin")); | |||||
| 362 | in t total = Integer.pa rseInt(req uest.getPa rameter("t otalRows") ); | |||||
| 363 | ||||||
| 364 | // Start a sc heduled ex port with its own th read if gr eater than the minim um thresho ld | |||||
| 365 | if (total >= minimumTh reshold) { | |||||
| 366 | ExcelGen eratorThre ad exGenTh read = new ExcelGene ratorThrea d("exGenTh read"); | |||||
| 367 | ||||||
| 368 | //Check to see if this is an OptIn Rep ort. The r equest par ameter | |||||
| 369 | //set in optInRepo rt.jsp. | |||||
| 370 | exGenThr ead.setTit le("Expiri ng Consent Detail Re port"); | |||||
| 371 | if (optI nReport) { | |||||
| 372 | exGe nThread.se tTitle("Op t-In Patie nts Detail Report"); | |||||
| 373 | } | |||||
| 374 | exGenThr ead.setFil terMap(fil terMap); | |||||
| 375 | exGenThr ead.setRep ortMap(rep ortMap); | |||||
| 376 | ||||||
| 377 | exGenThr ead.setExc elExporter (this.getE xcelExport er()); | |||||
| 378 | exGenThr ead.setRep ortHelper( getReportH elper()); | |||||
| 379 | exGenThr ead.setUse rId(UserHe lper.getUs erName(req uest)); | |||||
| 380 | exGenThr ead.setDoc umentHelpe r(getDocum entHelper( )); | |||||
| 381 | exGenThr ead.setPat ientConsen tDirDAO(ge tPatientCo nsentDirDA O()); | |||||
| 382 | exGenThr ead.setUse rDocumentD ao(getUser DocumentDA O()); | |||||
| 383 | ||||||
| 384 | // Set s earch attr ibutes for getting a udit resul ts | |||||
| 385 | exGenThr ead.setAtt ributes(ma pSessionAt tributes(r equest)); | |||||
| 386 | ||||||
| 387 | exGenThr ead.start( ); | |||||
| 388 | } | |||||
| 389 | // Otherwise generate a nd downloa d the expo rt directl y | |||||
| 390 | el se { | |||||
| 391 | // Creat e workbook | |||||
| 392 | String t itle = "Ex piring Con sent Detai l Report"; | |||||
| 393 | String f ileName = "Expiring_ Consent_De tail_Repor t"; | |||||
| 394 | if (optI nReport) { | |||||
| 395 | titl e = "Opt-I n Patients Detail Re port"; | |||||
| 396 | file Name = "Op t-In_Patie nts_Detail _Report"; | |||||
| 397 | } | |||||
| 398 | ||||||
| 399 | List<Map <String, O bject>> re sults; | |||||
| 400 | ||||||
| 401 | ExcelGen eratorThre ad doNow = new Excel GeneratorT hread("doN ow"); | |||||
| 402 | doNow.se tAttribute s(mapSessi onAttribut es(request )); | |||||
| 403 | doNow.se tPatientCo nsentDirDA O(this.get PatientCon sentDirDAO ()); | |||||
| 404 | // Set s earch attr ibutes for getting a udit resul ts | |||||
| 405 | doNow.se tAttribute s(mapSessi onAttribut es(request )); | |||||
| 406 | ||||||
| 407 | results = doNow.ge tPatientCo nsentDirRe sults(); | |||||
| 408 | ||||||
| 409 | final Wo rkbook wb = this.get ExcelExpor ter().expo rtToExcel( title, tit le, report Map, resul ts, filter Map, null) ; | |||||
| 410 | ||||||
| 411 | // Write Excel wor kbook to S tream | |||||
| 412 | this.get ExcelExpor ter().writ eExcelToSt ream(fileN ame, wb, r esponse); | |||||
| 413 | } | |||||
| 414 | } | |||||
| 415 | ||||||
| 416 | privat e Map<Stri ng, Object > mapSessi onAttribut es(HttpSer vletReques t request) { | |||||
| 417 | Ma p<String, Object> at tributes = new HashM ap<String, Object>() ; | |||||
| 418 | ||||||
| 419 | at tributes.p ut("userId ", request .getParame ter("enter edBy")); | |||||
| 420 | ||||||
| 421 | Da te startDa te = Repor tHelper.ge tStartDate (request.g etParamete r("startDa te")); | |||||
| 422 | Da te endDate = ReportH elper.getE ndDate(req uest.getPa rameter("e ndDate")); | |||||
| 423 | at tributes.p ut("startD ate", star tDate); | |||||
| 424 | at tributes.p ut("endDat e", endDat e); | |||||
| 425 | ||||||
| 426 | at tributes.p ut("statio nNumbers", request.g etParamete r("station Numbers")) ; | |||||
| 427 | at tributes.p ut("patien tTypes", I nteger.par seInt(requ est.getPar ameter("pa tientTypes "))); | |||||
| 428 | at tributes.p ut("consen tTypeName" , request. getParamet er("consen tTypeName" )); | |||||
| 429 | at tributes.p ut("includ eUnknownVi sn", "true ".equals(r equest.get Parameter( "includeUn knownVisn" ))); | |||||
| 430 | // sort | |||||
| 431 | fi nal String inboundSo rtValue = (request.g etParamete r("order[0 ][column]" )!=null) | |||||
| 432 | ? ge tSortValue (request.g etParamete r("order[0 ][column]" )) : getSo rtValue(re quest.getP arameter(" sortBy")); | |||||
| 433 | fi nal String inboundSo rtDirectio n = (reque st.getPara meter("ord er[0][dir] ")!=null) | |||||
| 434 | ?req uest.getPa rameter("o rder[0][di r]") : req uest.getPa rameter("s ortOrder") ; | |||||
| 435 | ||||||
| 436 | at tributes.p ut("sortVa lue", inbo undSortVal ue); | |||||
| 437 | at tributes.p ut("sortDi rection", inboundSor tDirection ); | |||||
| 438 | ||||||
| 439 | re turn attri butes; | |||||
| 440 | } | |||||
| 441 | ||||||
| 442 | public void expo rtToCsv(fi nal HttpSe rvletReque st request , | |||||
| 443 | fi nal HttpSe rvletRespo nse respon se) throws ServletEx ception, I OException { | |||||
| 444 | ||||||
| 445 | Ma p<String, String> cs vReportMap = new Lin kedHashMap <String, S tring>(); | |||||
| 446 | ||||||
| 447 | cs vReportMap .put("SSN" , "ssn"); | |||||
| 448 | cs vReportMap .put("Pati ent Last N ame", "las tName"); | |||||
| 449 | cs vReportMap .put("Pati ent First Name", "fi rstName"); | |||||
| 450 | cs vReportMap .put("Pati ent Middle Name", "m iddleName" ); | |||||
| 451 | cs vReportMap .put("Opt In Date", "optInDate "); | |||||
| 452 | cs vReportMap .put("Expi ration Dat e", "expir ationDate" ); | |||||
| 453 | cs vReportMap .put("Cons ent Type", "consentT ypeName"); | |||||
| 454 | cs vReportMap .put("Ente red By", " userId"); | |||||
| 455 | cs vReportMap .put("Auth enticating Facility" , "facilit yName"); | |||||
| 456 | ||||||
| 457 | in t minimumT hreshold = Integer.p arseInt((S tring) thi s.getServl etContext( ).getAttri bute("sche duledExpor tMin")); | |||||
| 458 | in t total = Integer.pa rseInt(req uest.getPa rameter("t otalRows") ); | |||||
| 459 | ||||||
| 460 | // Start a sc heduled ex port with its own th read if gr eater than the minim um thresho ld | |||||
| 461 | if (total >= minimumTh reshold) { | |||||
| 462 | ExcelGen eratorThre ad csvGenT hread = ne w ExcelGen eratorThre ad("csvGen Thread"); | |||||
| 463 | csvGenTh read.setDo cumentType ("csv"); | |||||
| 464 | csvGenTh read.setRe portMap(cs vReportMap ); | |||||
| 465 | ||||||
| 466 | csvGenTh read.setTi tle("Expir ing Consen t Detail R eport"); | |||||
| 467 | if (!Nul lChecker.i sNullOrEmp ty(request .getParame ter("optIn Report"))) { | |||||
| 468 | csvG enThread.s etTitle("O pt-In Pati ents Detai l Report") ; | |||||
| 469 | } | |||||
| 470 | csvGenTh read.setEx celExporte r(this.get ExcelExpor ter()); | |||||
| 471 | csvGenTh read.setRe portHelper (getReport Helper()); | |||||
| 472 | csvGenTh read.setUs erId(UserH elper.getU serName(re quest)); | |||||
| 473 | csvGenTh read.setDo cumentHelp er(getDocu mentHelper ()); | |||||
| 474 | csvGenTh read.setPa tientConse ntDirDAO(g etPatientC onsentDirD AO()); | |||||
| 475 | csvGenTh read.setUs erDocument Dao(getUse rDocumentD AO()); | |||||
| 476 | ||||||
| 477 | // Set s earch attr ibutes for getting a udit resul ts | |||||
| 478 | csvGenTh read.setAt tributes(m apSessionA ttributes( request)); | |||||
| 479 | ||||||
| 480 | csvGenTh read.start (); | |||||
| 481 | ||||||
| 482 | } | |||||
| 483 | // Otherwise generate a nd downloa d the expo rt directl y | |||||
| 484 | el se { | |||||
| 485 | List<Map <String, O bject>> re sults; | |||||
| 486 | SearchPa ckage pack edResults; | |||||
| 487 | ||||||
| 488 | packedRe sults = th is.getResu lts(reques t); | |||||
| 489 | results = packedRe sults.getR esults(); | |||||
| 490 | ||||||
| 491 | CsvExpor ter csvExp orter = ne w CsvExpor ter(); | |||||
| 492 | String t itle = "Ex piring Con sent Detai l Report"; | |||||
| 493 | if (!Nul lChecker.i sNullOrEmp ty(request .getParame ter("optIn Report"))) { | |||||
| 494 | titl e = "Opt-I n Patients Detail Re port"; | |||||
| 495 | } | |||||
| 496 | csvExpor ter.export ToCSV(resp onse, titl e, results , (LinkedH ashMap<Str ing, Strin g>) csvRep ortMap); | |||||
| 497 | } | |||||
| 498 | } | |||||
| 499 | ||||||
| 500 | public void view (HttpServl etRequest request, | |||||
| 501 | fi nal HttpSe rvletRespo nse respon se) throws ServletEx ception, | |||||
| 502 | IO Exception { | |||||
| 503 | Ht tpSession session = request.ge tSession(f alse); | |||||
| 504 | fi nal String icn = req uest.getPa rameter("i cn"); | |||||
| 505 | fi nal String documentU niqueId = request | |||||
| 506 | .getPara meter("exp iringConse ntUniqueId "); | |||||
| 507 | fi nal String styleShee tViewType = request | |||||
| 508 | .getPara meter("sty leSheetVie wType"); | |||||
| 509 | ||||||
| 510 | St ring docum ent = null ; | |||||
| 511 | tr y { | |||||
| 512 | document = this.ge tDocumentH elper().ge tDocument( icn, | |||||
| 513 | docu mentUnique Id, UserHe lper.getUs erName(req uest), | |||||
| 514 | this .getCmsHel per().getC ompleteHom eCommunity Id()); | |||||
| 515 | } catch (fin al Adapter Exception ex) { | |||||
| 516 | throw ne w ServletE xception(e x); | |||||
| 517 | } | |||||
| 518 | ||||||
| 519 | se ssion.setA ttribute(" icn", icn) ; | |||||
| 520 | se ssion.setA ttribute(" documentUn iqueId", d ocumentUni queId); | |||||
| 521 | se ssion.setA ttribute(" document", document) ; | |||||
| 522 | se ssion.setA ttribute(" isXmlViewE nabled", t his.getDoc umentHelpe r() | |||||
| 523 | .isXmlVi ewEnabled( )); | |||||
| 524 | ||||||
| 525 | if ("xml".eq uals(style SheetViewT ype)) { | |||||
| 526 | document = documen t | |||||
| 527 | .rep laceAll( | |||||
| 528 | "<?xml-sty lesheet ty pe=\"text/ xsl\" href =\"CCD.xsl \"?>", | |||||
| 529 | ""); | |||||
| 530 | response .setConten tType("tex t/xml;char set=UTF-8" ); | |||||
| 531 | response .getWriter ().write(d ocument); | |||||
| 532 | } else { | |||||
| 533 | // Updat e session in the doc ument | |||||
| 534 | final St ring html = this.get DocumentHe lper().get Html(docum ent, | |||||
| 535 | styl eSheetView Type); | |||||
| 536 | ||||||
| 537 | session. setAttribu te("update dDocument" , html); | |||||
| 538 | this.for ward(reque st, respon se, "showI nboundDocu mentReport Document") ; | |||||
| 539 | } | |||||
| 540 | } | |||||
| 541 | ||||||
| 542 | public void down load(final HttpServl etRequest request, | |||||
| 543 | fi nal HttpSe rvletRespo nse respon se) throws ServletEx ception, | |||||
| 544 | IO Exception { | |||||
| 545 | ||||||
| 546 | Da te startDa te = Repor tHelper.ge tStartDate (request.g etParamete r("startDa te")); | |||||
| 547 | Da te endDate = ReportH elper.getS tartDate(r equest.get Parameter( "endDate") ); | |||||
| 548 | St ring conse ntTypeName = request .getParame ter("conse ntTypeName "); | |||||
| 549 | St ring userI d = reques t.getParam eter("ente redBy"); | |||||
| 550 | fi nal int pa tientTypes = Integer .parseInt( request.ge tParameter ("patientT ypes")); | |||||
| 551 | ||||||
| 552 | St ring stati onNumber = request.g etParamete r("station Numbers"); | |||||
| 553 | ||||||
| 554 | if (endDate != null) { | |||||
| 555 | endDate = DateUtil .addTime(e ndDate, Ca lendar.HOU R, 24); | |||||
| 556 | } | |||||
| 557 | ||||||
| 558 | Co nsentDirec tiveDetail edExpirati onRequest expiration Request | |||||
| 559 | = new Co nsentDirec tiveDetail edExpirati onRequest( ); | |||||
| 560 | ex pirationRe quest.setS tartDate(s tartDate); | |||||
| 561 | ex pirationRe quest.setE ndDate(end Date); | |||||
| 562 | ex pirationRe quest.setF acilitySta tion(stati onNumber); | |||||
| 563 | ex pirationRe quest.setC onsentType Name(conse ntTypeName ); | |||||
| 564 | ex pirationRe quest.setU serId(user Id); | |||||
| 565 | ex pirationRe quest.setP atientType s(patientT ypes); | |||||
| 566 | ||||||
| 567 | St ring templ ate = this .getMailTe mplateDAO( ).getByLet terType(4L ).getText( ); | |||||
| 568 | ||||||
| 569 | ex pirationRe quest.setT emplate(te mplate); | |||||
| 570 | ||||||
| 571 | fi nal ByteAr rayInputSt ream byteI nputStream | |||||
| 572 | = this.g etCmsHelpe r().getExp iringConse ntReportLe tters(expi rationRequ est); | |||||
| 573 | ||||||
| 574 | re sponse.set ContentTyp e("applica tion/pdf") ; | |||||
| 575 | re sponse.add Header("Co ntent-Disp osition", "attachmen t; filenam e=patient_ letters.pd f"); | |||||
| 576 | ||||||
| 577 | Ou tputStream responseO utStream = response. getOutputS tream(); | |||||
| 578 | ||||||
| 579 | by te[] buffe r = new by te[4096]; | |||||
| 580 | in t bytesRea d; | |||||
| 581 | in t totalByt es = 0; | |||||
| 582 | ||||||
| 583 | wh ile ((byte sRead = by teInputStr eam.read(b uffer)) != -1) { | |||||
| 584 | response OutStream. write(buff er, 0, byt esRead); | |||||
| 585 | totalByt es += byte sRead; | |||||
| 586 | } | |||||
| 587 | ||||||
| 588 | re sponse.set ContentLen gth(totalB ytes); | |||||
| 589 | ||||||
| 590 | by teInputStr eam.close( ); | |||||
| 591 | re sponseOutS tream.flus h(); | |||||
| 592 | ||||||
| 593 | // this.forwa rd(request , response , "success "); | |||||
| 594 | } | |||||
| 595 | privat e PatientC onsentDirD AO getPati entConsent DirDAO() { | |||||
| 596 | re turn this. getBean("P atientCons entDirDAO" , PatientC onsentDirD AO.class); | |||||
| 597 | } | |||||
| 598 | ||||||
| 599 | privat e MailTemp lateDAO ge tMailTempl ateDAO() { | |||||
| 600 | re turn this. getBean("M ailTemplat eDAO", Mai lTemplateD AO.class); | |||||
| 601 | } | |||||
| 602 | ||||||
| 603 | public ReportHel per getRep ortHelper( ) { | |||||
| 604 | fi nal Report Helper rep ortHelper = this.get Bean("repo rtHelper", | |||||
| 605 | ReportHe lper.class ); | |||||
| 606 | re turn repor tHelper; | |||||
| 607 | } | |||||
| 608 | ||||||
| 609 | privat e Facility DAO getFac ilityDAO() { | |||||
| 610 | re turn this. getBean("F acilityDAO ", Facilit yDAO.class ); | |||||
| 611 | } | |||||
| 612 | ||||||
| 613 | public DocumentH elper getD ocumentHel per() { | |||||
| 614 | re turn this. getBean("a dapterDocu mentHelper ", Documen tHelper.cl ass); | |||||
| 615 | } | |||||
| 616 | ||||||
| 617 | privat e UserDocu mentDAO ge tUserDocum entDAO() { | |||||
| 618 | re turn this. getBean("U serDocumen tDAO", Use rDocumentD AO.class); | |||||
| 619 | } | |||||
| 620 | ||||||
| 621 | /** | |||||
| 622 | * Get the excel exporter class from Spring. | |||||
| 623 | * | |||||
| 624 | * @re turn the e xcel expor ter object | |||||
| 625 | */ | |||||
| 626 | public ExcelExpo rter getEx celExporte r() { | |||||
| 627 | fi nal ExcelE xporter ex celExporte r = this.g etBean("ex celExporte r", | |||||
| 628 | ExcelExp orter.clas s); | |||||
| 629 | re turn excel Exporter; | |||||
| 630 | } | |||||
| 631 | ||||||
| 632 | /** | |||||
| 633 | Inner class for packaging parameters | |||||
| 634 | */ | |||||
| 635 | privat e class Se archPackag e { | |||||
| 636 | pr ivate fina l List<Map <String,Ob ject>> res ults; | |||||
| 637 | pr ivate fina l Long cou nt; | |||||
| 638 | pr ivate fina l String e xpiredNoti ficationLe ttersMaxTi me; | |||||
| 639 | pr ivate fina l String e xpiredNoti ficationPe rLetterTim e; | |||||
| 640 | pr ivate fina l Long row TotalForLe tters; | |||||
| 641 | pr ivate fina l boolean onlyOneSta tionReques ted; | |||||
| 642 | ||||||
| 643 | pu blic Searc hPackage(L ist<Map<St ring, Obje ct>> resul ts, Long c ount, Stri ng expired Notificati onLettersM axTime, | |||||
| 644 | Stri ng expired Notificati onPerLette rTime, Lon g rowTotal ForLetters , boolean oneStation ) { | |||||
| 645 | this.res ults = res ults; | |||||
| 646 | this.cou nt = count ; | |||||
| 647 | this.exp iredNotifi cationLett ersMaxTime = expired Notificati onLettersM axTime; | |||||
| 648 | this.exp iredNotifi cationPerL etterTime = expiredN otificatio nPerLetter Time; | |||||
| 649 | this.row TotalForLe tters = ro wTotalForL etters; | |||||
| 650 | this.onl yOneStatio nRequested = oneStat ion; | |||||
| 651 | } | |||||
| 652 | ||||||
| 653 | pu blic List< Map<String , Object>> getResult s() { | |||||
| 654 | return r esults; | |||||
| 655 | } | |||||
| 656 | ||||||
| 657 | pu blic Long getCount() { | |||||
| 658 | return c ount; | |||||
| 659 | } | |||||
| 660 | ||||||
| 661 | pu blic Strin g getExpir edNotifica tionLetter sMaxTime() { | |||||
| 662 | return e xpiredNoti ficationLe ttersMaxTi me; | |||||
| 663 | } | |||||
| 664 | ||||||
| 665 | pu blic Strin g getExpir edNotifica tionPerLet terTime() { | |||||
| 666 | return e xpiredNoti ficationPe rLetterTim e; | |||||
| 667 | } | |||||
| 668 | ||||||
| 669 | pu blic Long getRowTota lForLetter s() { | |||||
| 670 | return r owTotalFor Letters; | |||||
| 671 | } | |||||
| 672 | ||||||
| 673 | pu blic boole an isOnlyO neStationR equested() { | |||||
| 674 | return o nlyOneStat ionRequest ed; | |||||
| 675 | } | |||||
| 676 | ||||||
| 677 | } | |||||
| 678 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.