package com.yihu.wlyy.repository.patient;

import com.yihu.wlyy.entity.patient.SocialSecurityInfo;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

/**
 * Created by lyr on 2016/8/8.
 */
public interface SocialSecurityInfoDao extends PagingAndSortingRepository<SocialSecurityInfo, String>, JpaSpecificationExecutor<SocialSecurityInfo> {
    SocialSecurityInfo findBySfzh18(String idcard);

    @Query("select a from SocialSecurityInfo a where a.id = (select max(b.id) from SocialSecurityInfo b where b.sfzh18 = ?1)")
    SocialSecurityInfo findBySfzh18Max(String idcard);

    @Query("select a from SocialSecurityInfo a where a.id = (select max(b.id) from SocialSecurityInfo b where b.id0000 = ?1)")
    SocialSecurityInfo findBySfzh15Max(String idcard);
}
