我正在编写一个向网络添加参与者和资产的事务。将参与者添加到网络有效,但是当我尝试访问医疗资产文件注册表时,该函数返回未定义。
错误:TypeError:未定义不可调用
交易逻辑:
return getParticipantRegistry(namespace + '.Patient')
.then(function (patientRegistry) {
return patientRegistry.add(newPatient);
}).then(function() {
return getAssetRegistry('nl.epd.blockchain.MedicalFile');
}).then(function (registry) {
var medicalFile = factory.newResource(namespace, 'MedicalFile', "test");
medicalFile.id = "test";
medicalFile.owner = newPatient.bsn;
medicalFile.mentors = [];
medicalFile.permissions = [];
medicalFile.allergies = [];
medicalFile.treatments = [];
medicalFile.medicine = [];
// registry is undefined
return registry.add(medicalFile);
});
}
楷模:
namespace nl.epd.blockchain
asset MedicalFile identified by id {
o String id
--> Patient owner
--> Patient[] mentors
o OrganisationPermission[] permissions
o Visit[] visits
o String[] allergies
o Treatment[] treatments
o Medicine[] medicine
}
participant Patient identified by bsn {
o String bsn
o String firstName
o String namePrefix optional
o String lastName
o String email
o String telephoneNumber
o String birthday
o String gender
o String city
o String zipCode
o String street
o String houseNumber
o String houseNumberExtra optional
}
NPM 依赖项:
"dependencies": {
"fabric-ca-client": "1.0.0-alpha.0",
"fabric-client": "1.0.0-alpha",
"homedir": "^0.6.0",
"composer-client": "^0.7.0",
"composer-rest-server": "^0.7.0"
}
知道有什么问题吗?