A general model of hospital behaviour