陈昶聿
14 小时以前 6a53d35b5d56e2f6bc64bbfe41579f6f32039c90
smartor/src/main/resources/mapper/smartor/PatMedOuthospMapper.xml
@@ -7,6 +7,7 @@
    <resultMap type="com.smartor.domain.PatMedOuthosp" id="PatMedOuthospResult">
        <result property="id" column="id"/>
        <result property="serialnum" column="serialnum"/>
        <result property="fuflag" column="fuflag"/>
        <result property="patid" column="patid"/>
        <result property="hospitalname" column="hospitalname"/>
        <result property="hospitalcode" column="hospitalcode"/>
@@ -34,230 +35,485 @@
        <result property="patname" column="patname"/>
        <result property="guid" column="guid"/>
        <result property="patno" column="patno"/>
        <result property="diagcheckFlag" column="diagcheck_flag"/>
        <result property="idcardno" column="idcardno"/>
        <result property="remark" column="remark"/>
        <result property="fudate" column="fudate"/>
        <result property="serverState" column="server_state"/>
        <result property="campusid" column="campusid"/>
    </resultMap>
    <sql id="selectPatMedOuthospVo">
        select id,
               outhospno,
               patno,
               serialnum,
               patid,
               hospitalname,
               hospitalcode,
               icd10code,
               diagname,
               deptcode,
               deptname,
               drcode,
               drname,
               admitdate,
               orgid,
               del_flag,
               guid,
               update_by,
               update_time,
               create_by,
               create_time,
               isupload,
               upload_time,
               schemestatus,
               deptid,
               schemetime,
               hpi,
               patname,
               mainsuit
        from pat_med_outhosp
    </sql>
