The government was aware of the threat of cyberattacks on the UK, Home Secretary Amber Rudd has said. Her remarks come as the NHS battles a global ransomware attack in which as many as 45 hospitals across England and Scotland were compromised.

Rudd stressed that patient data has not been accessed, but said that NHS trusts need to learn lessons from the experience.

Rudd told the BBC's Radio 4 Today programme: "Cyber and cyber security is a huge industry and it is an area where we can all do better to protect our businesses and our personal information and I would expect NHS trusts to learn from this and to make sure that they do upgrade [their IT systems]."

She added: "Nobody underestimates the difficulty in dealing with cyberattacks. We have known for a number of years that this is one of the most dangerous threats to this country, which is why we have put investment into it, which is why we are investing in training police officers ... we are investing in cyber skills.

"We know what's coming down to attack us, that's why we are defending this country so robustly with investment."

Despite the added investment in police training, the ransomware attack demonstrated that IT systems which are integral to public services and the country's infrastructure are lagging behind and are susceptible to attack.

In the wake of the cyberattack, it has been claimed that up to 90% of NHS hospitals still use Windows XP – an obsolete 16-year-old operating system that is no longer supported by Microsoft.

"If hospitals are knowingly using insecure XP machines and devices to hold and otherwise process patient data they may well be in serious contravention of their obligations," Jon Baines, chair of the National Association of Data Protection and Freedom of Information Officers, told IT publication Silicon in December.

Doctors have anonymously spoken of the dangers that patients face while IT systems are down.

"I know the staff will do their very best to keep looking after everyone but there are no robust systems in place to deal with blackouts like this," one junior doctor told the Guardian.

"Information sharing is hard enough in a clinical environment when everything works. Without the IT systems, I suspect test results will be missed and will definitely be delayed. Handovers are much more difficult. It will, absolutely certainly, impact patient safety negatively, even if that impact can't be clearly measured."

Rudd will chair a Cobra meeting in Whitehall at 2.30pm on 13 May.