IoT: Plug and Play (Healthcare Edition)

Gauri Mane
SFU Professional Computer Science
13 min readFeb 11, 2023

Authors: Aditya Desai, Gauri Mane, Karishma Damania, Rubin Hazarika, Owais Hetavkar

…68. 78. 96. 112. 120. 120. 120. 120…

My heart rate at multiple points as I watched the Argentina versus France World Cup Final on Dec 18, 2022. Every gut wrenching miss, every sigh of relief, every tense moment was captured on my Apple Watch, shared across all my iOS devices and broadcast on my Strava account. Now, imagine millions of other fans like me, perched on the edge of their seats, watching every nail-biting moment with eyes wide open. Imagine the sheer volume of data collected, analyzed and synced across the globe.

Now, imagine the possibilities.

Imagine a world where we take the time to study the stories behind every spike in blood oxygen level, and every lull in sleep respiratory rate. A world where a device can recognize if a father is showing early signs of arrhythmia and notify him, so that he can make an appointment. So that he can make it to his daughter’s next game. And the one after that.

Imagine a world like that.

In this post, we want to do more than just imagine. We want to walk you through how existing technologies can help build this reality

Big Data and IoT

Big data refers to extremely large and complex datasets that cannot be processed using traditional data processing techniques. The amount of data created in the modern era has grown enormously, and this expansion has sparked the creation of new technologies and methods for managing, storing, and analyzing this vast amount of data.

IoT stands for “Internet of Things.” It refers to a network of physical devices, such as sensors, appliances, and vehicles, that are embedded with electronics, software, and connectivity that enable these objects to collect and exchange data over the internet.

Human lifestyle has undergone a significant transformation as a result of Internet of Things (IoT) devices. IoT is revolutionizing how we engage with technology, from smart homes to smart transportation. The volume of data created by these smart devices is likewise growing quickly along with the number of devices. Big data is essential in the IoT age for understanding the meaning of the enormous volumes of data created by these smart devices.

When IoT meets HealthCare

Healthcare may benefit from IoT by using it to boost productivity, cut expenses and enhance patient outcomes. IoT can be used in healthcare in the following ways:

Wearable medical devices: Wearable devices used for medical purposes such as fitness trackers, smartwatches and continuous glucose monitors, can gather information on a patient’s health condition, physical activity and medication adherence. This data can be used to identify early warning signs of disease, monitor patient progress, and inform treatment decisions. Additionally, wearable devices can also support remote patient monitoring, allowing healthcare providers to monitor patients remotely and respond quickly to any changes in their health.

Electronic Health Records (EHRs) : Healthcare professionals may access and share information electronically thanks to EHRs, which offers a central repository for patients’ data. EHRs can store and analyze massive volumes of organized and unstructured data, including lab results, radiology pictures and patient-generated data from wearable devices, thanks to integration of Big Data and IoT technologies. By enabling healthcare professionals to make more educated decisions based on a thorough understanding of the patient’s health, this can enhance patient outcomes. EHR can be implemented using AWS CloudWatch and AWS CloudFormation.

Remote patient monitoring: Remote monitoring systems can monitor vital signs and other health parameters. This reduces the need for in-person visits and improves patients outcomes by enabling healthcare providers to monitor patients remotely and respond rapidly to any changes in their health.

Clinical Decision Support Systems: Clinical decision support systems analyze vast volumes of patient data using algorithms and machine learning and then give healthcare professionals immediate recommendations for diagnosis and treatment. These technologies can aid healthcare professionals in decision-making, enhance patient outcomes, and lower risk.

Image reference from: https://www.researchgate.net/publication/356364214_IOT_Big_Data_Analytics_in_Healthcare_Benefits_and_Challenges

Predictive Analysis — The Algorithms and the Theory

Where the realms of IoT, big data and healthcare merge, we find the budding field of preventive medicine. Preventive medicine is not a novel idea. The practice of promoting a healthy lifestyle and identifying at-risk individuals before they succumb to an illness has been around as long as the medical field itself. The fields of bioinformatics, biostatistics and epidemiology are particularly involved in the predictive analysis and interpretation of patient data. This niche sector in the medical field is where the IoT and machine learning algorithms can really make an impact.

