# Insurance and claims

> The claims preset installs claimants, a claim state machine, approvals, evidence attachments, SLA clocks and comments.

Source: https://bettersupabase.com/docs/presets/claims

The `claims` preset is for a claims system in the style of Guidewire. A
claimant reports a claim, an adjuster investigates it with the evidence
attached, a payout above a limit needs approval, and SLA clocks keep each
step on time.

## Config [#config]

```ts title="better-supabase.config.ts"
import { defineConfig } from "better-supabase/config";

export default defineConfig({ preset: "claims" });
```

`npx better-supabase init --preset claims` starts a new project from it, and
`npx better-supabase apply --preset claims` adds it to one you have
([CLI](/docs/cli/presets)).

## Blocks [#blocks]

The preset is [`saas`](/docs/presets#named-presets) plus these blocks, and
whatever they require:

| Block                                       | Role in the app                             |
| ------------------------------------------- | ------------------------------------------- |
| [parties](/docs/blocks/parties)             | Policyholders, claimants and third parties  |
| [state-machine](/docs/blocks/state-machine) | The claim's status, from reported to closed |
| [approvals](/docs/blocks/approvals)         | Payout approval above a limit               |
| [attachments](/docs/blocks/attachments)     | Photos, reports and invoices as evidence    |
| [sla](/docs/blocks/sla)                     | First contact and resolution clocks         |
| [comments](/docs/blocks/comments)           | Adjusters' notes on the claim               |

## How the blocks connect [#how-the-blocks-connect]

A claim is your own table, registered as a subject, with a state machine on
its status column. Mark the edge to `approved` with `requiresApproval`, and
give the approvals policy for claims `run: { transition: "approved" }`: the
final approval of the payout then runs the transition, and nobody can move a
claim to `approved` without it ([approvals](/docs/blocks/approvals#run-the-approved-action)).
SLA clocks start when the claim is reported and pause while it waits on the
claimant.

```ts title="better-supabase.config.ts"
import { defineConfig } from "better-supabase/config";

export default defineConfig({
  preset: "claims",
  subjects: {
    claim: {
      table: "public.claims",
      idType: "uuid",
      tenant: "organization_id",
    },
  },
  blocks: {
    "state-machine": {
      options: {
        machines: {
          claim: {
            column: "status",
            initial: "reported",
            transitions: {
              reported: ["investigating", "rejected"],
              investigating: ["approved", "rejected"],
              approved: ["paid"],
              paid: ["closed"],
              rejected: ["closed"],
            },
            requiresApproval: { investigating: ["approved"] },
          },
        },
      },
    },
  },
});
```

## With ReUI [#with-reui]

- Data Grid for the claim queue, with Filters on status, adjuster and SLA.
- Stepper for the claim's status on its page.
- Timeline for the claim's history, evidence and notes.