what was the drug last prescribed to patient 40059 in their current hospital visit?
select prescriptions.drug from prescriptions where prescriptions.hadm_id in ( select admissions.hadm_id from admissions where admissions.subject_id = 40059 and admissions.dischtime is null ) order by prescriptions.startdate desc limit 1