Уведомления врачам, если жизненные показатели пациента выходят за пределы нормального диапазона с использованием C#

private void SendNotification(int glucoseLevel, int bloodPressure, int heartRate, int oxygenSaturation)
{
    // Check if the glucose level is too high
    if (glucoseLevel > 180)
    {
        // Send a notification to the doctor
        SendEmail("[email protected]", "High Glucose Level", "Patient’s glucose level is too high: " + glucoseLevel);
    }

    // Check if the blood pressure is too high
    if (bloodPressure > 140)
    {
        // Send a notification to the doctor
        SendEmail("[email protected]", "High Blood Pressure", "Patient’s blood pressure is too high: " + bloodPressure);
    }

    // Check if the heart rate is too high
    if (heartRate > 100)
    {
        // Send a notification to the doctor
        SendEmail("[email protected]", "High Heart Rate", "Patient’s heart rate is too high: " + heartRate);
    }

    // Check if the oxygen saturation is too low
    if (oxygenSaturation < 90)
    {
        // Send a notification to the doctor
        SendEmail("[email protected]", "Low Oxygen Saturation", "Patient’s oxygen saturation is too low: " + oxygenSaturation);
    }
}

private void SendEmail(string to, string subject, string body)
{
    // Create a new mail message
    MailMessage message = new MailMessage();

    // Set the recipient
        message.To.Add(to);

    // Set the subject and body
    message.Subject = subject;
    message.Body = body;

    // Create a new SmtpClient to send the email
    SmtpClient client = new SmtpClient();

    // Send the email
    client.Send(message);
}

Этот код использует пространство имен System.Net.Mail для создания нового объекта MailMessage и отправки его с помощью класса SmtpClient. Вам нужно будет настроить SmtpClient с соответствующим хостом и учетными данными для успешной отправки электронной почты.