edin-guso/selected-work/01
cd ..

Mapping free text to a million medical codes

To find patients in health records, you first need to know which codes stand for a disease, a symptom or a treatment. Across the coding systems we work with there are over a million diagnosis, procedure and drug codes, and building these lists by hand was slow and hard to repeat.

I designed and built a GenAI system that drafts these code lists, so experts review a draft instead of starting from nothing. It was first used on a real programme within two months of starting, and since then I have kept improving it for several clients and disease programmes, until it became a tested part of our main platform.

At the start there was no measure of correctness, so every change was a guess. I introduced evaluation against expert-curated golden mappings, with precision and recall per concept, so that prompt and model changes could be compared on evidence. Each matching rule can be switched off, so its contribution can be measured on its own.

Scale was the other problem. The first version ran out of memory after a few thousand codes, so it could only work on small subsets. I rewrote the heavy parts so the system runs on the full set of over a million codes, and checked that in a full-scale simulation before relying on it.

When I moved the system into the platform, I gave it typed configuration, so bad settings fail at start-up, over 1,000 unit tests and an offline mode, so CI runs it end to end without paying for API calls. I also made it serve different clients and coding systems through configuration instead of separate code.