The IoT has already penetrated the medical industry through the use of digital biomarkers. Generally, biomarkers are biological molecules found in blood or tissue that can act as an indicator of normal or abnormal bodily function. They can be indicative of a specific disease or condition or they can be used to gauge a body’s response to a specific type of treatment. ‘Digital’ biomarkers serve the same purpose as their biological counterparts but instead of living in the human body, they exist in patient data. Pulse rate, blood sugar, gait monitoring are all examples of digital biomarkers currently used in the medical industry. Broadly speaking, all biomedical data that can indicate patient health and is acquired using digital tools can be classified as digital biomarkers. This necessity for digital data acquisition has paved the way for IoT devices. Whether it be simple wearable devices that monitor patient vitals (FitBit, Oura ring, etc.) or implants that track arrhythmia, and blood glucose levels, IoT devices collect and store massive amounts of data.

The PhysioBank databases is an ever-expanding example of digitized patient data that can be used as digital biomarkers for preventive medicine. It contains datasets from clinical critical care settings and waveforms composed of ECG data, gait and balance datasets and neuroelectric data. Operating with and performing predictive analysis on this data is where Big Data comes in. Classification algorithms are an essential part of this disease diagnosis process. Classification, in the context of medical data, uses a trained, supervised model to categorize and (potentially) predict a patient’s condition or susceptibility to a certain disease. Based on the classification model, the input patient data can be in the form of raw time series data or images. The use of classification models is prevalent in current research into the early identification of cardiovascular disease. Some of these models use NLP and assign parts-of-speech tags to different components of a patient’s EHR (electronic health record). Key noun phrases from the tagging process are sent to the next part of the model that identifies different digital biomarkers — medication, family history, heart risk factors — and assigns an indicator and timeline to at-risk patients. These classification models are trained on large patient datasets and their accuracy can be augmented by integrating data from everyday IoT devices.

While the theory of predictive analysis is important, it cannot accomplish much without the current technologies that enable it.

Big Data tools in IOT

Amazon Web Services (AWS) provides a range of technologies that can be used to implement Big Data and IoT solutions in healthcare. Here are some of the AWS technologies that can be used:

  1. AWS S3 / Redshift / DynamoDB: Are storage solutions that can be used to store large amounts of data, such as patient information, clinical notes, test results, and other healthcare data. They are a highly available and scalable solution, they can easily handle large amounts of data and grow with your organization’s needs. Redshift can be used to store and manage clinical data from various sources, such as electronic health records (EHRs), clinical trials, and medical devices
  2. AWS EC2: Amazon EC2 can be used to host and run medical image analysis systems, which can process and analyze large amounts of medical images, providing healthcare providers with valuable insights into patient health.
  3. AWS Kinesis / Kinesis Data Firehose / Kinesis Data Analytics: AWS Kinesis can be used to stream real-time patient data, such as heart rate, blood pressure, and other vital signs, enabling healthcare providers to quickly respond to changes in patient health. AWS Kinesis Data Firehose can be used to securely store patient data, and is fully compliant with healthcare regulations, such as the Health Insurance Portability and Accountability Act. AWS Kinesis Data Analysis can be used to analyze real-time patient data from medical devices, such as wearable fitness trackers and smartwatches, providing healthcare providers with valuable insights into patient health and enabling them to respond to changes in patient health in real-time.
  4. AWS QuickSight: AWS QuickSight can be used to analyze patient data and provide doctors with valuable insights into patient’s health and patient’s outcomes, with this they can prescribe them relatable drugs.
  5. AWS SageMaker: AWS SageMaker can be used to build machine learning models that analyze patient data to provide personalized recommendations for treatments, improving patient outcomes and reducing healthcare costs.
  6. AWS IoT Core/ AWS IoT Rule: AWS IoT Core can be used to monitor medical equipment and send alerts when maintenance is required, reducing the risk of equipment failure and improving patient safety. AWS IoT Rules can be used to integrate medical devices, such as wearables, into the healthcare ecosystem, enabling healthcare providers to access real-time patient data and respond quickly to changes in patient health.
  7. AWS CloudFront: A content delivery network (CDN) service for delivering web content, videos, and applications with low latency and high transfer speeds. In health care, Medical images and videos, like X-rays, CT scans, and videos of medical procedures, need to be sent quickly and easily. CloudFront can be used to send these files quickly and efficiently, even to places that are far away. This helps patients get better care and cuts down on wait times.

