feat(home): 添加处方统计数据功能
- 在 HomeStatisticsDto 中新增今日处方、昨日处方和处方趋势字段 - 实现处方数量查询逻辑,支持按日期和医生过滤 - 计算处方数据的日环比变化率 - 更新前端界面以显示处方统计信息 - 配置处方相关的路由映射 - 修正数据绑定逻辑以正确关联处方统计数据
This commit is contained in:
@@ -79,4 +79,19 @@ public class HomeStatisticsDto {
|
||||
* 待写病历数量
|
||||
*/
|
||||
private Integer pendingEmr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 今日处方数量
|
||||
*/
|
||||
private Integer todayPrescriptions;
|
||||
|
||||
/**
|
||||
* 昨日处方数量
|
||||
*/
|
||||
private Integer yesterdayPrescriptions;
|
||||
|
||||
/**
|
||||
* 处方相对前日变化百分比
|
||||
*/
|
||||
private Double prescriptionTrend;
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询指定日期的收款总额(状态为支付成功且未全部退款)
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user