A deep learning framework for drug repurposing via emulating clinical trials on real-world patient data