The former clinical director at Broadmoor told a court The Sun had published a "very accurate" story about the suicide of serial killer Daniel Gonzalez when details had not been released.
Psychiatrist Dr Kevin Murray, who believed Peter Sutcliffe was not a murderer, said the public should not have been told Gonzalez had killed himself in a maximum security hospital.
Gonzalez, also known as Freddy Krueger Killer, claimed four victims and injured two others in September 2004.
Murray was speaking at the Kingston Crown Court trial of six Sun journalists accused of a decade-long campaign of payments to police officers, prison guards, healthcare workers in Broadmoor Hospital, and serving soldiers.
Murray said: "The death would have been notified to the coroner – deaths of patients detained under the Mental Health Act are subject to enquiries.
"Beyond that, a notification is made to the deceased's family, to the Department of Health and what was known as the Healthcare Commission.
"There would have been nothing further."
He added: "Because Daniel Gonzalez was a patient we don't publish press releases more than Great Ormond Street or Guy's Hospital do.
"Broadmoor is a hospital. For it to work effectively there must be an expectation of confidentiality about what is disclosed by patients and what happens to them within the hospital.
"That's far from releasing a story to the press – which in this case was unauthorised.
"Part of the role at Broadmoor is attempting to restore the health of the patient, the second is assessing risk in relation to the patient.
"And for us to make well-founded judgments about that level of risk our patients pose we must have with them a relationship in which they trust.
"If they don't speak to us we don't know if they pose a risk and we can't know if what we are offering them is of any benefit.
"If we get risk assessments wrong the opportunity to identify people as having a mental health disorder and continue treating them is put in jeopardy.
"For us to do our job effectively, it does require that we have an effective and therapeutic relationship with our patients."
Peter Wright QC, prosecuting, asked whether there were occasions where press releases were made by Broadmoor.
"Like most hospitals, we have a communications department which prepares and releases statements, for instance when a minister occasionally visits Broadmoor," Murray continued.
He said the story was accurate and included the precise timing and other details.
Murray said he did not know who had leaked the information and explained that all staff know they have an obligation of confidentiality to patients.
He said: "When staff are known to have breached that obligation disciplinary action is taken, and in a hospital of Broadmoor's small size, news like that spreads quickly.
"There can be no excuse by a member of staff for not knowing this expectation.
"Patients expect confidentiality as if were their local GP. Reports should not be passed directly to the press.
"If I am asked to prepare a patient report for court I would explain to the patient what would happen to that report – that it would go to their solicitors and they would discuss it in court.
"It's never crossed my mind that I would have to explain the report would not go to the press, as it's so far from proper practice that it's almost inconceivable.
"There is a general public understanding of confidentiality incumbent on doctors."
Murray said he was aware that a report he had prepared for Peter Sutcliffe in 2010, who was trying to get his life tariff reduced, had been leaked to the press and published.
"The report should have been absolutely confidential in its entirety," said Murray.
"Articles such as this cause stress to families of our patients and to the families of their victims, sometimes of course they are the same families.
"This had been reported to me on a number of occasions and they have complained about the drip of stories into the press about Broadmoor.
"They say they lose confidence in the hospital. They say they are discouraged from coming to the hospital.
"Our patients complained about these articles as did their solicitors and it puts us in a very difficult situation of not knowing which clinicians in Broadmoor we can trust.
"Just to amplify, on one occasion we arranged for Peter Sutcliffe to have a compassionate visit out of the hospital to the Lake District.
"The number of people who knew was kept to an absolute minimum.
"Subsequently a number of staff felt very angry that they had been excluded from this information, but I had to explain that I didn't know where the leak was coming from.
"In the same way as we expect patients to take us into their confidence, I want the staff to know that I value their views.
"They spend much longer with my patients than I do, and they need to know I have confidence in them.
"It compromises the efficiency of the hospital."
In December 2007, The Sun published a story relating to an attempt on Sutcliffe's life by another inmate, who tried to cut his eye with a knife.
The story was entitled: "I will blind your one good eye."
Murray said the information was largely accurate, but none of it had been released.
"When nursing staff see something published in the papers 36 hours after it has taken place, and they know no statement has been released by the hospital, they know one of their colleagues must be leaking information to the press.
"They are left with the question, 'who do I speak to about this,' 'how do I record incidents like this?'
"Things like this erode the way hospitals should function.
"The patients don't know who they can trust among the staff.
"The patients read the newspapers and will know somebody will go to the press about what is going on in their ward.
"It is an unescapable fact that some patients want to demonstrate their machismo by harming more well-known patients.
"Articles such as this tend to make these events more likely, and because of this we have to be careful where we locate patients.
"It gets in the way of effective management of the hospital."
In 2008, The Sun reported that Sutcliffe's wife Sonia had been to visit him at Broadmoor.
Murray explained such information was not supposed to be released.
"The fact that someone is coming to visit someone in hospital is not a matter of public interest," Dr Murray continued.
"These stories are discouraging to friends and family who might otherwise come and visit their relatives in Broadmoor.
"There are people who have said to me I am not going to come up anymore, I don't trust it."
On 31 October 2008, reporter Jamie Pyatt published a story in The Sun, "Sick or Treat", which told of a Halloween party held for inmates at Broadmoor.
Murray said of organising the event: "You will see at such times how well people get on together.
"It also promotes a positive relationship between the patients and the staff."
Murray claimed the article had somehow mocked the patients.
"For the staff who have worked hard to try to organise events like these, it's profoundly discouraging," he said.
"It discourages patients from being involved. They see themselves as being ridiculed.
"The reasons they withdraw from these activities is that it puts them back on the front page of the newspapers."
Murray said the effect of the newspaper articles was "corrosive".
"Cumulatively, the effect is damaging on the effectiveness of running the hospital.
"There are people who have said to me it's a factor in their decision to leave Broadmoor, they say: 'I'm fed up with these articles appearing in the press.'
"Between 2004 and 2010 the Department of Health was deciding whether to fund the rebuilding of the hospital, and their confidence in the way the hospital was managed was not helped by this constant drip of stories appearing in the press."
Nigel Rumfitt QC, for news editor Chris Pharo, argued that most of the content in the stories published by The Sun had been "accurate".
Murray agreed, but claimed many stories had been fabricated and had "humiliated" inmates at Broadmoor.
Jurors heard that in 2010, when Sutcliffe tried to have his life tariff lessened, that Murray said that a jury in 1981 was wrong to convict him of 13 murders.
Murray suggested to Justice Mitting in 2010 that Sutcliffe should have been found guilty of manslaughter instead, Kingston Crown Court was told.
Rumfitt suggested Murray was "arrogant" to have dismissed the view of a jury.
Murray also said that it was "not in the public interest" for The Sun to have reported on Sutcliffe's poor personal hygiene.
The six defendants are accused of a decade-long campaign of payments to police officers, prison guards, healthcare workers in Broadmoor Hospital, and serving soldiers.
Pharo, 45, of Wapping, east London, denies six counts of conspiracy to commit misconduct in public office.
Ben O'Driscoll, 38, of Windsor, Berkshire, and Graham Dudman, 51, of Brentwood, Essex, both deny four counts of conspiracy to commit misconduct in public office.
John Edwards, of Brentwood, Essex, and Pyatt, of Windsor, deny three counts of conspiracy to commit misconduct in public office.
John Troup, of Saffron Walden, Essex, denies two counts of misconduct in public office.
The trial continues.
Email pged@pressgazette.co.uk to point out mistakes, provide story tips or send in a letter for publication on our "Letters Page" blog