Skip to main content
. 2025 Mar 17;25(6):1857. doi: 10.3390/s25061857
Algorithm 2 addData Function.
  • Input: 

    dataOwner, dataType, ipfsCID

  • Output: 

    dataID

  • 1:

    Generate dataID by hashing dataType, dataOwner, and ipfsCID using keccak256

  • 2:

    Call internal function encryptCID (ipfsCID) to get encryptedCID

  • 3:

    Create a new MedicalData instance newMedicalData with fields:

  • 4:

       dataType: dataType

  • 5:

       dataOwner: dataOwner

  • 6:

       ipfsCID: encryptedCID

  • 7:

       fileContent: fileContent

  • 8:

    Store newMedicalData in the medicalData mapping with key dataID

  • 9:

    Create a new DataRecord instance newDataRecord with fields:

  • 10:

       dataType: dataType

  • 11:

       dataOwner: dataOwner

  • 12:

       ipfsCID: encryptedCID

  • 13:

       dataID: dataID

  • 14:

    Add newDataRecord to the dataList array

  • 15:

    Append dataID to ownerToDataIDs[dataOwner] in the mapping

  • 16:

    Emit event LogMedicalData(dataID, dataType, dataOwner, encryptedCID, fileContent)

  • 17:

    return  dataID