package cn.hnthyy.thmz.mapper.his;

import cn.hnthyy.thmz.entity.his.MzyRequest;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface MzyRequestMapper {
    /**
     * 根据日期查询所有号表
     *
     * @param requestDay
     * @return
     */
    @Select(" select request_day,ampm,rtrim(unit_code) unit_code,group_code,rtrim(doctor_code) doctor_code,charge_type,op_id,total_num,left_num,bespeak_no,check_fee,sys_date,del_flag from mzy_request where request_day = #{requestDay,jdbcType=DATE}")
    List<MzyRequest> selectMzyRequestByRequestDay(@Param("requestDay") String requestDay);

    /**
     * 按日期和时间区间查询可以挂号的科室编号
     *
     * @param requestDay
     * @return
     */
    @Select("select rtrim(unit_code) unit_code from mzy_request where request_day = #{requestDay,jdbcType=DATE} and ampm =#{ampm,jdbcType=CHAR}  group by unit_code")
    List<String> selectUnitCodeByRequestDay(@Param("requestDay") String requestDay, @Param("ampm") String ampm);


    /**
     * 按日期和时间区间以及部门编码与号别类型查询可以挂号的医生编号及费用类型
     *
     * @param requestDay
     * @return
     */
    @Select("select rtrim(doctor_code) doctor_code,rtrim(charge_type) charge_type,check_fee from mzy_request where request_day = #{requestDay,jdbcType=DATE} and unit_code=#{unitCode,jdbcType=CHAR} and ampm =#{ampm,jdbcType=CHAR} and charge_type=#{chargeType,jdbcType=CHAR} and left_num > 0")
    List<MzyRequest> selectDoctorCodeByRequestDay(@Param("requestDay") String requestDay, @Param("unitCode") String unitCode, @Param("ampm") String ampm, @Param("chargeType") String chargeType);

    /**
     * 按日期和时间区间以及部门编码查询可以挂号的号别
     *
     * @param requestDay
     * @param unitCode
     * @param ampm
     * @return
     */
    @Select("select rtrim(charge_type) charge_type from mzy_request where request_day = #{requestDay,jdbcType=DATE} and unit_code=#{unitCode,jdbcType=CHAR} and ampm =#{ampm,jdbcType=CHAR}  and left_num > 0  group by charge_type")
    List<String> selectChargeTypeByRequestDay(@Param("requestDay") String requestDay, @Param("unitCode") String unitCode, @Param("ampm") String ampm);
}
