Everyone with experience of Scotland's NHS is agreed "boarding" - the practice by which patients are looked after in the wrong department because of bed shortages - is a bad idea.

The question is how to fix it.

The reason boarding is a bad idea is obvious. Patients should always be cared for by staff who are trained in dealing with their condition, but when boarding occurs, a patient can end up in a ward that does not specialise in their health problem. As the Royal College of Physicians of Edinburgh (RCPE) points out, this can lead to poorer outcomes for the patient - they may be more likely to die, for instance, their length of stay is hospital is likely to be longer, and there is a greater chance of them being re-admitted at a later date.

Despite this, boarding has been prevalent in the NHS in Scotland for some time now, partly because of the deep cuts to bed numbers since 2007, but also because of the pressures on the system caused by Scotland's ageing population. The RCPE also says boarding is a symptom of other underlying problems including inadequate social care in the community, staff shortages, and failures in planning and communication.

Dr Mike Jones, vice-president of the RCPE, has rightly pointed out that the problem of boarding cannot be fixed overnight, but an important first step to solving the problem would be a beds review to ensure Scotland's hospitals have the right beds with the right staff at the right time. The Herald has been calling for this review as part of our NHS: Time for Action campaign and now - on the cusp of winter, when the problem of boarding is at its worst - is the perfect time to do it.

As the RCPE has pointed out, Scotland's social care strategy is also an important element of the solution and there must be a review of community care capacity to determine how personal, residential and community-based care will need to expand to look after the ageing population outside hospital.

The issues of staffing and planning will also need to be scrutinised. In particular, any review must look at the idea of moving away from a nine-to-five health service to a seven-days-a-week service. One question worth considering is whether consultants should work more flexibly, although a round-the-clock operation must not be achieved by simply piling the pressure on to staff.

All of these issues, and more, will need to be considered if boarding is to be ended. The urgency of the aim is certainly in no doubt. Last winter, in Scotland's hospitals, patients were moved from ward to ward in search of a suitable bed and thousands of sick people were treated in the wrong department. This should not be happening in a system of which Scots are rightly proud. It may be that more beds are needed; it may be that it is greater flexibility. Whatever the answer, a review of beds is needed now to find it.