Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ services:
# (Adding the "ports" property to this file will not forward from a Codespace.)

db:
image: postgres:latest
image: postgres:16
restart: unless-stopped
volumes:
- postgres-data:/var/lib/postgresql/data
Expand Down
7 changes: 5 additions & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ verify_ssl = true
[dev-packages]

[packages]
flask = "*"
flask-sqlalchemy = "*"
flask-migrate = "*"
flask-swagger = "*"
Expand All @@ -17,9 +16,13 @@ gunicorn = "*"
cloudinary = "*"
flask-admin = "*"
typing-extensions = "*"
flask-jwt-extended = "==4.6.0"
wtforms = "==3.1.2"
flask = "*"
sqlalchemy = "*"
jwt = "*"
bcrypt = "*"
flask-jwt-extended = "*"
pyjwt = "==1.7.1"

[requires]
python_version = "3.13"
Expand Down
999 changes: 631 additions & 368 deletions Pipfile.lock

Large diffs are not rendered by default.

35 changes: 0 additions & 35 deletions migrations/versions/0763d677d453_.py

This file was deleted.

48 changes: 48 additions & 0 deletions migrations/versions/1466af5e8f40_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
"""empty message

Revision ID: 1466af5e8f40
Revises: cd73d3e1f8ee
Create Date: 2025-10-28 02:33:06.476454

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '1466af5e8f40'
down_revision = 'cd73d3e1f8ee'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('doctors', schema=None) as batch_op:
batch_op.add_column(sa.Column('license_number', sa.String(length=50), nullable=False))
batch_op.add_column(sa.Column('phone_number', sa.String(length=50), nullable=True))
batch_op.alter_column('specialty',
existing_type=sa.VARCHAR(length=80),
nullable=True)
batch_op.alter_column('work_days',
existing_type=sa.INTEGER(),
nullable=True)
batch_op.create_unique_constraint(None, ['license_number'])

# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('doctors', schema=None) as batch_op:
batch_op.drop_constraint(None, type_='unique')
batch_op.alter_column('work_days',
existing_type=sa.INTEGER(),
nullable=False)
batch_op.alter_column('specialty',
existing_type=sa.VARCHAR(length=80),
nullable=False)
batch_op.drop_column('phone_number')
batch_op.drop_column('license_number')

# ### end Alembic commands ###
32 changes: 32 additions & 0 deletions migrations/versions/cd73d3e1f8ee_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""empty message

Revision ID: cd73d3e1f8ee
Revises: ef5b24ee4ea3
Create Date: 2025-10-24 19:01:11.468866

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'cd73d3e1f8ee'
down_revision = 'ef5b24ee4ea3'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('appointments', schema=None) as batch_op:
batch_op.drop_column('medical_record')

# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('appointments', schema=None) as batch_op:
batch_op.add_column(sa.Column('medical_record', sa.VARCHAR(), autoincrement=False, nullable=True))

# ### end Alembic commands ###
48 changes: 48 additions & 0 deletions migrations/versions/dcc9c71b8a96_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
"""empty message

Revision ID: dcc9c71b8a96
Revises: 1466af5e8f40
Create Date: 2025-10-28 02:34:42.196679

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'dcc9c71b8a96'
down_revision = '1466af5e8f40'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('doctors', schema=None) as batch_op:
batch_op.alter_column('specialty',
existing_type=sa.VARCHAR(length=80),
nullable=False)
batch_op.alter_column('work_days',
existing_type=sa.INTEGER(),
nullable=False)
batch_op.drop_constraint(batch_op.f('doctors_license_number_key'), type_='unique')
batch_op.drop_column('license_number')
batch_op.drop_column('phone_number')

# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('doctors', schema=None) as batch_op:
batch_op.add_column(sa.Column('phone_number', sa.VARCHAR(length=50), autoincrement=False, nullable=True))
batch_op.add_column(sa.Column('license_number', sa.VARCHAR(length=50), autoincrement=False, nullable=False))
batch_op.create_unique_constraint(batch_op.f('doctors_license_number_key'), ['license_number'], postgresql_nulls_not_distinct=False)
batch_op.alter_column('work_days',
existing_type=sa.INTEGER(),
nullable=True)
batch_op.alter_column('specialty',
existing_type=sa.VARCHAR(length=80),
nullable=True)

