создал несколько таблиц
This commit is contained in:
parent
fc63f9e167
commit
523b6d5b89
13
api/app/domain/models/appointment_types.py
Normal file
13
api/app/domain/models/appointment_types.py
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
from sqlalchemy import Column, Integer, VARCHAR
|
||||||
|
from sqlalchemy.orm import relationship
|
||||||
|
|
||||||
|
from app.domain.models import Base
|
||||||
|
|
||||||
|
|
||||||
|
class AppointmentType(Base):
|
||||||
|
__tablename__ = 'appointment_types'
|
||||||
|
|
||||||
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||||
|
title = Column(VARCHAR(150), nullable=False, unique=True)
|
||||||
|
|
||||||
|
appointments = relationship('Appointment', back_populates='type')
|
||||||
20
api/app/domain/models/appointments.py
Normal file
20
api/app/domain/models/appointments.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
from sqlalchemy import Column, Integer, String, ForeignKey
|
||||||
|
from sqlalchemy.orm import relationship
|
||||||
|
|
||||||
|
from app.domain.models import Base
|
||||||
|
|
||||||
|
|
||||||
|
class Appointment(Base):
|
||||||
|
__tablename__ = 'appointments'
|
||||||
|
|
||||||
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||||
|
results = Column(String)
|
||||||
|
days_until_the_next_appointment = Column(Integer)
|
||||||
|
|
||||||
|
patient_id = Column(Integer, ForeignKey('patients.id'), nullable=False)
|
||||||
|
doctor_id = Column(Integer, ForeignKey('users.id'), nullable=False)
|
||||||
|
type_id = Column(Integer, ForeignKey('appointment_types.id'), nullable=False)
|
||||||
|
|
||||||
|
patient = relationship('Patient', back_populates='appointments')
|
||||||
|
doctor = relationship('User', back_populates='appointments')
|
||||||
|
type = relationship('AppointmentType', back_populates='appointments')
|
||||||
@ -28,3 +28,4 @@ class Lens(Base):
|
|||||||
type = relationship('LensesType', back_populates='lenses')
|
type = relationship('LensesType', back_populates='lenses')
|
||||||
|
|
||||||
set = relationship('SetLens', back_populates='lens')
|
set = relationship('SetLens', back_populates='lens')
|
||||||
|
lens_issues = relationship('LensIssue', back_populates='lens')
|
||||||
|
|||||||
19
api/app/domain/models/lens_issues.py
Normal file
19
api/app/domain/models/lens_issues.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
from sqlalchemy import Column, Integer, ForeignKey, Date
|
||||||
|
from sqlalchemy.orm import relationship
|
||||||
|
|
||||||
|
from app.domain.models import Base
|
||||||
|
|
||||||
|
|
||||||
|
class LensIssue(Base):
|
||||||
|
__tablename__ = 'lens_issues'
|
||||||
|
|
||||||
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||||
|
issue_date = Column(Date, nullable=False)
|
||||||
|
|
||||||
|
patient_id = Column(Integer, ForeignKey('patients.id'), nullable=False)
|
||||||
|
doctor_id = Column(Integer, ForeignKey('user.id'), nullable=False)
|
||||||
|
lens_id = Column(Integer, ForeignKey('lens.id'), nullable=False)
|
||||||
|
|
||||||
|
patient = relationship('Patient', back_populates='lens_issues')
|
||||||
|
doctor = relationship('User', back_populates='lens_issues')
|
||||||
|
lens = relationship('Lens', back_populates='lens_issues')
|
||||||
22
api/app/domain/models/patients.py
Normal file
22
api/app/domain/models/patients.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
from sqlalchemy import Column, Integer, VARCHAR, Date, String
|
||||||
|
from sqlalchemy.orm import relationship
|
||||||
|
|
||||||
|
from app.domain.models import Base
|
||||||
|
|
||||||
|
|
||||||
|
class Patient(Base):
|
||||||
|
__tablename__ = 'patients'
|
||||||
|
|
||||||
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||||
|
first_name = Column(VARCHAR(200), nullable=False)
|
||||||
|
last_name = Column(VARCHAR(200), nullable=False)
|
||||||
|
patronymic = Column(VARCHAR(200))
|
||||||
|
birthday = Column(Date, nullable=False)
|
||||||
|
address = Column(String)
|
||||||
|
email = Column(VARCHAR(350))
|
||||||
|
phone = Column(VARCHAR(25))
|
||||||
|
diagnosis = Column(String)
|
||||||
|
correction = Column(String)
|
||||||
|
|
||||||
|
lens_issues = relationship('LensIssue', back_populates='patient')
|
||||||
|
appointments = relationship('Appointment', back_populates='patient')
|
||||||
@ -17,3 +17,6 @@ class User(Base):
|
|||||||
role_id = Column(Integer, ForeignKey('roles.id'), nullable=False)
|
role_id = Column(Integer, ForeignKey('roles.id'), nullable=False)
|
||||||
|
|
||||||
role = relationship('Role', back_populates='users')
|
role = relationship('Role', back_populates='users')
|
||||||
|
|
||||||
|
lens_issues = relationship('LensIssue', back_populates='doctor')
|
||||||
|
appointments = relationship('Appointment', back_populates='doctor')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user