NATIONAL UNIVERSITY OF HO CHI MINH CITY UNIVERSITY OF TECHNOLOGY FACULTY OF COMPUTER SCIENCE AND ENGINEERING GRADUATION THESIS Programming IoT Wearables to Enact a Rule-Based Alert Bu
Trang 1NATIONAL UNIVERSITY OF HO CHI MINH CITY
UNIVERSITY OF TECHNOLOGY FACULTY OF COMPUTER SCIENCE AND ENGINEERING
GRADUATION THESIS
Programming IoT Wearables to Enact a
Rule-Based Alert Business Process in Smart
Healthcare
Major: Computer Engineering COMPUTER ENGINEERING COUNCIL INSTRUCTOR: Dr Le Lam Son
Student: Duong Tan Huy (1652228) Lam Bao Duy (1652096)
Ho Chi Minh, 06/2021
Trang 2ABSTRACT
The Internet of Things is the use of network sensors in physical devices to allow for remote monitoring and control This technology has gained massive traction in various spheres like healthcare, banking, retail, manufacturing, consumer goods etc It is expected that patient will be treat more effectively with smart healthcare solutions where real time data are exchanged to help medical staffs make optimal decisions In this paper we demonstrate how wearables can be built semi Î automatically to enact a medical rule-based alert process that assists hospital doctors in taking care of outbreak patients in dengue epidemic
Trang 3ACKNOWLEDGEMENT
We would like sincerely thank to our thesis supervisor Dr Le Lam Son of the Department
of Faculty of Computer Science and Engineering at Bach Khoa University and my thesis advisor
Dr Ton Phuoc Long of the Faculty of IT at Industrial University, who enthusiastically assisting us
to build this system Their support has helped us immensely to move in the right direction and finish my work
Last but not least, we are extremely grateful to our family for providing us with unfailing support and continuous encouragement throughout our years of study They all kept us going and this accomplishment would have never been possible without them
Trang 4Table of Contents
CHAPTER 1: INTRODUCTION 1
1.1 Motivation 1
1.2 The rise of IOT in healthcare 1
CHAPTER 2: BACKGROUND 2
2.1 Internet of Things - IoT 2
2.1.1 What is IoT? 2
2.1.2 Fundamental stages of IOT 2
2.1.3 IoT Wearables in Healthcare 3
2.1.4 Advantages of IoT in Healthcare 4
2.2 Hypertext Transfer Protocol 4
2.3 MVC Architecture 5
2.4 RESTful Web Services 7
2.4.1 What is REST? 7
2.4.2 Making requests 7
2.4.3 HTTP Methods 8
2.4.4 Response Codes 8
2.4.5 Advantages and disadvantages of RESTful Web Services 8
CHAPTER 3: PROPOSED SYSTEM 9
3.1 System goal 9
3.2 Case Study 9
3.3 Architecture of the System 9
3.3.1 State Machine 11
3.3.2 Use case diagram: 13
3.3.3 Hardware and server design 14
Hardware design 14
3.3.4 Components operating principles: 17
CHAPTER 4: IMPLEMENTATION 24
4.1 Programming Language and Database 24
4.1.1 Arduino 24
4.1.2 Spring framework 25
4.1.3 MySQL 28
4.2 System Implementation 29
Trang 54.2.1 Arduino IDE 29
4.2.2 Server and Web application 30
4.3 Test cases: 35
4.3.1 Wearable devices: 36
4.3.2: Web application: 37
CHAPTER 5: CONCLUSION AND FUTURE WORK 41
5.1 Conclusion 41
5.2 Future Work 41
Trang 6LIST OF FIGURES
FIGURE 2.1:THE FOUR STAGES OF IOT SOLUTIONS 3
FIGURE 2.2:BASIC ARCHITECTURE OF A WEB APPLICATION 5
FIGURE 2.3:MVC DESIGN PATTERN 6
FIGURE 2.4:MVC ARCHITECTURE WITH USER ACTION 6
FIGURE 2.5:REST COMMUNICATIONS BETWEEN CLIENT AND SERVER 7
FIGURE 2.6:COMMON HTTPSTATUS CODES 8
FIGURE 3.1:SOLUTION ARCHITECTURE 10
FIGURE 3.2:MEDICAL PROCESS 11
FIGURE 3.3:STATE MACHINE OF THE PATIENTÓS WEARABLE 12
FIGURE 3.4:STATE MACHINE OF THE DOCTORÓS WEARABLE 12
FIGURE 3.5:WEB APPLICATION USE CASE DIAGRAM 13
FIGURE 3.6:COMPONENTS OF PATIENTÓS WEARABLE 14
FIGURE 3.7:COMPONENTS OF STAFFÓS WEARABLE 15
FIGURE 3.8:DATABASE STRUCTURE 16
FIGURE 3.9:LCDTEXT 1602 PINOUTS 18
FIGURE 3.10:LCDTEXT 2004 PINOUTS 18
FIGURE 3.11:ESP8266SPECIFICATIONS 19
FIGURE 3.12:ESP8266 PINOUTS 20
FIGURE 3.13:PCF8574SPECIFICATIONS 21
FIGURE 3.14:PCF8574 PINOUTS 21
FIGURE 3.15:4X5KEYPAD PINOUTS 22
FIGURE 3.16:DHT11 PINOUTS 22
FIGURE 3.17:LED PINOUTS 23
FIGURE 4.1:DIFFERENT BETWEEN TRADITION AND DEPENDENCY INJECTION PATTERN 25
FIGURE 4.2:SPRING CONTAINER WORKFLOW 26
FIGURE 4.3:SPRING BEAN LIFECYCLE 27
FIGURE 4.4:MYSQL MAIN PROCESS 28
FIGURE 4.5WI-FI CONNECTION CONFIGURATION FOR WEARABLES 29
FIGURE 4.6:HOW PATIENTSÓ WEARABLE SEND TEMPERATURE AND CHANGE LED 29
FIGURE 4.7:HOW DOCTORS WEARABLE RECEIVES PATIENT LIST FOR BROWSING 30
FIGURE 4.8:KEYPAD ASSIGNATION 30
FIGURE 4.9:DATABASE INITIALIZATION 31
FIGURE 4.10:LIMIT CONDITION FOR CREATING RECORDS 31
FIGURE 4.11:PROJECT STRUCTURE 32
FIGURE 4.12:ROLE RESTRICTIONS 33
FIGURE 4.13:LOGIN AND ÒREMEMBER MEÓ USING COOKIES APIS 33
FIGURE 4.15:DOCTORÓS ACCESS 34
FIGURE 4.16:PATIENTÓS ACCESS 34
FIGURE 4.17:MYSQLDATABASEÓS CAPACITY TEST 35
FIGURE 4.18:PATIENTÓS DEVICE 36
FIGURE 4.19:DOCTORÓS DEVICE MAIN SCREEN 36
FIGURE 4.20:DOCTORÓS DEVICE DETAIL SCREEN 37
Trang 7FIGURE 4.21:LOGIN PAGE 37
FIGURE 4.22:ADMIN HOME PAGE 38
FIGURE 4.23:ALL RECORD IN ADMIN VIEW 38
FIGURE 4.24:RECORD IN DETAIL OF 1 PATIENT 39
FIGURE 4.25:DOCTOR LIST IN ADMIN VIEW 39
FIGURE 4.26:PATIENT LIST OF SPECIFIC DOCTORS IN ADMIN VIEW 40
Trang 8LIST OF TABLES
TABLE 3.1MEDICAL RULE 9
Trang 9CHAPTER 1: INTRODUCTION
1.1 Motivation
The shift in the computing paradigm always opens the door to the next generation of computer-aided solutions The success of e-commerce Web portals in the last decades is nowadays followed by the ever-growing deployment of IoT-driven business processes, giving rise to the term dgkpi"eqkpgf"ÐuoctvÑ0 Business processes of such a smart solution should be geared up to best harvest IoT technologies like the IoT wearable Î a lightweight device that relies on IoT data-driven communications to keep people connected purposefully for, fire-fighting, prompting fast-food clients, and medical treatment, to name just a few IoT-driven smart solutions are expected to unlock new ways of handling challenges that most of the world is struggling with: environmental pollution, disease outbreaks, and natural disaster There are four fundamentals, yet separable functions of an IoT application: deploying interconnected devices, capturing data from the devices, transmitting that information across a data network, and taking action based on the intelligence collected From a uqhvyctg"gpikpggtkpiÓu"rqkpv"qh"xkgy."vjg"gpcevogpv"qh"dwukpguu"rtqeguugu"kp"such an IoT-based solution necessitates, to some degree, the automation of these functions though they could be engineered separately
It would be significant if patients with IoT wearables who are informed daily about their jgcnvj"ecp"vcmg"c"rtqcevkxg"tqng"kp"jgcnvj"ectg0"Vjg"rquukdknkv{"qh"wukpi"yktgnguu"ugpuqtu"qp"qpgÓu"clothes or body increases comfort, convenience, and the effectivenguu" qh" vjg" rcvkgpvuÓ" jgcnvj"treatment Conskfgtkpi" vjcv" vjgug" ecp" dg" oqpkvqtgf" cv" fkuvcpeg" ykvjqwv" chhgevkpi" vjg" rcvkgpvuÓ"routine Remarkably, medical monitoring can be done in real-time through various devices, allowing patients to check their situation and getting new orientations via smartphones or tablets
In this paper, I present a system, called OISP Hospital, where wearables play a central role
1.2 The rise of IOT in healthcare
With the recent advances in the Internet of Things (IoT), the field has become more and more developed in healthcare The Internet of things will help physicians and hospital staff
perform their duties comfortably and intelligently With the latest advanced technologies, most of the challenges of using IoT have been resolved, and this technology can be a great revolution and has many benefits in the future of digital
Nowadays, thanks to the help of IoT, people can remove barriers such as crowding at hospitals, saving tremendous costs by monitoring the patient's condition more closely and more than that, creating a closer relationship between the doctor and the patient by exchanging data between wearables
Trang 102.1.2 Fundamental stages of IOT
Stage 1: Sensor, aductors
First step consists of the deployment of interconnected devices that includes sensors, actuators, monitors, detectors, camera systems, etc These devices collect the data
Stage 2: Internet Gateways and Data Aggregation
A data acquisition system collects raw data from the sensors and converts it from analog into digital format the data is also filtered and compressed to an optimum size for transmission
Stage 3: Edge IT:
Once the data is digitized and aggregated, this is pre-processed, standardized and moved to the data center
Stage 4 Data Center and Cloud:
In this stage, data will be analyzed, managed and securely stored for in-depth processing and
follow-up revision for feedback and crucial business decisions Stage 4 processing may execute precise analysis by combining data from other sources, both in the digital and physical worlds These sources can analyze to identify significant trends and patterns
Trang 11Figure 2.1: The four stages of IoT solutions (Source:
https://intersog.co.il/blog/coding-for-iot-what-language-does-your-wristband-speak/)
2.1.3 IoT Wearables in Healthcare
Wearable technology in healthcare includes electronic devices that users can wear on their wrist, like smartwatches which are designed to collect the constantly data of patients' personal
vjg"wugtÓu"rtqitguu"yknn"dg"vtcemkpi"in the most optimal way though the wearable medical devices are in high demand because they improve visibknkv{"kpvq"tgngxcpv"curgevu"qh"cp"kpfkxkfwcnÓu"jgcnvj"status to make more informed decisions about their health The benefits of using these healthcare wearables include:
- Oqpkvqt"Xwnpgtcdng"RcvkgpvuÓ"Jgcnvj"ykvj"Uvcvwu"Cngtvu"cpf"Cnctms
- Patient-Physician Information Sharing
- Social Media Sharing Capabilities
Trang 122.1.4 Advantages of IoT in Healthcare
The major advantages of IoT in healthcare include:
Real-Time monitoring
Real-time monitoring of patients allows hospital staff to react to critical changes immediately Thus, they can intervene in the patient's condition at just the right time Real-time monitoring is also helpful for remote care And together with telemedicine, doctors can provide accurate recommendations to patients thav"ecpÓv"dg"uggp"kp"rgtuqp0
Fewer Human Errors
Though IoT devices pose the risk of overloading doctors with data, if used correctly, they ecp" jgnr" ykvj" fkcipquku0" Cnuq." KqV" fgxkegu" ecp" jgnr" vtcem" rcvkgpvuÓ" cevkxkvkgu" cpf" tgcevkqpu" vq"medication, which can help to personalize treatment plans and reduce the possibility of medical errors
Cost Reduction
IoT enables patient monitoring in real-time, thus significantly cutting down unnecessary visits to doctors, hospital stays, and re-admissions
2.2 Hypertext Transfer Protocol
The Hypertext Transfer Protocol (HTTP) is an application-level protocol for distributed, collaborative, hypermedia information systems This is the foundation for data communication for
the World Wide Web (i.e., internet) since 1990
HTTP is a generic and stateless protocol that can be used for other purposes as well as using extensions of its request methods, error codes, and headers HTTP is a TCP/IP based communication protocol, that is used to deliver data (HTML files, image files, query results, etc.)
on the World Wide Web The default port is TCP 80, but other ports can be used as well It provides
a standardized way for computers to communicate with each other HTTP specification specifies jqy"enkgpvuÓ"tgswguv"fcvc"yknn"dg"eqpuvtweted and sent to the server, and how the servers respond to these requests
Trang 13Figure 2.2: Basic Architecture of a Web Application (Source: https://topdev.vn/blog/http-la-gi/)
2.3 MVC Architecture
MVC architecture is common and widely used in developing app and web application This design pattern consists of 3 parts: Model, View and Controller
Trang 14Figure 2.3: MVC design pattern (Source: https://www.educative.io/blog/mvc-tutorial)
Figure 2.4: MVC architecture with User action (Source:
https://www.educative.io/blog/mvc-tutorial)
Trang 15MVC Architecture advantages:
2.4 RESTful Web Services
2.4.1 What is REST?
REST stands for Representational State Transfer It is an architecture that provides communication between client and server Client side and server side can be implemented independently This makes the paradigm stateless, help RESTful applications become reliable, quick, high performed and can be managed without affecting the whole system even while it is operating
Figure 2.5: REST communications between client and server (Source:
https://antmedia.io/rest-api-getting-started-guide/)
2.4.2 Making requests
A request from client to the server consists of following:
Trang 162.4.3 HTTP Methods
The RESTful web services have four basic methods:
Disadvantages:
Trang 17CHAPTER 3: PROPOSED SYSTEM
3.1 System goal
With a large number of infections increasing every day during the outbreak of the epidemic, doctors will have to work very hard to take care of all patients Therefore, the system was born with the aim of reducing the workload for medical staff also ensuring patientuÓ"follow-up is always optimal
3.2 Case Study
We walk through a case study of a healthcare process for treating outbreak patients that suffer from dengue fever in Vietnam This process monitors patients and alerts doctors using programmable wearable devices that are coordinated with a rule-based server This server-side coordination needs to be customizable to allow the hospital management to, for example, assign/re-
assign a patient to another doctor/nurse
3.3 Architecture of the System
Two types of wearable are put in use for the system: one for patients and the other by doctors or nurses They are linked to the ugtxgt"vjcv"eqnngevu"rcvkgpvuÓ"dqf{"vgorgtcvwtgu"cu"vkog-
series data The hospital management can assign the medical rules to treat the dengue cases optimally These rules, combined with data collected over time, enable the medical staff to make priority decisions instead of checking manually and frequently each patient in a chaotic hospital environment
Table 3.1 Medical Rule
Dengue
heart failure or pulmonary edema)
parameters)
every 6 hours) Out of 4 condition
above
Trang 18Figure 3.1: Solution architecture (Source: Enacting a Rule-Based Alert Business Process in Smart
Healthcare Using IoT Wearables [4])
Figure 3.1 shows the overall architecture of the system we built As mentioned in Table 3.1, each rule states what medical action needs to be taken kh"c"rcvkgpvuÓ"dqf{"vgorgtcvwtg."
measured by their wearable, reaches a critical level sustainably
The first wearable of the system is for, and supposed to be worn by, patients It constantly sends the wearer real-time body temperature to the coordinating server Many of them are in a serious health condition and may not be able to cooperate voluntarily The server keeps track of vjg"rcvkgpvÓu"dqf{"vgorgtcvwtg"cpf"jgnru"fqevqtu1pwtugu"fgekfg"yjcv"vq"fq"pgzv"kp"c"twng-based manner
The second wearable is to be worn by the medical staff, i.e., doctors and nurses Its wearer can query the status of any patient she/he is responsible for The server maintains a rather simple database assigning a doctor or nurse to patients she takes care of in the hospital In case there is at
Trang 19least 1 patient in critical condition, the device will receive a warning The entire medical process
of monitoring patients is described in Figure 3.2 using a de-facto modeling standard
Figure 3.2: Medical process (Source: Enacting a Rule-Based Alert Business Process in Smart
Healthcare Using IoT Wearables [4])
3.3.1 State Machine
Hkiwtg"505"fguetkdg"hqt"wu"jqy"vjg"uvcvg"ocejkpg"qh"vjg"rcvkgpvÓu"ygctcdng"vq"dg"fghkpgf"xkuwcnn{0" Gcej" rcvkgpvÓu" ygctcdng" oc{" dg" kp" qpg" qh" vjg" hqnnowing states at run-time: Starting, Listening, Emergency, Recovery, Incubation, Febrile and Abnormal, the first of which refers to the moment when the wearable is switched on and establishes Wi-Fi connection to the coordinating server The wearable makes a transition to Listening when ready In this state, the wearable constantly takes a reading of its ygctgtÓu"dqf{"vgorgtcvwtg"vq"eqoowpkecvg"ykvj"vjg"ugtxgt0"Ujqwnf"the server decide to activate a medical rule, this wearable will change its state to either Emergency, Recovery, Incubation, Febrile or Abnormal
Trang 20Figure 3.3: State ocejkpg"qh"vjg"rcvkgpvÓu"ygctcdng (Source: Enacting a Rule-Based Alert
Business Process in Smart Healthcare Using IoT Wearables [4])
Figure 3.4: Stavg"ocejkpg"qh"vjg"fqevqtÓu"ygctcdng (Source: Enacting a Rule-Based Alert
Business Process in Smart Healthcare Using IoT Wearables [4])
Trang 213.3.2 Use case diagram:
Figure 3.5: Web application Use case diagram
Trang 223.3.3 Hardware and server design
Figure 3.6<"Eqorqpgpvu"qh"rcvkgpvÓu"ygctcdng
Trang 23EqorqpgpvuÓ"cppqvcvkqpu<"
For doctors: Vjg"fqevqtuÓ"fgxkegu"hgcvwtg"vjg"hqnnqykpi"eqorqpgpvu<"
- cp"NEF"hqt"dtkghn{"fkurnc{kpi"vjg"rcvkgpvuÓ"kphqtocvkqp"
Figure 3.7<"Eqorqpgpvu"qh"uvchhÓu"ygctcdng
Trang 24FcvcdcugÓu"uvtwevwtg"yknn"dg"created like this
Figure 3.8: Database structure
Trang 25Vcdng"ÓwugtuÓ< Each person in the system will have an account with unique name and
username The administrator will make the same name a bit different, for example, Nguyen Van A and Nguyen Van A (1), etc., similarly
to username
Vcdng"Ówugt"tqngÓ< user id mapped by id ip"vcdng"ÓwugtuÓ"cpf"tqng"kf"gzrtgssed by id in table
ÓtqngÓ"yknn"ujqy the role of each user
Vcdng"ÓtqngÓ< Pairs (id - name) such as: 1 - ADMIN, 2 - DOCTOR, 3 - PATIENT
Vcdng"ÓtgeqtfÓ< Vjku"vcdng"yknn"uvqtg"vjg"fgvckn"qh"gcej"tgeqtf"eqortkukpi"qh"rcvkgpvÓu name,
rcvkgpvÓu" kf." vjg temperatwtg" cv" c" egtvckp" vkog." fqevqtÓu" pcog" cpf" fqevqtÓu" kf" jg1ujg" ku" dgkpi"monitored, etc
Vcdng"ÓfqevqtÓ< Gcej"fqevqt"yknn"jcxg"wpkswg"kf"cpf"pcog."ukoknctn{"vq"vcdng"ÓwugtuÓ0 Vcdng"Órgtukuvgpv"nqikpuÓ< Used by Spring Remember Me API to store token and the time
user last logged in
3.3.4 Components operating principles:
1 LCD Display
The LCDs consists of the following pins:
- Enable pin: enables to write to the registers
- 8 data pins (D0 Î D7): each pin has 2 states of high and low for storing data values
- Contrast pin (V0): controls the display contrast
Features of LCDs: