Whenever, in the opinion of the physician of any prison or other place of confinement in which is imprisoned a woman who is about to give birth to a child during the term of her imprisonment, the best interests of the woman or of her unborn child require that she be granted a permit to be at liberty or discharged, he may so certify to the board or officer empowered to grant permits to be at liberty or discharges from the institution in which she is imprisoned, and such board or officer may, subject to such terms and conditions as appear necessary, grant the permit to be at liberty or the discharge.
Mass. Gen. Laws ch. 127, § 142