25 lines
1.0 KiB
Python
25 lines
1.0 KiB
Python
from datetime import datetime
|
|
from sqlalchemy import Column, Date, DateTime, ForeignKey, Integer, String, Text
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from app.db.base import Base
|
|
|
|
|
|
class Patient(Base):
|
|
__tablename__ = "patients"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
user_id = Column(Integer, ForeignKey("users.id"), unique=True, nullable=False)
|
|
date_of_birth = Column(Date, nullable=True)
|
|
blood_type = Column(String, nullable=True)
|
|
allergies = Column(Text, nullable=True)
|
|
medical_history = Column(Text, nullable=True)
|
|
emergency_contact_name = Column(String, nullable=True)
|
|
emergency_contact_phone = Column(String, nullable=True)
|
|
created_at = Column(DateTime, default=datetime.utcnow)
|
|
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
|
|
|
# Relationships
|
|
user = relationship("User", back_populates="patient")
|
|
appointments = relationship("Appointment", back_populates="patient")
|
|
medical_records = relationship("MedicalRecord", back_populates="patient") |