Section 12M. If a pregnancy has existed for twenty-four weeks or more, no abortion may be performed except by a physician and only if it is necessary to save the life of the mother, or if a continuation of her pregnancy will impose on her a substantial risk of grave impairment of her physical or mental health.