"""
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