Produced by Araxis Merge on 6/9/2017 3:51:26 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:26 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\patient | ExcelGeneratorThread.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 | 1178 |
| 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.patien t; | |||||
| 2 | ||||||
| 3 | import gov .va.med.nh in.adapter .audit.Act ionValuesT ype; | |||||
| 4 | import gov .va.med.nh in.adapter .audit.Aud itSummarie sType; | |||||
| 5 | import gov .va.med.nh in.adapter .audit.Aud itSummaryT ype; | |||||
| 6 | import gov .va.med.nh in.adapter .audit.Aud itType; | |||||
| 7 | import gov .va.med.nh in.adapter .audit.Fie ldType; | |||||
| 8 | import gov .va.med.nh in.adapter .audit.Get Audits; | |||||
| 9 | import gov .va.med.nh in.adapter .audit.Get AuditsResp onse; | |||||
| 10 | import gov .va.med.nh in.adapter .audit.Get AuditsSumm ary; | |||||
| 11 | import gov .va.med.nh in.adapter .audit.Get AuditsSumm aryRespons e; | |||||
| 12 | import gov .va.med.nh in.adapter .audit.Gro upByFields Type; | |||||
| 13 | import gov .va.med.nh in.adapter .audit.Pag eInfoType; | |||||
| 14 | import gov .va.med.nh in.adapter .audit.Sor tDirection ; | |||||
| 15 | import gov .va.med.nh in.adapter .audit.Sor tFieldType ; | |||||
| 16 | import gov .va.med.nh in.adapter .audit.Sor tFieldsTyp e; | |||||
| 17 | import gov .va.med.nh in.adapter .audit.Str ingValuesT ype; | |||||
| 18 | import gov .va.med.nh in.adapter .audit.Sum maryFields Type; | |||||
| 19 | import gov .va.nvap.c ommon.date .Gregorian DateUtil; | |||||
| 20 | import gov .va.nvap.c ommon.sort .BubbleSor tListMap; | |||||
| 21 | import gov .va.nvap.c ommon.tran sformer.Tr ansformerE xception; | |||||
| 22 | import gov .va.nvap.c ommon.vali dation.Nul lChecker; | |||||
| 23 | import gov .va.nvap.c ommon.xpat h.XPathExc eption; | |||||
| 24 | import gov .va.nvap.p rivacy.Org anizationT ype; | |||||
| 25 | import gov .va.nvap.s ervice.ada pter.audit .AdapterAu ditManager ; | |||||
| 26 | import gov .va.nvap.s ervice.ada pter.audit .DirectAud itManager; | |||||
| 27 | import gov .va.nvap.s ervice.ada pter.audit .DirectSer viceExcept ion; | |||||
| 28 | import gov .va.nvap.s ervice.aud it.AuditEx ception; | |||||
| 29 | import gov .va.nvap.s vc.consent mgmt.stub. dao.Delaye dConsentRe portDAO; | |||||
| 30 | import gov .va.nvap.s vc.consent mgmt.stub. dao.MailNo tification DAO; | |||||
| 31 | import gov .va.nvap.s vc.consent mgmt.stub. dao.Patien tConsentDi rDAO; | |||||
| 32 | import gov .va.nvap.s vc.consent mgmt.stub. data.Delay Reason; | |||||
| 33 | import gov .va.nvap.s vc.consent mgmt.stub. data.Delay edConsentR pt; | |||||
| 34 | import gov .va.nvap.s vc.consent mgmt.stub. data.Detai ledConsent Directive; | |||||
| 35 | import gov .va.nvap.s vc.consent mgmt.stub. data.MailN otificatio n; | |||||
| 36 | import gov .va.nvap.w eb.consent .audit.Aud itedConsen tEx; | |||||
| 37 | import gov .va.nvap.w eb.consent .audit.dao .AuditedCo nsentDAO; | |||||
| 38 | import gov .va.nvap.w eb.dao.Use rDocumentD AO; | |||||
| 39 | import gov .va.nvap.w eb.helper. document.D ocumentHel per; | |||||
| 40 | import gov .va.nvap.w eb.helper. facility.F acilityHel per; | |||||
| 41 | import gov .va.nvap.w eb.helper. privacy.Co nsentManag ementHelpe r; | |||||
| 42 | import gov .va.nvap.w eb.helper. report.Rep ortHelper; | |||||
| 43 | import gov .va.nvap.w eb.report. ReportData Processor; | |||||
| 44 | import gov .va.nvap.w eb.user.do cument.Use rDocument; | |||||
| 45 | import gov .va.nvap.w eb.util.Co nstants; | |||||
| 46 | import gov .va.nvap.w eb.util.Fi eldChecks; | |||||
| 47 | import gov .va.nvap.w eb.util.xl s.CsvExpor ter; | |||||
| 48 | import gov .va.nvap.w eb.util.xl s.ExcelExp orter; | |||||
| 49 | import jav a.text.Sim pleDateFor mat; | |||||
| 50 | import jav a.util.Arr ayList; | |||||
| 51 | import jav a.util.Arr ays; | |||||
| 52 | import jav a.util.Col lection; | |||||
| 53 | import jav a.util.Dat e; | |||||
| 54 | import jav a.util.Has hMap; | |||||
| 55 | import jav a.util.Has hSet; | |||||
| 56 | import jav a.util.Lin kedHashMap ; | |||||
| 57 | import jav a.util.Lis t; | |||||
| 58 | import jav a.util.Map ; | |||||
| 59 | import jav a.util.log ging.Level ; | |||||
| 60 | import jav a.util.log ging.Logge r; | |||||
| 61 | import jav ax.servlet .ServletEx ception; | |||||
| 62 | import org .apache.co mmons.lang .StringUti ls; | |||||
| 63 | import org .apache.po i.ss.userm odel.Workb ook; | |||||
| 64 | ||||||
| 65 | /** | |||||
| 66 | * Class t o create a nd run a s eparate th read for g enerating and storin g Excel an d CSV file s | |||||
| 67 | * | |||||
| 68 | * @author Zack Pete rson | |||||
| 69 | */ | |||||
| 70 | public cla ss ExcelGe neratorThr ead implem ents Runna ble{ | |||||
| 71 | ||||||
| 72 | privat e static f inal Logge r logger = | |||||
| 73 | Logger.g etLogger(E xcelGenera torThread. class.getN ame()); | |||||
| 74 | ||||||
| 75 | privat e String t itle; | |||||
| 76 | privat e String u serId; | |||||
| 77 | privat e Map<Stri ng, String > reportMa p; | |||||
| 78 | privat e Map<Stri ng, List<O bject>> fi lterMap; | |||||
| 79 | privat e boolean hasOptiona lRows = fa lse; | |||||
| 80 | privat e boolean isSummaryR eport = fa lse; | |||||
| 81 | privat e ExcelExp orter exEx port; | |||||
| 82 | privat e CsvExpor ter csvExp ort; | |||||
| 83 | privat e AdapterA uditManage r adapterA uditManage r; | |||||
| 84 | privat e DirectAu ditManager directAud itManager; | |||||
| 85 | privat e ReportHe lper repor tHelper; | |||||
| 86 | privat e Facility Helper fac ilityHelpe r; | |||||
| 87 | privat e ConsentM anagementH elper cmsH elper; | |||||
| 88 | privat e Document Helper doc umentHelpe r; | |||||
| 89 | privat e UserDocu mentDAO us erDocDao; | |||||
| 90 | privat e AuditedC onsentDAO auditedCon sentDAO; | |||||
| 91 | privat e PatientC onsentDirD AO patient ConsentDir DAO; | |||||
| 92 | privat e DelayedC onsentRepo rtDAO dela yedConsent ReportDAO; | |||||
| 93 | privat e MailNoti ficationDA O mailNoti ficationDA O; | |||||
| 94 | privat e Map<Stri ng, Object > attribut es; | |||||
| 95 | privat e Map<Stri ng, String > optional RowsMap; | |||||
| 96 | privat e String r eportSourc e; | |||||
| 97 | privat e String d ocumentTyp e; | |||||
| 98 | ||||||
| 99 | // Tot al counter s | |||||
| 100 | privat e int real PatientMes sages = 0; | |||||
| 101 | privat e int real PatientFai ls = 0; | |||||
| 102 | privat e int real PatientMat ches = 0; | |||||
| 103 | privat e int test PatientMes sages = 0; | |||||
| 104 | privat e int test PatientFai ls = 0; | |||||
| 105 | privat e int test PatientMat ches = 0; | |||||
| 106 | privat e long tot alCount = 0l; | |||||
| 107 | privat e int uniq ueRealPati ents = 0; | |||||
| 108 | privat e int uniq ueTestPati ents = 0; | |||||
| 109 | ||||||
| 110 | privat e Thread t hread; | |||||
| 111 | privat e final St ring threa dName; | |||||
| 112 | ||||||
| 113 | public ExcelGene ratorThrea d(String n ame) { | |||||
| 114 | th is.threadN ame = name ; | |||||
| 115 | } | |||||
| 116 | ||||||
| 117 | /** | |||||
| 118 | * Exc el generat ion code f or the new thread | |||||
| 119 | */ | |||||
| 120 | @Overr ide | |||||
| 121 | public void run( ) { | |||||
| 122 | if ("csv".eq uals(docum entType)) { | |||||
| 123 | logger.l og(Level.S EVERE, "EX PORT_CSV_S CHEDULED_B EGIN_" + T hread.curr entThread( ).getId() + " " + Sy stem.curre ntTimeMill is()); | |||||
| 124 | } else { | |||||
| 125 | logger.l og(Level.S EVERE, "EX PORT_EXCEL _SCHEDULED _BEGIN_" + Thread.cu rrentThrea d().getId( ) + " " + System.cur rentTimeMi llis()); | |||||
| 126 | } | |||||
| 127 | // Create in itial inco mplete use r document row | |||||
| 128 | // Using doc ument date to later retrieve d ocument si nce ID is generated | |||||
| 129 | Da te documen tDate = ne w Date(); | |||||
| 130 | Us erDocument userDoc = new UserD ocument(ti tle, docum entDate, u serId, nul l, "In Pro gress"); | |||||
| 131 | if (document Type != nu ll && docu mentType.e quals("csv ")) { | |||||
| 132 | userDoc. setFormat( "CSV"); | |||||
| 133 | } else { | |||||
| 134 | userDoc. setFormat( "Excel"); | |||||
| 135 | } | |||||
| 136 | tr y { | |||||
| 137 | userDocD ao.create( userDoc); | |||||
| 138 | } catch (Exc eption ex) { | |||||
| 139 | logger.l og(Level.S EVERE, "Us er documen t already exists: ", ex); | |||||
| 140 | } | |||||
| 141 | ||||||
| 142 | Li st<Map<Str ing, Objec t>> result s; | |||||
| 143 | tr y { | |||||
| 144 | // Get t he results from the adapter | |||||
| 145 | if (isSu mmaryRepor t) { | |||||
| 146 | resu lts = getS ummaryResu lts(); | |||||
| 147 | } else i f (!NullCh ecker.isNu llOrEmpty( auditedCon sentDAO)) { | |||||
| 148 | try { | |||||
| 149 | results = getAudited ConsentRes ults(); | |||||
| 150 | } ca tch (Servl etExceptio n ex) { | |||||
| 151 | logger.log (Level.SEV ERE, "Fail ed to retr ieve Audit ed Consent data: ", ex); | |||||
| 152 | markDocume ntFailure( documentDa te); | |||||
| 153 | return; | |||||
| 154 | } | |||||
| 155 | } else i f (!NullCh ecker.isNu llOrEmpty( patientCon sentDirDAO )) { | |||||
| 156 | resu lts = getP atientCons entDirResu lts(); | |||||
| 157 | } else i f (!NullCh ecker.isNu llOrEmpty( delayedCon sentReport DAO)) { | |||||
| 158 | resu lts = getD elayedCons entResults (); | |||||
| 159 | } else { | |||||
| 160 | resu lts = getR esults(); | |||||
| 161 | } | |||||
| 162 | } catch (Aud itExceptio n ex) { | |||||
| 163 | logger.l og(Level.S EVERE, "Er ror gettin g report r esults: ", ex); | |||||
| 164 | markDocu mentFailur e(document Date); | |||||
| 165 | return; | |||||
| 166 | } catch (Dir ectService Exception ex) { | |||||
| 167 | logger.l og(Level.S EVERE, "Er ror gettin g report r esults: ", ex); | |||||
| 168 | markDocu mentFailur e(document Date); | |||||
| 169 | return; | |||||
| 170 | } | |||||
| 171 | ||||||
| 172 | if (document Type != nu ll && docu mentType.e quals("csv ")) { | |||||
| 173 | createAn dStoreCsvD ocument(re sults, doc umentDate) ; | |||||
| 174 | } else { | |||||
| 175 | createAn dStoreExce lDocument( results, d ocumentDat e); | |||||
| 176 | } | |||||
| 177 | if ("csv".eq uals(docum entType)) { | |||||
| 178 | logger.l og(Level.S EVERE, "EX PORT_CSV_S CHEDULED_E ND_" + Thr ead.curren tThread(). getId() + " " + Syst em.current TimeMillis ()); | |||||
| 179 | } else { | |||||
| 180 | logger.l og(Level.S EVERE, "EX PORT_EXCEL _SCHEDULED _END_" + T hread.curr entThread( ).getId() + " " + Sy stem.curre ntTimeMill is()); | |||||
| 181 | } | |||||
| 182 | } | |||||
| 183 | ||||||
| 184 | privat e void cre ateAndStor eExcelDocu ment(List< Map<String , Object>> results, Date docum entDate) { | |||||
| 185 | // Clear rep ort map if there are no result s | |||||
| 186 | if (NullChec ker.isNull OrEmpty(re sults)) { | |||||
| 187 | reportMa p.clear(); | |||||
| 188 | reportMa p.put("", "No record s were fou nd."); | |||||
| 189 | } | |||||
| 190 | ||||||
| 191 | Ma p<String, List<Objec t>> option alRows = n ull; | |||||
| 192 | if (hasOptio nalRows) { | |||||
| 193 | try { | |||||
| 194 | opti onalRows = generateO ptionalRow s(); | |||||
| 195 | } catch (NoSuchFie ldExceptio n | Illega lArgumentE xception | IllegalAc cessExcept ion ex) { | |||||
| 196 | logg er.log(Lev el.SEVERE, "An optio nal row do es not hav e a corres ponding ac cessible f ield: ", e x); | |||||
| 197 | } | |||||
| 198 | } | |||||
| 199 | ||||||
| 200 | // Create wo rkbook | |||||
| 201 | fi nal Workbo ok wb = ex Export.exp ortToExcel (title, ti tle, repor tMap, resu lts, filte rMap, opti onalRows); | |||||
| 202 | ||||||
| 203 | tr y { | |||||
| 204 | byte[] d ocBytes = exExport.g etExcelAsB ytes(wb); | |||||
| 205 | ||||||
| 206 | // Get i ncomplete user doc r ow to fill in conten t | |||||
| 207 | UserDocu ment blank Doc = user DocDao.fin dByCreatio nDate(docu mentDate); | |||||
| 208 | if (blan kDoc != nu ll) { | |||||
| 209 | blan kDoc.setCo ntent(docB ytes); | |||||
| 210 | blan kDoc.setSt atus("COMP LETED"); | |||||
| 211 | user DocDao.edi t(blankDoc ); | |||||
| 212 | } else { | |||||
| 213 | User Document n ewDoc = ne w UserDocu ment(title , new Date (), userId , docBytes , "COMPLET ED", "Exce l"); | |||||
| 214 | user DocDao.cre ate(newDoc ); | |||||
| 215 | } | |||||
| 216 | } catch (Exc eption ex) { | |||||
| 217 | logger.l og(Level.S EVERE, "Er ror storin g Excel ex port: ", e x); | |||||
| 218 | markDocu mentFailur e(document Date); | |||||
| 219 | } | |||||
| 220 | } | |||||
| 221 | ||||||
| 222 | privat e void cre ateAndStor eCsvDocume nt(List<Ma p<String, Object>> r esults, Da te documen tDate) { | |||||
| 223 | ||||||
| 224 | St ringBuilde r sbOutput ; | |||||
| 225 | if (NullChec ker.isNull OrEmpty(re sults)) { | |||||
| 226 | sbOutput = new Str ingBuilder (); | |||||
| 227 | sbOutput .append("N o records were found ."); | |||||
| 228 | } else { | |||||
| 229 | SimpleDa teFormat d t = new Si mpleDateFo rmat("MM/d d/yyyy"); | |||||
| 230 | // Alloc ate string builder b ased on th e number o f rows, bu t no large r than 20M B. | |||||
| 231 | if (resu lts.size() > 100000) { | |||||
| 232 | sbOu tput = ne w StringBu ilder(2000 0000); | |||||
| 233 | } else { | |||||
| 234 | sbOu tput = ne w StringBu ilder(resu lts.size() * 200); | |||||
| 235 | } | |||||
| 236 | ||||||
| 237 | // Appen d column h eaders | |||||
| 238 | for (Str ing headin g : report Map.keySet ()) { | |||||
| 239 | sbOu tput.appen d(heading) ; | |||||
| 240 | sbOu tput.appen d(","); | |||||
| 241 | } | |||||
| 242 | sbOutput .append("\ n"); | |||||
| 243 | ||||||
| 244 | // Appen d report d ata | |||||
| 245 | for (Map <String, O bject> row : results ) { | |||||
| 246 | // C reate the row of dat a | |||||
| 247 | Stri ng separat or = ""; | |||||
| 248 | for (String da taField : reportMap. values()) { | |||||
| 249 | sbOutput.a ppend(sepa rator); | |||||
| 250 | separator = ","; | |||||
| 251 | // Include escape ch aracter. | |||||
| 252 | sbOutput.a ppend("\"" ); | |||||
| 253 | ||||||
| 254 | if (NullCh ecker.isNu llOrEmpty( row.get(da taField))) { | |||||
| 255 | sbOutp ut.append( ""); | |||||
| 256 | } else { | |||||
| 257 | if (da taField.co ntains("Da te")) { | |||||
| 258 | // Format da tes. patie ntDateForm atted is a n exceptio n - comes pre-format ted | |||||
| 259 | if (dataFiel d.equals(" patientDat eFormatted ")) { | |||||
| 260 | sbOutput .append(ro w.get(data Field)); | |||||
| 261 | } else { | |||||
| 262 | sbOutput .append(ro w.get(data Field)); | |||||
| 263 | } | |||||
| 264 | } else if (dataF ield.toLow erCase().c ontains("o id") && !N ullChecker .isNullOrE mpty(row.g et(dataFie ld))) { | |||||
| 265 | sb Output.app end(Report Helper.tri mOrgOid((S tring)row. get(dataFi eld))); | |||||
| 266 | } else { | |||||
| 267 | // Else prin t the data as-is. | |||||
| 268 | sb Output.app end(row.ge t(dataFiel d)); | |||||
| 269 | } | |||||
| 270 | } | |||||
| 271 | // Include closing e scape char acter. | |||||
| 272 | sbOutput.a ppend("\"" ); | |||||
| 273 | } | |||||
| 274 | sbOu tput.appen d("\n"); | |||||
| 275 | } | |||||
| 276 | } | |||||
| 277 | ||||||
| 278 | by te[] docBy tes = Stri ng.valueOf (sbOutput) .getBytes( ); | |||||
| 279 | ||||||
| 280 | tr y { | |||||
| 281 | // Get i ncomplete user doc r ow to fill in conten t | |||||
| 282 | UserDocu ment blank Doc = user DocDao.fin dByCreatio nDate(docu mentDate); | |||||
| 283 | if (blan kDoc != nu ll) { | |||||
| 284 | blan kDoc.setCo ntent(docB ytes); | |||||
| 285 | blan kDoc.setSt atus("COMP LETED"); | |||||
| 286 | user DocDao.edi t(blankDoc ); | |||||
| 287 | } else { | |||||
| 288 | User Document n ewDoc = ne w UserDocu ment(title , new Date (), userId , docBytes , "COMPLET ED", "CSV" ); | |||||
| 289 | user DocDao.cre ate(newDoc ); | |||||
| 290 | } | |||||
| 291 | } catch (Exc eption ex) { | |||||
| 292 | logger.l og(Level.S EVERE, "Er ror storin g CSV expo rt: ", ex) ; | |||||
| 293 | markDocu mentFailur e(document Date); | |||||
| 294 | } | |||||
| 295 | } | |||||
| 296 | ||||||
| 297 | /** | |||||
| 298 | * Cre ates new t hread and starts it | |||||
| 299 | */ | |||||
| 300 | public void star t() { | |||||
| 301 | if (thread = = null) { | |||||
| 302 | thread = new Threa d(this, th readName); | |||||
| 303 | thread.s tart(); | |||||
| 304 | } | |||||
| 305 | } | |||||
| 306 | ||||||
| 307 | privat e void mar kDocumentF ailure(Dat e document Date) { | |||||
| 308 | Us erDocument failedDoc = userDoc Dao.findBy CreationDa te(documen tDate); | |||||
| 309 | if (failedDo c != null) { | |||||
| 310 | failedDo c.setStatu s(title); | |||||
| 311 | try { | |||||
| 312 | user DocDao.edi t(failedDo c); | |||||
| 313 | } catch (Exception ex) { | |||||
| 314 | logg er.log(Lev el.SEVERE, "Failed u ser docume nt does no t exist: " , ex); | |||||
| 315 | } | |||||
| 316 | } | |||||
| 317 | } | |||||
| 318 | ||||||
| 319 | // Han dle the ca lculation of optiona l row tota ls here. | |||||
| 320 | privat e Map<Stri ng, List<O bject>> ge nerateOpti onalRows() throws No SuchFieldE xception, IllegalArg umentExcep tion, Ille galAccessE xception { | |||||
| 321 | Ma p<String, List<Objec t>> option alRows = n ew LinkedH ashMap<>() ; | |||||
| 322 | ||||||
| 323 | fo r(Map.Entr y<String, String> en try : opti onalRowsMa p.entrySet ()) { | |||||
| 324 | if(!entr y.getKey() .isEmpty() ) { | |||||
| 325 | List <Object> o ptionalRow List = new ArrayList <>(); | |||||
| 326 | opti onalRowLis t.add(getC lass().get DeclaredFi eld(entry. getKey()). get(this)) ; | |||||
| 327 | opti onalRows.p ut(entry.g etValue(), optionalR owList); | |||||
| 328 | } else { | |||||
| 329 | List <Object> b lank = new ArrayList <>(); | |||||
| 330 | opti onalRows.p ut("", bla nk); | |||||
| 331 | } | |||||
| 332 | } | |||||
| 333 | ||||||
| 334 | re turn optio nalRows; | |||||
| 335 | } | |||||
| 336 | ||||||
| 337 | privat e List<Map <String, O bject>> ge tResults() throws Au ditExcepti on, Direct ServiceExc eption { | |||||
| 338 | fi nal String icn = (St ring) attr ibutes.get ("icn"); | |||||
| 339 | fi nal String ssn = (St ring) attr ibutes.get ("ssn"); | |||||
| 340 | fi nal String lastName = (String) attribute s.get("las tName"); | |||||
| 341 | fi nal String firstName = (String ) attribut es.get("fi rstName"); | |||||
| 342 | fi nal String queryUser Id = (Stri ng) attrib utes.get(" userId"); | |||||
| 343 | fi nal Date s d = (Date) attribute s.get("sta rtDate"); | |||||
| 344 | fi nal Date e d = (Date) attribute s.get("end Date"); | |||||
| 345 | fi nal String purposeOf Use = (Str ing) attri butes.get( "purposeOf Use"); | |||||
| 346 | fi nal String facility = (String) attribute s.get("fac ility"); | |||||
| 347 | fi nal String organizat ion = (Str ing) attri butes.get( "organizat ion"); | |||||
| 348 | fi nal String remoteOrg anization = (String) attribute s.get("rem oteOrganiz ation"); | |||||
| 349 | fi nal int pa tientTypes = (Intege r) attribu tes.get("p atientType s"); | |||||
| 350 | St ring mpiMa tch = (Str ing) attri butes.get( "mpiMatch" ); | |||||
| 351 | // sort | |||||
| 352 | fi nal String sortValue = (String ) attribut es.get("so rtValue"); | |||||
| 353 | fi nal String sortDirec tion = (St ring) attr ibutes.get ("sortDire ction"); | |||||
| 354 | // action va lues | |||||
| 355 | fi nal Action ValuesType actionsTy pe = (Acti onValuesTy pe) attrib utes.get(" actionsTyp e"); | |||||
| 356 | ||||||
| 357 | if (NullChec ker.isNotE mpty(mpiMa tch) && mp iMatch.equ alsIgnoreC ase("all") ) { | |||||
| 358 | mpiMatch = null; | |||||
| 359 | } | |||||
| 360 | ||||||
| 361 | fi nal GetAud its getAud itsRequest = new Get Audits(); | |||||
| 362 | if (NullChec ker.isNotE mpty(sd)) { | |||||
| 363 | getAudit sRequest.s etFromDate (Gregorian DateUtil | |||||
| 364 | .getGregor ianCalenda rByDate(sd )); | |||||
| 365 | } | |||||
| 366 | if (NullChec ker.isNotE mpty(ed)) { | |||||
| 367 | getAudit sRequest.s etToDate(G regorianDa teUtil | |||||
| 368 | .getGregor ianCalenda rByDate(ed )); | |||||
| 369 | } | |||||
| 370 | ||||||
| 371 | // Set Patie nt Types | |||||
| 372 | ge tAuditsReq uest.setPa tientTypes (patientTy pes); | |||||
| 373 | ||||||
| 374 | // Set Patie nt Ids | |||||
| 375 | if (NullChec ker.isNotE mpty(icn)) { | |||||
| 376 | final St ringValues Type patie ntIds = ne w StringVa luesType() ; | |||||
| 377 | patientI ds.getValu e().add(ic n); | |||||
| 378 | patientI ds.setNotI n(false); | |||||
| 379 | getAudit sRequest.s etPatientI ds(patient Ids); | |||||
| 380 | } | |||||
| 381 | // Set SSN | |||||
| 382 | if (NullChec ker.isNotE mpty(ssn)) { | |||||
| 383 | String[] ssns = ss n.split(", "); | |||||
| 384 | final St ringValues Type patie ntSSNs = n ew StringV aluesType( ); | |||||
| 385 | patientS SNs.getVal ue().addAl l(Arrays.a sList(ssns )); | |||||
| 386 | patientS SNs.setNot In(false); | |||||
| 387 | getAudit sRequest.s etPatientS SNs(patien tSSNs); | |||||
| 388 | } | |||||
| 389 | // Set Last Name | |||||
| 390 | if (NullChec ker.isNotE mpty(lastN ame)) { | |||||
| 391 | final St ringValues Type patie ntLastName s = new St ringValues Type(); | |||||
| 392 | patientL astNames.g etValue(). add(lastNa me); | |||||
| 393 | patientL astNames.s etNotIn(fa lse); | |||||
| 394 | getAudit sRequest.s etPatientL astNames(p atientLast Names); | |||||
| 395 | } | |||||
| 396 | // Set First Name | |||||
| 397 | if (NullChec ker.isNotE mpty(first Name)) { | |||||
| 398 | final St ringValues Type patie ntFirstNam es = new S tringValue sType(); | |||||
| 399 | patientF irstNames. getValue() .add(first Name); | |||||
| 400 | patientF irstNames. setNotIn(f alse); | |||||
| 401 | getAudit sRequest.s etPatientG ivenNames( patientFir stNames); | |||||
| 402 | } | |||||
| 403 | // Set User ID | |||||
| 404 | if (NullChec ker.isNotE mpty(query UserId)) { | |||||
| 405 | final St ringValues Type userI ds = new S tringValue sType(); | |||||
| 406 | userIds. getValue() .add(query UserId); | |||||
| 407 | userIds. setNotIn(f alse); | |||||
| 408 | getAudit sRequest.s etUserIds( userIds); | |||||
| 409 | } | |||||
| 410 | // Set Purpo se of Use | |||||
| 411 | if ( !NullCheck er.isNullO rEmpty(pur poseOfUse) ) { | |||||
| 412 | final StringValu esType pur poseForUse s = new St ringValues Type(); | |||||
| 413 | purpos eForUses.g etValue(). add(purpos eOfUse); | |||||
| 414 | purpos eForUses.s etNotIn(fa lse); | |||||
| 415 | getAud itsRequest .setPurpos eForUses(p urposeForU ses); | |||||
| 416 | } | |||||
| 417 | // Set Facil ity Ids | |||||
| 418 | if ( NullChecke r.isNotEmp ty(facilit y)) { | |||||
| 419 | final StringValu esType fac ilityIds = new Strin gValuesTyp e(); | |||||
| 420 | facili tyIds.setN otIn(false ); | |||||
| 421 | facili tyIds.getV alue().add (facility) ; | |||||
| 422 | getAud itsRequest .setPatien tFacilityN umbers(fac ilityIds); | |||||
| 423 | } | |||||
| 424 | // Set Organ ization Id s | |||||
| 425 | if (NullChec ker.isNotE mpty(organ ization)) { | |||||
| 426 | final StringValu esType org anizationI ds = new S tringValue sType(); | |||||
| 427 | organi zationIds. setNotIn(f alse); | |||||
| 428 | organi zationIds. getValue() .add(remot eOrganizat ion); | |||||
| 429 | getAud itsRequest .setOrgani zationIds( organizati onIds); | |||||
| 430 | } el se if ("Di sclosures Detail Rep ort".equal s(title)) { | |||||
| 431 | // For D isclosure Detailed r eport: | |||||
| 432 | // input orgs are empty - in tent is to retrieve all orgs e xcept VA | |||||
| 433 | final St ringValues Type organ izationIds = new Str ingValuesT ype(); | |||||
| 434 | organiza tionIds.se tNotIn(tru e); | |||||
| 435 | organiza tionIds.ge tValue().a dd(cmsHelp er.getComp leteHomeCo mmunityId( )); | |||||
| 436 | getAudit sRequest.s etOrganiza tionIds(or ganization Ids); | |||||
| 437 | } | |||||
| 438 | // Set Remot e Organiza tion Ids | |||||
| 439 | if ( NullChecke r.isNotEmp ty(remoteO rganizatio n)) { | |||||
| 440 | final StringValu esType rem oteOrganiz ationIds = new Strin gValuesTyp e(); | |||||
| 441 | remote Organizati onIds.setN otIn(false ); | |||||
| 442 | remote Organizati onIds.getV alue().add (remoteOrg anization) ; | |||||
| 443 | getAud itsRequest .setRemote Organizati onIds(remo teOrganiza tionIds); | |||||
| 444 | } | |||||
| 445 | ||||||
| 446 | // sorting | |||||
| 447 | if (NullChec ker.isNotE mpty(sortV alue)) { | |||||
| 448 | final So rtFieldTyp e sortFiel d = new So rtFieldTyp e(); | |||||
| 449 | sortFiel d.setField (FieldType .fromValue (sortValue )); | |||||
| 450 | if ("DES C".equalsI gnoreCase( sortDirect ion)) { | |||||
| 451 | sort Field.setD irection(S ortDirecti on.DESC); | |||||
| 452 | } else { | |||||
| 453 | sort Field.setD irection(S ortDirecti on.ASC); | |||||
| 454 | } | |||||
| 455 | final So rtFieldsTy pe sortFie ldsType = new SortFi eldsType() ; | |||||
| 456 | sortFiel dsType.get SortField( ).add(sort Field); | |||||
| 457 | getAudit sRequest.s etSortFiel ds(sortFie ldsType); | |||||
| 458 | } | |||||
| 459 | ||||||
| 460 | // Set Actio n Types | |||||
| 461 | ge tAuditsReq uest.setAc tions(acti onsType); | |||||
| 462 | // Set MPI M atch | |||||
| 463 | if ("all".eq uals(mpiMa tch) || Nu llChecker. isEmpty(mp iMatch)) { | |||||
| 464 | getAudit sRequest.s etDetails( null); | |||||
| 465 | } else { | |||||
| 466 | getAudit sRequest.s etDetails( mpiMatch); | |||||
| 467 | } | |||||
| 468 | // Set Page Informatio n for all results | |||||
| 469 | fi nal PageIn foType pag eInfoType = new Page InfoType() ; | |||||
| 470 | pa geInfoType .setPageNu mber(0); | |||||
| 471 | if ("direct" .equals(re portSource )) { | |||||
| 472 | pageInfo Type.setPa geSize(Int eger.MAX_V ALUE); | |||||
| 473 | } else { | |||||
| 474 | pageInfo Type.setPa geSize(-1) ; | |||||
| 475 | } | |||||
| 476 | ge tAuditsReq uest.setPa geInfo(pag eInfoType) ; | |||||
| 477 | ||||||
| 478 | fi nal List<M ap<String, Object>> results = new ArrayL ist<>(); | |||||
| 479 | tr y { | |||||
| 480 | GetAudit sResponse queryRespo nse; | |||||
| 481 | if ("dir ect".equal s(reportSo urce)) { | |||||
| 482 | quer yResponse = this.dir ectAuditMa nager.getA udits(getA uditsReque st); | |||||
| 483 | } else { | |||||
| 484 | quer yResponse = this.ada pterAuditM anager.get Audits(get AuditsRequ est); | |||||
| 485 | } | |||||
| 486 | ||||||
| 487 | if (Null Checker.is NotEmpty(q ueryRespon se) | |||||
| 488 | && NullChe cker.isNot Empty(quer yResponse. getAudits( )) | |||||
| 489 | && NullChe cker.isNot Empty(quer yResponse. getAudits( ).getAudit ())) { | |||||
| 490 | fina l List<Aud itType> au ditTypeLis t = queryR esponse.ge tAudits(). getAudit() ; | |||||
| 491 | Hash Set<String > uniqueRe alPatients Set = new HashSet<>( ); | |||||
| 492 | Hash Set<String > uniqueTe stPatients Set = new HashSet<>( ); | |||||
| 493 | for (final Aud itType aud itType : a uditTypeLi st) { | |||||
| 494 | final Map< String, Ob ject> resu ltMap = ne w HashMap< >(); | |||||
| 495 | String exp lanationOf Failure = "N/A"; | |||||
| 496 | String pat ientFirstN ame = ""; | |||||
| 497 | String pat ientLastNa me = ""; | |||||
| 498 | String pat ientMiddle Name = ""; | |||||
| 499 | String pat ientSSN = ""; | |||||
| 500 | Boolean mv iFindMatch Failed = n ull; | |||||
| 501 | ||||||
| 502 | String det ails = Rep ortDataPro cessor.nul lEmptyRepl aceWithUnk nown(audit Type.getDe tails()); | |||||
| 503 | if (detail s.startsWi th("QUERY FAILED")) { | |||||
| 504 | explan ationOfFai lure = "MV I: Query F ailed"; | |||||
| 505 | mviFin dMatchFail ed = true; | |||||
| 506 | } else if (details.s tartsWith( "MATCH FAI LED")) { | |||||
| 507 | explan ationOfFai lure = "MV I: Match N ot Found"; | |||||
| 508 | mviFin dMatchFail ed = true; | |||||
| 509 | } else if (details.s tartsWith( "AMBIGUOUS FAILED")) { | |||||
| 510 | explan ationOfFai lure = "MV I: Ambiguo us Match"; | |||||
| 511 | mviFin dMatchFail ed = true; | |||||
| 512 | } else if (details.s tartsWith( "MATCH FOU ND")) { | |||||
| 513 | mviFin dMatchFail ed = false ; | |||||
| 514 | } | |||||
| 515 | resultMap. put("failu reExplanat ion", expl anationOfF ailure); | |||||
| 516 | ||||||
| 517 | if (Boolea n.TRUE.equ als(mviFin dMatchFail ed)) { | |||||
| 518 | patien tFirstName = reportH elper.extr actFromDet ails(detai ls, "FIRST NAME"); | |||||
| 519 | patien tLastName = reportHe lper.extra ctFromDeta ils(detail s, "LASTNA ME"); | |||||
| 520 | patien tMiddleNam e = report Helper.ext ractFromDe tails(deta ils, "MIDD LENAME"); | |||||
| 521 | patien tSSN = rep ortHelper. extractFro mDetails(d etails, "S SN"); | |||||
| 522 | } | |||||
| 523 | if (patien tSSN.lengt h() == 0) { | |||||
| 524 | patien tSSN = aud itType.get PatientSSN (); | |||||
| 525 | } | |||||
| 526 | ||||||
| 527 | // SSN | |||||
| 528 | ReportData Processor. addSsnToRe sultMap(re sultMap, p atientSSN) ; | |||||
| 529 | ||||||
| 530 | boolean is TestPatien t = report Helper.isT estPatient (resultMap .get("ssn" ).toString ()); | |||||
| 531 | ||||||
| 532 | if (NullCh ecker.isNo tEmpty(pat ientSSN)) { | |||||
| 533 | if (is TestPatien t) { | |||||
| 534 | if (!uniqueT estPatient sSet.conta ins(patien tSSN)) { | |||||
| 535 | uniqueTe stPatients Set.add(pa tientSSN); | |||||
| 536 | } | |||||
| 537 | } else { | |||||
| 538 | if (!uniqueR ealPatient sSet.conta ins(patien tSSN)) { | |||||
| 539 | uniqueRe alPatients Set.add(pa tientSSN); | |||||
| 540 | } | |||||
| 541 | } | |||||
| 542 | } | |||||
| 543 | ||||||
| 544 | if (isTest Patient) { | |||||
| 545 | testPa tientMessa ges++; | |||||
| 546 | if (Bo olean.TRUE .equals(mv iFindMatch Failed)) { | |||||
| 547 | te stPatientF ails++; | |||||
| 548 | } else if (Boole an.FALSE.e quals(mviF indMatchFa iled)) { | |||||
| 549 | te stPatientM atches++; | |||||
| 550 | } | |||||
| 551 | } else { | |||||
| 552 | realPa tientMessa ges++; | |||||
| 553 | if (Bo olean.TRUE .equals(mv iFindMatch Failed)) { | |||||
| 554 | re alPatientF ails++; | |||||
| 555 | } else if (Boole an.FALSE.e quals(mviF indMatchFa iled)) { | |||||
| 556 | re alPatientM atches++; | |||||
| 557 | } | |||||
| 558 | } | |||||
| 559 | ||||||
| 560 | // First n ame. | |||||
| 561 | if (patien tFirstName .length() == 0) { | |||||
| 562 | patien tFirstName = ReportD ataProcess or.nullEmp tyReplaceW ithUnknown (auditType .getPatien tGivenName ()); | |||||
| 563 | } | |||||
| 564 | resultMap. put("first Name", pat ientFirstN ame); | |||||
| 565 | ||||||
| 566 | // Middle name. | |||||
| 567 | if (patien tMiddleNam e.length() == 0) { | |||||
| 568 | patien tMiddleNam e = Repor tDataProce ssor.nullE mptyReplac eWithUnkno wn(auditTy pe.getPati entMiddleN ame()); | |||||
| 569 | } | |||||
| 570 | if ("Unkno wn".equals IgnoreCase (patientMi ddleName)) { | |||||
| 571 | patien tMiddleNam e = ""; | |||||
| 572 | } | |||||
| 573 | resultMap. put("middl eName", pa tientMiddl eName); | |||||
| 574 | ||||||
| 575 | // Last na me. | |||||
| 576 | if (patien tLastName. length() = = 0) { | |||||
| 577 | patien tLastName = ReportDa taProcesso r.nullEmpt yReplaceWi thUnknown( auditType. getPatient LastName() ); | |||||
| 578 | } | |||||
| 579 | resultMap. put("lastN ame", pati entLastNam e); | |||||
| 580 | ||||||
| 581 | // Patient preferred facility | |||||
| 582 | resultMap. put("patie ntFacility Name", Rep ortDataPro cessor | |||||
| 583 | .fix Station(au ditType.ge tPatientFa cilityName ())); | |||||
| 584 | resultMap. put("patie ntFacility Number", R eportDataP rocessor | |||||
| 585 | .nul lEmptyRepl aceWithUnk nown(audit Type | |||||
| 586 | .getPati entFacilit yNumber()) ); | |||||
| 587 | ||||||
| 588 | resultMap. put("organ izationNam e", report Helper.fin dOrganizat ionByOid(a uditType.g etOrganiza tionId(), auditType. getOrganiz ationName( ))); | |||||
| 589 | resultMap. put("facil ityOid", R eportDataP rocessor | |||||
| 590 | .nullE mptyReplac eWithUnkno wn(auditTy pe | |||||
| 591 | .g etOrganiza tionId())) ; | |||||
| 592 | ||||||
| 593 | resultMap. put("remot eOrganizat ionName", reportHelp er.findOrg anizationB yOid(audit Type.getRe moteOrgani zationId() , | |||||
| 594 | au ditType.ge tRemoteOrg anizationN ame())); | |||||
| 595 | ||||||
| 596 | resultMap. put("remot eFacilityO id", Repor tDataProce ssor.nullE mptyReplac eWithUnkno wn( | |||||
| 597 | au ditType.ge tRemoteOrg anizationI d())); | |||||
| 598 | ||||||
| 599 | resultMap. put("icn", ReportDat aProcessor .nullEmpty ReplaceWit hUnknown(a uditType.g etPatientI d())); | |||||
| 600 | resultMap. put("audit Time", Gre gorianDate Util.getDa teFromGreg orianCalen dar(auditT ype.getAud itTime())) ; | |||||
| 601 | resultMap. put("audit TimeFormat ted", | |||||
| 602 | re portHelper .getFormat tedDateTim e( | |||||
| 603 | Gr egorianDat eUtil | |||||
| 604 | .g etDateFrom GregorianC alendar(au ditType | |||||
| 605 | .g etAuditTim e()))); | |||||
| 606 | ||||||
| 607 | String use rIdString = ReportDa taProcesso r.nullEmpt yReplaceWi thUnknown( auditType. getUserId( )).replace (" ? ", " "); | |||||
| 608 | resultMap. put("userI d", userId String); | |||||
| 609 | ||||||
| 610 | //Parse th e user id field for facility c ode and us er name on ly if this is Receiv ed Documen ts Detaile d Report | |||||
| 611 | if ("RECEI VED EHEALT H EXCHANGE DOCUMENTS DETAIL RE PORT".equa ls(this.ti tle.toUppe rCase())) { | |||||
| 612 | if (use rIdString. length() > 4 && user IdString.s ubstring(0 ,4).matche s("^\\d{3} :")){ | |||||
| 613 | re sultMap.pu t("userFac ilityCode" , userIdSt ring.subst ring(0,3)) ; | |||||
| 614 | if (facility Helper != null) { | |||||
| 615 | resultMa p.put("use rFacilityN ame", faci lityHelper .getFacili tyNameBySt ationId(us erIdString .substring (0,3))); | |||||
| 616 | } | |||||
| 617 | } | |||||
| 618 | ||||||
| 619 | if (us erIdString .indexOf(" CN=") > 0) { | |||||
| 620 | re sultMap.pu t("userNam e",userIdS tring.subs tring((use rIdString. indexOf("C N=") + 3), | |||||
| 621 | userIdSt ring.index Of(",", us erIdString .indexOf(" CN=")))); | |||||
| 622 | } | |||||
| 623 | } | |||||
| 624 | ||||||
| 625 | resultMap. put("purpo seForUse", ReportDat aProcessor | |||||
| 626 | .n ullEmptyRe placeWithU nknown(aud itType | |||||
| 627 | .g etPurposeF orUse())); | |||||
| 628 | ||||||
| 629 | if (NullCh ecker.isNo tEmpty(aud itType.get Action())) { | |||||
| 630 | result Map.put("m essage", a uditType.g etAction() .name()); | |||||
| 631 | } | |||||
| 632 | ||||||
| 633 | details = processDet ails(detai ls); | |||||
| 634 | ||||||
| 635 | resultMap. put("detai ls", detai ls); | |||||
| 636 | ||||||
| 637 | resultMap. put("docum entId", Re portDataPr ocessor | |||||
| 638 | .nul lEmptyRepl aceWithUnk nown(audit Type | |||||
| 639 | .getDocu mentId())) ; | |||||
| 640 | resultMap. put("docum entTitle", ReportDat aProcessor | |||||
| 641 | .nul lEmptyRepl aceWithUnk nown(audit Type | |||||
| 642 | .getDocu mentTitle( ))); | |||||
| 643 | resultMap. put("roleN ame", Repo rtDataProc essor | |||||
| 644 | .nul lEmptyRepl aceWithUnk nown(audit Type | |||||
| 645 | .getRole Name())); | |||||
| 646 | ||||||
| 647 | results.ad d(resultMa p); | |||||
| 648 | } | |||||
| 649 | uniq ueRealPati ents = uni queRealPat ientsSet.s ize(); | |||||
| 650 | uniq ueTestPati ents = uni queTestPat ientsSet.s ize(); | |||||
| 651 | } | |||||
| 652 | ||||||
| 653 | return r esults; | |||||
| 654 | ||||||
| 655 | } catch (fin al AuditEx ception ex ) { | |||||
| 656 | throw ne w AuditExc eption(); | |||||
| 657 | } catch (fin al DirectS erviceExce ption ex) { | |||||
| 658 | throw ne w DirectSe rviceExcep tion(); | |||||
| 659 | } | |||||
| 660 | ||||||
| 661 | } | |||||
| 662 | ||||||
| 663 | privat e List<Map <String, O bject>> ge tSummaryRe sults() th rows Audit Exception { | |||||
| 664 | fi nal String queryUser Id = (Stri ng) attrib utes.get(" userId"); | |||||
| 665 | fi nal Date s d = (Date) attribute s.get("sta rtDate"); | |||||
| 666 | fi nal Date e d = (Date) attribute s.get("end Date"); | |||||
| 667 | fi nal String patientFa cility = ( String) at tributes.g et("facili ty"); | |||||
| 668 | fi nal String organizat ion = (Str ing) attri butes.get( "organizat ion"); | |||||
| 669 | fi nal String remoteOrg anization = (String) attribute s.get("rem oteOrganiz ation"); | |||||
| 670 | fi nal int pa tientTypes = (Intege r) attribu tes.get("p atientType s"); | |||||
| 671 | // sort | |||||
| 672 | fi nal String sortValue = (String ) attribut es.get("so rtValue"); | |||||
| 673 | fi nal String sortDirec tion = (St ring) attr ibutes.get ("sortDire ction"); | |||||
| 674 | // action va lues | |||||
| 675 | fi nal Action ValuesType actionsTy pe = (Acti onValuesTy pe) attrib utes.get(" actionsTyp e"); | |||||
| 676 | // group by values | |||||
| 677 | fi nal GroupB yFieldsTyp e groupByF ieldsType = (GroupBy FieldsType ) attribut es.get("gr oupByField sType"); | |||||
| 678 | ||||||
| 679 | fi nal GetAud itsSummary getAudits SummaryReq uest = new GetAudits Summary(); | |||||
| 680 | ||||||
| 681 | // Set start date | |||||
| 682 | if (NullChec ker.isNotE mpty(sd)) { | |||||
| 683 | getAudit sSummaryRe quest.setF romDate(Gr egorianDat eUtil.getG regorianCa lendarByDa te(sd)); | |||||
| 684 | } | |||||
| 685 | ||||||
| 686 | // Set end d ate | |||||
| 687 | if (NullChec ker.isNotE mpty(ed)) { | |||||
| 688 | getAudit sSummaryRe quest.setT oDate(Greg orianDateU til.getGre gorianCale ndarByDate (ed)); | |||||
| 689 | } | |||||
| 690 | ||||||
| 691 | // Set user ID | |||||
| 692 | if (NullChec ker.isNotE mpty(query UserId)) { | |||||
| 693 | final St ringValues Type userI dValue = n ew StringV aluesType( ); | |||||
| 694 | userIdVa lue.getVal ue().add(q ueryUserId ); | |||||
| 695 | userIdVa lue.setNot In(false); | |||||
| 696 | getAudit sSummaryRe quest.setU serIds(use rIdValue); | |||||
| 697 | } | |||||
| 698 | ||||||
| 699 | // Set patie nt preferr ed facilit y | |||||
| 700 | if (!NullChe cker.isNul lOrEmpty(p atientFaci lity)) { | |||||
| 701 | final St ringValues Type patie ntFacilyNu mber = new StringVal uesType(); | |||||
| 702 | patientF acilyNumbe r.setNotIn (false); | |||||
| 703 | final Li st<String> patientFa cilyNumber List = pat ientFacily Number.get Value(); | |||||
| 704 | patientF acilyNumbe rList.add( patientFac ility); | |||||
| 705 | getAudit sSummaryRe quest.setP atientFaci lityNumber s(patientF acilyNumbe r); | |||||
| 706 | } | |||||
| 707 | ||||||
| 708 | // Set partn er organiz ation | |||||
| 709 | if (NullChec ker.isNotE mpty(organ ization)) { | |||||
| 710 | final St ringValues Type orgTy pes = new StringValu esType(); | |||||
| 711 | orgTypes .getValue( ).add(orga nization); | |||||
| 712 | getAudit sSummaryRe quest.setO rganizatio nIds(orgTy pes); | |||||
| 713 | } | |||||
| 714 | ||||||
| 715 | if (NullChec ker.isNotE mpty(remot eOrganizat ion)) { | |||||
| 716 | final St ringValues Type remot eOrgTypes = new Stri ngValuesTy pe(); | |||||
| 717 | remoteOr gTypes.get Value().ad d(remoteOr ganization ); | |||||
| 718 | getAudit sSummaryRe quest.setR emoteOrgan izationIds (remoteOrg Types); | |||||
| 719 | } | |||||
| 720 | ||||||
| 721 | // Set patie nt types | |||||
| 722 | ge tAuditsSum maryReques t.setPatie ntTypes(pa tientTypes ); | |||||
| 723 | ||||||
| 724 | // Set actio n types | |||||
| 725 | ge tAuditsSum maryReques t.setActio ns(actions Type); | |||||
| 726 | ||||||
| 727 | // Group by | |||||
| 728 | ge tAuditsSum maryReques t.setGroup ByFields(g roupByFiel dsType); | |||||
| 729 | ||||||
| 730 | Li st<Map<Str ing, Objec t>> result s = null; | |||||
| 731 | tr y { | |||||
| 732 | // Get s ummary lis t from Exc hange | |||||
| 733 | GetAudit sSummaryRe sponse get AuditsSumm aryRespons e = this.a dapterAudi tManager.g etAuditSum mary(getAu ditsSummar yRequest); | |||||
| 734 | ||||||
| 735 | // Const ruct resul ts for the jsp page | |||||
| 736 | results = new Arra yList<>(); | |||||
| 737 | final Au ditSummari esType aud itSummarie sType = ge tAuditsSum maryRespon se.getAudi tSummaries (); | |||||
| 738 | ||||||
| 739 | List<Aud itSummaryT ype> audit Summary = new ArrayL ist<>(); | |||||
| 740 | if (audi tSummaries Type != nu ll) { | |||||
| 741 | audi tSummary = auditSumm ariesType. getAuditSu mmary(); | |||||
| 742 | } | |||||
| 743 | ||||||
| 744 | for (fin al AuditSu mmaryType auditSumma ryType : a uditSummar y) { | |||||
| 745 | fina l Map<Stri ng, Object > resultMa p = new Ha shMap<>(); | |||||
| 746 | fina l long cou nt = audit SummaryTyp e.getCount (); | |||||
| 747 | fina l SummaryF ieldsType summaryFie lds = audi tSummaryTy pe.getSumm aryFields( ); | |||||
| 748 | fina l List<Str ing> summa ryField = summaryFie lds.getSum maryField( ); | |||||
| 749 | ||||||
| 750 | if ( NullChecke r.isEmpty( summaryFie ld)) { | |||||
| 751 | continue; | |||||
| 752 | } | |||||
| 753 | ||||||
| 754 | if ( summaryFie ld.size() < 4) { | |||||
| 755 | continue; | |||||
| 756 | } | |||||
| 757 | ||||||
| 758 | // P artner org anization | |||||
| 759 | Orga nizationTy pe organiz ationType = null; | |||||
| 760 | if ( NullChecke r.isNotEmp ty(summary Field.get( 0))) { | |||||
| 761 | organizati onType = ( cmsHelper. getOrganiz ationByHom eCommunity Id(summary Field.get( 0).replace ("urn:oid: ", ""))); | |||||
| 762 | } | |||||
| 763 | if ( organizati onType != null) { | |||||
| 764 | resultMap. put("partn erOrg", Re portDataPr ocessor.nu llEmptyRep laceWithUn known(orga nizationTy pe.getOrgN ame())); | |||||
| 765 | } el se { | |||||
| 766 | resultMap. put("partn erOrg", Re portDataPr ocessor.nu llEmptyRep laceWithUn known(summ aryField.g et(3))); | |||||
| 767 | } | |||||
| 768 | ||||||
| 769 | // P atient pre ferred fac ility | |||||
| 770 | fina l String a dapterVAFa cility = s ummaryFiel d.get(1); | |||||
| 771 | Stri ng vaFacil ity; | |||||
| 772 | if ( ReportData Processor. isValidSta tion(adapt erVAFacili ty)) { | |||||
| 773 | vaFacility = facilit yHelper.ge tFacilityN ameByStati onId(adapt erVAFacili ty); | |||||
| 774 | if (NullCh ecker.isEm pty(vaFaci lity)) { | |||||
| 775 | vaFaci lity = sum maryField. get(2); | |||||
| 776 | } | |||||
| 777 | } el se { | |||||
| 778 | vaFacility = summary Field.get( 2); | |||||
| 779 | } | |||||
| 780 | resu ltMap.put( "vaFacilit y", Report DataProces sor.fixSta tion(vaFac ility)); | |||||
| 781 | ||||||
| 782 | // A udits coun t | |||||
| 783 | resu ltMap.put( "auditsCou nt", count ); | |||||
| 784 | ||||||
| 785 | // T he rest of the value s are simp ly copied from audit Summary | |||||
| 786 | resu ltMap.put( "countUniq ueRealPati ents", Str ingUtils.i sNumeric(s ummaryFiel d.get(4)) ? Long.par seLong(sum maryField. get(4)) : 0); | |||||
| 787 | resu ltMap.put( "countUniq ueTestPati ents", Str ingUtils.i sNumeric(s ummaryFiel d.get(5)) ? Long.par seLong(sum maryField. get(5)) : 0); | |||||
| 788 | resu ltMap.put( "matchesFo undRealPat ients", St ringUtils. isNumeric( summaryFie ld.get(6)) ? Long.pa rseLong(su mmaryField .get(6)) : 0); | |||||
| 789 | resu ltMap.put( "matchesFo undTestPat ients", St ringUtils. isNumeric( summaryFie ld.get(7)) ? Long.pa rseLong(su mmaryField .get(7)) : 0); | |||||
| 790 | resu ltMap.put( "matchFail sRealPatie nts", Stri ngUtils.is Numeric(su mmaryField .get(8)) ? Long.pars eLong(summ aryField.g et(8)) : 0 ); | |||||
| 791 | resu ltMap.put( "matchFail sTestPatie nts", Stri ngUtils.is Numeric(su mmaryField .get(9)) ? Long.pars eLong(summ aryField.g et(9)) : 0 ); | |||||
| 792 | ||||||
| 793 | resu lts.add(re sultMap); | |||||
| 794 | tota lCount += count; | |||||
| 795 | } | |||||
| 796 | ||||||
| 797 | // Sort | |||||
| 798 | if (Null Checker.is NotEmpty(s ortValue) && NullChe cker.isNot Empty(sort Direction) ) { | |||||
| 799 | bool ean ascend ing = !sor tDirection .equalsIgn oreCase("D ESC"); | |||||
| 800 | fina l BubbleSo rtListMap bSorter = new Bubble SortListMa p(); | |||||
| 801 | resu lts = bSor ter.sortBy Column(res ults, sort Value, asc ending); | |||||
| 802 | } | |||||
| 803 | } catch (fin al AuditEx ception ex ) { | |||||
| 804 | throw ne w AuditExc eption(ex) ; | |||||
| 805 | } | |||||
| 806 | ||||||
| 807 | re turn resul ts; | |||||
| 808 | } | |||||
| 809 | ||||||
| 810 | privat e List<Map <String, O bject>> ge tAuditedCo nsentResul ts() throw s ServletE xception { | |||||
| 811 | fi nal Audite dConsentDA O.DetailRe quest req = auditedC onsentDAO. new Detail Request(); | |||||
| 812 | ||||||
| 813 | re q.patientF irstName = (String) attributes .get("firs tName"); | |||||
| 814 | re q.patientL astName = (String) a ttributes. get("lastN ame"); | |||||
| 815 | re q.patientS sn = (Stri ng) attrib utes.get(" ssn"); | |||||
| 816 | re q.stationN umbers = ( String) at tributes.g et("statio nNumbers") ; | |||||
| 817 | re q.consentT ype = (Str ing) attri butes.get( "consentTy pe"); | |||||
| 818 | re q.inactiva tionReason = (String ) attribut es.get("in activation Reason"); | |||||
| 819 | re q.startDat e = (Date) attribute s.get("sta rtDate"); | |||||
| 820 | re q.endDate = (Date) a ttributes. get("endDa te"); | |||||
| 821 | re q.patientT ypes = (In teger) att ributes.ge t("patient Types"); | |||||
| 822 | re q.userId = (String) attributes .get("user Id"); | |||||
| 823 | re q.includeU nknownVisn = (Boolea n) attribu tes.get("i ncludeUnkn ownVisn"); | |||||
| 824 | re q.sortFiel d = (Strin g) attribu tes.get("s ortValue") ; | |||||
| 825 | re q.sortDire ction = (S tring) att ributes.ge t("sortDir ection"); | |||||
| 826 | re q.currentP age = 0; | |||||
| 827 | re q.pageSize = -1; | |||||
| 828 | ||||||
| 829 | Li st<String> actionTyp es = (List <String>) attributes .get("acti onTypes"); | |||||
| 830 | ||||||
| 831 | // The resul t of the q uery is a list of ar rays. | |||||
| 832 | // Each arra y is a [Au ditedConse nt, Facili ty, Visn] | |||||
| 833 | Li st<Object> auditedCo nsentExLis t = audite dConsentDA O.getEvent s(req); | |||||
| 834 | ||||||
| 835 | fi nal List<M ap<String, Object>> results = new ArrayL ist<>(); | |||||
| 836 | if (NullChec ker.isNotE mpty(audit edConsentE xList)) { | |||||
| 837 | for (fin al Object o : audite dConsentEx List) { | |||||
| 838 | Audi tedConsent Ex auditTy pe = (Audi tedConsent Ex) o; | |||||
| 839 | ||||||
| 840 | fina l Map<Stri ng, Object > resultMa p = new Ha shMap<>(); | |||||
| 841 | ||||||
| 842 | // R eplace SSN with Mask | |||||
| 843 | Repo rtDataProc essor.addS snToResult Map(result Map, audit Type.getPa tientSsn() ); | |||||
| 844 | ||||||
| 845 | resu ltMap.put( "icn", aud itType.get PatientId( )); | |||||
| 846 | resu ltMap.put( "auditTime ", auditTy pe.getTime OfEvent()) ; | |||||
| 847 | resu ltMap.put( "auditTime Formatted" , reportHe lper | |||||
| 848 | .getFormat tedDateTim e(auditTyp e.getTimeO fEvent())) ; | |||||
| 849 | resu ltMap.put( "userId", auditType. getUserId( )); | |||||
| 850 | resu ltMap.put( "actionTyp e", auditT ype.getAct ionType()) ; | |||||
| 851 | ||||||
| 852 | Stri ng consent TypeRow = auditType. getConsent Type(); | |||||
| 853 | if ( consentTyp eRow.conta ins("NwHIN ")) { | |||||
| 854 | consentTyp eRow = con sentTypeRo w.replace( "NwHIN", C onstants.g etOrganiza tionName() ); | |||||
| 855 | } | |||||
| 856 | resu ltMap.put( "consentTy pe", conse ntTypeRow) ; | |||||
| 857 | resu ltMap.put( "firstName ", auditTy pe.getPati entGivenNa me()); | |||||
| 858 | resu ltMap.put( "lastName" , auditTyp e.getPatie ntLastName ()); | |||||
| 859 | resu ltMap.put( "purposeOf Use", audi tType.getP ouValue()) ; | |||||
| 860 | ||||||
| 861 | Stri ng inactiv ationReaso nRow = aud itType.get OptoutReas on(); | |||||
| 862 | resu ltMap.put( "inactivat ionReason" , inactiva tionReason Row); | |||||
| 863 | resu ltMap.put( "patientDa te", audit Type.getCr eatedDate( )); | |||||
| 864 | resu ltMap.put( "patientDa teFormatte d", report Helper | |||||
| 865 | .getFormat tedDate(au ditType.ge tCreatedDa te())); | |||||
| 866 | ||||||
| 867 | resu ltMap.put( "facilityN ame", Repo rtDataProc essor | |||||
| 868 | .fixStatio n(auditTyp e.getFacil ityName()) ); | |||||
| 869 | resu ltMap.put( "facilityI d", auditT ype.getFac ility()); | |||||
| 870 | resu ltMap.put( "visnName" , NullChec ker.isNull OrEmpty(au ditType.ge tVisnName( )) ? "Unkn own" : aud itType.get VisnName() ); | |||||
| 871 | ||||||
| 872 | if ( actionType s.contains (auditType .getAction Type())) { | |||||
| 873 | resultMap. put("audit Id", audit Type.getCo nsentAudit Id()); | |||||
| 874 | } | |||||
| 875 | resu lts.add(Fi eldChecks. replaceEmp tyOrNullWi thSpace(re sultMap)); | |||||
| 876 | } | |||||
| 877 | } | |||||
| 878 | ||||||
| 879 | re turn resul ts; | |||||
| 880 | } | |||||
| 881 | ||||||
| 882 | public List<Map< String, Ob ject>> get PatientCon sentDirRes ults() { | |||||
| 883 | ||||||
| 884 | Da te startDa te = (Date ) attribut es.get("st artDate"); | |||||
| 885 | Da te endDate = (Date) attributes .get("endD ate"); | |||||
| 886 | fi nal Patien tConsentDi rDAO.Searc hRequest s earchReque st = patie ntConsentD irDAO.new SearchRequ est(); | |||||
| 887 | ||||||
| 888 | se archReques t.startDat e = startD ate; | |||||
| 889 | se archReques t.endDate = endDate; | |||||
| 890 | se archReques t.stationN umbers = ( String) at tributes.g et("statio nNumbers") ; | |||||
| 891 | se archReques t.includeU nknownVisn = (Boolea n) attribu tes.get("i ncludeUnkn ownVisn"); | |||||
| 892 | se archReques t.consentT ypeName = ""; | |||||
| 893 | if (!NullChe cker.isNul lOrEmpty(a ttributes. get("conse ntTypeName "))) { | |||||
| 894 | searchRe quest.cons entTypeNam e = (Strin g) attribu tes.get("c onsentType Name"); | |||||
| 895 | } | |||||
| 896 | se archReques t.userId = (String) attributes .get("user Id"); | |||||
| 897 | ||||||
| 898 | fi nal String inboundSo rtValue = (String) a ttributes. get("sortV alue"); | |||||
| 899 | fi nal String inboundSo rtDirectio n = (Strin g) attribu tes.get("s ortDirecti on"); | |||||
| 900 | ||||||
| 901 | fi nal int pa tientTypes = (Intege r) attribu tes.get("p atientType s"); | |||||
| 902 | ||||||
| 903 | se archReques t.patientT ypes = pat ientTypes; | |||||
| 904 | ||||||
| 905 | // For use i n sorting results | |||||
| 906 | if (NullChec ker.isNotE mpty(inbou ndSortValu e)) { | |||||
| 907 | searchRe quest.sort By = inbou ndSortValu e; | |||||
| 908 | } | |||||
| 909 | if (NullChec ker.isNotE mpty(inbou ndSortDire ction)) { | |||||
| 910 | searchRe quest.sort Order = in boundSortD irection; | |||||
| 911 | } | |||||
| 912 | ||||||
| 913 | se archReques t.fromPage = 0; | |||||
| 914 | se archReques t.recordsP erPage = - 1; | |||||
| 915 | ||||||
| 916 | fi nal List<M ap<String, Object>> results = new ArrayL ist<>(); | |||||
| 917 | tr y { | |||||
| 918 | ||||||
| 919 | final Pa tientConse ntDirDAO.S earchRespo nse search Response = patientCo nsentDirDA O.find(sea rchRequest ); | |||||
| 920 | ||||||
| 921 | if (sear chResponse != null) { | |||||
| 922 | ||||||
| 923 | if ( (searchRes ponse.cons ents != nu ll) | |||||
| 924 | && (search Response.c onsents.si ze() > 0)) { | |||||
| 925 | ||||||
| 926 | for (Detai ledConsent Directive detailedCo nsentRefer ence : sea rchRespons e.consents ) { | |||||
| 927 | final Map<String , Object> resultMap = new Hash Map<>(); | |||||
| 928 | if (de tailedCons entReferen ce != null ) { | |||||
| 929 | Re portDataPr ocessor.ad dSsnToResu ltMap(resu ltMap, det ailedConse ntReferenc e.getSsn() ); | |||||
| 930 | re sultMap.pu t("lastNam e", detail edConsentR eference.g etLastName ()); | |||||
| 931 | re sultMap.pu t("firstNa me", detai ledConsent Reference. getFirstNa me()); | |||||
| 932 | re sultMap.pu t("middleN ame", deta iledConsen tReference .getMiddle Name()); | |||||
| 933 | St ring conse ntTypeName = detaile dConsentRe ference.ge tOptinCons entType(). getName(); | |||||
| 934 | if (consentT ypeName.co ntains("Nw HIN")) { | |||||
| 935 | consentT ypeName = consentTyp eName.repl ace("NwHIN ", Constan ts.getOrga nizationNa me()); | |||||
| 936 | } | |||||
| 937 | re sultMap.pu t("consent TypeName", consentTy peName); | |||||
| 938 | ||||||
| 939 | Si mpleDateFo rmat dt = new Simple DateFormat ("MM/dd/yy yy"); | |||||
| 940 | re sultMap.pu t("optInDa te", dt.fo rmat(detai ledConsent Reference. getOptinDa te())); | |||||
| 941 | re sultMap.pu t("expirat ionDate", dt.format( detailedCo nsentRefer ence.getEx pirationDa te())); | |||||
| 942 | ||||||
| 943 | re sultMap.pu t("facilit yName", de tailedCons entReferen ce.getFaci lityName() ); | |||||
| 944 | re sultMap.pu t("userId" , detailed ConsentRef erence.get UserId()); | |||||
| 945 | re sults.add( resultMap) ; | |||||
| 946 | } | |||||
| 947 | } | |||||
| 948 | } | |||||
| 949 | } | |||||
| 950 | } catch (fin al Excepti on ex) { | |||||
| 951 | throw ne w RuntimeE xception(e x); | |||||
| 952 | } | |||||
| 953 | ||||||
| 954 | re turn resul ts; | |||||
| 955 | } | |||||
| 956 | ||||||
| 957 | public List<Map< String, Ob ject>> get DelayedCon sentResult s() { | |||||
| 958 | De layedConse ntReportDA O.SearchAl lRequest s earchReque st = delay edConsentR eportDAO.n ew SearchA llRequest( ); | |||||
| 959 | ||||||
| 960 | // Get param eters for the search from the request. | |||||
| 961 | se archReques t.patientS sn = (Stri ng) attrib utes.get(" ssn"); | |||||
| 962 | se archReques t.patientL astName = (String) a ttributes. get("lastN ame"); | |||||
| 963 | se archReques t.patientF irstName = (String) attributes .get("firs tName"); | |||||
| 964 | se archReques t.stationN umbers = ( String) at tributes.g et("statio nNumbers") ; | |||||
| 965 | se archReques t.aggregat eAtFacilit yLevel = f alse; | |||||
| 966 | se archReques t.includeU nknownVisn = (Boolea n) attribu tes.get("i ncludeUnkn ownVisn"); | |||||
| 967 | se archReques t.reasonsF orDelay = (String) a ttributes. get("reaso nsForDelay "); | |||||
| 968 | se archReques t.daysSinc eDelayed = (String) attributes .get("days SinceDelay ed"); | |||||
| 969 | se archReques t.consentT ype = (Str ing) attri butes.get( "consentTy pe"); | |||||
| 970 | se archReques t.start = 0; | |||||
| 971 | se archReques t.length = -1; | |||||
| 972 | se archReques t.sortBy = (String) attributes .get("sort Value"); | |||||
| 973 | se archReques t.sortOrde r = (Strin g) attribu tes.get("s ortDirecti on"); | |||||
| 974 | se archReques t.patientT ypes = (In teger) att ributes.ge t("patient Types"); | |||||
| 975 | se archReques t.enteredB y = (Strin g) attribu tes.get("u serId"); | |||||
| 976 | ||||||
| 977 | // Perform t he search. | |||||
| 978 | De layedConse ntReportDA O.SearchAl lResponse searchResp onse = del ayedConsen tReportDAO .searchAll (searchReq uest); | |||||
| 979 | ||||||
| 980 | // Generate report dat a. | |||||
| 981 | fi nal List<M ap<String, Object>> results = new ArrayL ist<>(); | |||||
| 982 | fo r (Delayed ConsentRpt r : searc hResponse. delayedCon sents) { | |||||
| 983 | final Ma p<String, Object> re sultMap = new HashMa p<>(); | |||||
| 984 | ||||||
| 985 | resultMa p.put("dat eAdded", r eportHelpe r.getForma ttedDateTi me(r.getDa teAdded()) ); | |||||
| 986 | resultMa p.put("icn ", r.getPa tientIen() ); | |||||
| 987 | resultMa p.put("ssn ", r.getPa tientSsn() ); | |||||
| 988 | resultMa p.put("las tName", r. getPatient LastName() ); | |||||
| 989 | resultMa p.put("fir stName", r .getPatien tFirstName ()); | |||||
| 990 | resultMa p.put("mid dleName", r.getPatie ntMiddleNa me()); | |||||
| 991 | resultMa p.put("con sentType", this.hand leConsentT ype(r)); | |||||
| 992 | resultMa p.put("rea sonsForDel ay", this. handleDela yReasons(r .getDelayR easonColle ction(), ( String) at tributes.g et("reason sForDelay" ))); | |||||
| 993 | resultMa p.put("ent eredBy", r .getUserId ()); | |||||
| 994 | resultMa p.put("aut henticatin gFacility" , r.getFac ilityName( )); | |||||
| 995 | resultMa p.put("mai lNotificat ions", thi s.handleMa ilNotifica tions(this .getMailNo tification sByDelayed Consent(r. getDelayed ConsentId( )),"\r\n") ); | |||||
| 996 | ||||||
| 997 | results. add(result Map); | |||||
| 998 | } | |||||
| 999 | ||||||
| 1000 | re turn resul ts; | |||||
| 1001 | } | |||||
| 1002 | ||||||
| 1003 | privat e String h andleConse ntType(Del ayedConsen tRpt delay edConsent) { | |||||
| 1004 | St ring conse ntType = " "; | |||||
| 1005 | if (!NullChe cker.isNul lOrEmpty(d elayedCons ent.getCon sentTypeId ())) { | |||||
| 1006 | consentT ype = dela yedConsent .getConsen tTypeId(). getName(); | |||||
| 1007 | consentT ype = Repo rtHelper.n ormalizeCo nsnentType Name(conse ntType); | |||||
| 1008 | } | |||||
| 1009 | re turn conse ntType; | |||||
| 1010 | } | |||||
| 1011 | ||||||
| 1012 | privat e String h andleDelay Reasons(Co llection<D elayReason > delayedR easons, St ring searc hedForReas ons) { | |||||
| 1013 | if (!NullChe cker.isNul lOrEmpty(d elayedReas ons)) { | |||||
| 1014 | StringBu ilder sb = new Strin gBuilder() ; | |||||
| 1015 | ||||||
| 1016 | if (Null Checker.is NullOrEmpt y(searched ForReasons ) || "ALL" .equals(se archedForR easons)) { | |||||
| 1017 | //ge t em all | |||||
| 1018 | for (DelayReas on dr : de layedReaso ns) { | |||||
| 1019 | sb.append( dr.getName ()); | |||||
| 1020 | sb.append( ", "); | |||||
| 1021 | } | |||||
| 1022 | } else { | |||||
| 1023 | //co ncatenate applicable reasons o nly | |||||
| 1024 | List <String> r easons = A rrays.asLi st(searche dForReason s.split("\ \s*,\\s*") ); | |||||
| 1025 | ||||||
| 1026 | for (DelayReas on dr : de layedReaso ns) { | |||||
| 1027 | if (reason s.contains (dr.getDel ayReasonId ().toStrin g())) { | |||||
| 1028 | sb.app end(dr.get Name()); | |||||
| 1029 | sb.app end(", "); | |||||
| 1030 | } | |||||
| 1031 | } | |||||
| 1032 | } | |||||
| 1033 | ||||||
| 1034 | return s b.length() > 0 ? sb. substring( 0, sb.leng th() - 2) : ""; //ge t rid of t he last co mma and sp ace (yeah its clunky and I don 't particu larly like it) | |||||
| 1035 | } else { | |||||
| 1036 | return " "; | |||||
| 1037 | } | |||||
| 1038 | } | |||||
| 1039 | ||||||
| 1040 | privat e String h andleMailN otificatio ns(Collect ion<MailNo tification > notifica tions, Str ing delimi ter) { | |||||
| 1041 | St ringBuilde r result = new Strin gBuilder() ; | |||||
| 1042 | bo olean isFi rstItem = true; | |||||
| 1043 | ||||||
| 1044 | fo r (MailNot ification mn : notif ications) { | |||||
| 1045 | result.a ppend(isFi rstItem ? "" : delim iter); | |||||
| 1046 | result.a ppend(repo rtHelper.g etFormatte dDate(mn.g etSentDate ())); | |||||
| 1047 | isFirstI tem = fals e; | |||||
| 1048 | } | |||||
| 1049 | ||||||
| 1050 | re turn resul t.toString (); | |||||
| 1051 | } | |||||
| 1052 | ||||||
| 1053 | privat e Collecti on<MailNot ification> getMailNo tification sByDelayed Consent(Lo ng delayed ConsentId) { | |||||
| 1054 | Co llection<M ailNotific ation> not ifications = this.ma ilNotifica tionDAO.fi ndByDelaye dConsentId (delayedCo nsentId.to String()); | |||||
| 1055 | ||||||
| 1056 | re turn notif ications; | |||||
| 1057 | } | |||||
| 1058 | ||||||
| 1059 | /** | |||||
| 1060 | * Pro cesses Det ails prope rty as fol lows: | |||||
| 1061 | * - M asks SSN | |||||
| 1062 | * - R eplaces "M OTHERSMAID ENNAME" wi th "MMN" | |||||
| 1063 | * @pa ram detail s Details property o f AuditTyp e | |||||
| 1064 | * @re turn Proce ssed Detai ls propert y string | |||||
| 1065 | */ | |||||
| 1066 | privat e String p rocessDeta ils(String details) { | |||||
| 1067 | // Mask SSN | |||||
| 1068 | in t pos1 = d etails.ind exOf("SSN= "); | |||||
| 1069 | in t pos2; | |||||
| 1070 | St ring ssn; | |||||
| 1071 | if (pos1 != -1) { | |||||
| 1072 | pos2 = d etails.ind exOf(",", pos1); | |||||
| 1073 | if (pos2 != -1) { | |||||
| 1074 | ssn = details. substring( pos1 + 4, pos2).trim (); | |||||
| 1075 | if ( ssn.length () > 0) { | |||||
| 1076 | details = details.su bstring(0, pos1 + 4) + ReportD ataProcess or.maskSsn (ssn) + de tails.subs tring(pos2 ); | |||||
| 1077 | } | |||||
| 1078 | } | |||||
| 1079 | } | |||||
| 1080 | // Replace " MOTHERSMAI DENNAME" w ith "MMN" | |||||
| 1081 | if (details. contains(" MOTHERSMAI DENNAME=") ) { | |||||
| 1082 | details = details. replace("M OTHERSMAID ENNAME=", "MMN="); | |||||
| 1083 | } | |||||
| 1084 | re turn detai ls; | |||||
| 1085 | } | |||||
| 1086 | ||||||
| 1087 | public void setT itle(Strin g title) { | |||||
| 1088 | th is.title = title; | |||||
| 1089 | } | |||||
| 1090 | ||||||
| 1091 | public void setR eportMap(M ap<String, String> p atientDisc overyMap) { | |||||
| 1092 | th is.reportM ap = patie ntDiscover yMap; | |||||
| 1093 | } | |||||
| 1094 | ||||||
| 1095 | public void setF ilterMap(M ap<String, List<Obje ct>> filte rMap) { | |||||
| 1096 | th is.filterM ap = filte rMap; | |||||
| 1097 | } | |||||
| 1098 | ||||||
| 1099 | public void setE xcelExport er(ExcelEx porter exE xport) { | |||||
| 1100 | th is.exExpor t = exExpo rt; | |||||
| 1101 | } | |||||
| 1102 | ||||||
| 1103 | public void setA dapterAudi tManager(A dapterAudi tManager a dapterAudi tManager) { | |||||
| 1104 | th is.adapter AuditManag er = adapt erAuditMan ager; | |||||
| 1105 | } | |||||
| 1106 | ||||||
| 1107 | public void setR eportHelpe r(ReportHe lper repor tHelper) { | |||||
| 1108 | th is.reportH elper = re portHelper ; | |||||
| 1109 | } | |||||
| 1110 | ||||||
| 1111 | public void setA ttributes( Map<String , Object> attributes ) { | |||||
| 1112 | th is.attribu tes = attr ibutes; | |||||
| 1113 | } | |||||
| 1114 | ||||||
| 1115 | public void setH asOptional Rows(boole an hasOpti onalRows) { | |||||
| 1116 | th is.hasOpti onalRows = hasOption alRows; | |||||
| 1117 | } | |||||
| 1118 | ||||||
| 1119 | public void setF acilityHel per(Facili tyHelper f acilityHel per) { | |||||
| 1120 | th is.facilit yHelper = facilityHe lper; | |||||
| 1121 | } | |||||
| 1122 | ||||||
| 1123 | public void setC msHelper(C onsentMana gementHelp er cmsHelp er) { | |||||
| 1124 | th is.cmsHelp er = cmsHe lper; | |||||
| 1125 | } | |||||
| 1126 | ||||||
| 1127 | public void setI sSummaryRe port(boole an isSumma ryReport) { | |||||
| 1128 | th is.isSumma ryReport = isSummary Report; | |||||
| 1129 | } | |||||
| 1130 | ||||||
| 1131 | public void setO ptionalRow sMap(Map<S tring, Str ing> optio nalRowsMap ) { | |||||
| 1132 | th is.optiona lRowsMap = optionalR owsMap; | |||||
| 1133 | } | |||||
| 1134 | ||||||
| 1135 | public void setU serId(Stri ng userId) { | |||||
| 1136 | th is.userId = userId; | |||||
| 1137 | } | |||||
| 1138 | ||||||
| 1139 | public void setU serDocumen tDao(UserD ocumentDAO userDocDa o) { | |||||
| 1140 | th is.userDoc Dao = user DocDao; | |||||
| 1141 | } | |||||
| 1142 | ||||||
| 1143 | public void setD irectAudit Manager(Di rectAuditM anager dir ectAuditMa nager) { | |||||
| 1144 | th is.directA uditManage r = direct AuditManag er; | |||||
| 1145 | } | |||||
| 1146 | ||||||
| 1147 | public void setR eportSourc e(String r eportSourc e) { | |||||
| 1148 | th is.reportS ource = re portSource ; | |||||
| 1149 | } | |||||
| 1150 | ||||||
| 1151 | public void setA uditedCons entDAO(Aud itedConsen tDAO audit edConsentD AO) { | |||||
| 1152 | th is.audited ConsentDAO = audited ConsentDAO ; | |||||
| 1153 | } | |||||
| 1154 | ||||||
| 1155 | public void setD ocumentHel per(Docume ntHelper d ocumentHel per) { | |||||
| 1156 | th is.documen tHelper = documentHe lper; | |||||
| 1157 | } | |||||
| 1158 | ||||||
| 1159 | public void setP atientCons entDirDAO( PatientCon sentDirDAO patientCo nsentDirDA O) { | |||||
| 1160 | th is.patient ConsentDir DAO = pati entConsent DirDAO; | |||||
| 1161 | } | |||||
| 1162 | ||||||
| 1163 | public void setD elayedCons entReportD AO(Delayed ConsentRep ortDAO del ayedConsen tReportDAO ) { | |||||
| 1164 | th is.delayed ConsentRep ortDAO = d elayedCons entReportD AO; | |||||
| 1165 | } | |||||
| 1166 | ||||||
| 1167 | public void setM ailNotific ationDAO(M ailNotific ationDAO m ailNotific ationDAO) { | |||||
| 1168 | th is.mailNot ificationD AO = mailN otificatio nDAO; | |||||
| 1169 | } | |||||
| 1170 | ||||||
| 1171 | public void setD ocumentTyp e(String d ocumentTyp e) { | |||||
| 1172 | th is.documen tType = do cumentType ; | |||||
| 1173 | } | |||||
| 1174 | ||||||
| 1175 | public void setC svExport(C svExporter csvExport ) { | |||||
| 1176 | th is.csvExpo rt = csvEx port; | |||||
| 1177 | } | |||||
| 1178 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.