feat(insurance): add insurance coverage flag to selected services and update coverage logic
This commit is contained in:
@@ -61,7 +61,7 @@ export default function NewSessionPage() {
|
||||
const nav = useNavigate();
|
||||
const qc = useQueryClient();
|
||||
|
||||
const [selectedServices, setSelectedServices] = useState<{ uuid: string; name: string; price: number; qty: number }[]>([]);
|
||||
const [selectedServices, setSelectedServices] = useState<{ uuid: string; name: string; price: number; qty: number; insured: boolean }[]>([]);
|
||||
const [sectionUuid, setSectionUuid] = useState('');
|
||||
const [itemUuid, setItemUuid] = useState('');
|
||||
const [baseId, setBaseId] = useState('');
|
||||
@@ -154,7 +154,7 @@ export default function NewSessionPage() {
|
||||
if (!itemUuid) return;
|
||||
const found = itemsData?.data?.find(i => i.uuid === itemUuid);
|
||||
if (!found || selectedServices.some(s => s.uuid === found.uuid)) return;
|
||||
setSelectedServices(p => [...p, { uuid: found.uuid, name: found.name, price: found.price_rials, qty: 1 }]);
|
||||
setSelectedServices(p => [...p, { uuid: found.uuid, name: found.name, price: found.price_rials, qty: 1, insured: !!found.insurance_covered }]);
|
||||
setItemUuid('');
|
||||
};
|
||||
|
||||
@@ -168,6 +168,8 @@ export default function NewSessionPage() {
|
||||
const servicesPatient = useMemo(
|
||||
() => selectedServices.reduce((sum, x) => {
|
||||
const total = x.price * x.qty;
|
||||
// پرچم سرویس gate نهایی: اگر «شامل بیمه» نباشد، کامل سهم بیمار است.
|
||||
if (!x.insured) return sum + total;
|
||||
return sum + patientShareOf(
|
||||
total,
|
||||
ruleFor(baseContract, baseCoverage, x.uuid),
|
||||
|
||||
Reference in New Issue
Block a user