By leveraging the scalability, security, and reliability of AWS, healthcare organizations can gain new insights, improve patient outcomes, and reduce costs.

The Architecture of IoT-based Healthcare

Three fundamental layers make up the architecture of IoT in the delivery of health care. These layers work together to collect, process, and analyze data from various healthcare sources:

Perception layer

Technology for perception and identification forms the IoT’s core. Radio frequency identification (RFID), infrared sensors, webcams, GPS, medical sensors, and smart device sensors are a few examples of sensors — devices that can detect changes in the environment. These sensors are capable of comprehensive perception through object, location, and geographic recognition. They can also transform this data to digital signals for easier network transmission. IoT sensor devices with the potential to save lives abound, but not all of them have undergone clinical testing or been shown to be secure or efficient. In Multimedia Appendix 1, a list of IoT devices that could support and enhance the delivery of health services is presented.

Network layer

IoT technologies have a network level that consists of wired and wireless networks that communicate and store processed (layer 1) data locally or centrally. Low, medium, and high frequencies can all be used for communication between objects, with high frequencies being the main IoT focus. These comprise wireless sensor networks, Bluetooth, Zigbee, low-power Wi-Fi, and the global system for mobile communications, as well as short-range communication technologies including RFID, Bluetooth, and low-power Wi-Fi. Fourth-generation (5G) networks are developing and are expected to be a major driver of the growth of IoT applications for health care, with the potential to provide dependable connection to up to thousands of devices at the same time. High-frequency fourth-generation (4G) cellular networks have seen even more communication potential.

Application layer:

Delivering application-specific services to the user is the responsibility of the application layer, which also applies and interprets data. Artificial intelligence is used in some of the most promising medical applications that the Internet of Things offers (AI). AI has a wide range of scientific applications, including image analysis, text recognition using natural language processing, pharmacological activity design, and gene mutation expression prediction. Deep machine learning and IoT-based healthcare can help medical professionals perceive what is invisible and offer new and improved diagnostic capabilities. Combining technology and physician skill consistently improves system performance, even if diagnostic confidence may never approach 100%. Applying AI to retinal images, for instance, increased the detection and grading of diabetic retinopathy and macular edoema compared to the diagnostic evaluation by 54 ophthalmologists and senior residents, obtaining high specificities (98%) and sensitivities (90%).

An Implementation For Real-Time IoT Device Monitoring with Amazon Web Services (AWS) Kinesis

The AWS CloudFormation template is designed to deploy an end-to-end solution for monitoring IoT devices in real-time. The solution involves the deployment of several AWS services to securely read, process, and display the device connectivity and activity metrics.

When the connected IoT devices send data to AWS IoT, the AWS IoT rule is triggered which then sends the data to a Kinesis data delivery stream. The delivery stream stores the incoming data in an Amazon S3 bucket as an archive and also sends it to the Kinesis Data Analytics Application for processing. The Application then sends the processed data to a Lambda function which forwards it as a real-time stream to a DynamoDB table for storage which will be used to display the real-time metrics on the dashboard. Additionally, the application sends the processed data to a second Kinesis data delivery stream, which archives it in an Amazon S3 bucket, once again serving the purpose of an archive.

Further, In order to maintain a layer of security between the data produced by the IoT devices and the accounts or users that are authorized to access these metrics, an Amazon Cognito User Pool is used to provide authenticated access to the dashboard that is delivered using Amazon CloudFront Distribution.

Dashboard Implementation:

