<?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.diagbot.mapper.HomePageMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.diagbot.entity.HomePage">
        <id column="home_page_id" property="homePageId" />
        <result column="hospital_id" property="hospitalId" />
        <result column="behospital_code" property="behospitalCode" />
        <result column="hospital_code" property="hospitalCode" />
        <result column="hospital_name" property="hospitalName" />
        <result column="org_code" property="orgCode" />
        <result column="pay_type" property="payType" />
        <result column="health_card" property="healthCard" />
        <result column="behospital_num" property="behospitalNum" />
        <result column="file_code" property="fileCode" />
        <result column="name" property="name" />
        <result column="sex" property="sex" />
        <result column="birthday" property="birthday" />
        <result column="age" property="age" />
        <result column="age_unit" property="ageUnit" />
        <result column="nationality" property="nationality" />
        <result column="newborn_month" property="newbornMonth" />
        <result column="newborn_day" property="newbornDay" />
        <result column="newborn_weight" property="newbornWeight" />
        <result column="newborn_behospital_weight" property="newbornBehospitalWeight" />
        <result column="born_address" property="bornAddress" />
        <result column="born_place" property="bornPlace" />
        <result column="nation" property="nation" />
        <result column="identity_card_no" property="identityCardNo" />
        <result column="job_type" property="jobType" />
        <result column="marriage" property="marriage" />
        <result column="cur_address" property="curAddress" />
        <result column="cur_phone" property="curPhone" />
        <result column="cur_post_code" property="curPostCode" />
        <result column="residence_address" property="residenceAddress" />
        <result column="residence_post_code" property="residencePostCode" />
        <result column="work_address" property="workAddress" />
        <result column="work_phone" property="workPhone" />
        <result column="work_post_code" property="workPostCode" />
        <result column="contact_name" property="contactName" />
        <result column="contact_relation" property="contactRelation" />
        <result column="contact_address" property="contactAddress" />
        <result column="contact_phone" property="contactPhone" />
        <result column="behospital_way" property="behospitalWay" />
        <result column="behospital_date" property="behospitalDate" />
        <result column="behospital_dept" property="behospitalDept" />
        <result column="behospital_ward" property="behospitalWard" />
        <result column="behospital_bed_id" property="behospitalBedId" />
        <result column="behospital_bed_code" property="behospitalBedCode" />
        <result column="change_dept" property="changeDept" />
        <result column="leave_hospital_date" property="leaveHospitalDate" />
        <result column="leave_hospital_dept" property="leaveHospitalDept" />
        <result column="leave_hospital_ward" property="leaveHospitalWard" />
        <result column="leave_hospital_bed_id" property="leaveHospitalBedId" />
        <result column="leave_hospital_bed_code" property="leaveHospitalBedCode" />
        <result column="behospital_day_num" property="behospitalDayNum" />
        <result property="treatmentType" column="treatment_type"/>
        <result column="outpatient_emr_diagnose" property="outpatientEmrDiagnose" />
        <result property="outpatientEmrChDiagnose" column="outpatient_emr_ch_diagnose"/>
        <result column="outpatient_emr_diagnose_code" property="outpatientEmrDiagnoseCode" />
        <result property="outpatientEmrChDiagnoseCode" column="outpatient_emr_ch_diagnose_code"/>
        <result property="implementationClinicalPathway" column="implementation_clinical_pathway"/>
        <result property="isChineseMedicinePreparation" column="is_chinese_medicine_preparation"/>
        <result property="isChineseDiagnoseEquipment" column="is_chinese_diagnose_equipment"/>
        <result property="isChineseDiagnoseTechnology" column="is_chinese_diagnose_technology"/>
        <result property="dialecticalNursing" column="dialectical_nursing"/>
        <result column="poison_factor" property="poisonFactor" />
        <result column="poison_factor_code" property="poisonFactorCode" />
        <result column="pathology_diagnose" property="pathologyDiagnose" />
        <result column="pathology_diagnose_code" property="pathologyDiagnoseCode" />
        <result column="pathology_diagnose_id" property="pathologyDiagnoseId" />
        <result column="is_med_allergy" property="isMedAllergy" />
        <result column="med_allergy_name" property="medAllergyName" />
        <result column="autopsy" property="autopsy" />
        <result column="blood_type" property="bloodType" />
        <result column="rh" property="rh" />
        <result column="dept_director" property="deptDirector" />
        <result column="director_doctor" property="directorDoctor" />
        <result column="attending_doctor" property="attendingDoctor" />
        <result column="behospital_doctor" property="behospitalDoctor" />
        <result column="response_nurse" property="responseNurse" />
        <result column="study_doctor" property="studyDoctor" />
        <result column="practice_doctor" property="practiceDoctor" />
        <result column="encode_man" property="encodeMan" />
        <result column="home_page_quality" property="homePageQuality" />
        <result column="qc_doctor" property="qcDoctor" />
        <result column="qc_nurse" property="qcNurse" />
        <result column="qc_date" property="qcDate" />
        <result column="leave_hospital_type" property="leaveHospitalType" />
        <result column="accept_org_code" property="acceptOrgCode" />
        <result column="again_behospital_plan" property="againBehospitalPlan" />
        <result column="again_behospital_goal" property="againBehospitalGoal" />
        <result column="tbi_before_day" property="tbiBeforeDay" />
        <result column="tbi_before_hour" property="tbiBeforeHour" />
        <result column="tbi_before_minute" property="tbiBeforeMinute" />
        <result column="tbi_after_day" property="tbiAfterDay" />
        <result column="tbi_after_hour" property="tbiAfterHour" />
        <result column="tbi_after_minute" property="tbiAfterMinute" />
        <result column="total_fee" property="totalFee" />
        <result column="own_fee" property="ownFee" />
        <result column="general_fee" property="generalFee" />
        <result column="service_fee" property="serviceFee" />
        <result column="nurse_fee" property="nurseFee" />
        <result column="other_fee" property="otherFee" />
        <result column="pathology_fee" property="pathologyFee" />
        <result column="lab_fee" property="labFee" />
        <result column="pacs_fee" property="pacsFee" />
        <result column="clinic_diagnose_fee" property="clinicDiagnoseFee" />
        <result column="not_operation_fee" property="notOperationFee" />
        <result column="clinic_physic_fee" property="clinicPhysicFee" />
        <result column="operation_treat_fee" property="operationTreatFee" />
        <result column="anaesthesia_fee" property="anaesthesiaFee" />
        <result column="operation_fee" property="operationFee" />
        <result column="health_type_fee" property="healthTypeFee" />
        <result column="chn_treat_fee" property="chnTreatFee" />
        <result column="western_med_fee" property="westernMedFee" />
        <result column="antibiosis_fee" property="antibiosisFee" />
        <result column="chn_med_fee" property="chnMedFee" />
        <result column="chn_herb_fee" property="chnHerbFee" />
        <result column="blood_fee" property="bloodFee" />
        <result column="albumen_fee" property="albumenFee" />
        <result column="globulin_fee" property="globulinFee" />
        <result column="blood_factor_fee" property="bloodFactorFee" />
        <result column="cell_factor_fee" property="cellFactorFee" />
        <result column="check_material_fee" property="checkMaterialFee" />
        <result column="treat_material_fee" property="treatMaterialFee" />
        <result column="operation_material_fee" property="operationMaterialFee" />
        <result column="other_type_fee" property="otherTypeFee" />
        <result column="single_diag_manage" property="singleDiagManage" />
        <result column="clinic_pathway_manage" property="clinicPathwayManage" />
        <result column="is_outpatient_behospital" property="isOutpatientBehospital" />
        <result column="is_leave_behospital" property="isLeaveBehospital" />
        <result column="is_operation_before_after" property="isOperationBeforeAfter" />
        <result column="is_clinic_pathology" property="isClinicPathology" />
        <result column="is_radiate_pathology" property="isRadiatePathology" />
        <result column="rescue_num" property="rescueNum" />
        <result column="rescue_success_num" property="rescueSuccessNum" />
        <result column="is_auto_leavehospital" property="isAutoLeavehospital" />
        <result column="return_to_type" property="returnToType" />
        <result column="is_deleted" property="isDeleted" />
        <result column="gmt_create" property="gmtCreate" />
        <result column="gmt_modified" property="gmtModified" />
        <result column="creator" property="creator" />
        <result column="modifier" property="modifier" />
        <result column="is_physical_restraint" property="isPhysicalRestraint" />
        <result column="tbi_behospital_before_time" property="tbiBehospitalBeforeTime" />
        <result column="tbi_behospital_after_time" property="tbiBehospitalAfterTime" />
        <result column="is_fall_bed" property="isFallBed" />
        <result column="is_nosocomial_infection" property="isNosocomialInfection" />
        <result column="is_into_icu" property="isIntoIcu" />
        <result column="is_complications" property="isComplications" />
        <result column="is_pressure_sore" property="isPressureSore" />
        <result column="is_behospital_pressure_sore" property="isBehospitalPressureSore" />
        <result column="is_unplanned_reoperation" property="isUnplannedReoperation" />
        <result column="treatment_results" property="treatmentResults" />
        <result column="complications_results" property="complicationsResults" />
        <result column="infection_site" property="infectionSite" />
        <result column="is_be_in_danger" property="isBeInDanger" />
    </resultMap>


    <!-- 按科室统计平均住院天数 -->
    <select id="getAverageDayNum"  parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.AverageStatisticsDTO">
        SELECT
        a.beh_dept_id as id,
        a.beh_dept_name as name,
        count(*) AS num,
        round( sum( CAST(b.behospital_day_num AS DECIMAL ( 18, 2 ) ))/ count(*), 2 ) AS averageValue,
        round( sum( CAST(b.behospital_day_num AS DECIMAL ( 18, 2 ) )), 2 ) AS totleValue
        FROM
        med_behospital_info a,
        med_home_page b
        WHERE
        a.hospital_id = b.hospital_id
        AND a.behospital_code = b.behospital_code
        AND a.is_deleted = 'N'
        AND b.is_deleted = 'N'
        <if test="isPlacefile != null and isPlacefile != ''">
            and a.is_placefile = #{isPlacefile}
        </if>
        <![CDATA[AND a.qc_type_id <>0 ]]>
        <if test="hospitalId != null and hospitalId != ''">
            AND a.hospital_id = #{hospitalId}
        </if>
        <if test="startDate != null and startDate != ''">
            <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
        </if>
        <if test="endDate != null and endDate != ''">
            <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
        </if>
        GROUP BY
        a.beh_dept_id,
        a.beh_dept_name
    </select>

    <!-- 按科室统计平均费用 -->
    <select id="getAverageFee"  parameterType="com.diagbot.vo.FilterVO"  resultType="com.diagbot.dto.AverageStatisticsDTO">
        SELECT
        a.beh_dept_id as id,
        a.beh_dept_name as name,
        count(*) AS num,
        round( sum( CAST(b.total_fee AS DECIMAL ( 18, 2 ) ))/ count(*), 2 ) AS averageValue,
        round( sum( CAST(b.total_fee AS DECIMAL ( 18, 2 ) )), 2 ) AS totleValue
        FROM
        med_behospital_info a,
        med_home_page b
        WHERE
        a.hospital_id = b.hospital_id
        AND a.behospital_code = b.behospital_code
        AND a.is_deleted = 'N'
        AND b.is_deleted = 'N'
        <if test="isPlacefile != null and isPlacefile != ''">
            and a.is_placefile = #{isPlacefile}
        </if>
        <![CDATA[AND a.qc_type_id <>0 ]]>
        <if test="hospitalId != null and hospitalId != ''">
            AND a.hospital_id = #{hospitalId}
        </if>
        <if test="startDate != null and startDate != ''">
            <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
        </if>
        <if test="endDate != null and endDate != ''">
            <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
        </if>
        GROUP BY
        a.beh_dept_id,
        a.beh_dept_name
    </select>

    <!-- 按科室统计平均住院天数 （分页）-->
    <select id="getAverageDayNumPage" resultType="com.diagbot.dto.AverageStatisticsDTO">
        SELECT t1.*
        FROM
        (SELECT
        t.id,
        t.NAME,
        sum( t.averageValue ) AS averageValue,
        sum( t.lastAverageValue ) AS lastAverageValue,
        sum( t.lastYearAverageValue ) AS lastYearAverageValue
        FROM
        (
        (
        SELECT
        a.beh_dept_id AS id,
        a.beh_dept_name AS NAME,
        count(*) AS num,
        round( sum( CAST( b.behospital_day_num AS DECIMAL ( 18, 2 ) ))/ count(*), 2 ) AS averageValue,
        0 AS lastAverageValue,
        0 AS lastYearAverageValue
        FROM
        med_behospital_info a,
        med_home_page b
        WHERE
        a.hospital_id = b.hospital_id
        AND a.behospital_code = b.behospital_code
        AND a.is_deleted = 'N'
        AND b.is_deleted = 'N'
        <if test="filterPageByAverageVO.isPlacefile != null and filterPageByAverageVO.isPlacefile != ''">
            and a.is_placefile = #{filterPageByAverageVO.isPlacefile}
        </if>
        <![CDATA[AND a.qc_type_id <>0 ]]>
        <if test="filterPageByAverageVO.hospitalId != null and filterPageByAverageVO.hospitalId != ''">
            AND a.hospital_id = #{filterPageByAverageVO.hospitalId}
        </if>
        <if test="filterPageByAverageVO.startDate != null and filterPageByAverageVO.startDate != ''">
            <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageByAverageVO.startDate})]]>
        </if>
        <if test="filterPageByAverageVO.endDate != null and filterPageByAverageVO.endDate != ''">
            <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageByAverageVO.endDate})]]>
        </if>
        <if test="filterPageByAverageVO.name != null and filterPageByAverageVO.name != ''">
            AND a.beh_dept_name like CONCAT('%', #{filterPageByAverageVO.name},'%')
        </if>
        GROUP BY
        a.beh_dept_id,
        a.beh_dept_name
        ) UNION
        (
        SELECT
        a.beh_dept_id AS id,
        a.beh_dept_name AS NAME,
        count(*) AS num,
        0 AS averageValue,
        round( sum( CAST( b.behospital_day_num AS DECIMAL ( 18, 2 ) ))/ count(*), 2 ) AS lastAverageValue,
        0 AS lastYearAverageValue
        FROM
        med_behospital_info a,
        med_home_page b
        WHERE
        a.hospital_id = b.hospital_id
        AND a.behospital_code = b.behospital_code
        AND a.is_deleted = 'N'
        AND b.is_deleted = 'N'
        <if test="filterPageByAverageVO.isPlacefile != null and filterPageByAverageVO.isPlacefile != ''">
            and a.is_placefile = #{filterPageByAverageVO.isPlacefile}
        </if>
        <![CDATA[AND a.qc_type_id <>0 ]]>
        <if test="filterPageByAverageVO.hospitalId != null and filterPageByAverageVO.hospitalId != ''">
            AND a.hospital_id = #{filterPageByAverageVO.hospitalId}
        </if>
        <if test="filterPageByAverageVO.lastStartDate != null and filterPageByAverageVO.lastStartDate != ''">
            <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageByAverageVO.lastStartDate})]]>
        </if>
        <if test="filterPageByAverageVO.lastEndDate != null and filterPageByAverageVO.lastEndDate != ''">
            <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageByAverageVO.lastEndDate})]]>
        </if>
        <if test="filterPageByAverageVO.name != null and filterPageByAverageVO.name != ''">
            AND a.beh_dept_name like CONCAT('%', #{filterPageByAverageVO.name},'%')
        </if>
        GROUP BY
        a.beh_dept_id,
        a.beh_dept_name
        ) UNION
        (
        SELECT
        a.beh_dept_id AS id,
        a.beh_dept_name AS NAME,
        count(*) AS num,
        0 AS averageValue,
        0 AS lastAverageValue,
        round( sum( CAST( b.behospital_day_num AS DECIMAL ( 18, 2 ) ))/ count(*), 2 ) AS lastYearAverageValue
        FROM
        med_behospital_info a,
        med_home_page b
        WHERE
        a.hospital_id = b.hospital_id
        AND a.behospital_code = b.behospital_code
        AND a.is_deleted = 'N'
        AND b.is_deleted = 'N'
        <if test="filterPageByAverageVO.isPlacefile != null and filterPageByAverageVO.isPlacefile != ''">
            and a.is_placefile = #{filterPageByAverageVO.isPlacefile}
        </if>
        <![CDATA[AND a.qc_type_id <>0 ]]>
        <if test="filterPageByAverageVO.hospitalId != null and filterPageByAverageVO.hospitalId != ''">
            AND a.hospital_id = #{filterPageByAverageVO.hospitalId}
        </if>
        <if test="filterPageByAverageVO.lastYearStartDate != null and filterPageByAverageVO.lastYearStartDate != ''">
            <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageByAverageVO.lastYearStartDate})]]>
        </if>
        <if test="filterPageByAverageVO.lastYearEndDate != null and filterPageByAverageVO.lastYearEndDate != ''">
            <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageByAverageVO.lastYearEndDate})]]>
        </if>
        <if test="filterPageByAverageVO.name != null and filterPageByAverageVO.name != ''">
            AND a.beh_dept_name like CONCAT('%', #{filterPageByAverageVO.name},'%')
        </if>
        GROUP BY
        a.beh_dept_id,
        a.beh_dept_name
        )
        ) t
        GROUP BY
        t.id,
        t.NAME
        ORDER BY
        t.averageValue DESC,
        t.lastAverageValue DESC,
        t.lastYearAverageValue DESC)
        t1
    </select>

    <!-- 按科室统计平均费用（分页） -->
    <select id="getAverageFeePage"   resultType="com.diagbot.dto.AverageStatisticsFeeDTO">
        SELECT t1.*
        FROM
        (SELECT
        t.id,
        t.NAME,
        sum( t.averageValue ) AS averageValue,
        sum( t.lastAverageValue ) AS lastAverageValue,
        sum( t.lastYearAverageValue ) AS lastYearAverageValue
        FROM
        (
        (
        SELECT
        a.beh_dept_id AS id,
        a.beh_dept_name AS NAME,
        count(*) AS num,
        round( sum( CAST( b.total_fee AS DECIMAL ( 18, 2 ) ))/ count(*), 2 ) AS averageValue,
        0 AS lastAverageValue,
        0 AS lastYearAverageValue
        FROM
        med_behospital_info a,
        med_home_page b
        WHERE
        a.hospital_id = b.hospital_id
        AND a.behospital_code = b.behospital_code
        AND a.is_deleted = 'N'
        AND b.is_deleted = 'N'
        <if test="filterPageByAverageVO.isPlacefile != null and filterPageByAverageVO.isPlacefile != ''">
            and a.is_placefile = #{filterPageByAverageVO.isPlacefile}
        </if>
        <![CDATA[AND a.qc_type_id <>0 ]]>
        <if test="filterPageByAverageVO.hospitalId != null and filterPageByAverageVO.hospitalId != ''">
            AND a.hospital_id = #{filterPageByAverageVO.hospitalId}
        </if>
        <if test="filterPageByAverageVO.startDate != null and filterPageByAverageVO.startDate != ''">
            <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageByAverageVO.startDate})]]>
        </if>
        <if test="filterPageByAverageVO.endDate != null and filterPageByAverageVO.endDate != ''">
            <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageByAverageVO.endDate})]]>
        </if>
        <if test="filterPageByAverageVO.name != null and filterPageByAverageVO.name != ''">
            AND a.beh_dept_name like CONCAT('%', #{filterPageByAverageVO.name},'%')
        </if>
        GROUP BY
        a.beh_dept_id,
        a.beh_dept_name
        ) UNION
        (
        SELECT
        a.beh_dept_id AS id,
        a.beh_dept_name AS NAME,
        count(*) AS num,
        0 AS averageValue,
        round( sum( CAST( b.total_fee AS DECIMAL ( 18, 2 ) ))/ count(*), 2 ) AS lastAverageValue,
        0 AS lastYearAverageValue
        FROM
        med_behospital_info a,
        med_home_page b
        WHERE
        a.hospital_id = b.hospital_id
        AND a.behospital_code = b.behospital_code
        AND a.is_deleted = 'N'
        AND b.is_deleted = 'N'
        <if test="filterPageByAverageVO.isPlacefile != null and filterPageByAverageVO.isPlacefile != ''">
            and a.is_placefile = #{filterPageByAverageVO.isPlacefile}
        </if>
        <![CDATA[AND a.qc_type_id <>0 ]]>
        <if test="filterPageByAverageVO.hospitalId != null and filterPageByAverageVO.hospitalId != ''">
            AND a.hospital_id = #{filterPageByAverageVO.hospitalId}
        </if>
        <if test="filterPageByAverageVO.lastStartDate != null and filterPageByAverageVO.lastStartDate != ''">
            <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageByAverageVO.lastStartDate})]]>
        </if>
        <if test="filterPageByAverageVO.lastEndDate != null and filterPageByAverageVO.lastEndDate != ''">
            <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageByAverageVO.lastEndDate})]]>
        </if>
        <if test="filterPageByAverageVO.name != null and filterPageByAverageVO.name != ''">
            AND a.beh_dept_name like CONCAT('%', #{filterPageByAverageVO.name},'%')
        </if>
        GROUP BY
        a.beh_dept_id,
        a.beh_dept_name
        ) UNION
        (
        SELECT
        a.beh_dept_id AS id,
        a.beh_dept_name AS NAME,
        count(*) AS num,
        0 AS averageValue,
        0 AS lastAverageValue,
        round( sum( CAST( b.total_fee AS DECIMAL ( 18, 2 ) ))/ count(*), 2 ) AS lastYearAverageValue
        FROM
        med_behospital_info a,
        med_home_page b
        WHERE
        a.hospital_id = b.hospital_id
        AND a.behospital_code = b.behospital_code
        AND a.is_deleted = 'N'
        AND b.is_deleted = 'N'
        <if test="filterPageByAverageVO.isPlacefile != null and filterPageByAverageVO.isPlacefile != ''">
            and a.is_placefile = #{filterPageByAverageVO.isPlacefile}
        </if>
        <![CDATA[AND a.qc_type_id <>0 ]]>
        <if test="filterPageByAverageVO.hospitalId != null and filterPageByAverageVO.hospitalId != ''">
            AND a.hospital_id = #{filterPageByAverageVO.hospitalId}
        </if>
        <if test="filterPageByAverageVO.lastYearStartDate != null and filterPageByAverageVO.lastYearStartDate != ''">
            <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageByAverageVO.lastYearStartDate})]]>
        </if>
        <if test="filterPageByAverageVO.lastYearEndDate != null and filterPageByAverageVO.lastYearEndDate != ''">
            <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageByAverageVO.lastYearEndDate})]]>
        </if>
        <if test="filterPageByAverageVO.name != null and filterPageByAverageVO.name != ''">
            AND a.beh_dept_name like CONCAT('%', #{filterPageByAverageVO.name},'%')
        </if>
        GROUP BY
        a.beh_dept_id,
        a.beh_dept_name
        )
        ) t
        GROUP BY
        t.id,
        t.NAME
        ORDER BY
        t.averageValue DESC,
        t.lastAverageValue DESC,
        t.lastYearAverageValue DESC)
        t1
    </select>

    <update id="updateBatchByKey">
        <foreach collection="list" item="item"  separator=";">
            update med_home_page
            <set>
                <if test="item.hospitalCode != null">
                    hospital_code = #{item.hospitalCode},
                </if>
                <if test="item.hospitalName != null">
                    hospital_name = #{item.hospitalName},
                </if>
                <if test="item.orgCode != null">
                    org_code = #{item.orgCode},
                </if>
                <if test="item.payType != null">
                    pay_type = #{item.payType},
                </if>
                <if test="item.healthCard != null">
                    health_card = #{item.healthCard},
                </if>
                <if test="item.behospitalNum != null">
                    behospital_num = #{item.behospitalNum},
                </if>
                <if test="item.fileCode != null">
                    file_code = #{item.fileCode},
                </if>
                <if test="item.name != null">
                    name = #{item.name},
                </if>
                <if test="item.sex != null">
                    sex = #{item.sex},
                </if>
                <if test="item.birthday != null">
                    birthday = #{item.birthday},
                </if>
                <if test="item.age != null">
                    age = #{item.age},
                </if>
                <if test="item.ageUnit != null">
                    age_unit = #{item.ageUnit},
                </if>
                <if test="item.nationality != null">
                    nationality = #{item.nationality},
                </if>
                <if test="item.newbornMonth != null">
                    newborn_month = #{item.newbornMonth},
                </if>
                <if test="item.newbornDay != null">
                    newborn_day = #{item.newbornDay},
                </if>
                <if test="item.newbornWeight != null">
                    newborn_weight = #{item.newbornWeight},
                </if>
                <if test="item.newbornBehospitalWeight != null">
                    newborn_behospital_weight = #{item.newbornBehospitalWeight},
                </if>
                <if test="item.bornAddress != null">
                    born_address = #{item.bornAddress},
                </if>
                <if test="item.bornPlace != null">
                    born_place = #{item.bornPlace},
                </if>
                <if test="item.nation != null">
                    nation = #{item.nation},
                </if>
                <if test="item.identityCardNo != null">
                    identity_card_no = #{item.identityCardNo},
                </if>
                <if test="item.jobType != null">
                    job_type = #{item.jobType},
                </if>
                <if test="item.marriage != null">
                    marriage = #{item.marriage},
                </if>
                <if test="item.curAddress != null">
                    cur_address = #{item.curAddress},
                </if>
                <if test="item.curPhone != null">
                    cur_phone = #{item.curPhone},
                </if>
                <if test="item.curPostCode != null">
                    cur_post_code = #{item.curPostCode},
                </if>
                <if test="item.residenceAddress != null">
                    residence_address = #{item.residenceAddress},
                </if>
                <if test="item.residencePostCode != null">
                    residence_post_code = #{item.residencePostCode},
                </if>
                <if test="item.workAddress != null">
                    work_address = #{item.workAddress},
                </if>
                <if test="item.workPhone != null">
                    work_phone = #{item.workPhone},
                </if>
                <if test="item.workPostCode != null">
                    work_post_code = #{item.workPostCode},
                </if>
                <if test="item.contactName != null">
                    contact_name = #{item.contactName},
                </if>
                <if test="item.contactRelation != null">
                    contact_relation = #{item.contactRelation},
                </if>
                <if test="item.contactAddress != null">
                    contact_address = #{item.contactAddress},
                </if>
                <if test="item.contactPhone != null">
                    contact_phone = #{item.contactPhone},
                </if>
                <if test="item.behospitalWay != null">
                    behospital_way = #{item.behospitalWay},
                </if>
                <if test="item.behospitalDate != null">
                    behospital_date = #{item.behospitalDate},
                </if>
                <if test="item.behospitalDept != null">
                    behospital_dept = #{item.behospitalDept},
                </if>
                <if test="item.behospitalWard != null">
                    behospital_ward = #{item.behospitalWard},
                </if>
                <if test="item.behospitalBedId != null">
                    behospital_bed_id = #{item.behospitalBedId},
                </if>
                <if test="item.behospitalBedCode != null">
                    behospital_bed_code = #{item.behospitalBedCode},
                </if>
                <if test="item.changeDept != null">
                    change_dept = #{item.changeDept},
                </if>
                <if test="item.leaveHospitalDate != null">
                    leave_hospital_date = #{item.leaveHospitalDate},
                </if>
                <if test="item.leaveHospitalDept != null">
                    leave_hospital_dept = #{item.leaveHospitalDept},
                </if>
                <if test="item.leaveHospitalWard != null">
                    leave_hospital_ward = #{item.leaveHospitalWard},
                </if>
                <if test="item.leaveHospitalBedId != null">
                    leave_hospital_bed_id = #{item.leaveHospitalBedId},
                </if>
                <if test="item.leaveHospitalBedCode != null">
                    leave_hospital_bed_code = #{item.leaveHospitalBedCode},
                </if>
                <if test="item.behospitalDayNum != null">
                    behospital_day_num = #{item.behospitalDayNum},
                </if>
                <if test="item.outpatientEmrDiagnose != null">
                    outpatient_emr_diagnose = #{item.outpatientEmrDiagnose},
                </if>
                <if test="item.outpatientEmrDiagnoseCode != null">
                    outpatient_emr_diagnose_code = #{item.outpatientEmrDiagnoseCode},
                </if>
                <if test="item.poisonFactor != null">
                    poison_factor = #{item.poisonFactor},
                </if>
                <if test="item.poisonFactorCode != null">
                    poison_factor_code = #{item.poisonFactorCode},
                </if>
                <if test="item.pathologyDiagnose != null">
                    pathology_diagnose = #{item.pathologyDiagnose},
                </if>
                <if test="item.pathologyDiagnoseCode != null">
                    pathology_diagnose_code = #{item.pathologyDiagnoseCode},
                </if>
                <if test="item.pathologyDiagnoseId != null">
                    pathology_diagnose_id = #{item.pathologyDiagnoseId},
                </if>
                <if test="item.isMedAllergy != null">
                    is_med_allergy = #{item.isMedAllergy},
                </if>
                <if test="item.medAllergyName != null">
                    med_allergy_name = #{item.medAllergyName},
                </if>
                <if test="item.autopsy != null">
                    autopsy = #{item.autopsy},
                </if>
                <if test="item.bloodType != null">
                    blood_type = #{item.bloodType},
                </if>
                <if test="item.rh != null">
                    rh = #{item.rh},
                </if>
                <if test="item.deptDirector != null">
                    dept_director = #{item.deptDirector},
                </if>
                <if test="item.directorDoctor != null">
                    director_doctor = #{item.directorDoctor},
                </if>
                <if test="item.attendingDoctor != null">
                    attending_doctor = #{item.attendingDoctor},
                </if>
                <if test="item.behospitalDoctor != null">
                    behospital_doctor = #{item.behospitalDoctor},
                </if>
                <if test="item.responseNurse != null">
                    response_nurse = #{item.responseNurse},
                </if>
                <if test="item.studyDoctor != null">
                    study_doctor = #{item.studyDoctor},
                </if>
                <if test="item.practiceDoctor != null">
                    practice_doctor = #{item.practiceDoctor},
                </if>
                <if test="item.encodeMan != null">
                    encode_man = #{item.encodeMan},
                </if>
                <if test="item.homePageQuality != null">
                    home_page_quality = #{item.homePageQuality},
                </if>
                <if test="item.qcDoctor != null">
                    qc_doctor = #{item.qcDoctor},
                </if>
                <if test="item.qcNurse != null">
                    qc_nurse = #{item.qcNurse},
                </if>
                <if test="item.qcDate != null">
                    qc_date = #{item.qcDate},
                </if>
                <if test="item.leaveHospitalType != null">
                    leave_hospital_type = #{item.leaveHospitalType},
                </if>
                <if test="item.acceptOrgCode != null">
                    accept_org_code = #{item.acceptOrgCode},
                </if>
                <if test="item.againBehospitalPlan != null">
                    again_behospital_plan = #{item.againBehospitalPlan},
                </if>
                <if test="item.againBehospitalGoal != null">
                    again_behospital_goal = #{item.againBehospitalGoal},
                </if>
                <if test="item.tbiBeforeDay != null">
                    tbi_before_day = #{item.tbiBeforeDay},
                </if>
                <if test="item.tbiBeforeHour != null">
                    tbi_before_hour = #{item.tbiBeforeHour},
                </if>
                <if test="item.tbiBeforeMinute != null">
                    tbi_before_minute = #{item.tbiBeforeMinute},
                </if>
                <if test="item.tbiAfterDay != null">
                    tbi_after_day = #{item.tbiAfterDay},
                </if>
                <if test="item.tbiAfterHour != null">
                    tbi_after_hour = #{item.tbiAfterHour},
                </if>
                <if test="item.tbiAfterMinute != null">
                    tbi_after_minute = #{item.tbiAfterMinute},
                </if>
                <if test="item.totalFee != null">
                    total_fee = #{item.totalFee},
                </if>
                <if test="item.ownFee != null">
                    own_fee = #{item.ownFee},
                </if>
                <if test="item.generalFee != null">
                    general_fee = #{item.generalFee},
                </if>
                <if test="item.serviceFee != null">
                    service_fee = #{item.serviceFee},
                </if>
                <if test="item.nurseFee != null">
                    nurse_fee = #{item.nurseFee},
                </if>
                <if test="item.otherFee != null">
                    other_fee = #{item.otherFee},
                </if>
                <if test="item.pathologyFee != null">
                    pathology_fee = #{item.pathologyFee},
                </if>
                <if test="item.labFee != null">
                    lab_fee = #{item.labFee},
                </if>
                <if test="item.pacsFee != null">
                    pacs_fee = #{item.pacsFee},
                </if>
                <if test="item.clinicDiagnoseFee != null">
                    clinic_diagnose_fee = #{item.clinicDiagnoseFee},
                </if>
                <if test="item.notOperationFee != null">
                    not_operation_fee = #{item.notOperationFee},
                </if>
                <if test="item.clinicPhysicFee != null">
                    clinic_physic_fee = #{item.clinicPhysicFee},
                </if>
                <if test="item.operationTreatFee != null">
                    operation_treat_fee = #{item.operationTreatFee},
                </if>
                <if test="item.anaesthesiaFee != null">
                    anaesthesia_fee = #{item.anaesthesiaFee},
                </if>
                <if test="item.operationFee != null">
                    operation_fee = #{item.operationFee},
                </if>
                <if test="item.healthTypeFee != null">
                    health_type_fee = #{item.healthTypeFee},
                </if>
                <if test="item.chnTreatFee != null">
                    chn_treat_fee = #{item.chnTreatFee},
                </if>
                <if test="item.westernMedFee != null">
                    western_med_fee = #{item.westernMedFee},
                </if>
                <if test="item.antibiosisFee != null">
                    antibiosis_fee = #{item.antibiosisFee},
                </if>
                <if test="item.chnMedFee != null">
                    chn_med_fee = #{item.chnMedFee},
                </if>
                <if test="item.chnHerbFee != null">
                    chn_herb_fee = #{item.chnHerbFee},
                </if>
                <if test="item.bloodFee != null">
                    blood_fee = #{item.bloodFee},
                </if>
                <if test="item.albumenFee != null">
                    albumen_fee = #{item.albumenFee},
                </if>
                <if test="item.globulinFee != null">
                    globulin_fee = #{item.globulinFee},
                </if>
                <if test="item.bloodFactorFee != null">
                    blood_factor_fee = #{item.bloodFactorFee},
                </if>
                <if test="item.cellFactorFee != null">
                    cell_factor_fee = #{item.cellFactorFee},
                </if>
                <if test="item.checkMaterialFee != null">
                    check_material_fee = #{item.checkMaterialFee},
                </if>
                <if test="item.treatMaterialFee != null">
                    treat_material_fee = #{item.treatMaterialFee},
                </if>
                <if test="item.operationMaterialFee != null">
                    operation_material_fee = #{item.operationMaterialFee},
                </if>
                <if test="item.otherTypeFee != null">
                    other_type_fee = #{item.otherTypeFee},
                </if>
                <if test="item.singleDiagManage != null">
                    single_diag_manage = #{item.singleDiagManage},
                </if>
                <if test="item.clinicPathwayManage != null">
                    clinic_pathway_manage = #{item.clinicPathwayManage},
                </if>
                <if test="item.isOutpatientBehospital != null">
                    is_outpatient_behospital = #{item.isOutpatientBehospital},
                </if>
                <if test="item.isLeaveBehospital != null">
                    is_leave_behospital = #{item.isLeaveBehospital},
                </if>
                <if test="item.isOperationBeforeAfter != null">
                    is_operation_before_after = #{item.isOperationBeforeAfter},
                </if>
                <if test="item.isClinicPathology != null">
                    is_clinic_pathology = #{item.isClinicPathology},
                </if>
                <if test="item.isRadiatePathology != null">
                    is_radiate_pathology = #{item.isRadiatePathology},
                </if>
                <if test="item.rescueNum != null">
                    rescue_num = #{item.rescueNum},
                </if>
                <if test="item.rescueSuccessNum != null">
                    rescue_success_num = #{item.rescueSuccessNum},
                </if>
                <if test="item.isAutoLeavehospital != null">
                    is_auto_leavehospital = #{item.isAutoLeavehospital},
                </if>
                <if test="item.returnToType != null">
                    return_to_type = #{item.returnToType},
                </if>

                <if test="item.gmtModified != null">
                    gmt_modified = #{item.gmtModified},
                </if>
                <if test="item.modifier != null">
                    modifier = #{item.modifier},
                </if>
            </set>
            where home_page_id = #{item.homePageId} and hospital_id = #{item.hospitalId} and behospital_code = #{item.behospitalCode}
        </foreach>
    </update>
</mapper>
