## 4 The Proposed Real-Time Monitoring System
### Proposed Encoding-Based Machine Learning Model
\begin{table}
\begin{tabular}{c c c c c c c c c c c} \hline \hline
**\#** & **Name** & **CP** & **SoB** & **Sys.** & **Dia.** & **HR** & **RR** & **GC** & \
\begin{tabular}{c} **SPO2** \\ **(\%)** \\ \end{tabular} &
\begin{tabular}{c} **Actual** \\ **Status** \\ \end{tabular} \\ \hline
1 & Person1 & YES & NO & 90 & 50 & 93 & 12 & 10 & 87 & Critical \\ \hline
2 & Person2 & YES & NO & 100 & 80 & 83 & 13 & 14 & 97 & Stable \\ \hline
3 & Person3 & NO & YES & 150 & 70 & 95 & 13 & 15 & 92 & Non-critical \\ \hline \hline \end{tabular}
\end{table} 
Table 5: Case study: patients’ medical information for model testing. ```
1:procedureMyProcedure
2:for\(i\gets 1\) to \(N\)do
3: Read patient information
4: Apply the PCA module to select the most important features (Risk Factors)
5:Calculate:
6: Risk Score (RS)=? (_LUT1_); As follows:
7:if (_Clest pain \(==\) Yes_) then CP =1
8: Else CP = 0
9:endif
10:if (_Shortness of breath \(==\) Yes_) then SoB =1
11: Else SoB = 0
12:endif
13: Vital Score (VS)=? (_LUT2_); As follows:
14:if (_Coma Scale \(<\) 13_) then GC =1
15: Else GC = 0
16:endif
17:if (_SPO2 \(<\) 94%) then SPO2 =1
18: Else SPO2 = 0
19:endif
20:if (_Systolic \(<\) 100 OR _Systolic \(>\)_ 140) OR (_Diastolic \(>\)_ 90 OR _Diastolic \(<\)_ 60) then Systolic/Diastolic (BP) = 1
21: Else Systolic/Diastolic (BP) = 0
22:endif
23:if (_HR \(>\)_ 100 OR _HR \(<\)_ 60) then HR =1
24: Else HR = 0
25:endif
26:if (_RR \(<\) 12 OR _RR \(>\)_ 16) then RR =1
27: Else RR = 0
28:endif
29: Case structure:
30: Begin:
31: Select the suitable case statement (case 0 to 31)
32:if (_condition \(==\) true_) then
33: Status = Non-critical OR Critical
34:else
35: Status = Stable OR Non-critical
36:endif
37: Index = VS
38:if (_condition \(==\) true_) then
39: Read _LUT4(index)_ for decision making
40:else
41: Read _LUT3(index)_ for decision making
42:endif
43: Select the predicted status (_SH_, _ER_, _ICU_)
44:EndCase;
45:goto step3
46:endfor
47:endprocedure
```  
**Algorithm 1** Pseudocode algorithm of the encoding-based model Person1: the values for \(RS\) and \(VS\) are first calculated based on the risk factors. As listed in Table 5, the patient suffers only chest pain from the risk factors, so RS = 2, while VS = 28 because the patient has GC, SPO2, and BP lower or higher than that set of the threshold; therefore, the bit value of these vital signs becomes '1' (refer to Algorithm 1 for the equations that determine the threshold values of these signs). The values of HR and RR are within the continuous range for normal operations of vital signs, and thus they are both set to '0'. Putting it all together, (\(b_{4}b_{3}b_{2}b_{1}b_{0}\)), it becomes (11100\({}_{2}\)), which is equivalent to 28 in decimals, where the GC represents the MSB and RR represents LSB. The value of VS is then fed to the case structure to select the suitable statement, stable, non-critical, and critical. As seen in Figure 6a, the selected case is Case#28, so the status is either non-critical (emergency room) or critical (ICU). This can be determined based on both the value of the VS and the condition (false/true) of the selected case since they will then be used as the address and read enable (RE) to read one of the statuses stored in LUT3 when the condition is false or LUT4 when the condition is true (see Table 6). It is worth mentioning that each condition has two equivalent statuses. One is when the condition is false and stored in LUT3 at the location indexed by VS, while the others for the true condition are stored at the identical location in LUT4. Since the condition is true (see Figure 6a, row1 of Tables 5 and 6), the predicted status is read from LUT4 and the model has classified it as critical, and thus both the actual and predicted status are the same. Note that Figure 7 illustrates  
Figure 5: The proposed encoding-based machine learning model. Person2: the model first calculates the risk score and vital score, which are RS = 2 and VS = 0. The patient has chest pain, and thus CP = 1, while VS = 0 since all selected vital signs are normal.