When a patient of any hospital for persons with mental illness becomes incorrigible and unmanageable to such an extent that the patient is dangerous to the safety of others in the hospital, the administrator, with the consent of the director of the Iowa department of corrections, may apply in writing to the district court or to any judge thereof, of the county in which the hospital is situated, for an order to transfer the patient to the Iowa medical and classification center and if the order is granted the patient shall be so transferred. The county attorney of the county shall appear in support of the application on behalf of the administrator.