Algorithm 2 Function. |
-
Input:
dataOwner, dataType, ipfsCID
-
Output:
dataID
-
1:
Generate dataID by hashing dataType, dataOwner, and ipfsCID using
-
2:
Call internal function (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 (dataID, dataType, dataOwner, encryptedCID, fileContent)
-
17:
return
dataID
|