package cn.hnthyy.thmz.mapper.his;

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

import java.util.List;

public interface ZdChargeItemMapper {
    /**
     * 根据单个收费项目编码查询字典
     *
     * @param code
     * @return
     */
    @Select("select code,name,exec_unit,audit_code,charge_amount,effective_date,effective_amount,percentag1,percentag2,percentag3,percentag4,percentag5," +
            "rtrim(self_flag) self_flag,rtrim(separate_flag) separate_flag,rtrim(suppress_flag) suppress_flag,py_code,d_code wb_code,bill_item_zy,bill_item_mz," +
            "charge_unit,percent_group_zy,percent_group_mz,rtrim(in_out_flag) in_out_flag,n_code yn_code,class_code,s_code bz_code,discription,rtrim(del_flag) del_flag, " +
            "rtrim(yp_flag) yp_flag,bill_item_code,rtrim(xnh_flag) xnh_flag,add_date,hnsyb_code,hnsyb_name,xnh_code,xnh_name,xnh_ratio,xnh_quotamoney,rtrim(xnh_status) xnh_status," +
            "yb_flag_new,yb_comment_new,yb_bl_new from zd_charge_item where  code = #{code,jdbcType=VARCHAR} ")
       //     " and (del_flag != 1 or del_flag is null) " )
    ZdChargeItem selectZdChargeItemByCode(@Param("code") String code);



    /**
     * 根据收费项目编码集合查询所包含的收费项目
     *
     * @param codes
     * @return
     */
    @Select({"<script>",
            "select code,name,exec_unit,audit_code,charge_amount,effective_date,effective_amount,percentag1,percentag2,percentag3,percentag4,percentag5,",
            "rtrim(self_flag) self_flag,rtrim(separate_flag) separate_flag,rtrim(suppress_flag) suppress_flag,py_code,d_code wb_code,bill_item_zy,bill_item_mz,",
            "charge_unit,percent_group_zy,percent_group_mz,rtrim(in_out_flag) in_out_flag,n_code yn_code,class_code,s_code bz_code,discription,rtrim(del_flag) del_flag, ",
            "rtrim(yp_flag) yp_flag,bill_item_code,rtrim(xnh_flag) xnh_flag,add_date,hnsyb_code,hnsyb_name,xnh_code,xnh_name,xnh_ratio,xnh_quotamoney,rtrim(xnh_status) xnh_status,",
           // "yb_flag_new,yb_comment_new,yb_bl_new from zd_charge_item where (del_flag != 1 or del_flag is null) ",
            "yb_flag_new,yb_comment_new,yb_bl_new from zd_charge_item  ",
            "<when test='codes!=null'>",
            " where code in",
            "<foreach item='item' index='index' collection='codes' open='(' separator=',' close=')'>",
            "#{item}",
            "</foreach>",
            "</when>",
            "</script>"})
    List<ZdChargeItem> selectZdChargeItemByCodeList(@Param("codes") List<String> codes);

    /**
     * 查询所有的核算码名称
     * @return
     */
    @Select("select distinct bb.name from zd_charge_item aa,zy_zd_audit_item bb where aa.audit_code = bb.code union select distinct dd.name from yp_zd_dict cc, yp_zd_drug_kind dd where cc.drug_kind = dd.code ")
    List<String> selectAllHsmName();
}
