CoolFace
Apppublic

Distopia22/Icd-cpt-coding-api

sourceHugging Facemitupdated 10mo agoView on Hugging Face
0likes
routes.py34 linesDownload Raw Back to api
1from fastapi import APIRouter, HTTPException2import sys3import os4 5# Add parent directory to path for imports6sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))7 8from models.request_models import ProviderNotesRequest9from models.response_models import CodingResponse10from services.groq_service import groq_service11 12router = APIRouter(prefix="/api/v1", tags=["Medical Coding"])13 14@router.post("/analyze", response_model=CodingResponse)15async def analyze_provider_notes(request: ProviderNotesRequest):16    """17    Analyze provider notes and return ICD-10 and CPT codes with explanations.18    19    - **provider_notes**: The medical provider notes to analyze20    21    Returns ICD-10 codes, CPT codes, and explanations for each.22    """23    try:24        result = await groq_service.analyze_provider_notes(request.provider_notes)25        return CodingResponse(**result)26    except ValueError as e:27        raise HTTPException(status_code=422, detail=str(e))28    except Exception as e:29        raise HTTPException(status_code=500, detail=f"Internal server error: {str(e)}")30 31@router.get("/health")32async def health_check():33    """Health check endpoint"""34    return {"status": "healthy", "service": "ICD-CPT Coding API"}