Before the liberty and custody judge and the first president of the court of appeal, the person undergoing psychiatric care is assisted or represented by a lawyer. He shall be represented by a lawyer if the judge decides, in the light of the medical opinion provided for in the second paragraph of article L. 3211-12-2, not to hear him. The other parties are not required to be represented by a lawyer.