123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618 |
- <?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 column="outpatient_emr_diagnose" property="outpatientEmrDiagnose" />
- <result column="outpatient_emr_diagnose_code" property="outpatientEmrDiagnoseCode" />
- <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" />
- </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 ))/ count(*), 2 ) AS averageValue,
- round( sum( CAST(b.behospital_day_num AS DECIMAL )), 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'
- <![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 ))/ count(*), 2 ) AS averageValue,
- round( sum( CAST(b.total_fee AS DECIMAL )), 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'
- <![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
- id,
- NAME,
- averageValue,
- lastAverageValue,
- lastYearAverageValue
- FROM
- (
- SELECT
- dept.id,
- dept.NAME,
- t1.averageValue,
- t2.lastAverageValue,
- t3.lastYearAverageValue
- FROM
- (
- SELECT DISTINCT
- id,
- NAME
- FROM
- (
- (
- SELECT DISTINCT
- a.beh_dept_id AS id,
- a.beh_dept_name AS NAME
- 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'
- <![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>
- ) UNION
- (
- SELECT DISTINCT
- a.beh_dept_id AS id,
- a.beh_dept_name AS NAME
- 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'
- <![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>
- ) UNION
- (
- SELECT DISTINCT
- a.beh_dept_id AS id,
- a.beh_dept_name AS NAME
- 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'
- <![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>
- ))dept1
- ) dept
- LEFT JOIN (
- 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 ))/ count(*), 2 ) AS averageValue,
- round( sum( CAST( b.behospital_day_num AS DECIMAL )), 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'
- <![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
- ) t1 ON dept.id = t1.id
- AND dept.NAME = t1.
- NAME LEFT JOIN (
- 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 ))/ count(*), 2 ) AS lastAverageValue,
- round( sum( CAST( b.behospital_day_num AS DECIMAL )), 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'
- <![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
- ) t2 ON dept.id = t2.id
- AND dept.NAME = t2.
- NAME LEFT JOIN (
- 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 ))/ count(*), 2 ) AS lastYearAverageValue,
- round( sum( CAST( b.behospital_day_num AS DECIMAL )), 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'
- <![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
- ) t3 ON dept.id = t3.id
- AND dept.NAME = t3.NAME
- ORDER BY
- t1.averageValue DESC,
- t2.lastAverageValue DESC,
- t3.lastYearAverageValue DESC
- )t
- </select>
- <!-- 按科室统计平均费用(分页) -->
- <select id="getAverageFeePage" resultType="com.diagbot.dto.AverageStatisticsDTO">
- SELECT
- id,
- NAME,
- averageValue,
- lastAverageValue,
- lastYearAverageValue
- FROM
- (
- SELECT
- dept.id,
- dept.NAME,
- t1.averageValue,
- t2.lastAverageValue,
- t3.lastYearAverageValue
- FROM
- (
- SELECT DISTINCT
- id,
- NAME
- FROM
- (
- (
- SELECT DISTINCT
- a.beh_dept_id AS id,
- a.beh_dept_name AS NAME
- 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'
- <![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>
- ) UNION
- (
- SELECT DISTINCT
- a.beh_dept_id AS id,
- a.beh_dept_name AS NAME
- 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'
- <![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>
- ) UNION
- (
- SELECT DISTINCT
- a.beh_dept_id AS id,
- a.beh_dept_name AS NAME
- 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'
- <![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>
- ))dept1
- ) dept
- LEFT JOIN (
- SELECT
- a.beh_dept_id AS id,
- a.beh_dept_name AS NAME,
- count(*) AS num,
- round( sum( CAST( b.total_fee AS DECIMAL ))/ count(*), 2 ) AS averageValue,
- round( sum( CAST( b.total_fee AS DECIMAL )), 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'
- <![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
- ) t1 ON dept.id = t1.id
- AND dept.NAME = t1.
- NAME LEFT JOIN (
- SELECT
- a.beh_dept_id AS id,
- a.beh_dept_name AS NAME,
- count(*) AS num,
- round( sum( CAST( b.total_fee AS DECIMAL ))/ count(*), 2 ) AS lastAverageValue,
- round( sum( CAST( b.total_fee AS DECIMAL )), 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'
- <![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
- ) t2 ON dept.id = t2.id
- AND dept.NAME = t2.
- NAME LEFT JOIN (
- SELECT
- a.beh_dept_id AS id,
- a.beh_dept_name AS NAME,
- count(*) AS num,
- round( sum( CAST( b.total_fee AS DECIMAL ))/ count(*), 2 ) AS lastYearAverageValue,
- round( sum( CAST( b.total_fee AS DECIMAL )), 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'
- <![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
- ) t3 ON dept.id = t3.id
- AND dept.NAME = t3.NAME
- ORDER BY
- t1.averageValue DESC,
- t2.lastAverageValue DESC,
- t3.lastYearAverageValue DESC
- )t
- </select>
- </mapper>
|