# ### end Alembic commands ###
104 changes: 104 additions & 0 deletions migrations/versions/ef5b24ee4ea3_init_schema.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
"""init schema

Revision ID: ef5b24ee4ea3
Revises:
Create Date: 2025-10-22 22:34:44.817589

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'ef5b24ee4ea3'
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('centers',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=255), nullable=False),
sa.Column('address', sa.String(length=255), nullable=False),
sa.Column('zip_code', sa.String(length=30), nullable=False),
sa.Column('phone', sa.Integer(), nullable=False),
sa.Column('type_center', sa.String(length=80), nullable=False),
sa.PrimaryKeyConstraint('id')
)
op.create_table('user',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('email', sa.String(length=255), nullable=False),
sa.Column('password', sa.String(), nullable=False),
sa.Column('is_active', sa.Boolean(), nullable=False),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('email')
)
op.create_table('doctors',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('email', sa.String(length=255), nullable=False),
sa.Column('first_name', sa.String(length=255), nullable=False),
sa.Column('last_name', sa.String(length=255), nullable=False),
sa.Column('specialty', sa.String(length=80), nullable=False),
sa.Column('center_id', sa.Integer(), nullable=True),
sa.Column('work_days', sa.Integer(), nullable=False),
sa.Column('is_active', sa.Boolean(), nullable=False),
sa.Column('password', sa.String(length=255), nullable=False),
sa.ForeignKeyConstraint(['center_id'], ['centers.id'], ondelete='SET NULL'),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('email')
)
with op.batch_alter_table('doctors', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_doctors_center_id'), ['center_id'], unique=False)

op.create_table('patients',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('email', sa.String(length=255), nullable=False),
sa.Column('first_name', sa.String(length=255), nullable=False),
sa.Column('last_name', sa.String(length=255), nullable=False),
sa.Column('birth_date', sa.Date(), nullable=False),
sa.Column('password', sa.String(), nullable=False),
sa.Column('assign_doctor', sa.Integer(), nullable=True),
sa.Column('is_active', sa.Boolean(), nullable=False),
sa.ForeignKeyConstraint(['assign_doctor'], ['doctors.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('email')
)
op.create_table('appointments',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('doctor_id', sa.Integer(), nullable=False),
sa.Column('patient_id', sa.Integer(), nullable=False),
sa.Column('center_id', sa.Integer(), nullable=False),
sa.Column('appointment_date', sa.DateTime(), nullable=False),
sa.Column('medical_record', sa.String(), nullable=True),
sa.Column('status', sa.String(), nullable=False),
sa.ForeignKeyConstraint(['center_id'], ['centers.id'], ),
sa.ForeignKeyConstraint(['doctor_id'], ['doctors.id'], ),
sa.ForeignKeyConstraint(['patient_id'], ['patients.id'], ),
sa.PrimaryKeyConstraint('id')
)
with op.batch_alter_table('appointments', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_appointments_center_id'), ['center_id'], unique=False)
batch_op.create_index(batch_op.f('ix_appointments_doctor_id'), ['doctor_id'], unique=False)
batch_op.create_index(batch_op.f('ix_appointments_patient_id'), ['patient_id'], unique=False)

# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('appointments', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_appointments_patient_id'))
batch_op.drop_index(batch_op.f('ix_appointments_doctor_id'))
batch_op.drop_index(batch_op.f('ix_appointments_center_id'))

op.drop_table('appointments')
op.drop_table('patients')
with op.batch_alter_table('doctors', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_doctors_center_id'))

op.drop_table('doctors')
op.drop_table('user')
op.drop_table('centers')
# ### end Alembic commands ###
7 changes: 6 additions & 1 deletion src/api/admin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import os
from flask_admin import Admin
from .models import db, User
from .models import db, User, Patient, Doctor, Appointment, Center
from flask_admin.contrib.sqla import ModelView

def setup_admin(app):
Expand All @@ -12,6 +12,11 @@ def setup_admin(app):

# Add your models here, for example this is how we add a the User model to the admin
admin.add_view(ModelView(User, db.session))
admin.add_view(ModelView(Patient, db.session))
admin.add_view(ModelView(Doctor, db.session))
admin.add_view(ModelView(Appointment, db.session))
admin.add_view(ModelView(Center, db.session))


# You can duplicate that line to add mew models
# admin.add_view(ModelView(YourModelName, db.session))
Loading