📄 body_parts.py 3,215 bytes Sunday 03:08 📋 Raw

"""
Body Parts API Endpoints
GET /api/v1/body-parts - Returns body part categories for sideline entry picker
"""
from typing import List
from fastapi import APIRouter, Depends
from pydantic import BaseModel
from sqlalchemy.orm import Session

from app.database import get_db
from app.auth import get_current_user, require_role

router = APIRouter(tags=["body-parts"])

============== SCHEMAS ==============

class BodyPart(BaseModel):
"""Individual body part"""
id: str
label: str
icon: str

class BodyPartCategory(BaseModel):
"""Category of body parts"""
name: str
parts: List[BodyPart]

============== DATA ==============

Body parts hierarchy matching the frontend picker

BODY_PARTS_DATA: List[BodyPartCategory] = [
BodyPartCategory(
name="Head & Neck",
parts=[
BodyPart(id="head", label="Head", icon="🧠"),
BodyPart(id="face", label="Face", icon="😷"),
BodyPart(id="neck", label="Neck", icon="ðŸĶ’"),
BodyPart(id="concussion", label="Concussion", icon="🧠"),
]
),
BodyPartCategory(
name="Upper Body",
parts=[
BodyPart(id="shoulder", label="Shoulder", icon="💊"),
BodyPart(id="upper_arm", label="Upper Arm", icon="💊"),
BodyPart(id="elbow", label="Elbow", icon="ðŸĶī"),
BodyPart(id="forearm", label="Forearm", icon="💊"),
BodyPart(id="wrist", label="Wrist", icon="⌚"),
BodyPart(id="hand", label="Hand", icon="✋"),
BodyPart(id="fingers", label="Fingers", icon="👆"),
BodyPart(id="chest", label="Chest", icon="ðŸŦ"),
BodyPart(id="upper_back", label="Upper Back", icon="↕ïļ"),
]
),
BodyPartCategory(
name="Lower Body",
parts=[
BodyPart(id="hip", label="Hip", icon="ðŸĶī"),
BodyPart(id="groin", label="Groin", icon="ðŸĐģ"),
BodyPart(id="thigh", label="Thigh", icon="ðŸĶĩ"),
BodyPart(id="knee", label="Knee", icon="ðŸĶĩ"),
BodyPart(id="shin", label="Shin", icon="ðŸĶĩ"),
BodyPart(id="calf", label="Calf", icon="ðŸĶĩ"),
BodyPart(id="ankle", label="Ankle", icon="ðŸĶķ"),
BodyPart(id="foot", label="Foot", icon="ðŸĶķ"),
BodyPart(id="toes", label="Toes", icon="ðŸ‘Ģ"),
BodyPart(id="lower_back", label="Lower Back", icon="↕ïļ"),
]
),
BodyPartCategory(
name="Other",
parts=[
BodyPart(id="abdomen", label="Abdomen", icon="ðŸŦƒ"),
BodyPart(id="ribs", label="Ribs", icon="🍖"),
BodyPart(id="general", label="General/Illness", icon="ðŸĪ’"),
]
),
]

============== ROUTER ENDPOINTS ==============

@router.get("", response_model=List[BodyPartCategory])
async def get_body_parts(
db: Session = Depends(get_db),
current_user = Depends(require_role(["at", "coach", "admin"])),
):
"""
Get body part categories and parts for the sideline entry picker

Returns a hierarchical list of body part categories and their parts
with icons for the 3-tap sideline entry flow.
"""
return BODY_PARTS_DATA