## 4 Phases of the Proposed Approach
### Phase 2  
In the second phase, the Mist broker (MB) focuses on the Mist's computational capacity (see Equation (3) below) and data priority to allocate resources for healthcare services. MB selects one of the three resources: Mist, Fog, and Cloud, to provide services for the healthcare system as follows.  
First, MB directly transfers high-priority data to the Cloud and allows healthcare providers to access these critical data. In addition, MB helps patients with urgent conditions in real-time processing to make quick decisions as the MB is very close to the sensing devices.  
Second, MB sends the medium-priority data to the Mist nodes of available capacity. The data are transferred to the next available Mist node if a Mist node is overloaded. If all Mist nodes have insufficient computing space for the medium-priority data, the data are transferred to the Fog broker.  
Third, MB sends the low-priority data to the Mist nodes of available capacity. The data are transferred to the next available Mist node if a Mist node is overloaded. However, if all Mist nodes lack adequate computing space (i.e., low and medium computing capacity) for low-priority data, they are then directed to the Fog broker for further processing, as indicated in Table 3.  
Moving to the subsequent layer, the Fog broker is equipped with a load balancer responsible for distributing the medium- and low-priority data received from the Mist  
Figure 6: FLS for health score.  
Figure 7: Membership function of health score.  
\begin{table}
\begin{tabular}{c c c} \hline \hline
**Data Priority** & \multicolumn{2}{c}{**Computational Capacity of**} & \\  & **Mist Node** & **Source Allocation** \\ \hline High & High & Cloud \\ High & Medium & Cloud \\ High & Low & Cloud \\ Medium & High & Mist \\ Medium & Medium & Mist \\ Medium & Low & Fog \\ Low & High & Mist \\ Low & Medium & Fog \\ Low & Low & Fog \\ \hline \hline \end{tabular}
\end{table}
Table 3: The fuzzy rules for server allocation.  
broker among the available Fog nodes. This distribution is based on two factors: the remaining computing capacity of each Fog node and a clustering technique. The calculation of the remaining capacity of a Mist node, as described by Equation (3), plays a crucial role in determining whether the healthcare services should be computed within the Mist node itself or whether the healthcare data should be redirected to another Mist node or the Fog broker in the event of an overloaded Mist node:  
\[\begin{split}\text{Remaining capacity}=\text{C}-\sum_{i=1}^{n} \text{Pi}_{i}\times\text{Si}\\ \text{Remaining capacity percentage}=\frac{\text{C}-\sum_{i=1}^{n} \text{Pi}_{i}\times\text{Si}}{\text{C}}\times 100\end{split} \tag{3}\]  
The equation consists of four factors to determine the computing capacity of a Mist node:  
* C is the capacity of a Mist node.
* Pi is the packet arrival rate for i as a data packet.
* Si is the size of the data packet i.
* n is the number of data packets.  
In Phase 2, the number of rules in the fuzzy logic system depends on the number of sensors in the experiment and how many readings each sensor can sense as follows:  
The number of rules = (number of data priority levels) \(\times\) (number of computational capacities of Mist node)  
Here, the number of rules = 3 \(\times\) 3 = 9 rules by using linguistic rules of \"if-then\" and \"and\" as logical operators to take the minimum membership value. The rules are represented in Table 3.  
Figures 8-11 in MATLAB depict the design of the fuzzy logic system responsible for server allocation. This system takes two inputs, namely data priority and Mist capacity, and generates an output that determines the server allocation.