61 lines
1.7 KiB
Python
61 lines
1.7 KiB
Python
from datetime import datetime, timezone
|
|
from typing import Optional
|
|
|
|
from beanie import Document, PydanticObjectId
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class IndicatorInterpretation(BaseModel):
|
|
"""单项指标解读"""
|
|
name: str
|
|
nickname: str = "" # 白话名称,如"氧气快递员"
|
|
value: str = ""
|
|
status: str = "normal"
|
|
what_is_it: str = "" # 通俗解释
|
|
impact: str = "" # 对宝宝的影响
|
|
suggestion: str = "" # 行动建议
|
|
recheck_reminder: Optional[str] = None
|
|
|
|
|
|
class CategoryInterpretation(BaseModel):
|
|
"""分类解读(如血液指标、激素水平)"""
|
|
category: str
|
|
status: str = "normal"
|
|
indicators: list[IndicatorInterpretation] = Field(default_factory=list)
|
|
|
|
|
|
class ActionItem(BaseModel):
|
|
"""行动建议"""
|
|
content: str
|
|
priority: str = "medium" # high / medium / low
|
|
category: str = "" # 饮食 / 运动 / 就医 / 复查
|
|
|
|
|
|
class Analysis(Document):
|
|
report_id: PydanticObjectId
|
|
user_id: PydanticObjectId
|
|
|
|
# Overall assessment
|
|
overall_status: str = "normal" # normal / attention / warning
|
|
risk_level: str = "low" # low / medium / high
|
|
overall_summary: str = "" # 整体评估文案
|
|
emotional_summary: str = "" # 情感化总结,如"宝宝发育良好"
|
|
|
|
# Detailed interpretations
|
|
categories: list[CategoryInterpretation] = Field(default_factory=list)
|
|
|
|
# Action items
|
|
action_items: list[ActionItem] = Field(default_factory=list)
|
|
|
|
# Tips
|
|
tips: list[str] = Field(default_factory=list)
|
|
|
|
created_at: datetime = Field(default_factory=lambda: datetime.now(timezone.utc))
|
|
|
|
class Settings:
|
|
name = "analyses"
|
|
indexes = [
|
|
"user_id",
|
|
"report_id",
|
|
]
|