chenyongxing 8 tahun lalu
induk
melakukan
7fbf24a96c

+ 84 - 5
patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/repository/wlyy/patient/PatientDao.java

@ -1,10 +1,89 @@
package com.yihu.mm.repository.wlyy.patient;
import com.yihu.wlyy.entity.patient.Patient;
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
import com.yihu.mm.entity.Patient;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by chenweida on 2017/8/8.
 */
public interface PatientDao extends PagingAndSortingRepository<Patient, Long> {
import java.util.List;
public interface PatientDao extends PagingAndSortingRepository<Patient, Long>,JpaSpecificationExecutor<Patient> {
    // 查询患者姓名
    @Query("select p.name from Patient p where p.code=?1")
    String findNameByCode(String code);
    // 根据姓名查询
    @Query("select p.code from Patient p where p.name=?1")
    String[] findByName(String name);
    // 根據患者標識查詢患者信息
    @Query("select p from Patient p where p.code=?1")
    Patient findByCode(String code);
    // 根據患者標識查詢患者信息
    @Query("select p from Patient p where p.code=?1 and p.idcard =?2")
    Patient findByCodeAndIdcard(String code, String idcard);
    // 根據身份證號查詢患者信息
    @Query("select p from Patient p where p.idcard=?1")
    Patient findByIdcard(String idcard);
    @Query("select p from Patient p where p.ssc=?1")
    Patient findBySsc(String ssc);
    // 根據手机号查詢患者信息
    @Query("select p from Patient p where p.mobile=?1")
    Patient findByMobile(String mobile);
    // 根據病情等级获取患者信息
    @Query("select p from Patient p where p.diseaseCondition=?1")
    Iterable<Patient> findInfoByLevel(int level);
    @Query("select p from Patient p where p.openid=?1")
    Patient findByOpenid(String openid);
    @Query("select count(1) from Patient p where p.openid=?1")
    int countByOpenid(String openid);
    //清空openid
    @Modifying
    @Query("update Patient p set p.openid = null where p.code <> ?1 and p.openid = ?2")
    int clearOpenid(String patient, String openid);
    @Modifying
    @Query(value = "update Patient p set p.status=?1 where p.id=?2 ")
    int updateStatus(Integer status, Long id);
    @Modifying
    @Query(value = "update Patient p set p.password=?1,p.salt=?2 where p.id=?3 ")
    int initPassword(String password, String salt, Long id);
    @Query(value = "select count(1) from Patient p where p.mobile = ?1")
    int isMobileExist(String mobile);
    @Query(value = "select count(1) from Patient p where p.idcard = ?1")
    int isIdCardExist(String idcard);
    @Query(value = "select count(1) from Patient p where p.ssc = ?1")
    int isSscExist(String ssc);
    @Query("select p from Patient p where p.city = ?1 and p.mobile is not null and p.mobile!='' ")
    List<Patient> findByCity(String city);
    @Query("select p from Patient p where p.city = ?1 and p.mobile is not null and p.mobile!=''  and p.town in ?2 ")
    List<Patient> findByCityAndTowns(String city, String towns[]);
    @Query(value = "SELECT DISTINCT p.* from wlyy_patient p LEFT JOIN wlyy_sign_family f on p.code = f.patient WHERE p.city = ?1 and p.mobile is not null and p.mobile!=''  and f.hospital in ?2 ",nativeQuery = true)
    List<Patient> findByCityAndHospital(String city, String hospital[]);
    @Query("select p from Patient p where p.idcard=?1 and p.ssc=?2")
    Patient findByIdcardAndSsc(String idcard, String ssc);
}