package thyyxxk.webserver.dao.his.inpatient;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import thyyxxk.webserver.entity.dictionary.CodeName;
import thyyxxk.webserver.entity.medicalinsurance.inpatient.SpecialDiag;

import java.util.List;

@Mapper
public interface DictionaryDao {

    @Select("SELECT RTRIM(code) AS code,rtrim(name) name from a_employee_mi WHERE " +
            "isnull(del_flag,0)!=1 and ${method} LIKE #{content} collate Chinese_PRC_CI_AS")
    List<CodeName> searchPhysician(String method, String content);

    @Select("select diagnosis_code as code,diagnosis_name as name from t_si_dl_dss_dns " +
            "where del_flag=0 and ${method} LIKE #{content} collate Chinese_PRC_CI_AS order by weight desc")
    List<CodeName> searchDiagnose(String method, String content);

    @Update("update zd_icd_code_new set weight=(weight+1) where yb_code=#{code}")
    void increaseWeight(String code);

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

    @Select("select * from ${table}")
    List<SpecialDiag> selectAllSpecialDiags(@Param("table") String table);

    @Select("select code,name from t_zd_injury_icd where ${method} like #{content} collate Chinese_PRC_CI_AS")
    List<CodeName> selectInjurydiag(String method, String content);

    @Select("select rtrim(new_code) as code, rtrim(new_name) as name from si_icd_employees_maternity_hospitalization " +
            "where ${method} like #{content} collate Chinese_PRC_CI_AS")
    List<CodeName> selectMatnDiagForFrontSheet(String method, String content);

    @Select("select rtrim(new_code) as code, rtrim(new_name) as name from si_hospitalization_single_disease " +
            "where ${method} like #{content} collate Chinese_PRC_CI_AS")
    List<CodeName> selectSpcDssDiagForFrontSheet(String method, String content);

    @Select("select code, name from t_zd_injury_disease where ${method} like #{content} collate Chinese_PRC_CI_AS")
    List<CodeName> selectInjuryDssDiagForFrontSheet(String method, String content);

    @Select("select med_type from t_si_pat_info with(nolock ) where pat_no=#{patNo} and times=#{times} " +
            "and mdtrt_id is not null order by ledger_sn desc")
    String selectAccurateMedType(@Param("patNo") String patNo, @Param("times") int times);
}
