(a) It is the duty of all officers of the state, or of any county or municipality thereof, or jailers having the charge and custody of any jail or place of detention, to receive any prisoners arrested by any officer or member of any law-enforcement office acting in his or her official capacity and to detain them in custody until ordered released by a tribunal of competent jurisdiction, and any officer, jailer or person having custody of any jail or place of detention who willfully fails or refuses to receive and detain the prisoner is guilty of a misdemeanor and, upon conviction thereof, shall be fined not less than $25 nor more than $200, or imprisoned in the county or regional jail for not more than sixty days, or both fined and imprisoned.
(b) Notwithstanding the provisions of subsection (a) of this section, no officer, jailer or other person having authority to accept prisoners in a county or regional jail is required to do so if the prisoner appears to be in need of medical attention of a degree necessitating treatment by a physician. If a prisoner is refused pursuant to the provisions of this section, he or she may not be accepted for detention until the arresting or transporting officer provides the officer, jailer or person accepting prisoners with a written clearance from a licensed physician reflecting that the prisoner has been examined and, if necessary, treated and which states that in the physician's medical opinion the prisoner can be safely confined in the county or regional jail.