Skip to content

Commit

Permalink
Adding comments and document_num to sanctaury model and schema (#137)
Browse files Browse the repository at this point in the history
Problem
Sanctuary would like these two attributes added

Solution
- added document_num and comment to sanctuary model and schema
- added migration file

Ticket URL
https://mediform.atlassian.net/browse/MEDI-90

Documentation
NA

Tests Run
- make testapi
- tested running migrations in dev environment
  • Loading branch information
MadelaineJ authored Mar 25, 2024
1 parent f1508d0 commit b812227
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
"""CHANGEME
Revision ID: 5a6e3d13358f
Revises: 38ecd95d6104
Create Date: 2024-03-22 18:05:23.388169
"""
from alembic import op
import sqlalchemy as sa

from alembic import context

# revision identifiers, used by Alembic.
revision = '5a6e3d13358f'
down_revision = '38ecd95d6104'
branch_labels = None
depends_on = None


def upgrade():
schema_upgrades()
if context.get_x_argument(as_dictionary=True).get("data", None):
data_upgrades()


def downgrade():
if context.get_x_argument(as_dictionary=True).get("data", None):
data_downgrades()
schema_downgrades()


def schema_upgrades():
"""schema upgrade migrations go here."""
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('intakes', sa.Column('document_num', sa.String(), nullable=True))
op.add_column('intakes', sa.Column('comment', sa.String(), nullable=True))
# ### end Alembic commands ###


def schema_downgrades():
"""schema downgrade migrations go here."""
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('intakes', 'comment')
op.drop_column('intakes', 'document_num')
# ### end Alembic commands ###


def data_upgrades():
"""Add any optional data upgrade migrations here!"""
pass


def data_downgrades():
"""Add any optional data downgrade migrations here!"""
pass
2 changes: 2 additions & 0 deletions app/api/models/intake.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class Intake(BaseSanctuary, BasicMetrics):
discharge_date = Column(DateTime, nullable=True)
discharge_time = Column(DateTime, nullable=True)
discharge_method = Column(String, nullable=True)
document_num = Column(String, nullable=True)
comment = Column(String, nullable=True)

def get_intake_by_uuid(
db: Session, uuid: uuid.UUID
Expand Down
2 changes: 2 additions & 0 deletions app/api/schemas/intake.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class IntakeSchema(BaseModel):
An intake for a given patient.
"""

document_num: Optional[str]
guest_rfid: Optional[str]
arrival_date: datetime
arrival_time: datetime
Expand All @@ -23,6 +24,7 @@ class IntakeSchema(BaseModel):
discharge_date: datetime
discharge_time: datetime
discharge_method: Optional[str]
comment: Optional[str]

class Config:
orm_mode = True
Expand Down

0 comments on commit b812227

Please sign in to comment.