Nasogastric Tube Dislodgment Detection in Rehabilitation Patients Based on Fog Computing with Warning Sensors and Fuzzy Petri Net

1Division of Infectious Diseases, Department of Medicine of Chi Mei Medical Center, Tainan City 710, Taiwan 2Department of Biochemistry, Medical College of National Cheng Kung University, Tainan City 70101, Taiwan 3KSVGH Originals & Enterprises and Department of Engineering and Maintenance, Kaohsiung Veterans General Hospital, Kaohsiung City 81362, Taiwan 4Department of Electrical Engineering, National Chin-Yi University of Technology, Taichung City 41170, Taiwan 5Department of Electrical Engineering, Kao-Yuan University, Kaohsiung City 82151, Taiwan


Introduction
(3) An NG tube is a flexible plastic tube inserted through the nose, the nasopharynx, the gullet, and into the stomach, as shown in Fig. 1(a). A pH testing result of <5 indicates that the tube is placed in the correct position.The NG tube can be easily placed and is taped to the patient's nose using a nose clip to prevent its accidental removal.However, some infectious complications may develop over several days or weeks after the insertion of the NG tube, such as nose bleeds, aspiration pneumonia, pulmonary aspiration, and acute respiratory distress syndrome. (1,6,7)In addition, mechanical complications occur during practical usage, such as tube displacement, dislodgment, or clogging, which may affect the delivery of nutrients to patients. (8)Such an unplanned extubation can be categorized into deliberate self-extubation and accidental extubation.Tube dislodgment can occur while the patient is being repositioned in bed, during walking, or during transfer to a chair.Sometimes, discomfort in the nares and a tube sensation in the pharynx may also cause patients to remove and dislodge the NG tubes.
In a rehabilitation room, >35% of patients require the placement of NG tubes, of whom about 70% have deliberate self-extubation and 30% have accidental extubation.These patients primarily include >60% of those aged >65 years and 64% of males, with 80% of them comprising the majority with ischemic stroke.To prevent such cases of unplanned extubation, this study was conducted to design a digital warning tool to detect NG tube dislodgment based on fog computing (9,10) using warning sensors and fuzzy Petri net (FPN) for patients under rehabilitation.Two warning sensors were arranged on the left and right sides of the nose tape, as shown in Fig. 1(b).Each sensor is a light-dependent resistor (variable resistance semiconductor) with varying light intensities.The resistor voltage divider and the voltage follower can be used to transfer voltage changes in the sensing unit.The FPN (11)(12)(13) is a dynamic and marked graphical system and can be extended to develop an algorithm to deal with fuzzy inferences for decision-making applications.In the fuzzy layer, fuzzification operations can convert the analogy voltage changes into membership grades using Z and S sigmoidal membership functions (MFs).Petri net is used to map these grades into rule-weighted outputs for decision-making to identify NG tube dislodgment.
On the basis of fog computing (edge computing) applications, (9,10) this framework can primarily analyze time-sensitive data at the network edge or near the sensing unit, instead of sending a vast amount of sensing data to the cloud layer.In this study, a digital warning tool, as seen in Fig. 1(b), is designed as a local connecting network, including one or more end-sensing units and a remote monitor system (such as a smart phone or iPad) in a rehabilitation room for individual or multibed monitoring applications.Any sensing unit detects abnormal data at the edge of the wireless communication network, while a wireless transmitter sends the selected warning messages to the cloud for further analysis and storage.This technique can reduce the communication bandwidth between the sensor and the central data center and involves the wireless sensor network, mobile data acquisition, and mobile signature analysis.The sensing unit along with the two warning sensors on the left and right sides of the nose manipulates highand low-analogy voltages with varying light intensities.The proposed assistant warning tool can continuously monitor the real-time unplanned extubation in the fog computing layer and can also integrate with the wireless sensor and the intelligent mobile device via fog-to-remote device communication for use in the rehabilitation room.The FPN-based digital warning tool can deal with input analogy voltages to clarify tube dislodgment with minimum and maximum composite operations (14) and the corresponding output with the logic high signal to drive an alarm unit.It performs computation and analysis operations using the microcomputer and microcontroller, (15,16) as shown in Fig. 2. Therefore, warning sensors and the digital warning tool were integrated into an intelligent end-alarm unit to indicate the warning information in the fog computing layer.Its inference output can also send warning information to the cloud layer via the WiFi wireless local area network [IEEE 802.11Standard, WLAN (17) ] to the central data center and iPad (smart phone).The experimental results demonstrated the efficiency of the proposed prototyping tool.This digital alarm unit based on fog computing can also be used for multibed monitoring applications in rehabilitation rooms.The remainder of this article is organized as follows.In Sect.2, we describe the methodology, including the warning sensor, FPN, and alarm unit based on fog computing.In Sects. 3 and 4, we present the experimental results and conclusion, respectively.