This solution employs four key elements of code to analyze and create the metrics on the real-time dashboard. The Amazon Kinesis Data Analytics application processes the data streams using SQL queries and produces the results. An AWS Lambda function is then utilized to transmit the processed data to an Amazon DynamoDB table for storage. A JavaScript file uses the results of the SQL queries to populate the chart on the dashboard, while an HTML file displays the chart in real-time.

Code Components:

Message Publishing:

For this demo, the send-messages.sh script is used to publish 1000 generated messages from 5 connected devices to the top ‘iot_device_analytics’.

  aws iot-data publish --topic "$TOPIC" --payload "{\"id\":\"1\",\"device\":\"$DEVICE\",\"flow\":$FLOW,\"temp\":$TEMP,\"humidity\":$HUMIDITY,\"sound\":$SOUND}" --profile "$PROFILE" --region "$REGION"

SQL Query:

This SQL query determines the average temperature recorded by all of the connected devices in one-minute increments. The results are saved in an in-application output stream called FAN_OUT_STREAM and labeled as ‘AvgTempValue’ along with the respective values.

-- 6. Average of the data point (temp) across all devices
CREATE OR REPLACE PUMP avg_aggregate_pump AS INSERT INTO FAN_OUT_STREAM
SELECT STREAM
STEP(source_sql_stream_001."COL_time" BY INTERVAL '1' MINUTE) AS event_timestamp,
'AvgTempValue',
'All',
0,
'Average',
AVG("temp") AS avg_value
FROM source_sql_stream_001
GROUP BY STEP(source_sql_stream_001.rowtime BY INTERVAL '1' MINUTE), STEP(source_sql_stream_001."COL_time" BY INTERVAL '1' MINUTE);

Lambda:

The Kinesis Data Analytics Application upon processing the data triggers the UpdateDDBLambda function which then transfers the data to the DynamoDB table as a real-time stream.

def put_record(metric_type, event_time, data, concurrency_token=None):
item = {
'MetricType': {'S':metric_type},
'EventTime': {'S':event_time},
'Data': {'S':dumps(data)},
'ConcurrencyToken': {'N':str(randint(0,maxsize))}
}


if concurrency_token:
client.put_item(
TableName = table_name,
Item = item,
ConditionExpression = 'ConcurrencyToken = :concurrency_token',
ExpressionAttributeValues = {':concurrency_token': {'N': str(concurrency_token)}}
)
else:
client.put_item(TableName = table_name, Item = item)

Javascript:

The dash.js file fills the chart with the average temperature reading recorded by all of the connected devices.

docClient.query(PerDeviceAvgTempParams, function(err, data) {
if (err) console.log(err);
else {
avgTempPerDeviceQueryTime = updateHorizontalBarChart(data, 20, avgTempPerDeviceChart, avgTempPerDeviceQueryTime, splitFunc);
}
});

HTML Elements:

The index.html file renders the HTML components received as results from the SQL Query.

<div class="col-md-5 col-md-offset-1 col-xs-12">
<div class="x_title">
<h3>Average Temperature Value</h3>
</div>
<div class="x_content">
<canvas id="avgTempValueCanvas"></canvas>
</div>
</div>

Dashboard Produced:

Anomaly Detection with IoT

The Real-Time IoT Device Monitoring solution utilizes the anomaly detection feature integrated in Amazon Kinesis to monitor data streams. An alert is triggered when an abnormal deviation is detected and the data will be displayed in the anomaly detection graph in the dashboard. For instance, if a device usually registers readings in the range of 0–30°C, and an anomalous value such as 58°C appears, this would be brought forth in the anomaly graph. This is especially useful since the quantity of data produced by a multitude of data is so high in velocity and volume, but using the capabilities of AWS Kinesis lets users be readily informed of any sudden changes or abnormalities in their systems’ performance.

Thus, through this implementation of Real-Time IoT Device Monitoring solution from AWS, we can see that Big Data Analytics integrated with IoT Devices can allow organizations to track time-series data on device connectivity and activity, react quickly to changing conditions, and make informed decisions to ensure the reliability, availability, and performance of their IoT devices. Further, we also have the flexibility to develop such personalized solutions for however small or large of a requirement, while being assured that these can be built, scaled and maintained using a cloud platform such as AWS.

--

--