|
@@ -1,13 +1,19 @@
|
|
|
package org.dromara.web.mapper;
|
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
|
|
|
import org.apache.ibatis.annotations.Select;
|
|
|
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
|
|
import org.dromara.web.domain.PatientMedicalRecord;
|
|
|
import org.dromara.web.domain.vo.PatientMedicalRecordVo;
|
|
|
+import org.dromara.web.domain.vo.indexData.FocusPatientVo;
|
|
|
+import org.dromara.web.domain.vo.indexData.IncomeDetailsVo;
|
|
|
import org.dromara.web.domain.vo.indexData.PatientOverviewVo;
|
|
|
import org.springframework.stereotype.Repository;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
/**
|
|
|
* 【请填写功能名称】Mapper接口
|
|
|
*
|
|
@@ -33,4 +39,92 @@ public interface PatientMedicalRecordMapper extends BaseMapperPlus<PatientMedica
|
|
|
") latest_rec ON sp.treat_num = latest_rec.treat_num " +
|
|
|
"WHERE sp.del_flag = '0'")
|
|
|
PatientOverviewVo selectCount();
|
|
|
+ @Select("SELECT " +
|
|
|
+ " sp.patient_name AS name, " +
|
|
|
+ " ROUND( " +
|
|
|
+ " CASE " +
|
|
|
+ " WHEN sp.age LIKE '%岁%月' THEN " +
|
|
|
+ " CAST(SUBSTRING_INDEX(sp.age, '岁', 1) AS UNSIGNED) + " +
|
|
|
+ " CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(sp.age, '岁', -1), '月', 1) AS UNSIGNED) / 12.0 " +
|
|
|
+ " WHEN sp.age LIKE '%岁' THEN " +
|
|
|
+ " CAST(SUBSTRING_INDEX(sp.age, '岁', 1) AS UNSIGNED) " +
|
|
|
+ " WHEN sp.age LIKE '%月' THEN " +
|
|
|
+ " CAST(SUBSTRING_INDEX(sp.age, '月', 1) AS UNSIGNED) / 12.0 " +
|
|
|
+ " ELSE " +
|
|
|
+ " CAST(sp.age AS UNSIGNED) " +
|
|
|
+ " END " +
|
|
|
+ " ) AS age, " +
|
|
|
+ " sdl.label_name AS disease, " +
|
|
|
+ " nd.medical_order AS reason " +
|
|
|
+ "FROM sys_patient sp " +
|
|
|
+ "INNER JOIN ( " +
|
|
|
+ " SELECT pmr1.* " +
|
|
|
+ " FROM patient_medical_record pmr1 " +
|
|
|
+ " INNER JOIN ( " +
|
|
|
+ " SELECT treat_num, MAX(id) as max_id " +
|
|
|
+ " FROM patient_medical_record " +
|
|
|
+ " WHERE del_flag = '0' " +
|
|
|
+ " AND type = '1' " +
|
|
|
+ " AND treatment_user_status = '0' " +
|
|
|
+ " GROUP BY treat_num " +
|
|
|
+ " ) pmr2 ON pmr1.id = pmr2.max_id " +
|
|
|
+ " WHERE pmr1.del_flag = '0' " +
|
|
|
+ " AND pmr1.type = '1' " +
|
|
|
+ " AND pmr1.treatment_user_status = '0' " +
|
|
|
+ ") latest_pmr ON sp.treat_num = latest_pmr.treat_num " +
|
|
|
+ "LEFT JOIN nutrition_diagnosis nd ON latest_pmr.id = nd.treatment_user_id " +
|
|
|
+ " AND nd.del_flag = '0' " +
|
|
|
+ "LEFT JOIN sys_disease_label sdl ON nd.diagnosis_lable_id = sdl.label_id " +
|
|
|
+ " AND sdl.del_flag = '0' " +
|
|
|
+ "WHERE sp.del_flag = '0' " +
|
|
|
+ "ORDER BY latest_pmr.create_time DESC")
|
|
|
+ List<FocusPatientVo>selectFocusPatients();
|
|
|
+ @InterceptorIgnore(tenantLine = "true")
|
|
|
+ @Select("WITH months AS ( " +
|
|
|
+ " SELECT 1 AS month_num, '1月' AS month_name UNION SELECT 2, '2月' UNION SELECT 3, '3月' UNION SELECT 4, '4月' " +
|
|
|
+ " UNION SELECT 5, '5月' UNION SELECT 6, '6月' UNION SELECT 7, '7月' UNION SELECT 8, '8月' " +
|
|
|
+ " UNION SELECT 9, '9月' UNION SELECT 10, '10月' UNION SELECT 11, '11月' UNION SELECT 12, '12月' " +
|
|
|
+ "), " +
|
|
|
+ "year_months AS ( " +
|
|
|
+ " SELECT " +
|
|
|
+ " m.month_name, " +
|
|
|
+ " CONCAT(YEAR(CURDATE()), '-', LPAD(m.month_num, 2, '0')) AS month_code " +
|
|
|
+ " FROM months m " +
|
|
|
+ "), " +
|
|
|
+ "charge_data AS ( " +
|
|
|
+ " SELECT " +
|
|
|
+ " DATE_FORMAT(cr.create_time, '%m') AS month_num, " +
|
|
|
+ " SUM(CASE " +
|
|
|
+ " WHEN s.charge_type IN ('2', '3', '4') THEN s.receivable_amount " +
|
|
|
+ " ELSE 0 " +
|
|
|
+ " END) AS nutritionProducts, " +
|
|
|
+ " SUM(CASE " +
|
|
|
+ " WHEN s.charge_type = '5' THEN s.receivable_amount " +
|
|
|
+ " ELSE 0 " +
|
|
|
+ " END) AS dietaryIncome, " +
|
|
|
+ " SUM(CASE " +
|
|
|
+ " WHEN s.charge_type = '0' THEN s.receivable_amount " +
|
|
|
+ " ELSE 0 " +
|
|
|
+ " END) AS screeningAssessment, " +
|
|
|
+ " SUM(CASE " +
|
|
|
+ " WHEN s.charge_type IN ('2', '3', '4', '5', '0') THEN s.receivable_amount " +
|
|
|
+ " ELSE 0 " +
|
|
|
+ " END) AS totalCollected " +
|
|
|
+ " FROM charge_record cr " +
|
|
|
+ " INNER JOIN settlement s ON cr.settlement_id = s.id " +
|
|
|
+ " WHERE cr.del_flag = '0' " +
|
|
|
+ " AND s.del_flag = '0' " +
|
|
|
+ " AND YEAR(cr.create_time) = YEAR(CURDATE()) " +
|
|
|
+ " GROUP BY DATE_FORMAT(cr.create_time, '%m') " +
|
|
|
+ ") " +
|
|
|
+ "SELECT " +
|
|
|
+ " ym.month_name AS month, " +
|
|
|
+ " COALESCE(cd.nutritionProducts, 0) AS nutritionProducts, " +
|
|
|
+ " COALESCE(cd.dietaryIncome, 0) AS dietaryIncome, " +
|
|
|
+ " COALESCE(cd.screeningAssessment, 0) AS screeningAssessment, " +
|
|
|
+ " COALESCE(cd.totalCollected, 0) AS totalCollected " +
|
|
|
+ "FROM year_months ym " +
|
|
|
+ "LEFT JOIN charge_data cd ON ym.month_code LIKE CONCAT('%-', LPAD(cd.month_num, 2, '0')) " +
|
|
|
+ "ORDER BY ym.month_code ")
|
|
|
+ List<Map<String, Object>>selectIncomeList();
|
|
|
}
|