Policy Endorsement
Overview
Endorsement are proposed changes to a policy which need to be approved before applying. The following mutations will be used:
addEndorsement
: create a new endorsement for a policyupdatePolicy2
: update policy, pass the endorsementId as parameteracceptEndorsement
: accept endorsement, all of the update we made in updatePolicy2 will apply to the policy
Original Policy
Suppose we have an original policy asl below:
{
"data": {
"policies": {
"list": [
{
"id": "b795a798-bb5b-4d9f-921f-92f119aa3cbf",
"createdAt": "2021-06-07T04:28:18.726Z",
"lastModifiedAt": "2021-06-07T04:28:18.726Z",
"insured": [],
"fields": null,
"product": {
"productId": {
"type": "Demo Insurance",
"plan": "Plan 1",
"version": "1"
}
},
"endorsements": []
}
]
}
}
}
Now we want to update the policy through endorsement with the following changes:
- Add an insured to the policy;
- Change the number of insured to 1;
- Change the product to "Demo Insurance Plan 2 version 1".
Create a new Endorsement
Query examples
mutation addEndorsement (
$policyId:String!
$type: String
$reasonOfChange: String
$effectiveDate: DateTimeOffset
){
addEndorsement(
policyId: $policyId
type: $type
reasonOfChange:$reasonOfChange
effectiveDate: $effectiveDate
){
status
errors
createdStatus { id }
}
}
Input:
{
"policyId": "b795a798-bb5b-4d9f-921f-92f119aa3cbf",
"type": "Demo Endorsement",
"reasonOfChange": "For Demo",
"effectiveDate": "2021-06-07T04:30:46.139Z"
}
Result:
{
"data": {
"addEndorsement": {
"status": "success",
"errors": null,
"createdStatus": {
"id": "171fea8d-5002-47ac-965b-31f070ad84c7"
}
}
}
}
Update Policy 2
Mutation updatePolicy2
is used to specify to change we want to make in the endorsement.
Query examples
mutation updatePolicy2(
$policyId:String!
$endorsementId: String!
$input: updatePolicyInput!
) {
updatePolicy2(
policyId: $policyId
endorsementId: $endorsementId
input: $input
){
status
errors
createdStatus { id }
}
}
Input:
{
"policyId": "b795a798-bb5b-4d9f-921f-92f119aa3cbf",
"endorsementId": "171fea8d-5002-47ac-965b-31f070ad84c7",
"input": {
"insuredIds": ["6cc1926c-86c7-4d0d-b0a4-374562891dcb"],
"fields": "{\n \"numberOfInsureds\": 1\n}",
"productId":{ "type": "Demo Insurance", "plan":"Plan 2", "version":"1"}
}
}
Result:
{
"data": {
"updatePolicy2": {
"status": "success",
"errors": null,
"createdStatus": {
"id": "652a10c3-f510-454b-9c7d-2ee08af50475"
}
}
}
}
Before and After Endorsement
Let's query the policy again. We can use beforeEndorsement
and afterEndorsement
to see the state of policy before and after applying the endorsement changes.
Query examples
query policies{
policies {
totalCount
list{
id
createdAt
lastModifiedAt
insured { name }
fields
product { productId { type plan version } }
endorsements{
id
isApproved isRejected
type reasonOfChange effectiveDate
afterEndorsement {
insured { name }
fields
product { productId { type plan version } }
}
beforeEndorsement {
insured { name }
fields
product { productId { type plan version } }
}
}
}
}
}
Result:
{
"data": {
"policies": {
"list": [
{
"id": "b795a798-bb5b-4d9f-921f-92f119aa3cbf",
"createdAt": "2021-06-07T04:28:18.726Z",
"lastModifiedAt": "2021-06-07T04:30:32.123Z",
"insured": [],
"fields": null,
"product": {
"productId": {
"type": "Demo Insurance",
"plan": "Plan 1",
"version": "1"
}
},
"endorsements": [
{
"id": "171fea8d-5002-47ac-965b-31f070ad84c7",
"isApproved": false,
"isRejected": false,
"type": "Demo Endorsement",
"reasonOfChange": "For Demo",
"effectiveDate": "2021-06-07T04:30:46.139Z",
"afterEndorsement": {
"insured": [
{
"name": "Demo User"
}
],
"fields": "{\n \"numberOfInsureds\": 1\n}",
"product": {
"productId": {
"type": "Demo Insurance",
"plan": "Plan 2",
"version": "1"
}
}
},
"beforeEndorsement": {
"insured": [],
"fields": null,
"product": {
"productId": {
"type": "Demo Insurance",
"plan": "Plan 1",
"version": "1"
}
}
}
}
]
}
]
}
}
}
Please note that changes in endorsement are not applied to the policy yet. It is becase the endorsement is not yet accepted.
Accept the Endorsement
Query examples
mutation acceptEndorsement(
$policyId:String!
$endorsementId: String!
) {
acceptEndorsement(
policyId: $policyId
endorsementId: $endorsementId
) {
status
errors
errors_2 { message code }
}
}
Input:
{
"policyId": "b795a798-bb5b-4d9f-921f-92f119aa3cbf",
"endorsementId": "171fea8d-5002-47ac-965b-31f070ad84c7"
}
Result:
{
"data": {
"acceptEndorsement": {
"status": "success",
"errors": null,
"errors_2": null
}
}
}
Final Policy
Now the changes in endorsement are applied:
{
"data": {
"policies": {
"list": [
{
"id": "b795a798-bb5b-4d9f-921f-92f119aa3cbf",
"createdAt": "2021-06-07T04:28:18.726Z",
"lastModifiedAt": "2021-06-07T04:32:01.41Z",
"insured": [
{
"name": "Demo User"
}
],
"fields": "{\n \"numberOfInsureds\": 1\n}",
"product": {
"productId": {
"type": "Demo Insurance",
"plan": "Plan 2",
"version": "1"
}
}
}
]
}
}
}