Pope Francis waved to well-wishers from a hospital balcony in Rome as doctors were to discharge him after treatment.