When deemed necessary, a court may order a defendant to be remanded for psychiatric medical examination. However, the defendant may not be subjected to this measure against his will unless he is in detention or he is accused of an offence of certain gravity. A person not accused of a crime may not be remanded for a psychiatric medical examination. However, on his consent a doctor's statement of his mental condition may be acquired.