finalize medical consultation agent backend

This commit is contained in:
刘金宝
2026-06-03 15:51:46 +08:00
parent 93d9e1c6a5
commit eb43573a44
33 changed files with 1063 additions and 281 deletions
+11 -11
View File
@@ -1,22 +1,22 @@
from __future__ import annotations
from sqlalchemy import Boolean, ForeignKey, Integer, String
from sqlalchemy.orm import Mapped, mapped_column, relationship
from sqlalchemy import BigInteger, Integer, String
from sqlalchemy.orm import Mapped, mapped_column
from app.db.base import Base
from app.models.mixins import TimestampMixin
BIGINT_PK = BigInteger().with_variant(Integer, "sqlite")
class Department(TimestampMixin, Base):
"""科室模型:维护病例、知识库和评分规则的科室分类"""
"""科室模型:使用用户端确定的 department 表字段"""
__tablename__ = "departments"
__tablename__ = "department"
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
name: Mapped[str] = mapped_column(String(100), nullable=False)
code: Mapped[str] = mapped_column(String(50), nullable=False, unique=True, index=True)
parent_id: Mapped[int | None] = mapped_column(ForeignKey("departments.id"), nullable=True)
sort_order: Mapped[int] = mapped_column(Integer, default=0)
is_active: Mapped[bool] = mapped_column(Boolean, default=True)
id: Mapped[int] = mapped_column(BIGINT_PK, primary_key=True, autoincrement=True, comment="科室ID")
name: Mapped[str] = mapped_column(String(100), nullable=False, comment="科室名称")
category: Mapped[str] = mapped_column(String(50), nullable=False, comment="科室分类")
institution_id: Mapped[int] = mapped_column(BigInteger, nullable=False, index=True, comment="所属机构ID")
parent: Mapped["Department | None"] = relationship(remote_side=[id])
__table_args__ = {"comment": "科室表"}