New York state lawmakers have approved legislation requiring doctors to issue drug prescriptions electronically within three years.