<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.glxp.mipsdl.thirddao.ctqyy.VInsurNationGoodsPhysicMapper">
    <resultMap id="BaseResultMap" type="com.glxp.mipsdl.entity.ctqyy.VInsurNationGoodsPhysic">
        <!--@mbg.generated-->
        <!--@Table v_insur_nation_goods_physic-->
        <result column="MED_LIST_CODG" jdbcType="VARCHAR" property="MED_LIST_CODG"/>
        <result column="FIXMEDINS_HILIST_ID" jdbcType="VARCHAR" property="FIXMEDINS_HILIST_ID"/>
        <result column="FIXMEDINS_HILIST_NAME" jdbcType="VARCHAR" property="FIXMEDINS_HILIST_NAME"/>
        <result column="FIXMEDINS_BCHNO" jdbcType="VARCHAR" property="FIXMEDINS_BCHNO"/>
        <result column="PRSC_DR_CERT_TYPE" jdbcType="CHAR" property="PRSC_DR_CERT_TYPE"/>
        <result column="PRSC_DR_CERTNO" jdbcType="VARCHAR" property="PRSC_DR_CERTNO"/>
        <result column="PRSC_DR_NAME" jdbcType="VARCHAR" property="PRSC_DR_NAME"/>
        <result column="PHAR_CERT_TYPE" jdbcType="CHAR" property="PHAR_CERT_TYPE"/>
        <result column="PHAR_CERTNO" jdbcType="VARCHAR" property="PHAR_CERTNO"/>
        <result column="PHAR_NAME" jdbcType="VARCHAR" property="PHAR_NAME"/>
        <result column="PHAR_PRAC_CERT_NO" jdbcType="VARCHAR" property="PHAR_PRAC_CERT_NO"/>
        <result column="HI_FEESETL_TYPE" jdbcType="VARCHAR" property="HI_FEESETL_TYPE"/>
        <result column="SETL_ID" jdbcType="VARCHAR" property="SETL_ID"/>
        <result column="MDTRT_SN" jdbcType="VARCHAR" property="MDTRT_SN"/>
        <result column="PSN_NO" jdbcType="VARCHAR" property="PSN_NO"/>
        <result column="PSN_CERT_TYPE" jdbcType="CHAR" property="PSN_CERT_TYPE"/>
        <result column="CERTNO" jdbcType="VARCHAR" property="CERTNO"/>
        <result column="PSN_NAME" jdbcType="VARCHAR" property="PSN_NAME"/>
        <result column="MANU_LOTNUM" jdbcType="VARCHAR" property="MANU_LOTNUM"/>
        <result column="MANU_DATE" jdbcType="TIMESTAMP" property="MANU_DATE"/>
        <result column="EXPY_END" jdbcType="TIMESTAMP" property="EXPY_END"/>
        <result column="RX_FLAG" jdbcType="CHAR" property="RX_FLAG"/>
        <result column="TRDN_FLAG" jdbcType="CHAR" property="TRDN_FLAG"/>
        <result column="FINL_TRNS_PRIC" jdbcType="DECIMAL" property="FINL_TRNS_PRIC"/>
        <result column="RXNO" jdbcType="VARCHAR" property="RXNO"/>
        <result column="RX_CIRC_FLAG" jdbcType="CHAR" property="RX_CIRC_FLAG"/>
        <result column="RTAL_DOCNO" jdbcType="VARCHAR" property="RTAL_DOCNO"/>
        <result column="STOOUT_NO" jdbcType="VARCHAR" property="STOOUT_NO"/>
        <result column="BCHNO" jdbcType="VARCHAR" property="BCHNO"/>
        <result column="RUG_PROD_BARC" jdbcType="VARCHAR" property="RUG_PROD_BARC"/>
        <result column="SHELF_POSI" jdbcType="VARCHAR" property="SHELF_POSI"/>
        <result column="SEL_RETN_CNT" jdbcType="INTEGER" property="SEL_RETN_CNT"/>
        <result column="SEL_RETN_TIME" jdbcType="TIMESTAMP" property="SEL_RETN_TIME"/>
        <result column="SEL_RETN_OPTER_NAME" jdbcType="VARCHAR" property="SEL_RETN_OPTER_NAME"/>
        <result column="MEMO" jdbcType="LONGVARCHAR" property="MEMO"/>
        <result column="MDTRT_SETL_TYPE" jdbcType="CHAR" property="MDTRT_SETL_TYPE"/>
        <result column="DRUGTRACINFO" jdbcType="LONGVARCHAR" property="DRUGTRACINFO"/>
        <result column="APPLY_NO" jdbcType="VARCHAR" property="APPLY_NO"/>
        <result column="SETTLE_NO" jdbcType="VARCHAR" property="SETTLE_NO"/>
        <result column="SICK_ID" jdbcType="VARCHAR" property="SICK_ID"/>
    </resultMap>
    <sql id="Base_Column_List">
        <!--@mbg.generated-->
        MED_LIST_CODG, FIXMEDINS_HILIST_ID, FIXMEDINS_HILIST_NAME, FIXMEDINS_BCHNO, PRSC_DR_CERT_TYPE,
        PRSC_DR_CERTNO, PRSC_DR_NAME, PHAR_CERT_TYPE, PHAR_CERTNO, PHAR_NAME, PHAR_PRAC_CERT_NO,
        HI_FEESETL_TYPE, SETL_ID, MDTRT_SN, PSN_NO, PSN_CERT_TYPE, CERTNO, PSN_NAME, MANU_LOTNUM,
        MANU_DATE, EXPY_END, RX_FLAG, TRDN_FLAG, FINL_TRNS_PRIC, RXNO, RX_CIRC_FLAG, RTAL_DOCNO,
        STOOUT_NO, BCHNO, RUG_PROD_BARC, SHELF_POSI, SEL_RETN_CNT, SEL_RETN_TIME, SEL_RETN_OPTER_NAME,
        MEMO, MDTRT_SETL_TYPE, DRUGTRACINFO, APPLY_NO, SETTLE_NO, SICK_ID
    </sql>


    <select id="selectGroupedWithPagination" resultType="com.glxp.mipsdl.entity.ctqyy.VInsurNationGoodsPhysic">
        SELECT PHYSIC_CODE
        FROM v_insur_nation_goods_physic
        <where>
            <if test="udiwmsBasicSkPrescribeRequest.startTime != null and udiwmsBasicSkPrescribeRequest.startTime != ''">
                <![CDATA[
                and SEL_RETN_TIME >= TO_DATE(#{udiwmsBasicSkPrescribeRequest.startTime}
                  , 'YYYY-MM-DD HH24:MI:SS')
                ]]>
            </if>
            <if test="udiwmsBasicSkPrescribeRequest.endTime != null and udiwmsBasicSkPrescribeRequest.endTime != ''">
                <![CDATA[
                and SEL_RETN_TIME <= TO_DATE(#{udiwmsBasicSkPrescribeRequest.endTime}
                  , 'YYYY-MM-DD HH24:MI:SS')
                ]]>
            </if>
            <if test="udiwmsBasicSkPrescribeRequest.code != null and udiwmsBasicSkPrescribeRequest.code != ''">
                and (RXNO  = #{udiwmsBasicSkPrescribeRequest.code}
                 or STOOUT_NO = #{udiwmsBasicSkPrescribeRequest.code}
                        )
            </if>
            <if test="udiwmsBasicSkPrescribeRequest.fromCorpName != null and udiwmsBasicSkPrescribeRequest.fromCorpName != ''">
                and (PSN_NAME  like  '%'  || #{udiwmsBasicSkPrescribeRequest.fromCorpName}  || '%' )
            </if>
            <if test="udiwmsBasicSkPrescribeRequest.key != null and udiwmsBasicSkPrescribeRequest.key != ''">
                and (
                STOOUT_NO like   '%'  || #{udiwmsBasicSkPrescribeRequest.key}  || '%'
                 or RXNO like  '%'  || #{udiwmsBasicSkPrescribeRequest.key}  || '%'
                        )
            </if>
        </where>
        GROUP BY
                PHYSIC_CODE
        ORDER BY
                PHYSIC_CODE
    </select>
</mapper>