<?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.MedIndexResultMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.diagbot.entity.MedIndexResult">
        <id column="id" property="id" />
        <result column="admission_result" property="admissionResult" />
        <result column="operation_result" property="operationResult" />
        <result column="leave_hospital_result" property="leaveHospitalResult" />
        <result column="med_home_result" property="medHomeResult" />
        <result column="ct_result" property="ctResult" />
        <result column="mri_result" property="mriResult" />
        <result column="pathology_result" property="pathologyResult" />
        <result column="germ_result" property="germResult" />
        <result column="antibiosis_result" property="antibiosisResult" />
        <result column="tumor_chemistry_result" property="tumorChemistryResult" />
        <result column="tumor_radiation_result" property="tumorRadiationResult" />
        <result column="operation_complete_result" property="operationCompleteResult" />
        <result column="implants_result" property="implantsResult" />
        <result column="blood_result" property="bloodResult" />
        <result column="ward_round_result" property="wardRoundResult" />
        <result column="rescue_result" property="rescueResult" />
        <result column="sec_file_result" property="secFileResult" />
        <result column="file_complete_result" property="fileCompleteResult" />
        <result column="no_copy_result" property="noCopyResult" />
        <result column="record_sign_result" property="recordSignResult" />
        <result column="fir_record_result" property="firRecordResult" />
        <result column="start_date" property="startDate" />
        <result column="end_date" property="endDate" />
        <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="medicalRecordIndicator" parameterType="com.diagbot.vo.FilterVO" resultType="java.util.Map">
         SELECT
            COALESCE (sum(a.admission_result), 0) AS 'startCount',
            COALESCE (sum(a.operation_result), 0) AS 'operationFeeNum',
            COALESCE (sum(a.ct_result), 0) AS 'CTNum',
            COALESCE (sum(a.mri_result), 0) AS 'MRNum',
            COALESCE (sum(a.pathology_result), 0) AS 'operationPathologyFeeNum',
            COALESCE (sum(a.germ_result), 0) AS 'bacterialCultureNum',
            COALESCE (sum(a.antibiosis_result), 0) AS 'antibiosisFeeNum',
            COALESCE (sum(a.tumor_chemistry_result),0) AS 'chemotherapyMalignantTumorsNum',
            COALESCE (sum(a.tumor_radiation_result),0) AS 'tumor_radiation_result',
            COALESCE (sum(a.implants_result), 0) AS 'implantsResult',
            COALESCE (sum(a.blood_result), 0) AS 'bloodResult',
            COALESCE (sum(a.rescue_result), 0) AS 'rescueResult',
            COALESCE (sum(a.sec_file_result), 0) AS 'secFileResult',
            COALESCE (sum(a.file_complete_result), 0) AS 'fileCompleteResult',
            COALESCE (sum(a.tumor_radiation_result), 0) AS 'tumorRadiationResult'

        FROM
            med_index_result a
        WHERE
            a.hospital_id = #{filterVO.hospitalId}
        AND a.is_deleted = 'N'
        AND (a.start_date BETWEEN #{filterVO.startDate} AND #{filterVO.endDate} )
        AND (a.end_date BETWEEN #{filterVO.startDate} AND #{filterVO.endDate} )
 </select>

</mapper>
