This paper describes the methods of development of ontologies and ontological models in medicine. A four-level model of knowledge representation is suggested. Algorithms for prevention of critical condition risks and complications are developed on the basis of ontological methods of knowledge representation. The work is based on the model-theoretic approach to representation of medical knowledge. The knowledge is represented through partial atomic diagrams of algebraic systems, as well as representation of patient's case data via Boolean-valued models. Ontology and ontological model of the "spinal deformity and degenerative diseases of the spine" subject domain have been developed. The ontology model contains: a) universal knowledge that is true for all patients, b) data on specific patients, and c) estimated (fuzzy) knowledge that is used for recommendations for doctors. Estimated knowledge is a set of probabilistic hypotheses on the possibility of emergence of patient's critical condition or complication. An algorithm for generation of estimated (fuzzy) knowledge, based on the analysis of medical records, has been developed. A software system for generating recommendations to prevent and reduce the risk of patient's critical condition has been implemented. The software system has been tested on the data of patients with spinal deformity and degenerative diseases of the spine.