<?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.kcim.dao.mapper.ImportPatientInfoMapper">

    <!-- 可根据自己的需求，是否要使用 -->
    <resultMap type="com.kcim.dao.model.ImportPatientInfo" id="importPatientInfoMap">
        <result property="id" column="id"/>
        <result property="hospId" column="hosp_id"/>
        <result property="computeDate" column="compute_date"/>
        <result property="visitNo" column="visit_no"/>
        <result property="patientNo" column="patient_no"/>
        <result property="name" column="name"/>
        <result property="departmentCode" column="department_code"/>
        <result property="departmentName" column="department_name"/>
        <result property="inpatientWardCode" column="inpatient_ward_code"/>
        <result property="inpatientWardName" column="inpatient_ward_name"/>

        <result property="type" column="type"/>
        <result property="primaryDiagCode" column="primary_diag_code"/>
        <result property="primaryDiagName" column="primary_diag_name"/>
        <result property="secondaryDiagCode" column="secondary_diag_code"/>
        <result property="secondaryDiagName" column="secondary_diag_name"/>
        <result property="primaryOperationCode" column="primary_operation_code"/>
        <result property="primaryOperationName" column="primary_operation_name"/>
        <result property="secondaryOperationCode" column="secondary_operation_code"/>
        <result property="secondaryOperationName" column="secondary_operation_name"/>
        <result property="groupCode" column="group_code"/>
        <result property="groupName" column="group_name"/>
        <result property="clinicalPathwayCode" column="clinical_pathway_code"/>
        <result property="clinicalPathwayName" column="clinical_pathway_name"/>
        <result property="inHospitalTime" column="in_hospital_time"/>
        <result property="outHospitalTime" column="out_hospital_time"/>
        <result property="inHospitalDays" column="in_hospital_days"/>
        <result property="bedDays" column="	bed_days"/>
        <result property="currentBedDays" column="current_bed_days"/>
        <result property="diseaseTypeCode" column="disease_type_code"/>
        <result property="createUser" column="create_user"/>
        <result property="createTime" column="create_time"/>
        <result property="updateUser" column="update_user"/>
        <result property="updateTime" column="update_time"/>
        <result property="deleteUser" column="delete_user"/>
        <result property="deleteTime" column="delete_time"/>
        <result property="delFlag" column="del_flag"/>
    </resultMap>
    <select id="getPatientInfoDepartment" resultType="com.kcim.vo.CommonDepartVo">
        select DISTINCT department_code, department_name
        from import_patient_info
        where compute_date = #{computeDate}
          and hosp_id = #{hospId}
          and type = #{type}
          and del_flag = 0
        <if test="filter != null and filter != ''">
            and (department_name like concat('%',#{filter,jdbcType=VARCHAR},'%') or department_code like concat('%',#{filter,jdbcType=VARCHAR},'%')  )
        </if>
    </select>
    <update id="reducingPatientInfoByFileId">
        update import_patient_info
        set del_flag = 0,delete_time = null,delete_user = null,update_time = #{date},update_user = #{userId}
        where del_flag = 1 and hosp_id = #{hospId} and file_id = #{fileId} and compute_date = #{computeDate}
    </update>

</mapper>