Developing the Health Care System for Smart Drugstore Based on the IoT and the Embedded System

DOI: https://doi.org/10.53523/ijoirVol9I1ID113 Abstract Recent studies have confirmed that the third cause of death is medical errors, as many patients around the world suffer from poor health care. Many medical errors are caused by taking the wrong medication, expired medication, taking damaged medication, and taking medication with foods and drinks that are incompatible with the medication. The Internet of Things (IoT) technology has been used in healthcare applications to solve healthcare problems and medical errors for the elderly and people who need special medical care. A smart drug store was established using embedded systems to control the physical factors that affect the drug and contribute to the health care system. On all smartphone operating systems and computer operating systems and supports real-time communication with all work parts based on Internet of Things technology. The efficacy of action was proven by using 12 drugs that differ from each other in properties and obtained results of enhancing dose adherence (96.45%), adherence time (96.18%), and expiration (97.81%) through temperature control and alerting all necessary information for health care. A smart pharmacy protects medication from spoilage by controlling temperature and humidity, providing needed schedules for better healthcare, sending needed alerts, sending warnings about drug expiration or drug running out, and sending notifications to three pharmacies to provide the elderly with necessary information drugs. The product can be used in various workplaces, homes, businesses, and military units. The research was practically applied and the research proved successful through the results that will be displayed.


Introduction
The tremendous technological development in many fields, including the medical field, led to the emergence of smart medical systems provided by IoT technology in various medical systems [1,2]. IoT technology is one of the most advanced technologies that have been relied upon in managing smart cities, health services, and industrial magazines [3,4]. The IoT service can help the elderly and overcome their health problems and find appropriate solutions that provide them with good health care [5,6]. The elderly usually suffers from many health problems that increase with age, which makes caring for this large segment of society very important. The large number of health problems of the elderly forced specialists to identify the most important problems and find solutions to them [7]. The elderly need to take multiple types of medications at different times and multiple doses, which made the organization and management of medication intake and related determinants of the most important health care factors for the elderly [8,9]. Medicines need a safe environment to keep the medicine at the appropriate temperature [10]. Many types of medicines need to provide a database to save the various information about medicines, such as the appropriate temperature for preservation, indications information, and the precautions of taking the medicine with different foods and drinks [11]. The elderly need a means that enables them to control the means of storing the medicine, contact the database to find out information about the use of the medicine [12,13]. One of the best means available today is the use of mobile applications in entering and extracting various data due to its availability and ease of use [14]. IoT technology provides the ability to control the various means by which health care tasks go through the presence of the Internet [15,16]. This study aims to create a smart drugstore that provides distinguished health care services from storing medicines safely, sending alerts containing medication information, creating different tables that organize good health care for the elderly.

Related Works
Researchers have invested in the tremendous technological development in IoT technology. Health care is one of the most prominent areas in which researchers have focused their efforts because of its great role in the lives of an important segment of people. IoT is the key to solving many health care problems. Many researchers went to solve health care problems using IOT technology, and we mention them as the closest to this study. Daih et al. (2015), this study was conducted in Taiwan where the society was suffering from a large number of elderly people. Elderly people need to take medication for a long time. The study adopted the problem of obtaining the required medication as a problem among the elderly. The study went towards the design of a remote drug dispensing device that combines information technology and health care [17]. Elie et al. (2016), the researcher's study relied on isolated areas where there are few pharmacies, which forces some to stand for a long time to get the medicine. The researcher suggested relying on IoT technology to search for medicine in the pharmacy and keep the medicine from spoiling by using sensors that maintain the pharmacy temperature [18]. Thierry et al. (2017), this study is based on finding solutions for health care systems in sub-Saharan Africa that faces a shortage of medicines. This study is presented using smart medicine that adopts Internet of Things technology in the drug supply monitoring system and drug delivery at specified times to increase adherence to treatment times [19]. Juliaet al. (2018), this study suggested the use of IoT technology to obtain a healthy and safe environment. The study relies on sensors that send data, health data is sent and processed according to IoT technology, according to standard definitions [20]. Sivakumar et al. (2019), this study deals with the problem of patients waiting for long periods in the pharmacy to obtain the drug. The study aimed to solve the problem by creating an embedded system that distributes medicines automatically to reduce time and human errors [21]. Regina et al. (2020), the aim of this study is to find suitable options for consumers. The study relied on the development of a smartphone application for purchasing medicines from pharmacies. The study was conducted in Jakarta, Indonesia by ordering medicines through the application and sending the medicine to the customer without going to the pharmacy [22].

