Overview
This PR touches Dentolize's API Config webhook system — the feature that lets a clinic's back office push real-time events (new patient, new invoice, new payment, etc.) to an outside system whenever something happens in Dentolize.
Status: unreleased. Everything described here is from the pull requestmo/add_api_for_balance_invoice(#375, branch basemain) and has not shipped to customers yet.
Three things change:
- Two new webhook events for patient balance. When a clinic tops up a
patient's credit balance directly, or when a patient overpays an invoice and the extra money is converted into balance, Dentolize now fires NEW_BALANCE_INVOICE and NEW_BALANCE_PAYMENT events — the same way it already fires NEW_INVOICE and NEW_PAYMENT for regular invoices.
- The webhook "type" selector is gone. Every configured webhook used to be
labeled OTHER, NPHIES, or ZATCA, each with its own payload shape. In practice NPHIES and ZATCA were unused, dead code paths that happened to produce byte-for-byte identical payloads to OTHER. This PR deletes both and makes OTHER the only shape, so the dropdown disappears from the settings form entirely.
- Two data bugs are fixed. The
insurance_policy_data.namefield sent in
every invoice/patient webhook payload was always undefined (it read a database column that doesn't exist), and a copy-paste bug meant the balance invoice created from an overpayment had its reference number written onto the wrong invoice object.
Why this matters
Dentolize's API Config is the mechanism third-party systems (accounting tools, insurance middleware, custom clinic dashboards) use to stay in sync with a clinic's data without polling. Before this PR, adding money to a patient's balance — either directly or as overpayment change — was invisible to those integrations: no event fired, so external systems had no way to know a balance invoice or balance payment had been created. This PR closes that gap.
Who touches what
- Clinic owners / account admins configure webhook URLs and pick which
events to receive, in Settings → Integrations → API Config (only visible to companies with the apiEnabled flag turned on — see For Support).
- Front-desk / accounting staff trigger the underlying actions (Add
Balance, taking a payment larger than what's owed) without knowing or caring that a webhook fires — it's entirely a backend side effect.
- Integration developers on the receiving end of the webhook are the real
audience for the new event types and the payload shape documented in Balance webhook events.
Read next: Walkthrough for an annotated tour of the screens involved, or jump straight to Balance webhook events for the technical payload details.