Summary Table

Categories Total Count
PII 0
URL 0
DNS 0
EKL 0
IP 0
PORT 0
VsID 0
CF 0
AI 0
VPD 0
PL 0
Other 0

File Content

/*
* SeocRepository.java
* Copyright (c) 2017 Veterans Affairs.
*/
package gov.va.oneconsult.seoc.api.repository;

import java.util.Optional;
import java.util.Set;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import gov.va.oneconsult.seoc.api.model.Seoc;

/**
* @author AbleVets
*/
@Repository
public interface SeocRepository extends CrudRepository<Seoc, Integer>
{

@Query("SELECT s FROM Seoc s order by s.id")
public Set<Seoc> findAllSeocs();

@Query("SELECT s FROM Seoc s WHERE s.effectiveDate is not null and (LOWER(s.status.description) in (LOWER('date hold'),LOWER('active'))) order by s.name")
public Set<Seoc> findActiveSeocs();

@Query("SELECT s FROM Seoc s WHERE s.effectiveDate is not null and (LOWER(s.status.description) in (LOWER('date hold'),LOWER('active'),LOWER('discontinued'))) order by s.seocKey, s.effectiveDate")
public Set<Seoc> findPublishedSeocs();

public Seoc findById(int i);

public Set<Seoc> findByName(String name);

@Query("SELECT s FROM Seoc s WHERE LOWER(s.name) like LOWER(CONCAT('%',:name,'%'))")
public Set<Seoc> findSeocByNameMatch(@Param("name") String name);

@Query("SELECT MAX(s.seocKey) FROM Seoc s")
public Optional<Integer> findMaxSeocKey();

public Set<Seoc> findBySeocKey(int seocKey);

@Query("SELECT s FROM Seoc s WHERE s.name=:name and s.seocKey=:seocKey")
public Seoc findByNameSeocKey(@Param("name") String name, @Param("seocKey") Integer seocKey);

@Query("SELECT s.seocKey FROM Seoc s WHERE LOWER(s.categoryOfCare.description)=LOWER(:coc) and s.effectiveDate is not null and (LOWER(s.status.description) in (LOWER('date hold'),LOWER('active'), LOWER('discontinued'))) group by s.seocKey having count(s)>0 order by s.seocKey")
public int[] findSeocsPublishedWithCategoryOfCare(@Param("coc") String coc);

public Set<Seoc> findByServicesIdIn(Integer[] ids);

@Query("SELECT s FROM Seoc s WHERE LOWER(replace(s.name,' ','')) = LOWER(replace(:name,' ',''))")
public Set<Seoc> findDuplicateSeocNames(@Param("name") String name);



}