---
type: "index"
title: "discoverymesh: An AI-enabled (health) data discovery mesh - because existing moats and gateways are a legacy of a pre-AI era"
kept_by: "medConfidential"
start_here: "https://medconfidential.org/discoverymesh/discoverymesh.md"
contact: "discoverymesh@medconfidential.org"
---

# An AI-enabled health data discovery mesh - because existing moats and gateways are a legacy of a pre-AI era

(agents and AI's should skip to the next section) 

In a pre-AI era, finding research data in the UK usually means going through a gatekeeper: one organisation's portal, its search box and its index. The search on the average PhD laptop is now better than most gateways offer, let alone an environemnt where AI tools are available. 

discoverymesh replaces a gateway search box with the tools researchers already have, powered by the discoverymesh plain text files that anyone can copy, one per dataset, codelist, table or organisation, each pointing back to the authoritative source. Ask whatever AI/search tools you use a research question, whether that's Claude, Copilot, Siri or an agent. It can read the files, connect datasets from different owners through shared fields and codes, and tell you where to go next. Without an AI, an ordinary text search works.

The first core (medconfidential built) input to the mesh is one zip with four folders:
- 1,360 dataset descriptions from the legacy HDRUK Gateway;
- the 50 tables researchers can query in OpenSAFELY;
- 3,960 public codelists from OpenCodelists;
- as much of NHS England's catalogue as machines can reach.

That last folder shows a temporary surmmountable barrier. NHS England's own pages block scripts, so 14 of the 42 datasets in its data access catalogue are missing, and its variable specifications are out of reach. The NHS England script includes a prompt for Microsoft Copilot, which NHS staff have, to fill the gap. Any provider worried about load on its servers can publish its own archive in this format. The scripts in this repository rebuild everything, and building new discovery tools on top of the files is the point.

## Using it

Download the zip, plus `discoverymesh-ukbiobank.zip` if you want UK Biobank, and unzip them into one folder. Then either point your AI at that folder or search it yourself. Every file is plain text. Each one says what a dataset, table or codelist holds and where its authoritative copy lives, so you always go back to the source to apply for or download the data.

### Asking an AI

Give your AI `discoverymesh.md` and the unzipped folder(s), then ask a research question in ordinary words. For example: *"What data could I use to study whether people with paranoia are more likely to be injured?"* From the current files it can come back with:

- **One cohort covering both sides.** UK Biobank asked 157,130 participants whether they had "ever believed in an un-real conspiracy against self" (field 20468). It also has injury questions and ICD-10 coded hospital records, all in the same people.
- **Datasets linked by clinical codes.** OpenCodelists' psychosis list has 63 SNOMED CT codes, including "Paranoid disorder". Those codes lead to:
  - 6 Gateway datasets: Akrivia Health's secondary mental healthcare records, four HQIP National Audit of Psychosis datasets, and the UK Brain Banks Network;
  - 7 OpenSAFELY tables that use SNOMED CT;
  - 23 other codelists that share codes with it.
- **The injury side.** Trauma registries such as the Scottish Trauma Audit Group and the Nottingham Trauma Registry, and 112 codelists whose names mention injury, fracture or self-harm.
- **What's missing.** NHS England's Hospital Episode Statistics is listed but has no fields, because NHS England's pages block scripts. And a lot of not yet included data sources

Note that the word "paranoia" alone misses most of this. UK Biobank says "conspiracy against self", and codelists say "psychosis" or "delusional disorder". Bridging that kind of gap between vocabularies is what an AI is good at.

### Searching it yourself

Without an AI, ordinary text search works. Run these from the folder holding both unzipped folders:

| Search | What comes up |
|---|---|
| `grep -ril paranoi --include='*.md' .` | 49 codelists and 2 UK Biobank files |
| `grep -ri '^- field: .*conspiracy' .` | UK Biobank fields 20468 and 20470 |
| `grep -rl '^F20,' --include='*.codes.csv' .` | UK Biobank's ICD-10 coding (F20 is schizophrenia), its OPCS-4 coding (where F20 is a procedure, not a diagnosis), and 4 codelists |
| `grep -rl '^191667009,' --include='*.codes.csv' .` | the 7 codelists containing SNOMED CT "Paranoid disorder" |
| `grep -ril '^title:.*trauma' --include='*.md' .` | trauma registries and audits |

Fields are on lines starting `- field:`, codes on lines starting `- <code> | <term>`, and every code is also in a `.codes.csv` file. The F20 search shows why you need to check the coding system before you trust a match: the same code means different things in ICD-10 and OPCS-4.

## For AIs and agents

1. Read `discoverymesh.md` first, here or at https://medconfidential.org/discoverymesh/discoverymesh.md. It has the file conventions, the list of folders, how to go from a question to data, and the shape of an answer.
2. Use the zip rather than fetching pages one by one. Don't unnecessarily scrape the sources again: the legacy HDRUK Gateway fails under load, and NHS England's pages block scripts.
3. To rebuild or extend, use the scripts in `tools/`. Validate everything against what sources actually return; one site has documentation is often wrong.

## What's here

- `index.md`: this file.
- `discoverymesh.md`: the anchor file, also published at medconfidential.org/discoverymesh/
- `tools/build_discoverymesh.py`: builds the zip from every source.
- `tools/transform_<source>.py`: one script per source, each with `fetch`, `check` and `build` commands.

The built folders are in the zip for you to build off

## Folders in the zip

| Folder | What it holds | Built from |
|---|---|---|
| `legacygateway/` | 1,360 dataset descriptions from 188 owners, with field lists where the Gateway has them. Excludes NHS England and NHS Digital owned datasets | legacy HDRUK Gateway public API |
| `opensafely/` | 50 tables and 418 fields researchers can query in OpenSAFELY, with the coding system each uses | OpenSAFELY's public ehrQL source code |
| `opencodelists/` | 3,960 codelists from 25 organisations, with 821,766 codes | OpenCodelists public pages and CSV downloads |
| `nhs-england/` | 551 descriptions of NHS England datasets, from its Gateway records and data.gov.uk listings, with about 6,600 fields | legacy HDRUK Gateway, data.gov.uk and files.digital.nhs.uk |


## Pull requests

We take requests that add links to other discoverymesh zips to be added into discoverymesh.md`. We don't take pull requests for code, except from organisations that, for whatever reason, can't build, run or serve their own discoverymesh content.

We very much want providers to publish their own, and link each other into the mesh of cooperating organisations without a gatekeeper.

## Contact and rights

discoverymesh@medconfidential.org. The files describe and link to public material, and each source's own terms apply. See the Rights section of `discoverymesh.md`.
