229.4  Right to release on application.
  A voluntary patient who requests release or whose release is requested, in writing, by the patient’s legal guardian, parent, spouse or adult next of kin shall be released from the hospital forthwith, except that:
  1.  If the patient was admitted on the patient’s own application and the request for release is made by some other person, release may be conditioned upon the agreement of the patient.
  2.  If the patient is a minor who was admitted on the application of the patient’s parent, guardian or custodian pursuant to section 229.2, subsection 1, the patient’s release prior to becoming eighteen years of age may be conditioned upon the consent of the parent, guardian or custodian, or upon the approval of the juvenile court if the admission was approved by the juvenile court; and
  3.  If the chief medical officer of the hospital, not later than the end of the next secular day on which the office of the clerk of the district court for the county in which the hospital is located is open and which follows the submission of the written request for release of the patient, files with that clerk a certification that in the chief medical officer’s opinion the patient is seriously mentally impaired, the release may be postponed for the period of time the court determines is necessary to permit commencement of judicial procedure for involuntary hospitalization. That period of time may not exceed five days, exclusive of days on which the clerk’s office is not open unless the period of time is extended by order of a district court judge for good cause shown. Until disposition of the application for involuntary hospitalization of the patient, if one is timely filed, the chief medical officer may detain the patient in the hospital and may provide treatment which is necessary to preserve the patient’s life, or to appropriately control behavior by the patient which is likely to result in physical injury to the patient or to others if allowed to continue, but may not otherwise provide treatment to the patient without the patient’s consent.
[C50, 54, 58, 62, 66, 71, 73, 75, §229.41; C77, 79, 81, §229.4]