package thyyxxk.webserver.dao.his.ybkf;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import thyyxxk.webserver.entity.datamodify.ZyDetailCharge;

import java.util.List;
import java.util.Map;

@Mapper
public interface YbUtilDao {

    @Select("<script> " +
            "select top 40 rtrim(name) as name, rtrim(code) as code from zd_unit_code with(nolock) where code not like '8%' and del_flag = 0 " +
            "<if test=\"str != null and str != '' \"> " +
            " and (name like '%${str}%' or code like '%${str}%' or py_code like ('%' + upper(#{str}) + '%') or d_code like ('%' + upper(#{str}) + '%') ) " +
            "</if> " +
            "order by code " +
            "</script> ")
    List<Map<String, Object>> selectSmallDept(@Param("str") String str);

    @Select("<script> " +
            "select top 40 rtrim(name) as name, rtrim(code) as code from a_employee_mi with(nolock) where 1 = 1 " +
            "<if test=\"str != null and str != '' \"> " +
            " and (name like '%${str}%' or code like '%${str}%' or py_code like ('%' + upper(#{str}) + '%') or d_code like ('%' + upper(#{str}) + '%') ) " +
            "</if> " +
            "order by py_code " +
            "</script> ")
    List<Map<String, Object>> selectDoctor(@Param("str") String str);

    /**
     * @description: 查询使用了特殊的项目或者材料
     * @author: hsh
     * @date: 2022/11/1 11:20
     * @param: [patNo, times, ledgerSn]
     * @return: List<ZyDetailCharge>
     **/
    @Select(" select * from zy_detail_charge " +
            "where inpatient_no = #{patNo} and admiss_times = #{times} and ledger_sn = #{ledgerSn} " +
            "and charge_code in ( " +
            "select code from zd_charge_item where national_code like #{item} " +
            ") ")
    List<ZyDetailCharge> selectInterventionalProject(@Param("patNo") String patNo, @Param("times") Integer times,
        @Param("ledgerSn") Integer ledgerSn, @Param("item") String item);

}
