src/Controller/API/TurnoController.php line 501

Open in your IDE?
  1. <?php
  2. namespace App\Controller\API;
  3. use App\Controller\BaseController;
  4. use App\Entity\Log\LogInteraction;
  5. use App\Services\API\TurnoService;
  6. use App\Utils\APIResponse;
  7. use App\Utils\CommonFunctions;
  8. use Exception;
  9. use OpenApi\Annotations as OA;
  10. use Symfony\Component\HttpFoundation\Request;
  11. use Symfony\Component\HttpFoundation\Response;
  12. use Symfony\Component\Routing\Annotation\Route;
  13. /**
  14.  * @Route("/turnos")
  15.  */
  16. class TurnoController extends BaseController
  17. {
  18.     /**
  19.      * @Route("/sucursales", name="obtener_sucursales", methods={"GET"})
  20.      * @param Request $request
  21.      * @param TurnoService $turnoService
  22.      * @return Response
  23.      *
  24.      * @OA\GET(
  25.      *     path="/api/v1/turnos/sucursales",
  26.      *     summary="Obtener sucursales",
  27.      *     @OA\Parameter(
  28.      *         name="fechaDesde",
  29.      *         in="query",
  30.      *         required=false,
  31.      *         @OA\Schema(type="string")
  32.      *     ),
  33.      *     @OA\Parameter(
  34.      *         name="lat",
  35.      *         in="query",
  36.      *         required=false,
  37.      *         @OA\Schema(type="integer")
  38.      *     ),
  39.      *     @OA\Parameter(
  40.      *         name="lng",
  41.      *         in="query",
  42.      *         required=false,
  43.      *         @OA\Schema(type="integer")
  44.      *     ),
  45.      *     @OA\Parameter(
  46.      *         name="idServicio",
  47.      *         in="query",
  48.      *         required=true,
  49.      *         @OA\Schema(type="string")
  50.      *     ),
  51.      *     @OA\Parameter(
  52.      *         name="clase",
  53.      *         in="query",
  54.      *         required=false,
  55.      *         @OA\Schema(type="string")
  56.      *     ),
  57.      *     @OA\Parameter(
  58.      *         name="patologia",
  59.      *         in="query",
  60.      *         required=false,
  61.      *         @OA\Schema(type="string")
  62.      *     ),
  63.      *     @OA\Parameter(
  64.      *         name="idPrestacion",
  65.      *         in="query",
  66.      *         required=false,
  67.      *         @OA\Schema(type="string")
  68.      *     ),
  69.      *     @OA\Response(
  70.      *         response=200,
  71.      *         description="Response",
  72.      *         @OA\MediaType(
  73.      *             mediaType="application/json",
  74.      *             @OA\Schema(
  75.      *                 @OA\Property(property="status", type="integer"),
  76.      *                 @OA\Property(property="errors", type="array", @OA\Items(type="string")),
  77.      *                 @OA\Property(property="content", type="object")
  78.      *            )
  79.      *        )
  80.      *    )
  81.      * )
  82.      */
  83.     public function obtenerSucursales(Request $requestTurnoService $turnoService)
  84.     {
  85.         $statusCode APIResponse::$SUCCESS;
  86.         $status APIResponse::$SUCCESS;
  87.         $errors = array();
  88.         $result null;
  89.         try {
  90.             $data $request;
  91.             $result $turnoService->getSucursales($data);
  92.         } catch (Exception $e) {
  93.             $statusCode APIResponse::$INTERNAL_ERROR;
  94.             $status APIResponse::$INTERNAL_ERROR;
  95.             $errors = array($e->getMessage());
  96.             $errorInfo CommonFunctions::getErrorException($e);
  97.             $this->logInteractionService->addErrorLog(
  98.                 LogInteraction::$LIST,
  99.                 CommonFunctions::getClassMethod(__METHOD__),
  100.                 $e->getMessage(),
  101.                 $errorInfo
  102.             );
  103.         }
  104.         return $this->generateJsonResponse($result$statusCode$status$errors);
  105.     }
  106.     /**
  107.      * @Route("/fechas", name="obtener_fechas", methods={"GET"})
  108.      * @param Request $request
  109.      * @param TurnoService $turnoService
  110.      * @return Response
  111.      *
  112.      * @OA\Get(
  113.      *     path="/api/v1/turnos/fechas",
  114.      *     summary="Obtener fechas para un tramite",
  115.      *     @OA\Parameter(
  116.      *         name="fechaDesde",
  117.      *         in="query",
  118.      *         required=false,
  119.      *         @OA\Schema(type="string")
  120.      *     ),
  121.      *     @OA\Parameter(
  122.      *         name="sedeId",
  123.      *         in="query",
  124.      *         required=false,
  125.      *         @OA\Schema(type="integer")
  126.      *     ),
  127.      *     @OA\Parameter(
  128.      *         name="idServicio",
  129.      *         in="query",
  130.      *         required=true,
  131.      *         @OA\Schema(type="string")
  132.      *     ),
  133.      *     @OA\Response(
  134.      *         response=200,
  135.      *         description="Response",
  136.      *         @OA\MediaType(
  137.      *             mediaType="application/json",
  138.      *             @OA\Schema(
  139.      *                 @OA\Property(property="status", type="integer"),
  140.      *                 @OA\Property(property="errors", type="array", @OA\Items(type="string")),
  141.      *                 @OA\Property(property="content", type="object")
  142.      *            )
  143.      *        )
  144.      *    )
  145.      * )
  146.      */
  147.     public function obtenerFechas(Request $requestTurnoService $turnoService)
  148.     {
  149.         $statusCode APIResponse::$SUCCESS;
  150.         $status APIResponse::$SUCCESS;
  151.         $errors = array();
  152.         $result null;
  153.         try {
  154.             $result $turnoService->getFechas($request);
  155.         } catch (Exception $e) {
  156.             $statusCode APIResponse::$INTERNAL_ERROR;
  157.             $status APIResponse::$INTERNAL_ERROR;
  158.             $errors = array($e->getMessage());
  159.             $errorInfo CommonFunctions::getErrorException($e);
  160.             $this->logInteractionService->addErrorLog(
  161.                 LogInteraction::$LIST,
  162.                 CommonFunctions::getClassMethod(__METHOD__),
  163.                 $e->getMessage(),
  164.                 $errorInfo
  165.             );
  166.         }
  167.         return $this->generateJsonResponse($result$statusCode$status$errors);
  168.     }
  169.     /**
  170.      * @Route("/horas", name="obtener_horas", methods={"GET"})
  171.      * @param Request $request
  172.      * @param TurnoService $turnoService
  173.      * @return Response
  174.      *
  175.      * @OA\Get(
  176.      *     path="/api/v1/turnos/horas",
  177.      *     summary="Obtener horas para una fecha determinada",
  178.      *      @OA\Parameter(
  179.      *         name="fechaDesde",
  180.      *         in="query",
  181.      *         required=false,
  182.      *         @OA\Schema(type="string")
  183.      *     ),
  184.      *     @OA\Parameter(
  185.      *         name="sedeId",
  186.      *         in="query",
  187.      *         required=false,
  188.      *         @OA\Schema(type="integer")
  189.      *     ),
  190.      *     @OA\Parameter(
  191.      *         name="idServicio",
  192.      *         in="query",
  193.      *         required=true,
  194.      *         @OA\Schema(type="string")
  195.      *     ),
  196.      *     @OA\Response(
  197.      *         response=200,
  198.      *         description="Response",
  199.      *         @OA\MediaType(
  200.      *             mediaType="application/json",
  201.      *             @OA\Schema(
  202.      *                 @OA\Property(property="status", type="integer"),
  203.      *                 @OA\Property(property="errors", type="array", @OA\Items(type="string")),
  204.      *                 @OA\Property(property="content", type="object")
  205.      *            )
  206.      *        )
  207.      *    )
  208.      * )
  209.      */
  210.     public function obtenerHoras(Request $requestTurnoService $turnoService)
  211.     {
  212.         $statusCode APIResponse::$SUCCESS;
  213.         $status APIResponse::$SUCCESS;
  214.         $errors = array();
  215.         $result null;
  216.         try {
  217.             $data $request;
  218.             $result $turnoService->getHoras($data);
  219.         } catch (Exception $e) {
  220.             $statusCode APIResponse::$INTERNAL_ERROR;
  221.             $status APIResponse::$INTERNAL_ERROR;
  222.             $errors = array($e->getMessage());
  223.             $errorInfo CommonFunctions::getErrorException($e);
  224.             $this->logInteractionService->addErrorLog(
  225.                 LogInteraction::$LIST,
  226.                 CommonFunctions::getClassMethod(__METHOD__),
  227.                 $e->getMessage(),
  228.                 $errorInfo
  229.             );
  230.         }
  231.         return $this->generateJsonResponse($result$statusCode$status$errors);
  232.     }
  233.     /**
  234.      * @Route("/fechasProxima", name="obtener_fechas_proxima", methods={"GET"})
  235.      * @param Request $request
  236.      * @param TurnoService $turnoService
  237.      * @return Response
  238.      *
  239.      * @OA\Get(
  240.      *     path="/api/v1/turnos/fechasProxima",
  241.      *     summary="Obtener fechas para un tramite",
  242.      *     @OA\Parameter(
  243.      *         name="fechaDesde",
  244.      *         in="query",
  245.      *         required=false,
  246.      *         @OA\Schema(type="string")
  247.      *     ),
  248.      *     @OA\Parameter(
  249.      *         name="lat",
  250.      *         in="query",
  251.      *         required=false,
  252.      *         @OA\Schema(type="integer")
  253.      *     ),
  254.      *     @OA\Parameter(
  255.      *         name="lng",
  256.      *         in="query",
  257.      *         required=false,
  258.      *         @OA\Schema(type="integer")
  259.      *     ),
  260.      *     @OA\Parameter(
  261.      *         name="idServicio",
  262.      *         in="query",
  263.      *         required=true,
  264.      *         @OA\Schema(type="string")
  265.      *     ),
  266.      *     @OA\Response(
  267.      *         response=200,
  268.      *         description="Response",
  269.      *         @OA\MediaType(
  270.      *             mediaType="application/json",
  271.      *             @OA\Schema(
  272.      *                 @OA\Property(property="status", type="integer"),
  273.      *                 @OA\Property(property="errors", type="array", @OA\Items(type="string")),
  274.      *                 @OA\Property(property="content", type="object")
  275.      *            )
  276.      *        )
  277.      *    )
  278.      * )
  279.      */
  280.     public function obtenerFechasProxima(Request $requestTurnoService $turnoService)
  281.     {
  282.         $statusCode APIResponse::$SUCCESS;
  283.         $status APIResponse::$SUCCESS;
  284.         $errors = array();
  285.         $result null;
  286.         try {
  287.             $result $turnoService->getFechasProxima($request);
  288.         } catch (Exception $e) {
  289.             $statusCode APIResponse::$INTERNAL_ERROR;
  290.             $status APIResponse::$INTERNAL_ERROR;
  291.             $errors = array($e->getMessage());
  292.             $errorInfo CommonFunctions::getErrorException($e);
  293.             $this->logInteractionService->addErrorLog(
  294.                 LogInteraction::$LIST,
  295.                 CommonFunctions::getClassMethod(__METHOD__),
  296.                 $e->getMessage(),
  297.                 $errorInfo
  298.             );
  299.         }
  300.         return $this->generateJsonResponse($result$statusCode$status$errors);
  301.     }
  302.     /**
  303.      * @Route("/bloquear", name="bloquear_Turno", methods={"POST"})
  304.      * @param Request $request
  305.      * @param TurnoService $turnoService
  306.      * @return Response
  307.      *
  308.      * @OA\Post (
  309.      *     path="/api/v1/turnos/bloquear",
  310.      *     summary="Bloquea Turno",
  311.      *     @OA\RequestBody(
  312.      *         @OA\MediaType(
  313.      *             mediaType="application/json",
  314.      *             @OA\Schema(
  315.      *                 @OA\Property(property="fecha", type="string"),
  316.      *                 @OA\Property(property="sedeId", type="string"),
  317.      *                 @OA\Property(property="idServicio", type="string"),
  318.      *             )
  319.      *         )
  320.      *     ),
  321.      *     @OA\Response(
  322.      *         response=200,
  323.      *         description="Response",
  324.      *         @OA\MediaType(
  325.      *             mediaType="application/json",
  326.      *             @OA\Schema(
  327.      *                 @OA\Property(property="status", type="integer"),
  328.      *                 @OA\Property(property="errors", type="array", @OA\Items(type="string")),
  329.      *                 @OA\Property(property="content", type="object")
  330.      *            )
  331.      *        )
  332.      *    )
  333.      * )
  334.      */
  335.     public function bloquearTurno(Request $requestTurnoService $turnoService)
  336.     {
  337.         $statusCode APIResponse::$SUCCESS;
  338.         $status APIResponse::$SUCCESS;
  339.         $errors = array();
  340.         $result null;
  341.         try {
  342.             $data $request;
  343.             $result $turnoService->bloquearTurno($data);
  344.         } catch (Exception $e) {
  345.             $statusCode APIResponse::$INTERNAL_ERROR;
  346.             $status APIResponse::$INTERNAL_ERROR;
  347.             $errors = array($e->getMessage());
  348.             $errorInfo CommonFunctions::getErrorException($e);
  349.             $this->logInteractionService->addErrorLog(
  350.                 LogInteraction::$LIST,
  351.                 CommonFunctions::getClassMethod(__METHOD__),
  352.                 $e->getMessage(),
  353.                 $errorInfo
  354.             );
  355.         }
  356.         return $this->generateJsonResponse($result$statusCode$status$errors);
  357.     }
  358.     /**
  359.      * @Route("/reservar", name="reservar_turno", methods={"POST"})
  360.      * @param Request $request
  361.      * @param TurnoService $turnoService
  362.      * @return Response
  363.      *
  364.      * @OA\Post (
  365.      *     path="/api/v1/turnos/reservar",
  366.      *     summary="Hace la reserva de un turno",
  367.      *     @OA\RequestBody(
  368.      *         @OA\MediaType(
  369.      *             mediaType="application/json",
  370.      *             @OA\Schema(
  371.      *                 @OA\Property(property="nombre", type="string"),
  372.      *                 @OA\Property(property="apellido", type="string"),
  373.      *                 @OA\Property(property="email", type="string"),
  374.      *                 @OA\Property(property="confirmacionEmail", type="boolean"),
  375.      *                 @OA\Property(property="telefono", type="string"),
  376.      *                 @OA\Property(property="genero", type="string"),
  377.      *                 @OA\Property(property="numDoc", type="string"),
  378.      *                 @OA\Property(property="tipoDoc", type="string"),
  379.      *                 @OA\Property(property="fechaHoraTramite", type="string"),
  380.      *                 @OA\Property(property="idSede", type="string"),
  381.      *                 @OA\Property(property="fechaNacimiento", type="string"),
  382.      *                 @OA\Property(property="tokenBloqueo", type="string"),
  383.      *                 @OA\Property(property="uuid_paso", type="string"),
  384.      *                 @OA\Property(property="idServicio", type="string"),
  385.      *             )
  386.      *         )
  387.      *     ),
  388.      *     @OA\Response(
  389.      *         response=200,
  390.      *         description="Response",
  391.      *         @OA\MediaType(
  392.      *             mediaType="application/json",
  393.      *             @OA\Schema(
  394.      *                 @OA\Property(property="status", type="integer"),
  395.      *                 @OA\Property(property="errors", type="array", @OA\Items(type="string")),
  396.      *                 @OA\Property(property="content", type="object")
  397.      *            )
  398.      *        )
  399.      *    )
  400.      * )
  401.      */
  402.     public function crearReserva(Request $requestTurnoService $turnoService){
  403.         $statusCode APIResponse::$SUCCESS;
  404.         $status APIResponse::$SUCCESS;
  405.         $errors = array();
  406.         $result null;
  407.         try {
  408.             $data CommonFunctions::getValidJson($request->getContent());
  409.             $result $turnoService->reservarTurno($this->getUser(),$data);
  410.         } catch (Exception $e) {
  411.             $statusCode APIResponse::$INTERNAL_ERROR;
  412.             $status APIResponse::$INTERNAL_ERROR;
  413.             $errors = array($e->getMessage());
  414.             $errorInfo CommonFunctions::getErrorException($e);
  415.             $this->logInteractionService->addErrorLog(
  416.                 LogInteraction::$LIST,
  417.                 CommonFunctions::getClassMethod(__METHOD__),
  418.                 $e->getMessage(),
  419.                 $errorInfo
  420.             );
  421.         }
  422.         return $this->generateJsonResponse($result$statusCode$status$errors);
  423.     }
  424.     /**
  425.      * @Route("/consulta", name="consulta_reserva", methods={"GET"})
  426.      * @param Request $request
  427.      * @param TurnoService $turnoService
  428.      * @return Response
  429.      *
  430.      * @OA\Get(
  431.      *     path="/api/v1/turnos/consulta",
  432.      *     summary="Obtener horas para una fecha determinada",
  433.      *      @OA\Parameter(
  434.      *         name="tipoDocumento",
  435.      *         in="query",
  436.      *         required=true,
  437.      *         @OA\Schema(type="string")
  438.      *     ),
  439.      *     @OA\Parameter(
  440.      *         name="numeroDocumento",
  441.      *         in="query",
  442.      *         required=true,
  443.      *         @OA\Schema(type="integer")
  444.      *     ),
  445.      *     @OA\Parameter(
  446.      *         name="genero",
  447.      *         in="query",
  448.      *         required=true,
  449.      *         @OA\Schema(type="string")
  450.      *     ),
  451.      *     @OA\Parameter(
  452.      *         name="idServicio",
  453.      *         in="query",
  454.      *         required=false,
  455.      *         @OA\Schema(type="string")
  456.      *     ),
  457.      *    @OA\Parameter(
  458.      *         name="todos",
  459.      *         in="query",
  460.      *         required=false,
  461.      *         @OA\Schema(type="boolean")
  462.      *     ),
  463.      *    @OA\Parameter(
  464.      *         name="page",
  465.      *         in="query",
  466.      *         required=false,
  467.      *         @OA\Schema(type="integer")
  468.      *     ),
  469.      *     @OA\Response(
  470.      *         response=200,
  471.      *         description="Response",
  472.      *         @OA\MediaType(
  473.      *             mediaType="application/json",
  474.      *             @OA\Schema(
  475.      *                 @OA\Property(property="status", type="integer"),
  476.      *                 @OA\Property(property="errors", type="array", @OA\Items(type="string")),
  477.      *                 @OA\Property(property="content", type="object")
  478.      *            )
  479.      *        )
  480.      *    )
  481.      * )
  482.      */
  483.     public function consultaReserva(Request $requestTurnoService $turnoService)
  484.     {
  485.         $statusCode APIResponse::$SUCCESS;
  486.         $status APIResponse::$SUCCESS;
  487.         $errors = array();
  488.         $result null;
  489.         try {
  490.             $data $request;
  491.             $result $turnoService->getReserva($data);
  492.         } catch (Exception $e) {
  493.             $statusCode APIResponse::$INTERNAL_ERROR;
  494.             $status APIResponse::$INTERNAL_ERROR;
  495.             $errors = array($e->getMessage());
  496.             $errorInfo CommonFunctions::getErrorException($e);
  497.             $this->logInteractionService->addErrorLog(
  498.                 LogInteraction::$LIST,
  499.                 CommonFunctions::getClassMethod(__METHOD__),
  500.                 $e->getMessage(),
  501.                 $errorInfo
  502.             );
  503.         }
  504.         return $this->generateJsonResponse($result$statusCode$status$errors);
  505.     }
  506. }