|
|
@@ -4,18 +4,35 @@
|
|
|
|
|
|
<select id="departmentStatistics"
|
|
|
resultType="org.jeecg.modules.medical.common.bo.ReportAfterQueryResponseBO">
|
|
|
+
|
|
|
SELECT
|
|
|
- m.id
|
|
|
- ,m.medical_dept_name
|
|
|
- ,m.medical_dept_code
|
|
|
- ,(SELECT count(*) from sys_user_depart where dep_id = (SELECT id from sys_depart where medical_dept_code = m.medical_dept_code)) as deptDoctorTotal -- 科室医生总数
|
|
|
- ,(select count(*) from ( SELECT count(doctor_id) from afterwards_audit_detail WHERE medical_dept_code = m.medical_dept_code GROUP BY doctor_id) as t ) as violationDoctorNumber -- 违规医生总数
|
|
|
- ,COUNT(id) as violationTotal
|
|
|
- ,(select IFNULL(sum(amount), 0) from afterwards_audit_detail WHERE medical_dept_code = m.medical_dept_code and treatment_type = '2') as outpatientsErrorAmount -- 门诊违规金额
|
|
|
- ,(select IFNULL(sum(amount),0) from afterwards_audit_detail WHERE medical_dept_code = m.medical_dept_code and treatment_type = '1') as hospErrorAmount -- 住院违规金额
|
|
|
- ,ifnull( sum(amount), 0) as errorAmountTotal -- 异常金额总和
|
|
|
- FROM afterwards_audit_detail as m
|
|
|
+ m.id,
|
|
|
+ m.medical_dept_name,
|
|
|
+ m.medical_dept_code,
|
|
|
+ IFNULL(sd.deptDoctorTotal, 0) AS deptDoctorTotal,
|
|
|
+ COUNT(DISTINCT t.doctor_id) AS violationDoctorNumber,
|
|
|
+ COUNT(m.id) AS violationTotal,
|
|
|
+ IFNULL(SUM(CASE WHEN m.treatment_type = '2' THEN m.amount ELSE 0 END), 0) AS outpatientsErrorAmount,
|
|
|
+ IFNULL(SUM(CASE WHEN m.treatment_type = '1' THEN m.amount ELSE 0 END), 0) AS hospErrorAmount,
|
|
|
+ IFNULL(SUM(m.amount), 0) AS errorAmountTotal
|
|
|
+ FROM afterwards_audit_detail AS m
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT dep.id AS department_id, COUNT(user_dep.id) AS deptDoctorTotal
|
|
|
+ FROM sys_depart AS dep
|
|
|
+ LEFT JOIN sys_user_depart AS user_dep ON dep.id = user_dep.dep_id
|
|
|
+ GROUP BY dep.id
|
|
|
+ ) AS sd ON sd.department_id = (
|
|
|
+ SELECT id
|
|
|
+ FROM sys_depart
|
|
|
+ WHERE medical_dept_code = m.medical_dept_code
|
|
|
+ )
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT medical_dept_code, doctor_id
|
|
|
+ FROM afterwards_audit_detail
|
|
|
+ GROUP BY medical_dept_code, doctor_id
|
|
|
+ ) AS t ON m.medical_dept_code = t.medical_dept_code
|
|
|
<where>
|
|
|
+ 1=1
|
|
|
<if test="ew.medicalDeptName != null and ew.medicalDeptName != ''">
|
|
|
AND medical_dept_name like concat(concat('%',#{ew.medicalDeptName}),'%')
|
|
|
</if>
|
|
|
@@ -26,8 +43,11 @@
|
|
|
AND <![CDATA[ create_time <= #{ew.endTime,jdbcType=VARCHAR} ]]>
|
|
|
</if>
|
|
|
</where>
|
|
|
- GROUP BY medical_dept_code
|
|
|
- ORDER BY violationDoctorNumber DESC
|
|
|
+ GROUP BY m.medical_dept_code
|
|
|
+ ORDER BY violationDoctorNumber DESC;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
</select>
|
|
|
|
|
|
<select id="departmentDetailStatistics"
|
|
|
@@ -61,6 +81,9 @@
|
|
|
<if test="ew.treatmentType != null and ew.treatmentType != '' ">
|
|
|
AND treatment_type = #{ew.treatmentType}
|
|
|
</if>
|
|
|
+ <if test="ew.medicalDeptCode != null and ew.medicalDeptCode != '' ">
|
|
|
+ AND medical_dept_code = #{ew.medicalDeptCode}
|
|
|
+ </if>
|
|
|
<if test="ew.medicalInsRuleInfoCode != null and ew.medicalInsRuleInfoCode != '' ">
|
|
|
AND medical_ins_rule_info_code = #{ew.medicalInsRuleInfoCode}
|
|
|
</if>
|
|
|
@@ -288,6 +311,7 @@
|
|
|
select ifnull(sum(amount), 0) as totalAmount
|
|
|
FROM afterwards_audit_detail
|
|
|
<where>
|
|
|
+ 1=1
|
|
|
<if test="ew.medicalProjectSearch != null and ew.medicalProjectSearch != '' ">
|
|
|
AND (
|
|
|
medical_project_code LIKE concat(concat('%',#{ew.medicalProjectSearch}),'%')
|
|
|
@@ -295,6 +319,9 @@
|
|
|
medical_project_name LIKE concat(concat('%',#{ew.medicalProjectSearch}),'%')
|
|
|
)
|
|
|
</if>
|
|
|
+ <if test="ew.medicalDeptCode != null and ew.medicalDeptCode != '' ">
|
|
|
+ AND medical_dept_code = #{ew.medicalDeptCode}
|
|
|
+ </if>
|
|
|
<if test="ew.treatmentType != null and ew.treatmentType != '' ">
|
|
|
AND treatment_type = #{ew.treatmentType}
|
|
|
</if>
|