feat(web): 患者详情 AI 标签页添加趋势分析+体检方案触发按钮
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { useEffect, useState, useCallback } from 'react';
|
||||
import { useParams, useNavigate } from 'react-router-dom';
|
||||
import { startAnalysis, type AnalysisType } from '../../api/ai/analysisSse';
|
||||
import {
|
||||
Card,
|
||||
Descriptions,
|
||||
@@ -44,6 +45,19 @@ export default function PatientDetail() {
|
||||
const navigate = useNavigate();
|
||||
const [patient, setPatient] = useState<PatientDetailType | null>(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [analysisResult, setAnalysisResult] = useState('');
|
||||
const [analyzing, setAnalyzing] = useState(false);
|
||||
|
||||
const triggerAnalysis = async (type: AnalysisType) => {
|
||||
if (!id) return;
|
||||
setAnalyzing(true);
|
||||
setAnalysisResult('');
|
||||
await startAnalysis(type, { patient_id: id }, {
|
||||
onChunk: (content) => setAnalysisResult(prev => prev + content),
|
||||
onError: (msg) => { message.error(msg); setAnalyzing(false); },
|
||||
onDone: () => { message.success('分析完成'); setAnalyzing(false); },
|
||||
});
|
||||
};
|
||||
const [editModalOpen, setEditModalOpen] = useState(false);
|
||||
const [form] = Form.useForm();
|
||||
const isDark = useThemeMode();
|
||||
@@ -313,7 +327,26 @@ export default function PatientDetail() {
|
||||
{
|
||||
key: 'ai',
|
||||
label: 'AI 建议',
|
||||
children: id ? <AiSuggestionTab patientId={id} /> : null,
|
||||
children: id ? (
|
||||
<Space direction="vertical" style={{ width: '100%' }}>
|
||||
<Space>
|
||||
<AuthButton code="ai.analysis.manage">
|
||||
<Button size="small" loading={analyzing} onClick={() => triggerAnalysis('trends')}>
|
||||
趋势分析
|
||||
</Button>
|
||||
<Button size="small" loading={analyzing} onClick={() => triggerAnalysis('checkup-plan')}>
|
||||
体检方案
|
||||
</Button>
|
||||
</AuthButton>
|
||||
</Space>
|
||||
<AiSuggestionTab patientId={id} />
|
||||
{analysisResult && (
|
||||
<Card title="分析结果" size="small" style={{ marginTop: 8 }}>
|
||||
<div style={{ whiteSpace: 'pre-wrap' }}>{analysisResult}</div>
|
||||
</Card>
|
||||
)}
|
||||
</Space>
|
||||
) : null,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user