feat(home): 添加处方统计数据功能

- 在 HomeStatisticsDto 中新增今日处方、昨日处方和处方趋势字段
- 实现处方数量查询逻辑,支持按日期和医生过滤
- 计算处方数据的日环比变化率
- 更新前端界面以显示处方统计信息
- 配置处方相关的路由映射
- 修正数据绑定逻辑以正确关联处方统计数据
This commit is contained in:
2026-06-02 15:31:37 +08:00
parent e1cb88e47e
commit 6958654d26
3 changed files with 73 additions and 8 deletions

View File

@@ -79,4 +79,19 @@ public class HomeStatisticsDto {
* 待写病历数量
*/
private Integer pendingEmr;
}
/**
* 今日处方数量
*/
private Integer todayPrescriptions;
/**
* 昨日处方数量
*/
private Integer yesterdayPrescriptions;
/**
* 处方相对前日变化百分比
*/
private Double prescriptionTrend;
}

View File

@@ -15,6 +15,8 @@ import com.openhis.common.enums.ParticipantType;
import com.openhis.web.dto.HomeStatisticsDto;
import com.openhis.financial.domain.PaymentReconciliation;
import com.openhis.financial.service.IPaymentReconciliationService;
import com.openhis.medication.domain.MedicationRequest;
import com.openhis.medication.service.IMedicationRequestService;
import com.openhis.common.enums.PaymentStatus;
import com.openhis.web.service.IHomeStatisticsService;
import java.math.BigDecimal;
@@ -56,6 +58,9 @@ public class HomeStatisticsServiceImpl implements IHomeStatisticsService {
@Autowired
private IPaymentReconciliationService paymentReconciliationService;
@Autowired
private IMedicationRequestService medicationRequestService;
/**
* 获取首页统计数据
*
@@ -131,9 +136,49 @@ public class HomeStatisticsServiceImpl implements IHomeStatisticsService {
statistics.setAppointmentTrend(0.0);
statistics.setPendingApprovals(0);
// 查询今日处方数量
int todayPrescriptions = queryPrescriptionCountByDate(new Date(), practitioner);
int yesterdayPrescriptions = queryPrescriptionCountByDate(getYesterday(), practitioner);
statistics.setTodayPrescriptions(todayPrescriptions);
statistics.setYesterdayPrescriptions(yesterdayPrescriptions);
statistics.setPrescriptionTrend(calculateTrend(todayPrescriptions, yesterdayPrescriptions));
return statistics;
}
/**
* 查询指定日期的处方数量
*
* @param date 日期
* @param practitioner 当前医生null 则查全部)
* @return 处方数量
*/
private int queryPrescriptionCountByDate(Date date, Practitioner practitioner) {
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
Date dayStart = cal.getTime();
cal.add(Calendar.DAY_OF_MONTH, 1);
Date dayEnd = cal.getTime();
LambdaQueryWrapper<MedicationRequest> query = new LambdaQueryWrapper<>();
query.ge(MedicationRequest::getCreateTime, dayStart)
.lt(MedicationRequest::getCreateTime, dayEnd)
.eq(MedicationRequest::getDeleteFlag, "0");
// 如果是医生角色,只统计自己开的处方
if (practitioner != null) {
query.eq(MedicationRequest::getPractitionerId, practitioner.getId());
}
return (int) medicationRequestService.count(query);
}
/**
* 查询指定日期的收款总额(状态为支付成功且未全部退款)
*

View File

@@ -1,4 +1,4 @@
<template>
<template>
<div class="home-container">
<!-- 顶部欢迎区域 -->
<div class="welcome-section">
@@ -319,7 +319,10 @@ const statisticsData = ref({
todayAppointments: 0,
yesterdayAppointments: 0,
appointmentTrend: 0,
pendingApprovals: 0
pendingApprovals: 0,
todayPrescriptions: 0,
yesterdayPrescriptions: 0,
prescriptionTrend: 0
})
// 不同角色的统计数据配置
@@ -724,8 +727,8 @@ const currentStats = computed(() => {
statWith.value = statisticsData.value.pendingEmr;
break;
case 'prescriptions':
statWith.value = statisticsData.value.todayAppointments;
statWith.trend = statisticsData.value.appointmentTrend;
statWith.value = statisticsData.value.todayPrescriptions;
statWith.trend = statisticsData.value.prescriptionTrend;
break;
case 'wardPatients':
statWith.value = statisticsData.value.totalPatients;
@@ -743,8 +746,8 @@ const currentStats = computed(() => {
statWith.trend = statisticsData.value.appointmentTrend;
break;
case 'todayPrescriptions':
statWith.value = statisticsData.value.todayAppointments;
statWith.trend = statisticsData.value.appointmentTrend;
statWith.value = statisticsData.value.todayPrescriptions;
statWith.trend = statisticsData.value.prescriptionTrend;
break;
case 'pendingReview':
statWith.value = statisticsData.value.pendingApprovals;
@@ -792,7 +795,9 @@ const handleStatClick = (stat) => {
todayAppointments: '/doctorstation/today-outpatient',
pendingApprovals: '/ybmanagement/ePrescribing',
pendingReview: '/ybmanagement/ePrescribing',
pendingEmr: '/pending-emr'
pendingEmr: '/pending-emr',
prescriptions: '/doctorstation',
todayPrescriptions: '/pharmacyManagement/westernmedicine'
}
const path = routeMap[stat.key]
if (!path) return