diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/dto/HomeStatisticsDto.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/dto/HomeStatisticsDto.java index fbea3b94f..9e8b35173 100755 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/dto/HomeStatisticsDto.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/dto/HomeStatisticsDto.java @@ -79,4 +79,19 @@ public class HomeStatisticsDto { * 待写病历数量 */ private Integer pendingEmr; -} + + /** + * 今日处方数量 + */ + private Integer todayPrescriptions; + + /** + * 昨日处方数量 + */ + private Integer yesterdayPrescriptions; + + /** + * 处方相对前日变化百分比 + */ + private Double prescriptionTrend; +} \ No newline at end of file diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/service/impl/HomeStatisticsServiceImpl.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/service/impl/HomeStatisticsServiceImpl.java index 59b984222..acc67f090 100755 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/service/impl/HomeStatisticsServiceImpl.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/service/impl/HomeStatisticsServiceImpl.java @@ -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 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); + } + /** * 查询指定日期的收款总额(状态为支付成功且未全部退款) * diff --git a/openhis-ui-vue3/src/views/index.vue b/openhis-ui-vue3/src/views/index.vue index bf2e021eb..6bcdf01b2 100755 --- a/openhis-ui-vue3/src/views/index.vue +++ b/openhis-ui-vue3/src/views/index.vue @@ -1,4 +1,4 @@ -