When “IPF” Doesn’t Mean IPF: The Hidden Problem With Clinical Coding
Imagine building a dataset of thousands of patients with idiopathic pulmonary fibrosis. The codes are there. The data looks clean. The cohort is ready.
But what if up to one in three of those patients doesn’t actually have IPF?
That’s not hypothetical — it’s what a recent validation study found. And it has a direct implication for anyone using routinely collected health data to study this disease: the algorithm you choose matters, and not all of them are good enough.
Why IPF is a harder coding problem than most
Routinely collected healthcare data has transformed epidemiological research. For most conditions — particularly those managed in primary care — simple lists of clinical codes reliably identify cases. Validation studies have confirmed this repeatedly.
IPF is different. It’s rare, progressive, and almost exclusively diagnosed and managed in secondary care, a setting where the robustness of coding for research purposes is much less well understood. Before Morgan and colleagues undertook this study, researchers using coded data to build IPF cohorts were largely doing so without a clear evidence base for which approach to trust.
What the study did
Ann Morgan’s team used the UK’s Clinical Practice Research Datalink (CPRD) Aurum dataset — primary care records linked to national hospital admissions and cause-of-death data — to evaluate eight diagnostic algorithms. Each combined clinical codes from primary and secondary care (SNOMED-CT or ICD-10) with or without additional supporting evidence.
To measure accuracy, they used death records as the gold standard, estimating the positive predictive value (PPV) of each algorithm: the proportion of coded cases that genuinely had IPF. They also tracked how coding practices changed across the study period, from 2008 to 2018, in a dataset of 17,559 individuals with at least one IPF-indicative record.
What they found
The results varied considerably depending on the algorithm used.
Algorithms relying on clinical codes alone produced PPVs ranging from 64.4% for a broad code set to 74.9% for a narrow set of highly specific codes. In practical terms, even the better-performing code-only approach misidentified roughly one in four patients.
Adding confirmatory evidence changed the picture — but not always in a useful direction. Requiring a CT scan alongside the diagnostic code pushed PPV up to 79.2%, but reduced sensitivity to under 10%. That means the algorithm correctly identified IPF in a higher proportion of flagged cases, but missed the vast majority of actual patients entirely. For most research purposes, a sample that small is of limited use.
The more promising finding involved hospitalisation data. Adding evidence of hospitalisation to the broad code-based algorithm improved PPV from 64.4% to 78.4%, while keeping sensitivity at 53.5% — a meaningful improvement in accuracy without the severe loss of sample size that came with CT confirmation.
The trade-off at the heart of algorithm design
This is the fundamental tension the study exposes: precision versus reach. Tighten your criteria and your sample gets cleaner but smaller. Loosen them and you capture more patients but introduce more noise. Every algorithm is a trade-off, and the right balance depends on what your research question actually requires.
What this study does is give researchers a basis for making that choice deliberately rather than by default.
Coding practices are improving — with a caveat
The study also found that IPF coding has evolved over the study period, with clinicians increasingly using IPF-specific codes rather than broader respiratory categories. That’s a positive development for data quality going forward.
But it creates a complication for longitudinal research. If coding practices changed substantially between 2008 and 2018, historical and more recent data may not be directly comparable. Researchers examining trends over time need to account for this, or risk attributing changes in coding behaviour to changes in disease incidence or outcomes.
What the study recommends
The study’s conclusion is specific and practical: for most research purposes, the best approach is a broader IPF code set combined with evidence of hospitalisation. This combination achieved a PPV of 78.4% while retaining a sensitivity of 53.5% — a reasonable balance between diagnostic accuracy and usable sample size, and one that doesn’t require the kind of additional clinical evidence that would make the algorithm difficult to apply at scale.
The CT-confirmed algorithm, despite its higher PPV, is not recommended for general use precisely because its sensitivity is so low as to make the resulting cohort unrepresentative.
What this means for researchers and coders
A few things follow from this directly.
Validation is not optional. Before using coded data to answer a clinical question, the algorithm needs to have been tested. PPV alone is not enough — sensitivity matters too, and the right balance depends on your research design.
Secondary care coding deserves more scrutiny. Most validation literature focuses on primary care. For rare, specialist-managed conditions like IPF, that evidence base doesn’t transfer, and assumptions built on it may not hold.
The way conditions are coded shapes what research is possible. A narrowly coded condition with poor sensitivity limits the questions you can ask. Improving coding specificity over time — as appears to be happening with IPF — is not just an administrative improvement, it’s a research infrastructure one.
The bottom line
Clinical coding is a powerful tool for population-level research, but its reliability isn’t uniform across conditions or settings. For IPF, Morgan and colleagues have done the field a genuine service: they’ve identified which algorithms work, which don’t, and — crucially — which one to use.
The answer isn’t to distrust coded data. It’s to understand exactly what your data is telling you, choose your algorithm deliberately, and know the trade-offs you’re accepting.
Trust the system. But know what you’re trusting, and why.