Financial
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.
PaymentNoticeandPaymentReconciliationare not available in the Esus API. Track charges and payments withAccount(to aggregate charges) andInvoice(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>" }].
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
}
]
}'
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.
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."
}'
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
| Status | Meaning |
|---|---|
draft | Prepared but not issued (default) |
issued | Issued to the recipient |
balanced | Paid in full |
cancelled | Cancelled (optionally explain in cancelledReason) |
entered-in-error | Recorded in error |
Account Statuses
| Status | Meaning |
|---|---|
active | Account is open and tracking charges (default) |
inactive | Account is closed |
on-hold | Suspended |
entered-in-error | Recorded in error |
unknown | Status cannot be determined |
Outstanding Balances
| Resource | Search parameters (all exact) |
|---|---|
Account | patient, status |
Invoice | patient, 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 ispatient.
Recording a Payment
- Move the
Invoicetobalancedwhen the total is paid in full (for examplePATCH /fhir/Invoice/:idwith{ "status": "balanced" }). - Record the payment details (amount, date, method, reference number) in
Invoice.note[](each note is{ "text": "..." }) or in your own ledger keyed byInvoice/<uuid>. - For partial payments, keep the
Invoiceinissuedand track the remaining balance in your own system.