首次提交by MimoCode
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
from sqlalchemy import Column, Integer, String, Text, ForeignKey, DateTime, JSON
|
||||
from sqlalchemy.orm import relationship
|
||||
from datetime import datetime
|
||||
|
||||
from app.database import Base
|
||||
|
||||
|
||||
class Medicine(Base):
|
||||
__tablename__ = "medicines"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
name = Column(String(200), nullable=False, index=True)
|
||||
generic_name = Column(String(200), index=True)
|
||||
brand_name = Column(String(200))
|
||||
manufacturer = Column(String(200))
|
||||
specification = Column(String(200))
|
||||
category_id = Column(Integer, ForeignKey("categories.id"))
|
||||
description = Column(Text)
|
||||
indications = Column(Text)
|
||||
adult_dose = Column(Text)
|
||||
child_dose = Column(Text)
|
||||
contraindications = Column(Text)
|
||||
notes = Column(Text)
|
||||
image_front_path = Column(String(500))
|
||||
image_expiry_path = Column(String(500))
|
||||
image_leaflet_paths = Column(JSON)
|
||||
expiry_grace_days = Column(Integer, default=0)
|
||||
created_by = Column(Integer, ForeignKey("users.id"))
|
||||
created_at = Column(DateTime, default=datetime.utcnow)
|
||||
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
||||
|
||||
category = relationship("Category", back_populates="medicines")
|
||||
creator = relationship("User", back_populates="medicines")
|
||||
batches = relationship("Batch", back_populates="medicine", cascade="all, delete-orphan")
|
||||
audit_logs = relationship("AuditLog", back_populates="medicine")
|
||||
Reference in New Issue
Block a user