# Anomaly Detection in Elderly Health Monitoring via IoT for Timely Interventions
## 2 Materials and Methods
### Data Flow Architecture and Communication System  
The data flow is designed such that, as soon as the M5 Stack collects and preprocesses the data, it is transmitted via a secure Wi-Fi connection to Azure SQL Database through an ASP.NET API, as depicted in Figure 4. Once received, the data is routed to a dedicated Azure Function, which retrieves the values, further preprocesses them, and passes them to the HADA model for evaluation. If the model identifies an anomaly, Azure Functions immediately triggers a set of automated actions:  
* Sending a notification to the alert system configured in Azure Notification Hubs;
* Generating a Short Message Service (SMS) alert through Azure Communication Services;
* Saving the incident in the database;
* After the incident is evaluated, the person responsible for monitoring the patient deactivates the alert, intervenes, and generates an intervention report so it is precisely known whether it was an actual incident or a false alarm (as the patient may have disconnected the bracelet), but also to identify the employee who intervened in case of a medical error.  
Figure 3: HADA data processing and training workflow.  
The UML diagram presented in Figure 4 includes the patient level, corresponding to the system's end user. He receives medical help in the event of anomalies and is subject to medical interventions when necessary. The wearable device collects vital data and transmits this data to the cloud infrastructure in real-time. As mentioned, this device features energy-saving capabilities, including a deep sleep mode. The cloud infrastructure ensures data transmission security through its mechanisms, preprocesses the data, transfers it to HADA, and generates alerts for patients or caregivers. HADA analyzes vital parameters using PCA, detects anomalies, and periodically updates the model to adapt to changes in patient conditions.  
These conceptual steps are schematically presented in Figure 5. For building the software pipeline, the Azure platform was chosen due to its multitude of features, which are necessary for managing a distributed monitoring system. Azure allows everything from data storage and processing to the automatic generation of alerts and workflow management. To achieve HADA integration, the following components were used:  
* Azure ASP.NET API for collecting data from MSStack devices;
* Azure Functions for serverless code execution, enabling rapid processing of received data and real-time generation of alerts;
* Azure Notification Hubs and Azure Communication Services for distributing notifications to operators, supervisors, and the monitored person's relatives based on the results of anomaly detection;
* Azure SQL Database for storing the patient's data history for subsequent system performance analysis.  
To ensure the integrity and confidentiality of the data, communication between M5 Stack and Azure is carried out through encrypted protocols (TLS/SSL). Additionally,  
Figure 4: The integrated system flow for monitoring the health of elderly people.  
Figure 5: Conceptual steps involved in the entire pipeline infrastructure.  
access to Azure resources is protected by multi-factor authentication and strict access rights management. The system is designed to comply with the General Data Protection Regulation (GDPR), ensuring the anonymization of personal data and implementing rigorous backup and recovery policies in the event of incidents.