Inspiration
Every year India loses viable donor organs, not because nobody needs them but because they don't reach the right patient in time. A heart has about 4 hours of cold ischaemia time and a liver about 12. When a transplant coordinator has to weigh blood group, tissue match, urgency, hospital capacity and distance by hand across dozens of hospitals, the clock usually wins. We wanted to build the tool we'd want a coordinator to have: one screen that shows every clock that's ticking, and a system that recommends the best match before time runs out.
What it does
HaemoRL is a hospital-style command center for organ and blood allocation across India's transplant network.
- Command Center: live critical-patient count, running ischaemia clocks, organ queue, blood stock and the busiest hospitals, on one calm dashboard.
- Ischaemia clocks: every critical patient has a live countdown. When an organ offer lapses it's logged as a missed offer, so the loss is never invisible.
- Smart matching: a reinforcement-learning environment scores every patient → donor → hospital pairing, and an agent recommends the best one.
- India Hospital Network: an interactive map drawn to India's official boundary. Tap it to zoom into any of 20 transplant centres and see live load, free beds and ICU capacity.
- Donors, blood bank & HLA matrix: organ availability, blood stock and 6-antigen tissue compatibility in one place.
- Kidney paired exchange: finds 2-way and 3-way swap chains for incompatible living-donor pairs.
- AI assistant: an optional LLM explains decisions and answers clinical questions. Without one, a deterministic rule-based engine keeps everything working.
How we built it
- Backend: Python + FastAPI, with a REST API, a WebSocket for live updates and an in-memory database persisted to JSON.
- RL environment: a standard
reset → step → gradeAPI with three graded tasks:single_match(easy),batch_allocation(medium) andcrisis_routing(hard, with trauma arrivals and overloaded hospitals). - Reward: an 8-component shaped reward in \([-1, 1]\):
$$ R = R_{blood} + R_{HLA} + R_{isch} + R_{paed} + R_{hosp} + R_{surv} + R_{geo} + R_{expiry} $$
It covers ABO compatibility, 6-antigen HLA match, urgency of the ischaemia clock, NOTTO paediatric priority (with PELD), hospital load and ICU availability, a survival estimate (MELD/PELD, CD4, EF, FEV1), transport distance, and a capped penalty for organs lost to delay.
- Agents: our composite policy averages +0.56 reward per step, against +0.29 for an urgency-only heuristic and +0.02 for random.
- Frontend: a single-page app in plain HTML/CSS/JS with Chart.js, a clinical light/dark design system, and an SVG India map we converted from official-boundary GeoJSON. It has a custom zoom/pan explorer and no map service dependency.
- Quality: a pytest suite (35 tests) with regression tests for every bug we fixed. Tests run on an isolated temp database.
Challenges we ran into
- Honest simulation: our first version counted the same expired organ on every step, and the penalty grew without limit, so rewards collapsed to −1. We rebuilt the clock so each lapse is counted exactly once and the patient gets a fresh window.
- Fairness math: our Gini fairness metric was returning negative values. Finding and fixing the formula taught us to test every metric against known answers.
- The map: common open datasets draw India with incorrect borders. We sourced official-boundary data, simplified it about 5× while keeping neighbouring states gap-free, and embedded it so the page works offline.
- Simplicity: the app once had 25 menu items. We cut it to 8 grouped sections so a coordinator under pressure never has to hunt.
Accomplishments that we're proud of
- An RL environment where a smart policy measurably beats the baselines.
- A dashboard that looks and feels like a real hospital system, in both light and dark mode.
- An India map that is both correct and fully interactive.
What we learned
Reward design is the whole game in RL: one wrong clamp or double-count and the agent learns nonsense. We also learned that in healthcare tools, clarity beats features. Fewer, calmer screens make faster decisions possible.
What's next for HaemoRL
- Connect every page to live hospital data instead of demo data.
- Secure logins with coordinator and admin roles, plus a full audit trail of every allocation decision (who, when and why), as NOTTO compliance requires.
- A real database and train a learned policy on the environment.
- Pilot with a regional transplant network (ROTTO/SOTTO).
Built With
- chart.js
- css3
- docker
- fastapi
- geojson
- html5
- httpx
- javascript
- pydantic
- pytest
- python
- reinforcement-learning
- svg
- uvicorn
- websockets
Log in or sign up for Devpost to join the conversation.