A comprehensive lab report analyzer that extracts biomarkers from plain-text lab reports, normalizes values, compares against clinically-validated reference ranges, and generates patient-friendly summaries with risk flag detection and multi-report trend tracking.
HealthReportAnalyzer helps users understand their lab results by:
- Parsing lab report text to extract biomarker names, values, and units
- Classifying values against reference ranges with age/gender adjustments
- Color-coding results for quick visual assessment
- Generating plain-English summaries of abnormal findings
- Detecting risk combinations (e.g., high glucose + high HbA1c = diabetes risk)
- Tracking trends across multiple reports over time with interactive charts
- Supports 150+ biomarker name aliases (CBC, lipid panel, liver panel, kidney panel, thyroid, vitamins, electrolytes, iron studies, inflammatory markers)
- Parses multiple lab report formats:
Hemoglobin: 14.5 g/dLGlucose (Fasting) 110 mg/dL 70-100TSH = 2.5 mIU/L
- Automatic deduplication by canonical biomarker name
- 50+ biomarkers with clinically-validated reference ranges
- Age and gender-adjusted ranges
- Multi-level classification:
- Normal (green)
- Borderline Low/High (yellow)
- Low/High (red)
- Critical Low/High (dark red)
- Diabetes Risk (elevated glucose + HbA1c)
- Cardiovascular Risk (lipid panel abnormalities)
- Kidney Concern (creatinine + BUN + eGFR)
- Liver Concern (ALT + AST + bilirubin)
- Thyroid Imbalance (TSH abnormalities)
- Anemia Risk (low hemoglobin + CBC changes)
- Metabolic Syndrome Indicators
- Vitamin D Deficiency
- Electrolyte Imbalance
- Iron Overload Risk
- Track biomarker changes across multiple reports
- Chart.js line charts with reference range overlays
- Percentage change and trend direction indicators
- Compare reports side by side
- Plain English explanations of each abnormal result
- Overall health assessment (Normal, Attention, Concern, Critical)
- Actionable context for each biomarker
| Component | Technology |
|---|---|
| Backend | FastAPI (Python) |
| Database | SQLite + SQLAlchemy |
| Frontend | React-style SPA (Vanilla JS) |
| Charts | Chart.js |
| Testing | pytest + httpx |
| Deployment | Docker + docker-compose |
- Python 3.10+
- pip
chmod +x start.sh
./start.shpython -m venv venv
source venv/bin/activate # Linux/Mac
# venv\Scripts\activate # Windows
pip install -r requirements.txt
uvicorn app:app --host 0.0.0.0 --port 8027 --reloaddocker-compose up --buildThe application will be available at http://localhost:8027
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/reports/upload |
Upload report as pasted text |
| POST | /api/reports/upload-file |
Upload report as .txt file |
| POST | /api/reports/analyze |
Analyze a pending report |
| GET | /api/reports |
List all reports |
| GET | /api/reports/{id} |
Get report with biomarkers |
| GET | /api/reports/{id}/summary |
Get report summary |
| GET | /api/reports/{id}/export |
Export report as JSON |
| DELETE | /api/reports/{id} |
Delete a report |
| GET | /api/reports/compare/trends |
Compare biomarker trends |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/patients |
Create patient profile |
| GET | /api/patients |
List patient profiles |
| GET | /api/patients/{id} |
Get patient with reports |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/health |
Health check |
| GET | /api/reference-ranges |
List reference ranges |
| POST | /api/comparisons |
Save a comparison |
| GET | /api/comparisons |
List saved comparisons |
| Route | View | Description |
|---|---|---|
#/ |
Dashboard | Overview stats and recent reports |
#/upload |
Upload | Paste text or upload .txt file |
#/report/:id |
Report Detail | Biomarker table with status badges, risk flags, summary |
#/history |
History | All reports list |
#/compare |
Compare | Multi-report trend analysis with charts |
Navigate to the Upload page and either:
- Paste text: Copy your lab report text and paste it into the text area
- Upload file: Drag & drop or browse for a
.txtfile
After analysis, you will see:
- Overall assessment badge (Normal/Attention/Concern/Critical)
- Risk flags highlighting concerning combinations
- Biomarker table with color-coded status badges
- Click "Details" on any biomarker for a plain-English explanation
- Filter biomarkers by category using the pills
Upload multiple reports over time, then use the Compare view to:
- Select which reports to compare
- View trend charts for individual biomarkers
- See percentage changes and trend directions
Click "Export JSON" on any report to download the full analysis data.
Run the test suite:
python -m pytest tests/ -v --tb=shortWith coverage:
python -m pytest tests/ -v --cov=. --cov-report=term-missinghealth-report-analyzer/
|-- app.py # FastAPI entry point
|-- config.py # Configuration
|-- requirements.txt
|-- README.md
|-- Dockerfile
|-- docker-compose.yml
|-- start.sh
|-- LICENSE
|-- .gitignore
|-- .github/workflows/ci.yml
|-- models/
| |-- __init__.py
| |-- database.py # SQLAlchemy engine/session
| |-- schemas.py # ORM models
|-- routes/
| |-- __init__.py
| |-- api.py # REST API endpoints
| |-- views.py # SPA serving
|-- services/
| |-- __init__.py
| |-- report_parser.py # Biomarker text extraction
| |-- analyzer.py # Classification, risk flags, summaries
|-- frontend/
| |-- index.html
| |-- static/css/app.css
| |-- static/js/app.js
|-- tests/
| |-- conftest.py
| |-- test_api.py
| |-- test_models.py
| |-- test_services.py
| |-- test_parser.py
|-- seed_data/
|-- data.json # Sample reports
|-- reference_ranges.json # 50+ biomarker reference ranges
Stores the uploaded lab report text and analysis results.
Individual biomarker extracted from a report with classification data.
Clinically-validated reference ranges with age/gender segmentation.
Optional patient information for personalised reference ranges.
Saved comparison data between multiple reports.
Environment variables:
| Variable | Default | Description |
|---|---|---|
HRA_PORT |
8027 |
Server port |
HRA_DEBUG |
false |
Debug mode |
DATABASE_URL |
sqlite:///... |
Database URL |
SECRET_KEY |
(dev key) | Application secret |
This application is for informational purposes only and does not constitute medical advice. Always consult with a qualified healthcare professional for interpretation of lab results and medical decisions.
MIT License. See LICENSE for details.