The calculator will help doctors identify high risk patients so that they can be tested for the disease and offered lifestyle advice. The test is targeted at people who have been admitted to hospital for emergency care.
Experts say it could offer a cost-effective way to identify people with diabetes in Scotland as it avoids the need for significant investment in screening.
The test calculates a person's risk of developing diabetes over the next three years based on their age, sex and the level of sugar in their blood, which is routinely measured on admission to A&E.
Blood sugar levels often rise during serious illness but usually drop back to normal when patients get better. This can make it difficult for doctors to identify patients who are at risk of diabetes, which is also associated with high levels of sugar in the blood.
"This tool will enable us to identify people at risk of diabetes and give them the opportunity to make positive lifestyle changes to improve their health, without the cost of running a national screening programme," says Dr David McAllister, clinical lecturer in epidemiology and public health
The calculator will help doctors determine which patients should be referred for diabetes testing when they recover. It was developed by a team led by the University of Edinburgh's Centre for Population Health Sciences, the University of Glasgow and members of the Scottish Diabetes Research Network.
The team linked records from more than 100,000 hospital patients to a national diabetes register to get the information needed to create the calculator.
The research is published today in the journal PLOS Medicine and was funded by the Chief Scientist Office of the Scottish Government.