Three mental health patients who are suing the government for $800,000 have been treated with the "utmost respect and dignity", the Attorney-General maintains.
The men argue they were mistreated while in state care, and unnecessarily detained and medicated.
However, in her closing submissions in the High Court in Wellington this morning, the Attorney-General's lawyer, Martha Coleman, insisted there was no medical malpractice and psychiatrists often consulted with the men.
"There's no suggestion of any systemic failure," she told the court.
"[The men] have been treated with the utmost respect and dignity."
She said in order for patients to be detained for the least amount of time possible, there needed to be certain types of rehabilitative treatment.
The lawyer for the men, Tony Ellis, earlier told the court they had been "put on a shelf and forgotten about".
Ellis is representing the men, while the Waitemata and Capital & Coast District Health Boards and the Attorney-General are among the five defendants.
The men have name suppression. One has been detained since 1999, one since 2002, and the other from between 2001 and 2014.
All three previously came before the courts on violence charges before detention.
Ms Coleman said it was important to balance rehabilitation, and maintaining the safety of staff and other patients.
"You have vulnerable people in a contained environment, but you also have the detention of people who are violent."