package thyyxxk.webserver.dao.his.search;

import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import thyyxxk.webserver.entity.dictionary.CodeName;

@Mapper
public interface SearchDao {
    @Select("select rtrim(code) as code,rtrim(name) as name, " +
            "rtrim(yb_code) as ybCode,rtrim(code_rs) as codeRs, " +
            "deptName=(select rtrim(d.name) from zd_unit_code d where d.code=dept_code) " +
            "from a_employee_mi where isnull(del_flag,0)!=1 and ${method} like #{content}")
    IPage<CodeName> searchPhysician(IPage<CodeName> iPage, String method, String content);

    @Select("select rtrim(code) as code,rtrim(name) as name " +
            "from zd_unit_code where isnull(del_flag,0)!=1 and ${method} like #{content}")
    IPage<CodeName> searchDept(IPage<CodeName> iPage, String method, String content);

    @Select("select rtrim(yb_code) as code, rtrim(yb_name) as name from zd_icd_code_new where ${method} like #{content} and del_flag=0")
    IPage<CodeName> searchSiDiagnose(IPage<CodeName> iPage, String method, String content);

    @Select("select rtrim(code) as code, rtrim(name) as name from zd_icd_code_new where ${method} like #{content} and del_flag=0")
    IPage<CodeName> searchIcd10Diagnose(IPage<CodeName> iPage, String method, String content);

    @Select("select class_code as code, sick_name as name from ${table} where ${method} like #{content}")
    IPage<CodeName> searchTcmDiag(IPage<CodeName> iPage, String table, String method, String content);

    @Select("select class_code as code, sick_name as name from zy_zh_name_class " +
            "where ${method} like #{content}")
    IPage<CodeName> searchTcmZh(IPage<CodeName> iPage, String method, String content);

    @Select("select distinct new_code as code,new_name as name from ${tableName} where new_name like #{content}")
    IPage<CodeName> selectSlwSpcDiag(IPage<CodeName> iPage, String content, String tableName);

    @Select("select distinct code,name from t_zd_injury_icd where ${method} like #{content}")
    IPage<CodeName> searchInjurydiag(IPage<CodeName> iPage, String method, String content);

    @Select("select rtrim(code) as code, rtrim(name) as name from zd_icd_code_new with(nolock) " +
            "where PATINDEX('%[V-Y]%',code)=1 and ${method} like #{content} ")
    IPage<CodeName> searchHurtReason(IPage<CodeName> iPage, String method, String content);

    @Select("select rtrim(code) as code, rtrim(name) as name from zd_icd_m_code with(nolock) " +
            "where ${method} like #{content} ")
    IPage<CodeName> searchPthDiag(IPage<CodeName> iPage, String method, String content);

    @Select("SELECT RTRIM(code) as code,rtrim(name) as name," +
            "gender_restriction,min_age_restriction,max_age_restriction " +
            "from ${table} where isnull(del_flag,0)!=1 and isnull(mz_flag,0)!=1 " +
            "and ${method} like #{content}")
    IPage<CodeName> searchJcJyItem(IPage<CodeName> iPage, String method, String content, String table);

    @Select("select code,name,charge_amount as price from zd_charge_item " +
            "where del_flag=0 and class_code in ('B','C','E','G','F','I','J') " +
            "and isnull(group_no,'00')!='91' and ${method} like #{content}")
    IPage<CodeName> searchZlItems(IPage<CodeName> iPage, String method, String content);

    @Select("SELECT RTRIM(code) as code,rtrim(name) as name,op_scale,op_type, " +
            "opTypeName=(select rtrim(d.name) from zd_operation_type d where d.code=op_type) " +
            "from zd_icd9_cm3 where del_flag!=1 and ${method} like #{content}")
    IPage<CodeName> searchIcd9Cm3(IPage<CodeName> iPage, String method, String content);

    @Select("select rtrim(yb_code) as code, rtrim(yb_name) as name " +
            "from zd_icd9_cm3 where ${method} like #{content} and del_flag=0")
    IPage<CodeName> searchYbSurgeries(IPage<CodeName> iPage, String method, String content);
}
