Advanced wastewater treatment for separation and removal of pharmaceutical residues and other hazardous substances