Webhook endpoint for processing patient payments from external systems (e.g., Stripe via Elation). Updates the associated claim with payment information and handles overpayments by creating unallocated patient credits.
This webhook endpoint allows external systems (e.g., payment processors like Stripe via Elation) to post patient payments directly to Cair Health. When a patient makes a payment, you can send the payment information to this endpoint, and it will automatically update the associated claim with the payment details.
The Elation bill.id that maps to the Claim identifier. This should match the
Claim identifier with system
https://fhir.cairhealth.com/fhir/identifier/claim-id.
Contains the payment processing details: - claimId: The UUID of the claim
that was updated - claimLifecycleId: The lifecycle ID of the claim -
amountSetOnClaim: The amount that was set on the claim (may be less than
paymentAmount if payment exceeds patient responsibility) - excessAmount:
(Optional) Only present if the payment amount exceeds the patient’s
responsibility. This excess amount is automatically created as an unallocated
patient credit.
Claim Lookup: The system searches for a claim matching the provided billId using the identifier system https://fhir.cairhealth.com/fhir/identifier/claim-id.
Patient Responsibility Calculation: The system calculates the patient’s responsibility from the associated ClaimResponse resource.
Payment Application:
If the payment amount is less than or equal to the patient responsibility, the full payment amount is applied to the claim.
If the payment amount exceeds the patient responsibility, only the responsibility amount is applied to the claim, and the excess is automatically created as an unallocated patient credit.
Database Updates:
Updates the patientPaidAmount field on all claims with the same claimLifecycleId
Creates or updates a PatientPaymentDetails record with payment information
FHIR Updates:
Creates or updates a PaymentReconciliation resource in FHIR
Links the payment to the patient via the patient-payment-issuer extension
Excess Payment Handling: If the payment exceeds the patient responsibility, an unallocated PatientCredit is automatically created for the excess amount, which can be allocated to other claims later.