# Build a claim from charges

Canonical page: https://docs.ovok.com/api/patient-billing/build-a-claim-from-charges

`POST /v1/patient-billing/patients/{patientId}/claims`

Builds a claim to an insurer from the patient's billable charges at one clinic, as a FHIR `Claim`. Its insurer is that of the patient's first insurance coverage in force for the services; `insurance` lists every such coverage in order, the first as focal. The charges turn `billed` in the same commit.

**Scope:** the caller's project, with `PATIENT_BILLING_ENABLED` on.

## Behaviour

- Your access policy must grant `patient_billing_claims` `create` and let you read the patient, else **403** `PATIENT_BILLING_NOT_ALLOWED` or **404** `PATIENT_BILLING_PATIENT_NOT_FOUND`.
- `clinicId` must be a clinic the patient is enrolled with, else **422** `BILLING_CLINIC_INVALID`. The clinic is the claim's provider.
- Only statutory and private coverages count, and only those whose `period` covers a day of the services. Without one, **422** `COVERAGE_NOT_INSURED`.
- `chargeIds` and the charge rules are those of issuing an invoice: 49 at most, one currency, **409** `CHARGE_NOT_BILLABLE` or `NO_BILLABLE_CHARGES`.
- Building a claim sends nothing. Submit it (`POST /v1/patient-billing/claims/<claimId>/submission`) to get it to the insurer.
- `identifier` is optional. With it, the same identifier for the same patient again answers the claim already built, with **200**. A new claim answers **201** with `Location: /v1/patient-billing/claims/<id>`.

## Example

```bash
curl -X POST 'https://api.sandbox.ovok.com/v1/patient-billing/patients/<patientId>/claims' \
  -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3NjcyNjg4MDAsImV4cCI6MTc2NzI3MjQwMH0.Ql3B_ztDvctlyZ2z0vp4sl3ExXRQGkzmxdmTAqxNzZk' \
  -H 'Content-Type: application/json' \
  -d '{ "clinicId": "<clinicId>", "chargeIds": null, "type": "professional" }'
```
