Sofia was rushed into emergency surgery and doctors said she might not survive