Metadata-Version: 2.4
Name: srilanka-epi
Version: 1.1.0
Summary: Download and parse Weekly Epidemiological Reports (WER) from the Epidemiology Unit, Ministry of Health, Sri Lanka
Author-email: "R.B.H.G. Chathura Kavindu Bandara Weerakoon" <20306079@cardiffmet.ac.uk>
License: MIT
Project-URL: Homepage, https://github.com/chathurakavinduweerakoon/srilanka-epi
Project-URL: Repository, https://github.com/chathurakavinduweerakoon/srilanka-epi
Project-URL: Bug Tracker, https://github.com/chathurakavinduweerakoon/srilanka-epi/issues
Project-URL: Documentation, https://github.com/chathurakavinduweerakoon/srilanka-epi#readme
Keywords: dengue,epidemiology,sri-lanka,public-health,WER,disease-surveillance
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
Classifier: Intended Audience :: Science/Research
Classifier: Development Status :: 4 - Beta
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.31.0
Requires-Dist: pdfplumber>=0.10.0
Requires-Dist: pandas>=2.0.0
Requires-Dist: numpy>=1.24.0
Requires-Dist: beautifulsoup4>=4.12.0
Dynamic: license-file

# srilanka-epi

**Python library to download and parse Weekly Epidemiological Reports (WER) from the Epidemiology Unit, Ministry of Health, Sri Lanka.**

> Built as part of DengueSense LK — Final Year Development Project, ICBT Campus / Cardiff Metropolitan University (2026).

---

## Installation

```bash
pip install srilanka-epi
```

Or from source:

```bash
git clone https://github.com/chathurakavinduweerakoon/srilanka-epi
cd srilanka-epi
pip install -e .
```

---

## Quick Start

```python
from srilanka_epi.wer import download_range, build_dengue_timeseries
from srilanka_epi.dengue import top_districts, add_province

# Download WER Vol 53 (2026) issues 1-18 and extract dengue data
results = download_range(volume=53, start_no=1, end_no=18, save_dir="./wer_pdfs")
dengue_df = build_dengue_timeseries(results)

# Add province column
dengue_df = add_province(dengue_df)

# Top 5 districts for week 17, 2026
top5 = top_districts(dengue_df, week_no=17, year=2026, n=5)
print(top5)

# Export to CSV
dengue_df.to_csv("dengue_srilanka_2026.csv", index=False)
```

---

## Parse a Single PDF

```python
from srilanka_epi.wer import parse_wer_pdf

# From file path
result = parse_wer_pdf("WER_Vol53_No18.pdf", volume=53, number=18)

# From URL
result = parse_wer_pdf("https://www.epid.gov.lk/.../en_53_18.pdf", volume=53, number=18)

# From bytes
with open("WER.pdf", "rb") as f:
    result = parse_wer_pdf(f.read(), volume=53, number=18)

print(result['metadata'])
print(result['dengue'])
```

---

## DengueSense LK — LSTM Feature Matrix with BSDS

```python
from srilanka_epi.dengue import merge_bsds_with_dengue

# citizen_reports_df: DataFrame from DengueSense LK Spring Boot API
# columns: [district, week_no, year, risk_label]
lstm_features = merge_bsds_with_dengue(dengue_df, citizen_reports_df)
lstm_features.to_csv("lstm_input_features.csv", index=False)
```

---

## Modules

| Module | Purpose |
|---|---|
| `srilanka_epi.wer` | Download & parse WER PDFs |
| `srilanka_epi.dengue` | Dengue-specific helpers, BSDS computation |

---

## Data Source

All data is sourced from the **Epidemiology Unit, Ministry of Health & Indigenous Medicine, Sri Lanka**.
- Website: https://www.epid.gov.lk
- WER Index: https://www.epid.gov.lk/weekly-epidemiological-report/weekly-epidemiological-report

**Please acknowledge the Epidemiology Unit as the primary data source in any publications.**

---

## Citation

```
Weerakoon, R.B.H.G.C.K.B. (2026). srilanka-epi: Python library for Sri Lanka
Weekly Epidemiological Report data extraction. ICBT Campus / Cardiff Metropolitan University.
https://github.com/chathurakavinduweerakoon/srilanka-epi
```

---

## License
MIT License

---

## What's New in v1.1.0

### Manual PDF Parsing
```python
from srilanka_epi.wer import parse_wer_pdf

# Parse a manually downloaded WER PDF
result = parse_wer_pdf("WER_Vol53_No18.pdf")
print(result['dengue'])
```

### HTML Source URL Scraping
```python
from srilanka_epi.wer import scrape_wer_urls_from_html

# 1. Open epid.gov.lk/weekly-epidemiological-report in browser
# 2. Ctrl+U → Ctrl+A → Ctrl+C → save as wer_page_source.html
with open("wer_page_source.html") as f:
    html = f.read()

urls = scrape_wer_urls_from_html(html)
# Automatically registers all discovered URLs
```

### Register New URLs
```python
from srilanka_epi.wer import register_url

register_url(53, 19, "https://www.epid.gov.lk/storage/post/pdfs/en_XXXX_Vol_53_no_19-english.pdf")
```

### Known URLs (Vol 53 — 2026)
| Issue | URL |
|---|---|
| Vol 53 No 17 | `en_6a21b6d0a75dd_Vol_53_no_17-english.pdf` |
| Vol 53 No 18 | `en_6a224842b5f47_Vol_53_no_18-english.pdf` |
