package thyyxxk.webserver.dao.his.medicalinsurance;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import thyyxxk.webserver.entity.login.UserInfo;
import thyyxxk.webserver.entity.medicalinsurance.inpatient.SiAdmissApply;
import thyyxxk.webserver.entity.medicalinsurance.inpatient.settleapply.response.SiSettleApply;
import thyyxxk.webserver.entity.medicalinsurance.setlinfo.SiSetlinfo;
import thyyxxk.webserver.entity.medicalinsurance.worklog.MatchWorkLog;
import thyyxxk.webserver.entity.medicalinsurance.worklog.WorkLogInquiry;

import java.util.List;

@Mapper
public interface SiWorkLogDao {

    @Select("select code,rtrim(name) as name from a_employee_mi " +
            "where dept_code=#{dept} and isnull(del_flag,0)=0 and LEN(name)<5")
    List<UserInfo> getYbkStaff(String dept);

    @Select("select * from t_si_setlinfo where setl_type=11 and revoked=0 " +
            "and setl_time>=#{start} and setl_time<=#{end} and staff_id in ${staff}")
    List<SiSetlinfo> getMzSetlinfo(WorkLogInquiry inquiry);

    @Select("select aac003 as psnName,pat_no as patNo,times,kaz001 as setlId,aaz217 as mdtrtId, " +
            "aka130 as medType,aae036 from t_injury_setlinfo where setl_type=11 and revoked=0 " +
            "and aae036>=#{gsStart} and aae036<=#{gsEnd} and staff_id in ${staff}")
    List<SiSetlinfo> getGsSetlinfo(WorkLogInquiry inquiry);

    @Select("select *,ybTypeName=case when yb_type=1 then N'国家医保' else N'工伤医保' end," +
            "opTypeName=case when op_type=1 then N'匹配' else N'取消匹配' end " +
            "from t_si_match_log where op_time>=#{start} and op_time<=#{end} and op_staff in ${staff}")
    List<MatchWorkLog> getMatchLog(WorkLogInquiry inquiry);

    @Select("select * from t_si_admiss_apply where handle_datetime>=#{start} " +
            "and handle_datetime<=#{end} and handle_staff in ${staff}")
    List<SiAdmissApply> getAdmApply(WorkLogInquiry inquiry);

    @Select("select * from t_si_settle_apply where handle_datetime>=#{start} " +
            "and handle_datetime<=#{end} and handle_staff in ${staff}")
    List<SiSettleApply> getDisApply(WorkLogInquiry inquiry);
}
