If a person who has been denied release or whose retention, continued retention, or transfer and continued retention has been authorized pursuant to this article, or any relative or friend in his behalf, be dissatisfied with any such order he may, within thirty days after the making of any such order, obtain a rehearing and a review of the proceedings already had and of such order upon a petition to a justice of the supreme court other than the judge or justice presiding over the court making such order. Such justice shall cause a jury to be summoned and shall try the question of the mental illness and the need for retention of the patient so authorized to be retained. Any such patient or the person applying on his behalf for such review may waive the trial of the fact by a jury and consent in writing to trial of such fact by the court. No such petition for rehearing and review shall be made by anyone other than the person so authorized to be retained or the father, mother, husband, wife, or child of such person, unless the petitioner shall have first obtained the leave of the court upon good cause shown. If the verdict of the jury, or the decision of the court when jury trial has been waived, be that such person does not have a mental illness or is not in need of retention the justice shall forthwith discharge him, but if the verdict of the jury, or the decision of the court where a jury trial has been waived, be that such person has a mental illness and is in need of retention the justice shall certify that fact and make an order authorizing continued retention under the original order. Such order shall be presented, at the time of authorization of continued retention of such mentally ill person, to, and filed with, the director of the hospital in which the person with a mental illness is authorized to be retained, and a copy thereof shall be forwarded to the department by such director and filed in the office thereof. Proceedings under the order shall not be stayed pending an appeal therefrom, except upon an order of a justice of the supreme court, made upon a notice and after a hearing, with provisions made therein for such temporary care or confinement of the alleged person with a mental illness as may be deemed necessary.