Design of a Fog Computing, Blockchain and IoT-Based Continuous Glucose Monitoring System for Crowdsourcing mHealth

: Diabetes Mellitus, usually called only Diabetes, is a worldwide chronic metabolic disorder that is characterized by abnormal oscillations in blood sugar levels. Such levels should be monitored by diabetes patients, which traditionally have had to take blood samples by ﬁnger-pricking, at least between twice and four times a day. Finger-pricking has a number of drawbacks that can be tackled by Continuous Glucose Monitors (CGMs), which are able to determine blood sugar levels throughout the day and not only at speciﬁc time instants. In this paper, the design of an IoT CGM-based system is proposed, whose collected blood sugar sample values can be accessed remotely; thus being able to monitor patients, speciﬁcally dependent ones (e.g., children, elders, and pregnant women) and warn them in the case where a dangerous situation is detected. In order to create such a system, a fog computing system, based on distributed mobile smart phones, has been devised to collect data from the CGMs. Moreover, the use of a blockchain is proposed, to receive, validate, and store the collected data with the objective of avoiding untrusted sources and, thus, to provide a transparent and trustworthy data source of a population, which can vary in age, ethnicity, psychology, education, self-care, and/or geographic location, in a rapid, ﬂexible, scalable, and low-cost way. These crowdsourced data can enable novel mHealth applications for diagnosis, patient monitoring, or even public health actions, which can help to advance in the control of the disease and raise global awareness on the increasing prevalence of diabetes.


