This commit is contained in:
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\AtencaoBasica\FichaComplementar;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\AtencaoBasica\FichaComplementar\FichaComplementarService;
|
||||
use Exception;
|
||||
use Illuminate\Http\{JsonResponse, Request, Response};
|
||||
|
||||
class FichaComplementarController extends Controller
|
||||
{
|
||||
protected $modulo = 'atencao-basica';
|
||||
|
||||
protected $funcionalidade = 'ficha-complementar';
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function historico(Request $request)
|
||||
{
|
||||
$pacienteId = filter_var($request->id, FILTER_VALIDATE_INT);
|
||||
|
||||
if (!$pacienteId) {
|
||||
return response()->json([], Response::HTTP_BAD_REQUEST);
|
||||
}
|
||||
|
||||
return response()->json(FichaComplementarService::historico($pacienteId), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function create(Request $request)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
$pacienteId = filter_var($request->id, FILTER_VALIDATE_INT);
|
||||
|
||||
if (!$pacienteId) {
|
||||
return response()->json([], Response::HTTP_BAD_REQUEST);
|
||||
}
|
||||
|
||||
return response()->json(FichaComplementarService::create($pacienteId), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json(FichaComplementarService::store($request), Response::HTTP_CREATED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function edit(int $id)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
$fichaComplementarId = filter_var($id, FILTER_VALIDATE_INT);
|
||||
|
||||
if (!$fichaComplementarId) {
|
||||
return response()->json([], Response::HTTP_BAD_REQUEST);
|
||||
}
|
||||
|
||||
return response()->json(FichaComplementarService::edit($fichaComplementarId), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param int $id
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function update(Request $request, int $id)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
$fichaComplementarId = filter_var($id, FILTER_VALIDATE_INT);
|
||||
|
||||
if (!$fichaComplementarId) {
|
||||
return response()->json([], Response::HTTP_BAD_REQUEST);
|
||||
}
|
||||
|
||||
return response()->json(
|
||||
FichaComplementarService::update($fichaComplementarId, $request),
|
||||
Response::HTTP_NO_CONTENT
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function destroy(int $id)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
$fichaComplementarId = filter_var($id, FILTER_VALIDATE_INT);
|
||||
|
||||
if (!$fichaComplementarId) {
|
||||
return response()->json([], Response::HTTP_BAD_REQUEST);
|
||||
}
|
||||
|
||||
return response()->json(FichaComplementarService::destroy($fichaComplementarId), Response::HTTP_NO_CONTENT);
|
||||
}
|
||||
|
||||
public function getUnidades()
|
||||
{
|
||||
return response()->json(FichaComplementarService::getUnidades(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function getInfraestruturas()
|
||||
{
|
||||
return response()->json(FichaComplementarService::getInfraestruturas(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function getEquipes()
|
||||
{
|
||||
return response()->json(FichaComplementarService::getEquipes(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function getOcupacoes()
|
||||
{
|
||||
return response()->json(FichaComplementarService::getOcupacoes(), Response::HTTP_OK);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user