Thermodynamics of apatite crystal growth and dissolution