Recently, the spread of COVID‐19 virus infection and the increase of people number with chronic diseases have attracted great attention all over the world. The detection and control of such diseases based on patient demographic data are considered to be a major problem. The key issue in the solution to these problems is the development of methods and algorithms to forecast wellness and categorise patients according to their healthy and unhealthy states. In this paper, a comprehensive analysis of machine learning approaches in the field of diagnosing COVID‐19 has been conducted, and for the detection of chronic diseases in patients, to identify symptoms of COVID‐19 virus infection in advance, and control the situation a healthcare system has been proposed. The constructed system provides real‐time monitoring of chronic diseases and COVID‐19 virus infection in patients. The proposed system consists of five layers: IoT sensor layer, Data transmission layer, Fog layer, Cloud layer, the Application layer. The system architecture in the Fog layer uses machine learning and deep learning algorithms to diagnose patients' diseases, to generate and send diagnostic and emergency alerts to users. The classification module of the system's Fog layer categorises the patient's health status into healthy and unhealthy classes. In this module, to classify medical data the Decision Tree, Random Forest, SVM, Gradient Boosting, Logistic Regression algorithms are used. The COVID‐19 dataset is used to test the effectiveness of the methods. The best results from the comparative analysis of the methods are obtained from the Decision Tree, Random Forest, and Gradient Boosting algorithms, which are recognised data points with high accuracy and on the accuracy metric reached 1.0, 0.99, 1.0 values, respectively. The classification of the other two SVM and Logistic Regression algorithms provided the worst results, and the accuracy score of both classifiers obtained a 0.89 value.