0

我正在编写一个向网络添加参与者和资产的事务。将参与者添加到网络有效,但是当我尝试访问医疗资产文件注册表时,该函数返回未定义。

错误: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"
  }

知道有什么问题吗?

4

1 回答 1

1

注册表为空的假设是不正确的。问题是所有者不是关系。这只是一个字符串,我认为这是允许的。

这导致了上述错误。

修复:

medicalFile.owner = factory.newRelationship(namespace, 'Patient', newPatient.bsn);
于 2017-06-04T10:59:11.213 回答