## 4 Technical Implementation of the Healthcare Hygiene Quality System
### Chaincode Implementation  
In the proposed system, several smart contract functions were designed to support the digital management of healthcare operations, including patient admission, room assignment, and event logging. One essential component is the routine cleaning registration function, which contributes to hygiene assurance by allowing cleaning personnel to log sanitation tasks directly onto the blockchain using RFID-enabled tools. As explained in Section 3.2, this chaincode enforces predefined validation rules and integrates with the transaction flow managed by peer and orderer nodes. This functionality is implemented using a smart contract (chaincode) written in Go and deployed on a multi-organization Hyperledger Fabric network. The chaincode includes data structures and logic that control access and enforces rules for each operation. Although the system contains multiple functions, Listing 1 presents a representative example: RoutineCleaning. This function records a cleaning event on the ledger using three input parameters--RoomID, CleaningStaffID, and Date. It checks that the room exists and is currently assigned to a patient before logging the event with a timestamp and updating the room's cleaning status. ```
func (s *SmartContract) RoutineCleaning(APIstub shim.ChaincodeStubInterface, args []string) sc.Response { if len(args)!=3 { return shim.Error(\"Expecting 3 arguments: RoomID, CleaningStaffID, Date\") } roomID := args [0] staffID := args [1] cleaningDate := args [2]
``` \begin{table}
\begin{tabular}{c c} \hline
**Component** & **Description** \\ \hline Blockchain Framework & Hyperledger Fabric v2.5.5 \\ \hline Identity Service & Fabric Certificate Authority (Fabric CA) \\ \hline CLI Tools & Docker CLI (v24.0.6), Docker Compose (v2.24.5) \\ \hline Benchmark Tool & Hyperledger Caliper (v0.6.0) \\ \hline Chaincode Language & Go \\ \hline Operating System & Google Cloud Compute Engine (Ubuntu 22.04 LTS) \\ \hline Hardware & 2 vCPU, 8 GB RAM (All virtual machines) \\ \hline Communication & TLS-enabled gRPC for peer/orderer and HTTPS for REST client interaction \\ \hline Caliper Configuration & Docker container setup with Fabric Gateway binding and automatic identity injection \\ \hline Client SDK & Node.js (v18.20.8), Python (v3.10) \\ \hline REST API Interface & Fabric Gateway SDK with Express.js and gRPC middleware \\ \hline \end{tabular}
\end{table} 
Table 2: Software and hardware components and their definitions used in the implementation. ```
``` roomBytes, err := APIStub.GetState(\"ROOM\" + roomID) if err!= nil || roomBytes == nil { return shim.Error(\"Room \" + roomID + \" does not exist.\") }
```

```
var room Room if err := json.Unmarshal(roomBytes, &room); err!= nil { return shim.Error(\"Failed to parse room data.\") } if room.AssignedPatientID == \"\" { return shim.Error(\"Room \" + roomID + \" is not assigned to any patient.\") } timestamp := time.Now().Format(time.RFC3339) event := CleaningEvent{ RoomID: roomID, CleaningStaffID: staffID, Date: cleaningDate, Operation: \"Routine Cleaning\", Timestamp: timestamp, } eventKey := \"CLEANING_\" + roomID + \"_\" + timestamp eventBytes, _\" := json.Marshal(event) if err := APIStub.PutState(eventKey, eventBytes); err!= nil { return shim.Error(\"Failed to record cleaning event.\") }
```

// Update the room's cleaning status room.CleaningStatus = \"Routine Cleaned\" room.LastCleaned = timestamp updatedRoomBytes, _\" := json.Marshal(room) if err := APIStub.PutState(\"ROOM\"+roomID, updatedRoomBytes); err!= nil { return shim.Error(\"Failed to update room status.\") } return shim.Success([]byte(\"Routine cleaning for Room \" + roomID + \" is complete.\")) } ```

### Ledger Level Representation

Although the proposed system includes multiple smart contract functions handling various aspects of healthcare workflows--such as patient registration, room occupancy management, and hygiene feedback logging--this section focuses on a representative function to demonstrate the blockchain-based data storage mechanism.