Managing Claims
Managing Claims
The faizanGeek Claim Processing System provides a comprehensive suite of features for users to manage their claims efficiently. This section guides you through the process of submitting new claims, viewing existing ones, updating claim details, and tracking their status within the system.
Prerequisites
Before you can manage claims, you must be an authenticated user. The system uses Spring Security with JWTs for authentication. Ensure you have successfully registered and obtained an authentication token.
- Registration:
POST /register - Login:
POST /login
All subsequent claim management operations require this authentication token to be included in the request headers (e.g., Authorization: Bearer <your-jwt-token>).
Submitting a New Claim
To submit a new claim, you will make a POST request to the claims endpoint. Upon submission, the claim's initial status is automatically set to "Submitted" and the claimDate is recorded.
Endpoint: POST /api/claims
Request Body Example (JSON):
{
"userId": 1,
"claimAmount": 1500.75,
"claimType": "Medical Reimbursement",
"description": "Consultation fees and prescription costs for a general check-up."
}
Response Example (JSON):
{
"claimId": 101,
"userId": 1,
"claimDate": "2023-10-27T10:00:00.000+00:00",
"claimAmount": 1500.75,
"claimType": "Medical Reimbursement",
"claimStatus": "Submitted",
"lastUpdated": "2023-10-27T10:00:00.000+00:00"
}
Viewing Claims
You can retrieve claims in various ways: by a specific ID, or by the user who submitted them.
Retrieve a Claim by ID
To fetch the details of a single claim, use its unique claimId.
Endpoint: GET /api/claims/{claimId}
Path Variable:
claimId(Long): The unique identifier of the claim.
Response Example (JSON):
{
"claimId": 101,
"userId": 1,
"claimDate": "2023-10-27T10:00:00.000+00:00",
"claimAmount": 1500.75,
"claimType": "Medical Reimbursement",
"claimStatus": "Processed",
"lastUpdated": "2023-10-27T11:30:00.000+00:00"
}
Retrieve Claims by User ID
To see all claims submitted by a particular user, query by their userId.
Endpoint: GET /api/claims/user/{userId}
Path Variable:
userId(Long): The unique identifier of the user.
Response Example (JSON Array):
[
{
"claimId": 101,
"userId": 1,
"claimDate": "2023-10-27T10:00:00.000+00:00",
"claimAmount": 1500.75,
"claimType": "Medical Reimbursement",
"claimStatus": "Processed",
"lastUpdated": "2023-10-27T11:30:00.000+00:00"
},
{
"claimId": 102,
"userId": 1,
"claimDate": "2023-10-26T14:15:00.000+00:00",
"claimAmount": 500.00,
"claimType": "Travel Expense",
"claimStatus": "Submitted",
"lastUpdated": "2023-10-26T14:15:00.000+00:00"
}
]
Checking Claim Status
For a quick check of a claim's current status, you can use a dedicated endpoint that leverages a fast caching mechanism (Redis).
Endpoint: GET /api/claims/{claimId}/status
Path Variable:
claimId(Long): The unique identifier of the claim.
Response Example (String):
ProcessedUpdating Claim Details
You can modify certain details of an existing claim by sending a PUT request with the updated information. Note that sensitive fields like userId cannot be changed directly via this endpoint. The lastUpdated timestamp will be automatically updated.
Endpoint: PUT /api/claims/{claimId}
Path Variable:
claimId(Long): The unique identifier of the claim to update.
Request Body Example (JSON):
{
"claimAmount": 1600.00,
"claimType": "Medical Reimbursement",
"claimStatus": "Submitted"
}
Note: While you can send a claimStatus in the PUT request, it's generally recommended to use the dedicated status update mechanism (if available) or rely on automated processing for status changes to ensure proper workflows and notifications are triggered.
Response Example (JSON):
{
"claimId": 101,
"userId": 1,
"claimDate": "2023-10-27T10:00:00.000+00:00",
"claimAmount": 1600.00,
"claimType": "Medical Reimbursement",
"claimStatus": "Submitted",
"lastUpdated": "2023-10-27T15:45:00.000+00:00"
}
Tracking Claim Status
The system provides robust mechanisms for tracking claim status, including manual updates and automated processing.
Manually Updating Claim Status
Authorized personnel (e.g., administrators or claim processors) can manually update a claim's status. This action triggers internal notifications.
Endpoint: PATCH /api/claims/{claimId}/status (Assumed endpoint for status-specific update)
Path Variable:
claimId(Long): The unique identifier of the claim.
Request Body Example (JSON):
{
"newStatus": "Approved",
"userEmail": "admin@example.com"
}
Note: The userEmail in the request body is used for notification purposes. In a real-world scenario, this might be extracted from the authenticated user's token.
Upon successful update, the new status is recorded, cached in Redis, and a Kafka message is published to notify relevant subscribers (e.g., for email notifications to the user).
Automated Claim Processing
The system includes a scheduled batch service that automatically processes pending claims. This service runs hourly, identifying claims that meet specific criteria (e.g., 'Pending' status and not updated for over 24 hours) and updating their status.
- Claims identified by the batch service will have their status updated (e.g., to "Processed").
- This automated update also triggers the same notification mechanisms (Kafka, email) as manual status updates.
Notifications
Users are notified of claim status updates through email. When a claim's status is updated (either manually or automatically), a message is sent to a Kafka topic. A Kafka listener then picks up this message and uses the EmailService to send an email to the user associated with the claim, informing them of the status change.
Deleting Claims
Claims can be deleted from the system using their claimId. This operation is typically restricted to administrators or users with specific permissions.
Endpoint: DELETE /api/claims/{claimId}
Path Variable:
claimId(Long): The unique identifier of the claim to delete.
Response:
- 204 No Content: On successful deletion.
- 404 Not Found: If the claim with the specified ID does not exist.