我正在使用Hyperledger Composer,提交交易时,必须手动添加Asset和Participiant的ID。有没有一种方法可以自动设置这些ID,而不必在每次提交交易时都添加它?有智能合约的javascript示例代码吗?谢谢。
CTO文件
participant Patient identified by ID_P {
o String ID_P
o String name
o String surname
o String Birth regex=/[0-9]+\-[0-9]+\-[0-9]/
o String CF regex=/[A-Z0-9]{11}/
}
asset Health_Provision identified by ID_CF {
o String ID_CF
o Type type
o String[] Date regex=/[0-9]+\-[0-9]+\-[0-9]/
o String NoteFromToDoctor
o String NoteFromToCup
o String Receipt
o String SignNRE
o String Priority
o String Name
o String Surname
o String CF
o String Birth
o String Exemption
o RequestSubstitution substate
o Make_Health_Provision_Prescription[] requests optional
o Make_Health_Provision_Reservation[] reqs optional
--> Patient Applicant
--> Doctor doctor
--> CUP cup
}
transaction SendPrescription {
o String NoteFromToDoctor
o RequestSubstitution substate
--> Health_Provision IDCF
--> Patient Applicant
--> Doctor newDoctor
}
Logic.js
function SendPrescription(tx) {
var IDCF = tx.IDCF;
tx.IDCF.doctor = tx.newDoctor;
return getAssetRegistry('org.example.healthdata.Health_Provision')
.then(function (assetRegistry) {
return assetRegistry.update(tx.IDCF);
});
我会更好地解释一下:提交发送处方交易时,每次要提交交易时,我都必须手动添加ID资产。但是我想自动化这种转换,我不知道该怎么做。
在此图像中,当我必须提交交易时,有与资产ID,患者ID和医生ID相关的随机数。我每次提交交易时都必须手动添加资产,患者和医生的ID吗?您认为我可以自动化吗?