坚持决定智能合同项目的工作
因此,我正在进行一个项目,该项目基本上是在智能合同的帮助下进行医疗保险索赔程序。它的工作方式是:
- 用户签署由保险公司运营的网站。
- 他们通过进入相关医院,保险金额和一个包含账单的PDF文件来提出索赔。
- 医院使用网站根据提供的信息批准/拒绝索赔。
- 保险公司使用网站批准/拒绝基于提供的信息并向用户支付索赔。
- 每当有人申请/批准/拒绝,支付索赔时,就会发出事件。
这是我的第一个以太坊/固体项目,我无法弄清楚如何将其集在一起。
这是主张的结构:
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
}
我的一些问题是:
- 如何将记录链接到特定用户?作为一个用户可以使用多个元掩体钱包。
- 是否可以获取所有带有ID的特定记录的事件,以便我可以向用户显示记录中发生的所有批准/拒绝?
- 对于医院而言,除了从智能合约中获取所有记录并在前端过滤外,是否有更好的方法获得相关记录?
非常感谢您的帮助。
So I'm doing a project which basically carries out the medical insurance claim process with the help of the smart contract. How it works is:
- User signs up to the website run by the insurer.
- They file a claim by entering the concerned hospital, insured amount and a pdf file containing the bills which are to be verified.
- The hospital uses the website to approve/deny the claim based on the info provided.
- The insurer uses the website approve/deny the claim based on the info provided and pays the user.
- Any time someone files, approves/denies, pays the claim, an event is emitted.
This is my first ethereum/solidity project and I'm unable to figure out how to pull this together.
This is the structure of a Claim:
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
}
Some of my questions were:
- How do I link a Record to a specific user? As a single user can use multiple Metamask wallets.
- Is it possible to fetch all the events linked to a specific record with an id so I can display all the approvals/denials happened with the Record to the user?
- For the hospital, is there a better way to get associated Records other than to get all Records from the smart contract and then filter it on the front end?
Thanks a lot for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要将记录链接到特定用户,您需要添加映射(我假设您拥有一个用户ID),该映射看起来像这样:
那么您将能够获得一系列记录,了解用户ID
:事件记录实际上很容易,因为我们有
索引
关键字,让我向您展示一个示例:使用此类事件,您可以使用用户ID和记录ID查询所有事件。
关于第三个问题,我建议您使用图形 https://thegraph.com/en/ 。它基本上通过以非常简单的方式为您索引所有事件来创建您自己的GraphQL后端。然后,您可以运行GraphQl查询并提高一些效率。
To link a Record to specific user you will need to add a mapping (I am assuming that you have a user ID) that will look like this:
Then you will be able to get an array of Records knowing the user id by:
About the event logging it's actually kind of easy because we have the
indexed
keyword, let me show you an example:With an event like this you are able to query all the events using the user id and the record id.
About the third question I suggest you to use the graph https://thegraph.com/en/. It basically creates your own GraphQL backend by indexing all the events for you in a very easy way. Then you are able to run your graphql queries and make something efficient.