Suggested System Approach
The methodology of the proposed system for the establishment of the smart drugstore relied on two main stages, the stage of the embedded system and the creation of the drugstore, the stage of software that includes reliance on IoT technology. The cost of creating a single cube is $80. Figure (1) shows the diagram of the smart drugstore.

The Embedded System and The Creation of the Drugstore
The drugstore was constructed by using a box with air delivery tubes and a compressor for the refrigerant. The box was divided into four cubes. Figure (2) shows the cubes in the drugstore. Each cube operates separately and is separated by an insulating material, and each cube contains a special door. Each cube is designed in such a way that we can control the temperature and humidity, open the cube door, control the security of the cube and give different warnings. Each cube contains embedded systems as follows:

Digital Temperature and Humidity Sensor
Many applications depend heavily on how well we control temperature and humidity, such as applications that deal with food and medicine. There are many types of digital temperature and humidity sensors that differ from each other in degrees of measurement and accuracy. The best types of sensors used in healthcare applications are the DHT22 sensor for the ability to measure temperature (-40 -80)C°, accurately (+/-0.5) C°, measure humidity (0-100%) and accurately (+/-2%) suitable for storing all kinds of medicines, In addition to the other advantages of low cost and long life for this type of sensor. The sensor contains an integrated circuit that converts analogue values into digital values that are easy to handle in microcontrollers. The DHT22 sensor is connected to an Arduino Mega microcontroller to control the temperature and humidity needed to keep medicines from spoiling.

Door Sensor Magnetic
The smart drugstore has four cubes, each cube has a separate door. Cubes are used to store medicines at certain temperatures, so you need to control the proper closing and opening of the door. Failure to close the door correctly can raise the temperature of the cube and thus damage the medicines. The sensor consists of two wires separated from each other that emit a signal when they are separated. In the smart drugstore, use a magnetic door sensor that gives a certain signal when the cube door remains open for 10s. The magnetic door sensor is connected to the Arduino Mega microcontroller to control the alarms.

Keypad
There are many data entry devices for the devices, among the most used are keypads. All keypad are similar in terms of functionality. It consists of rows and columns intersecting to produce a set of letters, numbers, and symbols. Each cube contains a keypad installed on the door of the cube and connected with the Arduino Mega for entering data from a user name and password in the case of using the security product.

Arduino Mega Controller
An open-source, computer-programmed electronic microcontroller, commonly used in applications that require data processing. Many types of Arduino differ from each other in characteristics. The language C is used in Arduino programming. The microcontroller used the Arduino Mega type to build the smart store as it contains 54 digital pins, 16 analogue pins, 8k flash RAM, 8k SRAM. The data of the input and output devices in the Arduino Mega is processed from reading the temperature and humidity, alarming after 10 s from opening the door of the cube, processing data with a keypad, controlling the cooling system, ringing the buzzer, turning on the LED, and displaying on the LCD.

Cooling Blower
Store each type of medicine at a certain temperature that keeps the medicine from spoiling. The smart drugstore is built with four cubes to keep the temperature of each cube isolated from the rest. The smart drugstore design meets the needs of the elderly for the difference in the required medication. The smart drugstore cooling system consists of a refrigerant compressor, refrigerant tubes, and an air blower to control the refrigerant intake and thus control the temperature of the cube. The blower is controlled by connecting it to the Arduino Mega.

Buzzer
To get the best performance of the smart drugstore, especially as it is designed for use by the elderly, the on-site warning feature has been added. The buzzer is sounded 10 s after the door is opened to avoid damage to medicines. The buzzer is connected to the Arduino Mega to control the firing of the buzzer.

LCD
To facilitate the use of the product by the elderly, an LCD screen was used. The LCD is used to display the Arduino MEGA's output of temperature and humidity, Wi-Fi connection, security, and cooling system. A separate LCD screen was used for each cube. It was used a type LCD 4X20 with I2C.

LED
Another visual method of warning is provided for the best use of the product. Each cube is provided with some internal and external LEDs to alert the cube's operation and provide it with the electrical power necessary to operate it.

