54. EPMO Open Source Coordination Office Redaction File Detail Report

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.

54.1 Files compared

# Location File Last Modified
1 HTRE_P3_v14.5_iter_4_build_14.zip\java\gov\va\med\ccht\service\htreports\impl PssReportServiceImpl.java Wed May 29 15:26:28 2019 UTC
2 HTRE_P3_v14.5_iter_4_build_14.zip\java\gov\va\med\ccht\service\htreports\impl PssReportServiceImpl.java Mon Jun 10 19:30:44 2019 UTC

54.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 4 2248
Changed 3 6
Inserted 0 0
Removed 0 0

54.3 Comparison options

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

54.4 Active regular expressions

No regular expressions were active.

54.5 Comparison detail

  1   package go v.va.med.c cht.servic e.htreport s.impl;
  2  
  3   import jav a.text.Par seExceptio n;
  4   import jav a.util.Arr ayList;
  5   import jav a.util.Dat e;
  6   import jav a.util.Lin kedList;
  7   import jav a.util.Lis t;
  8   import org .springfra mework.bea ns.factory .annotatio n.Autowire d;
  9   import org .springfra mework.ste reotype.Se rvice;
  10  
  11   import com .ibm.icu.u til.Calend ar;
  12  
  13   import gov .va.med.cc ht.model.p ssreport.C ategoryOfC are;
  14   import gov .va.med.cc ht.model.p ssreport.D istributio nOfSurveys Report;
  15   import gov .va.med.cc ht.model.p ssreport.S urveyTrend ChartResul t;
  16   import gov .va.med.cc ht.model.p ssreport.V endorSubmi ssionRepor tData;
  17   import gov .va.med.cc ht.model.r eport.Devi ceModality ;
  18   import gov .va.med.cc ht.model.s atisfactio nsurvey.Sa tisfaction SurveyQues tion;
  19   import gov .va.med.cc ht.model.s atisfactio nsurvey.Sa tisfaction SurveyQues tionResult ;
  20   import gov .va.med.cc ht.persist ent.Device ModalityDA O;
  21   import gov .va.med.cc ht.persist ent.PssDis tributionR eportDAO;
  22   import gov .va.med.cc ht.persist ent.Satisf actionSurv eyReportDA O;
  23   import gov .va.med.cc ht.persist ent.Survey TrendChart sDAO;
  24   import gov .va.med.cc ht.persist ent.Vendor Submission ReportDAO;
  25   import gov .va.med.cc ht.service .htreports .PssReport Service;
  26   import gov .va.med.cc ht.service .report.Re portConsta nts;
  27   import gov .va.med.cc ht.ui.mode l.PSSRepor tForm;
  28   import gov .va.med.fw .persisten t.DAOExcep tion;
  29   import gov .va.med.fw .service.S erviceExce ption;
  30   import gov .va.med.fw .util.Date Utils;
  31  
  32   @Service
  33   public cla ss PssRepo rtServiceI mpl implem ents PssRe portServic e, ReportC onstants{
  34           pr ivate Ques tionList b ucket;
  35           @A utowired
  36           pr ivate Vend orSubmissi onReportDA O vendorSu bmissionRe portDAO;
  37           @A utowired
  38           pr ivate PssD istributio nReportDAO  pssDistri butionRepo rtDAO;
  39           @A utowired
  40           pr ivate Sati sfactionSu rveyReport DAO satisf actionSurv eyReportDA O;
  41           @A utowired
  42           pr ivate Devi ceModality DAO device ModalityDa o;
  43           @A utowired
  44           pr ivate Surv eyTrendCha rtsDAO sur veyTrendCh artsDAO;
  45           
  46           Sa tisfaction SurveyQues tion quest ion = new  Satisfacti onSurveyQu estion();
  47           pr ivate Fisc alData que stionList  = new Fisc alData();
  48           
  49           pu blic PssRe portServic eImpl() {
  50           }
  51           
  52           pu blic PssRe portServic eImpl(Vend orSubmissi onReportDA O vendorSu bmissionRe portDAO,
  53                             PssDis tributionR eportDAO p ssDistribu tionReport DAO,
  54                             Satisf actionSurv eyReportDA O satisfac tionSurvey ReportDAO,  DeviceMod alityDAO d eviceModal ityDao,
  55                             Survey TrendChart sDAO surve yTrendChar tsDAO) {
  56                    this .vendorSub missionRep ortDAO = v endorSubmi ssionRepor tDAO;
  57                    this .pssDistri butionRepo rtDAO = ps sDistribut ionReportD AO;
  58                    this .satisfact ionSurveyR eportDAO =  satisfact ionSurveyR eportDAO;
  59                    this .deviceMod alityDao =  deviceMod alityDao;
  60                    this .surveyTre ndChartsDA O = survey TrendChart sDAO;
  61           }
  62  
  63           @O verride
  64           pu blic Linke dList<Surv eyTrendCha rtResult>  getSurveyT rendCharts ReportData (PSSReport Form form)  throws Pa rseExcepti on 
  65           {
  66                    if(f orm.getDat eTypeSelec tion() ==  QTR_ID){
  67                             //If r eport is a ll visns r eturn resu lts as is
  68                             if(for m.getTypeB uttonSelec tion() ==  QTR_ID &&  form.getVi snId().equ als(ALL_VI SN)){
  69                                      return s urveyTrend ChartsDAO. getSurveyT rendCharts ReportData (form);
  70                             }else{
  71                                      //otherw ise group  data by qu arter
  72                                      return s urveyTrend sQuarters( form, surv eyTrendCha rtsDAO.get SurveyTren dChartsRep ortData(fo rm));
  73                             }
  74                    }
  75                    retu rn surveyT rendCharts DAO.getSur veyTrendCh artsReport Data(form) ;
  76           };
  77           
  78           @O verride
  79           pu blic List< VendorSubm issionRepo rtData> ge tVendorSub missionRep ort() 
  80           {
  81                    retu rn vendorS ubmissionR eportDAO.g etVendorSu bmissionRe port();
  82           }
  83  
  84           @O verride
  85           pu blic Distr ibutionOfS urveysRepo rt getDist ributionNa tionalRepo rt(PSSRepo rtForm for m) throws  ParseExcep tion 
  86           {
  87                    retu rn pssDist ributionRe portDAO.ge tNationalR eport(form );
  88           }
  89           
  90           @O verride
  91           pu blic Distr ibutionOfS urveysRepo rt getDist ributionVi snReport(P SSReportFo rm form) t hrows Pars eException  
  92           {
  93                    retu rn pssDist ributionRe portDAO.ge tVisnRepor t(form);
  94           }
  95           
  96           @O verride
  97           pu blic Distr ibutionOfS urveysRepo rt getDist ributionFa cilityRepo rt(PSSRepo rtForm for m) throws  ParseExcep tion 
  98           {
  99                    retu rn pssDist ributionRe portDAO.ge tFacilityR eport(form );
  100           }
  101           
  102           @O verride
  103           pu blic List< CategoryOf Care> getC ategoriesO fCare() {
  104                    retu rn satisfa ctionSurve yReportDAO .getCatego riesOfCare ();
  105           }
  106           
  107           @O verride
  108           pu blic List< Date> getD atesByMont h() {
  109                    retu rn satisfa ctionSurve yReportDAO .getDatesB yMonth();
  110           }
  111           
  112           @O verride
  113           pu blic Array List<Strin g> getDate sByYears()  throws Pa rseExcepti on {
  114                    retu rn satisfa ctionSurve yReportDAO .getDatesB yYears();
  115           }
  116           
  117           @O verride
  118           pu blic List< Satisfacti onSurveyQu estionResu lt> getSat isfactionS urveyRepor t(PSSRepor tForm form ) throws N umberForma tException , DAOExcep tion, Serv iceExcepti on, ParseE xception {
  119                    if(f orm.getDat eTypeSelec tion() ==  QTR_ID) {
  120                             return  satSurvey Quarters(f orm, satAl lModalitie sCheck(for m, satisfa ctionSurve yReportDAO .getSatisf actionSurv eyReport(f orm)));
  121                    } el se if(form .getDateTy peSelectio n() == YEA R_ID) {
  122                             return  satSurvey Years(form , satAllMo dalitiesCh eck(form,  satisfacti onSurveyRe portDAO.ge tSatisfact ionSurveyR eport(form )));
  123                    } el se {
  124                             return  satAllMod alitiesChe ck(form, s atisfactio nSurveyRep ortDAO.get Satisfacti onSurveyRe port(form) );
  125                    }
  126           }
  127  
  128           @O verride
  129           pu blic List< DeviceModa lity> getA llDeviceMo dalities()  {
  130                    retu rn deviceM odalityDao .getAllDev iceModalit ies();
  131           }
  132           
  133           @O verride
  134           pu blic Devic eModality  getModalit yByName(St ring name)  {
  135                    retu rn deviceM odalityDao .getModali tyByName(n ame);
  136           }
  137           
  138           @O verride
  139           pu blic Devic eModality  getModalit yById(Long  id) {
  140                    retu rn deviceM odalityDao .getModali tyById(id) ;
  141           }
  142           
  143           // parse the  fiscal yea r from use r selectio n
  144           pu blic Strin g[] parseF iscalSelec ted(PSSRep ortForm fo rm) throws  ParseExce ption {
  145                    Stri ng[] dateA rray = new  String[TW O];
  146                    //fi scal from  date setup
  147                    Cale ndar calFr omDate = C alendar.ge tInstance( );
  148                    calF romDate.se tTime(Date Utils.pars eDate(form .getFiscal FromDate() , YEAR));
  149                    calF romDate.se t(Integer. parseInt(" " + form.g etFiscalFr omDate()),  OCT, ONE) ;
  150                    calF romDate.ro ll(Calenda r.YEAR, -1 );
  151                    date Array[FROM ] = DateUt ils.format (calFromDa te.getTime (), DateUt ils.MMDDYY YY);
  152                    //fi scal to da te setup
  153                    Cale ndar calTo Date = Cal endar.getI nstance();
  154                    calT oDate.setT ime(DateUt ils.parseD ate(form.g etFiscalFr omDate(),  YEAR));
  155                    calT oDate.set( Integer.pa rseInt(""  + form.get FiscalToDa te()), SEP T, THIRTY) ;
  156                    date Array[TO]  = DateUtil s.format(c alToDate.g etTime(),  DateUtils. MMDDYYYY);
  157                    retu rn dateArr ay;
  158           }
  159           
  160           
  161           // parse the  quarter an d year fro m user sel ection
  162           pu blic Strin g[] parseQ uarterSele cted(PSSRe portForm f orm) throw s ParseExc eption {
  163                    Stri ng[] dateA rray = new  String[TW O];
  164                    //qu arter from  date setu p
  165                    Stri ng qFrom =  "" + form .getQuarte rFromDate( ).charAt(6 );
  166                    Cale ndar calFr omDate = C alendar.ge tInstance( );
  167                    Stri ng fMonth  = null;
  168                    Stri ng fMonthY ear = null ;
  169                    swit ch (qFrom)  {
  170                    case  Q1:
  171                             fMonth  = Q1_STAR T_STR;
  172                             fMonth Year = fMo nth + "/"  + form.get QuarterFro mDate().su bstring(ZE RO, NUM_QT RS);
  173                             break;
  174                    case  Q2: 
  175                             fMonth  = Q2_STAR T_STR;
  176                             fMonth Year = fMo nth + "/"  + form.get QuarterFro mDate().su bstring(ZE RO, NUM_QT RS);
  177                             break;
  178                    case  Q3:
  179                             fMonth  = Q3_STAR T_STR;
  180                             fMonth Year = fMo nth + "/"  + form.get QuarterFro mDate().su bstring(ZE RO, NUM_QT RS);
  181                             break;
  182                    case  Q4:
  183                             fMonth  = Q4_STAR T_STR;
  184                             fMonth Year = fMo nth + "/"  + form.get QuarterFro mDate().su bstring(ZE RO, NUM_QT RS);
  185                             break;
  186                    defa ult:
  187                             break;
  188           }
  189                    calF romDate.se tTime(Date Utils.pars eDate(fMon thYear, "M M/yyyy"));
  190                    if(q From.equal s(Q1)) cal FromDate.r oll(Calend ar.YEAR, Y EAR_ROLLBA CK);
  191                    calF romDate.se t(Calendar .DAY_OF_MO NTH, calFr omDate.get ActualMini mum(Calend ar.DAY_OF_ MONTH));
  192                    date Array[FROM ] = DateUt ils.format (calFromDa te.getTime (), DateUt ils.MMDDYY YY);
  193                    //qu arter to d ate setup
  194                    Stri ng qTo = " " + form.g etQuarterT oDate().ch arAt(6);
  195                    Cale ndar calTo Date = Cal endar.getI nstance();
  196                    Stri ng tMonth  = null;
  197                    Stri ng tMonthY ear = null ;
  198                    swit ch (qTo) {
  199                    case  Q1:
  200                             tMonth  = Q1_END_ STR;
  201                             tMonth Year = tMo nth + "/"  + form.get QuarterToD ate().subs tring(ZERO , NUM_QTRS );
  202                             break;
  203                    case  Q2: 
  204                             tMonth  = Q2_END_ STR;
  205                             tMonth Year = tMo nth + "/"  + form.get QuarterToD ate().subs tring(ZERO , NUM_QTRS );
  206                             break;
  207                    case  Q3:
  208                             tMonth  = Q3_END_ STR;
  209                             tMonth Year = tMo nth + "/"  + form.get QuarterToD ate().subs tring(ZERO , NUM_QTRS );
  210                             break;
  211                    case  Q4:
  212                             tMonth  = Q4_END_ STR;
  213                             tMonth Year = tMo nth + "/"  + form.get QuarterToD ate().subs tring(ZERO , NUM_QTRS );
  214                             break;
  215                    defa ult:
  216                             break;
  217           }
  218                    calT oDate.setT ime(DateUt ils.parseD ate(tMonth Year, "MM/ yyyy"));
  219                    if(q To.equals( Q1)) calTo Date.roll( Calendar.Y EAR, YEAR_ ROLLBACK);
  220                    calT oDate.set( Calendar.D AY_OF_MONT H, calToDa te.getActu alMaximum( Calendar.D AY_OF_MONT H));
  221                    date Array[TO]  = DateUtil s.format(c alToDate.g etTime(),  DateUtils. MMDDYYYY);
  222                    retu rn dateArr ay;
  223           }
  224           
  225           @S uppressWar nings("dep recation")
  226           pr ivate Arra yList<Stri ng> yearPa rse(PSSRep ortForm fo rm, List<S atisfactio nSurveyQue stionResul t> data) {
  227                    Arra yList<Stri ng> years  = new Arra yList<Stri ng>();
  228                    Cale ndar dateF rom = Cale ndar.getIn stance();
  229                    date From.set(O NE, data.g et(0).getR esults().g et(0).getY ear());
  230                    date From.roll( Calendar.Y EAR, - ONE );
  231                    Cale ndar dateT o = Calend ar.getInst ance();
  232                    date To.set(ONE , data.get (0).getRes ults().get (data.get( 0).getResu lts().size ()-ONE).ge tYear());
  233                    Date  dateCnt =  new Date( );
  234                    for( ; dateFrom .equals(da teTo); dat eFrom.roll (Calendar. YEAR, YEAR _ROLLUP))  {
  235                             years. add("" + ( dateFrom.g etTime().g etYear())) ;
  236                    }
  237                    retu rn years;
  238           }
  239           
  240           
  241           
  242           pr ivate fina l class Qu estionList  {
  243                    priv ate int ye ar;
  244                    priv ate double [] qrtValu es;
  245                    priv ate double [] qrtStdD evValues;
  246                    priv ate double [] qrtMean Val;
  247                    priv ate double [][] qrtAl lMean;
  248                    priv ate int[][ ] qrtAllMo dCtr;
  249                    int[ ] avgCount  = new int [4];
  250                    priv ate Object [][] modal ityQrtValu es;
  251                    priv ate Object [][] modal ityStdrDev QrtValues;
  252                    priv ate String  questionT ext;
  253                    priv ate int qu estionNum;
  254                    priv ate int[]  qrtCntr;
  255                    priv ate int[][ ] modCntr;
  256                    
  257                    priv ate Questi onList() {
  258                             qrtVal ues = new  double[NUM _QTRS];
  259                             year =  ZERO;
  260                             modali tyQrtValue s = new Ob ject[NUM_Q TRS][NUM_Q TRS];
  261                             qrtStd DevValues  = new doub le[NUM_QTR S];
  262                             qrtMea nVal = new  double[NU M_QTRS];
  263                             qrtAll Mean = new  double[NU M_QTRS][NU M_QTRS];
  264                             modali tyStdrDevQ rtValues =  new Objec t[NUM_QTRS ][NUM_QTRS ];
  265                             qrtCnt r = new in t[NUM_QTRS ];
  266                             modCnt r = new in t[NUM_QTRS ][NUM_QTRS ];
  267                             qrtAll ModCtr = n ew int[NUM _QTRS][NUM _QTRS];
  268                             for (i nt i = ZER O; i < qrt Values.len gth; i++)  {
  269                                      qrtValue s[i] = 0.0 ;
  270                                      qrtStdDe vValues[i]  = 0.0;
  271                                      qrtMeanV al[i] = 0. 0;
  272                                      qrtCntr[ i] = ZERO;
  273                                      avgCount [i] = ZERO ;
  274                             }
  275                             for(in t i = 0; i  < modalit yQrtValues .length; i ++){
  276                                      for(int  j = 0; j <  modalityQ rtValues[i ].length;  j++){
  277                                               modalityQr tValues[i] [j]= 0.0;
  278                                               modalitySt drDevQrtVa lues[i][j] = 0.0;
  279                                               qrtAllMean [i][j] = 0 .0;
  280                                               modCntr[i] [j] = ZERO ;
  281                                               qrtAllModC tr[i][j] =  0;
  282                                      }
  283                                      
  284                             }
  285                    }
  286           }
  287           
  288           /* *
  289            *  always re turn the c orrect fis cal year b ased on gi ven month  and year
  290            *  @param mo nth
  291            *  @param ye ar
  292            *  @return
  293            * /
  294           pr ivate int  getFiscalY ear(int mo nth, int y ear) {
  295                    int  fiscalYear  = 0;
  296                    if(m onth < FIS CAL_START)  {
  297                             fiscal Year = yea r;
  298                    } el se {
  299                             fiscal Year = yea r + YEAR_I NCR;
  300                    }
  301                    retu rn fiscalY ear;
  302           }
  303           
  304           /* *
  305            *  build a p air to con trol year  counters
  306              * @author  DNS
  307            *
  308            *  @param <A >
  309            *  @param <B >
  310            * /
  311           pr ivate clas s CntrSet< A, B, C, D > {
  312                    priv ate A cntY ear;
  313                    priv ate B endY ear;
  314                    priv ate C mont hCounter;
  315                    priv ate D divC ounter;
  316                    priv ate CntrSe t(A first,  B second,  C third,  D fourth)  {
  317                         this.cntYe ar = first ;
  318                         this.endYe ar = secon d;
  319                         this.month Counter =  third;
  320                         this.divCo unter = fo urth;
  321                    }
  322           }
  323           
  324           /* *
  325            *  build a p air to sep erate valu es and mod  values in  a 
  326            *  list of o bjects
  327              * @author  DNS
  328            *
  329            *  @param <A >
  330            *  @param <B >
  331            * /
  332           pr ivate clas s ValPair< A, B> {
  333                    priv ate A val;
  334                    priv ate B valA rr;
  335                    priv ate ValPai r(A first,  B second)  {
  336                         this.val =  first;
  337                         this.valAr r = second ;
  338                    }
  339           }
  340           
  341           /* *
  342            *  object th at houses  the fiscal  data
  343              * @author  DNS
  344            *
  345            * /
  346           pr ivate fina l class Fi scalData {
  347                    priv ate List<I nteger> fi scalYearLi st;
  348                    priv ate List<V alPair<Dou ble, doubl e[]>> fisc alYearValu es;
  349                    priv ate List<V alPair<Dou ble, doubl e[]>> fisc alSDValues ;
  350                    priv ate List<V alPair<Dou ble, doubl e[]>> fisc alMeanValu es;
  351                    priv ate String  questionT ext;
  352                    priv ate int qu estionNum;
  353                    priv ate List<V alPair<Int eger, int[ ]>> fiscal AnswerCnt;
  354                    priv ate List<i nt[]> modC ntr;
  355                    priv ate int cu rrentMonth ;
  356                    
  357                    priv ate Fiscal Data() {
  358                             this.e mpty();
  359                    }
  360                    
  361                    priv ate void e mpty() {
  362                             this.f iscalYearL ist = new  ArrayList< Integer>() ;
  363                             this.f iscalYearV alues = ne w ArrayLis t<ValPair< Double, do uble[]>>() ;
  364                             this.f iscalMeanV alues = ne w ArrayLis t<ValPair< Double, do uble[]>>() ;
  365                             this.f iscalSDVal ues = new  ArrayList< ValPair<Do uble, doub le[]>>();
  366                             this.q uestionTex t = "";
  367                             this.f iscalAnswe rCnt = new  ArrayList <ValPair<I nteger, in t[]>>();
  368                             this.q uestionNum  = INT_INI T;
  369                             this.m odCntr = n ew ArrayLi st<int[]>( );
  370                             this.c urrentMont h = INT_IN IT;
  371                    }
  372           }
  373           
  374           /* *
  375            *  method to  seperate  the modali ties into  buckets 
  376            *  that corr espond to  the proper  mods
  377            *  @param fo rm
  378            *  @param mo n
  379            *  @return
  380            * /
  381           pr ivate void  modDataPa rse(PSSRep ortForm fo rm, Satisf actionSurv eyQuestion  mon, int  yr) {
  382                    swit ch (form.g etModality Name()) {
  383                    case  BRWSR_ID:
  384                             setFis calValues( form, yr,  BRWSR, mon );
  385                             questi onList.mod Cntr.get(q uestionLis t.fiscalYe arList.ind exOf(yr))[ BRWSR]++;
  386                             break;
  387                    case  DEVICE_ID :
  388                             setFis calValues( form, yr,  H_DEVICE,  mon);
  389                             questi onList.mod Cntr.get(q uestionLis t.fiscalYe arList.ind exOf(yr))[ H_DEVICE]+ +;
  390                             break;
  391                    case  IVR_ID:
  392                             setFis calValues( form, yr,  I_V_R, mon );
  393                             questi onList.mod Cntr.get(q uestionLis t.fiscalYe arList.ind exOf(yr))[ I_V_R]++;
  394                             break;
  395                    case  PSS_ALL_M OD:
  396                             switch  (mon.getM odality())  {
  397                             case B RWSR_STR:
  398                                      setFisca lValues(fo rm, yr, BR WSR, mon);
  399                                      question List.modCn tr.get(que stionList. fiscalYear List.index Of(yr))[BR WSR]++;
  400                                      break;
  401                             case D EVICE_STR:
  402                                      setFisca lValues(fo rm, yr, H_ DEVICE, mo n);
  403                                      question List.modCn tr.get(que stionList. fiscalYear List.index Of(yr))[H_ DEVICE]++;
  404                                      break;
  405                             case I VR_STR:
  406                                      setFisca lValues(fo rm, yr, I_ V_R, mon);
  407                                      question List.modCn tr.get(que stionList. fiscalYear List.index Of(yr))[I_ V_R]++;
  408                                      break;
  409                             case T OTALS_STR:
  410                                      setFisca lValues(fo rm, yr, TO TALS, mon) ;
  411                                      question List.modCn tr.get(que stionList. fiscalYear List.index Of(yr))[TO TALS]++;
  412                                      break;
  413                             }
  414                             break;
  415                    defa ult:
  416                             break;
  417                    }
  418           }
  419           /* *
  420            *  during mo dality cyc ling used  to inser a vg and cou nt values  for indivi dual
  421            *  modalitie s and to r educe code  reuse
  422            *  @param fo rm standar d pssRepor t form
  423            *  @param yr  fiscal ye ar used fo r indexing
  424            *  @param mo d current  mod for pr oper value  placement
  425            *  @param mo n satisfac tionSurvey Question t hat contai ns the val ues needed
  426            * /
  427           pr ivate void  setFiscal Values(PSS ReportForm  form, int  yr, int m od, Satisf actionSurv eyQuestion  mon) {
  428                    ques tionList.f iscalYearV alues.get( questionLi st.fiscalY earList.in dexOf(yr)) .valArr[mo d] += mon. getAvgAnsw er();
  429                    ques tionList.f iscalSDVal ues.get(qu estionList .fiscalYea rList.inde xOf(yr)).v alArr[mod]  += mon.ge tStdDeviat ion();
  430                    ques tionList.f iscalMeanV alues.get( questionLi st.fiscalY earList.in dexOf(yr)) .valArr[mo d] += mon. getMean();
  431                    if(f orm.getMod alityName( ).equals(P SS_ALL_MOD )) {
  432                             questi onList.fis calAnswerC nt.get(que stionList. fiscalYear List.index Of(yr)).va lArr[mod]  += mon.get AnswerCoun t();
  433                    } el se {
  434                             questi onList.fis calAnswerC nt.get(que stionList. fiscalYear List.index Of(yr)).va l += mon.g etAnswerCo unt();
  435                    }
  436           }
  437           
  438           /* *
  439            *  loop thro ugh and bu ild year l ist to hav e a full r ange of th e years
  440            *  for index ing and po pulation o f other fi elds
  441            *  @param ye arCount
  442            *  @param yr Cntr
  443            * /
  444           pr ivate void  buildFisc alData(int  yearCount , int yrCn tr) {
  445                    Inte ger cntr =  yrCntr;
  446                    for( int i = 0;  i < yearC ount; i++)  {
  447                             questi onList.fis calYearLis t.add(cntr );
  448                             questi onList.que stionNum =  INT_INIT;
  449                             questi onList.que stionText  = "";
  450                             questi onList.fis calYearVal ues.add(ne w ValPair< Double, do uble[]>(DU B_INIT, ne w double[F OUR]));
  451                             questi onList.fis calSDValue s.add(new  ValPair<Do uble, doub le[]>(DUB_ INIT, new  double[FOU R]));
  452                             questi onList.fis calMeanVal ues.add(ne w ValPair< Double, do uble[]>(DU B_INIT, ne w double[F OUR]));
  453                             questi onList.fis calAnswerC nt.add(new  ValPair<I nteger, in t[]>(INT_I NIT, new i nt[FOUR])) ;
  454                             questi onList.mod Cntr.add(n ew int[NUM _MODS]);
  455                             cntr++ ;
  456                    }
  457           }
  458           
  459           /* *
  460            *  set the a verages fo r fiscal y ear avgVal ues based  on modalit y once the y are comb ined
  461            *  @param yr Count numb er of year s to loop  through en suring all  fiscal va lues are a veraged
  462            *  @param fo rm standar d pssRepor tForm
  463            * /
  464           pr ivate void  setFiscal ModAverage s(PSSRepor tForm form , int yr)  {
  465                             switch  (form.get ModalityNa me()) {
  466                             case P SS_ALL_MOD :
  467                                      question List.fisca lYearValue s.get(ques tionList.f iscalYearL ist.indexO f(yr)).val Arr[BRWSR]  /= questi onList.mod Cntr.get(q uestionLis t.fiscalYe arList.ind exOf(yr))[ BRWSR];
  468                                      question List.fisca lSDValues. get(questi onList.fis calYearLis t.indexOf( yr)).valAr r[BRWSR] / = question List.modCn tr.get(que stionList. fiscalYear List.index Of(yr))[BR WSR];
  469                                      question List.fisca lMeanValue s.get(ques tionList.f iscalYearL ist.indexO f(yr)).val Arr[BRWSR]  /= questi onList.mod Cntr.get(q uestionLis t.fiscalYe arList.ind exOf(yr))[ BRWSR];
  470                                      question List.fisca lYearValue s.get(ques tionList.f iscalYearL ist.indexO f(yr)).val Arr[H_DEVI CE] /= que stionList. modCntr.ge t(question List.fisca lYearList. indexOf(yr ))[H_DEVIC E];
  471                                      question List.fisca lSDValues. get(questi onList.fis calYearLis t.indexOf( yr)).valAr r[H_DEVICE ] /= quest ionList.mo dCntr.get( questionLi st.fiscalY earList.in dexOf(yr)) [H_DEVICE] ;
  472                                      question List.fisca lMeanValue s.get(ques tionList.f iscalYearL ist.indexO f(yr)).val Arr[H_DEVI CE] /= que stionList. modCntr.ge t(question List.fisca lYearList. indexOf(yr ))[H_DEVIC E];
  473                                      question List.fisca lYearValue s.get(ques tionList.f iscalYearL ist.indexO f(yr)).val Arr[I_V_R]  /= questi onList.mod Cntr.get(q uestionLis t.fiscalYe arList.ind exOf(yr))[ I_V_R];
  474                                      question List.fisca lSDValues. get(questi onList.fis calYearLis t.indexOf( yr)).valAr r[I_V_R] / = question List.modCn tr.get(que stionList. fiscalYear List.index Of(yr))[I_ V_R];
  475                                      question List.fisca lMeanValue s.get(ques tionList.f iscalYearL ist.indexO f(yr)).val Arr[I_V_R]  /= questi onList.mod Cntr.get(q uestionLis t.fiscalYe arList.ind exOf(yr))[ I_V_R];
  476                                      question List.fisca lYearValue s.get(ques tionList.f iscalYearL ist.indexO f(yr)).val Arr[TOTALS ] /= quest ionList.mo dCntr.get( questionLi st.fiscalY earList.in dexOf(yr)) [TOTALS];
  477                                      question List.fisca lSDValues. get(questi onList.fis calYearLis t.indexOf( yr)).valAr r[TOTALS]  /= questio nList.modC ntr.get(qu estionList .fiscalYea rList.inde xOf(yr))[T OTALS];
  478                                      question List.fisca lMeanValue s.get(ques tionList.f iscalYearL ist.indexO f(yr)).val Arr[TOTALS ] /= quest ionList.mo dCntr.get( questionLi st.fiscalY earList.in dexOf(yr)) [TOTALS];
  479                                      break;
  480                             case B RWSR_ID:
  481                                      question List.fisca lYearValue s.get(ques tionList.f iscalYearL ist.indexO f(yr)).val Arr[BRWSR]  /= questi onList.mod Cntr.get(q uestionLis t.fiscalYe arList.ind exOf(yr))[ BRWSR];
  482                                      question List.fisca lSDValues. get(questi onList.fis calYearLis t.indexOf( yr)).valAr r[BRWSR] / = question List.modCn tr.get(que stionList. fiscalYear List.index Of(yr))[BR WSR];
  483                                      question List.fisca lMeanValue s.get(ques tionList.f iscalYearL ist.indexO f(yr)).val Arr[BRWSR]  /= questi onList.mod Cntr.get(q uestionLis t.fiscalYe arList.ind exOf(yr))[ BRWSR];
  484                                      break;
  485                             case D EVICE_ID:
  486                                      question List.fisca lYearValue s.get(ques tionList.f iscalYearL ist.indexO f(yr)).val Arr[H_DEVI CE] /= que stionList. modCntr.ge t(question List.fisca lYearList. indexOf(yr ))[H_DEVIC E];
  487                                      question List.fisca lSDValues. get(questi onList.fis calYearLis t.indexOf( yr)).valAr r[H_DEVICE ] /= quest ionList.mo dCntr.get( questionLi st.fiscalY earList.in dexOf(yr)) [H_DEVICE] ;
  488                                      question List.fisca lMeanValue s.get(ques tionList.f iscalYearL ist.indexO f(yr)).val Arr[H_DEVI CE] /= que stionList. modCntr.ge t(question List.fisca lYearList. indexOf(yr ))[H_DEVIC E];
  489                                      break;
  490                             case I VR_ID:
  491                                      question List.fisca lYearValue s.get(ques tionList.f iscalYearL ist.indexO f(yr)).val Arr[I_V_R]  /= questi onList.mod Cntr.get(q uestionLis t.fiscalYe arList.ind exOf(yr))[ I_V_R];
  492                                      question List.fisca lSDValues. get(questi onList.fis calYearLis t.indexOf( yr)).valAr r[I_V_R] / = question List.modCn tr.get(que stionList. fiscalYear List.index Of(yr))[I_ V_R];
  493                                      question List.fisca lMeanValue s.get(ques tionList.f iscalYearL ist.indexO f(yr)).val Arr[I_V_R]  /= questi onList.mod Cntr.get(q uestionLis t.fiscalYe arList.ind exOf(yr))[ I_V_R];
  494                                      break;
  495                             defaul t:
  496                                      break;
  497                             }
  498           }
  499           
  500           /* *
  501            *  set the a verages fo r fiscal y ear avgVal ues once t hey are co mbined
  502            *  @param yr Count numb er of year s to loop  through en suring all  fiscal va lues are a veraged
  503            * /
  504           pr ivate void  setFiscal Averages(i nt yr, int  divisor,  int divCou nter) {
  505                    if(q uestionLis t.currentM onth <= FI SCAL_END)  {
  506                             questi onList.fis calYearVal ues.get(qu estionList .fiscalYea rList.inde xOf(yr)).v al /= divi sor;
  507                             questi onList.fis calSDValue s.get(ques tionList.f iscalYearL ist.indexO f(yr)).val  /= diviso r;
  508                             questi onList.fis calMeanVal ues.get(qu estionList .fiscalYea rList.inde xOf(yr)).v al /= divi sor;
  509                    } el se {
  510                             questi onList.fis calYearVal ues.get(qu estionList .fiscalYea rList.inde xOf(yr)).v al /= divC ounter;
  511                             questi onList.fis calSDValue s.get(ques tionList.f iscalYearL ist.indexO f(yr)).val  /= divCou nter;
  512                             questi onList.fis calMeanVal ues.get(qu estionList .fiscalYea rList.inde xOf(yr)).v al /= divC ounter;
  513                    }
  514           }
  515           
  516           /* *
  517            *  after par sing this  method is  used to di stribute a nswer coun ts, modali ties, and
  518            *  avgAnswer  to the li st of sat  surv quest ions
  519            *  @param mo d value th at represe nts which  modality i s currentl y being se t up
  520            *  @param fo rm standar d pssRepor tForm 
  521            *  @param yr  fiscal ye ar used to  control i ndexing
  522            * /
  523           pr ivate void  setQuesti onModality AndAvgs(in t mod, PSS ReportForm  form, Int eger yr) {
  524                    swit ch (mod) {
  525                    case  BRWSR:
  526                             if(for m.getModal ityName(). equals(PSS _ALL_MOD))  {
  527                                      question .setAnswer Count(ques tionList.f iscalAnswe rCnt.get(q uestionLis t.fiscalYe arList.ind exOf(yr)). valArr[mod ]);
  528                             } else  {
  529                                      question .setAnswer Count(ques tionList.f iscalAnswe rCnt.get(q uestionLis t.fiscalYe arList.ind exOf(yr)). val);
  530                             }
  531                             setAll ModQuestio nValues(yr , mod);
  532                             questi on.setModa lity(BRWSR _STR);
  533                             break;
  534                    case  H_DEVICE:
  535                             if(for m.getModal ityName(). equals(PSS _ALL_MOD))  {
  536                                      question .setAnswer Count(ques tionList.f iscalAnswe rCnt.get(q uestionLis t.fiscalYe arList.ind exOf(yr)). valArr[mod ]);
  537                             } else  {
  538                                      question .setAnswer Count(ques tionList.f iscalAnswe rCnt.get(q uestionLis t.fiscalYe arList.ind exOf(yr)). val);
  539                             }
  540                             setAll ModQuestio nValues(yr , mod);
  541                             questi on.setModa lity(DEVIC E_STR);
  542                             break;
  543                    case  I_V_R:
  544                             if(for m.getModal ityName(). equals(PSS _ALL_MOD))  {
  545                                      question .setAnswer Count(ques tionList.f iscalAnswe rCnt.get(q uestionLis t.fiscalYe arList.ind exOf(yr)). valArr[mod ]);
  546                             } else  {
  547                                      question .setAnswer Count(ques tionList.f iscalAnswe rCnt.get(q uestionLis t.fiscalYe arList.ind exOf(yr)). val);
  548                             }
  549                             setAll ModQuestio nValues(yr , mod);
  550                             questi on.setModa lity(IVR_S TR);
  551                             break;
  552                    case  TOTALS:
  553                             questi on.setAnsw erCount(qu estionList .fiscalAns werCnt.get (questionL ist.fiscal YearList.i ndexOf(yr) ).valArr[m od]);
  554                             setAll ModQuestio nValues(yr , mod);
  555                             questi on.setModa lity(TOTAL S_STR);
  556                             break;
  557                    defa ult:
  558                             break;
  559                    }
  560           }
  561           
  562           pr ivate void  setAllMod QuestionVa lues(int y r, int mod ) {
  563                    ques tion.setSt dDeviation (questionL ist.fiscal SDValues.g et(questio nList.fisc alYearList .indexOf(y r)).valArr [mod]);
  564                    ques tion.setMe an(questio nList.fisc alMeanValu es.get(que stionList. fiscalYear List.index Of(yr)).va lArr[mod]) ;
  565                    ques tion.setAv gAnswer(qu estionList .fiscalYea rValues.ge t(question List.fisca lYearList. indexOf(yr )).valArr[ mod]);
  566           }
  567           
  568           /* *
  569            *  after dat a is parse d this met hod is use d to build  it into a  satisfact ion survey  question  object
  570            *  to later  be added t o a list
  571            *  @param fo rm standar d pssRepor tForm
  572            *  @param yr  fiscal ye ar for ind exing
  573            *  @param qL ist Fiscal Data objec t housing  the data n eeded to b uild the q uestion
  574            *  @param i 
  575            * /
  576           pr ivate void  setQuesti onUp(PSSRe portForm f orm, int y r, FiscalD ata qList,  Integer m od) {
  577                    ques tion = new  Satisfact ionSurveyQ uestion();
  578                    ques tion.setYe ar(yr);
  579                    ques tion.setHe aderString ("FY" + yr  + " Patie nt Satisfa ction Inde x");
  580                    ques tion.setQu estionNumb er(qList.q uestionNum );
  581                    ques tion.setQu estionText (qList.que stionText) ;
  582                    if(f orm.getMod alityName( ).equals(P SS_MOD_DNI )) {
  583                             questi on.setAnsw erCount(qu estionList .fiscalAns werCnt.get (questionL ist.fiscal YearList.i ndexOf(yr) ).val);
  584                             questi on.setAvgA nswer(ques tionList.f iscalYearV alues.get( questionLi st.fiscalY earList.in dexOf(yr)) .val);
  585                             questi on.setStdD eviation(q uestionLis t.fiscalSD Values.get (questionL ist.fiscal YearList.i ndexOf(yr) ).val);
  586                             questi on.setMean (questionL ist.fiscal MeanValues .get(quest ionList.fi scalYearLi st.indexOf (yr)).val) ;
  587                             questi on.setModa lity(EMPTY _STRING);
  588                    } el se {
  589                             setQue stionModal ityAndAvgs (mod, form , yr);
  590                    }
  591           }
  592           
  593           pr ivate List <Satisfact ionSurveyQ uestion> a ddQuestion OnYearUp(S atisfactio nSurveyQue stion mon,  CntrSet<I nteger, In teger, Int eger, Inte ger> count er, int yr Count, PSS ReportForm  form, Lis t<Satisfac tionSurvey Question>  satSurvQue stList) {
  594                    int  yr = count er.cntYear ;
  595                    if(f orm.getMod alityName( ).equals(P SS_MOD_DNI )) {
  596                             setFis calAverage s(yr, coun ter.monthC ounter, co unter.divC ounter);
  597           }  else {
  598                    setF iscalModAv erages(for m, yr);
  599           }
  600                    //if  all modal ities then  create co rrespondin g Satisfac tion surve y question s
  601                    if(f orm.getMod alityName( ).equals(P SS_ALL_MOD )) {
  602                             boolea n check =  false;
  603                             for(in t i = 0; i  < NUM_MOD S; i++) {
  604                                      switch(i ) {
  605                                      case BRW SR:
  606                                               if(!(quest ionList.mo dCntr.get( questionLi st.fiscalY earList.in dexOf(yr)) [BRWSR] ==  ZERO)) {
  607                                                       se tQuestionU p(form, yr , question List, BRWS R);
  608                                                       ch eck = true ;
  609                                               }
  610                                               break;
  611                                      case H_D EVICE:
  612                                               if(!(quest ionList.mo dCntr.get( questionLi st.fiscalY earList.in dexOf(yr)) [H_DEVICE]  == ZERO))  {
  613                                                       se tQuestionU p(form, yr , question List, H_DE VICE);
  614                                                       ch eck = true ;
  615                                               }
  616                                               break;
  617                                      case I_V _R:
  618                                               if(!(quest ionList.mo dCntr.get( questionLi st.fiscalY earList.in dexOf(yr)) [I_V_R] ==  ZERO)) {
  619                                                       se tQuestionU p(form, yr , question List, I_V_ R);
  620                                                       ch eck = true ;
  621                                               }
  622                                               break;
  623                                      case TOT ALS:
  624                                               if(!(quest ionList.mo dCntr.get( questionLi st.fiscalY earList.in dexOf(yr)) [TOTALS] = = ZERO)) {
  625                                                       se tQuestionU p(form, yr , question List, TOTA LS);
  626                                                       ch eck = true ;
  627                                               }
  628                                               break;
  629                                      default:
  630                                               break;
  631                                      }
  632                             if (ch eck) satSu rvQuestLis t.add(ques tion);
  633                             check  = false;
  634                             }
  635                    } el se {
  636                             switch  (form.get ModalityNa me()) {
  637                             case B RWSR_ID:
  638                                      setQuest ionUp(form , yr, ques tionList,  BRWSR);
  639                                      break;
  640                             case D EVICE_ID:
  641                                      setQuest ionUp(form , yr, ques tionList,  H_DEVICE);
  642                                      break;
  643                             case I VR_ID:
  644                                      setQuest ionUp(form , yr, ques tionList,  I_V_R);
  645                                      break;
  646                             //defa ult is use d for moda lity do no t include
  647                             defaul t:
  648                                      setQuest ionUp(form , yr, ques tionList,  null);
  649                                      break;
  650                             }
  651                             satSur vQuestList .add(quest ion);
  652                    }
  653                    retu rn satSurv QuestList;
  654           }
  655           
  656           /* *
  657            *  method us ed to pars e the fisc al data fr om the que ryResults  gotten fro m the
  658            *  call to g etSatisfac tionSurvey Report(PSS ReportForm  form)
  659            *  @param fo rm standar d pssRepor tForm
  660            *  @param da ta query r esults
  661            *  @return a  list of S atisfactio nSurveyQue stionResul ts
  662            * /
  663           pr ivate List <Satisfact ionSurveyQ uestionRes ult> yearD ataParse(P SSReportFo rm form, L ist<Satisf actionSurv eyQuestion Result> da ta) {
  664                    List <Satisfact ionSurveyQ uestion> s atSurvQues tList = ne w ArrayLis t<Satisfac tionSurvey Question>( );
  665                    List <Satisfact ionSurveyQ uestionRes ult> resul tList = ne w ArrayLis t<Satisfac tionSurvey QuestionRe sult>();
  666                    Sati sfactionSu rveyQuesti onResult r esult = nu ll;
  667                    //bu ild and in itialize c ounter pai r
  668                    Cntr Set<Intege r,Integer,  Integer,  Integer> c ounter = n ew CntrSet <Integer,  Integer, I nteger, In teger>(INT _INIT, INT _INIT, INT _INIT, INT _INIT);
  669                
  670                    //lo op through  given dat a and get  a monthlis t for each  question  in the sur vey
  671                for(Sati sfactionSu rveyQuesti onResult q Result : d ata) {
  672                    //ge ts month l ist
  673                    List <Satisfact ionSurveyQ uestion> m onthList =  qResult.g etResults( );
  674                    resu lt = new S atisfactio nSurveyQue stionResul t();
  675                    resu lt.setQues tionNumber (monthList .get(ZERO) .getQuesti onNumber() );
  676                    resu lt.setQues tionText(m onthList.g et(ZERO).g etQuestion Text().sub string(THR EE));
  677                    
  678                             //rese t year cou nter to us e in the n ext inner  loop
  679                             //set  the first  fiscal yea r in the m onth list  and the la st
  680                             counte r.cntYear  = getFisca lYear(mont hList.get( ZERO).getM onthAsInt( ), monthLi st.get(ZER O).getYear ());
  681                             counte r.endYear  = getFisca lYear(mont hList.get( monthList. size() - Y EAR_INCR). getMonthAs Int(), mon thList.get (monthList .size() -  YEAR_INCR) .getYear() );
  682                             counte r.monthCou nter = INT _INIT;
  683                             counte r.divCount er = INT_I NIT;
  684                             int yr Count = (c ounter.end Year - cou nter.cntYe ar) + YEAR _INCR;
  685                             //rebu ild for th e new ques tion numbe r
  686                             //if y ou are beg inning a n ew questio n
  687                    buil dFiscalDat a(yrCount,  counter.c ntYear);
  688                    
  689                    //ad ds questio n number a nd text be fore cycli ng through  each mont h since th ey wont ch ange
  690                             questi onList.que stionNum =  monthList .get(INT_I NIT).getQu estionNumb er();
  691                             
  692                             questi onList.que stionText  = monthLis t.get(INT_ INIT).getQ uestionTex t().substr ing(THREE) ;
  693                             Intege r totalCou nt = INT_I NIT;
  694                             //loop  through e ach month  and assign  values to  the appro priate fie lds
  695                             for(Sa tisfaction SurveyQues tion mon :  monthList ) {
  696                                      question List.curre ntMonth =  mon.getMon thAsInt();
  697                                      totalCou nt++;
  698                                      //on con dition whe re fiscal  year rolls  over then
  699                                      //adds s atSurvQues tion to th e satSurvQ uestion li st and ite rates coun ter
  700                                      if(getFi scalYear(m on.getMont hAsInt(),  mon.getYea r()) != co unter.cntY ear) {
  701                                               if(!(form. getModalit yName().eq uals(PSS_A LL_MOD)))  {     
  702                                                       sa tSurvQuest List = add QuestionOn YearUp(mon , counter,  yrCount,  form, satS urvQuestLi st);
  703                                                       co unter.cntY ear = getF iscalYear( mon.getMon thAsInt(),  mon.getYe ar());
  704                                                       co unter.divC ounter = I NT_INIT;
  705                                               } else {
  706                                                       if (mon.getMo dality().e quals(TOTA LS_STR)){
  707                                                                satS urvQuestLi st = addQu estionOnYe arUp(mon,  counter, y rCount, fo rm, satSur vQuestList );
  708                                                                coun ter.cntYea r = getFis calYear(mo n.getMonth AsInt(), m on.getYear ());
  709                                                       }
  710                                               }
  711                                               counter.mo nthCounter  = 0;
  712                                      }
  713                                      counter. divCounter ++;
  714                                      counter. monthCount er++;
  715                                      if(form. getModalit yName().eq uals(PSS_M OD_DNI)) {
  716                                               questionLi st.fiscalA nswerCnt.g et(questio nList.fisc alYearList .indexOf(c ounter.cnt Year)).val  += mon.ge tAnswerCou nt();
  717                                               questionLi st.fiscalY earValues. get(questi onList.fis calYearLis t.indexOf( counter.cn tYear)).va l += mon.g etAvgAnswe r();
  718                                               questionLi st.fiscalS DValues.ge t(question List.fisca lYearList. indexOf(co unter.cntY ear)).val  += mon.get StdDeviati on();
  719                                               questionLi st.fiscalM eanValues. get(questi onList.fis calYearLis t.indexOf( counter.cn tYear)).va l += mon.g etMean();
  720                                      } else {
  721                                               modDataPar se(form, m on, counte r.cntYear) ;
  722                                      }
  723                                      if((mont hList.get( monthList. size() - Y EAR_INCR). getMonthAs Int() == m on.getMont hAsInt())  && (totalC ount.equal s(monthLis t.size())) ) {
  724                                               satSurvQue stList = a ddQuestion OnYearUp(m on, counte r, yrCount , form, sa tSurvQuest List);
  725                                               counter.di vCounter =  INT_INIT;
  726                                      }
  727                             }
  728                    resu lt.setResu lts(satSur vQuestList );
  729                    satS urvQuestLi st = new A rrayList<S atisfactio nSurveyQue stion>();
  730                    resu ltList.add (result);
  731                    ques tionList.e mpty();
  732                    }
  733                
  734                    retu rn resultL ist;
  735           }
  736           
  737           
  738           pu blic List< Satisfacti onSurveyQu estionResu lt> satSur veyYears(P SSReportFo rm form, L ist<Satisf actionSurv eyQuestion Result> re sults) {
  739                    List <Satisfact ionSurveyQ uestionRes ult> yResu lts = new  ArrayList< Satisfacti onSurveyQu estionResu lt>();
  740                    yRes ults = yea rDataParse (form, res ults);
  741                    if(y Results.is Empty()){
  742                             return  results;
  743                    }
  744                    retu rn yResult s;
  745           }        
  746           
  747           pr ivate Arra yList<Ques tionList>  quarterPar se(PSSRepo rtForm for m, List<Sa tisfaction SurveyQues tionResult > data) {
  748                    Arra yList<Ques tionList>  questList  = new Arra yList<Ques tionList>( );
  749                    buck et = new Q uestionLis t();
  750                    for( Satisfacti onSurveyQu estionResu lt qResult  : data) {
  751                             List<S atisfactio nSurveyQue stion> mon thList = q Result.get Results();
  752                             bucket .questionN um = qResu lt.getQues tionNumber ();
  753                             bucket .questionT ext = qRes ult.getQue stionText( ).substrin g(THREE);
  754                             if(mon thList.get (ZERO).get MonthAsInt () < Q1_ST ART) {
  755                                      bucket.y ear = mont hList.get( ZERO).getY ear();
  756                             } else  {
  757                                      bucket.y ear = mont hList.get( ZERO).getY ear() + ON E;
  758                             }
  759                             int cn tYear = ZE RO;
  760                             if(mon thList.get (ZERO).get MonthAsInt () < Q1_ST ART){
  761                                      cntYear  = monthLis t.get(ZERO ).getYear( ) - 1;
  762                             }else{
  763                                      cntYear  = monthLis t.get(ZERO ).getYear( );
  764                             }
  765                             questL ist.ensure Capacity(m onthList.s ize());
  766                             int co untQtr = Z ERO;
  767                             for(Sa tisfaction SurveyQues tion mon :  monthList ) {
  768                                      if(mon.g etMonthAsI nt() == 10  && mon.ge tYear() !=  cntYear)  {
  769                                               questList. add(bucket );
  770                                               bucket = n ew Questio nList();
  771                                               bucket.que stionNum =  qResult.g etQuestion Number();
  772                                               bucket.que stionText  = qResult. getQuestio nText().su bstring(TH REE);
  773                                               bucket.yea r = mon.ge tYear() +  ONE;
  774                                               cntYear =  mon.getYea r();
  775                                      }
  776                                      if(mon.g etMonthAsI nt() >= Q1 _START){
  777                                               setBucketC onditional ( mon,  fo rm,  ZERO)
  778                                      }
  779                                      if(mon.g etMonthAsI nt() <= Q2 _END){
  780                                               setBucketC onditional ( mon,  fo rm,  ONE);
  781                                      }
  782                                      if(mon.g etMonthAsI nt() >= Q3 _START &&  mon.getMon thAsInt()  <= Q3_END) {
  783                                               setBucketC onditional ( mon,  fo rm,  TWO);
  784                                      }
  785                                      if(mon.g etMonthAsI nt() >= Q4 _START &&  mon.getMon thAsInt()  <= Q4_END) {
  786                                               setBucketC onditional ( mon,  fo rm,  THREE );
  787                                      }
  788                                      countQtr ++;
  789                                      if(count Qtr == mon thList.siz e()) {
  790                                               questList. add(bucket );
  791                                               bucket = n ew Questio nList();
  792                                              
  793                                              
  794                                      }
  795                             }
  796                    }
  797                    
  798                    retu rn questLi st;
  799           }
  800           
  801           pu blic List< Satisfacti onSurveyQu estionResu lt> satSur veyQuarter s(PSSRepor tForm form , List<Sat isfactionS urveyQuest ionResult>  results){
  802                    List <Satisfact ionSurveyQ uestionRes ult> qResu lts = new  ArrayList< Satisfacti onSurveyQu estionResu lt>();
  803                    Arra yList<Ques tionList>  questList  = quarterP arse(form,  results);
  804                    Sati sfactionSu rveyQuesti onResult r ow = new S atisfactio nSurveyQue stionResul t();
  805                    List <Satisfact ionSurveyQ uestion> r owResult =  new Array List<Satis factionSur veyQuestio n>();
  806                    if(q uestList.i sEmpty()){
  807                             return  results;
  808                    }
  809                    int  questionCt r = questL ist.get(ZE RO).questi onNum;
  810                    int  entryCtr =  ZERO;
  811                    
  812                    for( QuestionLi st entry:  questList)  {
  813                             entryC tr++;
  814                             if(que stionCtr ! = entry.qu estionNum) {
  815                                      row.setR esults(row Result);
  816                                      qResults .add(row);
  817                                      rowResul t = new Ar rayList<Sa tisfaction SurveyQues tion>();
  818                                      row = ne w Satisfac tionSurvey QuestionRe sult();
  819                                      question Ctr = entr y.question Num;
  820                             }
  821                             
  822                             if(for m.getModal ityName(). equals("-2 ")){
  823                                      row.setQ uestionNum ber(entry. questionNu m);
  824                                      row.setQ uestionTex t(entry.qu estionText );
  825                                      for(int  i = 0; i <  NUM_QTRS;  i++){
  826                                               Satisfacti onSurveyQu estion q =  new Satis factionSur veyQuestio n();
  827                                               q.setAnswe rCount(ent ry.avgCoun t[i]);
  828                                              
  829                                               if(form.ge tReportVer sionButton Selection( ) == 1) {
  830                                                       q. setMean((( double)ent ry.qrtMean Val[i]/ent ry.qrtCntr [i]));
  831                                               } else {
  832                                                       q. setMean((( double)ent ry.qrtMean Val[i]/ent ry.qrtCntr [i]));
  833                                               }
  834                                               q.setAvgAn swer(entry .qrtValues [i]/entry. qrtCntr[i] );
  835                                               q.setStdDe viation(en try.qrtStd DevValues[ i]/entry.q rtCntr[i]) ;
  836                                               q.setHeade rString("Q " + (i + O NE) + " FY " + entry. year + " P atient Sat isfaction  Index");
  837                                               q.setQuest ionNumber( entry.ques tionNum);
  838                                               q.setQuest ionText(en try.questi onText);
  839                                               q.setQuart erAsInt(i  + ONE);
  840                                               q.setQuart erAsString ("Q" +  (i  + ONE) +  " FY" + en try.year);
  841                                               q.setModal ity("");
  842                                               q.setYear( entry.year );
  843                                               if(q.getAn swerCount( ) != ZERO)  rowResult .add(q);
  844                                      }
  845                             } else  if(form.g etModality Name().equ als("-1")) {
  846                                      row.setQ uestionNum ber(entry. questionNu m);
  847                                      row.setQ uestionTex t(entry.qu estionText );
  848                                      for(int  i = 0; i <  NUM_QTRS;  i++){
  849                                               for(int j  = 0; j < N UM_QTRS; j ++){
  850                                                       Sa tisfaction SurveyQues tion q = n ew Satisfa ctionSurve yQuestion( );
  851                                                       q. setAnswerC ount(entry .modCntr[i ][j]);
  852                                                       q. setStdDevi ation((dou ble)entry. modalitySt drDevQrtVa lues[i][j] /entry.qrt AllModCtr[ i][j]);
  853                                                       q. setAvgAnsw er((double )entry.mod alityQrtVa lues[i][j] /entry.qrt AllModCtr[ i][j]);
  854                                                       if (form.getR eportVersi onButtonSe lection()  == 1) {
  855                                                                q.se tMean(((do uble)entry .qrtAllMea n[i][j]/en try.qrtAll ModCtr[i][ j]));
  856                                                       }  else {
  857                                                                q.se tMean(((do uble)entry .qrtAllMea n[i][j]/en try.qrtAll ModCtr[i][ j]));
  858                                                       }
  859                                                       q. setHeaderS tring("Q"  + (i +1) +  " FY" + e ntry.year  + " Patien t Satisfac tion Index ");
  860                                                       q. setQuestio nNumber(en try.questi onNum);
  861                                                       q. setQuestio nText(entr y.question Text);
  862                                                       q. setQuarter AsInt(i+1) ;
  863                                                       q. setQuarter AsString(" Q" +  (i + 1) + " FY"  + entry.y ear);
  864                                                       sw itch (j) {
  865                                                                case  BRWSR:  
  866                                                                         q.setM odality("B rowser");
  867                                                                         break;
  868                                                                case  H_DEVICE:  
  869                                                                         q.setM odality("H ome Device ");
  870                                                                         break;
  871                                                                case  I_V_R:
  872                                                                         q.setM odality("I VR");
  873                                                                         break;
  874                                                                defa ult:
  875                                                                         q.setM odality("T otal");
  876                                                                         break;
  877                                                       }
  878                                                       q. setYear(en try.year);
  879                                                       if (q.getAnsw erCount()  != ZERO)   rowResult. add(q);
  880                                               }
  881                                      }
  882                             } else  {
  883                                      row.setQ uestionNum ber(entry. questionNu m);
  884                                      row.setQ uestionTex t(entry.qu estionText );
  885                                      for(int  i = 0; i <  FOUR; i++ ){
  886                                               Satisfacti onSurveyQu estion q =  new Satis factionSur veyQuestio n();
  887                                               q.setAnswe rCount(ent ry.avgCoun t[i]);
  888                                               int pos =  0;
  889                                               switch (fo rm.getModa lityName() ) {
  890                                               case BRWSR _ID:  
  891                                                       po s = BRWSR;
  892                                                       q. setModalit y(BRWSR_ST R);
  893                                                       br eak;
  894                                               case DEVIC E_ID: 
  895                                                       po s = H_DEVI CE;
  896                                                       q. setModalit y(DEVICE_S TR);
  897                                                       br eak;
  898                                               case IVR_I D:
  899                                                       po s = I_V_R;
  900                                                       q. setModalit y(IVR_STR) ;
  901                                                       br eak;
  902                                               default:
  903                                                       br eak;
  904                                               }
  905                                               q.setStdDe viation((d ouble)entr y.modality StdrDevQrt Values[i][ pos]/entry .qrtCntr[i ]);
  906                                               q.setAvgAn swer((doub le)entry.m odalityQrt Values[i][ pos]/entry .qrtCntr[i ]);
  907                                               if(form.ge tReportVer sionButton Selection( ) == 1) {
  908                                                       q. setMean((( double)ent ry.qrtMean Val[i]/ent ry.qrtCntr [i]));
  909                                               } else {
  910                                                       q. setMean((( double)ent ry.qrtMean Val[i]/ent ry.qrtCntr [i]));
  911                                               }
  912                                               q.setHeade rString("Q " + (i +1)  + " FY" +  entry.yea r + " Pati ent Satisf action Ind ex");
  913                                               q.setQuest ionNumber( entry.ques tionNum);
  914                                               q.setQuest ionText(en try.questi onText);
  915                                               q.setQuart erAsInt(i  + ONE); // one added  to correct  indexing
  916                                               q.setQuart erAsString ("Q" +  (i  + ONE) +  " FY" + en try.year);
  917                                               q.setYear( entry.year );
  918                                               if(q.getAn swerCount( ) != ZERO)  rowResult .add(q);
  919                                      }
  920                             }
  921                             if(ent ryCtr == q uestList.s ize()){
  922                                      row.setR esults(row Result);
  923                                      qResults .add(row);
  924                             }
  925                    }
  926                    retu rn qResult s;
  927           }
  928  
  929           pr ivate Link edList<Sur veyTrendCh artResult>  surveyTre ndsQuarter s(PSSRepor tForm form , LinkedLi st<SurveyT rendChartR esult> res ults){
  930                    Link edList<Sur veyTrendCh artResult>  quarterRe sults = ne w LinkedLi st<SurveyT rendChartR esult>();
  931                    Obje ct[][] tem p = new Ob ject[NUM_Q TRS][TWO];
  932                    for( Object[] e ntry: temp ){
  933                             entry[ ZERO] ="";
  934                             entry[ ONE] = 0;
  935                    }
  936                    int  month = 0;
  937                    for( SurveyTren dChartResu lt entry:  results){
  938                             month  = entry.ge tMonthNum( );
  939                             if(mon th >= Q1_S TART){
  940                                      temp[ZER O][ZERO] =  "Q1";
  941                                      temp[ZER O][ONE] =  (int)temp[ ZERO][ONE]  + entry.g etNumOfSur veys();
  942                             }
  943                             if(mon th <= Q2_E ND){
  944                                      temp[ONE ][ZERO] =  "Q2";
  945                                      temp[ONE ][ONE] = ( int)temp[O NE][ONE] +  entry.get NumOfSurve ys();
  946                             }
  947                             if(mon th >= Q3_S TART && mo nth <= Q3_ END){
  948                                      temp[TWO ][ZERO] =  "Q3";
  949                                      temp[TWO ][ONE] = ( int)temp[T WO][ONE] +  entry.get NumOfSurve ys();
  950                             }
  951                             if(mon th >= Q4_S TART && mo nth <= Q4_ END){
  952                                      temp[THR EE][ZERO]  = "Q4";
  953                                      temp[THR EE][ONE] =  (int)temp [THREE][ON E] + entry .getNumOfS urveys();
  954                             }
  955                    }
  956                    
  957                    for( Object[] e ntry: temp ){
  958                             Survey TrendChart Result row  = new Sur veyTrendCh artResult( );
  959                             row.se tQuarter(e ntry[ZERO] .toString( ));
  960                             row.se tNumOfSurv eys(Intege r.parseInt (entry[ONE ].toString ()));
  961                             if(row .getNumOfS urveys() ! = ZERO) qu arterResul ts.add(row );
  962                    }
  963                    retu rn quarter Results;
  964           }
  965           
  966           pr ivate void  setBucket (int num,  int mod, S atisfactio nSurveyQue stion mon,  PSSReport Form form)  {
  967                    buck et.modalit yQrtValues [num][mod]  = (double )bucket.mo dalityQrtV alues[num] [mod] + mo n.getAvgAn swer();
  968                    buck et.modalit yStdrDevQr tValues[nu m][mod] =  (double)bu cket.modal ityStdrDev QrtValues[ num][mod]  + mon.getS tdDeviatio n();
  969                    if(f orm.getMod alityName( ).equals(" -1")) {
  970                             bucket .modCntr[n um][mod] =  bucket.mo dCntr[num] [mod] + mo n.getAnswe rCount();
  971                             bucket .qrtAllMea n[num][mod ] = (doubl e)bucket.q rtAllMean[ num][mod]  + mon.getM ean();
  972                             bucket .qrtAllMod Ctr[num][m od]++;
  973                    } el se {
  974                             bucket .avgCount[ num] += mo n.getAnswe rCount();
  975                             bucket .qrtMeanVa l[num] +=  mon.getMea n();
  976                             bucket .qrtCntr[n um]++;
  977                    }
  978           }
  979           
  980           pr ivate void  setBucket Conditiona l(Satisfac tionSurvey Question m on, PSSRep ortForm fo rm, int nu m) {
  981                    if ( mon.getMod ality().eq uals("")){
  982                             bucket .qrtValues [num] = bu cket.qrtVa lues[num]  + mon.getA vgAnswer() ;
  983                             bucket .qrtStdDev Values[num ] = bucket .qrtStdDev Values[num ] + mon.ge tStdDeviat ion();
  984                             bucket .qrtMeanVa l[num] = b ucket.qrtM eanVal[num ] + mon.ge tMean();
  985                             bucket .avgCount[ num] = buc ket.avgCou nt[num] +  mon.getAns werCount() ;
  986                             bucket .qrtCntr[n um]++;
  987                    }els e{
  988                             switch  (mon.getM odality())  {
  989                             case " Browser":   
  990                                      setBucke t(num, BRW SR, mon, f orm);
  991                                      break;
  992                             case " Home Devic e": 
  993                                      setBucke t(num, H_D EVICE, mon , form);
  994                                      break;
  995                             case " IVR":
  996                                      setBucke t(num, I_V _R, mon, f orm);
  997                                      break;
  998                             case " Total":
  999                                      setBucke t(num, TOT ALS, mon,  form);
  1000                                      break;
  1001                             defaul t:
  1002                                      break;
  1003                             }
  1004                    }
  1005           }
  1006           
  1007  
  1008           pr ivate List <Satisfact ionSurveyQ uestionRes ult> satAl lModalitie sCheck(PSS ReportForm  form, Lis t<Satisfac tionSurvey QuestionRe sult> data ) {
  1009                    if(! form.getMo dalityName ().equals( PSS_ALL_MO D)){
  1010                             return  data;
  1011                    }
  1012                    List <Satisfact ionSurveyQ uestionRes ult> resul tList = ne w ArrayLis t<Satisfac tionSurvey QuestionRe sult>();
  1013                    Sati sfactionSu rveyQuesti onResult r esult = nu ll;
  1014                
  1015                    //lo op through  given dat a and get  a monthlis t for each  question  in the sur vey
  1016                for(Sati sfactionSu rveyQuesti onResult q Result : d ata) {
  1017                    //ge ts month l ist
  1018                    List <Satisfact ionSurveyQ uestion> m onthList =  qResult.g etResults( );
  1019                    resu lt = new S atisfactio nSurveyQue stionResul t();
  1020                    resu lt.setQues tionNumber (monthList .get(ZERO) .getQuesti onNumber() );
  1021                    resu lt.setQues tionText(m onthList.g et(ZERO).g etQuestion Text().sub string(THR EE));
  1022                                      
  1023                    int  currentMon th = month List.get(Z ERO).getMo nthAsInt() ;
  1024                    Sati sfactionSu rveyQuesti on totalRo w = new Sa tisfaction SurveyQues tion();
  1025                             totalR ow.setMont hAsInt(mon thList.get (ZERO).get MonthAsInt ());
  1026                             totalR ow.setYear (monthList .get(ZERO) .getYear() );
  1027                             totalR ow.setModa lity(TOTAL S_STR);
  1028                             totalR ow.setMont hAsString( monthList. get(ZERO). getMonthAs String());
  1029                    int  answerCoun t = ZERO;
  1030                    int  loopCounte r = ZERO;
  1031                    
  1032                    List <Integer>  surveysPer ModPerMon  = new Arra yList<Inte ger>();
  1033                    List <Double> a vgsPerModP erMon = ne w ArrayLis t<Double>( );
  1034                    List <Double> s tdDevPerMo dPerMon =  new ArrayL ist<Double >();
  1035                    List <Double> m eanPerModP erMon = ne w ArrayLis t<Double>( );
  1036                    
  1037                             for(Sa tisfaction SurveyQues tion mon :  monthList ) {
  1038                                      loopCoun ter++;
  1039                                      if(curre ntMonth !=  mon.getMo nthAsInt() ){
  1040                                              
  1041                                               Double avg  = 0.0;
  1042                                      Double m ean = 0.0;
  1043                                      Double s tdDev = 0. 0;
  1044                                               for(int i  = 0; i < s urveysPerM odPerMon.s ize(); i++ ) {
  1045  
  1046                                                       //  Calculate  a weighte d average
  1047                                                       av g += avgsP erModPerMo n.get(i)*( surveysPer ModPerMon. get(i)/(do uble)answe rCount);
  1048                                                       st dDev += st dDevPerMod PerMon.get (i)*(surve ysPerModPe rMon.get(i )/(double) answerCoun t);
  1049                                                       me an += mean PerModPerM on.get(i)* (surveysPe rModPerMon .get(i)/(d ouble)answ erCount);
  1050                                               }
  1051                                              
  1052                                               totalRow.s etAnswerCo unt(answer Count);
  1053                                               totalRow.s etAvgAnswe r(avg);
  1054                                               totalRow.s etMean(mea n);
  1055                                               totalRow.s etStdDevia tion(stdDe v);
  1056                                              
  1057                                               result.add ToResultsL ist(totalR ow);
  1058                                      surveysP erModPerMo n = new Ar rayList<In teger>();
  1059                                      avgsPerM odPerMon =  new Array List<Doubl e>();
  1060                                      stdDevPe rModPerMon  = new Arr ayList<Dou ble>();
  1061                                      meanPerM odPerMon =  new Array List<Doubl e>();
  1062                                      answerCo unt = ZERO ;
  1063                                               totalRow =  new Satis factionSur veyQuestio n();
  1064                                               totalRow.s etMonthAsI nt(mon.get MonthAsInt ());
  1065                                               totalRow.s etYear(mon .getYear() );
  1066                                               totalRow.s etModality (TOTALS_ST R);
  1067                                               totalRow.s etMonthAsS tring(mon. getMonthAs String());
  1068                                               currentMon th = mon.g etMonthAsI nt();
  1069                                              
  1070                                      }
  1071                                      result.a ddToResult sList(mon) ;
  1072                                      answerCo unt += mon .getAnswer Count();
  1073                                      
  1074                                      surveysP erModPerMo n.add(mon. getAnswerC ount());
  1075                                      avgsPerM odPerMon.a dd(mon.get AvgAnswer( ));
  1076                                      stdDevPe rModPerMon .add(mon.g etStdDevia tion());
  1077                                      meanPerM odPerMon.a dd(mon.get Mean());
  1078                                      
  1079                                      if(loopC ounter ==  monthList. size()){
  1080                                              
  1081                                               Double avg  = 0.0;
  1082                                      Double m ean = 0.0;
  1083                                      Double s tdDev = 0. 0;
  1084                                               for(int i  = 0; i < s urveysPerM odPerMon.s ize(); i++ ) {
  1085  
  1086                                                       //  Calculate  a weighte d average
  1087                                                       av g += avgsP erModPerMo n.get(i)*( surveysPer ModPerMon. get(i)/(do uble)answe rCount);
  1088                                                       st dDev += st dDevPerMod PerMon.get (i)*(surve ysPerModPe rMon.get(i )/(double) answerCoun t);
  1089                                                       me an += mean PerModPerM on.get(i)* (surveysPe rModPerMon .get(i)/(d ouble)answ erCount);
  1090                                               }
  1091                                              
  1092                                               totalRow.s etAnswerCo unt(answer Count);
  1093                                               totalRow.s etAvgAnswe r(avg);
  1094                                               totalRow.s etMean(mea n);
  1095                                               totalRow.s etStdDevia tion(stdDe v);
  1096                                              
  1097                                               result.add ToResultsL ist(totalR ow);
  1098                                      }       
  1099                    }
  1100                             result List.add(r esult);
  1101                }
  1102                    retu rn resultL ist;
  1103           }
  1104           
  1105  
  1106           pu blic List< Satisfacti onSurveyQu estionResu lt> getAll Modalities GraphData( List<Satis factionSur veyQuestio nResult> d ata) {
  1107                    List <Satisfact ionSurveyQ uestionRes ult> graph Data = new  ArrayList <Satisfact ionSurveyQ uestionRes ult>();
  1108                    Sati sfactionSu rveyQuesti onResult r esult = nu ll;
  1109                
  1110                    //lo op through  given dat a and get  a monthlis t for each  question  in the sur vey
  1111                for(Sati sfactionSu rveyQuesti onResult q Result : d ata) {
  1112                    List <Satisfact ionSurveyQ uestion> m onthList =  qResult.g etResults( );
  1113                    resu lt = new S atisfactio nSurveyQue stionResul t();
  1114                    resu lt.setQues tionNumber (monthList .get(ZERO) .getQuesti onNumber() );
  1115                    resu lt.setQues tionText(m onthList.g et(ZERO).g etQuestion Text().sub string(THR EE));
  1116                    
  1117                             for(Sa tisfaction SurveyQues tion mon :  monthList ) {
  1118                                      if(mon.g etModality ().equals( TOTALS_STR )) {
  1119                                               result.add ToResultsL ist(mon);
  1120                                      }
  1121                             }
  1122                             graphD ata.add(re sult);
  1123                }
  1124                    retu rn graphDa ta;
  1125           }
  1126           
  1127   }