# STI e-Health Backend — Eswatini
Flask API with ML-Enhanced Decision Support + E-Prescription Module
## Setup & Run
```bash
# 1. Install dependencies
pip install -r requirements.txt
# 2. Start the API server
python app.py
# Runs on
localhost
```
## (Optional) Train the ML model
```bash
python ml_model.py
# Trains Logistic Regression, Decision Tree, Random Forest
# Saves best model to sti_model.pkl
```
## API Endpoints
| Method | Endpoint | Description |
|--------|-----------------------------------|--------------------------------|
| GET | /api/health | Health check |
| GET | /api/symptoms | List symptom categories |
| GET | /api/risk-factors | List risk factors |
| POST | /api/assess | Run ML assessment |
| POST | /api/prescription | Generate e-prescription |
| POST | /api/prescription/ /verify | Pharmacy verify prescription |
| POST | /api/prescription/ /dispense | Mark prescription as dispensed |
| GET | /api/stats | Dashboard statistics |
## Example: POST /api/assess
```json
{
"symptoms": ["vaginal_discharge", "itching_vagina"],
"risk_factors": ["unprotected_sex", "new_partner_3months"],
"demographics": { "sex": "female", "age": 24, "pregnant": false, "hiv_positive": false }
}
```