fix(billing): bill the insurance share on clinic appointments
The invoice and the encounter belong to the clinic, but the contract sits on the doctor, so every coverage lookup asked the clinic, got nothing, and resolved to zero percent. Three failures followed from that one wrong tenant: the encounter charged the patient the full amount, the payment page showed a balance the insurer owed, and — because no line carried an insurance share — no claim was ever built, leaving the claims page empty. Coverage now resolves through the same doctor-first-then-clinic rule the rest of the insurance settings use, both when the encounter is created and when its invoice lines are built. Changing the insurance on an appointment also re-runs the encounter's shares. Reception routinely confirms first and corrects the insurance afterwards, and until now those shares stayed frozen at whatever the first calculation said. Recorded payments are untouched; only the payable amount moves, so an overpayment simply clamps the remainder at zero. The PATCH response also returns the appointment's real venue now, matching GET. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -56,6 +56,7 @@ class AppointmentController extends BaseController
|
||||
private readonly \App\Resource\Service\PublicResourceBookingService $publicResources,
|
||||
private readonly \App\Treatment\Service\SessionBookingLink $sessionLink,
|
||||
private readonly \App\Shared\Tenant\TenantFilterScope $tenantScope,
|
||||
private readonly \App\Patient\Service\PatientService $patients,
|
||||
private readonly \Psr\Log\LoggerInterface $logger,
|
||||
) {}
|
||||
|
||||
@@ -1482,7 +1483,12 @@ class AppointmentController extends BaseController
|
||||
if ($completed) {
|
||||
}
|
||||
|
||||
return $this->success(['data' => $appointment->toArray()]);
|
||||
// انتخاب بیمه میتواند بعد از ساختهشدنِ مراجعه عوض شود — پذیرش اول نوبت را
|
||||
// قطعی میکند و بعد بیمه را اصلاح میکند. بدون این، سهمهای مراجعه روی همان
|
||||
// محاسبهٔ اول میمانند و صفحهٔ پرداخت سهمِ بیمه را از بیمار میخواهد.
|
||||
$this->patients->resyncInsuranceShares($appointment);
|
||||
|
||||
return $this->success(['data' => $this->appointmentWithVenue($appointment)]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user