99. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 4/27/2018 2:59:10 PM Central 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.

99.1 Files compared

# Location File Last Modified
1 v2.0_Sprint_15_Build_5.zip\v2.0_Sprint_15_Build_5\Unredacted\ARS_Backend\ars_app\src\main\java\gov\va\med\ars\service\impl RfaiLookupServiceImpl.java Tue Apr 24 14:50:45 2018 UTC
2 v2.0_Sprint_15_Build_5..zip\v2.0_Sprint_15_Build_5\Unredacted\ARS_Backend\ars_app\src\main\java\gov\va\med\ars\service\impl RfaiLookupServiceImpl.java Thu Apr 26 16:08:44 2018 UTC

99.2 Comparison summary

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

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

99.4 Active regular expressions

No regular expressions were active.

99.5 Comparison detail

  1   /**
  2    * 
  3    */
  4   package go v.va.med.a rs.service .impl;
  5  
  6   import jav a.text.Dat eFormat;
  7   import jav a.text.Par seExceptio n;
  8   import jav a.text.Sim pleDateFor mat;
  9   import jav a.util.Arr ayList;
  10   import jav a.util.Cal endar;
  11   import jav a.util.Col lections;
  12   import jav a.util.Com parator;
  13   import jav a.util.Dat e;
  14   import jav a.util.Lis t;
  15   import jav a.util.str eam.Stream ;
  16  
  17   import jav ax.persist ence.crite ria.Criter iaBuilder;
  18   import jav ax.persist ence.crite ria.Criter iaQuery;
  19   import jav ax.persist ence.crite ria.Predic ate;
  20   import jav ax.persist ence.crite ria.Root;
  21  
  22   import org .apache.lo g4j.LogMan ager;
  23   import org .apache.lo g4j.Logger ;
  24   import org .springfra mework.bea ns.factory .annotatio n.Autowire d;
  25   import org .springfra mework.dat a.domain.P age;
  26   import org .springfra mework.dat a.domain.P ageRequest ;
  27   import org .springfra mework.dat a.domain.S ort;
  28   import org .springfra mework.dat a.jpa.doma in.Specifi cation;
  29   import org .springfra mework.htt p.HttpStat us;
  30   import org .springfra mework.ste reotype.Se rvice;
  31  
  32   import gov .va.med.ar s.constant s.ClaimSub missionCon stants;
  33   import gov .va.med.ar s.constant s.ErrorMes sages;
  34   import gov .va.med.ar s.dao.ars. IRfaiLooku pRepositor y;
  35   import gov .va.med.ar s.dao.ars. RfaiLookup Repository ;
  36   import gov .va.med.ar s.exceptio ns.Generic Exception;
  37   import gov .va.med.ar s.model.re quest.Rfai LookupRequ est;
  38   import gov .va.med.ar s.model.re sponse.Gen ericRespon se;
  39   import gov .va.med.ar s.model.re sponse.Rfa iLookUpRes ponse;
  40   import gov .va.med.ar s.service. IRfaiLooku pService;
  41   import gov .va.med.do main.ars.C laimSubmis sion;
  42  
  43   /**
  44    * @author   PI I
  45    *
  46    */
  47   @Service
  48   public cla ss RfaiLoo kupService Impl imple ments IRfa iLookupSer vice {
  49  
  50           pr ivate stat ic final L ogger logg er = LogMa nager.getL ogger(Rfai LookupServ iceImpl.cl ass);
  51  
  52           Da teFormat d ateFormat  = new Simp leDateForm at("MM/dd/ yyyy");
  53           pr ivate stat ic final S tring CURR ENT_DATE_F ORMAT = "M M/dd/yyyy" ;
  54  
  55           @A utowired
  56           Rf aiLookupRe pository r faiReposit ory;
  57  
  58           @A utowired
  59           IR faiLookupR epository  iRfaiRepos itory;
  60  
  61           @O verride
  62           pu blic Gener icResponse  getRfaiSi mpleSearch Results(Rf aiLookupRe quest rfai LookupRequ est) throw s GenericE xception {
  63                    Gene ricRespons e searchRe sponse;
  64                    List <ClaimSubm ission> pd iClaim = n ew ArrayLi st<>();
  65                    List <ClaimSubm ission> su bmissionId  = new Arr ayList<>() ;
  66                    List <ClaimSubm ission> pa tientId;
  67                    List <ClaimSubm ission> pr oviderNpi;
  68  
  69                    if ( rfaiLookup Request.ge tNumber(). matches("[ 0-9]+")) {
  70                             pdiCla im = rfaiR epository. findBytrn0 2fppsClaim Id(Long.va lueOf(rfai LookupRequ est.getNum ber()));
  71                             submis sionId = r faiReposit ory.findBy submission id(Long.va lueOf(rfai LookupRequ est.getNum ber()));
  72                             patien tId = rfai Repository .findByhl4 nm109ptid( rfaiLookup Request.ge tNumber()) ;
  73                             provid erNpi = rf aiReposito ry.findByh l3nm109prv npi(rfaiLo okupReques t.getNumbe r());
  74                    } el se {
  75                             patien tId = rfai Repository .findByhl4 nm109ptid( rfaiLookup Request.ge tNumber()) ;
  76                             provid erNpi = rf aiReposito ry.findByh l3nm109prv npi(rfaiLo okupReques t.getNumbe r());
  77                    }
  78  
  79                    List <ClaimSubm ission> cm  = new Arr ayList<>() ;
  80                    cm.a ddAll(pdiC laim);
  81                    cm.a ddAll(subm issionId);
  82                    cm.a ddAll(pati entId);
  83                    cm.a ddAll(prov iderNpi);
  84  
  85                    Coll ections.so rt(cm, new  Comparato r<ClaimSub mission>()  {
  86  
  87                             @Overr ide
  88                             public  int compa re(ClaimSu bmission o 1, ClaimSu bmission o 2) {
  89                                      try {
  90                                               switch (rf aiLookupRe quest.getS ortColumn( )) {
  91                                               case Claim Submission Constants. PROVIDER_N AME:
  92                                                       re turn compa reByAscDes c(rfaiLook upRequest. getDescend ing(), o1. getHl3nm10 3svcbillpr vnm(),
  93                                                                         o2.get Hl3nm103sv cbillprvnm (), ClaimS ubmission. class
  94                                                                                           .getDeclar edField(Cl aimSubmiss ionConstan ts.PROVIDE R_NAME_DB_ COLUMN).ge tType());
  95                                               case Claim Submission Constants. PROVIDER_N PI:
  96                                                       re turn compa reByAscDes c(rfaiLook upRequest. getDescend ing(), o1. getHl3nm10 9prvnpi(),
  97                                                                         o2.get Hl3nm109pr vnpi(), Cl aimSubmiss ion.class
  98                                                                                           .getDeclar edField(Cl aimSubmiss ionConstan ts.PROVIDE R_NPI_DB_C OLUMN).get Type());
  99                                               case Claim Submission Constants. PROVIDER_T IN:
  100                                                       re turn compa reByAscDes c(rfaiLook upRequest. getDescend ing(), o1. getHl2nm10 9svcprvtin (),
  101                                                                         o2.get Hl2nm109sv cprvtin(),  ClaimSubm ission.cla ss
  102                                                                                           .getDeclar edField(Cl aimSubmiss ionConstan ts.PROVIDE R_TIN_DB_C OLUMN).get Type());
  103                                               case Claim Submission Constants. PATIENT_LA ST_NAME:
  104                                                       re turn compa reByAscDes c(rfaiLook upRequest. getDescend ing(), o1. getHl4nm10 3ptlstnm() ,
  105                                                                         o2.get Hl4nm103pt lstnm(),
  106                                                                         ClaimS ubmission. class
  107                                                                                           .getDeclar edField(Cl aimSubmiss ionConstan ts.PATIENT _LAST_NAME _DB_COLUMN )
  108                                                                                           .getType() );
  109                                               case Claim Submission Constants. PATIENT_FI RST_NAME:
  110                                                       re turn compa reByAscDes c(rfaiLook upRequest. getDescend ing(), o1. getHl4nm10 4ptftnm(),
  111                                                                         o2.get Hl4nm104pt ftnm(),
  112                                                                         ClaimS ubmission. class
  113                                                                                           .getDeclar edField(Cl aimSubmiss ionConstan ts.PATIENT _FIRST_NAM E_DB_COLUM N)
  114                                                                                           .getType() );
  115                                               case Claim Submission Constants. PATIENT_ID :
  116                                                       re turn compa reByAscDes c(rfaiLook upRequest. getDescend ing(), o1. getHl4nm10 9ptid(),
  117                                                                         o2.get Hl4nm109pt id(), Clai mSubmissio n.class
  118                                                                                           .getDeclar edField(Cl aimSubmiss ionConstan ts.PATIENT _ID_DB_COL UMN).getTy pe());
  119                                               case Claim Submission Constants. PATIENT_CO NTROL_NUMB ER:
  120                                                       re turn compa reByAscDes c(rfaiLook upRequest. getDescend ing(), o1. getRef102p tctrlnmbr( ),
  121                                                                         o2.get Ref102ptct rlnmbr(),
  122                                                                         ClaimS ubmission. class
  123                                                                                           .getDeclar edField(Cl aimSubmiss ionConstan ts.PATIENT _CONTROL_N UMBER_DB_C OLUMN)
  124                                                                                           .getType() );
  125                                               case Claim Submission Constants. LINE_ITEM_ CONTROL_NU MBER:
  126                                                       re turn compa reByAscDes c(rfaiLook upRequest. getDescend ing(), Lon g.valueOf( o1.getSubm issionid() ),
  127                                                                         Long.v alueOf(o2. getSubmiss ionid()),  ClaimSubmi ssion.clas s
  128                                                                                           .getDeclar edField(Cl aimSubmiss ionConstan ts.SUBMISS ION_ID_DB_ COLUMN).ge tType());
  129                                               case Claim Submission Constants. MEDICAL_RE CORD_NUMBE R:
  130                                                       re turn compa reByAscDes c(rfaiLook upRequest. getDescend ing(), o1. getRef302m edrecnmbr( ),
  131                                                                         o2.get Ref302medr ecnmbr(),
  132                                                                         ClaimS ubmission. class
  133                                                                                           .getDeclar edField(Cl aimSubmiss ionConstan ts.MEDICAL _RECORD_NU MBER_DB_CO LUMN)
  134                                                                                           .getType() );
  135                                               case Claim Submission Constants. DATE_SUBMI TTED:
  136                                                       re turn compa reByAscDes c(rfaiLook upRequest. getDescend ing(), o1. getDatesub mitted(),
  137                                                                         o2.get Datesubmit ted(), Cla imSubmissi on.class
  138                                                                                           .getDeclar edField(Cl aimSubmiss ionConstan ts.DATE_SU BMITTED_DB _COLUMN).g etType());
  139                                               case Claim Submission Constants. REQUIRED_R ESPONSE_DA TE:
  140                                                       re turn compa reByAscDes c(rfaiLook upRequest. getDescend ing(), o1. getDtp203r esponsedue date(),
  141                                                                         o2.get Dtp203resp onseduedat e(),
  142                                                                         ClaimS ubmission. class
  143                                                                                           .getDeclar edField(Cl aimSubmiss ionConstan ts.RESPONS E_DUE_DATE _DB_COLUMN )
  144                                                                                           .getType() );
  145                                               case Claim Submission Constants. PATIENT_NA ME:
  146                                                       re turn compa reByAscDes c(rfaiLook upRequest. getDescend ing(), o1. getHl4nm10 3ptlstnm() ,
  147                                                                         o2.get Hl4nm103pt lstnm(),
  148                                                                         ClaimS ubmission. class
  149                                                                                           .getDeclar edField(Cl aimSubmiss ionConstan ts.PATIENT _LAST_NAME _DB_COLUMN )
  150                                                                                           .getType() );
  151                                               case Claim Submission Constants. PDI_CLAIM_ ID:
  152                                                       re turn compa reByAscDes c(rfaiLook upRequest. getDescend ing(),
  153                                                                         Long.v alueOf(o1. getTrn02fp psClaimId( )), Long.v alueOf(o2. getTrn02fp psClaimId( )),
  154                                                                         ClaimS ubmission. class
  155                                                                                           .getDeclar edField(Cl aimSubmiss ionConstan ts.Claim_P DI_DB_COLU MN_NAME).g etType());
  156                                               case Claim Submission Constants. SUBMISSION _ID:
  157                                                       re turn compa reByAscDes c(rfaiLook upRequest. getDescend ing(), Lon g.valueOf( o1.getSubm issionid() ),
  158                                                                         Long.v alueOf(o2. getSubmiss ionid()),  ClaimSubmi ssion.clas s
  159                                                                                           .getDeclar edField(Cl aimSubmiss ionConstan ts.SUBMISS ION_ID_DB_ COLUMN).ge tType());
  160                                               case Claim Submission Constants. STATUS:
  161                                                       re turn compa reByAscDes c(rfaiLook upRequest. getDescend ing(), o1. getSubmiss ionStatus( ),
  162                                                                         o2.get Submission Status(),
  163                                                                         ClaimS ubmission. class
  164                                                                                           .getDeclar edField(Cl aimSubmiss ionConstan ts.SUBMISS ION_STATUS _DB_COLUMN )
  165                                                                                           .getType() );
  166                                               default:
  167                                                       re turn compa reByAscDes c(rfaiLook upRequest. getDescend ing(), Lon g.valueOf( o1.getSubm issionid() ),
  168                                                                         Long.v alueOf(o2. getSubmiss ionid()),  ClaimSubmi ssion.clas s
  169                                                                                           .getDeclar edField(Cl aimSubmiss ionConstan ts.SUBMISS ION_ID_DB_ COLUMN).ge tType());
  170                                               }
  171                                      } catch  (NoSuchFie ldExceptio n | Securi tyExceptio n e) {
  172                                               logger.inf o("Excepti on occured  in try/ca tch statem ents : " +  e);
  173                                               return 0;
  174                                      }
  175                             }
  176  
  177                             int co mpareByAsc Desc(boole an desc, O bject o1,  Object o2,  Class<?>  classObjec t) {
  178                                      Object p re;
  179                                      Object p ost;
  180                                      if (!des c) {
  181                                               post = o2;
  182                                               pre = o1;
  183                                      } else {
  184                                               post = o1;
  185                                               pre = o2;
  186                                      }
  187                                      if (pre  == null) {
  188                                               return (po st == null ) ? 0 : -1 ;
  189                                      }
  190                                      if (post  == null)  {
  191                                               return 1;
  192                                      }
  193                                      switch ( classObjec t.getSimpl eName()) {
  194                                      case "Lo ng":
  195                                      case "lo ng":
  196                                               return ((L ong) pre). compareTo( (Long) pos t);
  197                                      case "Da te":
  198                                               return ((D ate) pre). compareTo( (Date) pos t);
  199                                      default:
  200                                               return ((S tring) pre ).compareT o((String)  post);
  201                                      }
  202                             }
  203                    });
  204  
  205                    List <RfaiLookU pResponse>  responseL ist = assi gnClaimSub missionLis tData(cm);
  206  
  207                    sear chResponse  = new Gen ericRespon se(rfaiLoo kupRequest .getPageNu mber().int Value(),
  208                                      rfaiLook upRequest. getPageSiz e().intVal ue(), rfai LookupRequ est.getSor tColumn(),
  209                                      new Long (responseL ist.size() ));
  210                    List <RfaiLookU pResponse>  response  = new Arra yList<>();
  211                    int  upperLimit  = rfaiLoo kupRequest .getPageNu mber() * r faiLookupR equest.get PageSize() ;
  212                    int  lowerLimit  = upperLi mit - rfai LookupRequ est.getPag eSize();
  213                    for  (int i = l owerLimit;  i < upper Limit && i  < respons eList.size (); i++) {
  214                             if (re sponseList .size() >  i) {
  215                                      response .add(respo nseList.ge t(i));
  216                             }
  217                    }
  218                    if ( !response. isEmpty())  {
  219                             search Response.s etResponse (response) ;
  220                    } el se {
  221                             throw  new Generi cException (ErrorMess ages.INVAL ID_REQUEST , "Invalid  request",  HttpStatu s.NOT_FOUN D);
  222                    }
  223  
  224                    retu rn searchR esponse;
  225           }
  226  
  227           pr ivate List <RfaiLookU pResponse>  assignCla imSubmissi onListData (List<Clai mSubmissio n> cm) {
  228                    List <RfaiLookU pResponse>  responseL ist = new  ArrayList< >();
  229  
  230                    for  (ClaimSubm ission cs  : cm) {
  231                             RfaiLo okUpRespon se respons e = new Rf aiLookUpRe sponse();
  232                             respon se.setSubm issionId(c s.getSubmi ssionid()) ;
  233                             respon se.setPdiC laimId(cs. getTrn02fp psClaimId( ));
  234                             respon se.setPati entName(cs .getHl4nm1 03ptlstnm( ) + ", " +  cs.getHl4 nm104ptftn m());
  235                             respon se.setStat us(cs.getS ubmissionS tatus());
  236                             respon se.setProv iderName(c s.getHl3nm 103svcbill prvnm());
  237                             respon se.setProv iderNpi(cs .getHl3nm1 09prvnpi() );
  238                             respon se.setProv iderTin(cs .getHl2nm1 09svcprvti n());
  239                             respon se.setPati entId(cs.g etHl4nm109 ptid());
  240                             respon se.setPati entControl Number(cs. getRef102p tctrlnmbr( ));
  241                             respon se.setMedi calRecordN umber(cs.g etRef302me drecnmbr() );
  242                             if (cs .getDatesu bmitted()  != null) {
  243                                      response .setDatesu bmitted(da teFormat.f ormat(cs.g etDatesubm itted()));
  244                             }
  245                             if (cs .getDtp203 responsedu edate() !=  null) {
  246                                      response .setRequir edResponse Date(dateF ormat.form at(cs.getD tp203respo nseduedate ()));
  247                             }
  248  
  249                             respon seList.add (response) ;
  250                    }
  251                    retu rn respons eList;
  252           }
  253  
  254           pr ivate Page Request ge neratePagi nation(Rfa iLookupReq uest rfaiL ookupReque st) {
  255                    Page Request pa geable;
  256                    Stri ng sortCol umn = vali dateSort(r faiLookupR equest.get SortColumn ());
  257                    if ( rfaiLookup Request.ge tDescendin g()) {
  258                             pageab le = new P ageRequest (rfaiLooku pRequest.g etPageNumb er().intVa lue() - 1,
  259                                               rfaiLookup Request.ge tPageSize( ).intValue (), Sort.D irection.D ESC, sortC olumn);
  260                    } el se {
  261                             pageab le = new P ageRequest (rfaiLooku pRequest.g etPageNumb er().intVa lue() - 1,
  262                                               rfaiLookup Request.ge tPageSize( ).intValue (), Sort.D irection.A SC, sortCo lumn);
  263                    }
  264                    retu rn pageabl e;
  265           }
  266  
  267           pr ivate Stri ng validat eSort(Stri ng sortCol umn) {
  268                    if ( sortColumn  != null & & !(sortCo lumn.isEmp ty())) {
  269                             switch  (sortColu mn) {
  270                             case C laimSubmis sionConsta nts.PROVID ER_NAME:
  271                                      return " hl3nm103sv cbillprvnm ";
  272                             case C laimSubmis sionConsta nts.PROVID ER_NPI:
  273                                      return " hl3nm109pr vnpi";
  274                             case C laimSubmis sionConsta nts.PROVID ER_TIN:
  275                                      return " hl2nm109sv cprvtin";
  276                             case C laimSubmis sionConsta nts.PATIEN T_LAST_NAM E:
  277                                      return " hl4nm103pt lstnm";
  278                             case C laimSubmis sionConsta nts.PATIEN T_FIRST_NA ME:
  279                                      return " hl4nm104pt ftnm";
  280                             case C laimSubmis sionConsta nts.PATIEN T_ID:
  281                                      return " hl4nm109pt id";
  282                             case C laimSubmis sionConsta nts.PATIEN T_CONTROL_ NUMBER:
  283                                      return " ref102ptct rlnmbr";
  284                             case C laimSubmis sionConsta nts.LINE_I TEM_CONTRO L_NUMBER:
  285                                      return " submission id";
  286                             case C laimSubmis sionConsta nts.MEDICA L_RECORD_N UMBER:
  287                                      return " ref302medr ecnmbr";
  288                             case C laimSubmis sionConsta nts.DATE_S UBMITTED:
  289                                      return " datesubmit ted";
  290                             case C laimSubmis sionConsta nts.REQUIR ED_RESPONS E_DATE:
  291                                      return " dtp203resp onseduedat e";
  292                             case C laimSubmis sionConsta nts.PATIEN T_NAME:
  293                                      return " hl4nm103pt lstnm";
  294                             case C laimSubmis sionConsta nts.PDI_CL AIM_ID:
  295                                      return " trn02fppsC laimId";
  296                             case C laimSubmis sionConsta nts.SUBMIS SION_ID:
  297                                      return C laimSubmis sionConsta nts.SUBMIS SION_ID_DB _COLUMN;
  298                             case C laimSubmis sionConsta nts.STATUS :
  299                                      return " submission Status";
  300                             defaul t:
  301                                      return C laimSubmis sionConsta nts.SUBMIS SION_ID_DB _COLUMN;
  302                             }
  303                    } el se {
  304                             return  "submissi onid";
  305                    }
  306  
  307           }
  308  
  309           @O verride
  310           pu blic Gener icResponse  getRfaiAd vResults(R faiLookupR equest rfa iLookupReq uest) thro ws Generic Exception  {
  311                    Gene ricRespons e searchRe sponse = n ull;
  312                    Page Request pa geable = g eneratePag ination(rf aiLookupRe quest);
  313                    try  {
  314                             boolea n value =  checkObjec tNullOrEmp ty(rfaiLoo kupRequest );
  315                             if (va lue) {
  316                                      Long cou ntElements  = iRfaiRe pository.c ount(new S pecificati on<ClaimSu bmission>( ) {
  317  
  318                                               @Override
  319                                               public Pre dicate toP redicate(R oot<ClaimS ubmission>  root, Cri teriaQuery <?> query,
  320                                                                Crit eriaBuilde r cb) {
  321                                                       Li st<Predica te> predic ates = new  ArrayList <>();
  322  
  323                                                       ge tQueryData (rfaiLooku pRequest,  root, cb,  predicates );
  324  
  325                                                       re turn cb.an d(predicat es.toArray (new Predi cate[0]));
  326                                               }
  327  
  328                                      });
  329                                      int page Number = r faiLookupR equest.get PageNumber ();
  330                                      pageNumb er = reset PageNumber sOnCountEl ements(rfa iLookupReq uest, coun tElements,  pageNumbe r);
  331                                      if (coun tElements  > 0) {
  332                                               searchResp onse = set GenericJso nResponse( rfaiLookup Request, p ageable, c ountElemen ts, pageNu mber);
  333                                      } else {
  334                                               // throw n ew Generic Exception( ErrorMessa ges.INVALI D_REQUEST,  "Invalid  request",
  335                                               // HttpSta tus.NOT_FO UND);
  336                                               GenericRes ponse empt yResponse  = new Gene ricRespons e(rfaiLook upRequest. getPageNum ber(),
  337                                                                rfai LookupRequ est.getPag eSize(), r faiLookupR equest.get SortColumn (), countE lements);
  338                                               return emp tyResponse ;
  339                                      }
  340                             } else  {
  341                                      throw ne w GenericE xception(E rrorMessag es.INVALID _REQUEST,
  342                                                       "A t least on e field in formation  needs to b e added",  HttpStatus .NOT_FOUND );
  343                             }
  344  
  345                    } ca tch (Excep tion e) {
  346                             throw  new Generi cException (ErrorMess ages.DATA_ ACCESS_ERR OR, e.getM essage(),
  347                                               HttpStatus .INTERNAL_ SERVER_ERR OR);
  348                    }
  349                    retu rn searchR esponse;
  350           }
  351  
  352           pr ivate Gene ricRespons e setGener icJsonResp onse(RfaiL ookupReque st rfaiLoo kupRequest , PageRequ est pageab le,
  353                             Long c ountElemen ts, int pa geNumber)  {
  354                    Gene ricRespons e searchRe sponse;
  355                    if ( pageNumber  == 0) {
  356                             List<R faiLookUpR esponse> r esponseLis t = queryS pecificati on(rfaiLoo kupRequest , pageable );
  357                             search Response =  new Gener icResponse (rfaiLooku pRequest.g etPageNumb er(), rfai LookupRequ est.getPag eSize(),
  358                                               rfaiLookup Request.ge tSortColum n(), count Elements);
  359                             search Response.s etResponse (responseL ist);
  360  
  361                    } el se {
  362                             List<R faiLookUpR esponse> r esponseLis t = queryS pecificati on(rfaiLoo kupRequest , pageable );
  363  
  364                             search Response =  new Gener icResponse (rfaiLooku pRequest.g etPageNumb er().intVa lue(),
  365                                               rfaiLookup Request.ge tPageSize( ).intValue (), rfaiLo okupReques t.getSortC olumn(), c ountElemen ts);
  366                             search Response.s etResponse (responseL ist);
  367                    }
  368                    retu rn searchR esponse;
  369           }
  370  
  371           pr ivate int  resetPageN umbersOnCo untElement s(RfaiLook upRequest  rfaiLookup Request, L ong countE lements,
  372                             int pa geNumber)  {
  373                    if ( countEleme nts <= (rf aiLookupRe quest.getP ageSize()  * rfaiLook upRequest. getPageNum ber())) {
  374                             Intege r resultCo untIntVal  = countEle ments.intV alue();
  375                             float  pageNumber Float = (f loat) resu ltCountInt Val / (flo at) rfaiLo okupReques t.getPageS ize();
  376                             pageNu mber = (in t) Math.ce il(pageNum berFloat);
  377                             /*
  378                              * log ger.debug(  "getClaim SearchResu lts() : pa geNumber i s :" + pag eNumber +
  379                              * " a nd pageSiz e is :" +  rfaiLookup Request.ge tPageSize( ));
  380                              */
  381                    }
  382                    retu rn pageNum ber;
  383           }
  384  
  385           pr ivate bool ean checkO bjectNullO rEmpty(Rfa iLookupReq uest rfaiL ookupReque st) {
  386                    retu rn Stream
  387                                      .of(rfai LookupRequ est.getNum ber(), rfa iLookupReq uest.getMe dicalRecor dNumber(),
  388                                                       rf aiLookupRe quest.getP atientCont rolNumber( ), rfaiLoo kupRequest .getPatien tfirstName (),
  389                                                       rf aiLookupRe quest.getP atientLast Name(), rf aiLookupRe quest.getP roviderNam e(),
  390                                                       rf aiLookupRe quest.getP roviderNpi (), rfaiLo okupReques t.getProvi derTin(),
  391                                                       rf aiLookupRe quest.getS erviceEndD ate(), rfa iLookupReq uest.getSe rviceStart Date(),
  392                                                       rf aiLookupRe quest.getP atientIden tifier())
  393                                      .filter( t -> t !=  null).filt er(t -> !( (String) t ).isEmpty( )).findAny ().isPrese nt();
  394           }
  395  
  396           pr ivate List <RfaiLookU pResponse>  querySpec ification( RfaiLookup Request rf aiLookupRe quest, Pag eRequest p ageable) {
  397                    Page <ClaimSubm ission> cm  = (Page<C laimSubmis sion>) iRf aiReposito ry
  398                                      .findAll (new Speci fication<C laimSubmis sion>() {
  399  
  400                                               @Override
  401                                               public Pre dicate toP redicate(R oot<ClaimS ubmission>  root, Cri teriaQuery <?> query,
  402                                                                Crit eriaBuilde r cb) {
  403                                                       Li st<Predica te> predic ates = new  ArrayList <>();
  404  
  405                                                       ge tQueryData (rfaiLooku pRequest,  root, cb,  predicates );
  406  
  407                                                       re turn cb.an d(predicat es.toArray (new Predi cate[0]));
  408                                               }
  409  
  410                                      }, pagea ble);
  411  
  412                    retu rn assignD ata(cm);
  413           }
  414  
  415           pr ivate List <RfaiLookU pResponse>  assignDat a(Page<Cla imSubmissi on> cm) {
  416                    List <RfaiLookU pResponse>  responseL ist = new  ArrayList< >();
  417  
  418                    for  (ClaimSubm ission cs  : cm) {
  419                             RfaiLo okUpRespon se respons e = new Rf aiLookUpRe sponse();
  420                             respon se.setSubm issionId(c s.getSubmi ssionid()) ;
  421                             respon se.setPdiC laimId(cs. getTrn02fp psClaimId( ));
  422                             respon se.setPati entName(cs .getHl4nm1 03ptlstnm( ) + ", " +  cs.getHl4 nm104ptftn m());
  423                             respon se.setStat us(cs.getS ubmissionS tatus());
  424                             respon se.setProv iderName(c s.getHl3nm 103svcbill prvnm());
  425                             respon se.setProv iderNpi(cs .getHl3nm1 09prvnpi() );
  426                             respon se.setProv iderTin(cs .getHl2nm1 09svcprvti n());
  427                             respon se.setPati entId(cs.g etHl4nm109 ptid());
  428                             respon se.setPati entControl Number(cs. getRef102p tctrlnmbr( ));
  429                             respon se.setMedi calRecordN umber(cs.g etRef302me drecnmbr() );
  430                             if (cs .getDatesu bmitted()  != null) {
  431                                      response .setDatesu bmitted(da teFormat.f ormat(cs.g etDatesubm itted()));
  432                             }
  433                             if (cs .getDtp203 responsedu edate() !=  null) {
  434                                      response .setRequir edResponse Date(dateF ormat.form at(cs.getD tp203respo nseduedate ()));
  435                             }
  436  
  437                             respon seList.add (response) ;
  438                    }
  439                    retu rn respons eList;
  440           }
  441  
  442           pr ivate void  getQueryD ata(RfaiLo okupReques t rfaiLook upRequest,  Root<Clai mSubmissio n> root, C riteriaBui lder cb,
  443                             List<P redicate>  predicates ) {
  444  
  445                    Date Format for matter = n ew SimpleD ateFormat( CURRENT_DA TE_FORMAT) ;
  446  
  447                    if ( rfaiLookup Request.ge tNumber()  != null &&  !(rfaiLoo kupRequest .getNumber ().isEmpty ())) {
  448                             predic ates.add(c b.equal(ro ot.get("tr n02fppsCla imId"), rf aiLookupRe quest.getN umber()));
  449                    }
  450  
  451                    if ( rfaiLookup Request.ge tProviderN ame() != n ull && !(r faiLookupR equest.get ProviderNa me().isEmp ty())) {
  452                             predic ates.add(c b.equal(cb .lower(roo t.get("hl3 nm103svcbi llprvnm")) ,
  453                                               rfaiLookup Request.ge tProviderN ame().toLo werCase()) );
  454                    }
  455  
  456                    if ( rfaiLookup Request.ge tProviderN pi() != nu ll && !(rf aiLookupRe quest.getP roviderNpi ().isEmpty ())) {
  457                             predic ates.add(
  458                                               cb.equal(c b.lower(ro ot.get("hl 3nm109prvn pi")), rfa iLookupReq uest.getPr oviderNpi( ).toLowerC ase()));
  459                    }
  460  
  461                    if ( rfaiLookup Request.ge tProviderT in() != nu ll && !(rf aiLookupRe quest.getP roviderTin ().isEmpty ())) {
  462                             predic ates.add(c b.equal(cb .lower(roo t.get("hl2 nm109svcpr vtin")),
  463                                               rfaiLookup Request.ge tProviderT in().toLow erCase())) ;
  464                    }
  465  
  466                    if ( rfaiLookup Request.ge tPatientLa stName() ! = null &&  !(rfaiLook upRequest. getPatient LastName() .isEmpty() )) {
  467                             predic ates.add(c b.equal(cb .lower(roo t.get("hl4 nm103ptlst nm")),
  468                                               rfaiLookup Request.ge tPatientLa stName().t oLowerCase ()));
  469                    }
  470  
  471                    if ( rfaiLookup Request.ge tPatientfi rstName()  != null &&  !(rfaiLoo kupRequest .getPatien tfirstName ().isEmpty ())) {
  472                             predic ates.add(c b.equal(cb .lower(roo t.get("hl4 nm104ptftn m")),
  473                                               rfaiLookup Request.ge tPatientfi rstName(). toLowerCas e()));
  474                    }
  475  
  476                    if ( rfaiLookup Request.ge tPatientId entifier()  != null & & !(rfaiLo okupReques t.getPatie ntIdentifi er().isEmp ty())) {
  477                             predic ates.add(c b.equal(cb .lower(roo t.get("hl4 nm109ptid" )),
  478                                               rfaiLookup Request.ge tPatientId entifier() .toLowerCa se()));
  479                    }
  480  
  481                    if ( rfaiLookup Request.ge tPatientCo ntrolNumbe r() != nul l
  482                                      && !(rfa iLookupReq uest.getPa tientContr olNumber() .isEmpty() )) {
  483                             predic ates.add(c b.equal(cb .lower(roo t.get("ref 102ptctrln mbr")),
  484                                               rfaiLookup Request.ge tPatientCo ntrolNumbe r().toLowe rCase()));
  485                    }
  486  
  487                    if ( rfaiLookup Request.ge tMedicalRe cordNumber () != null
  488                                      && !(rfa iLookupReq uest.getMe dicalRecor dNumber(). isEmpty()) ) {
  489                             predic ates.add(c b.equal(cb .lower(roo t.get("ref 302medrecn mbr")),
  490                                               rfaiLookup Request.ge tMedicalRe cordNumber ().toLower Case()));
  491                    }
  492  
  493                    if ( rfaiLookup Request.ge tServiceSt artDate()  != null &&  !(rfaiLoo kupRequest .getServic eStartDate ().isEmpty ())) {
  494  
  495                             Date b eginServic eDateInDat eType;
  496                             try {
  497                                      beginSer viceDateIn DateType =  formatter .parse(rfa iLookupReq uest.getSe rviceStart Date());
  498                                      predicat es.add(cb. greaterTha nOrEqualTo (root.get( "dtp103svc frmdt"), b eginServic eDateInDat eType));
  499                             } catc h (ParseEx ception e)  {
  500                                      // TODO  Auto-gener ated catch  block
  501                                      e.printS tackTrace( );
  502                             }
  503                    }
  504  
  505                    if ( rfaiLookup Request.ge tServiceEn dDate() !=  null && ! (rfaiLooku pRequest.g etServiceE ndDate().i sEmpty()))  {
  506  
  507                             Date e ndServiceD ateInDateT ype;
  508                             try {
  509                                      endServi ceDateInDa teType = f ormatter.p arse(rfaiL ookupReque st.getServ iceEndDate ());
  510                                      Calendar  cal = Cal endar.getI nstance();
  511                                      cal.setT ime(endSer viceDateIn DateType);
  512                                      cal.add( Calendar.H OUR, 24);
  513                                      predicat es.add(cb. lessThanOr EqualTo(ro ot.get("dt p103svctod t"), cal.g etTime())) ;
  514                             } catc h (ParseEx ception e)  {
  515                                      // TODO  Auto-gener ated catch  block
  516                                      e.printS tackTrace( );
  517                             }
  518                    }
  519           }
  520   }