Defining an issuance claim

Let's write a chaincode. Open LiteIDE and create a new file called claimcontract.go, as follows:

In the insurance claim use case analysis, we analysed the participants in the issuance claim process. There are three participants for whom we need to define a chaincode: insuree, broker, and insurer, as shown in the following example:

type Insuree struct {
Id string `json:"id"`
FirstName string `json:"firstName"`
LastName string `json:"lastName"`
SSN string `json:"ssn"`
PolicyNumber string `json:"policyNumber"`
}

In Insuree, we define Id, firstname, LastName, SSNand policyNumber.

In Go language, it allows the first letter of a field name as to be either uppercase or lowercase. When we need an exported field to be public for any piece of code to use it, it needs to be a capitalized letter. You can use encoding in the JSON package to unmarshal data into struct, which defines the field name in JSON as the firstName key, as shown in the following format:

type Member struct {
Name string `json:"member_name"`
}

The broker and insurers data models are similar and only different in type. We define them as follows:

type Company struct {
Id string `json:"id"`
Type string `json:"type"`
Name string `json:"name"`
}

In the issuance claim process, Insuree initializes a claim request. The claim document will keep track of each step of the process in the blockchain. It records all necessary information, including status, user claim description, insueeId, brokerId, insurerId, process time at each step, and comments entered from an authorized party, as shown in the following example:

type Claim struct {
Id string `json:"id"` //the fieldtags are needed to keep case from bouncing around
Desc string `json:"desc"` //claim description
Status string `json:"status"` //status of claim
InsureeId string `json:"insureeId"` //InsureeId
BrokerId string `json:"brokerId"` //BrokerId
InsurerId string `json:"insurerId"` //InsurerId
Comment string `json:"comment"` //comment
ProcessAt string `json:"processAt"` //processAt
}

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.226.185.96