<?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.emr.dao.approve.Emr_Apply_ApproveMapper" >
  <resultMap id="BaseResultMap" type="com.emr.entity.approve.Emr_Apply_Approve" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="applyer" property="applyer" jdbcType="NVARCHAR" />
    <result column="apply_time" property="applyTime" jdbcType="NCHAR" />
    <result column="effe_time" property="effeTime" jdbcType="NCHAR" />
    <result column="effe_days" property="effeDays" jdbcType="INTEGER" />
    <result column="apply_type" property="applyType" jdbcType="NVARCHAR" />
    <result column="apply_reason" property="applyReason" jdbcType="NVARCHAR" />
    <result column="apply_state" property="applyState" jdbcType="NVARCHAR" />
    <result column="approver" property="approver" jdbcType="NVARCHAR" />
    <result column="approve_time" property="approveTime" jdbcType="NCHAR" />
    <result column="approve_state" property="approveState" jdbcType="NVARCHAR" />
    <result column="approve_notes" property="approveNotes" jdbcType="NVARCHAR" />
    <result column="patient_id" property="patientId" jdbcType="VARCHAR" />
    <result column="admiss_id" property="admissId" jdbcType="CHAR" />
    <result column="inpatient_no" property="inpatientNo" jdbcType="CHAR" />
    <result column="admiss_times" property="admissTimes" jdbcType="SMALLINT" />
    <result column="dis_date" property="disDate" jdbcType="TIMESTAMP" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, applyer, apply_time, effe_time, effe_days, apply_type, apply_reason, apply_state, 
    approver, approve_time, approve_state, approve_notes, patient_id, admiss_id, inpatient_no, 
    admiss_times, dis_date
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from emr_apply_approve
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from emr_apply_approve
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.emr.entity.approve.Emr_Apply_Approve" >
    insert into emr_apply_approve (applyer, apply_time,
      effe_time, effe_days, apply_type, 
      apply_reason, apply_state, approver, 
      approve_time, approve_state, approve_notes, 
      patient_id, admiss_id, inpatient_no, 
      admiss_times, dis_date)
    values (#{applyer,jdbcType=NVARCHAR}, #{applyTime,jdbcType=NCHAR},
      #{effeTime,jdbcType=NCHAR}, #{effeDays,jdbcType=INTEGER}, #{applyType,jdbcType=NVARCHAR}, 
      #{applyReason,jdbcType=NVARCHAR}, #{applyState,jdbcType=NVARCHAR}, #{approver,jdbcType=NVARCHAR}, 
      #{approveTime,jdbcType=NCHAR}, #{approveState,jdbcType=NVARCHAR}, #{approveNotes,jdbcType=NVARCHAR}, 
      #{patientId,jdbcType=VARCHAR}, #{admissId,jdbcType=CHAR}, #{inpatientNo,jdbcType=CHAR}, 
      #{admissTimes,jdbcType=SMALLINT}, #{disDate,jdbcType=TIMESTAMP})
  </insert>
  <insert id="insertSelective" parameterType="com.emr.entity.approve.Emr_Apply_Approve" >
    insert into emr_apply_approve
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="applyer != null" >
        applyer,
      </if>
      <if test="applyTime != null" >
        apply_time,
      </if>
      <if test="effeTime != null" >
        effe_time,
      </if>
      <if test="effeDays != null" >
        effe_days,
      </if>
      <if test="applyType != null" >
        apply_type,
      </if>
      <if test="applyReason != null" >
        apply_reason,
      </if>
      <if test="applyState != null" >
        apply_state,
      </if>
      <if test="approver != null" >
        approver,
      </if>
      <if test="approveTime != null" >
        approve_time,
      </if>
      <if test="approveState != null" >
        approve_state,
      </if>
      <if test="approveNotes != null" >
        approve_notes,
      </if>
      <if test="patientId != null" >
        patient_id,
      </if>
      <if test="admissId != null" >
        admiss_id,
      </if>
      <if test="inpatientNo != null" >
        inpatient_no,
      </if>
      <if test="admissTimes != null" >
        admiss_times,
      </if>
      <if test="disDate != null" >
        dis_date,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=INTEGER},
      </if>
      <if test="applyer != null" >
        #{applyer,jdbcType=NVARCHAR},
      </if>
      <if test="applyTime != null" >
        #{applyTime,jdbcType=NCHAR},
      </if>
      <if test="effeTime != null" >
        #{effeTime,jdbcType=NCHAR},
      </if>
      <if test="effeDays != null" >
        #{effeDays,jdbcType=INTEGER},
      </if>
      <if test="applyType != null" >
        #{applyType,jdbcType=NVARCHAR},
      </if>
      <if test="applyReason != null" >
        #{applyReason,jdbcType=NVARCHAR},
      </if>
      <if test="applyState != null" >
        #{applyState,jdbcType=NVARCHAR},
      </if>
      <if test="approver != null" >
        #{approver,jdbcType=NVARCHAR},
      </if>
      <if test="approveTime != null" >
        #{approveTime,jdbcType=NCHAR},
      </if>
      <if test="approveState != null" >
        #{approveState,jdbcType=NVARCHAR},
      </if>
      <if test="approveNotes != null" >
        #{approveNotes,jdbcType=NVARCHAR},
      </if>
      <if test="patientId != null" >
        #{patientId,jdbcType=VARCHAR},
      </if>
      <if test="admissId != null" >
        #{admissId,jdbcType=CHAR},
      </if>
      <if test="inpatientNo != null" >
        #{inpatientNo,jdbcType=CHAR},
      </if>
      <if test="admissTimes != null" >
        #{admissTimes,jdbcType=SMALLINT},
      </if>
      <if test="disDate != null" >
        #{disDate,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.emr.entity.approve.Emr_Apply_Approve" >
    update emr_apply_approve
    <set >
      <if test="applyer != null" >
        applyer = #{applyer,jdbcType=NVARCHAR},
      </if>
      <if test="applyTime != null" >
        apply_time = #{applyTime,jdbcType=NCHAR},
      </if>
      <if test="effeTime != null" >
        effe_time = #{effeTime,jdbcType=NCHAR},
      </if>
      <if test="effeDays != null" >
        effe_days = #{effeDays,jdbcType=INTEGER},
      </if>
      <if test="applyType != null" >
        apply_type = #{applyType,jdbcType=NVARCHAR},
      </if>
      <if test="applyReason != null" >
        apply_reason = #{applyReason,jdbcType=NVARCHAR},
      </if>
      <if test="applyState != null" >
        apply_state = #{applyState,jdbcType=NVARCHAR},
      </if>
      <if test="approver != null" >
        approver = #{approver,jdbcType=NVARCHAR},
      </if>
      <if test="approveTime != null" >
        approve_time = #{approveTime,jdbcType=NCHAR},
      </if>
      <if test="approveState != null" >
        approve_state = #{approveState,jdbcType=NVARCHAR},
      </if>
      <if test="approveNotes != null" >
        approve_notes = #{approveNotes,jdbcType=NVARCHAR},
      </if>
      <if test="patientId != null" >
        patient_id = #{patientId,jdbcType=VARCHAR},
      </if>
      <if test="admissId != null" >
        admiss_id = #{admissId,jdbcType=CHAR},
      </if>
      <if test="inpatientNo != null" >
        inpatient_no = #{inpatientNo,jdbcType=CHAR},
      </if>
      <if test="admissTimes != null" >
        admiss_times = #{admissTimes,jdbcType=SMALLINT},
      </if>
      <if test="disDate != null" >
        dis_date = #{disDate,jdbcType=TIMESTAMP},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.emr.entity.approve.Emr_Apply_Approve" >
    update emr_apply_approve
    set applyer = #{applyer,jdbcType=NVARCHAR},
      apply_time = #{applyTime,jdbcType=NCHAR},
      effe_time = #{effeTime,jdbcType=NCHAR},
      effe_days = #{effeDays,jdbcType=INTEGER},
      apply_type = #{applyType,jdbcType=NVARCHAR},
      apply_reason = #{applyReason,jdbcType=NVARCHAR},
      apply_state = #{applyState,jdbcType=NVARCHAR},
      approver = #{approver,jdbcType=NVARCHAR},
      approve_time = #{approveTime,jdbcType=NCHAR},
      approve_state = #{approveState,jdbcType=NVARCHAR},
      approve_notes = #{approveNotes,jdbcType=NVARCHAR},
      patient_id = #{patientId,jdbcType=VARCHAR},
      admiss_id = #{admissId,jdbcType=CHAR},
      inpatient_no = #{inpatientNo,jdbcType=CHAR},
      admiss_times = #{admissTimes,jdbcType=SMALLINT},
      dis_date = #{disDate,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <!--根据用户获取审批通过且未过期的patientId集合-->
  <select id="selectPatientIdsByUser" resultMap="BaseResultMap" parameterType="java.lang.String">
      SELECT
          patient_id,inpatient_no
      FROM
          emr_apply_approve
      WHERE
          effe_time > GETDATE() -1
      AND
          approve_state = '1'
      AND
          applyer = #{userName}
          <if test="patientId != null and patientId != ''">
              AND  patient_id = #{patientId}
          </if>
          <choose>
              <when test="type != null and type == 3">
                  AND apply_type = 3
              </when>
              <otherwise>
                  AND apply_type != 3
              </otherwise>
          </choose>
  </select>
  <!--根据用户获取确认且未过期的patientId集合-->
  <select id="selectPatientIdsByUserAndApplyStatus" resultMap="BaseResultMap" parameterType="java.lang.String">
      SELECT
          patient_id
      FROM
          emr_apply_approve
      WHERE
          effe_time > GETDATE() -1
      AND
          apply_state = '2'
      AND
          approve_state != '2'
      AND
          applyer = #{userName}
          <if test="patientId != null and patientId != ''">
              AND  patient_id IN (${patientId})
          </if>
          <if test="applyType != null and applyType != ''">
              AND  apply_type = #{applyType}
          </if>
      GROUP BY patient_id
  </select>
  <!--根据用户获取保存未提交的patientId集合-->
  <select id="selectNotSumbitPatientIdsByUser" resultMap="BaseResultMap" parameterType="java.lang.String">
      SELECT
          id,effe_time,effe_days,apply_type,apply_reason,inpatient_no
      FROM
          emr_apply_approve
      WHERE
          apply_state = '1'
      AND
          applyer = #{userName}
      AND
          patient_id = #{patientId}
      <choose>
          <when test="type != '' and type == 2">
              AND apply_type == 3
          </when>
          <otherwise>
              AND apply_type != 3
          </otherwise>
      </choose>
  </select>

  <!--根据申请者查询申请集合-->
  <select id="selectAllApproveByCreater" resultMap="BaseResultMap">
    SELECT
        a.id,
        a.applyer,
        a.apply_time,
        a.effe_time,
        a.effe_days,
        emr_dictionary.Name apply_type,
        a.apply_reason,
        a.inpatient_no,
        a.admiss_times,
        a.dis_date,
        a.approve_notes,
        a.patient_id,
    CASE WHEN effe_time  &lt;= GETDATE() THEN '已过期' WHEN apply_state='1' THEN '未提交' WHEN apply_state='2' THEN '已提交' END apply_state,
        a.approver,
        a.approve_time,
    CASE WHEN effe_time  &lt;= GETDATE() THEN '已过期' WHEN approve_state = '1' THEN '审核通过' WHEN approve_state='2' THEN '审核不通过' WHEN approve_state is null THEN '待审批'  END approve_state,
        c.name,
        CASE WHEN emr_lock.id is null THEN 0 ELSE 1 END lockStatus
    FROM
        emr_apply_approve a
    LEFT JOIN
      commomtable c
    ON
        a.patient_id = c.patient_id
    LEFT JOIN
        (select code,Name from emr_dictionary where parent_id = 'apply_type') emr_dictionary
    ON
        a.apply_type = emr_dictionary.code
    LEFT JOIN
        emr_lock
    ON
        a.patient_id = emr_lock.patient_id
    AND emr_lock.lock_state = 1
    <where>
        <if test="applyers != '' and applyers != null">
            a.applyer IN (${applyers})
        </if>
        <if test="record.applyer != '' and record.applyer != null">
          AND a.applyer LIKE '%${record.applyer}%'
        </if>
        <if test="record.approver != '' and record.approver != null">
          AND a.approver LIKE '${record.approver}%'
        </if>
        <if test="record.effeDays != '' and record.effeDays != null">
          AND a.effe_days = ${record.effeDays}
        </if>
        <if test="record.inpatientNo != '' and record.inpatientNo != null">
          AND a.inpatient_no LIKE '%${record.inpatientNo}%'
        </if>
        <if test="startTime1 != '' and startTime1 != null">
          AND a.apply_time &gt;=  #{startTime1}
          <if test="endTime1 != '' and endTime1 != null">
            AND a.apply_time  &lt;= #{endTime1}
          </if>
        </if>
        <if test="startTime2 != '' and startTime2 != null">
          AND a.approve_time &gt;=  #{startTime2}
          <if test="endTime2 != '' and endTime2 != null">
            AND a.approve_time  &lt;= #{endTime2}
          </if>
        </if>
        <if test="record.name != '' and record.name != null">
          AND c.name LIKE '%${record.name}%'
        </if>
        <if test="record.applyType != '' and record.applyType != null">
          AND a.apply_type = ${record.applyType}
        </if>
        <if test="record.applyState != '' and record.applyState != null">
          AND (CASE WHEN effe_time  &lt;= GETDATE() THEN '已过期' WHEN apply_state='1' THEN '未提交' WHEN apply_state='2' THEN '已提交' END) = #{record.applyState}
        </if>
        <if test="record.approveState != '' and record.approveState != null">
          AND (CASE WHEN effe_time  &lt;= GETDATE() THEN '已过期' WHEN approve_state = '1' THEN '审核通过' WHEN approve_state='2' THEN '审核不通过' WHEN approve_state is null THEN '待审批' WHEN approve_state = '' THEN '待审批'  END) = #{record.approveState}
        </if>
    </where>
    ORDER BY a.apply_time DESC
  </select>

  <!--查询审批集合-->
  <select id="selectAllApprove" resultMap="BaseResultMap">
    SELECT
        a.id,
        a.applyer,
        a.apply_time,
        a.effe_time,
        a.effe_days,
        emr_dictionary.Name apply_type,
        a.apply_reason,
        a.inpatient_no,
        a.admiss_times,
        a.dis_date,
        a.approve_notes,
        a.patient_id,
    CASE WHEN effe_time  &lt;= GETDATE() THEN '已过期' WHEN apply_state='1' THEN '未提交' WHEN apply_state='2' THEN '已提交' END apply_state,
        a.approver,
        a.approve_time,
    CASE WHEN effe_time  &lt;= GETDATE() THEN '已过期' WHEN approve_state = '1' THEN '审核通过' WHEN approve_state='2' THEN '审核不通过' WHEN approve_state is null THEN '待审批'  WHEN approve_state = '' THEN '待审批' END approve_state,
        c.name,
        CASE WHEN emr_lock.id is null THEN 0 ELSE 1 END lockStatus
    FROM
        emr_apply_approve a
    LEFT JOIN
        commomtable c
    ON
        a.patient_id = c.patient_id
    LEFT JOIN
        (select code,Name from emr_dictionary where parent_id = 'apply_type') emr_dictionary
    ON
        a.apply_type = emr_dictionary.code
    LEFT JOIN
        emr_lock
    ON
        a.patient_id = emr_lock.patient_id
    AND emr_lock.lock_state = 1
    <where>
        <if test="userIds != '' and userIds != null">
            a.applyer IN (${userIds})
        </if>
        <if test="record.applyer != '' and record.applyer != null">
          AND a.applyer LIKE '%${record.applyer}%'
        </if>
        <if test="record.approver != '' and record.approver != null">
          AND a.approver IN (${record.approver})
        </if>
        <if test="record.effeDays != '' and record.effeDays != null">
          AND a.effe_days = ${record.effeDays}
        </if>
        <if test="record.inpatientNo != '' and record.inpatientNo != null">
          AND a.inpatient_no LIKE '%${record.inpatientNo}%'
        </if>
        <if test="startTime1 != '' and startTime1 != null">
          AND a.apply_time &gt;=  #{startTime1}
          <if test="endTime1 != '' and endTime1 != null">
            AND a.apply_time  &lt;= #{endTime1}
          </if>
        </if>
        <if test="startTime2 != '' and startTime2 != null">
          AND a.approve_time &gt;=  #{startTime2}
          <if test="endTime2 != '' and endTime2 != null">
            AND a.approve_time  &lt;= #{endTime2}
          </if>
        </if>
        <if test="record.name != '' and record.name != null">
          AND c.name LIKE '%${record.name}%'
        </if>
        <if test="record.applyType != '' and record.applyType != null">
          AND a.apply_type = ${record.applyType}
        </if>
        <if test="record.applyState != '' and record.applyState != null">
          AND (CASE WHEN effe_time  &lt;= GETDATE() THEN '已过期' WHEN apply_state='1' THEN '未提交' WHEN apply_state='2' THEN '已提交' END) = #{record.applyState}
        </if>
        <if test="record.approveState != '' and record.approveState != null">
          AND (CASE WHEN effe_time  &lt;= GETDATE() THEN '已过期' WHEN approve_state = '1' THEN '审核通过' WHEN approve_state='2' THEN '审核不通过' WHEN approve_state is null THEN '待审批' WHEN approve_state = '' THEN '待审批'  END) = #{record.approveState}
        </if>
    </where>
    ORDER BY a.apply_time DESC
  </select>

  <!--根据id查询包括患者姓名的申请对象-->
  <select id="selectApproveById" resultMap="BaseResultMap">
    SELECT
        emr_apply_approve.id,
        emr_apply_approve.applyer,
        emr_apply_approve.effe_time,
        emr_apply_approve.effe_days,
        emr_apply_approve.apply_type,
        emr_apply_approve.apply_reason,
        emr_apply_approve.inpatient_no,
        emr_apply_approve.admiss_times,
        emr_apply_approve.approve_notes,
        commomtable.name,
        commomtable.dis_date,
        c.parent_id reasonParentId,
        d.parent_id annoParentId
    FROM
        emr_apply_approve
    LEFT JOIN
        commomtable
    ON
        emr_apply_approve.patient_id = commomtable.patient_id
    LEFT JOIN
		(SELECT
          a.parent_id,
          a.content
      FROM
          emr_reason_anno_model a
      LEFT JOIN
          emr_reason_anno_model b
      ON
          a.parent_id = b.id
      WHERE
          a.type_flag is null
      AND
          a.creater = #{creater}
	  ) c
	ON
		c.content = emr_apply_approve.apply_reason
		LEFT JOIN
		(SELECT
          a.parent_id,
          a.content
      FROM
          emr_reason_anno_model a
      LEFT JOIN
          emr_reason_anno_model b
      ON
          a.parent_id = b.id
      WHERE
          a.type_flag is null
      AND
          a.creater = #{creater}
	  ) d
	ON
		d.content = emr_apply_approve.approve_notes
    WHERE
        emr_apply_approve.id = #{id}
  </select>
    <!--根据申请者查询集合-->
    <select id="selectAllByIds" resultMap="BaseResultMap">
        SELECT
        a.id,
        a.applyer,
        a.apply_time,
        a.effe_time,
        a.effe_days,
        emr_dictionary.Name apply_type,
        a.apply_reason,
        a.inpatient_no,
        a.admiss_times,
        a.approve_notes,
        CASE WHEN effe_time  &lt;= GETDATE() THEN '已过期' WHEN apply_state=1 THEN '未提交' WHEN apply_state=2 THEN '已提交' END apply_state,
        a.approver,
        a.approve_time,
        CASE WHEN effe_time  &lt;= GETDATE() THEN '已过期' WHEN approve_state = 1 THEN '审核通过' WHEN approve_state=2 THEN '审核不通过' WHEN approve_state is null THEN '待审批' WHEN approve_state = '' THEN '待审批' END approve_state,
        c.name,
        CASE WHEN emr_lock.id is null THEN 0 ELSE 1 END lockStatus
        FROM
        emr_apply_approve a
        LEFT JOIN
        commomtable c
        ON
        a.patient_id = c.patient_id
        LEFT JOIN
        (select code,Name from emr_dictionary where parent_id = (select id from emr_dictionary where typeCode = 'apply_type')) emr_dictionary
        ON
        a.apply_type = emr_dictionary.code
        LEFT JOIN
        emr_lock
        ON
        a.patient_id = emr_lock.patient_id
        AND emr_lock.lock_state = 1
        <where>
            a.id IN (${checks})
        </where>
    </select>


    <!--批量插入-->
    <insert id="SimpleInsert" parameterType="java.util.List">
        INSERT INTO
        emr_apply_approve(
          applyer, apply_time, effe_time, effe_days, apply_type, apply_reason, apply_state,
    approver, approve_time, approve_state, approve_notes, patient_id, admiss_id, inpatient_no,
    admiss_times, dis_date
        )
          <foreach collection="list" item="item" separator="union">
             select  #{item.applyer,jdbcType=NVARCHAR}, #{item.applyTime,jdbcType=NCHAR},
              #{item.effeTime,jdbcType=NCHAR}, #{item.effeDays,jdbcType=INTEGER}, #{item.applyType,jdbcType=NVARCHAR},
              #{item.applyReason,jdbcType=NVARCHAR}, #{item.applyState,jdbcType=NVARCHAR}, #{item.approver,jdbcType=NVARCHAR},
              #{item.approveTime,jdbcType=NCHAR}, #{item.approveState,jdbcType=NVARCHAR}, #{item.approveNotes,jdbcType=NVARCHAR},
              #{item.patientId,jdbcType=VARCHAR}, #{item.admissId,jdbcType=CHAR}, #{item.inpatientNo,jdbcType=CHAR},
              #{item.admissTimes,jdbcType=SMALLINT}, #{item.disDate,jdbcType=TIMESTAMP}
          </foreach>
    </insert>
    <!--查询未过期且审核通过-->
    <select id="selectIsPowerByUser" resultType="java.lang.Integer">
        SELECT
            COUNT(1)
        FROM emr_apply_approve
        where approve_state = 1
        AND effe_time > GETDATE()
        AND applyer = #{userName}
        AND patient_id = #{patientId}
        <choose>
            <when test="applyType != null and applyType == 3">
                AND apply_type = 3
            </when>
            <otherwise>
                AND apply_type != 3
            </otherwise>
        </choose>
    </select>
    <!--批量更新-->
    <update id="SimpleUpdate">
        update emr_apply_approve
        <set >
            <if test="record.applyer != null" >
                applyer = #{record.applyer,jdbcType=NVARCHAR},
            </if>
            <if test="record.applyTime != null" >
                apply_time = #{record.applyTime,jdbcType=NCHAR},
            </if>
            <if test="record.effeTime != null" >
                effe_time = #{record.effeTime,jdbcType=NCHAR},
            </if>
            <if test="record.effeDays != null" >
                effe_days = #{record.effeDays,jdbcType=INTEGER},
            </if>
            <if test="record.applyType != null" >
                apply_type = #{record.applyType,jdbcType=NVARCHAR},
            </if>
            <if test="record.applyReason != null" >
                apply_reason = #{record.applyReason,jdbcType=NVARCHAR},
            </if>
            <if test="record.applyState != null" >
                apply_state = #{record.applyState,jdbcType=NVARCHAR},
            </if>
            <if test="record.approver != null" >
                approver = #{record.approver,jdbcType=NVARCHAR},
            </if>
            <if test="record.approveTime != null" >
                approve_time = #{record.approveTime,jdbcType=NCHAR},
            </if>
            <if test="record.approveState != null" >
                approve_state = #{record.approveState,jdbcType=NVARCHAR},
            </if>
            <if test="record.approveNotes != null" >
                approve_notes = #{record.approveNotes,jdbcType=NVARCHAR},
            </if>
            <if test="record.patientId != null" >
                patient_id = #{record.patientId,jdbcType=VARCHAR},
            </if>
            <if test="record.admissId != null" >
                admiss_id = #{record.admissId,jdbcType=CHAR},
            </if>
            <if test="record.inpatientNo != null" >
                inpatient_no = #{record.inpatientNo,jdbcType=CHAR},
            </if>
            <if test="record.admissTimes != null" >
                admiss_times = #{record.admissTimes,jdbcType=SMALLINT},
            </if>
            <if test="record.disDate != null" >
                dis_date = #{record.disDate,jdbcType=TIMESTAMP},
            </if>
        </set>
        where id in (${idsStr})
    </update>
</mapper>