CoolFace
Apppublic

Distopia22/medical-coding-api

sourceHugging Facemitupdated 10mo agoView on Hugging Face
0likes
App README

๐Ÿฅ Medical Coding API

AI-powered API for extracting ICD-10 and CPT codes from clinical provider notes using Microsoft Phi-3.

๐Ÿš€ Features

  • โ€”โœ… Extract ICD-10 diagnosis codes
  • โ€”โœ… Extract CPT procedure codes
  • โ€”โœ… Supports notes up to 10,000 characters (~2,500 words)
  • โ€”โœ… JSON output format
  • โ€”โœ… GPU-accelerated inference (when available)
  • โ€”โœ… Automatic text truncation
  • โ€”โœ… Production-ready with error handling

๐Ÿ“ก API Endpoints

POST /predict

Extract medical codes from clinical note.

Request:

json
{
  "note": "Your clinical note here..."
}

Response:

json
{
  "result": {
    "icd10_codes": ["I10", "E11.9"],
    "cpt_codes": ["99213"]
  },
  "raw_output": "...",
  "note_length": 250,
  "truncated": false,
  "processing_time": 3.45
}

GET /health

Check API health status.

GET /docs

Interactive API documentation (Swagger UI).

๐Ÿงช Usage Examples

cURL

bash
curl -X POST "https://YOUR-SPACE.hf.space/predict" \
  -H "Content-Type: application/json" \
  -d '{"note": "Patient with HTN, BP 160/95. Prescribed lisinopril."}'

Python

python
import requests

response = requests.post(
    "https://YOUR-SPACE.hf.space/predict",
    json={"note": "Patient with diabetes, HbA1c 8.2. Started metformin."}
)
print(response.json())

JavaScript

javascript
fetch("https://YOUR-SPACE.hf.space/predict", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ note: "Clinical note here..." }),
})
  .then((res) => res.json())
  .then((data) => console.log(data));

โš™๏ธ Technical Details

  • โ€”Model: RayyanAhmed9477/med-coding (Phi-3 based)
  • โ€”Framework: FastAPI + Transformers
  • โ€”Deployment: HuggingFace Spaces (Docker)
  • โ€”First Request: 30-60 seconds (model loading)
  • โ€”Subsequent Requests: 2-10 seconds

๐Ÿ“ License

MIT License