Any public officer or employee who, without legal grounds, detains a person, shall suffer:
1. The penalty of arresto mayor in its maximum period to prision correccional in its minimum period, if the detention has not exceeded three days;
2. The penalty of prision correccional in its medium and maximum periods, if the detention has continued more than three but not more than fifteen days;
3. The penalty of prision mayor, if the detention has continued for more than fifteen days but not more than six months; and
4. That of reclusion temporal, if the detention shall have exceeded six months.
The commission of a crime, or violent insanity or any other ailment requiring the compulsory confinement of the patient in a hospital, shall be considered legal grounds for the detention of any person.