Skip to content

Commit

Permalink
get_plan_by_id.py
Browse files Browse the repository at this point in the history
  • Loading branch information
WSL0809 committed May 16, 2024
1 parent 082e773 commit bd92d46
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 33 deletions.
1 change: 1 addition & 0 deletions api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
from .insert_client import router as insert_client_router
from .manage_plan import router as manage_plan_router
from .allocate_room import router as allocate_room_router
from .get_plan_by_id import router as get_plan_by_id_router
16 changes: 16 additions & 0 deletions api/get_plan_by_id.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from fastapi import APIRouter, Depends
from sqlalchemy.orm import Session

import model
from database import get_db

router = APIRouter()


@router.get("/get_meal_plan_by_id")
async def get_plan_by_id(meal_plan_id: int, db: Session = Depends(get_db)):
return db.query(model.MealPlan).filter(model.MealPlan.id == meal_plan_id).first()

@router.get("/get_recovery_plan_by_id")
async def get_plan_by_id(recovery_plan_id: int, db: Session = Depends(get_db)):
return db.query(model.RecoveryPlan).filter(model.RecoveryPlan.id == recovery_plan_id).first()
4 changes: 2 additions & 2 deletions api/insert_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class InsertClientRecv(BaseModel):
meal_plan_seller: Union[Dict, None] = {}
recovery_plan_seller: Union[Dict, None] = {}
due_date: Union[str, None] = None

status: int
class Config:
orm_mode = True

Expand Down Expand Up @@ -67,7 +67,7 @@ def update_client_and_room(db, insert_client_recv: InsertClientRecv):
reserve_recv_dict = dict(insert_client_recv)
reserve_recv_dict["meal_plan_seller"] = json.dumps(insert_client_recv.meal_plan_seller)
reserve_recv_dict["recovery_plan_seller"] = json.dumps(insert_client_recv.recovery_plan_seller)
reserve_recv_dict["status"] = ClientStatus.manual_create_without_room.value
# reserve_recv_dict["status"] = ClientStatus.manual_create_without_room.value
try:
db.execute(create_client_sql, reserve_recv_dict)
db.flush()
Expand Down
3 changes: 2 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
check_out_router, get_room_by_room_name_router, get_all_clients_router,
fault_registration_router, get_baby_nurse_router, insert_baby_nurse_router,
reminder_router, get_client_by_room_number_router, product_router, insert_client_router,
manage_plan_router, allocate_room_router)
manage_plan_router, allocate_room_router, get_plan_by_id_router)
from fastapi.middleware.cors import CORSMiddleware

model.Base.metadata.create_all(bind=engine)
Expand All @@ -41,6 +41,7 @@
app.include_router(insert_client_router)
app.include_router(manage_plan_router)
app.include_router(allocate_room_router)
app.include_router(get_plan_by_id_router)
origins = [
"*"
]
Expand Down
32 changes: 2 additions & 30 deletions model/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,6 @@ class Client(Base):
babies = relationship("Baby", back_populates="client")


# class RemovedClient(Base):
# __tablename__ = "removed_client"
#
# id = Column(Integer, primary_key=True)
# meal_plan_id = Column(Integer)
# recovery_plan_id = Column(Integer)
# assigned_baby_nurse = Column(Integer)
# name = Column(String(255), nullable=False)
# tel = Column(String(255), nullable=False)
# age = Column(Integer, nullable=False)
# scheduled_date = Column(String(255), nullable=False)
# check_in_date = Column(String(255), nullable=False)
# hospital_for_childbirth = Column(String(255), nullable=False)
# contact_name = Column(String(255), nullable=False)
# contact_tel = Column(String(255), nullable=False)
# mode_of_delivery = Column(String(255), nullable=False)
# room = Column(String(255), ForeignKey("room.room_number"), unique=True)
# status = Column(String(255), nullable=False)


class Baby(Base):
__tablename__ = "baby"

Expand All @@ -70,16 +50,6 @@ class Baby(Base):
client = relationship("Client", back_populates="babies")


# class ClientBabyNurse(Base):
# __tablename__ = "client_baby_nurse"
#
# id = Column(Integer, primary_key=True)
# client_id = Column(Integer, ForeignKey("client.id"))
# baby_nurse_id = Column(Integer, ForeignKey("baby_nurse.baby_nurse_id"))
# start_date = Column(String(255), nullable=False)
# end_date = Column(String(255), nullable=False)
# status = Column(String(255), nullable=False)


class BabyNurse(Base):
__tablename__ = "baby_nurse"
Expand All @@ -103,6 +73,7 @@ class MealPlan(Base):
details = Column(Text)
duration = Column(Integer)
name = Column(String(255))
price = Column(DECIMAL(10, 2), default=0.00)


class RecoveryPlan(Base):
Expand All @@ -111,3 +82,4 @@ class RecoveryPlan(Base):
details = Column(Text)
duration = Column(Integer)
name = Column(String(255))
price = Column(DECIMAL(10, 2), default=0.00)
Empty file removed periodic_task/__init__.py
Empty file.

0 comments on commit bd92d46

Please sign in to comment.