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

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

import java.util.List;

public interface HospitalRepository extends JpaRepository<Hospital, Integer> {
    Hospital findHospitalById(int id);

    @Query(value = "select * from hospital where id in :ids and is_deleted = 0 and status = 0;", nativeQuery = true)
    List<Hospital> getAllHospitalsByIds(@Param("ids") List<Integer> ids);

    @Query(value = "select * from hospital where status = 0 and is_deleted = 0 order by weight desc;", nativeQuery = true)
    List<Hospital> getHospitalList();

    /**
     *
     * @param areaIds
     * @return
     */
    @Query(value = "select * from hospital where status = 0 and is_deleted = 0 and area_ids like ? order by weight desc;", nativeQuery = true)
    List<Hospital> getAreaHospitalList(String areaIds);

    @Query(value = "select id from hospital where status = 0 and is_deleted = 0 and area_ids like ? order by weight desc;", nativeQuery = true)
    List<Integer> getAreaHospitalIdList(String areaIds);

    @Query(value = "select id from hospital where status = 0 and is_deleted = 0 order by weight desc;", nativeQuery = true)
    List<Integer> getAreaAllHospitalIdList();


    @Query(value = "select * from hospital where id = ? and  intro_status = 1 and is_deleted = 0 limit 1;", nativeQuery = true)
   Hospital getHospitalIntro(int id);


}
