This is a question that involves religion, philosophy, legal opinion, and cultural factors. It is, therefore, not an easy answer and cannot be answered by one segment of society, and that includes the Supreme Court, which is highly influenced by religious thinking, with five of the nine Justices being practicing Catholics. 
     Catholicism is strongly associated with the right to life, and Feminism is strongly associated with pro-choice. So who is right? That too is a difficult question to answer. It depends on when in history you ask the question.  Catholic thinking was not entirely pro-life when Saint Thomas Aquinas, Augustine of Hippo, and Saint Jerome were opining about it. Quickening was the dividing line. This is when the mother detects the first movement of the fetus. That is also not an exact point. It can be seen as early as 16 weeks and as late as 25 weeks.
     In the Roman era, abortion was practiced and not opposed by the church. It was not until the middle ages that it became an issue. The problem became more urgent because nuns were showing up pregnant, and not all of them were in that state by “divine impregnation” i.e., virgin conception. It was Pope Gregory XIV who determined (ex-cathedra) that ensoulment occurred at 166 days (24 weeks)  after conception. The three “Supersaints” Aquinas, Augustine, and Jerome did note that conception was God’s will, but it was not until ensoulment that determined that a fetus becomes a human person in the church’s eyes as to when abortion becomes the taking of a life, i.e., homicide. Prior to that, it was NOT a mortal sin.
     The whole idea of taking a human life then sprang from ensoulment, which also is a vague point in time. That and quickening roughly coincide in the writings and canons of the church. The pro-lifers historically cannot point to “early abortions” – before 24 weeks to taking of a human life, at least not on the cultural and historical data. And that did not change until 1869  when Pope Pius IX  proclaimed that Mary, Mother of God, was free from sin in the first instant of conception. From then on and not before, any conception that was terminated through human action was considered a homicide. It was not until 1869 that the church reversed the nearly eight-century position of ensoulment. For the last 150 years, a more radical position that any interference with conception, including even blocking conception (birth control – condoms, birth control pills, etc.) was a mortal sin.  
     What about other religions that legitimately have a voice in this moral dilemma? Jews are of the opinion that life does not start at conception. In fact, the status of personhood does not happen until birth. If the mother’s life is at risk because of the pregnancy, the fetus has to be destroyed in order to save the life of the mother. Over 80% of Jews support abortion for any reason.
     Islam also uses ensoulment as the point of personhood. The Prophet Mohammed has placed that to be at 120 days from conception. Protestants are not united in one stance on abortion. However, 60% support abortion rights, similar to Hindus, while Buddhists are overwhelmingly supportive of abortion at 82%. The overall support in the US for abortion is 60%, while 40% are opposed.
     The beating heart is not a sensible measure of personhood. The heart is not the seat of the soul, no matter what Aristotle claimed. If the contraction of an organ is the deciding measure, you might as well use the function of the colon as the determining factor. The human embryo has heart muscle that starts to contract at five weeks but cannot sustain life. A heartbeat can be detected at ten weeks by ultrasound, but the actual beating of the heart cannot be heard by the human ear until 20 weeks. I am not sure when ensoulment happens. I am not even sure I know what a soul is. I do know that after 24 weeks, the fetus can survive outside the mother’s womb. That would be what I would consider viability.
     What do we do with issues that divide us usually? We vote on it. I would put it on the ballot, and let the majority decide. On second thought, that didn’t work out so well last time.