Scientists have developed a new artificial intelligence tool that can predict whether an adult has attention deficit hyperactivity disorder by examining their past medical records. This predictive model suggests that subtle patterns in daily medical visits can identify undiagnosed individuals months before doctors formally detect symptoms. This study was recently published in the journal european psychiatry.
Attention-deficit hyperactivity disorder is a common neurodevelopmental disorder that affects approximately 5 to 7.2 percent of children and approximately 2.5 percent of adults worldwide. People with this condition experience varying degrees of inattention, hyperactivity, and impulsivity that interfere with daily life. It tends to be very difficult to receive a proper diagnosis as an adult.
Doctors often have a hard time identifying symptoms in older patients because the symptoms often overlap with other mental health problems. Delayed diagnosis often results in impaired school and work performance, increased accident rates, and decreased overall quality of life. Early diagnosis provides opportunities for evidence-based pharmacological treatments and treatments that can prevent many of these negative outcomes.
These days, artificial intelligence is expected to help doctors discover hidden patterns in patient data. Many previous attempts to use machine learning to detect attention-deficit hyperactivity disorder have relied primarily on brain scans, structured behavioral assessments, or specialized physiological tests. This type of medical data is expensive and not routinely collected for the average patient.
To create a more practical tool, the researchers decided to focus on electronic medical records. These records are standard digital files that clinics and hospitals already maintain for all patients. By training a computer program to read a standard medical history, the authors hoped to create a cost-effective screening method that relied solely on information doctors already had on hand.
Scientists analyzed historical medical data from a regional health system in southwestern Sweden. This database included information from primary care clinics, specialist visits, and hospitalizations from 2011 to 2022. Detailed data on patient demographics, specific medical diagnoses, clinical procedures, and prescribed medications were collected.
To build the model, the researchers started with a group of 3,570 adults who had been formally diagnosed with attention-deficit hyperactivity disorder or prescribed related medications. They also selected a control group of adults who had visited a psychiatric outpatient clinic but did not have the disorder. During the design phase, when the control group included patients with depression or anxiety, the predictive model had a hard time distinguishing between the two groups.
To solve this problem, the researchers excluded people with depression or anxiety from the control group. Cognitive and behavioral symptoms of depression and anxiety overlap with attention problems, so removing them allowed the computer to focus on the unique symptoms of attention deficit hyperactivity disorder. This adjustment resulted in a final control group of 5,126 adults, providing sufficient data for the program.
The authors then fed this data into a machine learning system based on a “Transformer” architecture. Transformers are an advanced type of artificial intelligence technology that excels at understanding sets of information. This particular transducer was trained to read a patient’s sequence of encounters and prescription codes over time, rather than reading words in a sentence.
These models use a mathematical technique called positional encoding to understand the exact chronological order of events. This allows the system to understand how a patient’s health status changes over months or years. The researchers tested whether the model could predict diagnoses 6, 12, and 18 months before the actual diagnosis date.
They evaluated the final model on a completely separate set of 800 patients, splitting this test group evenly between 400 diagnosed and 400 disease-free patients. Testing the model with a separate group ensures that the artificial intelligence is evaluated based on fresh information that has not been seen before. This result suggests that this model can successfully predict attention deficit hyperactivity disorder in adults using routine clinical data.
Artificial intelligence performed best when predicting diagnoses six months in advance. Over the past six months, the model has accurately identified 80% of patients who actually suffer from the disorder. Additionally, the disease was correctly excluded in 77% of patients who did not have the disease.
The model achieved a score of 0.79 on a mathematical metric called area under the curve. This metric evaluates how well the predictive model distinguishes between the two groups. A score of 1.0 is perfect and a score of 0.5 is equivalent to a random guess. Results were fairly stable when predicting diagnosis 18 months later.
The scientists also investigated which specific medical codes the computer used to make its predictions. To do this, they used an analytical technique called Shapley Additive Explains. This method helps open the “black box” of artificial intelligence by showing precisely which demographic factors or clinical codes increase or decrease predicted risk.
This analysis revealed that a past diagnosis related to substance use was a strong indicator of a future diagnosis of attention-deficit/hyperactivity disorder. For example, medical measures indicating stimulant use, including heavy use of caffeine, had very high predictive power. The model also flagged codes related to specific blood alcohol concentrations ranging from 0.60 to 0.79 milligrams per 100 milliliters.
These findings are consistent with previous research showing that adults with undiagnosed attention-related problems may try to self-medicate with caffeine, alcohol, or other substances. The computer program also featured medical codes related to birth complications. This data suggests that mothers who experience problems such as obstructed labor or abnormal fetal position are slightly more likely to be later diagnosed with attention-deficit hyperactivity disorder.
Researchers believe this may reflect broader physical and psychosocial challenges rather than a direct physical cause. Additionally, scientists noticed different demographic and healthcare utilization patterns between the two groups. Those diagnosed tended to be younger, with an average age of about 31 years, compared to 52 years in the control group.
They also had significantly more primary care and psychiatrist visits than the control group, but fewer hospital admissions and shorter hospital stays. Although these findings are promising, the authors caution against viewing this artificial intelligence as a replacement for human doctors. This tool is not designed to formally diagnose someone on its own.
Instead, it is intended to act as an early warning system that operates silently in the background of a hospital’s computer network. By flagging patients who exhibit questionable healthcare utilization patterns, the system simply notifies physicians that a particular person could benefit from a comprehensive psychological evaluation. A trained medical professional must be present with the patient to conduct a structured interview and confirm the diagnosis.
One of the limitations of this study is that patients with depression and anxiety were excluded from the control group. In clinical practice, physicians often need to distinguish between attention-deficit/hyperactivity disorder and depression. This model may face challenges when introduced to general psychiatrists because it was not trained for patients with these specific overlapping symptoms.
The researchers also noted some differences in how the models treated men and women. Artificial intelligence successfully identified this condition in 75.2 percent of female patients, but only in 66.7 percent of male cases. Although false positive rates were consistent across genders, differences in successful identification highlight the need for further evaluation to ensure unbiased performance.
In the future, the scientists hope to test the model in different health systems outside of Sweden. Medical coding practices can vary widely from country to country, so algorithms need to prove their adaptability. The authors also suggest exploring how this data-driven approach can work with newer, more flexible ways to classify mental health conditions in the future.
The study, “Early Detection of Adult ADHD Using Electronic Health Records: A Machine Learning Study,” was authored by Omar Hamed, Farzaneh Etminani, Peter Jacobsson, and Thomas Davidsson.