ESP Arduino
An open-source microcontroller that supports TCP/IP and WiFi connection creation. This type of microcontroller supports all tasks performed by the Arduino microcontroller. The ESP NODE MCU -12E microcontroller was used in this work as it is one of the best means that can convert a wired connection to a wireless connection. The microcontroller provides the advantage of using the technology of the Internet of things by connecting the parts wirelessly to each other in the presence of the Internet. It contains pins used for input and output, and buttons to install the system. It can work with a voltage (3-10) as it is equipped with a voltage regulator. The controller is programmed in the Arduino IDE, which is an easy-to-use programming language. Each cube contains a microcontroller that connects to the Arduino Mega microcontroller via serial communication (TX, RX) and is connected to the database in the electronic cloud with the presence of the Internet.

The Software That Includes Reliance on IoT Technology
IoT technology provides the ability to connect components to each other with the presence of the Internet. This wonderful technology allows the possibility of data exchange in real-time. The smart drugstore has been established based on this technology, where all drugstore components data are transmitted to the database and mobile application by ESP Arduino WiFi. IoT technology allows us to control temperature and humidity, send alerts, confirm medication intake, send various alerts, create medication history, and much more. The IoT stage depends mainly on the database and the mobile application.

Cloud Database
The product was created to serve the elderly. Older people do not have the health information that would enable them to make better use of the product. Establishing a reliable database supervised by a healthcare professional (admin) is essential to obtain the best results. Data for 10 drugs were entered into the database. The information added by the mobile application is directly added to the database in real-time based on IoT technology, where two more drugs are added, bringing the total of drugs used in the work to 12 drugs. A reliable database has been created that includes a list of cube details as shown in Figure 3, a list of the remaining drug dose information as shown in Figure 4, a list of drug information as shown in Figure 5, a list of the information of the three pharmacies from which the drug is ordered as shown in Figure 6. , the list of drug information used by the user as shown in Figure  7, the list of user information as shown in Figure 8. The Google Firebase service provided by Google was used to create the database, which is the best way to save data.

Mobile Application
The proliferation of smartphone applications in various fields has made it the ideal solution for use in the smart drugstore. The smart drugstore application was built using the JavaScript programming language due to its many features. The application was created for use with several mobile operating systems (Android and iPhone) and can also be used with computers. The mobile application communicates with the database based on IoT technology. The mobile application information is entered by the user. The application is protected with a username, password and email. A drug search is performed to enter drug information when a drug is not found in the database as shown in Figure 9. Azithrosam is in the database so it appears directly in the search. In the list of add drugs the drug information of drug dose, various warnings, date, drug dose number, drug quantity, drug expiry date are entered as shown in Figure 10. The mobile application data matches the real-time database.

Results and Discussion
The health requirements of the elderly and people who need special health care have been studied. The establishment of the smart pharmacy came to address health care problems, taking into account the improvement and development of the product to reach the best possible care. The product was used on 11 people and the product proved successful as shown in Table I. The product can be used locally by controlling the temperature and humidity of the cube by using the letter C, choosing the security status of the product operation (ARMED) by using a user name and password, and by using the letter B activating the alarm after opening the doors of the cube for 10 s to ensure that the medicines are saved from damage. Table II show the use of the product on-site on the LCD.
Smart pharmacy results are linked together by Internet of Things technology. The data is entered into the mobile application to match the data with the database in the cloud in real time. All results can be extracted via the application user interface. The results are in the form of tables and instructions that the user can read, and the other results come in the form of alerts. The user can follow the user's medication list, which shows the medications used by the user, and a list of all medications that represent all medications saved in the product and can be for more than one user, the history list includes the history of medications taken by the user, important alerts and warnings are sent to the user This includes alerting the need to replace the drug if the drug has expired, refilling the drug when the drug is out of stock, confirming the replacement and refilling, choosing one of the three pharmacies entered to send an email and providing the user with the drugs he needs, sending alerts about times to take the drug, sending Notes about the use of the drug, confirmation of receipt of the drug from the pharmacy, adding data and many other features that make it easier for the elderly to use. The Arabic language was used in the work as it is the target audience, in addition to the fact that the product is characterized by the possibility of changing the language according to the audience, as shown in Table (3).

Conclusions
The smart drugstore was created to meet the requirements of the elderly in the field of healthcare. The product can be used locally without the use of IoT technology and with certain limitations for the purpose of making the most of the product. The smart drugstore is used to save medicines from spoilage by controlling temperature and humidity, alerting of medication times, medication doses, medication schedules used by the user, medication schedule used in all cubes, medication history table for the user, confirming the exchange of medications at the expiry date, Refilling medications that are carried out upon use, confirming refilling, sending a drug purchase notice, choosing the pharmacy to be sent a notification to supply the drug, alerting the side effects of use, and many other features that allow the elderly to easily use them.