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

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

import java.util.List;

public interface TransferOrderViewRepository extends JpaRepository<TransferOrderView, Integer> {

    /**
     *  查看某个患者当前有没有正在进行的订单（订单状态，10-待付款,20-已付款），转诊
     *
     * @param doctorId
     * @param patientId
     * @return
     */
    @Query(value = "SELECT  * FROM  transfer_order_view WHERE from_doctor_id = ? AND patient_id = ? AND is_deleted = 0 AND order_status in (10,20) ORDER BY create_time DESC limit 1",nativeQuery = true)
    List<TransferOrderView> checkTransferOrder(int doctorId, int patientId);


}
