Produced by Araxis Merge on 6/11/2019 10:54:09 AM 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 | HTRE_P3_v14.5_iter_4_build_14.zip\java\gov\va\med\ccht\persistent\hibernate | SurveyTrendChartsDAOImpl.java | Wed May 29 15:26:40 2019 UTC |
| 2 | HTRE_P3_v14.5_iter_4_build_14.zip\java\gov\va\med\ccht\persistent\hibernate | SurveyTrendChartsDAOImpl.java | Mon Jun 10 19:29:09 2019 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 934 |
| Changed | 1 | 2 |
| Inserted | 0 | 0 |
| 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.med.c cht.persis tent.hiber nate; | |
| 2 | ||
| 3 | import jav a.text.Par seExceptio n; | |
| 4 | import jav a.util.Arr ayList; | |
| 5 | import jav a.util.Cal endar; | |
| 6 | import jav a.util.Dat e; | |
| 7 | import jav a.util.Lin kedList; | |
| 8 | import jav a.util.Lis t; | |
| 9 | ||
| 10 | import jav ax.persist ence.Query ; | |
| 11 | import jav ax.transac tion.Trans actional; | |
| 12 | ||
| 13 | import org .hibernate .Session; | |
| 14 | import org .hibernate .SessionFa ctory; | |
| 15 | import org .springfra mework.bea ns.factory .annotatio n.Autowire d; | |
| 16 | import org .springfra mework.ste reotype.Re pository; | |
| 17 | ||
| 18 | import gov .va.med.cc ht.model.p ssreport.S urveyTrend ChartResul t; | |
| 19 | import gov .va.med.cc ht.persist ent.Report sDAO; | |
| 20 | import gov .va.med.cc ht.persist ent.Survey TrendChart sDAO; | |
| 21 | import gov .va.med.cc ht.service .htreports .CensusAct ivityRepor tsConstant s; | |
| 22 | import gov .va.med.cc ht.service .htreports .PssReport Service; | |
| 23 | import gov .va.med.cc ht.service .report.Re portConsta nts; | |
| 24 | import gov .va.med.cc ht.ui.mode l.PSSRepor tForm; | |
| 25 | import gov .va.med.fw .util.Date Utils; | |
| 26 | ||
| 27 | /** | |
| 28 | * | |
| 29 | * @author DN S
|
|
| 30 | * | |
| 31 | */ | |
| 32 | ||
| 33 | @Repositor y | |
| 34 | @Transacti onal | |
| 35 | public cla ss SurveyT rendCharts DAOImpl im plements S urveyTrend ChartsDAO, ReportCon stants, | |
| 36 | Ce nsusActivi tyReportsC onstants { | |
| 37 | ||
| 38 | pr ivate stat ic final i nt MONTH = 0; | |
| 39 | pr ivate stat ic final i nt VISN = 0; | |
| 40 | pr ivate stat ic final i nt NUM_OF_ SURVEYS = 1; | |
| 41 | pr ivate stat ic final i nt MONTH_N UM = 2; | |
| 42 | ||
| 43 | pu blic stati c final in t NATIONAL _SELECTION = 1; | |
| 44 | pu blic stati c final in t VISN_SEL ECTION = 2 ; | |
| 45 | pu blic stati c final in t FACILITY _SELECTION = 3; | |
| 46 | ||
| 47 | @A utowired | |
| 48 | pr ivate Repo rtsDAO rep ortsDao; | |
| 49 | ||
| 50 | @A utowired | |
| 51 | pr ivate PssR eportServi ce pssRepo rtService; | |
| 52 | ||
| 53 | @A utowired | |
| 54 | pr ivate Sess ionFactory sessionFa ctory; | |
| 55 | ||
| 56 | pu blic Surve yTrendChar tsDAOImpl( ) { | |
| 57 | } | |
| 58 | ||
| 59 | pu blic Surve yTrendChar tsDAOImpl( SessionFac tory facto ry, Report sDAO repor tsDao) { | |
| 60 | sess ionFactory = factory ; | |
| 61 | this .reportsDa o = report sDao; | |
| 62 | } | |
| 63 | ||
| 64 | pr otected Se ssion getS ession() { | |
| 65 | retu rn this.se ssionFacto ry.getCurr entSession (); | |
| 66 | } | |
| 67 | ||
| 68 | @O verride | |
| 69 | pu blic Linke dList<Surv eyTrendCha rtResult> getSurveyT rendCharts ReportData (PSSReport Form form) throws Pa rseExcepti on { | |
| 70 | ||
| 71 | Quer y query = null; | |
| 72 | ||
| 73 | swit ch (form.g etTypeButt onSelectio n()) { | |
| 74 | ||
| 75 | case NATIONAL _SELECTION : | |
| 76 | if((fo rm.getDate TypeSelect ion() == O NE) || (fo rm.getDate TypeSelect ion() == T WO)) { | |
| 77 | query = getNationa lReportQue ry(form); | |
| 78 | } else { | |
| 79 | query = getNationa lReportQue ryByYear(f orm); | |
| 80 | } | |
| 81 | break; | |
| 82 | case VISN_SELE CTION: | |
| 83 | if(for m.getVisnI d().equals IgnoreCase (ALL_VISNS )) { | |
| 84 | query = getAllVisn ReportQuer y(form); | |
| 85 | } | |
| 86 | else { | |
| 87 | if((form .getDateTy peSelectio n() == ONE ) || (form .getDateTy peSelectio n() == TWO )) { | |
| 88 | query = ge tVisnRepor tQuery(for m); | |
| 89 | } else { | |
| 90 | query = ge tVisnRepor tQuerybyYe ar(form); | |
| 91 | } | |
| 92 | // if qu ery is for a single visn sets query para meter for that visn | |
| 93 | query.se tParameter ("visnId", form.getV isnId()); | |
| 94 | } | |
| 95 | break; | |
| 96 | case FACILITY_ SELECTION: | |
| 97 | if(for m.getFacil ityId().eq ualsIgnore Case(ALL_F ACILITIES) ) { | |
| 98 | if((form .getDateTy peSelectio n() == ONE ) || (form .getDateTy peSelectio n() == TWO )) { | |
| 99 | query = ge tAllFacili tyReport(f orm); | |
| 100 | } else { | |
| 101 | query = ge tNationalR eportQuery ByYear(for m); | |
| 102 | } | |
| 103 | } | |
| 104 | else { | |
| 105 | if((form .getDateTy peSelectio n() == ONE ) || (form .getDateTy peSelectio n() == TWO )) { | |
| 106 | query = ge tFacilityR eportQuery (form); | |
| 107 | } else { | |
| 108 | query = ge tFacilityR eportQuery ByYear(for m); | |
| 109 | } | |
| 110 | // if qu ery is for a single facility s ets query parameter for that f acility | |
| 111 | query.se tParameter ("facility Id", form. getFacilit yId()); | |
| 112 | } | |
| 113 | break; | |
| 114 | defa ult: | |
| 115 | return new Linke dList<Surv eyTrendCha rtResult>( ); | |
| 116 | } | |
| 117 | ||
| 118 | //fo rtify Fix, Null Dere ference | |
| 119 | if(q uery == nu ll) { | |
| 120 | return new Linke dList<Surv eyTrendCha rtResult>( ); | |
| 121 | } | |
| 122 | ||
| 123 | //fo rtify Fix, Null Dere ference | |
| 124 | if(( form.getSh ortFormatR eportFromD ate() != n ull && for m.getShort FormatRepo rtToDate() != null) || | |
| 125 | (form.ge tQuarterFr omDate() ! = null && form.getQu arterToDat e() != nul l) || | |
| 126 | (form.ge tFiscalFro mDate() != null && f orm.getFis calToDate( ) != null) ) { | |
| 127 | addDat eParams(qu ery, form) ; | |
| 128 | } | |
| 129 | else { | |
| 130 | // ret urn empty list to av oid errors , will res ult in emp ty report. | |
| 131 | return new Linke dList<Surv eyTrendCha rtResult>( ); | |
| 132 | } | |
| 133 | ||
| 134 | List <Object[]> reportDat a = query. getResultL ist(); | |
| 135 | ||
| 136 | Link edList <Su rveyTrendC hartResult > results = new Link edList<Sur veyTrendCh artResult> (); | |
| 137 | ||
| 138 | if(f orm.getDat eTypeSelec tion() == THREE && ( !(form.get TypeButton Selection( ) == VISN_ SELECTION && form.ge tVisnId(). equals(ALL _VISNS)))) { | |
| 139 | //if t he report is run by fiscal yea r & the re port is no t being ru n for all visns pars e the data by fiscal year | |
| 140 | result s = yearPa rse(form, reportData ); | |
| 141 | }els e { | |
| 142 | //If r eport is b eing run f or All vis ns the dat a returned is each v isn | |
| 143 | // & t he number of surveys over the selected t ime period | |
| 144 | if(for m.getTypeB uttonSelec tion() == VISN_SELEC TION && fo rm.getVisn Id().equal s(ALL_VISN S)) { | |
| 145 | for(Obje ct[] entry : reportD ata) { | |
| 146 | SurveyTren dChartResu lt row = n ew SurveyT rendChartR esult(); | |
| 147 | row.setVis n(entry[VI SN].toStri ng()); | |
| 148 | row.setNum OfSurveys( Integer.pa rseInt(ent ry[NUM_OF_ SURVEYS].t oString()) ); | |
| 149 | results.ad d(row); | |
| 150 | } | |
| 151 | } | |
| 152 | else{ | |
| 153 | for(Obje ct[] entry : reportD ata) { | |
| 154 | SurveyTren dChartResu lt row = n ew SurveyT rendChartR esult(); | |
| 155 | row.setMon th(entry[M ONTH].toSt ring()); | |
| 156 | row.setNum OfSurveys( Integer.pa rseInt(ent ry[NUM_OF_ SURVEYS].t oString()) ); | |
| 157 | row.setMon thNum((int )entry[MON TH_NUM]); | |
| 158 | results.ad d(row); | |
| 159 | } | |
| 160 | } | |
| 161 | } | |
| 162 | retu rn results ; | |
| 163 | } | |
| 164 | ||
| 165 | pr ivate Link edList <Su rveyTrendC hartResult > yearPars e(PSSRepor tForm form , List<Obj ect[]> dat a) { | |
| 166 | Link edList <Su rveyTrendC hartResult > temp = n ew LinkedL ist<Survey TrendChart Result>(); | |
| 167 | Cale ndar dateF rom = Cale ndar.getIn stance(); | |
| 168 | date From.setTi me(form.ge tShortForm atReportFr omDate()); | |
| 169 | Cale ndar dateT o = Calend ar.getInst ance(); | |
| 170 | date To.setTime (form.getS hortFormat ReportToDa te()); | |
| 171 | //ad ded to day s so that the last y ear in the list will be includ ed as it c ompares th e from dat e (10/01/y yyy) to (1 0/02/yyyy) | |
| 172 | date To.add(Cal endar.DATE , 2); | |
| 173 | List <String> y ears = new ArrayList <String>() ; | |
| 174 | Date dateCount er = new D ate(); dat eCounter = form.getS hortFormat ReportFrom Date(); | |
| 175 | for( dateCounte r = dateFr om.getTime (); dateFr om.before( dateTo); d ateFrom.ad d(Calendar .YEAR, 1), dateCount er = dateF rom.getTim e()) { | |
| 176 | years. add(DateUt ils.format (dateCount er, DateUt ils.YYYY)) ; | |
| 177 | } | |
| 178 | Cale ndar divid er = Calen dar.getIns tance(); | |
| 179 | Cale ndar curre nt = Calen dar.getIns tance(); | |
| 180 | int mm; | |
| 181 | Stri ng yyyy; | |
| 182 | int surveyCoun t=0; | |
| 183 | Obje ct[][] sur veyCountBu cket = new Object[ye ars.size() ][TWO]; | |
| 184 | for( Object[] e ntry: surv eyCountBuc ket){ | |
| 185 | entry[ ZERO] =""; | |
| 186 | entry[ ONE] = 0; | |
| 187 | } | |
| 188 | for( Object[] e ntry : dat a) { | |
| 189 | mm= (i nt) entry[ ZERO]; | |
| 190 | yyyy = entry[ONE ].toString (); | |
| 191 | survey Count = (i nt) entry[ TWO]; | |
| 192 | int po s = 0; | |
| 193 | for(in t i=0;i<ye ars.size() ;i++){ | |
| 194 | if(years .get(i).in dexOf(yyyy )!=-1){ | |
| 195 | pos = i; | |
| 196 | brea k; | |
| 197 | } | |
| 198 | } | |
| 199 | if (mm < 10){ | |
| 200 | surveyCo untBucket[ pos-1][ONE ] = (int)s urveyCount Bucket[pos -1][ONE] + surveyCou nt; | |
| 201 | surveyCo untBucket[ pos-1][ZER O] = yyyy; | |
| 202 | } | |
| 203 | if (mm >= 10){ | |
| 204 | surveyCo untBucket[ pos][ONE] = (int)sur veyCountBu cket[pos][ ONE] + sur veyCount; | |
| 205 | surveyCo untBucket[ pos][ZERO] = (Intege r.parseInt (yyyy)+1 + ""); | |
| 206 | } | |
| 207 | ||
| 208 | ||
| 209 | } | |
| 210 | for( Object[] e ntry : sur veyCountBu cket) { | |
| 211 | Survey TrendChart Result row = new Sur veyTrendCh artResult( ); | |
| 212 | String year = en try[ZERO]. toString() ; | |
| 213 | if(yea r.equals(" "))break; | |
| 214 | row.se tYear("FY" + year); | |
| 215 | row.se tNumOfSurv eys(Intege r.parseInt (entry[ONE ].toString ())); | |
| 216 | temp.a dd(row); | |
| 217 | } | |
| 218 | retu rn temp; | |
| 219 | } | |
| 220 | ||
| 221 | ||
| 222 | ||
| 223 | ||
| 224 | pr ivate Stri ng getComm onCOCJoin( ){ | |
| 225 | Stri ngBuilder sql = new StringBuil der(); | |
| 226 | sql. append("IN NER JOIN ( select cp. patient_id , cp.level _of_care f rom census patient cp "); | |
| 227 | sql. append("in ner join ( select dis tinct MAX( census_id) as census id, patien t_id, dise nrollment_ date "); | |
| 228 | sql. append("fr om censusp atient whe re disenro llment_dat e is null group by p atient_id, disenroll ment_date) as lcpe " ); | |
| 229 | sql. append("on cp.census _id = lcpe .censusid and cp.pat ient_id = lcpe.patie nt_id) f " ); | |
| 230 | sql. append("on b.patient _id = f.pa tient_id " ); | |
| 231 | retu rn sql.toS tring(); | |
| 232 | } | |
| 233 | ||
| 234 | /* * | |
| 235 | * Creates qu ery for Na tional tot als | |
| 236 | * @param fo rm | |
| 237 | * @return q uery for n ational to tals | |
| 238 | * / | |
| 239 | pr ivate Quer y getNatio nalReportQ uery(PSSRe portForm f orm) { | |
| 240 | ||
| 241 | Stri ngBuilder sql = new StringBuil der(); | |
| 242 | sql. append("SE LECT conve rt(char(3) , received _date) as [Month], " ); | |
| 243 | sql. append("co unt(*) as [Count], " ); | |
| 244 | sql. append("da tepart(mon th, receiv ed_date) a s [MonthNu m] "); | |
| 245 | sql. append("fr om Surveye d_Activity _Response a, surveye d_activity b "); | |
| 246 | sql. append(get CommonCOCJ oin()); | |
| 247 | sql. append("wh ere a.surv eyed_activ ity_id= b. surveyed_a ctivity_id "); | |
| 248 | sql. append("an d (a.surve y_id != 1) "); //do not includ e VR-12 da ta | |
| 249 | sql. append("an d a.survey _accepted_ status = 1 "); | |
| 250 | sql. append(rep ortsDao.ge tCategoryO fCare(form )); | |
| 251 | sql. append("an d received _date "); | |
| 252 | sql. append("BE TWEEN :fro mDate AND :toDate ") ; | |
| 253 | sql. append("gr oup by con vert(char( 3), receiv ed_date),d atepart(mo nth, recei ved_date) "); | |
| 254 | sql. append("or der by Mon thNum"); | |
| 255 | ||
| 256 | retu rn getSess ion().crea teNativeQu ery(sql.to String()); | |
| 257 | } | |
| 258 | ||
| 259 | /* * | |
| 260 | * Creates qu ery for Na tional tot als by yea r query | |
| 261 | * @param for m | |
| 262 | * @return qu ery for na tional tot als | |
| 263 | */ | |
| 264 | pr ivate Quer y getNatio nalReportQ ueryByYear (PSSReport Form form) { | |
| 265 | Stri ngBuilder sql = new StringBuil der(); | |
| 266 | sql. append("SE LECT DATEP ART(mm, re ceived_dat e) AS Mon, DATEPART( yy, receiv ed_date) A S Yr, "); | |
| 267 | sql. append("co unt(*) as [Count] ") ; | |
| 268 | sql. append("fr om Surveye d_Activity _Response a, surveye d_activity b "); | |
| 269 | sql. append(get CommonCOCJ oin()); | |
| 270 | sql. append("wh ere a.surv eyed_activ ity_id= b. surveyed_a ctivity_id "); | |
| 271 | sql. append("an d (a.surve y_id != 1) "); //do not includ e VR-12 da ta | |
| 272 | sql. append("an d a.survey _accepted_ status = 1 "); | |
| 273 | sql. append(rep ortsDao.ge tCategoryO fCare(form )); | |
| 274 | sql. append("an d received _date "); | |
| 275 | sql. append("BE TWEEN :fro mDate AND :toDate ") ; | |
| 276 | sql. append("gr oup by DAT EPART(mm, received_d ate), DATE PART(yy, r eceived_da te) "); | |
| 277 | sql. append("or der by Yr, Mon"); | |
| 278 | retu rn getSess ion().crea teNativeQu ery(sql.to String()); | |
| 279 | } | |
| 280 | ||
| 281 | ||
| 282 | ||
| 283 | / ** | |
| 284 | * Creates q uery for A ll VISNS | |
| 285 | * whi ch returns results b y visn ins tead of by month | |
| 286 | * @param fo rm | |
| 287 | * @return q uery for a ll visns b y visn ins tead of mo nth | |
| 288 | * / | |
| 289 | pr ivate Quer y getAllVi snReportQu ery(PSSRep ortForm fo rm) { | |
| 290 | Stri ngBuilder sql = new StringBuil der(); | |
| 291 | ||
| 292 | sql. append("SE LECT 'Visn ' + conver t(varchar( 2), b.visn _id) "); | |
| 293 | sql. append("as [VISN], " ); | |
| 294 | sql. append("co unt(*) as [Count] ") ; | |
| 295 | sql. append("fr om Surveye d_Activity _Response a, surveye d_activity b "); | |
| 296 | sql. append(get CommonCOCJ oin()); | |
| 297 | sql. append("wh ere a.surv eyed_activ ity_id= b. surveyed_a ctivity_id "); | |
| 298 | sql. append("an d (a.surve y_id != 1) "); //do not includ e vr-12 da ta | |
| 299 | sql. append("an d a.survey _accepted_ status = 1 "); | |
| 300 | sql. append(rep ortsDao.ge tCategoryO fCare(form )); | |
| 301 | sql. append("an d received _date "); | |
| 302 | sql. append("BE TWEEN :fro mDate AND :toDate ") ; | |
| 303 | sql. append("gr oup by b.v isn_id ") ; | |
| 304 | sql. append("or der by b.v isn_id"); | |
| 305 | ||
| 306 | retu rn getSess ion().crea teNativeQu ery(sql.to String()); | |
| 307 | } | |
| 308 | ||
| 309 | /* * | |
| 310 | * Creates q uery for a single vi sn | |
| 311 | * @param fo rm | |
| 312 | * @return q uery for s ingle visn by month | |
| 313 | * / | |
| 314 | pr ivate Quer y getVisnR eportQuery (PSSReport Form form) { | |
| 315 | Stri ngBuilder sql = new StringBuil der(); | |
| 316 | ||
| 317 | sql. append("SE LECT conve rt(char(3) , received _date) as [Month], " ); | |
| 318 | sql. append("co unt(*) as [Count], " ); | |
| 319 | sql. append("da tepart(mon th, receiv ed_date) a s [MonthNu m] "); | |
| 320 | sql. append("fr om Surveye d_Activity _Response a, surveye d_activity b "); | |
| 321 | sql. append(get CommonCOCJ oin()); | |
| 322 | sql. append("wh ere a.surv eyed_activ ity_id= b. surveyed_a ctivity_id "); | |
| 323 | sql. append("an d b.visn_i d= :visnId "); | |
| 324 | sql. append("an d (a.surve y_id != 1) "); //do not includ e vr-12 da ta | |
| 325 | sql. append("an d a.survey _accepted_ status = 1 "); | |
| 326 | sql. append(rep ortsDao.ge tCategoryO fCare(form )); | |
| 327 | sql. append("an d received _date "); | |
| 328 | sql. append("BE TWEEN :fro mDate AND :toDate ") ; | |
| 329 | sql. append("gr oup by con vert(char( 3), receiv ed_date),d atepart(mo nth, recei ved_date), b.visn_id "); | |
| 330 | sql. append("or der by Mon thNum, b.v isn_id "); | |
| 331 | ||
| 332 | retu rn getSess ion().crea teNativeQu ery(sql.to String()); | |
| 333 | } | |
| 334 | ||
| 335 | /* * | |
| 336 | * Creates q uery for a single vi sn by year | |
| 337 | * @param fo rm | |
| 338 | * @return q uery for s ingle visn by month | |
| 339 | * / | |
| 340 | pr ivate Quer y getVisnR eportQuery byYear(PSS ReportForm form) { | |
| 341 | Stri ngBuilder sql = new StringBuil der(); | |
| 342 | sql. append("SE LECT DATEP ART(mm, re ceived_dat e) AS Mon, DATEPART( yy, receiv ed_date) A S Yr, "); | |
| 343 | sql. append("co unt(*) as [Count] ") ; | |
| 344 | sql. append("fr om Surveye d_Activity _Response a, surveye d_activity b "); | |
| 345 | sql. append(get CommonCOCJ oin()); | |
| 346 | sql. append("wh ere a.surv eyed_activ ity_id= b. surveyed_a ctivity_id "); | |
| 347 | sql. append("an d b.visn_i d= :visnId "); | |
| 348 | sql. append("an d (a.surve y_id != 1) "); //do not includ e vr-12 da ta | |
| 349 | sql. append("an d a.survey _accepted_ status = 1 "); | |
| 350 | sql. append(rep ortsDao.ge tCategoryO fCare(form )); | |
| 351 | sql. append("an d received _date "); | |
| 352 | sql. append("BE TWEEN :fro mDate AND :toDate ") ; | |
| 353 | sql. append("gr oup by DAT EPART(mm, received_d ate), DATE PART(yy, r eceived_da te), b.vis n_id "); | |
| 354 | sql. append("or der by Yr, Mon, b.vi sn_id"); | |
| 355 | retu rn getSess ion().crea teNativeQu ery(sql.to String()); | |
| 356 | } | |
| 357 | ||
| 358 | /* * | |
| 359 | * Creates q uery for A ll Facilit ies | |
| 360 | * @param fo rm | |
| 361 | * @return q uery for a ll facilit ies by mon th | |
| 362 | * / | |
| 363 | pr ivate Quer y getAllFa cilityRepo rt(PSSRepo rtForm for m) { | |
| 364 | Stri ngBuilder sql = new StringBuil der(); | |
| 365 | sql. append("SE LECT conve rt(char(3) , received _date) as [Month], " ); | |
| 366 | sql. append("co unt(*) as [Count], " ); | |
| 367 | sql. append("da tepart(mon th, receiv ed_date) as [MonthN um] "); | |
| 368 | sql. append("fr om Surveye d_Activity _Response a, surveye d_activity b "); | |
| 369 | sql. append(get CommonCOCJ oin()); | |
| 370 | sql. append("wh ere a.surv eyed_activ ity_id= b. surveyed_a ctivity_id "); | |
| 371 | sql. append("an d (a.surve y_id != 1) "); //do not includ e vr-12 da ta | |
| 372 | sql. append("an d a.survey _accepted_ status = 1 "); | |
| 373 | sql. append(rep ortsDao.ge tCategoryO fCare(form )); | |
| 374 | sql. append("an d received _date "); | |
| 375 | sql. append("BE TWEEN :fro mDate AND :toDate ") ; | |
| 376 | sql. append("GR OUP BY CON VERT(char( 3), a.Rece ived_Date) ,DATEPART( month, a.R eceived_Da te) "); | |
| 377 | sql. append("or der by Mon thNum"); | |
| 378 | ||
| 379 | retu rn getSess ion().crea teNativeQu ery(sql.to String()); | |
| 380 | } | |
| 381 | ||
| 382 | /* * | |
| 383 | * Creates q uery for a single fa cility | |
| 384 | * @param fo rm | |
| 385 | * @return q uery for s ingle faci lity by mo nth | |
| 386 | * / | |
| 387 | pr ivate Quer y getFacil ityReportQ uery(PSSRe portForm f orm) { | |
| 388 | ||
| 389 | Stri ngBuilder sql = new StringBuil der(); | |
| 390 | sql. append("SE LECT conve rt(char(3) , received _date) as [Month], " ); | |
| 391 | sql. append("co unt(*) as [Count], " ); | |
| 392 | sql. append("da tepart(mon th, receiv ed_date) a s [MonthNu m] "); | |
| 393 | sql. append("fr om Surveye d_Activity _Response a, facilit ies c, sur veyed_acti vity b "); | |
| 394 | sql. append(get CommonCOCJ oin()); | |
| 395 | sql. append("wh ere a.surv eyed_activ ity_id= b. surveyed_a ctivity_id "); | |
| 396 | sql. append("an d c.id = b .Facility_ id and b.F acility_id = :facilit yId "); | |
| 397 | sql. append("an d (a.surve y_id != 1) "); //do not includ e vr-12 da ta | |
| 398 | sql. append("an d a.survey _accepted_ status = 1 "); | |
| 399 | sql. append(rep ortsDao.ge tCategoryO fCare(form )); | |
| 400 | sql. append("an d received _date "); | |
| 401 | sql. append("BE TWEEN :fro mDate AND :toDate ") ; | |
| 402 | sql. append("GR OUP BY CON VERT(char( 3), a.Rece ived_Date) ,"); | |
| 403 | sql. append("DA TEPART(mon th, a.Rece ived_Date) , c.Facili ty_Name ") ; | |
| 404 | sql. append("or der by Mon thNum"); | |
| 405 | ||
| 406 | retu rn getSess ion().crea teNativeQu ery(sql.to String()); | |
| 407 | } | |
| 408 | ||
| 409 | /* * | |
| 410 | * Creates q uery for a single fa cility by year | |
| 411 | * @param fo rm | |
| 412 | * @return q uery for s ingle faci lity by mo nth | |
| 413 | * / | |
| 414 | pr ivate Quer y getFacil ityReportQ ueryByYear (PSSReport Form form) { | |
| 415 | Stri ngBuilder sql = new StringBuil der(); | |
| 416 | sql. append("SE LECT DATEP ART(mm, re ceived_dat e) AS Mon, DATEPART( yy, receiv ed_date) A S Yr, "); | |
| 417 | sql. append("co unt(*) as [Count] ") ; | |
| 418 | sql. append("fr om Surveye d_Activity _Response a, facilit ies c, sur veyed_acti vity b "); | |
| 419 | sql. append(get CommonCOCJ oin()); | |
| 420 | sql. append("wh ere a.surv eyed_activ ity_id= b. surveyed_a ctivity_id "); | |
| 421 | sql. append("an d c.id = b .Facility_ id and b.F acility_id = :facilit yId "); | |
| 422 | sql. append("an d (a.surve y_id != 1) "); //do not includ e vr-12 da ta | |
| 423 | sql. append("an d a.survey _accepted_ status = 1 "); | |
| 424 | sql. append(rep ortsDao.ge tCategoryO fCare(form )); | |
| 425 | sql. append("an d received _date "); | |
| 426 | sql. append("BE TWEEN :fro mDate AND :toDate ") ; | |
| 427 | sql. append("gr oup by DAT EPART(mm, received_d ate), DATE PART(yy, r eceived_da te) , c.Fa cility_Nam e "); | |
| 428 | sql. append("or der by Yr, Mon"); | |
| 429 | retu rn getSess ion().crea teNativeQu ery(sql.to String()); | |
| 430 | } | |
| 431 | ||
| 432 | pr ivate Quer y addDateP arams(Quer y query, P SSReportFo rm form) t hrows Pars eException { | |
| 433 | swit ch (form.g etDateType Selection( )) { | |
| 434 | case 2: | |
| 435 | String [] quarter Date = pss ReportServ ice.parseQ uarterSele cted(form) ; | |
| 436 | form.s etShortFor matReportF romDate(Da teUtils.pa rseDate(qu arterDate[ 0], DateUt ils.MMDDYY YY)); | |
| 437 | form.s etShortFor matReportT oDate(Date Utils.pars eDate(quar terDate[1] , DateUtil s.MMDDYYYY )); | |
| 438 | break; | |
| 439 | case 3: | |
| 440 | String [] fiscalD ate = pssR eportServi ce.parseFi scalSelect ed(form); | |
| 441 | form.s etShortFor matReportF romDate(Da teUtils.pa rseDate(fi scalDate[0 ], DateUti ls.MMDDYYY Y)); | |
| 442 | form.s etShortFor matReportT oDate(Date Utils.pars eDate(fisc alDate[1], DateUtils .MMDDYYYY) ); | |
| 443 | break; | |
| 444 | defa ult: | |
| 445 | break; | |
| 446 | } | |
| 447 | quer y.setParam eter("from Date", for m.getShort FormatRepo rtFromDate ()); | |
| 448 | ||
| 449 | //Ca lendar def aults to t he 1st of the month so adding an additio nal month minus 1 da y | |
| 450 | //to include t he entire month in t he report and settin g the time to the la st millise cond | |
| 451 | //of the last day in the month | |
| 452 | Cale ndar toDat e = Calend ar.getInst ance(); | |
| 453 | toDa te.setTime (form.getS hortFormat ReportToDa te()); | |
| 454 | ||
| 455 | toDa te.set(Cal endar.MILL ISECOND, 9 99); | |
| 456 | toDa te.set(Cal endar.SECO ND, 59); | |
| 457 | toDa te.set(Cal endar.MINU TE, 59); | |
| 458 | toDa te.set(Cal endar.HOUR _OF_DAY, 2 3); | |
| 459 | if(f orm.getDat eTypeSelec tion() == 1){ | |
| 460 | toDate .add(Calen dar.MONTH, 1); | |
| 461 | toDate .add(Calen dar.DATE, -1); | |
| 462 | } | |
| 463 | ||
| 464 | quer y.setParam eter("toDa te", toDat e.getTime( )); | |
| 465 | ||
| 466 | retu rn query; | |
| 467 | } | |
| 468 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.