# CloseClaim - Advanced Documentation ## Overview Closes a claim with a specified date and note, preventing further modifications. Optionally cleans up open tasks and future calendar events. Requires **ManageClosingClaims** permission. ## Required Fields The `ClaimInfo` object must include: - **ID** (long) - ClaimID, must be >= 1 - **ClosedDate** (DateTime) - Required, cannot be empty - **ClosedNote** (string) - Required, cannot be null or empty - **Timestamp** - Must match the current database value (optimistic concurrency) ## Optional Parameters - **DeleteOpenTasks** (bool) - If true, deletes all incomplete tasks associated with this claim - **DeleteFutureEvents** (bool) - If true, deletes future calendar events that belong **exclusively** to this claim. Events shared with other claims are preserved. ## Business Rules 1. Full claim validation runs (`Validate()`) - all standard claim field rules apply 2. Timestamp concurrency check - if another user modified the claim since you loaded it, the close fails 3. Status is recomputed after setting ClosedDate 4. Claim request cache for the firm is cleared (because filtering uses status) 5. Claim color label is recalculated ## Side Effects - Sets ClosedDate and ClosedNote on the claim - Updates claim Status - Optionally deletes open tasks (via Task service) - Optionally deletes future-only calendar events (only if exclusively for this claim) - Clears claim request cache for the firm - Triggers claim finalization and color label recalculation ## Script Example ```javascript async () => { // First get the claim to have the current Timestamp const claim = await SecureApi.GetClaimWithoutNotes(771360); claim.ClosedDate = new Date().toISOString(); claim.ClosedNote = "Case resolved. Settlement complete."; const result = await SecureApi.CloseClaim(claim, true, true); return { id: result.ID, status: result.Status, closedDate: result.ClosedDate }; } ``` ## Error Conditions - `ClaimID < 1` - throws RadoloException - ClosedDate not set - throws RadoloException - ClosedNote empty - throws RadoloException - Validation failure - throws RadoloException - Timestamp mismatch (concurrency conflict) - throws RadoloException - User lacks ManageClosingClaims permission - throws RadoloException