<!--    <sql id="selectPatMedOuthospVo">-->
<!--        select id,-->
<!--               outhospno,-->
<!--               campusid,-->
<!--               server_state,-->
<!--               diagcheck_flag,-->
<!--               patno,-->
<!--               remark,-->
<!--               fudate,-->
<!--               fuflag,-->
<!--               serialnum,-->
<!--               patid,-->
<!--               hospitalname,-->
<!--               hospitalcode,-->
<!--               icd10code,-->
<!--               diagname,-->
<!--               deptcode,-->
<!--               deptname,-->
<!--               drcode,-->
<!--               drname,-->
<!--               admitdate,-->
<!--               orgid,-->
<!--               del_flag,-->
<!--               guid,-->
<!--               update_by,-->
<!--               update_time,-->
<!--               create_by,-->
<!--               create_time,-->
<!--               isupload,-->
<!--               upload_time,-->
<!--               schemestatus,-->
<!--               deptid,-->
<!--               schemetime,-->
<!--               hpi,-->
<!--               patname,-->
<!--               mainsuit-->
<!--        from pat_med_outhosp-->
<!--    </sql>-->
    <select id="selectPatMedOuthospList" parameterType="com.smartor.domain.PatMedOuthosp"
            resultMap="PatMedOuthospResult">
        select
        pmo.id,
        pmo.outhospno,
        pmo.patno,
        pmo.serialnum,
        pmo.patid,
        pmo.hospitalname,
        pmo.hospitalcode,
        pmo.icd10code,
        pmo.diagname,
        pmo.deptcode,
        pmo.deptname,
        pmo.drcode,
        pmo.drname,
        pmo.admitdate,
        pmo.orgid,
        pmo.del_flag,
        pmo.guid,
        pmo.update_by,
        pmo.update_time,
        pmo.create_by,
        pmo.create_time,
        pmo.isupload,
        pmo.upload_time,
        pmo.schemestatus,
        pmo.deptid,
        pmo.schemetime,
        pmo.hpi,
        pmo.patname,
        CONCAT(pa.age,pa.age_unit,pa.age2,pa.age_unit2) AS age,
        pa.telcode,
        pmo.mainsuit
        from pat_med_outhosp pmo left join pat_archive pa on pmo.patid = pa.id
        <where>
            pmo.del_flag=0
            and pmo.orgid =#{orgid}
            <if test="hospitalname != null  and hospitalname != ''">and pmo.hospitalname like concat('%',
                #{hospitalname},
                '%')
            </if>
            <if test="deptname != null  and deptname != ''">and pmo.deptname like concat('%', #{deptname}, '%')</if>
            <if test="drname != null  and drname != ''">and pmo.drname like concat('%', #{drname}, '%')</if>
            <if test="patname != null  and patname != ''">and pmo.patname like concat('%', #{patname}, '%')</if>
            <if test="admitdate != null ">and pmo.admitdate = #{admitdate}</if>
            <if test="patid != null ">and pmo.patid = #{patid}</if>
            <if test="patno != null ">and pmo.patno = #{patno}</if>
            <if test="orgid != null  and orgid != ''">and pmo.orgid = #{orgid}</if>
            <if test="outhospno != null  and outhospno != ''">and pmo.outhospno = #{outhospno}</if>
        </where>
        order by pmo.update_time desc
    </select>
    <!--    <select id="selectPatMedOuthospList" parameterType="com.smartor.domain.PatMedOuthosp"-->
    <!--            resultMap="PatMedOuthospResult">-->
    <!--        select-->
    <!--        pmo.id,-->
    <!--        pmo.outhospno,-->
    <!--        pmo.patno,-->
    <!--        pmo.serialnum,-->
    <!--        pmo.patid,-->
    <!--        pmo.icd10code,-->
    <!--        pmo.diagname,-->
    <!--        pmo.deptcode,-->
    <!--        pmo.deptname,-->
    <!--        pmo.drcode,-->
    <!--        pmo.drname,-->
    <!--        pmo.admitdate,-->
    <!--        pmo.schemestatus,-->
    <!--        pmo.deptid,-->
    <!--        pmo.schemetime,-->
    <!--        pmo.fuflag,-->
    <!--        pmo.patname,-->
    <!--        pmo.update_time,-->
    <!--        pmo.mainsuit-->
    <!--        from pat_med_outhosp pmo-->
    <!--        <where>pmo.del_flag='0'-->
    <!--            <if test="orgid != null ">and pmo.orgid = #{orgid}</if>-->
    <!--            <if test="serialnum != null ">and pmo.serialnum = #{serialnum}</if>-->
    <!--            <if test="serverState != null ">and pmo.server_state = #{serverState}</if>-->
    <!--            <if test="hospitalname != null  and hospitalname != ''">and pmo.hospitalname like concat('%',-->
    <!--                #{hospitalname},-->
    <!--                '%')-->
    <!--            </if>-->
    <!--            <if test="deptcodes != null and deptcodes.size()>0">-->
    <!--                AND pmo.deptcode IN-->
    <!--                <foreach collection="deptcodes" item="deptcode" open="(" separator=","-->
    <!--                         close=")">-->
    <!--                    #{deptcode}-->
    <!--                </foreach>-->
    <!--            </if>-->
    <!--            <if test="deptname != null  and deptname != ''">and pmo.deptname like concat('%', #{deptname}, '%')</if>-->
    <!--            <if test="drname != null  and drname != ''">and pmo.drname like concat('%', #{drname}, '%')</if>-->
    <!--            <if test="patname != null  and patname != ''">and pmo.patname like concat('%', #{patname}, '%')</if>-->
    <!--            <if test="beginTime != null ">and date_format(pmo.admitdate,'%y%m%d') &gt;=-->
    <!--                date_format(#{beginTime},'%y%m%d')-->
    <!--            </if>-->
    <!--            <if test="endTime != null ">and date_format(pmo.admitdate,'%y%m%d') &lt;=-->
    <!--                date_format(#{endTime},'%y%m%d')-->
    <!--            </if>-->
    <!--            <if test="patid != null ">and pmo.patid = #{patid}</if>-->
    <!--            <if test="campusid != null ">and pmo.campusid = #{campusid}</if>-->
    <!--            <if test="fuflag != null ">and pmo.fuflag = #{fuflag}</if>-->
    <!--            <if test="patno != null ">and pmo.patno = #{patno}</if>-->
    <!--            <if test="outhospno != null  and outhospno != ''">and pmo.outhospno = #{outhospno}</if>-->
    <!--            <if test="diagcheckFlag != null  and diagcheckFlag != ''">and pmo.diagcheck_flag = #{diagcheckFlag}</if>-->
    <!--            <if test="diagname != null  and diagname != ''">and pmo.diagname like concat('%',#{diagname}, '%')</if>-->
    <!--        </where>-->
    <!--        order by pmo.update_time desc-->
    <!--        <if test="pageSize != null  and pageNum != null">limit ${pageSize} OFFSET ${pageNum}</if>-->
    <!--    </select>-->
    <select id="selectPatMedOuthospById" parameterType="Long" resultMap="PatMedOuthospResult">
        <include refid="selectPatMedOuthospVo"/>
        where id = #{id}
    </select>
    <insert id="insertPatMedOuthosp" parameterType="com.smartor.domain.PatMedOuthosp" useGeneratedKeys="true"
            keyProperty="id">
        insert into pat_med_outhosp
    <!--    <insert id="insertPatMedOuthosp" parameterType="com.smartor.domain.PatMedOuthosp" useGeneratedKeys="true"-->
    <!--            keyProperty="id">-->
    <!--        insert into pat_med_outhosp-->
    <!--        <trim prefix="(" suffix=")" suffixOverrides=",">-->
    <!--            <if test="serialnum != null">serialnum,</if>-->
    <!--            <if test="patid != null">patid,</if>-->
    <!--            <if test="hospitalname != null">hospitalname,</if>-->
    <!--            <if test="hospitalcode != null">hospitalcode,</if>-->
    <!--            <if test="icd10code != null">icd10code,</if>-->
    <!--            <if test="diagname != null">diagname,</if>-->
    <!--            <if test="deptcode != null">deptcode,</if>-->
    <!--            <if test="deptname != null">deptname,</if>-->
    <!--            <if test="drcode != null">drcode,</if>-->
    <!--            <if test="drname != null">drname,</if>-->
    <!--            <if test="admitdate != null">admitdate,</if>-->
    <!--            <if test="orgid != null">orgid,</if>-->
    <!--            <if test="delFlag != null and delFlag != ''">del_flag,</if>-->
    <!--            <if test="updateBy != null">update_by,</if>-->
    <!--            <if test="updateTime != null">update_time,</if>-->
    <!--            <if test="createBy != null">create_by,</if>-->
    <!--            <if test="createTime != null">create_time,</if>-->
    <!--            <if test="isupload != null">isupload,</if>-->
    <!--            <if test="uploadTime != null">upload_time,</if>-->
    <!--            <if test="schemestatus != null">schemestatus,</if>-->
    <!--            <if test="deptid != null">deptid,</if>-->
    <!--            <if test="schemetime != null">schemetime,</if>-->
    <!--            <if test="hpi != null">hpi,</if>-->
    <!--            <if test="mainsuit != null">mainsuit,</if>-->
    <!--            <if test="outhospno != null">outhospno,</if>-->
    <!--            <if test="patname != null">patname,</if>-->
    <!--            <if test="guid != null">guid,</if>-->
    <!--            <if test="patno != null">patno,</if>-->
    <!--            <if test="diagcheckFlag != null">diagcheck_flag,</if>-->
    <!--            <if test="remark != null">remark,</if>-->
    <!--            <if test="fuflag != null">fuflag,</if>-->
    <!--            <if test="fudate != null">fudate,</if>-->
    <!--            <if test="campusid != null">campusid,</if>-->
    <!--            <if test="serverState != null">server_state,</if>-->
    <!--        </trim>-->
    <!--        <trim prefix="values (" suffix=")" suffixOverrides=",">-->
    <!--            <if test="serialnum != null">#{serialnum},</if>-->
    <!--            <if test="patid != null">#{patid},</if>-->
    <!--            <if test="hospitalname != null">#{hospitalname},</if>-->
    <!--            <if test="hospitalcode != null">#{hospitalcode},</if>-->
    <!--            <if test="icd10code != null">#{icd10code},</if>-->
    <!--            <if test="diagname != null">#{diagname},</if>-->
    <!--            <if test="deptcode != null">#{deptcode},</if>-->
    <!--            <if test="deptname != null">#{deptname},</if>-->
    <!--            <if test="drcode != null">#{drcode},</if>-->
    <!--            <if test="drname != null">#{drname},</if>-->
    <!--            <if test="admitdate != null">#{admitdate},</if>-->
    <!--            <if test="orgid != null">#{orgid},</if>-->
    <!--            <if test="delFlag != null and delFlag != ''">#{delFlag},</if>-->
    <!--            <if test="updateBy != null">#{updateBy},</if>-->
    <!--            <if test="updateTime != null">#{updateTime},</if>-->
    <!--            <if test="createBy != null">#{createBy},</if>-->
    <!--            <if test="createTime != null">#{createTime},</if>-->
    <!--            <if test="isupload != null">#{isupload},</if>-->
    <!--            <if test="uploadTime != null">#{uploadTime},</if>-->
    <!--            <if test="schemestatus != null">#{schemestatus},</if>-->
    <!--            <if test="deptid != null">#{deptid},</if>-->
    <!--            <if test="schemetime != null">#{schemetime},</if>-->
    <!--            <if test="hpi != null">#{hpi},</if>-->
    <!--            <if test="mainsuit != null">#{mainsuit},</if>-->
    <!--            <if test="outhospno != null">#{outhospno},</if>-->
    <!--            <if test="patname != null">#{patname},</if>-->
    <!--            <if test="guid != null">#{guid},</if>-->
    <!--            <if test="patno != null">#{patno},</if>-->
    <!--            <if test="diagcheckFlag != null">#{diagcheckFlag},</if>-->
    <!--            <if test="remark != null">#{remark},</if>-->
    <!--            <if test="fuflag != null">#{fuflag},</if>-->
    <!--            <if test="fudate != null">#{fudate},</if>-->
    <!--            <if test="campusid != null">#{campusid},</if>-->
    <!--            <if test="serverState != null">#{serverState},</if>-->
    <!--        </trim>-->
    <!--    </insert>-->
    <!-- 新增到动态表名(用于路由到最新分表) -->
    <insert id="insertIntoTable" parameterType="map" useGeneratedKeys="true" keyProperty="record.id">
        insert into ${tableName}
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="serialnum != null">serialnum,</if>
            <if test="patid != null">patid,</if>
            <if test="hospitalname != null">hospitalname,</if>
            <if test="hospitalcode != null">hospitalcode,</if>
            <if test="icd10code != null">icd10code,</if>
            <if test="diagname != null">diagname,</if>
            <if test="deptcode != null">deptcode,</if>
            <if test="deptname != null">deptname,</if>
            <if test="drcode != null">drcode,</if>
            <if test="drname != null">drname,</if>
            <if test="admitdate != null">admitdate,</if>
            <if test="orgid != null">orgid,</if>
            <if test="delFlag != null and delFlag != ''">del_flag,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="isupload != null">isupload,</if>
            <if test="uploadTime != null">upload_time,</if>
            <if test="schemestatus != null">schemestatus,</if>
            <if test="deptid != null">deptid,</if>
            <if test="schemetime != null">schemetime,</if>
            <if test="hpi != null">hpi,</if>
            <if test="mainsuit != null">mainsuit,</if>
            <if test="outhospno != null">outhospno,</if>
            <if test="patname != null">patname,</if>
            <if test="guid != null">guid,</if>
            <if test="patno != null">patno,</if>
            <if test="record.serialnum != null">serialnum,</if>
            <if test="record.patid != null">patid,</if>
            <if test="record.hospitalname != null">hospitalname,</if>
            <if test="record.hospitalcode != null">hospitalcode,</if>
            <if test="record.icd10code != null">icd10code,</if>
            <if test="record.diagname != null">diagname,</if>
            <if test="record.deptcode != null">deptcode,</if>
            <if test="record.deptname != null">deptname,</if>
            <if test="record.drcode != null">drcode,</if>
            <if test="record.drname != null">drname,</if>
            <if test="record.admitdate != null">admitdate,</if>
            <if test="record.orgid != null">orgid,</if>
            <if test="record.delFlag != null and record.delFlag != ''">del_flag,</if>
            <if test="record.updateBy != null">update_by,</if>
            <if test="record.updateTime != null">update_time,</if>
            <if test="record.createBy != null">create_by,</if>
            <if test="record.createTime != null">create_time,</if>
            <if test="record.isupload != null">isupload,</if>
            <if test="record.uploadTime != null">upload_time,</if>
            <if test="record.schemestatus != null">schemestatus,</if>
            <if test="record.deptid != null">deptid,</if>
            <if test="record.schemetime != null">schemetime,</if>
            <if test="record.hpi != null">hpi,</if>
            <if test="record.mainsuit != null">mainsuit,</if>
            <if test="record.outhospno != null">outhospno,</if>
            <if test="record.patname != null">patname,</if>
            <if test="record.guid != null">guid,</if>
            <if test="record.patno != null">patno,</if>
            <if test="record.diagcheckFlag != null">diagcheck_flag,</if>
            <if test="record.remark != null">remark,</if>
            <if test="record.fuflag != null">fuflag,</if>
            <if test="record.fudate != null">fudate,</if>
            <if test="record.campusid != null">campusid,</if>
            <if test="record.serverState != null">server_state,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="serialnum != null">#{serialnum},</if>
            <if test="patid != null">#{patid},</if>
            <if test="hospitalname != null">#{hospitalname},</if>
            <if test="hospitalcode != null">#{hospitalcode},</if>
            <if test="icd10code != null">#{icd10code},</if>
            <if test="diagname != null">#{diagname},</if>
            <if test="deptcode != null">#{deptcode},</if>
            <if test="deptname != null">#{deptname},</if>
            <if test="drcode != null">#{drcode},</if>
            <if test="drname != null">#{drname},</if>
            <if test="admitdate != null">#{admitdate},</if>
            <if test="orgid != null">#{orgid},</if>
            <if test="delFlag != null and delFlag != ''">#{delFlag},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="isupload != null">#{isupload},</if>
            <if test="uploadTime != null">#{uploadTime},</if>
            <if test="schemestatus != null">#{schemestatus},</if>
            <if test="deptid != null">#{deptid},</if>
            <if test="schemetime != null">#{schemetime},</if>
            <if test="hpi != null">#{hpi},</if>
            <if test="mainsuit != null">#{mainsuit},</if>
            <if test="outhospno != null">#{outhospno},</if>
            <if test="patname != null">#{patname},</if>
            <if test="guid != null">#{guid},</if>
            <if test="patno != null">#{patno},</if>
            <if test="record.serialnum != null">#{record.serialnum},</if>
            <if test="record.patid != null">#{record.patid},</if>
            <if test="record.hospitalname != null">#{record.hospitalname},</if>
            <if test="record.hospitalcode != null">#{record.hospitalcode},</if>
            <if test="record.icd10code != null">#{record.icd10code},</if>
            <if test="record.diagname != null">#{record.diagname},</if>
            <if test="record.deptcode != null">#{record.deptcode},</if>
            <if test="record.deptname != null">#{record.deptname},</if>
            <if test="record.drcode != null">#{record.drcode},</if>
            <if test="record.drname != null">#{record.drname},</if>
            <if test="record.admitdate != null">#{record.admitdate},</if>
            <if test="record.orgid != null">#{record.orgid},</if>
            <if test="record.delFlag != null and record.delFlag != ''">#{record.delFlag},</if>
            <if test="record.updateBy != null">#{record.updateBy},</if>
            <if test="record.updateTime != null">#{record.updateTime},</if>
            <if test="record.createBy != null">#{record.createBy},</if>
            <if test="record.createTime != null">#{record.createTime},</if>
            <if test="record.isupload != null">#{record.isupload},</if>
            <if test="record.uploadTime != null">#{record.uploadTime},</if>
            <if test="record.schemestatus != null">#{record.schemestatus},</if>
            <if test="record.deptid != null">#{record.deptid},</if>
            <if test="record.schemetime != null">#{record.schemetime},</if>
            <if test="record.hpi != null">#{record.hpi},</if>
            <if test="record.mainsuit != null">#{record.mainsuit},</if>
            <if test="record.outhospno != null">#{record.outhospno},</if>
            <if test="record.patname != null">#{record.patname},</if>
            <if test="record.guid != null">#{record.guid},</if>
            <if test="record.patno != null">#{record.patno},</if>
            <if test="record.diagcheckFlag != null">#{record.diagcheckFlag},</if>
            <if test="record.remark != null">#{record.remark},</if>
            <if test="record.fuflag != null">#{record.fuflag},</if>
            <if test="record.fudate != null">#{record.fudate},</if>
            <if test="record.campusid != null">#{record.campusid},</if>
            <if test="record.serverState != null">#{record.serverState},</if>
        </trim>
    </insert>
    <update id="updatePatMedOuthosp" parameterType="com.smartor.domain.PatMedOuthosp">
        update pat_med_outhosp
        <trim prefix="SET" suffixOverrides=",">
            <if test="serialnum != null">serialnum = #{serialnum},</if>
            <if test="patid != null">patid = #{patid},</if>
            <if test="hospitalname != null">hospitalname = #{hospitalname},</if>
            <if test="hospitalcode != null">hospitalcode = #{hospitalcode},</if>
            <if test="icd10code != null">icd10code = #{icd10code},</if>
            <if test="diagname != null">diagname = #{diagname},</if>
            <if test="deptcode != null">deptcode = #{deptcode},</if>
            <if test="deptname != null">deptname = #{deptname},</if>
            <if test="drcode != null">drcode = #{drcode},</if>
            <if test="drname != null">drname = #{drname},</if>
            <if test="admitdate != null">admitdate = #{admitdate},</if>
            <if test="orgid != null">orgid = #{orgid},</if>
            <if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="isupload != null">isupload = #{isupload},</if>
            <if test="uploadTime != null">upload_time = #{uploadTime},</if>
            <if test="schemestatus != null">schemestatus = #{schemestatus},</if>
            <if test="deptid != null">deptid = #{deptid},</if>
            <if test="schemetime != null">schemetime = #{schemetime},</if>
            <if test="hpi != null">hpi = #{hpi},</if>
            <if test="mainsuit != null">mainsuit = #{mainsuit},</if>
            <if test="outhospno != null">outhospno = #{outhospno},</if>
            <if test="patname != null">patname = #{patname},</if>
            <if test="guid != null">guid = #{guid},</if>
            <if test="patno != null">patno = #{patno},</if>
        </trim>
        where id = #{id}
    <!--    <update id="updatePatMedOuthosp" parameterType="com.smartor.domain.PatMedOuthosp">-->
    <!--        update pat_med_outhosp-->
    <!--        <trim prefix="SET" suffixOverrides=",">-->
    <!--            <if test="serialnum != null">serialnum = #{serialnum},</if>-->
    <!--            <if test="patid != null">patid = #{patid},</if>-->
    <!--            <if test="hospitalname != null">hospitalname = #{hospitalname},</if>-->
    <!--            <if test="hospitalcode != null">hospitalcode = #{hospitalcode},</if>-->
    <!--            <if test="icd10code != null">icd10code = #{icd10code},</if>-->
    <!--            <if test="diagname != null">diagname = #{diagname},</if>-->
    <!--            <if test="deptcode != null">deptcode = #{deptcode},</if>-->
    <!--            <if test="deptname != null">deptname = #{deptname},</if>-->
    <!--            <if test="drcode != null">drcode = #{drcode},</if>-->
    <!--            <if test="drname != null">drname = #{drname},</if>-->
    <!--            <if test="admitdate != null">admitdate = #{admitdate},</if>-->
    <!--            <if test="orgid != null">orgid = #{orgid},</if>-->
    <!--            <if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if>-->
    <!--            <if test="updateBy != null">update_by = #{updateBy},</if>-->
    <!--            <if test="updateTime != null">update_time = #{updateTime},</if>-->
    <!--            <if test="createBy != null">create_by = #{createBy},</if>-->
    <!--            <if test="createTime != null">create_time = #{createTime},</if>-->
    <!--            <if test="isupload != null">isupload = #{isupload},</if>-->
    <!--            <if test="uploadTime != null">upload_time = #{uploadTime},</if>-->
    <!--            <if test="schemestatus != null">schemestatus = #{schemestatus},</if>-->
    <!--            <if test="deptid != null">deptid = #{deptid},</if>-->
    <!--            <if test="schemetime != null">schemetime = #{schemetime},</if>-->
    <!--            <if test="hpi != null">hpi = #{hpi},</if>-->
    <!--            <if test="mainsuit != null">mainsuit = #{mainsuit},</if>-->
    <!--            <if test="outhospno != null">outhospno = #{outhospno},</if>-->
    <!--            <if test="patname != null">patname = #{patname},</if>-->
    <!--            <if test="guid != null">guid = #{guid},</if>-->
    <!--            <if test="patno != null">patno = #{patno},</if>-->
    <!--            <if test="diagcheckFlag != null">diagcheck_flag = #{diagcheckFlag},</if>-->
    <!--            <if test="remark != null">remark = #{remark},</if>-->
    <!--            <if test="fuflag != null">fuflag = #{fuflag},</if>-->
    <!--            <if test="fudate != null">fudate = #{fudate},</if>-->
    <!--            <if test="campusid != null">campusid = #{campusid},</if>-->
    <!--            <if test="serverState != null">server_state = #{serverState},</if>-->
    <!--        </trim>-->
    <!--        where id = #{id}-->
    <!--    </update>-->
    <select id="getTableColumns" resultType="String">
        SELECT column_name
        FROM information_schema.columns
        WHERE table_schema = DATABASE()
          AND table_name = #{tableName}
        ORDER BY ordinal_position
    </select>
    <select id="getTableColumnMeta" resultType="java.util.HashMap">
        SELECT column_name AS column_name,
               data_type   AS data_type,
               column_type AS column_type
        FROM information_schema.columns
        WHERE table_schema = DATABASE()
          AND table_name = #{tableName}
        ORDER BY ordinal_position
    </select>
    <update id="createOrReplaceProcedure">
        ${procSql}
    </update>
    <delete id="deletePatMedOuthospById" parameterType="Long">
        delete
        from pat_med_outhosp
        where id = #{id}
    </delete>
    <!-- 调用存储过程 sp_query_outhosp 查询门诊记录 -->
    <select id="callSpQueryOuthosp" parameterType="com.smartor.domain.PatMedOuthospQueryReq"
            resultType="com.smartor.domain.PatMedOuthosp"
            statementType="CALLABLE">
        {CALL sp_query_outhosp(
                #{outhospno,     jdbcType=VARCHAR,  mode=IN},
                #{serialnum,     jdbcType=VARCHAR,  mode=IN},
                #{patid,         jdbcType=BIGINT,   mode=IN},
                #{patname,       jdbcType=VARCHAR,  mode=IN},
                #{patno,        jdbcType=VARCHAR,  mode=IN},
                #{hospitalname,  jdbcType=VARCHAR,  mode=IN},
                #{hospitalcode,  jdbcType=VARCHAR,  mode=IN},
                #{icd10code,     jdbcType=VARCHAR,  mode=IN},
                #{diagname,      jdbcType=VARCHAR,  mode=IN},
                #{deptid,        jdbcType=BIGINT,   mode=IN},
                #{deptcode,      jdbcType=VARCHAR,  mode=IN},
                #{deptname,      jdbcType=VARCHAR,  mode=IN},
                #{drcode,        jdbcType=VARCHAR,  mode=IN},
                #{drname,        jdbcType=VARCHAR,  mode=IN},
                #{beginAdmitdate,jdbcType=DATE,     mode=IN},
                #{endAdmitdate,  jdbcType=DATE,     mode=IN},
                #{orgid,         jdbcType=VARCHAR,  mode=IN},
                #{isupload,      jdbcType=BIGINT,   mode=IN},
                #{schemestatus,  jdbcType=BIGINT,   mode=IN},
                #{hpi,         jdbcType=VARCHAR,  mode=IN},
                #{mainsuit,         jdbcType=VARCHAR,  mode=IN},
                #{pid,   jdbcType=INTEGER,  mode=IN},
                #{guid, jdbcType=VARCHAR,  mode=IN},
                #{pguid, jdbcType=VARCHAR,  mode=IN},
                #{hospitaldistrictcode,   jdbcType=VARCHAR,  mode=IN},
                #{hospitaldistrictname,   jdbcType=VARCHAR,  mode=IN},
                #{diagcheckFlag,          jdbcType=VARCHAR,  mode=IN},
                #{fuflag,          jdbcType=VARCHAR,  mode=IN},
                #{campusid,          jdbcType=VARCHAR,  mode=IN},
                #{serverState,      jdbcType=VARCHAR,  mode=IN},
                #{pageSize,      jdbcType=INTEGER,  mode=IN},
                #{pageNum,       jdbcType=INTEGER,  mode=IN}
            )}
    </select>
    <delete id="deletePatMedOuthospByIds" parameterType="String">
        delete from pat_med_outhosp where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    <select id="selectPatMedOuthospCount" parameterType="com.smartor.domain.PatMedReq"
            resultType="com.smartor.domain.PatMedRes">
        SELECT
        COUNT(id) AS rc,
        COUNT(DISTINCT patid) AS rs
        FROM
        pat_med_outhosp
        <where>
            del_flag=0
            and date_format(admitdate,'%y%m%d') &gt;= date_format(#{startDate},'%y%m%d')
            and date_format(admitdate,'%y%m%d') &lt;= date_format(#{endDate},'%y%m%d')
            <if test="deptcodeList != null">
                and deptcode in
                <foreach collection="deptcodeList" item="deptcode" open="(" separator="," close=")">
                    #{deptcode}
                </foreach>
            </if>
    <select id="callSpQueryOuthospCount" parameterType="com.smartor.domain.PatMedOuthospQueryReq"
            resultType="Long"
            statementType="CALLABLE">
        {CALL sp_count_outhosp(
                #{outhospno,     jdbcType=VARCHAR,  mode=IN},
                #{serialnum,     jdbcType=VARCHAR,  mode=IN},
                #{patid,         jdbcType=BIGINT,   mode=IN},
                #{patname,       jdbcType=VARCHAR,  mode=IN},
                #{patno,        jdbcType=VARCHAR,  mode=IN},
                #{hospitalname,  jdbcType=VARCHAR,  mode=IN},
                #{hospitalcode,  jdbcType=VARCHAR,  mode=IN},
                #{icd10code,     jdbcType=VARCHAR,  mode=IN},
                #{diagname,      jdbcType=VARCHAR,  mode=IN},
                #{deptid,        jdbcType=BIGINT,   mode=IN},
                #{deptcode,      jdbcType=VARCHAR,  mode=IN},
                #{deptname,      jdbcType=VARCHAR,  mode=IN},
                #{drcode,        jdbcType=VARCHAR,  mode=IN},
                #{drname,        jdbcType=VARCHAR,  mode=IN},
                #{beginAdmitdate,jdbcType=DATE,     mode=IN},
                #{endAdmitdate,  jdbcType=DATE,     mode=IN},
                #{orgid,         jdbcType=VARCHAR,  mode=IN},
                #{isupload,      jdbcType=BIGINT,   mode=IN},
                #{schemestatus,  jdbcType=BIGINT,   mode=IN},
                #{hpi,         jdbcType=VARCHAR,  mode=IN},
                #{mainsuit,         jdbcType=VARCHAR,  mode=IN},
                #{pid,   jdbcType=INTEGER,  mode=IN},
                #{guid, jdbcType=VARCHAR,  mode=IN},
                #{pguid, jdbcType=VARCHAR,  mode=IN},
                #{hospitaldistrictcode,   jdbcType=VARCHAR,  mode=IN},
                #{hospitaldistrictname,   jdbcType=VARCHAR,  mode=IN},
                #{diagcheckFlag,          jdbcType=VARCHAR,  mode=IN},
                #{fuflag,          jdbcType=VARCHAR,  mode=IN},
                #{campusid,          jdbcType=VARCHAR,  mode=IN},
                #{serverState,      jdbcType=VARCHAR,  mode=IN}
            )}
    </select>
    <select id="existsInTable" resultType="int">
        SELECT COUNT(*)
        FROM ${tableName}
        WHERE id = #{id}
    </select>
    <update id="updateInTable" parameterType="map">
        update ${tableName}
        <trim prefix="SET" suffixOverrides=",">
            <if test="record.serialnum != null">serialnum = #{record.serialnum},</if>
            <if test="record.patid != null">patid = #{record.patid},</if>
            <if test="record.hospitalname != null">hospitalname = #{record.hospitalname},</if>
            <if test="record.hospitalcode != null">hospitalcode = #{record.hospitalcode},</if>
            <if test="record.icd10code != null">icd10code = #{record.icd10code},</if>
            <if test="record.diagname != null">diagname = #{record.diagname},</if>
            <if test="record.deptcode != null">deptcode = #{record.deptcode},</if>
            <if test="record.deptname != null">deptname = #{record.deptname},</if>
            <if test="record.drcode != null">drcode = #{record.drcode},</if>
            <if test="record.drname != null">drname = #{record.drname},</if>
            <if test="record.admitdate != null">admitdate = #{record.admitdate},</if>
            <if test="record.orgid != null">orgid = #{record.orgid},</if>
            <if test="record.delFlag != null and record.delFlag != ''">del_flag = #{record.delFlag},</if>
            <if test="record.updateBy != null">update_by = #{record.updateBy},</if>
            <if test="record.updateTime != null">update_time = #{record.updateTime},</if>
            <if test="record.createBy != null">create_by = #{record.createBy},</if>
            <if test="record.createTime != null">create_time = #{record.createTime},</if>
            <if test="record.isupload != null">isupload = #{record.isupload},</if>
            <if test="record.uploadTime != null">upload_time = #{record.uploadTime},</if>
            <if test="record.schemestatus != null">schemestatus = #{record.schemestatus},</if>
            <if test="record.deptid != null">deptid = #{record.deptid},</if>
            <if test="record.schemetime != null">schemetime = #{record.schemetime},</if>
            <if test="record.hpi != null">hpi = #{record.hpi},</if>
            <if test="record.mainsuit != null">mainsuit = #{record.mainsuit},</if>
            <if test="record.outhospno != null">outhospno = #{record.outhospno},</if>
            <if test="record.patname != null">patname = #{record.patname},</if>
            <if test="record.guid != null">guid = #{record.guid},</if>
            <if test="record.patno != null">patno = #{record.patno},</if>
            <if test="record.diagcheckFlag != null">diagcheck_flag = #{record.diagcheckFlag},</if>
            <if test="record.remark != null">remark = #{record.remark},</if>
            <if test="record.fuflag != null">fuflag = #{record.fuflag},</if>
            <if test="record.fudate != null">fudate = #{record.fudate},</if>
            <if test="record.campusid != null">campusid = #{record.campusid},</if>
            <if test="record.serverState != null">server_state = #{record.serverState},</if>
        </trim>
        <where>del_flag=0
            <if test="record.guid != null">and guid = #{record.guid}</if>
            <if test="record.serialnum != null">and serialnum = #{record.serialnum}</if>
        </where>
    </update>
    <select id="tableExists" resultType="int">
        SELECT COUNT(*)
        FROM information_schema.tables
        WHERE table_schema = DATABASE()
          AND table_name = #{tableName}
    </select>
    <update id="createPatMedOuthosp">
        CREATE TABLE ${newName} LIKE ${templateName}
    </update>
    <update id="createPatMedOuthospAutoAdd">
        ALTER TABLE ${newName} MODIFY COLUMN id BIGINT NOT NULL AUTO_INCREMENT;
    </update>
    <update id="setAutoIncrement">
        ALTER TABLE ${tableName} AUTO_INCREMENT = #{autoInc}
    </update>
    <select id="getAllOuthospTableNames" resultType="String">
        SELECT table_name
        FROM information_schema.tables
        WHERE table_schema = DATABASE()
          AND table_name LIKE 'pat_med_outhosp%'
    </select>
</mapper>