Warning sensors and FPN
In this study, the warning sensor was made of a high-resistance semiconductor and was a light-controlled variable resistor (illumination: 0.1-1000.0Lux).The warning sensor was sensitive to light spectrum between 500 (green light) and 700 nm (red light), manipulating the low or high resistors as a dark-activated switching circuit.When it acted in the dark-activated state, the sensor resistor was >10 MW, and as the light intensity increased, the internal resistor decreased.Two light-controlled sensors were arranged on the left and right sides of the nose tape for continuous monitoring.As shown in Fig. 2, a resistor voltage divider with a warning sensor (R s ) and a pull-down resistor (R g ) were connected to a constant voltage source of V cc = +5.0VDC (current: 0.00-5.00mA).In the case of an NG tube dislodgment, any warning will detect light as the sensor resistor decreases.This implies that the current flowing through both R s and R g will increase through the constant voltage source V cc to the ground, and the nodal voltage across the pull-down resistor will also increase.Then, the two sensing nodal voltages, V i , i = 1, 2, could be obtained on the analog input connectors as follows: The analog input ports were used to measure the 0.0-5.0VDC voltage signals via the voltage followers to analog-to-digital converters (ADCs).Then, digital nodal voltages, V i , i = 1, 2, were applied to the FPN-based digital warning tool.As shown in Fig. 3, the voltage level changes were parameterized using the Z and S sigmoidal MFs to describe the high or low voltage level as shown below.
Here, V i is the nodal voltage; the index i is the number of warning sensors, i = 1, 2; the MFs μ i,1 are used to detect the voltage change for Sensor 1# and Sensor 2#, which are employed to identify the high voltage level, and the MFs μ i,2 are used to identify the low voltage level, as seen in Fig. 3.The standard deviation s is 0.5 VDC in this study.As shown in Fig. 3, a membership grade between "0" and "1" is assigned to represent the high and low voltage levels in the sensing unit.
The FPN can be used to represent the Fuzzy IF-THEN rules of a rule-based inference system for the detection of NG tube dislodgment, as shown in Fig. 4. It is a marked graphical system containing the following two types: places (Pl) and transitions (Tr), where circles represent Pls and bars represent Trs.Each Tr is associated with a certainty factor between "0" and "1".In general form, the definition of the FPN is as follows: (10)(11)(12) where Pl = [p 1 , p 2 , p 3 , …, p m ] is a finite set Pls; The structure of the FPN-based inference tool is represented by a rule connectivity graphical system, as depicted in Fig. 4. The FPN performs the minimum (AND operator) or maximum (OR operator) composite operations [by Looney and Alfize (14) ] to generate the final goal Pr C, and the overall FPN inference rules are shown in Table 1.The FPN algorithm is summarized as follows: Step (1): Step (3): compute the proposition using MF, θ i (p i ), then Pr is d i = θ i (p i ), i = 1, 2, where θ i (p i ) is a nonlinear approximator and is defined by Step (4): perform the maximum operation in place Pl-2#, p 3 = max{d 1 , d 2 }, j = i*, i* is the index at its maximum value in place Pl-2#.
Step (5): compute the final output C = W j × d j , where the index j = 1, W 1 = 1 for "NG tube dislodgment", and the index j = 2, W 2 = 0 for normal condition, as In place Pl-2#, the value p i *, 0 ≤ p i * ≤ 1, θ i* (p i* = 0) = 0.3679, and the larger the value, the more likely the output goal Pr will be identified.We have the following two states: • NG tube dislodgment: W 1 = 1 and the final output C > 0.3679, • normal condition: W 2 = 0 and the final output C = 0.0000.
A hard limit function with the threshold value of 0.50 is used to produce the high-voltage signal to drive an alarm unit as follows: 1, 0.50, * 0, 0.50, where the index C* sets the digital output state as either "logic high (1)" or "logic low (0)".The output index C* is used to identify the possible state for normal condition (0) and dislodgment condition (1).Then, a loud alarm is activated when the digital output is in the high level.In addition, the warning information is easily transmitted from the sensing unit to a mobile device via WiFi wireless synchronous serial communication.

