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

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface CommonDoctorSettingRepository extends JpaRepository<CommonDoctorSetting, Integer>, JpaSpecificationExecutor<CommonDoctorSetting> {

    @Query(value = "select hospital_id from common_doctor_setting where doctor_id in :ids and terminal = :terminal and deleted = 0 and type = 2  and value = :sta ", nativeQuery = true)
    List<Integer> findDoctorHospId(@Param("ids") List<Integer> ids, @Param("terminal") int terminal, @Param("sta") String sta);

    @Query(value = "select doctor_id from common_doctor_setting where terminal = ? and deleted = 0 and type = 2  and value = ?;", nativeQuery = true)
    List<Integer> findDoctorId(int terminal, String value);

    @Query(value = "select * from common_doctor_setting where doctor_id = ? and terminal = ? and type = ? and deleted = 0;", nativeQuery = true)
    CommonDoctorSetting findDoctorSettingByType(int doctorId, int terminalId, int type);

}