IF you were mentally ill in Scotland in 1948, it is highly likely you would be confined to an asylum.

Long before care in the community, counselling and antidepressants, thousands of psychiatric patients were locked away in rundown Victorian mental hospitals - many of them for years at a time.

A government review in 1954 estimated that 46 per cent of patients in British mental hospitals had been resident for more than ten years, and 10 per cent for more than 30 years.

HeraldScotland: Gartnavel mental hospital

The Royal Edinburgh Asylum in Morningside and Glasgow Royal Asylum at Gartnavel were the largest in Scotland, but there were others in Dundee, Fife, Dumfries and Aberdeen.

At its peak in 1956, Scotland’s total inpatient psychiatric population reached 20,925.

When plans for the NHS were drawn up it was not taken for granted that mental healthcare would even be included, however, with some politicians arguing that it should be up to local authorities to provide it.

The Mental Health Foundation said the eventual decision to mental health under the NHS umbrella was "hugely important in bringing psychiatry into the broader family of medical disciplines".

There was no overnight transformation in care though.

Dr Allan Beveridge, a retired consultant psychiatrist who has written on the history of psychiatry in Scotland, said improvements "came later".

Free access to healthcare did remove an element of the previous rich-poor divide which had seen asylums carved up into the more prestigious "royal" mental hospitals and so-called "pauper" district asylums.

"In the old psychiatric hospitals you had a divide between private and non-private patients," said Dr Beveridge. "Private patients paid for their board, and the non-private patients were paid for from the local parish.

"It tended to be [that you got better treatment if you were paying] because they were trying to attract the rich customers by making the wards they were in better."

Read more: Thousand psychiatric patients sent up to 500 miles away for an inpatient bed

In the first years of the NHS, the trend to confining patients in asylums continued - but within a decade thinking had begun to change.

Dr Beveridge said: "If we're looking at the period after 1948, in the 1950s the psychiatric hospitals were filling up and overcrowded - they were probably at their peak occupancy.

"Gartnavel Hospital in Glasgow had 900 inpatients, a colossal number. But there was a feeling that these large mental hospitals were counter-therapeutic.

"People started looking at social treatments and moving people out of the hospitals. I think that was part of the zeitgeist more than anything to do with the national health service."

HeraldScotland: Dr Alan Beveridge

There was also a dramatic shift in treatments. In 1950, the UK's Ministry of Health set out the various treatments available to the mentally ill.

According to the Mental Health Foundation, these included: "Therapeutic convulsion treatment ('a potent weapon for cutting short depressive illness'), insulin shock treatment ('particularly valuable' in the treatment of schizophrenia) and prefrontal leucotomy – cutting out part of the brain (believed to have a 'usefulness' in 'properly selected cases')".

These were gradually sidelined as the 1950s saw a new wave of psychiatric medications, including the first anti-psychotic, chlorpromazine, the first antidepressants, and the use of lithium as a mood stabiliser.

Chlorpromazine, first introduced in France, was a game-changer in the treatment of schizophrenia.

Dr Peter Bennie, chair of the BMA in Scotland but also a general adult psychiatrist based in Paisley, said the arrival of chlorpromazine was one of the biggest advances in psychiatry in the past 100 years.

And of course, the creation of the NHS made access to the drug free to anyone who needed it.

Dr Bennie said: "You were talking about people who had lived for 20 years or more in the psychiatric hospital who were suddenly transformed and able to leave the psychiatric hospital and resume day to day life.

"In our day and age we don't really get the opportunity to see such a life-changing event as a new medicine for a condition such as that.

"Now we look at things like chlopromazine and they're drastically old-fashioned, but in its day it was one of the most innovative treatments imaginable.

"It makes you look forward and think about the mental health conditions we still don't have any medical treatment for, and I always think about Alzheimer's.

"You just have to assume there will be a medical advance and at some point - who knows when - there will be a medical treatment that makes a radical difference to Alzheimer's and that would be just as life-transforming as chlopromazine once was in the 1950s."

Despite the high numbers of inpatients treated mental hospitals in the first decade of the NHS, the number of psychiatrists was woeful. Records estimate that there were fewer than 50 working in the NHS in Scotland in 1950.

Today the consultant psychiatrist workforce in Scotland is nearly 537 'whole-time equivalent' (a measure that takes into account part-time working), while the average number of mental health inpatients in hospital has been falling steadily - from around 15,000 in 1983/84 to fewer than 5000 in 2015/16.

This of course reflects the drive towards more care in the community, with the gradual closure of asylums, a steady reduction in mental health beds and a desire to give psychiatric patients more independence.

Demand for outpatient clinics meanwhile has soared - and general psychiatry currently has one of the highest vacancy rates in NHS Scotland with almost 12 per cent of posts empty, triple what it was five years ago.

Dr Beveridge said the shift towards more community-based care is welcome, but as with social care of the elderly the cut in bed numbers has generally outstripped the resources available to provide the best possible support outside of hospital.

He said: "There was a notion in the 1980s and 1990s of a bed-free service, but I think that was misguided. Some patients need to be an inpatient so you need a range of services.

"Beds are being cut and if you're working in the psychiatric service at times it is difficult to find beds and patients are transferred all over Scotland.

"So it definitely doesn't seem like we have too many beds, but funding community care is very expensive to do it properly."

HeraldScotland: Dr Peter Bennie

Dr Bennie adds that in many cases psychiatric patients end up in limbo - well enough to be discharged, but with no suitable accommodation to go to or social care funding to support them at home.

As a result, psychiatric wards - in an ironic echo of the asylums of the past - are becoming needlessly overcrowded.

Dr Bennie said: "It's very often the case, right across Scotland, that a clinical decision that a person requires inpatient care is only the beginning of a very long, drawn out process of locating a bed.

"For the poor individual and their family it's a time of huge uncertainty. They're being told 'there might be a bed but it's 50 miles away' or 'we might be able to get you into the hospital three miles away' or 'we might be able to get you in here, but someone else is coming back in the next day'.

"Basically to run a service efficiently you need a bed occupancy rate of 85 per cent because that allows for slack.

"It allows for the situation that arises unpredictably where you have three people presenting with severe illness in one night, all absolutely requiring inpatient care.

"You need to have the capacity to attend to that and we've lost that - we run at 95 per cent up to 100 per cent occupancy all the time."