PATIENTS were told to stay away from hospitals unless in an emergency yesterday after Scotland’s NHS was caught up in a major cyber attack that left computer systems down across the country.

More than half of the country’s health boards were targeted by the large-scale hack which brought down NHS computer systems throughout the UK with medical staff unable to access patient records.

GP surgeries and dental surgeries were all hit by the ransomware virus on IT systems, which left ransom notes on computers and which also disrupted health services in England.

Read more: Inmates could turn carers as ageing prisoner crisis looms

First Minister Nicola Sturgeon last night chaired a resilience meeting as the scale of the crisis became apparent,.

Prime Minister Theresa May said the attack was “not targeted” at the NHS, but was part of a wider assault on organisations across a number of countries.

NHS Lanarkshire said only those patients requiring emergency treatment should attend hospital while they dealt with the issue.

Scotland’s biggest health board, NHS Greater Glasgow and Clyde, as well as NHS Tayside, NHS Dumfries and Galloway and NHS Forth Valley confirmed that some of their GP surgeries had been caught up in the incident.

Read more: Video: Catholic Church warns against "state ownership" of body parts in Scotland

NHS Lanarkshire urged non- emergency patients to stay away from its hospitals as it dealt with a the attack to its network.

A spokesman said: “As a precaution, NHS Lanarkshire is closing down its non-essential networked IT systems on a temporary basis. All our sites remain open, however we are appealing to members of the public only to attend hospital for emergency treatment during this period.”

Staff were forced to revert to pen and paper and use their own mobiles after the attack affected key systems, including telephones.

Pictures posted on social media showed screens of NHS computers with images demanding payment of $300 worth of the online currency Bitcoin, threatening to delete files within seven days.

Read more: Battle against chemicals in tap water goes to Holyrood

Cybersecurity experts were stunned by the scale of the attack, which spread to networks in 74 countries around the globe, including the US, Russia, Spain, Italy and China. Ibedrola, parent company of Scottish Power, was one of those affected.

PWC Cybersecurity partner Colin Slater said: “There’s no evidence of data being taken from computers -–this is purely a ransomware attack. But what’s surprising is its ability to ‘worm’ its way around systems.”

He said that systems could have been infected by something as simple as visiting a website or opening an email.

Mr Slater added: “It will likely take weeks to sort something like this out as you will have to clear systems of the virus then restore files from somewhere which has hopefully not been compromised itself.”

The National Cyber Security Centre is working to support the NHS.

A Microsoft spokesman said customers running free antivirus software and have Windows Updates enabled are protected from “ransomware” attack.

Theresa May said the Government is not aware of any evidence that patient records have been compromised in the massive cyber attack on the NHS.

Mrs May said: “The National Cyber Security Centre is working closely with NHS to ensure that they support the organisations concerned and that they protect patient safety.

“And, we are not aware of any evidence that patient data has been compromised.”