package thyyxxk.webserver.dao.his.inpatient.casefrontsheet;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import thyyxxk.webserver.entity.casefrontsheet.CaseFrontsheetDisdiag;
import thyyxxk.webserver.entity.dictionary.CodeName;

import java.util.List;

@Mapper
public interface SheetCreatedDao extends BaseMapper<CaseFrontsheetDisdiag> {

    @Select("select role_id from dj_user_role with(nolock) where user_code=#{code}")
    List<Integer> selectUserRoles(@Param("code") String code);

    @Select("select distinct code,name from " +
            "(select name=c.name,code=a.dept " +
            "from zd_dept_all a, a_employee_mi b, zd_unit_code c " +
            "where b.code=#{code} and c.code=a.dept " +
            "and (b.dept_code=a.small_dept or b.dept_code=a.dept) " +
            "union " +
            "select name=c.name,code=a.dept " +
            "from zd_dept_all a, zy_part_time_dept b,zd_unit_code c " +
            "where b.code=#{code} and c.code=a.dept " +
            "and (b.dept_code=a.small_dept or b.dept_code=a.dept)) t " +
            "order by code")
    List<CodeName> getUserWards(@Param("code") String code);

    @Select("select rtrim(dept_code) code, rtrim(dept_name) name from zy_adtward with(nolock) " +
            "where dept_code not like '8%' order by dept_code")
    List<CodeName> getAllWards();

    @Select("select rtrim(code) code, rtrim(name) name from zd_marital_status with(nolock)")
    List<CodeName> getMarriageCode();

    @Select("select rtrim(code) code, rtrim(name) name from zd_sex_code with(nolock)")
    List<CodeName> getSexCode();

    @Select("select rtrim(code) code, rtrim(name) name from zy_zd_admiss_way with(nolock)")
    List<CodeName> getAdmissWay();

    @Select("select rtrim(code) code, rtrim(name) name from zd_blood_type with(nolock) union select code='',name=''")
    List<CodeName> getBloodType();

    @Select("select rtrim(code) code, rtrim(name) name from zd_anaesthesia with(nolock)")
    List<CodeName> getAnaesthesia();

    @Select("select rtrim(code_sy) code,rtrim(name_sy) name from op_zd_scale with(nolock)")
    List<CodeName> getOperateScale();

    @Select("select rtrim(code) code, rtrim(name_new) name from zd_cut_heal_grade with(nolock)")
    List<CodeName> getCutHealGrade();

    @Select("select rtrim(code) code, rtrim(name) name from zd_dis_admiss_status with(nolock)")
    List<CodeName> getDisAdmissStatus();

    @Select("select rtrim(code) code, rtrim(name) name from zd_dis_diag_status with(nolock)")
    List<CodeName> getDisdiagStatus();

    @Select("select rtrim(code) code, rtrim(name) name from zd_hbsag with(nolock) union select code='',name=''")
    List<CodeName> getHbsag();

    @Select("select rtrim(code) code, rtrim(name) name from zd_diag_conform with(nolock)")
    List<CodeName> getDiagConform();

    @Select("select rtrim(code) code, rtrim(name) name from zd_dis_diag_type with(nolock)")
    List<CodeName> getDisdiagType();

    @Select("select rtrim(code) code, rtrim(name) name from zd_patient_status with(nolock)")
    List<CodeName> getPatientStatus();

    @Select("select rtrim(code) code, rtrim(name) name from zd_admiss_status with(nolock)")
    List<CodeName> getAdmissStatus();

    @Select("select rtrim(code) code, rtrim(name) name from zd_quality_level with(nolock)")
    List<CodeName> getQualityLevel();

    @Select("select rtrim(code) code, rtrim(name) name from zd_zy_dismiss_way with(nolock)")
    List<CodeName> getZyDismissWay();

    @Select("select rtrim(code) code, rtrim(name) name from zy_zd_relative_code with(nolock)")
    List<CodeName> getRelations();

    @Select("select code, name from zd_statutory_epidemic with(nolock) union select code='',name=''")
    List<CodeName> getStatutoryEpidemic();

    @Select("select code, name from zd_clinical_pathway_management with(nolock) union select code='',name=''")
    List<CodeName> getClinicalPathwayManagement();

    @Select("select code, name from zd_drgs_management with(nolock) union select code='',name=''")
    List<CodeName> getDrgsManagement();

    @Select("select code, name from zd_case_classification with(nolock) union select code='',name=''")
    List<CodeName> getCaseClassification();

    @Select("select rtrim(code) code, rtrim(name) name from zy_occupation_code with(nolock)")
    List<CodeName> getOccupation();

    @Select("select rtrim(code) code, rtrim(name) name from zd_country_code with(nolock)")
    List<CodeName> getCountry();

    @Select("select rtrim(code) code, rtrim(name) name from zd_nation_code with(nolock)")
    List<CodeName> getNation();

    @Select("select rtrim(code) code, rtrim(name) name from zd_pay_method with(nolock) union select code='',name=''")
    List<CodeName> getPayMethod();

    @Select("select rtrim(code) code, rtrim(code) name from zd_tnm with(nolock) where T=1 union select code='',name=''")
    List<CodeName> getTumorLevelT();

    @Select("select rtrim(code) code, rtrim(code) name from zd_tnm with(nolock) where N=1 union select code='',name=''")
    List<CodeName> getTumorLevelN();

    @Select("select rtrim(code) code, rtrim(code) name from zd_tnm with(nolock) where M=1 union select code='',name=''")
    List<CodeName> getTumorLevelM();

    @Select("select rtrim(code) code, rtrim(code) name from zd_tnm with(nolock) where stage=1 union select code='',name=''")
    List<CodeName> getTumorLevel();
}
