# Deduplication-Aware Healthcare Data Distribution in IoMT
## 4 Proposed Solution
Function Data_Chunking_BreakPoint (index \(k\), \(sLen\))
10. Set s_readings = substring (\(k\), \(sLen\), readings)
11. \(reading\_brs\_len1\) = Split (s_readings, \(R_{A}\)) // Two parts
12. Set p as 0 // for 1 st part of the split readings
13. If size (\(reading\_brs\_len1\)\([p]\)) <= max_sized_chunk then
14. If size (\(reading\_brs\_len1\)\([p]\)) > \(win\_s\)then
15. return \(k\) = \(k\) + size (\(reading\_brs\_len1\)\([p]\))
16. Else
17. While size (\(reading\_brs\_len1\)\([p]\)) < \(win\_s\)do
18. \(k\) = \(k\) + Indexov(\(reading\_brs\_len1\)\([p]\), \(R_{A}\))
19. End While
20. return \(k\)
21. End if
22. Else If\(reading\_brs\_len1\)\([p]\)) > max_sized_chunk then
23. Set \(q\) as 0 // for 1 st part of the split readings_br
24. \(reading\_brs\_len2\)\([q]\) = Split (\(reading\_brs\_len1\)\([p]\)), \(R_{B}\))
25. If size (\(reading\_brs\_len2\)\([q]\)) >= \(win\_s\)then
26. return \(k\) = \(k\) + size(\(reading\_brs\_len2\)\([q]\))
27. Else
28. \(q\) = \(q\) + 1
29. return \(k\) = \(k\) + Indexov(\(reading\_brs\_len2\)\([q]\), \(R_{B}\))
30. End if
31. End if
32. End function
```  
**Algorithm 1**Delimiter-Based Incremental Chunking Algorithm (DICA)  
In situations where the size of the chunks is larger than the max_size_chunk, the first data string is divided to obtain another string. Here, p is considered as the index value (\(reading\_brs\_len1\)\([p]\)), finding the data chunk based on this index. In the same way, q is the index value for (\(reading\_brs\_len2\)\([q]\)). In the proposed DICA, the size of a window of variable size is handled based on the delimiter that is used in the collected data to distinguish between the different values associated with the healthcare parameters. In this algorithm, we employ the delimiter \(R_{A}\) to segment the data into chunks, particularly during the procedure of finding a window of variable size. Each sensing device appends a delimiter to aggregate the data; these delimiters help in distinguishing the healthcare parameters from each other. Furthermore, the aggregator nodes also employ a distinct delimiter to aggregate the data received from various sensors. This approach lessens the cost of identifying the next suitable breakpoint. As the algorithm's level of complexity is linear, it is represented as O (n) due to the addition of an iterative operation to find the index values. A second iteration is also required to maintain a list of chunks. The storage of data in the cloud repository is illustrated in Algorithm 2. The aggregated data that are received from the fog server are transmitted to the cloud. Before saving these data in the repository, they are extracted and checked for duplicated values. If the data item's value is the same as the previously received value, it is replaced with a Boolean digit and stored in the cloud repository; otherwise, it is stored in its full form. ```
Input: Received Aggregated data Output: Stored Deduplicated Data At Cloud Function save_data (DataItem)
1. Extract DataItem
2. If If DataItemValue equals prevoiusdataValue then
3. save as Boolean digit in cloud repository
4. Else
5. save data in their original form in cloud repository
6. End if
7. End function
```  
**Algorithm 2**Receiving and Extracting Data at Cloud