package thyyxxk.webserver.dao.his.medicalinsurance;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
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.querydata.TUploadDrgGroup;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author lihong
 * @since 2023-01-29
 */
@Mapper
public interface TUploadDrgGroupDao extends BaseMapper<TUploadDrgGroup> {
    @Select(" select" +
            " t1.*," +
            "t3.med_type,t3.insuplc_admdvs,t3.clr_optins,clr_optins_name=(select name from t_region where code=t3.clr_optins),t3.psn_type,"+
            " out_dept_name=(select rtrim(name) from zd_unit_code where code = isnull(t2.zk_ward, t2.small_dept))," +
            " rtrim(isnull(zk_ward,small_dept)) as out_dept" +
            " from t_upload_drg_group t1" +
            "         left join zy_inactpatient t2 on t1.pat_no = t2.inpatient_no and t1.times = t2.admiss_times " +
            "  left join t_si_setlinfo t3 on t1.pat_no = t3.pat_no and t1.times = t3.times and t1.ledger_sn = t3.ledger_sn and t3.revoked = 0 "+
            " where  ${ew.sqlSegment} " +
            "")
    IPage<TUploadDrgGroup> listPage(IPage<TUploadDrgGroup> page,@Param("ew") QueryWrapper<TUploadDrgGroup> query);
}
