Explore documentation

Payment Management

Tracking payments through Account and Invoice

Set up the SDK server client to run the examples using esus. The REST examples use a session token. To run them with the SDK’s API key, send X-API-Key instead of Authorization.

PaymentNotice and PaymentReconciliation are not available in the Esus API. Track charges and payments with Account (to aggregate charges) and Invoice (to itemize and settle).

Account — Aggregating Charges

Account aggregates billable activity for a patient over a period (an inpatient stay, a billing cycle, a single encounter). No field is required; status defaults to active. Send the patient as the flat id subjectId (it must exist in your organization); responses return it as subject: [{ "reference": "Patient/<uuid>" }].

REST
curl -X POST https://api.esus.health/fhir/Account \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/fhir+json" \
  -d '{
    "status": "active",
    "name": "Inpatient stay — April 2026",
    "subjectId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "servicePeriod": {
      "start": "2026-04-15",
      "end": "2026-04-21"
    },
    "coverage": [
      {
        "coverage": { "reference": "Coverage/c1a2e3d4-5b6f-7890-abcd-ef1234567890" },
        "priority": 1
      }
    ]
  }'
SDK
const created = await esus.fhir.create("Account", {
  "status": "active",
  "name": "Inpatient stay — April 2026",
  "subjectId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "servicePeriod": {
    "start": "2026-04-15",
    "end": "2026-04-21"
  },
  "coverage": [
    {
      "coverage": {
        "reference": "Coverage/c1a2e3d4-5b6f-7890-abcd-ef1234567890"
      },
      "priority": 1
    }
  ]
});

Invoice — Settling an Account

Invoice is the document you issue to a payer or patient. No field is required; status defaults to draft. The patient goes in subjectId and the account in accountId (flat ids); responses return them as subject and account references. lineItem and totalPriceComponent are stored as sent, so use the standard FHIR shapes.

REST
curl -X POST https://api.esus.health/fhir/Invoice \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/fhir+json" \
  -d '{
    "status": "issued",
    "subjectId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "accountId": "aa11bb22-cc33-dd44-ee55-ff6677889900",
    "recipient": {
      "reference": "Patient/3fa85f64-5717-4562-b3fc-2c963f66afa6"
    },
    "date": "2026-04-22",
    "lineItem": [
      {
        "sequence": 1,
        "chargeItemCodeableConcept": {
          "coding": [{
            "system": "http://www.ama-assn.org/go/cpt",
            "code": "99213",
            "display": "Office visit, established patient"
          }]
        },
        "priceComponent": [{
          "type": "base",
          "amount": { "value": 150.00, "currency": "USD" }
        }]
      }
    ],
    "totalNet":   { "value": 150.00, "currency": "USD" },
    "totalGross": { "value": 168.00, "currency": "USD" },
    "paymentTerms": "Payment due within 30 days."
  }'
SDK
const created = await esus.fhir.create("Invoice", {
  "status": "issued",
  "subjectId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "accountId": "aa11bb22-cc33-dd44-ee55-ff6677889900",
  "recipient": {
    "reference": "Patient/3fa85f64-5717-4562-b3fc-2c963f66afa6"
  },
  "date": "2026-04-22",
  "lineItem": [
    {
      "sequence": 1,
      "chargeItemCodeableConcept": {
        "coding": [
          {
            "system": "http://www.ama-assn.org/go/cpt",
            "code": "99213",
            "display": "Office visit, established patient"
          }
        ]
      },
      "priceComponent": [
        {
          "type": "base",
          "amount": {
            "value": 150.0,
            "currency": "USD"
          }
        }
      ]
    }
  ],
  "totalNet": {
    "value": 150.0,
    "currency": "USD"
  },
  "totalGross": {
    "value": 168.0,
    "currency": "USD"
  },
  "paymentTerms": "Payment due within 30 days."
});

Invoice Statuses

StatusMeaning
draftPrepared but not issued (default)
issuedIssued to the recipient
balancedPaid in full
cancelledCancelled (optionally explain in cancelledReason)
entered-in-errorRecorded in error

Account Statuses

StatusMeaning
activeAccount is open and tracking charges (default)
inactiveAccount is closed
on-holdSuspended
entered-in-errorRecorded in error
unknownStatus cannot be determined

Outstanding Balances

ResourceSearch parameters (all exact)
Accountpatient, status
Invoicepatient, status, account (<uuid> or Account/<uuid>)
# All active accounts for a patient
curl "https://api.esus.health/fhir/Account?patient=3fa85f64-5717-4562-b3fc-2c963f66afa6&status=active" \
  -H "Authorization: Bearer YOUR_TOKEN"

# All unpaid invoices for a patient
curl "https://api.esus.health/fhir/Invoice?patient=3fa85f64-5717-4562-b3fc-2c963f66afa6&status=issued" \
  -H "Authorization: Bearer YOUR_TOKEN"

# All invoices of an account
curl "https://api.esus.health/fhir/Invoice?account=aa11bb22-cc33-dd44-ee55-ff6677889900" \
  -H "Authorization: Bearer YOUR_TOKEN"

On the body the patient is the flat id subjectId, but the search parameter is patient.

Recording a Payment

  1. Move the Invoice to balanced when the total is paid in full (for example PATCH /fhir/Invoice/:id with { "status": "balanced" }).
  2. Record the payment details (amount, date, method, reference number) in Invoice.note[] (each note is { "text": "..." }) or in your own ledger keyed by Invoice/<uuid>.
  3. For partial payments, keep the Invoice in issued and track the remaining balance in your own system.