所以我正在做一个项目,在智能合同的帮助下,基本完成医疗保险索赔过程。它的工作原理是:
H 210G 211这是我的第一个ethereum/solidity项目,我想不出如何把它整合在一起。
这是一项索赔的结构:
struct Record {
uint id; // unique id for the record
address patientAddr;
address hospitalAddr;
string billId; // points to the pdf stored somewhere
uint amount;
mapping (address => RecordStatus) status; // status of the record
bool isValid; // variable to check if record has already been created or not
}我的一些问题是:
非常感谢你的帮助。
发布于 2022-04-20 21:15:00
要将记录链接到特定用户,需要添加如下所示的映射(我假设您有一个用户ID):
mapping(uint => Record[]) recordsByUserID;然后,您将能够通过以下方法获得知道用户id的记录数组:
Records userRecords[] = recordsByUserID[user_id];关于事件日志,它实际上有点简单,因为我们有indexed关键字,让我向您展示一个示例:
event Approved(uint indexed userId, uint indexed recordId);使用这样的事件,您可以使用用户id和记录id查询所有事件。
关于第三个问题,我建议您使用图形https://thegraph.com/en/。它基本上是通过以非常简单的方式为所有事件建立索引来创建您自己的GraphQL后端。然后,您可以运行您的graphql查询,并使之高效。
https://stackoverflow.com/questions/71944044
复制相似问题