The principles and prototyping of a knowledge-based diabetes management system