[]]], requestBody: new OA\RequestBody( required: true, content: new OA\JsonContent( required: ['name', 'medical_system_code'], properties: [ new OA\Property(property: 'name', type: 'string'), new OA\Property(property: 'medical_system_code', type: 'string'), new OA\Property(property: 'source', type: 'string', default: 'irimc'), new OA\Property(property: 'source_ref', type: 'string', nullable: true, description: 'profile_url یا شناسهٔ مبدأ'), new OA\Property(property: 'gender', type: 'string', nullable: true), new OA\Property(property: 'degree', type: 'string', nullable: true), new OA\Property(property: 'info', type: 'string', nullable: true), new OA\Property(property: 'specialties', type: 'array', items: new OA\Items(type: 'integer'), nullable: true), new OA\Property(property: 'states', type: 'array', items: new OA\Items(type: 'integer'), nullable: true), new OA\Property(property: 'cities', type: 'array', items: new OA\Items(type: 'integer'), nullable: true), ] ) ), responses: [ new OA\Response(response: 201, description: 'Doctor imported (created)'), new OA\Response(response: 200, description: 'Doctor already existed (updated or skipped)'), new OA\Response(response: 403, description: 'Requires ROLE_ADMIN or ROLE_IMPORTER'), new OA\Response(response: 422, description: 'Validation error'), ] )] #[Route('/api/v1/admin/doctors/import', methods: ['POST'])] public function import(Request $request, #[CurrentUser] User $user): JsonResponse { if (!$this->isGranted('ROLE_ADMIN') && !$this->isGranted('ROLE_IMPORTER')) { return $this->error(ErrorCodes::ERR_FORBIDDEN_001, 'دسترسی به این منبع مجاز نیست', 403); } $data = json_decode($request->getContent(), true) ?? []; $name = trim((string) ($data['name'] ?? '')); $code = trim((string) ($data['medical_system_code'] ?? $data['medicalSystemCode'] ?? '')); if ($name === '') { return $this->error(ErrorCodes::VALIDATION, 'نام الزامی است', 422, 'name'); } if ($code === '') { return $this->error(ErrorCodes::VALIDATION, 'کد نظام پزشکی الزامی است', 422, 'medical_system_code'); } $result = $this->importService->import($data, $user); $payload = ['uuid' => $result->doctor->getUuid(), 'created' => $result->created]; if ($result->skipped !== null) { $payload['skipped'] = $result->skipped; } return $this->success($payload, $result->created ? 201 : 200); } }