package thyyxxk.webserver.dao.lis;

import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import thyyxxk.webserver.entity.examinations.covidexam.CovidExamResult;

@Mapper
public interface CovidExamDao {

    @Select("select " +
            "a.ctat_addr,a.phone_num,a.last_updt_date,a.aply_flow_num,a.ptnt_age,b.smpl_num, " +
            "a.ptnt_name as ptntName,a.id_card as idCard, c.itm_str_value as itmStrValue, " +
            "a.ptnt_no as ptntNo,b.ordr_date as ordrCreateDate,a.ptnt_sex " +
            "from m_ordr_info(nolock) as a " +
            "inner join m_ordr(nolock) as b on a.ordr_info_id = b.ordr_info_id " +
            "inner join m_ordr_item(nolock) as c on b.ordr_id = c.ordr_id " +
            "where b.audt_status = 1 and (c.itm_id = 1855) and c.itm_str_value like #{value} " +
            "and (b.audt_time >= #{start} and b.audt_time < #{end}) " +
            "order by audt_time, REPLICATE(0,20-len(b.smpl_num))+b.smpl_num")
    IPage<CovidExamResult> selectHstResult(IPage<CovidExamResult> iPage,
                                           @Param("start") String start,
                                           @Param("end") String end,
                                           @Param("value") String value);

    @Select("select " +
            "a.ptnt_name as ptntName, a.id_card as idCard, c.itm_str_value as itmStrValue, " +
            "a.ptnt_no as ptntNo, b.ordr_create_date as ordrCreateDate " +
            "from m_ordr_info(nolock) as a " +
            "inner join m_ordr(nolock) as b on a.ordr_info_id = b.ordr_info_id " +
            "inner join m_ordr_item(nolock) as c on b.ordr_id = c.ordr_id " +
            "where b.audt_status = 1 " +
            "and (c.itm_id in ( 1865,1870,1871)) " +
            "and (b.audt_time >= #{start} and b.audt_time < #{end}) " +
            "order by audt_time, REPLICATE(0,20-len(b.smpl_num))+b.smpl_num")
    IPage<CovidExamResult> selectKtResult(IPage<CovidExamResult> iPage, @Param("start") String start, @Param("end") String end);

}
