A Family of Algorithms for Patient Similarity Based on Electronic Health Records