Implementing a pharmacovigilance framework using data from electronic medical records