feat(insurance): resolve coverage percent per service category
Base insurance is a percentage-only rule: patient share is now total minus the base share, and the contract franchise no longer inflates it (franchise stays meaningful for supplementary contracts only). Coverage percentages are managed centrally by admin per service category (outpatient/inpatient, extensible via the ServiceCategory enum). A tenant contract may override a category, otherwise it follows the admin default live — changing the central value immediately applies to every contract that did not override it. - add ServiceCategory enum + GET /api/v1/service-categories as the single source of the category list for every client - add insurance_coverage_defaults (+ GET/PUT admin coverage-defaults endpoints) and expose coverage_defaults on the insurance list and insurance-pricing - add tenant_insurance_category_coverage; tenant-insurances accepts optional category_coverages (needs insurances.update) and returns the effective percentages with their source - add service_items.service_category; visits always resolve as outpatient - drop the reverse-engineered percent from patient_share_rials in MyPatientsPage and align the client-side BillingCalculator mirror in CreateStep Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -88,8 +88,9 @@ class PatientService
|
||||
/**
|
||||
* تفکیک سهم بیمهها و سهم بیمار برای یک مراجعه.
|
||||
*
|
||||
* ویزیت با قاعدهی قرارداد بیمه (coverageRule) و هر خدمت با قاعدهی پوشش همان خدمت
|
||||
* (coverageRuleForService) محاسبه میشود — هر دو از طریق BillingCalculator، همان مسیری
|
||||
* ویزیت خدمتِ سرپایی است و با قاعدهی قرارداد بیمه (coverageRule) محاسبه میشود؛ هر خدمت
|
||||
* با قاعدهی پوشش نوعِ خودش (coverageRuleForService بر پایهی service_category همان خدمت)
|
||||
* محاسبه میشود — هر دو از طریق BillingCalculator، همان مسیری
|
||||
* که InvoiceService برای صدور فاکتور استفاده میکند. تنها منبع محاسبه همین است تا مبلغ
|
||||
* صفحهی پرداخت و فاکتور نتوانند از هم واگرا شوند.
|
||||
*
|
||||
@@ -143,7 +144,10 @@ class PatientService
|
||||
];
|
||||
}
|
||||
|
||||
/** درصد پوشش قرارداد فعال — snapshot روی مراجعه، نه ورودی محاسبه. */
|
||||
/**
|
||||
* درصد پوشش مؤثر ویزیت (سرپایی) از همان زنجیرهی resolve محاسبه —
|
||||
* snapshot نمایشی روی مراجعه، نه ورودی محاسبه.
|
||||
*/
|
||||
private function contractPercent(string $entityType, int $entityId, ?int $insuranceId): float
|
||||
{
|
||||
return $this->tenantInsuranceService->coverageRule($entityType, $entityId, $insuranceId)->coveragePercent;
|
||||
|
||||
Reference in New Issue
Block a user