# IoT-Based Medical Image Monitoring System Using HL7 in a Hospital Database
## 2 Materials and Methods
### Ultrasound Machine to Raspberry Pi HL7 Messaging Process
#### 2.1.1 HL7 Block Formation and Messages
Extracted Result data stored in the database. After getting the result message from the ULSM (Ultrasound Machine), the proposed model categorizes the message into two parts: (i) saved raw result data (ii) extracted result data. Here, the proposed model worked with (ii) the extracted result data. Here, real-time data mean raw formatted data which have been sent by ULSM and are stored in LIS storage, and thereafter any changes will be strictly prohibited. The result data are transferred from the RSPI3 to the LIS via the API over the intranet connection (Figure 6). Here, messages are stored in the main database every time the validity of upcoming messages are checked in LIS based on the API token. Therefore, no unwanted message will be stored in the LIS because of the API token. The raw result data are stored in the database as a response. Extracted data from result messages are also recorded in the database using the patient record ID and sample ID, which is then utilized for further processing. ### Raspberry Pi to FTP Server Image Transfer

After getting a message from the ultrasound source and storing data in the LIS, the Raspberry Pi processes the HL7 messages and finds out patient information, sample ID, and doctor information using the Base64 image. The Base64 image is transferred to the FTP server database as a formatted image with a Globally Unique Identifier (GUID). The image is renamed with the GUID and sent to the FTP server using the FTP server user ID and password. After the image is successfully transferred to the FTP server, it responds with a unique image link using the GUID. This process is described in the following steps:

1. Convert the image from Base64 to JPG, or get the image from HL7 or the direct Base64 image. 2. Construct the GUID (Globally Unique Identifier) for the image. 3. Rename this image with the GUID send it to FTP server. 4. From the FTP server generate a unique image link and send it back to the Raspberry Pi. After getting the response message from the FTP server the RSPI3 encrypts the image link via RSA public key and then sends the link to the IoT server (Figure 7). Figure 6: RSPI3 to LIS result data transfer. Figure 7: Image transfer process from RSPI3 to FTP. Algorithm 4 is used in this process to:

1. Generate the GUID. 2. Transfer Base64 image data using the GUID to the FTP server. 3. Get Base64 image links from the FTP server. 4. Encrypt the image link via public key. 5. Transfer the encrypted image link to the IoT server. Those images are also mapped based on sample ID with GUID as per the following steps:

The following RSA encryption process is carried out based on the GUID of an image. This study uses the key and messages as shown in Tables 11-12. Algorithm 4 describes how the Raspberry Pi sends the image to the FTP server. ```
Input: Image data from Ultrasound Machine Output: boolean:true/false
1 Start
2 IoTServerResponse = false whileGetImageDataFromIllrasoundMachinedo ifImageDatalsValidthen
5 ftpResponse = FTPServer(imageData) ifftpResponse == IsValidImageLinkthen imageLink = ftpResponse['imageLink'] encryptedImageLink = ENCRYPT(imageLink, publicKey) IoTServerResponse = TransferImageToIoTServer (encryptedImageLink) returnIoTServerResponse End
```

**Algorithm 4**RSPI3 to IoT Server Image Transfer

### RSPI3 to IoT Server Image Transfer

The MQTT protocol is used to send the encrypted image link to the IoT server. After producing an encrypted image link with a login and password from an FTP server, the image link is transferred to a real-time IoT server. This phase configures the real-time IoT server. This image is displayed in the IoT server alongside patient data. If a patient's ultrasound image cannot be transmitted to an IoT server, the image is re-sent. The Raspberry Pi not only sends the encrypted image, but it also sends the patient information using the MQTT protocol. This process is described in the following steps:

1. Get the encrypted image link from the FTP server. 2. Transfer the encrypted image link to the IoT server using the IoT client username and password.