From 5140552ff6e93b4e445b3fd6e641aead560de899 Mon Sep 17 00:00:00 2001 From: iven Date: Mon, 4 May 2026 00:03:40 +0800 Subject: [PATCH] =?UTF-8?q?fix(health):=20=E8=B5=B0=E6=9F=A5=E6=AD=A2?= =?UTF-8?q?=E8=A1=80=20=E2=80=94=20=E6=82=A3=E8=80=85=E5=90=8D=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E4=BF=AE=E5=A4=8D=20+=20=E6=9E=9A=E4=B8=BE=E8=A1=A5?= =?UTF-8?q?=E5=85=A8=20+=20=E5=8C=BB=E6=8A=A4=E7=BB=9F=E8=AE=A1=20+=20?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E9=80=89=E6=8B=A9=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 后端: - alert_service: list_alerts 批量查询 patient_name 填充 AlertResponse - consultation_service: list_sessions 批量查询 patient_name/doctor_name - erp-ai handler: list_analysis 通过 raw SQL 查询 patient_name 前端: - AlertList/AlertDashboard: 使用后端返回的 patient_name 替代 ID 截断 - ConsultationDetail: 使用 patient_name/doctor_name 替代 ID 截断 - AiAnalysisList: 使用 patient_name 替代 ID 截断 - constants/health: SEVERITY 补 high/medium, STATUS 补 active - AdminDashboard: 医护人数改为 API 查询(useStatsData 新增 doctorCount) - DeviceManage: 患者 ID 输入改为 PatientSelect 搜索选择器 --- apps/web/src/api/ai/analysis.ts | 1 + apps/web/src/api/health/alerts.ts | 1 + apps/web/src/constants/health.ts | 9 +++++ apps/web/src/pages/health/AiAnalysisList.tsx | 7 ++-- apps/web/src/pages/health/AlertDashboard.tsx | 2 +- apps/web/src/pages/health/AlertList.tsx | 9 ++--- .../src/pages/health/ConsultationDetail.tsx | 5 ++- apps/web/src/pages/health/DeviceManage.tsx | 15 +++---- .../StatisticsDashboard/AdminDashboard.tsx | 6 +-- .../StatisticsDashboard/useStatsData.ts | 12 +++++- crates/erp-ai/src/handler/mod.rs | 40 ++++++++++++++++++- crates/erp-health/src/dto/alert_dto.rs | 1 + .../erp-health/src/service/alert_service.rs | 39 ++++++++++++++++-- .../src/service/consultation_service.rs | 37 ++++++++++++++++- 14 files changed, 155 insertions(+), 29 deletions(-) diff --git a/apps/web/src/api/ai/analysis.ts b/apps/web/src/api/ai/analysis.ts index 1c4822d..5c7e238 100644 --- a/apps/web/src/api/ai/analysis.ts +++ b/apps/web/src/api/ai/analysis.ts @@ -4,6 +4,7 @@ import type { PaginatedResponse } from '../types'; export interface AnalysisItem { id: string; patient_id: string; + patient_name?: string; analysis_type: string; source_ref: string; model_used: string; diff --git a/apps/web/src/api/health/alerts.ts b/apps/web/src/api/health/alerts.ts index bc8feb7..7c00b2d 100644 --- a/apps/web/src/api/health/alerts.ts +++ b/apps/web/src/api/health/alerts.ts @@ -5,6 +5,7 @@ import type { PaginatedResponse } from '../types'; export interface Alert { id: string; patient_id: string; + patient_name?: string; rule_id: string; severity: string; title: string; diff --git a/apps/web/src/constants/health.ts b/apps/web/src/constants/health.ts index 6b017d2..80543ea 100644 --- a/apps/web/src/constants/health.ts +++ b/apps/web/src/constants/health.ts @@ -40,6 +40,8 @@ export const SEVERITY_COLOR: Record = { warning: 'orange', critical: 'red', urgent: 'magenta', + high: 'red', + medium: 'orange', }; export const SEVERITY_LABEL: Record = { @@ -47,18 +49,23 @@ export const SEVERITY_LABEL: Record = { warning: '警告', critical: '严重', urgent: '紧急', + high: '严重', + medium: '中等', }; export const SEVERITY_OPTIONS = [ { value: 'info', label: '提示' }, { value: 'warning', label: '警告' }, + { value: 'medium', label: '中等' }, { value: 'critical', label: '严重' }, + { value: 'high', label: '严重' }, { value: 'urgent', label: '紧急' }, ]; // --- 告警状态(统一 3 处: AlertDashboard, AlertList) --- export const ALERT_STATUS_COLOR: Record = { pending: 'orange', + active: 'gold', acknowledged: 'blue', resolved: 'green', dismissed: 'default', @@ -66,6 +73,7 @@ export const ALERT_STATUS_COLOR: Record = { export const ALERT_STATUS_LABEL: Record = { pending: '待处理', + active: '活跃', acknowledged: '已确认', resolved: '已恢复', dismissed: '已忽略', @@ -73,6 +81,7 @@ export const ALERT_STATUS_LABEL: Record = { export const ALERT_STATUS_OPTIONS = [ { value: '', label: '全部状态' }, + { value: 'active', label: '活跃' }, { value: 'pending', label: '待处理' }, { value: 'acknowledged', label: '已确认' }, { value: 'resolved', label: '已恢复' }, diff --git a/apps/web/src/pages/health/AiAnalysisList.tsx b/apps/web/src/pages/health/AiAnalysisList.tsx index 12be95e..d93861c 100644 --- a/apps/web/src/pages/health/AiAnalysisList.tsx +++ b/apps/web/src/pages/health/AiAnalysisList.tsx @@ -11,6 +11,7 @@ import { import { useThemeMode } from '../../hooks/useThemeMode'; import { analysisApi, type AnalysisItem } from '../../api/ai/analysis'; import { suggestionApi, type SuggestionItem } from '../../api/ai/suggestions'; +import { EntityName } from '../../components/EntityName'; const { Text } = Typography; @@ -321,9 +322,9 @@ export default function AiAnalysisList() { dataIndex: 'patient_id', key: 'patient_id', width: 140, - render: (v: string) => ( - - {v.slice(0, 8)} + render: (_: unknown, record: AnalysisItem) => ( + + ), }, diff --git a/apps/web/src/pages/health/AlertDashboard.tsx b/apps/web/src/pages/health/AlertDashboard.tsx index 4e78338..330a8ac 100644 --- a/apps/web/src/pages/health/AlertDashboard.tsx +++ b/apps/web/src/pages/health/AlertDashboard.tsx @@ -245,7 +245,7 @@ export default function AlertDashboard() { } description={ - 患者: + 患者: {' · '} {new Date(alert.created_at).toLocaleString('zh-CN')} diff --git a/apps/web/src/pages/health/AlertList.tsx b/apps/web/src/pages/health/AlertList.tsx index af6c447..5882c1a 100644 --- a/apps/web/src/pages/health/AlertList.tsx +++ b/apps/web/src/pages/health/AlertList.tsx @@ -137,12 +137,11 @@ export default function AlertList() { dataIndex: 'patient_id', key: 'patient_id', width: 140, - render: (id: string) => ( - + render: (_: unknown, record: Alert) => ( + 8 ? id.slice(0, 8) + '...' : id} + name={record.patient_name} + id={record.patient_id} /> ), diff --git a/apps/web/src/pages/health/ConsultationDetail.tsx b/apps/web/src/pages/health/ConsultationDetail.tsx index 2bb73a4..059f71a 100644 --- a/apps/web/src/pages/health/ConsultationDetail.tsx +++ b/apps/web/src/pages/health/ConsultationDetail.tsx @@ -7,6 +7,7 @@ import { StatusTag } from './components/StatusTag'; import { ImagePreview } from './components/ImagePreview'; import { useThemeMode } from '../../hooks/useThemeMode'; import { AuthButton } from '../../components/AuthButton'; +import { EntityName } from '../../components/EntityName'; const PAGE_SIZE = 30; const POLL_INTERVAL = 10_000; @@ -297,10 +298,10 @@ export default function ConsultationDetail() { {session && ( <> - 患者: {session.patient_id.slice(0, 8)} + 患者: - 医护: {session.doctor_id ? session.doctor_id.slice(0, 8) : '-'} + 医护: diff --git a/apps/web/src/pages/health/DeviceManage.tsx b/apps/web/src/pages/health/DeviceManage.tsx index 7ba0fa8..041b59c 100644 --- a/apps/web/src/pages/health/DeviceManage.tsx +++ b/apps/web/src/pages/health/DeviceManage.tsx @@ -5,6 +5,7 @@ import dayjs from 'dayjs'; import { deviceApi, type DeviceItem } from '../../api/health/devices'; import { DEVICE_TYPE_OPTIONS, DEVICE_TYPE_COLOR } from '../../constants/health'; +import { PatientSelect } from './components/PatientSelect'; function formatTime(val?: string | null): string { if (!val) return '-'; @@ -109,13 +110,13 @@ export default function DeviceManage() {

设备管理

- setFilterPatientId(e.target.value)} - style={{ width: 200 }} - allowClear - /> +
+ setFilterPatientId(val || '')} + placeholder="搜索患者" + /> +