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

	<!-- 可根据自己的需求，是否要使用 -->
    <resultMap type="com.kcim.dao.model.Sql" id="sqlMap">
        <result property="id" column="id"/>
        <result property="hospId" column="hosp_id"/>
        <result property="code" column="code"/>
        <result property="sqlCode" column="sql_code"/>
        <result property="sql" column="sql"/>
        <result property="sqlDefinition" column="sql_definition"/>
        <result property="sqlType" column="sql_type"/>
        <result property="sort" column="sort"/>
        <result property="status" column="status"/>
        <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="getMedicalServiceCostDetailList" resultType="com.kcim.vo.HospitalServiceProjectCostVO">
        SELECT
            a.`code` as itemCode,
            a.`name` as itemName ,
            b.cost_type as costTypeCode,
            a.quantity  AS serviceVolume,
            SUM( b.compute_result ) AS hospitalFullCost
        FROM
            compute_project_cost a
                INNER JOIN compute_project_cost_account b ON a.id = b.project_cost_id
                AND b.del_flag = 0
                AND b.hosp_id = #{hospId,jdbcType=BIGINT}
        WHERE
            a.del_flag = 0
          AND a.hosp_id = #{hospId,jdbcType=BIGINT}
          AND a.compute_date = #{computeDate,jdbcType=VARCHAR}
        GROUP BY
            a.`code`,
            b.cost_type
    </select>
</mapper>