Nothing in this act shall be construed to apply to any person alleged or thought to be a mentally ill person subject to involuntary commitment for care and treatment under this act who is in custody on a criminal charge, except with the consent of either the prosecuting attorney or trial court.
K.S.A. 59-2983