Files
rkm-conectasus-ci-sandbox/api/app/Http/Controllers/AtencaoBasica/RelatorioCuidadoPessoaIdosaController.php
Antonio Lopes dos Santos afec302c3e
All checks were successful
build-api-image / build (push) Successful in 51s
init commit
2026-08-04 16:52:02 -03:00

56 lines
1.8 KiB
PHP

<?php
namespace App\Http\Controllers\AtencaoBasica;
use App\Http\Controllers\Controller;
use App\Services\AtencaoBasica\RelatorioCuidadoPessoaIdosaService;
use Illuminate\Http\Response;
class RelatorioCuidadoPessoaIdosaController extends Controller
{
protected $modulo = 'atencao-basica';
protected $funcionalidade = 'relatorio-cuidado-pessoa-idosa';
public function index()
{
$this->auth(__FUNCTION__);
return response()->json(RelatorioCuidadoPessoaIdosaService::index(), Response::HTTP_OK);
}
public function create()
{
return response()->json(RelatorioCuidadoPessoaIdosaService::create(), Response::HTTP_OK);
}
public function list()
{
return response()->json(RelatorioCuidadoPessoaIdosaService::list(), Response::HTTP_OK);
}
public function autocompletePaciente()
{
return datatables()
->of(RelatorioCuidadoPessoaIdosaService::autocompletePaciente())
->filterColumn('paciente.prontuario', function ($query, $keyword) {
$query->whereRaw("LPAD(paciente.prontuario, 7, 0) like ?", ["%{$keyword}%"]);
})
->filterColumn('cidadao.cpf', function ($query, $keyword) {
$query->whereRaw("cidadao.cpf like ?", ["%{$keyword}%"])
->orWhereRaw(
"CONCAT(
SUBSTR(cidadao.cpf, 1, 3),
'.',
SUBSTR(cidadao.cpf, 4, 3),
'.',
SUBSTR(cidadao.cpf, 7, 3),
'-',
SUBSTR(cidadao.cpf, 10, 2)
) like ?",
["%{$keyword}%"]
);
})
->toJson();
}
}