feat: add insurance and location management
- Introduced InsuranceType enum for insurance categorization. - Created InsuranceRepository for managing insurance entities. - Developed LocationController for handling provinces and cities, including CRUD operations. - Implemented City and Province entities with necessary fields and relationships. - Added CityRepository and ProvinceRepository for database interactions. - Established Specialty management with SpecialtyController, including CRUD operations. - Created Specialty and Tag entities with appropriate fields and relationships. - Implemented TagController for managing tags, including CRUD operations. - Added TagRepository for database interactions with tags.
This commit is contained in:
@@ -4,11 +4,15 @@ namespace App\Clinic\Controller;
|
||||
|
||||
use App\Auth\Entity\User;
|
||||
use App\Auth\Repository\UserRepository;
|
||||
use App\Category\Repository\CategoryRepository;
|
||||
use App\Clinic\Entity\Clinic;
|
||||
use App\Clinic\Repository\ClinicRepository;
|
||||
use App\Doctor\Entity\Doctor;
|
||||
use App\Doctor\Repository\DoctorRepository;
|
||||
use App\DoctorService\Repository\DoctorServiceRepository;
|
||||
use App\Insurance\Repository\InsuranceRepository;
|
||||
use App\Location\Repository\CityRepository;
|
||||
use App\Location\Repository\ProvinceRepository;
|
||||
use App\Specialty\Repository\SpecialtyRepository;
|
||||
use App\Shared\Constant\ErrorCodes;
|
||||
use App\Shared\Controller\BaseController;
|
||||
use App\Shared\Service\FileValidatorService;
|
||||
@@ -24,12 +28,16 @@ use Symfony\Component\Uid\Uuid;
|
||||
class ClinicController extends BaseController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ClinicRepository $clinicRepo,
|
||||
private readonly DoctorRepository $doctorRepo,
|
||||
private readonly CategoryRepository $categoryRepo,
|
||||
private readonly UserRepository $userRepo,
|
||||
private readonly FileValidatorService $fileValidator,
|
||||
private readonly string $projectDir,
|
||||
private readonly ClinicRepository $clinicRepo,
|
||||
private readonly DoctorRepository $doctorRepo,
|
||||
private readonly SpecialtyRepository $specialtyRepo,
|
||||
private readonly DoctorServiceRepository $serviceRepo,
|
||||
private readonly InsuranceRepository $insuranceRepo,
|
||||
private readonly ProvinceRepository $provinceRepo,
|
||||
private readonly CityRepository $cityRepo,
|
||||
private readonly UserRepository $userRepo,
|
||||
private readonly FileValidatorService $fileValidator,
|
||||
private readonly string $projectDir,
|
||||
) {}
|
||||
|
||||
#[OA\Post(
|
||||
@@ -399,7 +407,7 @@ class ClinicController extends BaseController
|
||||
|
||||
// Location
|
||||
if (!empty($data['state']) && is_array($data['state'])) {
|
||||
$clinic->setStateId((int) $data['state'][0]);
|
||||
$clinic->setProvinceId((int) $data['state'][0]);
|
||||
}
|
||||
if (!empty($data['city']) && is_array($data['city'])) {
|
||||
$clinic->setCityId((int) $data['city'][0]);
|
||||
@@ -427,10 +435,10 @@ class ClinicController extends BaseController
|
||||
// ManyToMany: specialties
|
||||
if (array_key_exists('specialties', $data) && is_array($data['specialties'])) {
|
||||
$clinic->getSpecialties()->clear();
|
||||
foreach ($data['specialties'] as $catId) {
|
||||
$cat = $this->categoryRepo->find((int) $catId);
|
||||
if ($cat !== null) {
|
||||
$clinic->getSpecialties()->add($cat);
|
||||
foreach ($data['specialties'] as $id) {
|
||||
$specialty = $this->specialtyRepo->find((int) $id);
|
||||
if ($specialty !== null) {
|
||||
$clinic->getSpecialties()->add($specialty);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -438,10 +446,10 @@ class ClinicController extends BaseController
|
||||
// ManyToMany: services (doctor_services)
|
||||
if (array_key_exists('doctor_services', $data) && is_array($data['doctor_services'])) {
|
||||
$clinic->getServices()->clear();
|
||||
foreach ($data['doctor_services'] as $catId) {
|
||||
$cat = $this->categoryRepo->find((int) $catId);
|
||||
if ($cat !== null) {
|
||||
$clinic->getServices()->add($cat);
|
||||
foreach ($data['doctor_services'] as $id) {
|
||||
$service = $this->serviceRepo->find((int) $id);
|
||||
if ($service !== null) {
|
||||
$clinic->getServices()->add($service);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -449,10 +457,10 @@ class ClinicController extends BaseController
|
||||
// ManyToMany: insurances
|
||||
if (array_key_exists('insurance', $data) && is_array($data['insurance'])) {
|
||||
$clinic->getInsurances()->clear();
|
||||
foreach ($data['insurance'] as $catId) {
|
||||
$cat = $this->categoryRepo->find((int) $catId);
|
||||
if ($cat !== null) {
|
||||
$clinic->getInsurances()->add($cat);
|
||||
foreach ($data['insurance'] as $id) {
|
||||
$insurance = $this->insuranceRepo->find((int) $id);
|
||||
if ($insurance !== null) {
|
||||
$clinic->getInsurances()->add($insurance);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -460,28 +468,28 @@ class ClinicController extends BaseController
|
||||
|
||||
private function loadLocationData(Clinic $clinic): array
|
||||
{
|
||||
$stateData = [];
|
||||
$cityData = [];
|
||||
$provinceData = [];
|
||||
$cityData = [];
|
||||
|
||||
if ($clinic->getStateId() !== null) {
|
||||
$state = $this->categoryRepo->find($clinic->getStateId());
|
||||
if ($state !== null) {
|
||||
$stateData = ['uuid' => $state->getUuid(), 'id' => (string) $state->getId(), 'name' => $state->getLabel()];
|
||||
if ($clinic->getProvinceId() !== null) {
|
||||
$province = $this->provinceRepo->find($clinic->getProvinceId());
|
||||
if ($province !== null) {
|
||||
$provinceData = ['uuid' => $province->getUuid(), 'id' => (string) $province->getId(), 'name' => $province->getName()];
|
||||
}
|
||||
}
|
||||
if ($clinic->getCityId() !== null) {
|
||||
$city = $this->categoryRepo->find($clinic->getCityId());
|
||||
$city = $this->cityRepo->find($clinic->getCityId());
|
||||
if ($city !== null) {
|
||||
$cityData = [
|
||||
'uuid' => $city->getUuid(),
|
||||
'id' => (string) $city->getId(),
|
||||
'name' => $city->getLabel(),
|
||||
'parent' => $city->getParentId() !== null ? (string) $city->getParentId() : null,
|
||||
'name' => $city->getName(),
|
||||
'parent' => $city->getProvinceId() !== null ? (string) $city->getProvinceId() : null,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return [$stateData, $cityData];
|
||||
return [$provinceData, $cityData];
|
||||
}
|
||||
|
||||
private function handleFileUpload(Request $request, string $subDir): JsonResponse
|
||||
|
||||
Reference in New Issue
Block a user