Alarm unit based on fog computing
As shown in Fig. 5, the proposed FPN algorithm could be easily implemented in the Arduino ® prototyping platform (Uno, Atmel 8-bit CMOS microcontroller 32 kB selfprogrammable mechanism, 6 analog inputs, 14 digital inputs/outputs, DI/DO) in the fog layer.Each warning sensor (variable resistor, R s ) was connected to a constant voltage source and a fixed pull-down resistor, R g = 10 kW.Two light-controlled sensors were used, which were connected using two signal wires to two analog inputs of an Arduino, as shown in Fig. 2. The serial communication was 9600 bits of data per second to obtain the nodal voltages from the sensing unit to a smart mobile device or a portable computer.The analog voltage ranged from 0 to about 5 VDC scaled as , 1023.0 where V mea,i , i = 1, 2, is the metering voltage whose value changes from 0-1023 to the range that corresponds to the voltage 0.0-5.0VDC (10-bit analog-to-digital converter, 6 channels, maximum reading rate: 10000 times/s).The proposed FPN algorithm detected 1024 (2 10 ) discrete analog levels and took about 100 ms to obtain an input analog voltage.Then, two nodal voltages, V 1 to V 2 , were applied to identify the voltage level changes using Eqs.( 2) and ( 3).Table 2 shows the possible nodal voltage of each sensor versus possible ambient light in a rehabilitation room.When the sensing unit detected any nodal voltage changes, the proposed FPN-based digital alarm unit produced the logic high signal to drive a loud alarm in the fog computing layer.Thus, an end-sensing unit was converted into an intelligent tool to identify the "Yes" or "No" tube dislodgment and to indicate the warning information in a liquid crystal display (LCD) screen.It could transit warning signals to the cloud layer via the WiFi WLAN (IEEE 802.11Standard) to a wearable or a mobile device in the 2.4-GHz medical frequency band (17) for continuous personalized real-time monitoring in a rehabilitation room (20 × 30 m 2 ).

