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:
@@ -38,18 +38,39 @@ describe('filterInsurances', () => {
|
||||
});
|
||||
});
|
||||
|
||||
const categories = [
|
||||
{ key: 'outpatient', label: 'سرپایی' },
|
||||
{ key: 'inpatient', label: 'بستری' },
|
||||
];
|
||||
|
||||
describe('contractSummary', () => {
|
||||
it('shows coverage, franchise and ceiling inline', () => {
|
||||
const s = contractSummary(mk({ coverage_percent: 90, franchise_rials: 500_000, annual_ceiling_rials: 20_000_000 }));
|
||||
expect(s).toContain('پوشش');
|
||||
expect(s).toContain('فرانشیز');
|
||||
it('breaks the coverage down per service category', () => {
|
||||
const s = contractSummary(
|
||||
mk({ category_coverages: { outpatient: 70, inpatient: 30 }, annual_ceiling_rials: 20_000_000 }),
|
||||
categories,
|
||||
);
|
||||
expect(s).toContain('سرپایی ۷۰٪');
|
||||
expect(s).toContain('بستری ۳۰٪');
|
||||
expect(s).toContain('سقف پوشش');
|
||||
});
|
||||
it('omits franchise when zero and marks unlimited ceiling', () => {
|
||||
const s = contractSummary(mk({ franchise_rials: 0, annual_ceiling_rials: null }));
|
||||
expect(s).not.toContain('فرانشیز');
|
||||
|
||||
it('shows the franchise only on a supplementary contract', () => {
|
||||
const basic = contractSummary(mk({ franchise_rials: 500_000, insurance_kind: 'basic' }), categories);
|
||||
expect(basic).not.toContain('فرانشیز');
|
||||
|
||||
const supp = contractSummary(mk({ franchise_rials: 500_000, insurance_kind: 'supplementary' }), categories);
|
||||
expect(supp).toContain('فرانشیز');
|
||||
});
|
||||
|
||||
it('marks an unlimited ceiling', () => {
|
||||
const s = contractSummary(mk({ franchise_rials: 0, annual_ceiling_rials: null }), categories);
|
||||
expect(s).toContain('سقف پوشش نامحدود');
|
||||
});
|
||||
|
||||
it('falls back to the legacy contract percent with no category rows', () => {
|
||||
const s = contractSummary(mk({ coverage_percent: 90, category_coverages: undefined }), categories);
|
||||
expect(s).toContain('پوشش ۹۰٪');
|
||||
});
|
||||
});
|
||||
|
||||
describe('TenantInsuranceContracts', () => {
|
||||
|
||||
Reference in New Issue
Block a user