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#-5wh=EF&1tl%mJln2V^8o%Qv(*=zEuO7y z=m*8?xpUn-*@h5Cl_3BK3joiGkyaScK+>|MWdMRWm@RT!Q1piAlv5hL@B6>3&GI8) zP!xBc6}ZNIpJLL%2a8Y!+(<=f%WX>_uWVxlga9!D*oYt$l0cxRDMvqfU;Kq_mLK5k z)dvqYcgLa_Lz?3HyeF)@$%$&6lI?r4I>6W#M*<)vq{?& Oqrx``d`mhpVPr> z#q078F6gw_X<=?KR>8%^t%@wbITvNMu!hKiTSkCTJkw>1!e*Y{%31#_yMf=LW7{RJ zYoC^w$6%3cBtVG5)x#{Hg6IVTh9XEcM{gQwXk!R^y95^f-hZ`d{aVa+xW1EO4wDV4 zB?JgD7*?qkvc|$nIykTvNl2x0j3Q!MXoLL^)~}d7jcYf(H8D~c+?$pKL(px>Z3`eb z04RzS6_AgFT6Pn#iZAg$Sl_j8#;6ShF%&(Fag#E2asU@@LaN;=b=Wf7sgPKhfzhBM zC@eFL8^MrnA*9&Khe*Ab@CC9*uyJGXyi(;y2>lQLJZt;ShtJi?3Yf_t `F+$hY!+Q2Ndsx=U+bjTiAy7djLji>7k%k`$9&--f<*BNA3Hy&ZrHH|4 zG5H&9cB?O#zI1_OOf0Ce%mDfQxdtp3vU%(iY6yji3iISS61XLv#z|!zI_sZqza@B+ zyu9st5-h+`H7QUKx9}3w@oU@EO}&cEzG?fu!!bLO->%zkcg;i9^j`S~=WKMnDi1f= P00000NkvXXu0mjft=yBf literal 0 HcmV?d00001 diff --git a/doctor_web/src/assets/react.svg b/doctor_web/src/assets/react.svg new file mode 100644 index 0000000..6c87de9 --- /dev/null +++ b/doctor_web/src/assets/react.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/doctor_web/src/assets/vite.svg b/doctor_web/src/assets/vite.svg new file mode 100644 index 0000000..5101b67 --- /dev/null +++ b/doctor_web/src/assets/vite.svg @@ -0,0 +1 @@ + diff --git a/doctor_web/src/components/layout/DoctorLayout.module.css b/doctor_web/src/components/layout/DoctorLayout.module.css new file mode 100644 index 0000000..1f47a18 --- /dev/null +++ b/doctor_web/src/components/layout/DoctorLayout.module.css @@ -0,0 +1,124 @@ +.layout { + display: flex; + min-height: 100vh; +} + +/* ---- 侧边栏 ---- */ +.sidebar { + width: 224px; + background: #FFF; + border-right: 1px solid #EDF0F7; + display: flex; + flex-direction: column; + flex-shrink: 0; +} + +.brand { + padding: 24px 20px 20px; + border-bottom: 1px solid #EDF0F7; +} + +.brandTitle { + font-size: 18px; + font-weight: 700; + color: #1A1D28; + display: flex; + align-items: center; + gap: 8px; +} + +.brandSub { + font-size: 12px; + color: #9BA0B4; + margin-top: 2px; +} + +.nav { + flex: 1; + padding: 12px 12px; + display: flex; + flex-direction: column; + gap: 2px; +} + +.navItem { + display: flex; + align-items: center; + gap: 12px; + padding: 10px 12px; + border-radius: 10px; + text-decoration: none; + color: #5A6072; + font-size: 14px; + font-weight: 500; + transition: all 0.15s; +} + +.navItem:hover { + background: #F5F6FA; + color: #1A1D28; +} + +.navItem.active { + background: #EDF0FD; + color: #4F6EF7; + font-weight: 600; +} + +.navIcon { + width: 20px; + height: 20px; + display: flex; + align-items: center; + justify-content: center; + font-size: 16px; +} + +.footer { + padding: 16px 20px; + border-top: 1px solid #EDF0F7; + background: #FAFBFD; +} + +.doctorInfo { + display: flex; + align-items: center; + gap: 12px; +} + +.avatar { + width: 40px; + height: 40px; + border-radius: 10px; + background: linear-gradient(135deg, #4F6EF7, #6C8AFF); + display: flex; + align-items: center; + justify-content: center; + color: #FFF; + font-size: 16px; + font-weight: 600; +} + +.doctorName { + font-size: 14px; + font-weight: 600; + color: #1A1D28; +} + +.doctorMeta { + font-size: 12px; + color: #9BA0B4; +} + +/* ---- 内容区 ---- */ +.content { + flex: 1; + background: #F2F5FA; + min-width: 0; + animation: fadeIn 0.25s ease; +} + +@keyframes fadeIn { + from { opacity: 0; transform: translateY(6px); } + to { opacity: 1; transform: translateY(0); } +} diff --git a/doctor_web/src/components/layout/DoctorLayout.tsx b/doctor_web/src/components/layout/DoctorLayout.tsx new file mode 100644 index 0000000..cece26d --- /dev/null +++ b/doctor_web/src/components/layout/DoctorLayout.tsx @@ -0,0 +1,70 @@ +import { NavLink, Outlet, useLocation } from 'react-router-dom'; +import { useEffect, useState } from 'react'; +import { api } from '../../services/api-client'; +import type { DashboardStats } from '../../types'; +import styles from './DoctorLayout.module.css'; + +const NAV_ITEMS = [ + { to: '/dashboard', label: '工作台', icon: '📊' }, + { to: '/patients', label: '患者管理', icon: '👥' }, + { to: '/consultations', label: '在线问诊', icon: '💬' }, + { to: '/reports', label: '报告审核', icon: '📋' }, + { to: '/follow-ups', label: '复查随访', icon: '📅' }, +]; + +export default function DoctorLayout() { + const location = useLocation(); + const [doctor, setDoctor] = useState (null); + + useEffect(() => { + api.get ('/api/doctor/dashboard').then(setDoctor).catch(() => {}); + }, []); + + return ( + + {/* 侧边栏 */} + + + {/* 内容区 */} ++ ); +} diff --git a/doctor_web/src/index.css b/doctor_web/src/index.css new file mode 100644 index 0000000..4a4891c --- /dev/null +++ b/doctor_web/src/index.css @@ -0,0 +1,5 @@ +*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; } +body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif; color: #1A1D28; background: #F2F5FA; -webkit-font-smoothing: antialiased; } +a { text-decoration: none; color: inherit; } +button { cursor: pointer; font-family: inherit; } +input, textarea, select { font-family: inherit; } diff --git a/doctor_web/src/main.tsx b/doctor_web/src/main.tsx new file mode 100644 index 0000000..d9736ad --- /dev/null +++ b/doctor_web/src/main.tsx @@ -0,0 +1,9 @@ +import { StrictMode } from 'react'; +import { createRoot } from 'react-dom/client'; +import App from './App'; + +createRoot(document.getElementById('root')!).render( ++ ++ + , +); diff --git a/doctor_web/src/pages/consultations/ChatPage.tsx b/doctor_web/src/pages/consultations/ChatPage.tsx new file mode 100644 index 0000000..a1b2024 --- /dev/null +++ b/doctor_web/src/pages/consultations/ChatPage.tsx @@ -0,0 +1,167 @@ +import { useEffect, useRef, useState } from 'react'; +import { useParams } from 'react-router-dom'; +import { api } from '../../services/api-client'; +import { getConnection, startConnection } from '../../services/signalr'; +import type { ConsultationMessage } from '../../types'; + +export default function ChatPage() { + const { id } = useParams<{ id: string }>(); + const [messages, setMessages] = useState+ ([]); + const [status, setStatus] = useState(''); + const [text, setText] = useState(''); + const [connected, setConnected] = useState(false); + const bottomRef = useRef (null); + + // 加载历史消息 + useEffect(() => { + if (!id) return; + api.get<{ status: string; messages: ConsultationMessage[] }>(`/api/doctor/consultations/${id}/messages`) + .then(data => { + setMessages(data.messages); + setStatus(data.status); + }) + .catch(() => {}); + }, [id]); + + // 建立 SignalR 连接 + useEffect(() => { + if (!id) return; + let disposed = false; + + (async () => { + try { + const conn = getConnection(); + await startConnection(); + if (disposed) return; + + // 加入问诊房间 + await conn.invoke('JoinConsultation', id); + setConnected(true); + + // 注册消息接收 + const handler = (msg: ConsultationMessage & { consultationId: string }) => { + if (msg.consultationId !== id) return; + setMessages(prev => { + if (prev.some(m => m.id === msg.id)) return prev; // 去重 + return [...prev, msg]; + }); + }; + conn.on('ReceiveMessage', handler); + + // 重连时重新加入房间 + conn.onreconnected(() => { + conn.invoke('JoinConsultation', id); + }); + } catch { /* ignore */ } + })(); + + return () => { + disposed = true; + const conn = getConnection(); + if (conn.state === 'Connected') { + conn.invoke('LeaveConsultation', id).catch(() => {}); + conn.off('ReceiveMessage'); + } + }; + }, [id]); + + // 自动滚到底部 + useEffect(() => { + bottomRef.current?.scrollIntoView({ behavior: 'smooth' }); + }, [messages]); + + async function sendMessage() { + if (!text.trim() || !id) return; + const content = text.trim(); + setText(''); + + // 通过 HTTP 发送(后端会通过 SignalR 广播) + try { + await api.post(`/api/doctor/consultations/${id}/messages`, { content }); + } catch { + // fallback: 直接通过 SignalR 发送 + try { + await getConnection().invoke('SendMessage', id, 'Doctor', '医生 · 王建国', content); + } catch { /* ignore */ } + } + } + + return ( + + {/* 顶栏 */} ++ ); +} diff --git a/doctor_web/src/pages/consultations/ConsultationListPage.tsx b/doctor_web/src/pages/consultations/ConsultationListPage.tsx new file mode 100644 index 0000000..b4dbab6 --- /dev/null +++ b/doctor_web/src/pages/consultations/ConsultationListPage.tsx @@ -0,0 +1,57 @@ +import { useEffect, useState } from 'react'; +import { Link } from 'react-router-dom'; +import { api } from '../../services/api-client'; +import type { Consultation } from '../../types'; + +const STATUS_MAP: Record++ + {/* 消息列表 */} +++问诊对话++ {status === 'AiTalking' ? 'AI 分身对话中' : status === 'WaitingDoctor' ? '等待医生回复' : status === 'DoctorReplied' ? '医生已回复' : status === 'Closed' ? '已结束' : status} +++ + {connected ? '已连接' : '未连接'} +++ {messages.map((msg, i) => { + const isDoctor = msg.senderType === 'Doctor'; + const isAi = msg.senderType === 'Ai'; + return ( ++ + {/* 输入栏 */} ++ {/* 发送者名称 */} + {!isDoctor && msg.senderName && ( ++ ); + })} + +{msg.senderName}+ )} + {/* 气泡 */} ++ {msg.content} ++ {/* AI 标记 */} + {isAi && ( ++ AI 分析,仅供参考 ++ )} + {/* 时间 */} ++ {new Date(msg.createdAt).toLocaleTimeString('zh-CN', { hour: '2-digit', minute: '2-digit' })} +++++ setText(e.target.value)} + onKeyDown={e => e.key === 'Enter' && sendMessage()} + placeholder="输入回复..." + style={{ flex: 1, padding: '12px 18px', border: '1px solid #E1E5ED', borderRadius: 12, fontSize: 15, outline: 'none' }} + /> + ++= { + AiTalking: { label: 'AI 对话中', color: '#9BA0B4' }, + WaitingDoctor: { label: '等待医生', color: '#F59E0B' }, + DoctorReplied: { label: '医生已回复', color: '#20C997' }, + Closed: { label: '已结束', color: '#CCC' }, +}; + +export default function ConsultationListPage() { + const [list, setList] = useState ([]); + + useEffect(() => { + api.get ('/api/doctor/consultations').then(setList).catch(() => {}); + }, []); + + return ( + ++ ); +} diff --git a/doctor_web/src/pages/dashboard/DashboardPage.tsx b/doctor_web/src/pages/dashboard/DashboardPage.tsx new file mode 100644 index 0000000..7b6bf6c --- /dev/null +++ b/doctor_web/src/pages/dashboard/DashboardPage.tsx @@ -0,0 +1,72 @@ +import { useEffect, useState } from 'react'; +import { Link } from 'react-router-dom'; +import { api } from '../../services/api-client'; +import type { DashboardStats } from '../../types'; + +const CARD_CONFIG = [ + { key: 'totalPatients', label: '患者总数', color: '#4F6EF7', bg: '#EDF0FD' }, + { key: 'activeConsultations', label: '进行中问诊', color: '#20C997', bg: '#E6F9F2' }, + { key: 'pendingReports', label: '待审核报告', color: '#F59E0B', bg: '#FFF8E6' }, + { key: 'todayFollowUps', label: '今日随访', color: '#845EF7', bg: '#F3E8FF' }, +]; + +const QUICK_LINKS = [ + { to: '/patients', label: '患者列表', color: '#4F6EF7' }, + { to: '/consultations', label: '在线问诊', color: '#20C997' }, + { to: '/reports', label: '报告审核', color: '#F59E0B' }, + { to: '/follow-ups', label: '随访管理', color: '#845EF7' }, +]; + +export default function DashboardPage() { + const [stats, setStats] = useState在线问诊
+ + {list.length === 0 ? ( +暂无问诊记录+ ) : ( ++ {list.map(c => { + const st = STATUS_MAP[c.status] ?? { label: c.status, color: '#9BA0B4' }; + return ( + ++ )} ++ {(c.patientName || '患')[0]} ++++{c.patientName || c.patientPhone}++ {c.lastMessage?.content?.slice(0, 40) || '暂无消息'} +++ + {st.label} + ++ + ); + })} ++ {new Date(c.createdAt).toLocaleDateString('zh-CN')} ++(null); + + useEffect(() => { + api.get ('/api/doctor/dashboard').then(setStats).catch(() => {}); + }, []); + + if (!stats) return 加载中...; + + return ( ++ {/* 欢迎 */} ++ ); +} diff --git a/doctor_web/src/pages/followups/FollowUpEditPage.tsx b/doctor_web/src/pages/followups/FollowUpEditPage.tsx new file mode 100644 index 0000000..ffa6a21 --- /dev/null +++ b/doctor_web/src/pages/followups/FollowUpEditPage.tsx @@ -0,0 +1,105 @@ +import { useEffect, useState } from 'react'; +import { useParams, useNavigate } from 'react-router-dom'; +import { api } from '../../services/api-client'; + +interface PatientSimple { id: string; name: string; phone: string; } + +export default function FollowUpEditPage() { + const { id } = useParams<{ id: string }>(); + const nav = useNavigate(); + const isEdit = !!id; + + const [patients, setPatients] = useState++ + {/* 统计卡片 */} +欢迎回来,{stats.doctorName}
+{stats.doctorTitle} · {stats.doctorDepartment}
++ {CARD_CONFIG.map(c => ( ++ + {/* 快捷操作 */} ++ ++ ))} +{(stats as any)[c.key]}+{c.label}+++++ +快捷操作
++ {QUICK_LINKS.map(l => ( + + {l.label} + + ))} ++++今日待办
+++📋 待审核报告 {stats.pendingReports} 份+💬 进行中问诊 {stats.activeConsultations} 个+📅 今日随访 {stats.todayFollowUps} 个+([]); + const [userId, setUserId] = useState(''); + const [title, setTitle] = useState(''); + const [scheduledAt, setScheduledAt] = useState(''); + const [notes, setNotes] = useState(''); + const [saving, setSaving] = useState(false); + + useEffect(() => { + // 加载患者列表 + api.get ('/api/doctor/patients-simple').then(setPatients).catch(() => {}); + // 编辑模式:加载现有随访 + if (id) { + api.get (`/api/doctor/follow-ups`).then(list => { + const item = list.find(f => f.id === id); + if (item) { + setUserId(item.userId); + setTitle(item.title); + // datetime-local 格式 + const d = new Date(item.scheduledAt); + setScheduledAt(d.toISOString().slice(0, 16)); + setNotes(item.notes || ''); + } + }).catch(() => {}); + } + }, [id]); + + async function save() { + if (!userId || !title || !scheduledAt) return alert('请填写完整信息'); + setSaving(true); + try { + const body = { userId, title, scheduledAt: new Date(scheduledAt).toISOString(), notes }; + if (isEdit) { + await api.put(`/api/doctor/follow-ups/${id}`, body); + } else { + await api.post('/api/doctor/follow-ups', body); + } + nav('/follow-ups'); + } catch { alert('保存失败'); } + setSaving(false); + } + + return ( + ++ ); +} diff --git a/doctor_web/src/pages/followups/FollowUpListPage.tsx b/doctor_web/src/pages/followups/FollowUpListPage.tsx new file mode 100644 index 0000000..8760a2b --- /dev/null +++ b/doctor_web/src/pages/followups/FollowUpListPage.tsx @@ -0,0 +1,94 @@ +import { useEffect, useState } from 'react'; +import { Link, useNavigate } from 'react-router-dom'; +import { api } from '../../services/api-client'; +import type { FollowUp } from '../../types'; + +const STATUS_MAP: Record+ ++ +{isEdit ? '编辑随访' : '新建随访'}
++ {/* 患者选择 */} +++ + ++ + {/* 标题 */} ++ + setTitle(e.target.value)} placeholder="如:PCI术后1个月随访" + style={{ width: '100%', padding: '10px 14px', border: '1px solid #E1E5ED', borderRadius: 10, fontSize: 14, outline: 'none' }} /> ++ + {/* 时间 */} ++ + setScheduledAt(e.target.value)} + style={{ width: '100%', padding: '10px 14px', border: '1px solid #E1E5ED', borderRadius: 10, fontSize: 14, outline: 'none' }} /> ++ + {/* 备注 */} ++ ++ + += { + Upcoming: { label: '即将到来', color: '#4F6EF7' }, + Completed: { label: '已完成', color: '#20C997' }, + Cancelled: { label: '已取消', color: '#EF4444' }, +}; + +export default function FollowUpListPage() { + const [list, setList] = useState ([]); + const [filter, setFilter] = useState(''); + const nav = useNavigate(); + + useEffect(() => { loadList(); }, [filter]); + + async function loadList() { + const q = filter ? `?status=${filter}` : ''; + try { setList(await api.get (`/api/doctor/follow-ups${q}`)); } catch { setList([]); } + } + + async function deleteItem(id: string) { + if (!confirm('确定删除?')) return; + try { + await api.del(`/api/doctor/follow-ups/${id}`); + setList(prev => prev.filter(f => f.id !== id)); + } catch { alert('删除失败'); } + } + + async function markComplete(id: string) { + try { + await api.put(`/api/doctor/follow-ups/${id}`, { status: 'Completed' }); + loadList(); + } catch { alert('操作失败'); } + } + + return ( + ++ ); +} diff --git a/doctor_web/src/pages/patients/PatientDetailPage.tsx b/doctor_web/src/pages/patients/PatientDetailPage.tsx new file mode 100644 index 0000000..8563137 --- /dev/null +++ b/doctor_web/src/pages/patients/PatientDetailPage.tsx @@ -0,0 +1,273 @@ +import { useEffect, useState } from 'react'; +import { useParams, Link } from 'react-router-dom'; +import { api } from '../../services/api-client'; +import type { PatientDetail, TrendRecord } from '../../types'; +import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, Legend } from 'recharts'; + +const METRIC_LABELS: Record++ + {/* 筛选 */} +复查随访
+ ++ {[{ k: '', l: '全部' }, { k: 'Upcoming', l: '即将到来' }, { k: 'Completed', l: '已完成' }, { k: 'Cancelled', l: '已取消' }].map(t => ( + + ))} ++ + {list.length === 0 ? ( +暂无随访安排+ ) : ( ++ {list.map(f => { + const st = STATUS_MAP[f.status] ?? { label: f.status, color: '#9BA0B4' }; + return ( ++ )} ++ 📅 ++ ); + })} +++ + {st.label} + + {/* 操作按钮 */} +{f.title}++ {f.patientName || '-'} · {new Date(f.scheduledAt).toLocaleString('zh-CN')} ++ {f.notes &&{f.notes}} ++ {f.status === 'Upcoming' && ( + + )} + 编辑 + ++= { + BloodPressure: '血压', HeartRate: '心率', Glucose: '血糖', SpO2: '血氧', Weight: '体重', +}; + +const METRIC_COLORS: Record = { + BloodPressure: '#EF4444', HeartRate: '#F59E0B', Glucose: '#4F6EF7', SpO2: '#20C997', Weight: '#845EF7', +}; + +const DAY_LABELS = ['日', '一', '二', '三', '四', '五', '六']; + +export default function PatientDetailPage() { + const { id } = useParams<{ id: string }>(); + const [data, setData] = useState (null); + const [chartMetric, setChartMetric] = useState ('BloodPressure'); + + useEffect(() => { + if (id) api.get (`/api/doctor/patients/${id}`).then(setData).catch(() => {}); + }, [id]); + + if (!data) return 加载中...; + + const p = data.profile; + const a = data.archive; + + // 趋势图数据(用 any 兼容不同指标的数据结构) + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const chartData: any[] = buildChartData(data.trendRecords, chartMetric); + + return ( ++ {/* 标题 */} ++ ); +} + +// ===== 子组件 ===== + +function InfoCard({ p, a }: { p: PatientDetail['profile']; a: PatientDetail['archive'] }) { + return ( ++ ← 返回列表 ++ + {/* 基本信息卡片 */} +{p.name || '未设置'} 的健康档案
++ + {/* 健康指标 */} + + + + {/* 趋势图 */} ++ {data.latestRecords.map(r => ( +++ ++ ))} + {data.latestRecords.length === 0 &&{METRIC_LABELS[r.metricType] || r.metricType}++ {r.metricType === 'BloodPressure' ? `${r.systolic}/${r.diastolic}` : r.value} + {r.unit} +++ {new Date(r.recordedAt).toLocaleDateString('zh-CN')} ++} + + + + {/* 用药 */} ++ {Object.keys(METRIC_LABELS).map(m => ( + + ))} ++ {chartData.length > 0 ? ( +++ ) :+ ++ ++ + + + + {chartMetric === 'BloodPressure' ? ( + <> + + + > + ) : ( + + )} + } + + {data.medications.length > 0 ? ( + + + {/* 饮食 + 运动 双列 */} ++ {data.medications.map(m => ( ++ ) :+ 💊 ++ ))} +++{m.name} {m.dosage}+{m.frequency} · {m.timeOfDay?.join(', ')}+} + ++ + {/* 报告 */} +++🍽️ 近期饮食+ {data.dietRecords.length > 0 ? ( ++ {data.dietRecords.map(d => ( ++ ) :++ ))} +{d.foods.map(f => f.name).join('、')}++ {d.mealType === 'Breakfast' ? '早餐' : d.mealType === 'Lunch' ? '午餐' : d.mealType === 'Dinner' ? '晚餐' : '加餐'} + {' · '}{d.totalCalories}kcal · 评分 {d.healthScore}/5 ++} + ++🏃 运动计划+ {data.exercisePlan ? ( ++ {data.exercisePlan.items.map((item, i) => ( ++ ) :+ 周{DAY_LABELS[item.dayOfWeek]} + + {item.isRestDay ? '休息' : `${item.exerciseType} ${item.durationMinutes}分钟`} + + {item.isCompleted && ✓ 已完成} ++ ))} +} + + {data.reports.length > 0 ? ( + + + {/* 随访 */} ++ {data.reports.map(r => ( + + 📄 ++ ) :++{r.category} 报告+{new Date(r.createdAt).toLocaleDateString('zh-CN')}++ + ))} + } + + {data.followUps.length > 0 ? ( + ++ {data.followUps.map(f => ( ++ ) :+ 📅 ++ ))} +++{f.title}++ {new Date(f.scheduledAt).toLocaleString('zh-CN')} + {f.doctorName ? ` · ${f.doctorName}` : ''} + {f.notes ? ` · ${f.notes}` : ''} +++ } + ++ ); +} + +function Row({ label, value }: { label: string; value?: string | null }) { + return ( ++++ {p.name?.[0] ?? '?'} ++++{p.name || '未设置'}+{p.phone} · {p.gender || '未知'} · {p.birthDate || '未知'}+ {a && ( +++ )} ++
+
+
+
+
+
+
+ {label}: + {value || '未填写'} ++ ); +} + +function Section({ title, children }: { title: string; children: React.ReactNode }) { + return ( +++ ); +} + +function Empty({ text }: { text: string }) { + return{title}+ {children} +{text}; +} + +function StatusBadge({ status, map }: { status: string; map: Record}) { + const [label, color] = map[status] ?? [status, '#9BA0B4']; + return ( + + {label} + + ); +} + +// 构建趋势图数据 +function buildChartData(records: TrendRecord[], metric: string) { + const filtered = records.filter(r => r.metricType === metric); + if (metric === 'BloodPressure') { + return filtered.map(r => ({ + date: new Date(r.recordedAt).toLocaleDateString('zh-CN', { month: 'short', day: 'numeric' }), + systolic: r.systolic, + diastolic: r.diastolic, + })); + } + return filtered.map(r => ({ + date: new Date(r.recordedAt).toLocaleDateString('zh-CN', { month: 'short', day: 'numeric' }), + value: r.value, + })); +} diff --git a/doctor_web/src/pages/patients/PatientListPage.tsx b/doctor_web/src/pages/patients/PatientListPage.tsx new file mode 100644 index 0000000..21a27d3 --- /dev/null +++ b/doctor_web/src/pages/patients/PatientListPage.tsx @@ -0,0 +1,80 @@ +import { useEffect, useState } from 'react'; +import { Link } from 'react-router-dom'; +import { api } from '../../services/api-client'; +import type { Patient } from '../../types'; + +export default function PatientListPage() { + const [patients, setPatients] = useState ([]); + const [search, setSearch] = useState(''); + const [loading, setLoading] = useState(true); + + useEffect(() => { loadPatients(); }, []); + + async function loadPatients(s?: string) { + setLoading(true); + try { + const q = s !== undefined ? s : search; + const data = await api.get (`/api/doctor/patients${q ? `?search=${encodeURIComponent(q)}` : ''}`); + setPatients(data); + } catch { setPatients([]); } + setLoading(false); + } + + return ( + ++ ); +} diff --git a/doctor_web/src/pages/reports/ReportDetailPage.tsx b/doctor_web/src/pages/reports/ReportDetailPage.tsx new file mode 100644 index 0000000..00ed135 --- /dev/null +++ b/doctor_web/src/pages/reports/ReportDetailPage.tsx @@ -0,0 +1,133 @@ +import { useEffect, useState } from 'react'; +import { useParams, useNavigate } from 'react-router-dom'; +import { api } from '../../services/api-client'; +import type { Report } from '../../types'; + +export default function ReportDetailPage() { + const { id } = useParams<{ id: string }>(); + const nav = useNavigate(); + const [report, setReport] = useState++ + {loading ? ( +患者管理
++ setSearch(e.target.value)} + onKeyDown={e => e.key === 'Enter' && loadPatients()} + placeholder="搜索姓名或手机号..." + style={{ padding: '8px 16px', border: '1px solid #E1E5ED', borderRadius: 10, fontSize: 14, outline: 'none', width: 240 }} + /> + ++加载中...+ ) : patients.length === 0 ? ( +暂无患者数据+ ) : ( +++ )} ++ +
++ {['姓名', '手机号', '性别', '出生日期', '健康档案', '操作'].map(h => ( + + + + {patients.map(p => ( +{h} + ))} ++ + ))} + +{p.name || '未设置'} +{p.phone} +{p.gender || '-'} +{p.birthDate || '-'} ++ + {p.hasArchive ? '已建立' : '未建立'} + + ++ + 查看详情 → + + +(null); + const [comment, setComment] = useState(''); + const [submitting, setSubmitting] = useState(false); + const [success, setSuccess] = useState(false); + + useEffect(() => { + if (id) api.get (`/api/doctor/reports/${id}`).then(r => { setReport(r); setComment(r.doctorComment || ''); }).catch(() => {}); + }, [id]); + + async function submitReview() { + if (!id) return; + setSubmitting(true); + try { + await api.post(`/api/doctor/reports/${id}/review`, { comment }); + setSuccess(true); + } catch { alert('提交失败'); } + setSubmitting(false); + } + + if (!report) return 加载中...; + + // 解析 AI 指标 + let indicators: any[] = []; + try { indicators = JSON.parse(report.aiIndicators || '[]'); } catch {} + + return ( +++ ); +} diff --git a/doctor_web/src/pages/reports/ReportListPage.tsx b/doctor_web/src/pages/reports/ReportListPage.tsx new file mode 100644 index 0000000..c99cc77 --- /dev/null +++ b/doctor_web/src/pages/reports/ReportListPage.tsx @@ -0,0 +1,75 @@ +import { useEffect, useState } from 'react'; +import { Link } from 'react-router-dom'; +import { api } from '../../services/api-client'; +import type { Report } from '../../types'; + +const STATUS_MAP: Record+ ++ + {/* 基本信息 */} +报告详情
+++ + {/* AI 预解读 */} +++ {report.fileUrl && ( +患者:{report.patientName || '-'}+类型:{report.category}+上传时间:{new Date(report.createdAt).toLocaleString('zh-CN')}++ 状态: + + {report.status === 'PendingDoctor' ? '待审核' : '已审核'} + +++ + 📎 查看原始文件 + ++ )} +++ + {/* 医生审核 */} +🤖 AI 预解读
+ {report.aiSummary && ( ++ {report.aiSummary} ++ )} + {indicators.length > 0 && ( ++ +
+ )} ++ {['指标', '结果', '单位', '参考范围', '状态'].map(h => ( + + + + {indicators.map((ind: any, i: number) => { + const abnormal = ind.status === 'high' || ind.status === 'abnormal'; + const low = ind.status === 'low'; + return ( +{h} + ))} ++ + ); + })} + +{ind.name} +{ind.value} +{ind.unit || '-'} +{ind.range || '-'} ++ + {abnormal ? '偏高' : low ? '偏低' : '正常'} + + +++👨⚕️ 医生审核意见
+ {success && ( ++ ✓ 审核已提交 ++ )} += { + PendingDoctor: { label: '待审核', color: '#F59E0B' }, + DoctorReviewed: { label: '已审核', color: '#20C997' }, +}; + +export default function ReportListPage() { + const [reports, setReports] = useState ([]); + const [filter, setFilter] = useState(''); + + useEffect(() => { + const q = filter ? `?status=${filter}` : ''; + api.get (`/api/doctor/reports${q}`).then(setReports).catch(() => {}); + }, [filter]); + + return ( + ++ ); +} diff --git a/doctor_web/src/router/index.tsx b/doctor_web/src/router/index.tsx new file mode 100644 index 0000000..b35031c --- /dev/null +++ b/doctor_web/src/router/index.tsx @@ -0,0 +1,31 @@ +import { createBrowserRouter, Navigate } from 'react-router-dom'; +import DoctorLayout from '../components/layout/DoctorLayout'; +import DashboardPage from '../pages/dashboard/DashboardPage'; +import PatientListPage from '../pages/patients/PatientListPage'; +import PatientDetailPage from '../pages/patients/PatientDetailPage'; +import ConsultationListPage from '../pages/consultations/ConsultationListPage'; +import ChatPage from '../pages/consultations/ChatPage'; +import ReportListPage from '../pages/reports/ReportListPage'; +import ReportDetailPage from '../pages/reports/ReportDetailPage'; +import FollowUpListPage from '../pages/followups/FollowUpListPage'; +import FollowUpEditPage from '../pages/followups/FollowUpEditPage'; + +export const router = createBrowserRouter([ + { + path: '/', + element:报告审核
+ + {/* 筛选标签 */} ++ {[{ k: '', l: '全部' }, { k: 'PendingDoctor', l: '待审核' }, { k: 'DoctorReviewed', l: '已审核' }].map(t => ( + + ))} ++ + {reports.length === 0 ? ( +暂无报告+ ) : ( +++ )} ++ +
++ {['患者', '类型', '状态', 'AI 摘要', '上传时间', '操作'].map(h => ( + + + + {reports.map(r => { + const st = STATUS_MAP[r.status] ?? { label: r.status, color: '#9BA0B4' }; + return ( +{h} + ))} ++ + ); + })} + +{r.patientName || '-'} +{r.category} ++ {st.label} + ++ {r.aiSummary?.slice(0, 40) || '-'} + +{new Date(r.createdAt).toLocaleDateString('zh-CN')} ++ + {r.status === 'PendingDoctor' ? '审核 →' : '查看 →'} + + +, + children: [ + { index: true, element: }, + { path: 'dashboard', element: }, + { path: 'patients', element: }, + { path: 'patients/:id', element: }, + { path: 'consultations', element: }, + { path: 'consultations/:id', element: }, + { path: 'reports', element: }, + { path: 'reports/:id', element: }, + { path: 'follow-ups', element: }, + { path: 'follow-ups/new', element: }, + { path: 'follow-ups/:id/edit', element: }, + ], + }, +]); diff --git a/doctor_web/src/services/api-client.ts b/doctor_web/src/services/api-client.ts new file mode 100644 index 0000000..6f773e0 --- /dev/null +++ b/doctor_web/src/services/api-client.ts @@ -0,0 +1,29 @@ +const BASE_URL = 'http://localhost:5000'; + +async function request (method: string, path: string, body?: unknown): Promise { + const headers: Record = { 'Content-Type': 'application/json' }; + + const res = await fetch(`${BASE_URL}${path}`, { + method, + headers, + body: body ? JSON.stringify(body) : undefined, + }); + + if (!res.ok) { + const text = await res.text(); + throw new Error(text || `HTTP ${res.status}`); + } + + const json = await res.json(); + if (json.code !== 0) { + throw new Error(json.message || `Error code ${json.code}`); + } + return json.data as T; +} + +export const api = { + get: (path: string) => request ('GET', path), + post: (path: string, body?: unknown) => request ('POST', path, body), + put: (path: string, body?: unknown) => request ('PUT', path, body), + del: (path: string) => request ('DELETE', path), +}; diff --git a/doctor_web/src/services/signalr.ts b/doctor_web/src/services/signalr.ts new file mode 100644 index 0000000..a89afd9 --- /dev/null +++ b/doctor_web/src/services/signalr.ts @@ -0,0 +1,30 @@ +import { HubConnectionBuilder, HubConnection, LogLevel } from '@microsoft/signalr'; + +const HUB_URL = 'http://localhost:5000/hubs/consultation'; + +let connection: HubConnection | null = null; + +export function getConnection(): HubConnection { + if (!connection) { + connection = new HubConnectionBuilder() + .withUrl(HUB_URL) + .withAutomaticReconnect() + .configureLogging(LogLevel.Information) + .build(); + } + return connection; +} + +export async function startConnection(): Promise { + const conn = getConnection(); + if (conn.state === 'Disconnected') { + await conn.start(); + } +} + +export async function stopConnection(): Promise { + if (connection && connection.state !== 'Disconnected') { + await connection.stop(); + connection = null; + } +} diff --git a/doctor_web/src/types/index.ts b/doctor_web/src/types/index.ts new file mode 100644 index 0000000..823a159 --- /dev/null +++ b/doctor_web/src/types/index.ts @@ -0,0 +1,158 @@ +// 患者 +export interface Patient { + id: string; + phone: string; + name: string | null; + gender: string | null; + birthDate: string | null; + hasArchive: boolean; +} + +// 患者详情 +export interface PatientDetail { + profile: { + id: string; + phone: string; + name: string | null; + gender: string | null; + birthDate: string | null; + avatarUrl: string | null; + }; + archive: { + diagnosis: string | null; + surgeryType: string | null; + surgeryDate: string | null; + allergies: string[]; + dietRestrictions: string[]; + chronicDiseases: string[]; + familyHistory: string | null; + } | null; + latestRecords: HealthRecord[]; + trendRecords: TrendRecord[]; + medications: Medication[]; + dietRecords: DietRecord[]; + exercisePlan: ExercisePlan | null; + reports: Report[]; + followUps: FollowUp[]; +} + +// 健康记录 +export interface HealthRecord { + id: string; + metricType: string; + systolic: number | null; + diastolic: number | null; + value: number | null; + unit: string; + recordedAt: string; + isAbnormal: boolean; +} + +// 趋势数据 +export interface TrendRecord { + id: string; + metricType: string; + systolic: number | null; + diastolic: number | null; + value: number | null; + unit: string; + recordedAt: string; + isAbnormal: boolean; +} + +// 用药 +export interface Medication { + id: string; + name: string; + dosage: string; + frequency: string; + timeOfDay: string[]; + startDate: string; + endDate: string | null; +} + +// 饮食记录 +export interface DietRecord { + id: string; + mealType: string; + totalCalories: number; + healthScore: number; + recordedAt: string; + foods: { name: string; portion: string; calories: number; warning: string | null }[]; +} + +// 运动计划 +export interface ExercisePlan { + weekStartDate: string; + items: { + dayOfWeek: number; + exerciseType: string | null; + durationMinutes: number; + isCompleted: boolean; + isRestDay: boolean; + completedAt: string | null; + }[]; +} + +// 报告 +export interface Report { + id: string; + userId: string; + patientName?: string; + fileUrl: string; + fileType: string; + category: string; + status: string; + aiSummary: string | null; + aiIndicators: string | null; + doctorComment: string | null; + doctorName: string | null; + reviewedAt: string | null; + createdAt: string; +} + +// 随访 +export interface FollowUp { + id: string; + userId: string; + patientName?: string; + title: string; + doctorName: string | null; + department: string | null; + scheduledAt: string; + notes: string | null; + status: string; + createdAt: string; +} + +// 问诊 +export interface Consultation { + id: string; + userId: string; + patientName?: string; + patientPhone?: string; + status: string; + createdAt: string; + closedAt: string | null; + lastMessage: { content: string; senderType: string; createdAt: string } | null; +} + +// 问诊消息 +export interface ConsultationMessage { + id: string; + senderType: string; + senderName: string | null; + content: string; + createdAt: string; +} + +// Dashboard +export interface DashboardStats { + doctorName: string; + doctorTitle: string; + doctorDepartment: string; + totalPatients: number; + activeConsultations: number; + pendingReports: number; + todayFollowUps: number; +} diff --git a/doctor_web/tsconfig.app.json b/doctor_web/tsconfig.app.json new file mode 100644 index 0000000..7f42e5f --- /dev/null +++ b/doctor_web/tsconfig.app.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", + "target": "es2023", + "lib": ["ES2023", "DOM"], + "module": "esnext", + "types": ["vite/client"], + "skipLibCheck": true, + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "verbatimModuleSyntax": true, + "moduleDetection": "force", + "noEmit": true, + "jsx": "react-jsx", + + /* Linting */ + "noUnusedLocals": true, + "noUnusedParameters": true, + "erasableSyntaxOnly": true, + "noFallthroughCasesInSwitch": true + }, + "include": ["src"] +} diff --git a/doctor_web/tsconfig.json b/doctor_web/tsconfig.json new file mode 100644 index 0000000..1ffef60 --- /dev/null +++ b/doctor_web/tsconfig.json @@ -0,0 +1,7 @@ +{ + "files": [], + "references": [ + { "path": "./tsconfig.app.json" }, + { "path": "./tsconfig.node.json" } + ] +} diff --git a/doctor_web/tsconfig.node.json b/doctor_web/tsconfig.node.json new file mode 100644 index 0000000..d3c52ea --- /dev/null +++ b/doctor_web/tsconfig.node.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", + "target": "es2023", + "lib": ["ES2023"], + "module": "esnext", + "types": ["node"], + "skipLibCheck": true, + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "verbatimModuleSyntax": true, + "moduleDetection": "force", + "noEmit": true, + + /* Linting */ + "noUnusedLocals": true, + "noUnusedParameters": true, + "erasableSyntaxOnly": true, + "noFallthroughCasesInSwitch": true + }, + "include": ["vite.config.ts"] +} diff --git a/doctor_web/vite.config.ts b/doctor_web/vite.config.ts new file mode 100644 index 0000000..8b0f57b --- /dev/null +++ b/doctor_web/vite.config.ts @@ -0,0 +1,7 @@ +import { defineConfig } from 'vite' +import react from '@vitejs/plugin-react' + +// https://vite.dev/config/ +export default defineConfig({ + plugins: [react()], +}) diff --git a/health_app/lib/pages/consultation/consultation_pages.dart b/health_app/lib/pages/consultation/consultation_pages.dart index 801f83f..885761c 100644 --- a/health_app/lib/pages/consultation/consultation_pages.dart +++ b/health_app/lib/pages/consultation/consultation_pages.dart @@ -103,7 +103,7 @@ class _DoctorChatPageState extends ConsumerState { @override void dispose() { - ref.read(consultationChatProvider.notifier).stopPolling(); + ref.read(consultationChatProvider.notifier).stop(); _textCtrl.dispose(); _scrollCtrl.dispose(); super.dispose(); diff --git a/health_app/lib/providers/consultation_provider.dart b/health_app/lib/providers/consultation_provider.dart index 7fc6d0f..3642a3d 100644 --- a/health_app/lib/providers/consultation_provider.dart +++ b/health_app/lib/providers/consultation_provider.dart @@ -1,5 +1,7 @@ import 'dart:async'; import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:signalr_netcore/signalr_client.dart'; +import '../core/api_client.dart' show baseUrl; import 'auth_provider.dart'; class ConsultationMsg { @@ -8,7 +10,6 @@ class ConsultationMsg { final String? senderName; final String content; final DateTime createdAt; - final List ? quickOptions; ConsultationMsg({ required this.id, @@ -16,7 +17,6 @@ class ConsultationMsg { this.senderName, required this.content, required this.createdAt, - this.quickOptions, }); } @@ -30,6 +30,7 @@ class ConsultationChatState { final List messages; final bool isLoading; final bool isSending; + final bool isConnected; final int quotaRemaining; final int quotaTotal; @@ -43,6 +44,7 @@ class ConsultationChatState { this.messages = const [], this.isLoading = true, this.isSending = false, + this.isConnected = false, this.quotaRemaining = 3, this.quotaTotal = 3, }); @@ -57,6 +59,7 @@ class ConsultationChatState { List ? messages, bool? isLoading, bool? isSending, + bool? isConnected, int? quotaRemaining, int? quotaTotal, }) => @@ -70,6 +73,7 @@ class ConsultationChatState { messages: messages ?? this.messages, isLoading: isLoading ?? this.isLoading, isSending: isSending ?? this.isSending, + isConnected: isConnected ?? this.isConnected, quotaRemaining: quotaRemaining ?? this.quotaRemaining, quotaTotal: quotaTotal ?? this.quotaTotal, ); @@ -80,7 +84,8 @@ final consultationChatProvider = ConsultationChatNotifier.new); class ConsultationChatNotifier extends Notifier { - Timer? _pollTimer; + HubConnection? _hub; + String get _hubUrl => '$baseUrl/hubs/consultation'; @override ConsultationChatState build() => const ConsultationChatState(); @@ -127,12 +132,54 @@ class ConsultationChatNotifier extends Notifier { state = state.copyWith(consultationId: consultationId, isLoading: false); } - _startPolling(); + // 建立 SignalR 连接 + await _connectHub(consultationId); } catch (_) { state = state.copyWith(isLoading: false); } } + Future _connectHub(String consultationId) async { + try { + _hub?.stop(); + _hub = HubConnectionBuilder() + .withUrl(_hubUrl) + .withAutomaticReconnect() + .build(); + + // 注册消息接收 + _hub!.on('ReceiveMessage', (args) { + if (args == null || args.isEmpty) return; + final data = args[0] as Map ; + final msgConsultationId = data['consultationId']?.toString() ?? ''; + if (msgConsultationId != consultationId) return; + + final msg = ConsultationMsg( + id: data['id']?.toString() ?? DateTime.now().millisecondsSinceEpoch.toString(), + senderType: data['senderType']?.toString() ?? 'Ai', + senderName: data['senderName']?.toString(), + content: data['content']?.toString() ?? '', + createdAt: data['createdAt'] != null + ? DateTime.tryParse(data['createdAt'].toString()) ?? DateTime.now() + : DateTime.now(), + ); + + // 去重 + final existingIds = state.messages.map((m) => m.id).toSet(); + if (!existingIds.contains(msg.id)) { + state = state.copyWith(messages: [...state.messages, msg]); + } + }); + + await _hub!.start(); + await _hub!.invoke('JoinConsultation', args: [consultationId]); + state = state.copyWith(isConnected: true); + } catch (_) { + // SignalR 连接失败,回退到轮询 + _startPolling(); + } + } + Future _loadDoctorInfo(String doctorId) async { try { final api = ref.read(apiClientProvider); @@ -185,27 +232,37 @@ class ConsultationChatNotifier extends Notifier { ); try { - final api = ref.read(apiClientProvider); - await api.post('/api/consultations/${state.consultationId}/messages', data: {'content': text}); - state = state.copyWith(isSending: false); - _pollMessages(); + // 优先通过 SignalR 发送 + if (_hub != null && _hub!.state == HubConnectionState.Connected) { + await _hub!.invoke('SendMessage', + args: