feat: add visit price requirement feature
- Introduced a new boolean flag `require_visit_price` in the `EntityInsurancePricing` to enforce visit price for appointments. - Updated the appointment creation endpoints to validate `visit_price_rials` based on the new flag. - Added `visit_price_rials` field to the `Appointment` entity to store the visit price. - Enhanced the `PatientService` to validate visit price during session creation. - Updated API documentation to reflect changes in appointment and insurance pricing. - Implemented a new service `VisitPriceRequirementResolver` to determine if a visit price is required for a doctor based on their pricing settings. - Added migrations to update the database schema for the new fields.
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Insurance\Service;
|
||||
|
||||
use App\Clinic\Repository\ClinicRepository;
|
||||
use App\Doctor\Entity\Doctor;
|
||||
use App\Insurance\Entity\EntityInsurancePricing;
|
||||
use App\Insurance\Repository\EntityInsurancePricingRepository;
|
||||
|
||||
/**
|
||||
* فلگ «الزامی کردن هزینه ویزیت» را برای پزشکِ یک نوبت resolve میکند:
|
||||
* ردیف قیمتگذاری خود پزشک اگر موجود باشد؛ وگرنه کلینیکِ واحد پزشک
|
||||
* (همان ترتیب resolve کردن tenant در PatientService).
|
||||
*/
|
||||
class VisitPriceRequirementResolver
|
||||
{
|
||||
public function __construct(
|
||||
private readonly EntityInsurancePricingRepository $pricingRepo,
|
||||
private readonly ClinicRepository $clinicRepo,
|
||||
) {}
|
||||
|
||||
public function isRequiredForDoctor(Doctor $doctor): bool
|
||||
{
|
||||
$row = $this->pricingRepo->findOneForInsurance(EntityInsurancePricing::TYPE_DOCTOR, $doctor->getId(), null);
|
||||
if ($row !== null) {
|
||||
return $row->isRequireVisitPrice();
|
||||
}
|
||||
|
||||
$clinics = $this->clinicRepo->findByDoctor($doctor);
|
||||
if (count($clinics) === 1) {
|
||||
return $this->pricingRepo
|
||||
->findOneForInsurance(EntityInsurancePricing::TYPE_CLINIC, $clinics[0]->getId(), null)
|
||||
?->isRequireVisitPrice() ?? false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user