142. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 12/13/2018 10:35:23 AM 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.

142.1 Files compared

# Location File Last Modified
1 v12.5_iter_7_build 51.zip\TRM_Upgrade\src\main\java\gov\va\med\ccht\persistent\hibernate QIRDAOImpl.java Fri Dec 7 17:36:30 2018 UTC
2 v12.5_iter_7_build 51.zip\TRM_Upgrade\src\main\java\gov\va\med\ccht\persistent\hibernate QIRDAOImpl.java Wed Dec 12 22:33:38 2018 UTC

142.2 Comparison summary

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

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

142.4 Active regular expressions

No regular expressions were active.

142.5 Comparison detail

  1   /**
  2  
  3    * 
  4    */
  5   package go v.va.med.c cht.persis tent.hiber nate;
  6  
  7   import jav a.text.Dat eFormat;
  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 lection;
  12   import jav a.util.Dat e;
  13   import jav a.util.Has hMap;
  14   import jav a.util.Lis t;
  15   import jav a.util.Map ;
  16  
  17   import jav ax.persist ence.Query ;
  18   import jav ax.transac tion.Trans actional;
  19  
  20   import org .hibernate .Session;
  21   import org .hibernate .SessionFa ctory;
  22   import org .springfra mework.bea ns.factory .annotatio n.Autowire d;
  23   import org .springfra mework.ste reotype.Re pository;
  24  
  25   import gov .va.med.cc ht.model.q ir.QIR;
  26   import gov .va.med.cc ht.model.q ir.QIRAtta chment;
  27   import gov .va.med.cc ht.model.q ir.QIRSear chParamete rs;
  28   import gov .va.med.cc ht.model.q ir.QIRSear chResult;
  29   import gov .va.med.cc ht.model.q ir.QIRStat usType;
  30   import gov .va.med.cc ht.persist ent.QIRDAO ;
  31   import gov .va.med.fw .util.Coll ectionUtil s;
  32   import gov .va.med.fw .util.Stri ngUtils;
  33   import gov .va.med.cc ht.util.ES APIValidat ionType;
  34   import gov .va.med.cc ht.util.ES APIValidat or;
  35  
  36   /**
  37    * @author   DNS
  38    *
  39    */
  40   @Repositor y
  41   @Transacti onal
  42   public cla ss QIRDAOI mpl implem ents QIRDA O { 
  43           
  44           st atic final  private L ong NEW_ST ATUS = (lo ng) 20301;
  45           st atic final  private L ong WITHDR AWN_STATUS  = (long)  20303;
  46  
  47           pu blic QIRDA OImpl() {
  48           }
  49  
  50           pu blic QIRDA OImpl(Sess ionFactory  factory)  {
  51                    sess ionFactory  = factory ;
  52           }
  53  
  54           @A utowired
  55           pr ivate Sess ionFactory  sessionFa ctory;
  56           
  57           pr otected Se ssion getS ession() {
  58                    retu rn this.se ssionFacto ry.getCurr entSession ();
  59           }
  60  
  61           pu blic QIR s aveQIR(QIR  qir) {
  62                    getS ession().s aveOrUpdat e(qir); 
  63                    retu rn qir;
  64           }
  65           
  66           @O verride
  67           pu blic List< String> ge tVendorRes ponseDueQI RIds() {
  68                    
  69                    fina l StringBu ilder sql  = new Stri ngBuilder( );
  70                    sql. append("SE LECT \n");
  71                    sql. append("     cast(q.Q IR_ID as v archar) \n ");
  72                    sql. append("FR OM \n");
  73                    sql. append("     qir.QIR  q  \n");
  74                    sql. append("     join qir .qir_statu s_types qs t  \n");
  75                    sql. append("     on (qst. id = q.qir _status_ty pe_id)   \ n");
  76                    sql. append("WH ERE \n");
  77                    sql. append("     q.VENDOR _RESP_DUE_ DATE is no t null  \n ");
  78                    sql. append("     and q.VE NDOR_RESP_ DUE_DATE <  current_t imestamp \ n");
  79                    sql. append("     and q.da te_email_r eminder_se nt is null  \n");
  80                    sql. append("     and qst. name in (' Approved', 'Replied', 'Agreed')  \n");
  81                    
  82                    @Sup pressWarni ngs("unche cked")
  83                    fina l List<Str ing> qirId s = (List< String>)ge tSession()
  84                                      .createN ativeQuery (sql.toStr ing())
  85                                      .list();
  86                    
  87                    retu rn qirIds;
  88  
  89           }
  90  
  91           pr ivate Quer y buildQue rySearchBy Generic(QI RSearchPar ameters qi rSearchPar ameters) {
  92                    
  93                    Map< String, Ob ject> para meters = n ew HashMap <String, O bject>();
  94                    Stri ng sql = " SELECT ";
  95                    if ( qirSearchP arameters. getMaxReco rds() != n ull && qir SearchPara meters.get MaxRecords () > 0) {
  96                             sql +=  " top " +  qirSearch Parameters .getMaxRec ords().int Value() +  " ";
  97                    }
  98                    
  99                    sql  += "q.QIR_ ID id, qt. NAME qirTy pe, qst.NA ME qirStat usType, "
  100                                      + "cast( v.visn_nam e as varch ar) visn,  f.facility _id facili tyCode, f. facility_n ame facili ty, "
  101                                      + "mdmt. NAME devic eType, ven .VENDOR_NA ME vendor,  "
  102                                      + "q.QIR _COMPLAINT  complaint , q.QIR_SU MMARY head line, "
  103                                      + "q.DAT E_SUBMITTE D submitte dDate, q.S UBMITTED_B Y submitte dBy, q.REC ORD_MODIFI ED_COUNT,  "
  104                                      + "isnul l(u.last_n ame,'') +  ', ' + isn ull(u.firs t_name,'') +' ' + isn ull(u.midd le_name,'' ) submitte dByName, "
  105                                      + "count (qda.QIR_D OC_ATTCHMN T_ID) attc hmnt_cnt "  + "FROM q ir.QIR q "
  106                                      + "join  qir.QIR_ST ATUS_TYPES  qst on q. QIR_STATUS _TYPE_ID =  qst.ID "
  107                                      + "join  ht.app_use r u on q.S UBMITTED_B Y = u.user _name "
  108                                      + "left  join qir.Q IR_TYPES q t on q.QIR _TYPE_ID =  qt.id "
  109                                      + "left  join dbo.M EDICAL_DEV ICE_MODEL_ TYPE mdmt  on q.MED_D VC_MODEL_T YPE_ID = m dmt.id "
  110                                      + "left  join dbo.V ENDOR ven  on q.VENDO R_ID = ven .Vendor_ID  "
  111                                      + "left  join dbo.f acilities  f on q.FAC ILITIES_ID  = f.ID "
  112                                      + "left  join dbo.v isn v on q .visn_id =  v.visn_id  "
  113                                      + "left  outer join  qir.QIR_D OC_ATTACHM ENTS qda o n q.QIR_ID  = qda.QIR _ID " + "w here 1=1 " ;
  114  
  115                    // q ir id and  statuses a re exclusi ve
  116                    if ( StringUtil s.isEmpty( qirSearchP arameters. getId()))  {
  117                             if (Co llectionUt ils.isNotE mpty(qirSe archParame ters.getQi rStatuses( ))) {
  118                                      paramete rs.put("qi rStatuses" , qirSearc hParameter s.getQirSt atuses());
  119                                      sql += " and qst.co de in (:qi rStatuses)  ";
  120                             }
  121  
  122                             // Add itional se arch condi tions
  123                             if (qi rSearchPar ameters.ge tDeviceTyp e() != nul l) {
  124                                      paramete rs.put("de viceType",  qirSearch Parameters .getDevice Type().get Value());
  125                                      sql += " and mdmt.c ode = :dev iceType ";
  126                             }
  127  
  128                             if (qi rSearchPar ameters.ge tVendor()  != null) {
  129                                      paramete rs.put("ve ndor_id",  qirSearchP arameters. getVendor( ).getValue ());
  130                                      sql += " and ven.ve ndor_id =  :vendor_id  ";
  131                             }
  132  
  133                             if (qi rSearchPar ameters.ge tQirType()  != null)  {
  134                                      paramete rs.put("qi rType", qi rSearchPar ameters.ge tQirType() .getValue( ));
  135                                      sql += " and qt.cod e = :qirTy pe ";
  136                             }
  137  
  138                             if (qi rSearchPar ameters.ge tFacility( ) != null)  {
  139                                      paramete rs.put("st ation", qi rSearchPar ameters.ge tFacility( ).getValue ());
  140                                      sql += " and f.faci lity_id =  :station " ;
  141                             }
  142  
  143                             if (qi rSearchPar ameters.ge tVisn() !=  null) {
  144                                      paramete rs.put("vi snName", q irSearchPa rameters.g etVisn().g etValue()) ;
  145                                      sql += " and v.visn _name = :v isnName ";
  146                             }
  147                             if (St ringUtils. isNotEmpty (qirSearch Parameters .getSubmit tedBy()))  {
  148                                      paramete rs.put("su bmittedBy" , qirSearc hParameter s.getSubmi ttedBy());
  149                                      sql += " and q.subm itted_by =  :submitte dBy ";
  150                             }
  151                             if (qi rSearchPar ameters.ge tSubmitted FromDate()  != null)  {
  152                                      paramete rs.put("su bmittedFro mDate", qi rSearchPar ameters.ge tSubmitted FromDate() );
  153                                      sql += " and DATE_S UBMITTED > = :submitt edFromDate  ";
  154                             }
  155                             if (qi rSearchPar ameters.ge tSubmitted ToDate() ! = null) {
  156                                      // Becau se our dat es have ti mestamps i n the data base,
  157                                      // we ha ve to go f orward one  day then  use a less  than to e nsure
  158                                      // we ar e grabbing  everythin g up to th e end of t he toDate.
  159                                      Calendar  cal = Cal endar.getI nstance();
  160                                      cal.setT ime(qirSea rchParamet ers.getSub mittedToDa te());
  161                                      cal.add( Calendar.D ATE, 1);
  162                                      paramete rs.put("su bmittedToD ate", cal. getTime()) ;
  163                                      sql += " and DATE_S UBMITTED <  :submitte dToDate ";
  164                             }
  165                             if (qi rSearchPar ameters.ge tIsVendor( ) == true)  { // vend or should  not be abl e to view  new or wit hdrawn QIR s
  166                                      paramete rs.put("Ne wStatus",  NEW_STATUS );
  167                                      paramete rs.put("Wi thdrawnSta tus", WITH DRAWN_STAT US);
  168                                      sql += " and QIR_ST ATUS_TYPE_ ID != :New Status ";
  169                                      sql += " and QIR_ST ATUS_TYPE_ ID != :Wit hdrawnStat us ";
  170                             }
  171                    } el se {
  172                             parame ters.put(" id", qirSe archParame ters.getId ());
  173                             sql +=  "and q.qi r_id = :id  ";
  174                    }
  175  
  176                    sql  += "group  by q.QIR_I D, qt.NAME , qst.NAME , v.visn_n ame, f.fac ility_id,  f.facility _name, mdm t.NAME, ve n.VENDOR_N AME, q.QIR _COMPLAINT , q.QIR_SU MMARY, q.D ATE_SUBMIT TED, "
  177                                      + "q.SUB MITTED_BY,  q.RECORD_ MODIFIED_C OUNT, u.la st_name, u .first_nam e, u.middl e_name ord er by q.QI R_ID DESC" ;
  178  
  179                    fina l Query qu ery = getS ession().c reateNativ eQuery(sql );
  180                    for( String key : paramete rs.keySet( )) {
  181                             query. setParamet er(key, pa rameters.g et(key));
  182                    }
  183                    
  184                    retu rn query;
  185           }
  186  
  187           pu blic Date  getVendorR esponseDue Date(long  id) {
  188  
  189                    fina l String s ql = "SELE CT VENDOR_ RESP_DUE_D ATE FROM q ir.QIR WHE RE qir_id  = :id";
  190                    
  191                    retu rn (Date)  sessionFac tory
  192                                      .getCurr entSession ()
  193                                      .createN ativeQuery (sql)
  194                                      .setPara meter("id" , id)
  195                                      .uniqueR esult();
  196  
  197           }
  198  
  199           @O verride
  200           pu blic List< QIR> findB yIds(Colle ction<Long > ids) { 
  201  
  202                    fina l String s ql = "SELE CT * FROM  qir.QIR WH ERE qir_id  in :ids";
  203                    
  204                    retu rn getSess ion()
  205                                      .createN ativeQuery (sql, QIR. class)
  206                                      .setPara meter("ids ", ids)
  207                                      .getResu ltList();
  208  
  209           }
  210    
  211           @O verride
  212           pu blic QIR f indById(Lo ng id) {
  213                    
  214                    fina l String s ql = "SELE CT * FROM  qir.QIR WH ERE qir_id  = :id";
  215                    
  216                    retu rn getSess ion()
  217                                      .createN ativeQuery (sql, QIR. class)
  218                                      .setPara meter("id" , id)
  219                                      .getSing leResult() ;
  220           }
  221  
  222           @O verride
  223           pu blic List< QIRSearchR esult> sea rchQIR(QIR SearchPara meters qir SearchPara meters) { 
  224                    
  225                    Quer y query =  buildQuery SearchByGe neric(qirS earchParam eters);
  226                    
  227                    @Sup pressWarni ngs("unche cked")
  228                    List <Object[]>  qirs = qu ery.getRes ultList();
  229                    fina l List<QIR SearchResu lt> result s = new Ar rayList<QI RSearchRes ult>();
  230                    Date Format df  = new Simp leDateForm at("MM/dd/ yyyy");
  231  
  232                    for( Object[] o bjs: qirs)  {
  233                             QIRSea rchResult  record = n ew QIRSear chResult() ;
  234                             record .id = ESAP IValidator .validateS tringInput (String.va lueOf(objs [0]), ESAP IValidatio nType.Numb ers_WhiteL ist);
  235                             record .qirType =  (String)  objs[1];
  236                             record .qirStatus Type = (St ring) objs [2];
  237                             record .visn = (S tring) obj s[3];
  238                             record .facilityC ode = (Str ing) objs[ 4];
  239                             record .facility  = (String)  objs[5];
  240                             record .deviceTyp e = (Strin g) objs[6] ;
  241                             record .vendor =  (String) o bjs[7];
  242                             record .complaint  = (String ) objs[8];
  243                             record .headline  = (String)  objs[9];
  244                             record .submitted Date = (Da te) objs[1 0];
  245                             record .submitted DateAsStri ng = df.fo rmat((Date ) objs[10] );
  246                             record .submitted By = (Stri ng) objs[1 1];
  247                             record .submitted ByName = ( String) ob js[13];
  248                             record .attachmen tCount = ( (Integer)  objs[14]). toString() ;
  249                             if ((I nteger) ob js[14] > 0 ) {
  250                                      record.h asAttachme nts = "tru e";
  251                             }
  252  
  253                             result s.add(reco rd);
  254                    }
  255                    
  256                    retu rn results ;
  257                    
  258           }
  259  
  260  
  261           @O verride
  262           pu blic void  updateAtta chment(QIR Attachment  attachmen t) {
  263                    getS ession().s aveOrUpdat e(attachme nt);
  264           }
  265           
  266           @O verride
  267           pu blic void  deleteAtta chment(Lon g attachme ntId) {
  268                    getS ession().d elete(find Attachment ById(attac hmentId));
  269           }
  270  
  271  
  272           @O verride
  273           pu blic QIRAt tachment f indAttachm entById(Lo ng attachm entId) {
  274                    fina l String s ql = "SELE CT * FROM  qir.qir_do c_attachme nts "
  275                                      + "WHERE  qir_doc_a ttchmnt_id  = :id";
  276                    
  277                    retu rn getSess ion()
  278                                      .createN ativeQuery (sql, QIRA ttachment. class)
  279                                      .setPara meter("id" , attachme ntId)
  280                                      .getSing leResult() ;
  281           }
  282  
  283  
  284           @O verride
  285           pu blic void  insertQIRS tatusType( QIRStatusT ype type)  {
  286                    getS ession().s ave(type);
  287                    
  288           }
  289  
  290  
  291           @O verride
  292           pu blic void  deleteQIRS tatusType( QIRStatusT ype type)  {
  293                    getS ession().d elete(type );
  294           }
  295  
  296  
  297           @O verride
  298           pu blic void  deleteQIR( QIR qir) {
  299                    getS ession().d elete(qir) ;
  300           }
  301  
  302  
  303           @O verride
  304           pu blic List< QIRStatusT ype> findA llQIRStatu sTypes() {
  305  
  306                    fina l String s ql = "SELE CT * FROM  qir.QIR_ST ATUS_TYPES ";
  307                    
  308                    retu rn getSess ion()
  309                                      .createN ativeQuery (sql, QIRS tatusType. class)
  310                                      .getResu ltList();
  311  
  312           }
  313           
  314           @O verride
  315           pu blic QIRSt atusType f indQIRStat usTypeByNa me(String  name) {
  316                    fina l String s ql = "SELE CT * FROM  qir.QIR_ST ATUS_TYPES  WHERE nam e = :name" ;
  317                    
  318                    retu rn getSess ion()
  319                                      .createN ativeQuery (sql, QIRS tatusType. class)
  320                                      .setPara meter("nam e", name)
  321                                      .getSing leResult() ;
  322           }
  323  
  324  
  325           @O verride
  326           pu blic QIRSt atusType f indQIRStat usType(Str ing code)  {
  327                    
  328                    fina l String s ql = "SELE CT * FROM  qir.QIR_ST ATUS_TYPES  WHERE cod e = :code" ;
  329                    
  330                    retu rn getSess ion()
  331                                      .createN ativeQuery (sql, QIRS tatusType. class)
  332                                      .setPara meter("cod e", code)
  333                                      .getSing leResult() ;
  334           }
  335  
  336   }