Files
rkm-conectasus-ci-sandbox/api/app/Http/Controllers/Ambulatorio/RelatorioRastreioFeridaController.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

62 lines
2.2 KiB
PHP

<?php
namespace App\Http\Controllers\Ambulatorio;
use App\Http\Controllers\Controller;
use App\Services\Ambulatorio\RelatorioRastreioFeridaService;
use Illuminate\Http\Response;
use App\Utils\MaskUtil;
class RelatorioRastreioFeridaController extends Controller
{
protected $modulo = 'ambulatorio';
protected $funcionalidade = 'relatorio-rastreio-ferida';
public function index()
{
$this->auth(__FUNCTION__);
return response()->json(RelatorioRastreioFeridaService::index(), Response::HTTP_OK);
}
public function create()
{
return response()->json(RelatorioRastreioFeridaService::create(), Response::HTTP_OK);
}
public function list()
{
return response()->json(RelatorioRastreioFeridaService::list(), Response::HTTP_OK);
}
public function autocomplete()
{
return datatables()
->of(RelatorioRastreioFeridaService::autocomplete())
->filterColumn('cadastro_cidadao.data_nascimento', function ($query, $keyword) {
$query->whereRaw("DATE_FORMAT(cadastro_cidadao.data_nascimento, '%d/%m/%Y') like ?", ["%{$keyword}%"]);
})
->filterColumn('cadastro_paciente.prontuario', function ($query, $keyword) {
$query->whereRaw("LPAD(cadastro_paciente.prontuario, 7, 0) like ?", ["%{$keyword}%"]);
})
->filterColumn('cadastro_cidadao.cpf', function ($query, $keyword) {
$query
->whereRaw("cadastro_cidadao.cpf like ?", ["%{$keyword}%"])
->orWhereRaw(
"CONCAT(
SUBSTR(cadastro_cidadao.cpf, 1, 3),
'.',
SUBSTR(cadastro_cidadao.cpf, 4, 3),
'.',
SUBSTR(cadastro_cidadao.cpf, 7, 3),
'-',
SUBSTR(cadastro_cidadao.cpf, 10, 2)
) like ?",
["%{$keyword}%"]
);
})
->editColumn('cns', fn ($paciente) => MaskUtil::getCnsMasked($paciente->cns))
->toJson();
}
}