Article 27 (Right to freedom and security) (1) Everyone has the right to freedom and security. (2) No one may be wholy or partially deprived of their freedom, except as a consequence of a judicial sentence imposed for the practise of an act that is punishable by law with a prison term or the imposition by a court of a security measure. (3) The following cases of deprivation of freedom for such time and under such conditions as the law may determine shall be exceptions to this principle: (a) Detention in flagrante delicto; (b) Detention or remand in custody where there is strong evidence of the commission of a serious crime punishable by imprisonment for a maximum term of more than three years; (c) The imposition of imprisonment, detention or any other coercive measure subject to judicial control, on a person who improperly entered or is improperly present in Portuguese territory, or who is currently the object of extradition or deportation proceedings; (d) The imposition of disciplinary imprisonment on military personnel. Such imprisonment shall be subject to appeal to the competent court; (e) The subjection of a minor to measures intended to protect, assist or educate him in a suitable establishment, when ordered by the competent court of law; (f) Detention under a court order for disobeying a court ruling or to ensure appearance before a competent judicial authority; (g) Detentions of suspects for identification purposes, in such cases and for such time as may be strictly necessary; (h) Committal of a person suffering from a psychic anomaly to an appropriate therapeutic establishment, when ordered or confirmed by a competent judicial authority. (4) Every person who is deprived of his freedom shall immediately be informed in an understandable manner of the reasons for his arrest, imprisonment or detention and of his rights. (5) Deprivation of freedom contrary to the provisions of this Constitution and the law shall place the state under a duty to compensate the aggrieved person in accordance with the law.