27. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 8/14/2018 11:32:39 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.

27.1 Files compared

# Location File Last Modified
1 cbs-2018-06-18.zip\cbs\src\main\java\gov\va\cpss\job\cbs CbsQueryNewPSPatientTasklet.java Tue Jun 19 13:45:43 2018 UTC
2 cbs-2018-06-18.zip\cbs\src\main\java\gov\va\cpss\job\cbs CbsQueryNewPSPatientTasklet.java Tue Aug 14 00:51:37 2018 UTC

27.2 Comparison summary

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

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

27.4 Active regular expressions

No regular expressions were active.

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