Introduction
Diabetes Mellitus (DM), usually called only Diabetes, is a worldwide chronic metabolic disorder that is characterized by abnormal oscillations in blood sugar levels. Diabetes is related to diverse illnesses, being involved with certain kinds of blindness and problems in the kidneys, blood vessels, or heart.
The World Health Organization (WHO) categorizes DM into three different types [1]: Type-1 DM, Type-2 DM, and gestational diabetes. Type-1 DM patients need insulin on a daily basis, since their body is not able to produce it properly. Type-2 DM is the most common, and occurs when the body makes ineffective use of insulin. Until recently, Type-2 DM was mostly observed in adults, but recently, largely due to higher weights and a lack of physical activity, it is increasingly occurring in children.
Regarding gestational diabetes, it is characterized by above-normal blood sugar levels in women during pregnancy.
Due to the characteristics of DM, it is important to monitor vulnerable groups, especially children, the elderly, and pregnant women. Such a monitoring has been traditionally performed by taking blood samples through finger-pricking, which has a number of drawbacks (e.g., active involvement of the patient/care taker, infections) that can be tackled by Continuous Glucose Monitors (CGMs), which are based on a small device with a sensor that takes blood sugar readings 24 h a day. Such measurements make it easier for diabetics to have more precise control over their blood sugar, and allow for the making of informed decisions regarding a potential treatment of a patient. Thus, CGMs may warn patients about glucose highs and lows, in order to take the appropriate preventive measures.
The concept of CGM opens the possibility of creating Internet of Things (IoT) devices that provide rapid warnings and take autonomous decisions, which need to be performed as fast as possible. Thus, an IoT CGM can make use of a remote cloud system where information is stored, and where decisions can be made according to rules (e.g., to warn a doctor when the patient's blood sugar level is above a specific threshold). However, a cloud computing based architecture may have certain limitations: All the information and decisions are centralized and managed, in general, by a third party; the cloud availability may be compromised by its massive use, or by cyber-attacks; and, due to the physical distance between patient and cloud, decisions require some time to be taken and communicated, which may be too high in some scenarios. Fortunately, for such scenarios where a fast response and low communications overhead are required, other paradigms have proven to be successful, by moving computing capabilities from the cloud towards the edge of the network [2]. One of such paradigms is fog computing, which transfers the cloud's computational and communication capabilities close to the sensor nodes, in order to minimize latency, to distribute computational and storage resources, to enhance mobility and location awareness, and to ease network scalability while providing connectivity among devices in different physical environments [3,4].
Another problem found when collecting and processing the sensed data from IoT devices is their security and trustworthiness. Regarding security, diverse authors have proposed energy-efficient mechanisms to make use of high-security cipher suites in IoT devices [5], since they are usually constrained in terms of computational resources-especially when they rely on batteries. With respect to trustworthiness, it is essential when data are shared with third parties. Therefore, the data collected for doctors, or for an autonomous system that acts upon the received blood sugar values, should be valid.
Crowdsourcing is a distributed problem-solving, knowledge management, and production model which takes advantage of the collective intelligence of an online community to research and develop innovative approaches and novel products and services. Its use within public health is starting to being explored [6], especially with the uprise of mobile health (mHealth) which enables healthcare through applications delivered using mobile phones and wireless technologies.
Traditionally, human intelligence-based crowdsourcing mHealth systems have managed the demands of patients and public health stakeholders in a centralized way, hence they are prone to attacks and have an inherent single point of failure. Moreover, sensitive user information is saved in a database that is exposed to data breaches and data loss.
In contrast, this paper proposes the use of a blockchain-based decentralized framework, which does not rely on any central third party and guarantees user privacy. It addition, the design of an IoT CGM-based system is described, whose collected blood sugar sample values can be accessed remotely, thus making it possible to monitor patients, specifically dependent ones (e.g., children, elders, pregnant women), and warn them in the case where a dangerous situation is detected. In order to create such a system, a fog computing system, based on distributed mobile smart phones, has been devised to collect data from the CGMs.

Related Work
Different authors have studied the use of CGMs, in order to apply them to different scenarios. For instance, in [7], the possibility of adding intelligence to CGM sensors is analyzed, in order to issue alerts when glucose levels are not within the appropriate range. The authors emphasize the fact that the sensors have to be calibrated, and that their data needs to be filtered to improve their signal-to-noise ratio. The same authors focused, later, on the same concepts in another paper that reviews the state of the art on contributions to the development of hardware and smart algorithms for CGMs [8]. Similar reviews on the evolution of CGM technology can be found in [9,10].
Other researchers analyzed specific aspects of the CGMs. For example, in [11], the authors studied the problem of calibration algorithms in commercial CGMs and the process of estimating the amount of glucose in blood plasma. Another study [12] highlighted the ability of CGMs to detect losses in the performance on insulin infusion set actuation, which can lead to dangerous complications in Type-1 DM diabetics due to prolonged hyperglycemia.
CGMs have also allowed for studying how daily habits affect diabetics. For instance, in [13], the impact of physical exercise on blood sugar levels on Type-1 DM patients is reviewed, concluding that even certain daily activities alter the dynamics of glucose and can cause problems with blood glucose regulation during and after exercise.
Finally, it is worth pointing out that, very recently, the IEEE introduced a draft on the part 10425 of its standard IEEE 11073 [14], which is aimed at standardizing the communication between CGMs and between a CGM and other devices (e.g., cell phones, computers, health appliances), in a manner that enables plug-and-play interoperability. Figure 1 shows the proposed communications architecture. In such a figure, CGM sensors collect blood sugar levels from multiple patients and send them to smartphones that run a mHealth fog service. The fog service collects and processes the data and, depending on the sensed values, the service decides the measures to be taken. Moreover, the fog service is able to send the processed values and additional information on the patients to both a remote server and to the blockchain, where they are stored. In the case of the remote server, it basically makes use of a back-end that collects the sensed values and a front-end that displays them in a user-friendly way through a web interface to remote users, like doctors, nurses, or caretakers for children/elderly.

Communications Architecture
Regarding the type of blockchain, a federated blockchain was selected to increase the transaction privacy and accelerate the transaction validation. Only registered and authorized users can access to the network, and the consensus algorithm is run by a pre-selected group of nodes. The federated blockchain stores the received data or their unique hashes, enabling public access to them in a secure way. Data anonymization of the patients can also be included to protect their privacy (i.e., to guarantee that there is no link with the real identity of a patient). In addition, the blockchain can run smart contracts; so, for instance, when it is detected that a user is going to run out of sensors, an automated purchase can be performed.

Implementation
In order to implement a first proof-of-concept version of the proposed system, the following components, which are shown in Figure 2, were selected:

•
CGM sensor: Abbott's Freestyle Libre. Although its reading range is limited (up to 20 cm) due to the use of NFC, its sensors last longer than others provided by Dexcom or Medtronic (14 days versus roughly a week), it is a cost-effective solution (e.g., a kit with one reader, and sensors currently cost e169.69), finger-pricking is not necessary on a daily basis to calibrate the sensor, and it is more accurate than other systems (i.e., it has lower Mean Absolute Relative Difference (MARD)). • Cloud service: Nightscout. It is an open-source system, aimed at collecting CGM data through a cloud service that is also able to display them though a web interface.

•
Smartphone apps: Glimp is used to read Abbot's Freestyle Libre CGM sensor through NFC. A lightweight Ethereum client can also run on the smartphone and a monitoring fog app may read the blood sugar values and decide whether it is necessary to take certain actions (e.g., warn the patient or his/her caretakers) without relying on cloud services.
• Back-end and front-end: Django. It is a framework, based on Python, that allows for quickly developing web applications. In addition, the proposed system makes use of SQLite3 as a database and HTML/Javascript for the web page displayed by the front-end.

•
Blockchain and smart contracts [15]: Ethereum. It is an open-source platform, based on blockchain technology, that is able to run smart contracts.

•
Warning system: Twilio and Telegram. Although, for clarity purposes, this system is actually not depicted in Figure 2, it is essential when sending warnings to remote users to their smartphone. Thus, Twilio allows the system to send custom SMS, while it a Telegram bot was programmed to send instant messages.
The regular functioning of the system is quite straightforward. After the sensor has been placed on the patient's arm, it has to be read periodically by approaching the smartphone. The read values can be uploaded both to Nightscout or Ethereum, where they may be accessed by remote users. When the read values exceed a pre-fixed threshold (specified through the managing web application that runs on the front-end), the system quickly sends warnings to the patient or to his/her caretakers. Regarding the information stored in Ethereum, depending on the scenario, it can be accessed by remote users of the public Ethereum blockchain, or by a selected group of users that run an internal blockchain. In both cases, besides storing the relevant data, smart contracts coded in Solidity can be run on the blockchain.

Preliminary Results
Although the presented system still needs to be enhanced (for instance, in this first implemented version, smart contracts were not deployed on the blockchain), the basic functionality of the system was tested on a patient for 14 days. As an example, Figure 3 shows a snapshot of one of the menus of the web front-end, which depicts the collected blood sugar level values. The system has been already proved to be useful since, as is pointed out by the orange circle in Figure 3, it was able to detect and warn the patient in advance, regarding a sudden descent in blood sugar level that anticipated a hypoglycemia.

Conclusions
In this paper, the design and a preliminary version of an IoT CGM-based system for crowdsourcing mHealth was presented. Such a system is able to collect blood sugar levels from remote CGMs, which can then be accessed remotely. Therefore, the system allows for the monitoring of patients and warning them in the case where a dangerous situation is detected. In order to create such a system, a fog computing system, based on distributed mobile smart phones, was devised to collect data from the CGMs and send them to a remote cloud and/or to a blockchain. Thanks to the blockchain and the proposed CGM-based system, it is possible to provide a transparent and trustworthy blood sugar data source from a population in a rapid, flexible, scalable, and low-cost way. Such crowdsourced data can enable novel mHealth applications for diagnosis, patient monitoring, or even public health actions, that may help advance the control of diabetes and raise global awareness on the increasing prevalence of the disease.