A general framework for building patient monitoring systems