## 3 Materials and Methods
### Blockchain Transaction Lifecycle and Chaincode Execution
According to the RAFT-based consensus approval mechanism, the patient registration process can only be recorded on the blockchain after approval by the hospital andhealth authority nodes. The approved patient data is divided into blocks by the ordering service and added to the blockchain ledger. This stage ensures that the patient's identity information is securely stored and immutable while also preserving data integrity. Once the patient is assigned to a hospital room, the room allocation information is updated in the system, creating a unique record for each patient. Thus, the patient admission and placement process is completed in a decentralized, transparent, and traceable manner. **Chaincode Hospital:**  
**@PatientRegistration0**  
Public RegisterPatient(String PatientID, String PatientName, String HealthRecord, String RoomID)  
// Check if the patient already exists  
If PatientID NOT EXISTS in Blockchain  
// Check if the room exists  
If RoomID EXISTS in Blockchain  
// Check if the room is available  
If RoomID is NOT assigned to a patient  
// Store the patient data with the room assignment  
Store Patient(PatientID, PatientName, HealthRecord, RoomID, CurrentTimestamp)  
// Update the room with the assigned patient  
Update Room(RoomID, PatientID, AssignedTimestamp)  
Return \"Patient registration successful and room assigned.\"  
Else  
Return \"Room is already occupied, please choose another room.\"  
Else  
Return \"Room does not exist.\"  
Else  
Return \"Patient is already registered.\"  
End Function  
**Chaincode Cleaning:**  
**@Routine Cleaning0**  
Public PerformRoutine Cleaning(String RoomID, String CleaningStaffID, String Date)  
// Check if the room exists  
If RoomID EXISTS in Blockchain  
// Check if the room is assigned to a patient  
If RoomID is assigned to a patient  
// Record the cleaning operation with a timestamp  
Record Cleaning(Operation: \"Routine Cleaning\", RoomID, CleaningStaffID, Date, CurrentTimestamp)  
// Update the room with cleaning status  
Update Room(RoomID, CleaningStatus: \" Routine Cleaned\", LastCleaned: CurrentTimestamp)  
Return \" Routine cleaning for Room \" + RoomID + \" is complete.\"  
Else  
Return \"Room \" + RoomID + \" is not assigned to any patient.\"  
Else  
Return \"Room \" + RoomID + \" does not exist.\"  
End Function  
Figure 3: Pseudocode representation of Patient Registration and Routine Cleaning chaincode functions in the proposed Quality Assurance Model. Figure 5 provides a detailed explanation of how cleaning operations in patient rooms are digitally recorded and integrated into the blockchain system. This process is built on a structure that requires the collaboration of IoT devices, RFID technology, and blockchain systems to ensure the reliability and traceability of cleaning services. The RFID readers, acting as part of the IoT layer, collect operational data in real time and trigger blockchain transaction requests. The process begins with the execution of cleaning activities in patient rooms, where operations performed by cleaning staff are monitored in real-time using RFID-based IoT devices through a gateway. To enable the recording of cleaning operations, IoT devices must request an E-Cert before being integrated into the blockchain network. This certificate, issued by the Local CA, ensures that only authorized devices can write data to the ledger. The certificate, approved by the Local CA, is assigned to the IoT device responsible for cleaning operations, allowing the device to perform authorized transactions on the blockchain. Once the certificate is obtained, details of the cleaning operations such as which room was cleaned, the identity of the cleaning personnel, the materials used, and the duration of the process are collected via RFID-based sensors and transmitted to the cleaning service provider. The cleaning service provider processes this data through the relevant chaincode and generates a transaction request to write it onto the blockchain network.