Skip to main content
Toggle menu

Search the website

Introducing ‘diabetes-algo’ - A reusable action for OpenSAFELY users

Posted:
Written by:
  • Alain Amstutz
Categories:

Over 5 million people in the UK are estimated to live with diabetes. Of these, around 90% have type 2 diabetes, 8% have type 1, and the remaining 2% are affected by rarer types, including gestational diabetes.

Given its prevalence, diabetes research is a top research priority for NHS England, and so it is for OpenSAFELY - including the impact of COVID-19 on diabetes. Beyond diabetes-focused studies, the condition frequently appears as a key comorbidity in other research projects. For example to define study populations, address confounding, or when characterizing COVID-19.

The challenge: Identifying diabetes types in routine data

Determining the exact type of diabetes using routinely collected health data is far from straightforward. It involves interpreting a complex web of:

  • Diagnostic codes (for example, ICD-10 E11 for type 2 diabetes, or SNOMED 46635009 for type 1 diabetes)
  • Process codes (for diabetes treatment monitoring, etc.)
  • Laboratory test codes (such as HbA1c)
  • Medication prescription codes

To complicate things further, a single patient might have conflicting records - for instance, type 1 in primary care and type 2 in secondary care.

The solution: Adjudication algorithms

Fortunately, clever adjudication algorithms have been developed to assign the most likely diabetes type using routinely collected UK health data. One example is the algorithm developed by Sophie Eastwood and colleagues.

For project #175 where type 2 diabetes is a key eligibility criterion we implemented this algorithm in OpenSAFELY and quickly realized it could help other researchers, too.

Introducing ‘diabetes-algo’: A reusable action for OpenSAFELY users

Together with collaborators in Bristol and at the Bennett Institute, we created a reusable action called ‘diabetes-algo’. Here is what it does:

  1. Accepts 21 diabetes-related codes (diagnoses, processes, HbA1c [glycated hemoglobin A1C test, indicating the average blood glucose level of the last 2-3 months], medications, age, ethnicity)
  2. Applies the adjudication algorithm
  3. Returns the most likely diabetes type (or none/unlikely) for each person
  4. Adds the result back to the input dataset

This can be particularly useful when your OpenSAFELY project needs diabetes type as a key exposure, eligibility criterion, confounder or outcome. For a demonstration, have a closer look at the yaml action file in project #175.

Know your algorithm: One size doesn’t fit all

As with all reusable actions, users should check whether the algorithm fits their specific research needs. For example, individuals with a history of gestational diabetes who later develop type 2 are classified (only) as type 2, a common and reasonable approach, but probably not ideal when studying gestational diabetes itself. Moreover, this is an evolving field of research and other slightly different adjudication algorithms have been developed.

Collaboratively building for the community

Developing this reusable action with and for the OpenSAFELY community has been fun and rewarding. It’s great to see peer-reviewed, complex code turned into an action that’s easy to reuse for others - and not only stored away in a repository.

Looking ahead, we may expand ‘diabetes-algo’ to offer a choice of different adjudication algorithms. Until then, we hope it is useful for other OpenSAFELY users and makes diabetes classification just a little bit easier.

Thanks to Venexia Walker, Tom Palmer, Paul Madley-Dowd and Ewan Walker from the Electronic Health Records Group in Bristol and Iain Dillingham from the Bennett Institute in Oxford for code review, guidance and advice along the way.