Temporal sequence alignment and agglomerative clustering for the analysis of medical longitudinal data