Water and carbon dioxide for sustainable synthesis and separation of pharmaceutical intermediates