Catching Outbreaks Before They're Obvious: Building Outbreak Signal Service on DHIS2
2026-11-16 · 6 min read
Most district health teams already enter their weekly surveillance numbers into DHIS2. The data is there. What's usually missing is something watching it continuously and saying, clearly, "this week's malaria count in this district doesn't look like the last twelve weeks, go look at it."
That's what Outbreak Signal Service does. It's an open-source Spring
Boot service that pulls weekly surveillance data straight from DHIS2, runs
five statistical aberration-detection algorithms on it automatically, and
turns the result into alerts someone can actually act on, over a REST API,
signed webhooks, email, and real FHIR DetectedIssue resources.
The full walkthrough above shows the service and its companion DHIS2 app end to end.
The problem with watching surveillance data by hand
Routine disease surveillance in DHIS2 produces a weekly number per district, per disease. Multiply that across dozens of districts and a handful of reportable diseases, and nobody is realistically eyeballing every series, every week, for a one-off spike or a slow, sustained climb that only looks obvious in hindsight. That's exactly the kind of pattern-matching a computer is good at and a tired reviewer is not.
What it actually does
- Syncs weekly observations from DHIS2 on a schedule (daily by default), idempotently, coordinated with ShedLock so only one running instance ever syncs at a time.
- Runs five detection strategies right after every sync, each hand-verified against independently computed fixtures: moving-average Z-score, the CDC's EARS C1/C2/C3, and a one-sided CUSUM.
- Creates an alert idempotently whenever one of them fires, with an
explicit review lifecycle (
OPEN→ACKNOWLEDGED→RESOLVED/DISMISSED), optimistic locking so two reviewers can't silently overwrite each other, and a full history of who reviewed what, when. - Notifies people who should know: a transactional outbox fans every alert out as a signed webhook (at-least-once, retried, dead-lettered after a configured attempt limit) and an email, to a general ops address plus anyone registered for that alert's specific org unit.
- Speaks FHIR: every alert also maps to a read-only
DetectedIssue, content-negotiated as real FHIR JSON, with an honestCapabilityStatement. - Ships as a signed, non-root Docker image with Prometheus metrics,
structured logs, and a
GET /actuator/healththat means what it says.
The five algorithms, and why five
A single threshold rule misses too much of what an outbreak actually looks like, because outbreaks don't all arrive the same shape. Some spike hard in a single week. Some build slowly over a month. So this uses five, each with a different sensitivity-to-noise trade-off, from the video above:
| Algorithm | Baseline window | Catches |
|---|---|---|
| Moving-average Z | 12 weeks | The simplest "is this week unusual" check; conservative, slow to react to a gradual rise |
| EARS C1 | 7 weeks, no gap | Fast trigger on a sudden spike; its own baseline gets contaminated if the outbreak already started |
| EARS C2 | 7 weeks, 2-week gap | Same idea as C1, with a guard band so a rise already underway can't inflate its own baseline |
| EARS C3 | C2's z-scores, summed over 3 weeks | Catches a slow, sustained rise that never spikes hard enough to trip C1 or C2 alone |
| CUSUM | 8-week reference, fixed once | The strictest of the five; slowest to fire on noise, but a sustained rise trips it eventually |
Does it actually work? The backtest
Nothing here is tuned after the fact. Against a synthetic 104-week series with a seasonal baseline and a 4-week outbreak ramp injected into 200 independent replicates, each algorithm running its own production default configuration:
| Algorithm | Sensitivity | False-alarm episodes / 100 weeks | Median detection delay |
|---|---|---|---|
| Moving-average Z | 65.0% | 1.11 | 2.0 weeks |
| EARS C1 | 58.5% | 2.13 | 2.0 weeks |
| EARS C2 | 80.5% | 1.94 | 2.0 weeks |
| EARS C3 | 88.5% | 1.71 | 2.0 weeks |
| CUSUM | 87.5% | 1.71 | 2.0 weeks |
EARS C3 and CUSUM both catch roughly nine out of ten injected outbreaks at about the same false-alarm rate as the others, with a median two-week detection delay. The full methodology, including why CUSUM's raw per-week false-alarm count looks worse than its actual episode count, is in RESULTS.md on GitHub, reproducible with one test command.
A control panel inside DHIS2
The service is useful on its own through its REST API, but most reviewers live inside DHIS2, not in an API client. Outbreak Signal Manager is the companion DHIS2 app from the video: configure a Route to the service once, then trigger a sync or detection run, filter and browse every alert by org unit, algorithm, or severity, open one to see its weekly trend and review history, and manage who gets notified for which org unit, all without leaving DHIS2.
What it's built with
Spring Boot 4.1 on Java 25, a PostgreSQL schema managed by Flyway with
constraints that reject duplicate weeks and bad data at the database level,
an OAuth2 resource server backed by Keycloak (roles read straight from its
realm_access.roles claim), and RFC 9457 problem responses that never leak
a stack trace. The DHIS2 app side is a small React control panel calling
back into that same API.
What this is not
An alert from this service is a statistical signal for a person to review. It is not a confirmed outbreak, and it doesn't claim to be. See ETHICS.md in the repo for what the software is, what it isn't, and its known limits.
Frequently asked questions
Is this a confirmed-outbreak detector? No. Every alert is a statistical signal computed against recent history for a person to review, not a diagnosis or a confirmed outbreak. See ETHICS.md for the full scope and known limits.
What is EARS, and why five different algorithms instead of one? EARS (Early Aberration Reporting System) is a family of simple z-score-based outbreak detection methods originally developed by the US CDC. Outbreaks don't all have the same shape, some spike in a single week, others build slowly over a month, so this service runs five algorithms (moving-average Z, EARS C1/C2/C3, and CUSUM) in parallel rather than picking just one.
Can I run this against my own DHIS2 instance?
Yes. outbreak.dhis2.base-url and its credentials are plain configuration;
by default it points at the public DHIS2 demo so anyone can try it without
setting up an instance first.
Is the source code and the backtest reproducible? Both are public. The service and the DHIS2 app are on GitHub below, the detection backtest is a single test command, and RESULTS.md has the full numbers unedited.
Dig in
- Service source, Docker image, full docs: github.com/khalilurrrahmanridoykhan/outbreak-signal-service
- DHIS2 app source: github.com/khalilurrrahmanridoykhan/dhis2-outbreak-signal-manager
- Live backend: running in production at
outbreak.krrkhan.com