<?php
namespace App\Controller\API;
use App\Controller\BaseController;
use App\Entity\Log\LogInteraction;
use App\Services\API\TurnoService;
use App\Utils\APIResponse;
use App\Utils\CommonFunctions;
use Exception;
use OpenApi\Annotations as OA;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
/**
* @Route("/turnos")
*/
class TurnoController extends BaseController
{
/**
* @Route("/sucursales", name="obtener_sucursales", methods={"GET"})
* @param Request $request
* @param TurnoService $turnoService
* @return Response
*
* @OA\GET(
* path="/api/v1/turnos/sucursales",
* summary="Obtener sucursales",
* @OA\Parameter(
* name="fechaDesde",
* in="query",
* required=false,
* @OA\Schema(type="string")
* ),
* @OA\Parameter(
* name="lat",
* in="query",
* required=false,
* @OA\Schema(type="integer")
* ),
* @OA\Parameter(
* name="lng",
* in="query",
* required=false,
* @OA\Schema(type="integer")
* ),
* @OA\Parameter(
* name="idServicio",
* in="query",
* required=true,
* @OA\Schema(type="string")
* ),
* @OA\Parameter(
* name="clase",
* in="query",
* required=false,
* @OA\Schema(type="string")
* ),
* @OA\Parameter(
* name="patologia",
* in="query",
* required=false,
* @OA\Schema(type="string")
* ),
* @OA\Parameter(
* name="idPrestacion",
* in="query",
* required=false,
* @OA\Schema(type="string")
* ),
* @OA\Response(
* response=200,
* description="Response",
* @OA\MediaType(
* mediaType="application/json",
* @OA\Schema(
* @OA\Property(property="status", type="integer"),
* @OA\Property(property="errors", type="array", @OA\Items(type="string")),
* @OA\Property(property="content", type="object")
* )
* )
* )
* )
*/
public function obtenerSucursales(Request $request, TurnoService $turnoService)
{
$statusCode = APIResponse::$SUCCESS;
$status = APIResponse::$SUCCESS;
$errors = array();
$result = null;
try {
$data = $request;
$result = $turnoService->getSucursales($data);
} catch (Exception $e) {
$statusCode = APIResponse::$INTERNAL_ERROR;
$status = APIResponse::$INTERNAL_ERROR;
$errors = array($e->getMessage());
$errorInfo = CommonFunctions::getErrorException($e);
$this->logInteractionService->addErrorLog(
LogInteraction::$LIST,
CommonFunctions::getClassMethod(__METHOD__),
$e->getMessage(),
$errorInfo
);
}
return $this->generateJsonResponse($result, $statusCode, $status, $errors);
}
/**
* @Route("/fechas", name="obtener_fechas", methods={"GET"})
* @param Request $request
* @param TurnoService $turnoService
* @return Response
*
* @OA\Get(
* path="/api/v1/turnos/fechas",
* summary="Obtener fechas para un tramite",
* @OA\Parameter(
* name="fechaDesde",
* in="query",
* required=false,
* @OA\Schema(type="string")
* ),
* @OA\Parameter(
* name="sedeId",
* in="query",
* required=false,
* @OA\Schema(type="integer")
* ),
* @OA\Parameter(
* name="idServicio",
* in="query",
* required=true,
* @OA\Schema(type="string")
* ),
* @OA\Response(
* response=200,
* description="Response",
* @OA\MediaType(
* mediaType="application/json",
* @OA\Schema(
* @OA\Property(property="status", type="integer"),
* @OA\Property(property="errors", type="array", @OA\Items(type="string")),
* @OA\Property(property="content", type="object")
* )
* )
* )
* )
*/
public function obtenerFechas(Request $request, TurnoService $turnoService)
{
$statusCode = APIResponse::$SUCCESS;
$status = APIResponse::$SUCCESS;
$errors = array();
$result = null;
try {
$result = $turnoService->getFechas($request);
} catch (Exception $e) {
$statusCode = APIResponse::$INTERNAL_ERROR;
$status = APIResponse::$INTERNAL_ERROR;
$errors = array($e->getMessage());
$errorInfo = CommonFunctions::getErrorException($e);
$this->logInteractionService->addErrorLog(
LogInteraction::$LIST,
CommonFunctions::getClassMethod(__METHOD__),
$e->getMessage(),
$errorInfo
);
}
return $this->generateJsonResponse($result, $statusCode, $status, $errors);
}
/**
* @Route("/horas", name="obtener_horas", methods={"GET"})
* @param Request $request
* @param TurnoService $turnoService
* @return Response
*
* @OA\Get(
* path="/api/v1/turnos/horas",
* summary="Obtener horas para una fecha determinada",
* @OA\Parameter(
* name="fechaDesde",
* in="query",
* required=false,
* @OA\Schema(type="string")
* ),
* @OA\Parameter(
* name="sedeId",
* in="query",
* required=false,
* @OA\Schema(type="integer")
* ),
* @OA\Parameter(
* name="idServicio",
* in="query",
* required=true,
* @OA\Schema(type="string")
* ),
* @OA\Response(
* response=200,
* description="Response",
* @OA\MediaType(
* mediaType="application/json",
* @OA\Schema(
* @OA\Property(property="status", type="integer"),
* @OA\Property(property="errors", type="array", @OA\Items(type="string")),
* @OA\Property(property="content", type="object")
* )
* )
* )
* )
*/
public function obtenerHoras(Request $request, TurnoService $turnoService)
{
$statusCode = APIResponse::$SUCCESS;
$status = APIResponse::$SUCCESS;
$errors = array();
$result = null;
try {
$data = $request;
$result = $turnoService->getHoras($data);
} catch (Exception $e) {
$statusCode = APIResponse::$INTERNAL_ERROR;
$status = APIResponse::$INTERNAL_ERROR;
$errors = array($e->getMessage());
$errorInfo = CommonFunctions::getErrorException($e);
$this->logInteractionService->addErrorLog(
LogInteraction::$LIST,
CommonFunctions::getClassMethod(__METHOD__),
$e->getMessage(),
$errorInfo
);
}
return $this->generateJsonResponse($result, $statusCode, $status, $errors);
}
/**
* @Route("/fechasProxima", name="obtener_fechas_proxima", methods={"GET"})
* @param Request $request
* @param TurnoService $turnoService
* @return Response
*
* @OA\Get(
* path="/api/v1/turnos/fechasProxima",
* summary="Obtener fechas para un tramite",
* @OA\Parameter(
* name="fechaDesde",
* in="query",
* required=false,
* @OA\Schema(type="string")
* ),
* @OA\Parameter(
* name="lat",
* in="query",
* required=false,
* @OA\Schema(type="integer")
* ),
* @OA\Parameter(
* name="lng",
* in="query",
* required=false,
* @OA\Schema(type="integer")
* ),
* @OA\Parameter(
* name="idServicio",
* in="query",
* required=true,
* @OA\Schema(type="string")
* ),
* @OA\Response(
* response=200,
* description="Response",
* @OA\MediaType(
* mediaType="application/json",
* @OA\Schema(
* @OA\Property(property="status", type="integer"),
* @OA\Property(property="errors", type="array", @OA\Items(type="string")),
* @OA\Property(property="content", type="object")
* )
* )
* )
* )
*/
public function obtenerFechasProxima(Request $request, TurnoService $turnoService)
{
$statusCode = APIResponse::$SUCCESS;
$status = APIResponse::$SUCCESS;
$errors = array();
$result = null;
try {
$result = $turnoService->getFechasProxima($request);
} catch (Exception $e) {
$statusCode = APIResponse::$INTERNAL_ERROR;
$status = APIResponse::$INTERNAL_ERROR;
$errors = array($e->getMessage());
$errorInfo = CommonFunctions::getErrorException($e);
$this->logInteractionService->addErrorLog(
LogInteraction::$LIST,
CommonFunctions::getClassMethod(__METHOD__),
$e->getMessage(),
$errorInfo
);
}
return $this->generateJsonResponse($result, $statusCode, $status, $errors);
}
/**
* @Route("/bloquear", name="bloquear_Turno", methods={"POST"})
* @param Request $request
* @param TurnoService $turnoService
* @return Response
*
* @OA\Post (
* path="/api/v1/turnos/bloquear",
* summary="Bloquea Turno",
* @OA\RequestBody(
* @OA\MediaType(
* mediaType="application/json",
* @OA\Schema(
* @OA\Property(property="fecha", type="string"),
* @OA\Property(property="sedeId", type="string"),
* @OA\Property(property="idServicio", type="string"),
* )
* )
* ),
* @OA\Response(
* response=200,
* description="Response",
* @OA\MediaType(
* mediaType="application/json",
* @OA\Schema(
* @OA\Property(property="status", type="integer"),
* @OA\Property(property="errors", type="array", @OA\Items(type="string")),
* @OA\Property(property="content", type="object")
* )
* )
* )
* )
*/
public function bloquearTurno(Request $request, TurnoService $turnoService)
{
$statusCode = APIResponse::$SUCCESS;
$status = APIResponse::$SUCCESS;
$errors = array();
$result = null;
try {
$data = $request;
$result = $turnoService->bloquearTurno($data);
} catch (Exception $e) {
$statusCode = APIResponse::$INTERNAL_ERROR;
$status = APIResponse::$INTERNAL_ERROR;
$errors = array($e->getMessage());
$errorInfo = CommonFunctions::getErrorException($e);
$this->logInteractionService->addErrorLog(
LogInteraction::$LIST,
CommonFunctions::getClassMethod(__METHOD__),
$e->getMessage(),
$errorInfo
);
}
return $this->generateJsonResponse($result, $statusCode, $status, $errors);
}
/**
* @Route("/reservar", name="reservar_turno", methods={"POST"})
* @param Request $request
* @param TurnoService $turnoService
* @return Response
*
* @OA\Post (
* path="/api/v1/turnos/reservar",
* summary="Hace la reserva de un turno",
* @OA\RequestBody(
* @OA\MediaType(
* mediaType="application/json",
* @OA\Schema(
* @OA\Property(property="nombre", type="string"),
* @OA\Property(property="apellido", type="string"),
* @OA\Property(property="email", type="string"),
* @OA\Property(property="confirmacionEmail", type="boolean"),
* @OA\Property(property="telefono", type="string"),
* @OA\Property(property="genero", type="string"),
* @OA\Property(property="numDoc", type="string"),
* @OA\Property(property="tipoDoc", type="string"),
* @OA\Property(property="fechaHoraTramite", type="string"),
* @OA\Property(property="idSede", type="string"),
* @OA\Property(property="fechaNacimiento", type="string"),
* @OA\Property(property="tokenBloqueo", type="string"),
* @OA\Property(property="uuid_paso", type="string"),
* @OA\Property(property="idServicio", type="string"),
* )
* )
* ),
* @OA\Response(
* response=200,
* description="Response",
* @OA\MediaType(
* mediaType="application/json",
* @OA\Schema(
* @OA\Property(property="status", type="integer"),
* @OA\Property(property="errors", type="array", @OA\Items(type="string")),
* @OA\Property(property="content", type="object")
* )
* )
* )
* )
*/
public function crearReserva(Request $request, TurnoService $turnoService){
$statusCode = APIResponse::$SUCCESS;
$status = APIResponse::$SUCCESS;
$errors = array();
$result = null;
try {
$data = CommonFunctions::getValidJson($request->getContent());
$result = $turnoService->reservarTurno($this->getUser(),$data);
} catch (Exception $e) {
$statusCode = APIResponse::$INTERNAL_ERROR;
$status = APIResponse::$INTERNAL_ERROR;
$errors = array($e->getMessage());
$errorInfo = CommonFunctions::getErrorException($e);
$this->logInteractionService->addErrorLog(
LogInteraction::$LIST,
CommonFunctions::getClassMethod(__METHOD__),
$e->getMessage(),
$errorInfo
);
}
return $this->generateJsonResponse($result, $statusCode, $status, $errors);
}
/**
* @Route("/consulta", name="consulta_reserva", methods={"GET"})
* @param Request $request
* @param TurnoService $turnoService
* @return Response
*
* @OA\Get(
* path="/api/v1/turnos/consulta",
* summary="Obtener horas para una fecha determinada",
* @OA\Parameter(
* name="tipoDocumento",
* in="query",
* required=true,
* @OA\Schema(type="string")
* ),
* @OA\Parameter(
* name="numeroDocumento",
* in="query",
* required=true,
* @OA\Schema(type="integer")
* ),
* @OA\Parameter(
* name="genero",
* in="query",
* required=true,
* @OA\Schema(type="string")
* ),
* @OA\Parameter(
* name="idServicio",
* in="query",
* required=false,
* @OA\Schema(type="string")
* ),
* @OA\Parameter(
* name="todos",
* in="query",
* required=false,
* @OA\Schema(type="boolean")
* ),
* @OA\Parameter(
* name="page",
* in="query",
* required=false,
* @OA\Schema(type="integer")
* ),
* @OA\Response(
* response=200,
* description="Response",
* @OA\MediaType(
* mediaType="application/json",
* @OA\Schema(
* @OA\Property(property="status", type="integer"),
* @OA\Property(property="errors", type="array", @OA\Items(type="string")),
* @OA\Property(property="content", type="object")
* )
* )
* )
* )
*/
public function consultaReserva(Request $request, TurnoService $turnoService)
{
$statusCode = APIResponse::$SUCCESS;
$status = APIResponse::$SUCCESS;
$errors = array();
$result = null;
try {
$data = $request;
$result = $turnoService->getReserva($data);
} catch (Exception $e) {
$statusCode = APIResponse::$INTERNAL_ERROR;
$status = APIResponse::$INTERNAL_ERROR;
$errors = array($e->getMessage());
$errorInfo = CommonFunctions::getErrorException($e);
$this->logInteractionService->addErrorLog(
LogInteraction::$LIST,
CommonFunctions::getClassMethod(__METHOD__),
$e->getMessage(),
$errorInfo
);
}
return $this->generateJsonResponse($result, $statusCode, $status, $errors);
}
}