25. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 2/7/2017 12:14:06 PM Eastern Standard 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.

25.1 Files compared

# Location File Last Modified
1 cpss.zip\cpss\src\main\java\gov\va\cpss\job\cbs CbsQueryNewPSPatientTasklet.java Wed Feb 1 21:07:30 2017 UTC
2 cpss.zip\cpss\src\main\java\gov\va\cpss\job\cbs CbsQueryNewPSPatientTasklet.java Fri Feb 3 20:42:01 2017 UTC

25.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 2 502
Changed 1 2
Inserted 0 0
Removed 0 0

25.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

25.4 Active regular expressions

No regular expressions were active.

25.5 Comparison detail

  1   package go v.va.cpss. job.cbs;
  2  
  3   import sta tic gov.va .cpss.job. cbs.CbsPro cessingCon stants.CBS _DETECTED_ PATIENTS_E RROR_KEY;
  4  
  5   import jav a.util.Arr ayList;
  6   import jav a.util.Has hMap;
  7   import jav a.util.Lis t;
  8   import jav a.util.Map ;
  9  
  10   import org .apache.lo g4j.Logger ;
  11   import org .springfra mework.bat ch.core.Jo bExecution ;
  12   import org .springfra mework.bat ch.core.St epContribu tion;
  13   import org .springfra mework.bat ch.core.sc ope.contex t.ChunkCon text;
  14   import org .springfra mework.bat ch.core.st ep.tasklet .Tasklet;
  15   import org .springfra mework.bat ch.repeat. RepeatStat us;
  16  
  17   import gov .va.cpss.m odel.fps.P SPatient;
  18   import gov .va.cpss.m odel.fps.P SSite;
  19   import gov .va.cpss.m odel.icn.V istaAccoun t;
  20   import gov .va.cpss.s ervice.Fps Service;
  21   import gov .va.cpss.s ervice.Vis taAccountS ervice;
  22  
  23   /**
  24    * Query f or all PSP atient rec ords assoc iated with  PSSite re cords asso ciated
  25    * with PS Received r ecords in  the NEW st ate.
  26    * 
  27    * @author   DN S      P II
  28    */
  29   public cla ss CbsQuer yNewPSPati entTasklet  implement s Tasklet  {
  30  
  31           pr ivate fina l Logger t askletLogg er;
  32  
  33           pr ivate FpsS ervice fps Service;
  34  
  35           pr ivate Vist aAccountSe rvice vist aAccountSe rvice;
  36  
  37           pr ivate CbsR untimeStat e cbsRunti meState;
  38  
  39           pu blic CbsQu eryNewPSPa tientTaskl et() {
  40                    task letLogger  = Logger.g etLogger(t his.getCla ss().getCa nonicalNam e());
  41           }
  42  
  43           pu blic FpsSe rvice getF psService( ) {
  44                    retu rn fpsServ ice;
  45           }
  46  
  47           pu blic void  setFpsServ ice(FpsSer vice fpsSe rvice) {
  48                    this .fpsServic e = fpsSer vice;
  49           }
  50  
  51           pu blic Vista AccountSer vice getVi staAccount Service()  {
  52                    retu rn vistaAc countServi ce;
  53           }
  54  
  55           pu blic void  setVistaAc countServi ce(VistaAc countServi ce vistaAc countServi ce) {
  56                    this .vistaAcco untService  = vistaAc countServi ce;
  57           }
  58  
  59           pu blic CbsRu ntimeState  getCbsRun timeState( ) {
  60                    retu rn cbsRunt imeState;
  61           }
  62  
  63           pu blic void  setCbsRunt imeState(C bsRuntimeS tate cbsRu ntimeState ) {
  64                    this .cbsRuntim eState = c bsRuntimeS tate;
  65           }
  66  
  67           @O verride
  68           pu blic Repea tStatus ex ecute(Step Contributi on contrib ution, Chu nkContext  chunkConte xt) throws  Exception  {
  69  
  70                    task letLogger. info("Begi n execute" );
  71                    
  72                    // R ead in all  the PSSit e records  for NEW PS Received i nto a Map  by id.
  73                    // A dded this  optimizati on to read  the sites  in one qu ery rather  than one  at a time  during the  following  loop.
  74                    fina l Map<Long , PSSite>  newPsSiteM ap = loadN ewPsSites( );
  75  
  76                    // L oop throug h all of t he NEW PSS ite.
  77                    whil e (!cbsRun timeState. isDataErro r() && (cb sRuntimeSt ate.pollCu rrentPSSit eID() != n ull)) {
  78  
  79                             
  80                             final  long curre ntPSSiteID  = cbsRunt imeState.g etCurrentP SSiteID();
  81                             final  PSSite cur rentPSSite  = newPsSi teMap.get( currentPSS iteID);
  82                             
  83                             // Get  all patie nt for thi s PSSite.
  84                             List<P SPatient>  psPatientL  = null;
  85                             if (cu rrentPSSit e == null)  {
  86                                      psPatien tL = fpsSe rvice.getP SPatientLi stForPSSit eID(curren tPSSiteID) ;
  87                             } else  {
  88                                      psPatien tL = fpsSe rvice.getP SPatientLi stForPSSit e(currentP SSite);
  89                             }
  90  
  91                             // Set  error fla g if empty . This fla g will be  checked by  the
  92                             // sub sequent re ader.
  93                             if ((p sPatientL  == null) | | psPatien tL.isEmpty ()) {
  94  
  95                                      taskletL ogger
  96                                                       .e rror("Erro r obtainin g patient  list for s ite ID(" +  cbsRuntim eState.get CurrentPSS iteID() +  ")");
  97                                      cbsRunti meState.se tDataError (true);
  98                             } else  {
  99                                      
  100                                      // Save  list of pa tient erro rs.
  101                                      List<Str ing> patie ntErrorL =  new Array List<>();
  102  
  103                                      // Loop  through ea ch PSPatie nt in the  list to cr eate a
  104                                      // Map<C BSAccount,  List<PSPa tient>> fo r this sit e.
  105                                      // 1. Ge t 'dfn/sit e' pair fr om the PSP atient obj ect.
  106                                      // 2. Ch eck if in  VistaAccou nt table:
  107                                      // a. if  exists:
  108                                      // i. Up date the P SPatient o bject (in  memory, le ave db rec ord
  109                                      // alone ) with ICN  from Vist aAccount t able.
  110                                      // b. if  does not  exist:
  111                                      // i. Us e ICN from  PSPatient  object to  get CBS A ccount Num ber
  112                                      // from  CBSAccount  table.
  113                                      // ii. C reate Vist aAccount r ecord usin g CBS Acco unt Number  and
  114                                      // ICN f rom PSPati ent object .
  115                                      // 3. Sa ve this Si te Map<CBS Account, L ist<PSPati ent>> into  the
  116                                      // conso lidated Cb sRuntimeSt ate Map<CB SAccount,
  117                                      // List< PSPatient> >.
  118                                      Map<Long , List<PSP atient>> p sPatientM  = new Hash Map<>();
  119  
  120                                      for (PSP atient p :  psPatient L) {
  121                                              
  122                                               try {
  123                                                       bo olean succ essful = f alse;
  124                                                       fi nal long d fn = p.get DfnNumber( );
  125                                                       fi nal String  site = p. getPsSite( ).getFacil ityNum();
  126           
  127                                                       Vi staAccount  vista = v istaAccoun tService.g etAccountR ecord(dfn,  site);
  128           
  129                                                       if  (vista !=  null) {
  130                                                                p.se tIcnNumber (vista.get Icn());
  131                                                                succ essful = t rue;
  132                                                       }  else {
  133                                                                vist a = new Vi staAccount (dfn, site , p.getIcn Number(),
  134                                                                                  vistaAcc ountServic e.getAccou ntNumberFo rICN(p.get IcnNumber( )));
  135                                                                succ essful = v istaAccoun tService.r egisterAcc ount(vista );
  136                                                       }
  137           
  138                                                       if  (successf ul) {
  139                                                                if ( psPatientM .containsK ey(vista.g etCbssAcnt Id())) {
  140                                                                         psPati entM.get(v ista.getCb ssAcntId() ).add(p);
  141                                                                } el se {
  142                                                                         List<P SPatient>  pL = new A rrayList<> ();
  143                                                                         pL.add (p);
  144                                                                         psPati entM.put(v ista.getCb ssAcntId() , pL);
  145                                                                }
  146                                                       }  else {
  147                                                                appe ndToErrorL ist(p, pat ientErrorL );
  148                                                       }
  149                                                       
  150                                               } catch (R untimeExce ption e) {
  151                                                       
  152                                                       ap pendToErro rList(p, p atientErro rL);
  153                                               } catch (E xception e ) {
  154                                                       
  155                                                       ta skletLogge r.error(e. getMessage ());
  156                                                       ap pendToErro rList(p, p atientErro rL);
  157                                               }
  158                                      }
  159  
  160                                      // Save  all of the  PSPatient s for this  site into  the patie nt
  161                                      // map.
  162                                      cbsRunti meState.sa vePSPatien tMap(psPat ientM);
  163                                      
  164                                      // Save  the detect ed patient s with err or to the  context fo r later re porting.
  165                                      saveDete ctedPatien tDataError s(patientE rrorL, chu nkContext. getStepCon text().get StepExecut ion().getJ obExecutio n());
  166                             }
  167                    }
  168  
  169                    task letLogger. info("End  execute");
  170  
  171                    retu rn RepeatS tatus.FINI SHED;
  172           }
  173           
  174           /* *
  175            *  Returns a  Map of al l PSSite r ecords for  NEW PSRec eived reco rds.
  176            *  
  177            *  @return       Map<Lo ng, PSSite > keyed by  PSSite.id
  178            * /
  179           pr ivate Map< Long, PSSi te> loadNe wPsSites()  {
  180                    
  181                    Map< Long, PSSi te> newPsS iteMap = n ew HashMap <>();
  182                    if ( !cbsRuntim eState.isD ataError() ) {
  183                             List<P SSite> psS iteL = fps Service.ge tPSSitesFo rNewPSRece ived();
  184                             
  185                             if ((p sSiteL ==  null) || p sSiteL.isE mpty()) {
  186                                      taskletL ogger.erro r("Error o btaining s ite list f or new rec eived stat ement file s");
  187                                      cbsRunti meState.se tDataError (true);
  188                             } else  {
  189                                      for (PSS ite psSite  : psSiteL ) {
  190                                               newPsSiteM ap.put(psS ite.getId( ), psSite) ;
  191                                      }
  192                             }
  193                    }
  194  
  195                    retu rn newPsSi teMap;
  196           }
  197           
  198           /* *
  199            *  Append th e error to  the list.
  200            *  
  201            *  @param ps Patient
  202            *              The pati ent record .
  203            *  @param pa tientError L
  204            *              The erro r list.
  205            * /
  206           pr ivate void  appendToE rrorList(f inal PSPat ient psPat ient, List <String> p atientErro rL) {
  207                    Stri ngBuffer s trBuff = n ew StringB uffer();
  208                    strB uff.append (psPatient .getIcnNum ber());
  209                    strB uff.append (" ");
  210                    strB uff.append (psPatient .getPsSite ().getFaci lityNum()) ;
  211                    strB uff.append (" ");
  212                    strB uff.append (psPatient .getPatien tLastName( ));
  213                    pati entErrorL. add(strBuf f.toString ());
  214           }
  215           
  216           /* *
  217            *  Save dete cted patie nt data er rors to jo b executio n context.
  218            *  @param pa tientError L This lis t of error  patients.
  219            * /
  220           pr ivate void  saveDetec tedPatient DataErrors (final Lis t<String>  patientErr orL, JobEx ecution jo bExecution ) {
  221  
  222                    // I f patient  data had e rrors capt ure in the  runtime d ata.
  223                    if ( !patientEr rorL.isEmp ty()) {
  224  
  225                             taskle tLogger.er ror("There  were some  unprocess ed patient  records") ;
  226  
  227                             String  existingP atientErro rs = null;
  228                             String Buffer str Buff = new  StringBuf fer();
  229  
  230                             // Add  (append i f necessar y) to the  job execut ion.
  231                             if (jo bExecution .getExecut ionContext ().contain sKey(CBS_D ETECTED_PA TIENTS_ERR OR_KEY)) {
  232                                      existing PatientErr ors = jobE xecution.g etExecutio nContext() .getString (CBS_DETEC TED_PATIEN TS_ERROR_K EY);
  233                             }
  234  
  235                             if (ex istingPati entErrors  == null) {
  236                                      strBuff. append("Un processed  Records:") ;
  237                             } else  {
  238                                      strBuff. append(exi stingPatie ntErrors);
  239                             }
  240  
  241                             // App end to the  error mes sage.
  242                             for (S tring p :  patientErr orL) {
  243                                      strBuff. append("\n ");
  244                                      strBuff. append(p);
  245                             }
  246  
  247                             // Sav e the mess age to the  job execu tion conte xt.
  248                             jobExe cution.get ExecutionC ontext().p utString(C BS_DETECTE D_PATIENTS _ERROR_KEY , strBuff. toString() );
  249                    }
  250           }
  251  
  252   }