Experimental Results and Discussion
The proposed FPN-based intelligent algorithm was implemented using a high-level programming language (Language C/C++) in the Arduino ® board, including the exponentiation operations, logic operations, and bubble (quick) sorting algorithms, (18,19) as shown in Fig. 6.We were able to design a control program on a host tablet PC, which could be downloaded to the Arduino ® platform.The program could automatically perform when the universal serial bus (USB) wire connection to the tablet PC was removed.For portable application, the Arduino ® platform was powered by a mobile battery (standard range of 6-9 VDC) without connecting to the tablet PC. Figure 7 shows the experimental setup for the detection of the NG tube dislodgment under four situations.When the nose tape was partially or completely dislodged, the total resistance of the light-controlled sensor photocell and the pull-down resistor decreased, and the current flowing through the fixed pull-down resistor increased.Thus, any nodal voltage was   proportional to the inverse of the photocell resistance.The nodal voltages, V 1 and V 2 , could be obtained to identify the voltage level using Eqs.( 2) and (3).For example, considering two-tube dislodgment, the detection procedure is as shown below.
Step (5) Find the final goal Pr C = p 3 × W 1 = 1.0000 and produce the output signal using the hard limit function, C* = 1.0000 (Yes, NG tube dislodgement), as shown in Table 3.
This finding confirmed that the proposed FPN-based digital alarm unit can detect partial and two-tube dislodgments, as seen in Fig. 8. Considering the possible situations, the experimental results indicated the efficiency of the prototype tool as shown in Table 3.This digital warning tool could produce an output binary pattern with the logic high signal to directly drive a loud alarm, which can be used to transmit warning information to healthcare nurses.
In critical, acute, and long-term care, healthcare nurses provide nutrition and hydration via the NG tube to rehabilitation patients via oral intake.However, tube usage could lead to mechanical, infectious, and metabolic complications.The mechanical complications include deliberate self-extubation and accidental extubation, which are primarily unplanned extubation.Taping to the nasal bridge is the most frequently used method to secure the NG tube.In some cases, clinicians use the bridle technique to anchor small-bore NG tubes in patients for unintentional tube removal owing to the mental status, distress, and discomfort. (20)In addition, a noticeable mark could be made on the tube at a known distance from the nose.Displaced tubes can be detected when the nurses notice an increase in the external length of the NG tube outside the nose.In the acute and critical care setting, nurses have to regularly check the tube position at 4 h intervals. (21)Therefore, care facilities must consider a checklist or standard mechanisms to ensure the correct tube position in routine examination.For rehabilitation patients' healthcare, the proposed digital warning tool could enhance the healthcare quality and could be integrated into one or more intelligent end-alarm units to perform measurement, Table 3 Experiment results for normal condition, partial dislodgment, and two-tube dislodgment.Situation .00 μ 1,1 = 0.00 t 1,1 = 0.00 p 1 = max(t 1,1 ×β, t 2,1 ×β) = 0.00 μ 1,2 = 0.00 t 1,2 = 0.00 p 2 = max(t 1,2 ×β, t 2,2 ×β) = 0.00 = 0.3679 μ 2,2 = 0.00 t 2,2 = 0.00 control, and communication activities for multibed monitoring application.On the basis of fog computing (edge computing), this framework could primarily process the warning information at the network edge or near the source of the sensing data, (9,22) as depicted in Fig. 9.Moreover, while any sensing unit detects abnormal data, the WiFi wireless transmitter can send warning messages to the central data center (cloud layer) via fog-to-cloud communication for further analysis, persistent data storage, and final decision-making.This technique only sends the selected warning messages to the cloud layer and can further reduce the communication bandwidth.The warning information that is also sent to the nursing staff via the cloud-toremote device communication or fog-to-remote device communication can be received on  the iPad or a smart phone.This digital warning tool intends to enhance smart care in the rehabilitation room and also is expected to reduce the unnecessary medical disputes and litigations for unplanned extubation events.

Conclusions
A digital warning tool integrating two light-controlled sensors and FPN was established to detect NG tube dislodgment.The two photocell sensors used in this study were small, inexpensive, and easy to implement in a wearable device.The FPN-based intelligent algorithm could be easily implemented using a high-level C/C++ programming language in an embedded system.The prototype model could be further reduced and integrated into a compact portable microchip without limiting the patient's range of motions in practical situations.The experimental results indicated a hit rate of 100% under possible situations of complications.Its portable device provided a promising result for personalized physiological monitoring applications.This new digital warning tool and the computing model can be implemented to advance the healthcare quality for multibed monitoring application in rehabilitation rooms.For healthcare or medical electrical equipment designs, biocompatibility, electrical safety, and effectiveness were also considered for validation before commercialization, which covers the design methodology (hardware and software), verification, and risk assessment, according to the IEC 60601 series standard.The proposed assistant tool can be further integrated with highsensitivity sensors and a compact microchip without limiting the patient's range of motions in clinical application.
is a set of input analog voltages, a mapping from Trs to desired Pls; C is the output function for final decisions;μ = [μ 1,1 , μ 1,2 , μ 2,1 , μ 2,2] is a set of MFs, as defined in [0,1] from inputs to Trs; θ = [θ 1 , θ 2 ] is a set of MFs, as defined in [0,1] from places to Prs; β = 1 is a weighted value from Trs to desired Pls; W = 1 is a weighted value from Prs to a desired final output, C.

Table 2
Nodal voltage of warning sensor under different ambient light conditions.