import { useState, useEffect } from "react"; import { useNavigate, useParams } from "react-router"; import { motion } from "motion/react"; import { ChevronLeft, Copy, Check, MessageCircle, Clipboard, Share2, Download, Loader2, } from "lucide-react"; import { Button } from "../components/ui/button"; import { Card } from "../components/ui/card"; import { Badge } from "../components/ui/badge"; import { getDoctorQuestions } from "../services/api"; interface Question { id: string; category: string; question: string; reason: string; priority: "high" | "medium" | "low"; } export function DoctorQuestionsPage() { const navigate = useNavigate(); const { reportId } = useParams(); const [copiedId, setCopiedId] = useState(null); const [questions, setQuestions] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { if (!reportId) return; getDoctorQuestions(reportId) .then((data) => { setQuestions( data.questions.map((q, i) => ({ id: String(i), category: q.category, question: q.question, reason: q.reason, priority: (i < 2 ? "high" : i < 4 ? "medium" : "low") as Question["priority"], })) ); }) .catch(() => {/* keep empty */}) .finally(() => setLoading(false)); }, [reportId]); const handleCopy = (text: string, id: string) => { navigator.clipboard.writeText(text); setCopiedId(id); setTimeout(() => setCopiedId(null), 2000); }; const handleCopyAll = () => { const allQuestions = questions .map((q, index) => `${index + 1}. ${q.question}`) .join("\n\n"); navigator.clipboard.writeText(allQuestions); setCopiedId("all"); setTimeout(() => setCopiedId(null), 2000); }; const priorityLabels = { high: { text: "重要", color: "bg-red-100 text-red-700" }, medium: { text: "建议", color: "bg-morandi-rose-100 text-morandi-rose-400" }, low: { text: "了解", color: "bg-morandi-50 text-morandi-500" }, }; if (loading) { return (

正在生成问诊清单...

); } return (
{/* 顶部导航 */}

问诊清单

智能生成{questions.length}个问题

{/* 使用说明 */}

💬 如何使用问诊清单

✓ 基于您的报告异常项,AI智能生成针对性问题

✓ 点击单个问题可复制,方便向医生提问

✓ 可一键复制全部问题,就诊时查看

✓ 按优先级排序,重要问题优先询问

{/* 问题列表 */}

📋 建议咨询的问题

{questions.map((question, index) => (
{index + 1}
{priorityLabels[question.priority].text} {question.category}

{question.question}

💡 为什么问: {question.reason}

))}
{/* 其他建议 */}

💡 就诊小贴士

  • 问诊时可以拿出手机查看问题清单,避免紧张时忘记要问的内容
  • 听从医生建议,记录重要的用药和注意事项
  • 如医生时间有限,优先询问标记为"重要"的问题
  • 就诊后可返回APP查看AI建议,结合医生意见调整生活方式
{/* 底部操作 */}
); }