This longitudinal study, based on two cohorts of approximately 1.4 million people with incident type 2 diabetes from population-representative EMRs from two different healthcare systems, offers new insight into the depression risk dynamics in YOD and usual-onset type 2 diabetes patients. The primary findings are: (1) a significant increasing trend in the prevalence of depression at the time of type 2 diabetes diagnosis, which is similar across all age groups in both countries, and (2) that men and women with YOD (aged <40 years at time of diagnosis) have a significantly higher risk of developing depression compared with those who developed type 2 diabetes at ≥50 years, with the risk being similar irrespective of cardiometabolic comorbidities at the time of type 2 diabetes diagnosis.
We observed a significant increasing trend in the prevalence of depression and AMI at the time of type 2 diabetes diagnosis, which was similar across all age groups in men and women in both countries. Although the prevalence of a cardiometabolic comorbidity at the time of type 2 diabetes diagnosis has been found to be highest among people aged ≥60 years at the time of type 2 diabetes diagnosis in both countries [2, 5, 29], we observed that the depression prevalence is similar across all age groups.
Although our depression prevalence estimates at the time of type 2 diabetes diagnosis for the UK are higher than in the USA (UK 35%; USA 25%), the estimates are comparable with those obtained in earlier studies from Europe and the USA in established type 2 diabetes populations: 23% (CI 18, 28%) in Europe  and 25% (CI 23, 28%) in the USA .
A novel finding of our study is the significantly higher risk of developing depression in patients with YOD compared with patients with usual-onset type 2 diabetes, with the risk estimates being similar for people with and without comorbidities at the time of type 2 diabetes diagnosis. In the UK, these risk estimates were similar for people with and without comorbidities in both men and women across all increasing age groups. A similar trend was observed in US men. However, the patterns of risk among US women were different by baseline comorbidity status, particularly in the comparisons with age groups 40–49 and 50–59 years (Fig. 2b and d). The observed difference could be due to unmeasured mediation effects, which requires further investigation. This clearly indicates the mental health implications of developing diabetes at an early age irrespective of underlying comorbidities. While the pathophysiology of depression in people with type 2 diabetes has been discussed [1, 6], several factors, including a higher burden of risk factors including obesity in YOD, may partially explain the higher risk of developing depression in patients with YOD compared with usual-onset type 2 diabetes. A recent USA CEMR data-based study reported a similar mediation effect of depression across all age groups after diagnosis of type 2 diabetes on the increased cardiovascular risk . However, to further evaluate the observed higher depression risk in YOD irrespective of comorbidity status at type 2 diabetes diagnosis, future studies evaluating the mediation effects of the time-varying cardiometabolic diseases and risk factors before and after type 2 diabetes diagnosis on depression risk in different age groups, sex and ethnicity would be of great importance.
As observed in this study, the prevalence and incidence of depression in people with type 2 diabetes are significantly higher among women in both countries, with the rate of increase in the prevalence of depression among women also being consistently higher across all age groups, compared with men. While recent studies using these UK or USA EMRs have reported the overall prevalence of depression and other comorbidities at onset of type 2 diabetes [2, 5, 15, 29], we are not aware of any study that explored the population-level trend in depression prevalence at the time of type 2 diabetes diagnosis across age groups and sex . Understanding the recent changing dynamics of cardiometabolic comorbidity and depression in patients with YOD and usual-onset type 2 diabetes is of paramount importance for proactive engagement of primary care teams in population-level mental health management and healthcare cost reduction. The 2004–2011 Medical Expenditure Panel Survey from the USA showed that the average medical cost for patients with diabetes and symptomatic depression was more than double compared with people with diabetes and no depression .
Despite the sociodemographic and healthcare system differences between the UK and the USA, all age groups experienced statistically significant increases in comorbid depression during the study period (Fig. 1). A plausible reason for the 2–9% annual increase in the rates of comorbid depression is an increased awareness and likelihood of diagnosis in primary/ambulatory care, as more research and education about the association between diabetes and depression emerges [3, 11]. In addition, better record-keeping as a result of the transition to EMRs would have resulted in an increased likelihood of capturing secondary medical diagnoses including depression. This is reflected in the overall temporal prevalence of depression for the USA, with a significant annual percentage change observed from 2009 onwards (ESM Fig. 2).
Proactive management of comorbid depression in terms of timely screening, early diagnosis and pharmacotherapeutic treatment may lead to improved glycaemic and other risk factor control in people with diabetes, delayed onset of complications and lower healthcare-associated costs. Petrak et al  recommend treating depression first, as the response to medications is usually seen within weeks after initiation of antidepressant treatment, while improvement in the glycaemic control requires several months. Given the increasing rate of comorbidities and the varying dynamics of different sociodemographic populations, innovative approaches to identify subgroups of patients for proactive management will be beneficial. More research is required to understand the dynamics and patterns of management of patients with depression to improve outcomes for patients with diabetes and other comorbidities including depression. In addition, given the complexity of the roles of comorbidities in the interplay of diabetes and depression, detailed evaluation of the bidirectional association between these conditions in different ethnicities, age groups and sex is crucial .
The main strength of our study is the simultaneous evaluation of longitudinal data from two nationally representative primary/ambulatory care EMRs from different healthcare systems in the UK and the USA over a period of 11 years. Compared with cross-sectional surveys that primarily capture self-reported symptomatology at a single point in time, EMR data provides information on a wealth of comorbidities based on reliable clinical diagnoses. In addition, patient data in EMRs can be linked to longitudinal patient-level medical and clinical records; making it possible to explore temporal associations between risk factors and disease outcomes, including depression .
There are several unavoidable limitations in outcome studies based on EMRs. The under-reporting of depression is a common problem globally. Mis-coding of conditions is a common limitation when using EMRs. However, we used clinically guided machine learning-based methods to identify people with type 2 diabetes and depression. There is bias in recording of depression over time, and difficulties identifying people who have been receiving prescriptions for antidepressants that are meant to be used for treating depression only (in the absence of clinical codes for depression). The increasing prevalence of comorbid depression may reflect an increase in the actual incidence of depression but may also be due to several other factors, including physician awareness and diagnosis or documentation practices. Also, the availability of socioeconomic, smoking status and ethnicity data was not consistent in the EMRs from the UK and the USA. Other limitations include unavoidable indication bias and residual confounding, which are common problems in any EMR-based outcome studies, together with a lack of data on physical activity, the nature of insurance, education, income, other cultural drivers, missing HbA1c results and lack of reliable data on competing risks such as death. While mortality is an important competing risk in the context of outcome studies with real-world longitudinal EMRs, we were unable to perform any sensitivity analysis accounting for competing risks due to death, as the CEMR database does not provide death data and deaths are poorly recorded in the THIN database. Furthermore, while obtaining reliable information on medication adherence is a common problem in all clinical studies, detailed validation studies of these EMRs suggested a high level of agreement between EMR prescription data and pharmacy claims data, especially for chronic diseases .
In conclusion, the prevalence and incidence of depression among people with incident type 2 diabetes in the UK and the USA are rapidly increasing across all age groups, particularly in those with YOD. Men and women with YOD have a significantly higher risk of developing depression compared with those with usual-onset type 2 diabetes, with the risk being similar in people with and without comorbidities at type 2 diabetes diagnosis. It is recommended that clinicians screen regularly for depression in people with incident type 2 diabetes, particularly among those who are <50 years old, irrespective of their cardiometabolic comorbidity status.