Mathematical modeling of self-organization in medicine, biology and ecology