package com.ywt.outpatient.taihe.rpc.domain.entity.center;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * 医生ID对码表（内部系统的医生ID与医院HIS系统的医生编码关联表）(DoctorHisCode)表Repository类
 *
 * @author makejava
 * @since 2019-04-29 10:54:37
 */
public interface DoctorHisCodeRepository extends JpaRepository<DoctorHisCode, Integer> {
    @Query(value = "select * from doctor_his_code where doctor_id = ? and hospital_id = ? and deleted = 0 limit 1",nativeQuery = true)
    DoctorHisCode getDoctorHisCode(int doctorId, int hospitalId);

    /**
     * 根据医院ID和his编号得到相关信息
     * @param hospitalId
     * @param hisCode
     * @return
     */
    @Query(value = "select * from doctor_his_code where hospital_id = ? and his_code = ? and deleted = 0 limit 1",nativeQuery = true)
    DoctorHisCode getDoctorByHisCode(int hospitalId, String hisCode);

    @Query(value = "select * from doctor_his_code where doctor_id = ? and hospital_id = ? and deleted = 0;", nativeQuery = true)
    List<DoctorHisCode> getListByDoctorIdAndHospitalId(int doctorId, int hospitalId);
}