init commit
All checks were successful
build-api-image / build (push) Successful in 51s

This commit is contained in:
Antonio Lopes dos Santos
2026-08-04 16:52:02 -03:00
commit afec302c3e
11594 changed files with 1636728 additions and 0 deletions

View File

@@ -0,0 +1,59 @@
<?php
namespace App\Http\Controllers\PainelSenha;
use App\Http\Controllers\Controller;
use App\Http\Requests\AvisoRequest;
use App\Services\PainelSenha\AvisoService;
use Illuminate\Http\Response;
class AvisoController extends Controller
{
protected $modulo = 'painel-senha';
protected $funcionalidade = 'aviso';
public function datatable()
{
return AvisoService::datatable();
}
public function create()
{
return response()->json(AvisoService::create(), Response::HTTP_OK);
}
public function store(AvisoRequest $request)
{
[$dados, $status] = AvisoService::store($request);
return response()->json($dados, $status);
}
public function edit($id)
{
return AvisoService::edit($id);
}
public function update($id, AvisoRequest $request)
{
[$dados, $status] = AvisoService::update($id, $request);
return response()->json($dados, $status);
}
public function destroy($id)
{
[$dados, $status] = AvisoService::destroy($id);
return response()->json($dados, $status);
}
public function send()
{
[$dados, $status] = AvisoService::send();
return response()->json($dados, $status);
}
public function mudarStatus($id)
{
[$dados, $status] = AvisoService::mudarStatus($id);
return response()->json($dados, $status);
}
}

View File

@@ -0,0 +1,15 @@
<?php
namespace App\Http\Controllers\PainelSenha;
use App\Http\Controllers\Controller;
use App\Services\PainelSenha\ChamadaService;
use Illuminate\Http\Response;
class ChamadaController extends Controller
{
public function store()
{
return response()->json(ChamadaService::store(), Response::HTTP_CREATED);
}
}

View File

@@ -0,0 +1,127 @@
<?php
namespace App\Http\Controllers\PainelSenha;
use App\Http\Controllers\Controller;
use App\Http\Requests\PainelSenha\EncaminhamentoRequest;
use App\Models\Cadastro\Estabelecimento\CentroCusto;
use App\Models\PainelSenha\Encaminhamento;
use Illuminate\Http\Response;
class EncaminhamentoController extends Controller
{
protected $modulo = 'painel-senha';
protected $funcionalidade = 'encaminhamento';
public function index()
{
$this->auth(__FUNCTION__);
$where = $this->getWhereFromQueryString([
'centro_custo_id_de'
]);
$encaminhamentos = $this->get(Encaminhamento::class)
->where($where)
->whereHas('centroCustoDe', function($query) {
$query->where('infraestrutura_id', $this->getCentroCustoLogado()->infraestrutura_id);
})
->whereHas('centroCustoPara', function($query) {
$query->where('infraestrutura_id', $this->getCentroCustoLogado()->infraestrutura_id);
})
->get()
->sortBy('centroCustoDe.setor.nome')
->values();
return response()->json($encaminhamentos, Response::HTTP_OK);
}
public function create()
{
$this->auth(__FUNCTION__);
return response()->json(
[
'form' => [
'setores' => CentroCusto::where('infraestrutura_id', $this->getCentroCustoLogado()->infraestrutura_id)
->get()
->map(function($query) {
return [
'id' => $query->setor->id,
'centro_custo_id' => $query->id,
'nome' => $query->setor->nome,
];
})->sortBy('nome')->values(),
],
'model' => [
'id' => null,
'centroCustoIdDe' => null,
'centroCustoIdPara' => null,
]
],
Response::HTTP_OK
);
}
public function store(EncaminhamentoRequest $request)
{
$this->auth(__FUNCTION__);
return response()->json(Encaminhamento::create($request->all())->fresh(), Response::HTTP_CREATED);
}
public function show($id)
{
$this->auth(__FUNCTION__);
return response()->json($this->get(Encaminhamento::class, $id), Response::HTTP_OK);
}
public function edit($id)
{
$this->auth(__FUNCTION__);
$encaminhamento = Encaminhamento::findOrFail($id);
return response()->json(
[
'form' => [
'setores' => CentroCusto::where('infraestrutura_id', $this->getCentroCustoLogado()->infraestrutura_id)
->get()
->map(function($query) {
return [
'id' => $query->setor->id,
'centro_custo_id' => $query->id,
'nome' => $query->setor->nome,
];
})->sortBy('nome')->values(),
],
'model' => [
'id' => $encaminhamento->id,
'centro_custo_id_de' => $encaminhamento->centro_custo_id_de,
'centro_custo_id_para' => $encaminhamento->centro_custo_id_para,
],
],
Response::HTTP_OK
);
}
public function update(EncaminhamentoRequest $request, $id)
{
$this->auth(__FUNCTION__);
return response()->json(tap(Encaminhamento::findOrFail($id))->update($request->all()), Response::HTTP_OK);
}
public function destroy($id)
{
$this->auth(__FUNCTION__);
return response()->json(Encaminhamento::findOrFail($id)->delete(), Response::HTTP_NO_CONTENT);
}
private function getCentroCustoLogado()
{
return CentroCusto::findOrFail(auth()->payload()->get('centro_custo_id'));
}
}

View File

@@ -0,0 +1,104 @@
<?php
namespace App\Http\Controllers\PainelSenha;
use App\Http\Controllers\Controller;
use App\Services\PainelSenha\FilaAtendimentoService;
use Illuminate\Http\Response;
class FilaAtendimentoController extends Controller
{
protected $modulo = 'painel-senha';
protected $funcionalidade = 'fila-atendimento';
public function create()
{
//$this->auth(__FUNCTION__);
return response()->json(FilaAtendimentoService::create(), Response::HTTP_OK);
}
public function createEncaminhamento($filaId)
{
return response()->json(FilaAtendimentoService::createEncaminhamento($filaId), Response::HTTP_OK);
}
public function store()
{
//$this->auth(__FUNCTION__);
return response()->json(FilaAtendimentoService::store(), Response::HTTP_CREATED);
}
public function edit($id)
{
$this->auth(__FUNCTION__);
return response()->json(FilaAtendimentoService::edit($id), Response::HTTP_OK);
}
public function update($id)
{
$this->auth(__FUNCTION__);
return response()->json(FilaAtendimentoService::update($id), Response::HTTP_OK);
}
public function list()
{
return response()->json(FilaAtendimentoService::list(), Response::HTTP_OK);
}
public function listEncaminhamento()
{
return response()->json(FilaAtendimentoService::listEncaminhamento(), Response::HTTP_OK);
}
public function autocompletePaciente()
{
return datatables()
->of(FilaAtendimentoService::autocompletePaciente())
->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, 6, 0) like ?", ["%{$keyword}%"]);
})
->toJson();
}
public function answer($id)
{
FilaAtendimentoService::answer($id);
return response()->noContent();
}
public function sendBack($id)
{
FilaAtendimentoService::sendBack($id);
return response()->noContent();
}
public function finalize($id)
{
FilaAtendimentoService::finalize($id);
return response()->noContent();
}
public function evade($id)
{
FilaAtendimentoService::evade($id);
return response()->noContent();
}
public function forward($id)
{
FilaAtendimentoService::forward($id);
return response()->noContent();
}
}

View File

@@ -0,0 +1,54 @@
<?php
namespace App\Http\Controllers\PainelSenha;
use App\Http\Controllers\Controller;
use App\Http\Requests\PainelSenha\FilaRequest;
use App\Services\PainelSenha\FilaService;
use Illuminate\Http\Response;
class FilaController extends Controller
{
protected $modulo = 'painel-senha';
protected $funcionalidade = 'fila';
public function index()
{
return response()->json(FilaService::index()->get(), Response::HTTP_OK);
}
public function create()
{
return response()->json(FilaService::create(), Response::HTTP_OK);
}
public function store(FilaRequest $request)
{
return response()->json(FilaService::store($request->all()), Response::HTTP_CREATED);
}
public function show($id)
{
return response()->json(FilaService::show($id), Response::HTTP_OK);
}
public function destroy($id)
{
return response()->json(FilaService::destroy($id), Response::HTTP_NO_CONTENT);
}
public function answer($id)
{
return response()->json(FilaService::answer($id), Response::HTTP_OK);
}
public function forward(FilaRequest $request, $id)
{
return response()->json(FilaService::forward($request, $id), Response::HTTP_OK);
}
public function evade(FilaRequest $request, $id)
{
return response()->json(FilaService::evade($request, $id), Response::HTTP_OK);
}
}

View File

@@ -0,0 +1,129 @@
<?php
namespace App\Http\Controllers\PainelSenha;
use App\Http\Controllers\Controller;
use App\Http\Requests\PainelSenha\OpcaoChamadaRequest;
use App\Models\Cadastro\Estabelecimento\CentroCusto;
use App\Models\PainelSenha\OpcaoChamada;
use App\Models\PainelSenha\Tela;
use Illuminate\Http\Response;
class OpcaoChamadaController extends Controller
{
protected $modulo = 'painel-senha';
protected $funcionalidade = 'opcao-chamada';
public function index()
{
$this->auth(__FUNCTION__);
$opcoesChamada = $this->get(OpcaoChamada::class)->whereHas('centroCusto', function($query) {
$query->where('infraestrutura_id', $this->getCentroCustoLogado()->infraestrutura_id);
})
->get()
->sortBy('centroCusto.setor.nome')
->values();
return response()->json($opcoesChamada, Response::HTTP_OK);
}
public function create()
{
$this->auth(__FUNCTION__);
return response()->json(
[
'form' => [
'setores' => CentroCusto::where('infraestrutura_id', $this->getCentroCustoLogado()->infraestrutura_id)
->get()
->map(function($query) {
return [
'id' => $query->setor->id,
'centro_custo_id' => $query->id,
'nome' => $query->setor->nome,
];
})->sortBy('nome')->values(),
'telas' => Tela::select(['id', 'nome'])
->where('infraestrutura_id', $this->getCentroCustoLogado()->infraestrutura_id)
->orderBy('nome')
->get(),
],
'model' => [
'id' => null,
'centroCustoId' => null,
'telaId' => null,
]
],
Response::HTTP_OK
);
}
public function store(OpcaoChamadaRequest $request)
{
$this->auth(__FUNCTION__);
return response()->json(OpcaoChamada::create($request->all())->fresh(), Response::HTTP_CREATED);
}
public function show($id)
{
$this->auth(__FUNCTION__);
return response()->json($this->get(OpcaoChamada::class, $id), Response::HTTP_OK);
}
public function edit($id)
{
$this->auth(__FUNCTION__);
$opcaoChamada = OpcaoChamada::findOrFail($id);
return response()->json(
[
'form' => [
'setores' => CentroCusto::where('infraestrutura_id', $this->getCentroCustoLogado()->infraestrutura_id)
->get()
->map(function($query) {
return [
'id' => $query->setor->id,
'centro_custo_id' => $query->id,
'nome' => $query->setor->nome,
];
})->sortBy('nome')->values(),
'telas' => Tela::select(['id', 'nome'])
->where('infraestrutura_id', $this->getCentroCustoLogado()->infraestrutura_id)
->orderBy('nome')
->get(),
],
'model' => [
'id' => $opcaoChamada->id,
'unidade_id' => $opcaoChamada->centroCusto->infraestrutura->unidade->id,
'infraestrutura_id' => $opcaoChamada->centroCusto->infraestrutura->id,
'centro_custo_id' => $opcaoChamada->centro_custo_id,
'tela_id' => $opcaoChamada->tela_id,
],
],
Response::HTTP_OK
);
}
public function update(OpcaoChamadaRequest $request, $id)
{
$this->auth(__FUNCTION__);
return response()->json(tap(OpcaoChamada::findOrFail($id))->update($request->all()), Response::HTTP_OK);
}
public function destroy($id)
{
$this->auth(__FUNCTION__);
return response()->json(OpcaoChamada::findOrFail($id)->delete(), Response::HTTP_NO_CONTENT);
}
private function getCentroCustoLogado()
{
return CentroCusto::findOrFail(auth()->payload()->get('centro_custo_id'));
}
}

View File

@@ -0,0 +1,68 @@
<?php
namespace App\Http\Controllers\PainelSenha;
use App\Http\Controllers\Controller;
use App\Services\PainelSenha\OpcaoEntradaService;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
class OpcaoEntradaController extends Controller
{
protected $modulo = 'painel-senha';
protected $funcionalidade = 'opcao-entrada';
public function index()
{
$this->auth(__FUNCTION__);
return response()->json(OpcaoEntradaService::index(), Response::HTTP_OK);
}
public function create()
{
$this->auth(__FUNCTION__);
return response()->json(OpcaoEntradaService::create(), Response::HTTP_OK);
}
public function store(Request $request)
{
$this->auth(__FUNCTION__);
return response()->json(OpcaoEntradaService::store($request), Response::HTTP_CREATED);
}
public function show($id)
{
$this->auth(__FUNCTION__);
return response()->json(OpcaoEntradaService::show($id), Response::HTTP_OK);
}
public function edit($id)
{
$this->auth(__FUNCTION__);
return response()->json(OpcaoEntradaService::edit($id), Response::HTTP_OK);
}
public function update(Request $request, $id)
{
$this->auth(__FUNCTION__);
return response()->json(OpcaoEntradaService::update($request, $id), Response::HTTP_OK);
}
public function destroy($id)
{
$this->auth(__FUNCTION__);
return response()->json(OpcaoEntradaService::destroy($id), Response::HTTP_NO_CONTENT);
}
public function list()
{
return response()->json(OpcaoEntradaService::list(), Response::HTTP_OK);
}
}

View File

@@ -0,0 +1,91 @@
<?php
namespace App\Http\Controllers\PainelSenha;
use App\Http\Controllers\Controller;
use App\Http\Requests\PainelSenha\ParametrizacaoRequest;
use App\Models\Administracao\Modulo;
use App\Models\Cadastro\Estabelecimento\Infraestrutura;
use App\Models\Cadastro\Estabelecimento\Unidade;
use App\Models\PainelSenha\ParametrizacaoInfraestrutura;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\DB;
class ParametrizacaoController extends Controller
{
protected $modulo = 'painel-senha';
protected $funcionalidade = 'parametrizacao';
public function create()
{
$this->auth(__FUNCTION__);
return response()->json(
[
'form' => [
'unidades' => Unidade::orderBy('nome_fantasia')->get(['id', 'nome_fantasia']),
'infraestruturas' => [],
'modulos' => Modulo::orderBy('nome')->get(['id', 'nome']),
],
'model' => [
'infraestruturas' => ParametrizacaoInfraestrutura::get(['id', 'infraestrutura_id'])
->map(fn ($parametrizacao) => [
'id' => $parametrizacao->infraestrutura_id,
'nome' => $parametrizacao->infraestrutura->nome,
'unidade_id' => $parametrizacao->infraestrutura->unidade->id,
'unidade_nome_fantasia' => $parametrizacao->infraestrutura->unidade->nome_fantasia,
'modulos' => $parametrizacao->modulos->map(fn ($modulo) => [
'id' => $modulo->id,
'nome' => $modulo->nome,
]),
]),
]
],
Response::HTTP_OK
);
}
public function list()
{
$data = null;
switch (request()->listar) {
case 'infraestruturas': {
return Infraestrutura::setEagerLoads([])
->where('unidade_id', request()->unidade_id)
->get(['id', 'nome', 'principal', 'unidade_id'])
->map(fn ($infraestrutura) => [
'id' => $infraestrutura->id,
'nome' => $infraestrutura->nome,
])
->sortBy('nome')
->values();
}
}
return response()->json($data, Response::HTTP_OK);
}
public function store(ParametrizacaoRequest $request)
{
$this->auth(__FUNCTION__);
DB::transaction(function () use ($request) {
ParametrizacaoInfraestrutura::whereNotIn('id', collect($request->infraestruturas)->pluck('id'))->delete();
collect($request->infraestruturas)->each(function ($infraestrutura) {
$parametrizacao = ParametrizacaoInfraestrutura::updateOrCreate([
'infraestrutura_id' => $infraestrutura['id']
]);
$parametrizacao->modulos()->sync($infraestrutura['modulos']);
});
});
return response()->json(null, Response::HTTP_CREATED);
}
}

View File

@@ -0,0 +1,63 @@
<?php
namespace App\Http\Controllers\PainelSenha;
use App\Http\Controllers\Controller;
use App\Services\PainelSenha\PrioridadeService;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
class PrioridadeController extends Controller
{
protected $modulo = 'painel-senha';
protected $funcionalidade = 'prioridade';
public function index()
{
$this->auth(__FUNCTION__);
return response()->json(PrioridadeService::index(), Response::HTTP_OK);
}
public function create()
{
$this->auth(__FUNCTION__);
return response()->json(PrioridadeService::create(), Response::HTTP_OK);
}
public function store(Request $request)
{
$this->auth(__FUNCTION__);
return response()->json(PrioridadeService::store($request), Response::HTTP_CREATED);
}
public function show($id)
{
$this->auth(__FUNCTION__);
return response()->json(PrioridadeService::show($id), Response::HTTP_OK);
}
public function edit($id)
{
$this->auth(__FUNCTION__);
return response()->json(PrioridadeService::edit($id), Response::HTTP_OK);
}
public function update(Request $request, $id)
{
$this->auth(__FUNCTION__);
return response()->json(PrioridadeService::update($request, $id), Response::HTTP_OK);
}
public function destroy($id)
{
$this->auth(__FUNCTION__);
return response()->json(PrioridadeService::destroy($id), Response::HTTP_NO_CONTENT);
}
}

View File

@@ -0,0 +1,142 @@
<?php
namespace App\Http\Controllers\PainelSenha;
use App\Http\Controllers\Controller;
use App\Http\Requests\PainelSenha\TelaRequest;
use App\Models\PainelSenha\Chamada;
use App\Models\PainelSenha\ParametrizacaoInfraestrutura;
use App\Models\PainelSenha\Tela;
use Illuminate\Http\Response;
class TelaController extends Controller
{
protected $modulo = 'painel-senha';
protected $funcionalidade = 'tela';
public function index()
{
$this->auth(__FUNCTION__);
$telas = $this->get(Tela::class)
->where('infraestrutura_id', $this->getCurrentCentroCusto()->infraestrutura_id)
->get()
->sortBy('nome')
->values();
$telas->each(function ($tela) {
$parametrizacao = ParametrizacaoInfraestrutura::where('infraestrutura_id', $tela->infraestrutura_id)->first();
$tela->modulos = is_null($parametrizacao)
? []
: $parametrizacao->modulos
->map(fn ($modulo) => [
'id' => $modulo->id,
'nome' => $modulo->nome,
]);
});
return response()->json($telas, Response::HTTP_OK);
}
public function create()
{
$this->auth(__FUNCTION__);
return response()->json(
[
'model' => [
'id' => null,
'nome' => null,
],
],
Response::HTTP_OK
);
}
public function store(TelaRequest $request)
{
$this->auth(__FUNCTION__);
return response()->json(Tela::create($request->all())->fresh(), Response::HTTP_CREATED);
}
public function show($id)
{
$this->auth(__FUNCTION__);
return response()->json($this->get(Tela::class, $id), Response::HTTP_OK);
}
public function edit($id)
{
$this->auth(__FUNCTION__);
$tela = Tela::findOrFail($id);
return response()->json(
[
'model' => [
'id' => $tela->id,
'nome' => $tela->nome,
],
],
Response::HTTP_OK
);
}
public function update(TelaRequest $request, $id)
{
$this->auth(__FUNCTION__);
return response()->json(tap(Tela::findOrFail($id))->update($request->all()), Response::HTTP_OK);
}
public function destroy($id)
{
$this->auth(__FUNCTION__);
return response()->json(Tela::findOrFail($id)->delete(), Response::HTTP_NO_CONTENT);
}
public function list()
{
switch (request()->listar) {
case 'chamadas':
return response()->json(['model' => $this->getChamadas()], Response::HTTP_OK);
break;
}
}
private function getChamadas()
{
return Chamada::where('tela_id', request()->tela_id)
->when(request()->modulo_ids ?? null, fn ($q, $moduloIds) => $q
->whereHas('fila', fn ($q) => $q
->whereHas('opcaoEntrada', fn ($q) => $q
->whereIn('modulo_id', $moduloIds)
)
)
)
->orderBy('created_at', 'desc')
->take(4)
->get()
->map(function($query) {
return [
'id' => $query->id,
'paciente' => [
'cidadao' => [
'preferencia_nome_id' => $query->paciente->cidadao->preferencia_nome_id ?? null,
'nome' => $query->paciente->cidadao->nome ?? null,
'nome_social' => $query->paciente->cidadao->nome_social ?? null,
],
],
'sala' => [
'nome' => $query->sala->nome ?? null,
],
'senha' => $query->fila->senha ?? null,
];
});
}
}

View File

@@ -0,0 +1,87 @@
<?php
namespace App\Http\Controllers\PainelSenha;
use Illuminate\Http\Response;
use App\Http\Controllers\Controller;
use App\Models\PainelSenha\TempoEspera;
use App\Models\Cadastro\Estabelecimento\CentroCusto;
use App\Http\Requests\PainelSenha\TempoEsperaRequest;
class TempoEsperaController extends Controller
{
protected $modulo = 'painel-senha';
protected $funcionalidade = 'tempo-espera';
public function index()
{
$this->auth(__FUNCTION__);
$temposEspera = $this->get(TempoEspera::class)
->where('infraestrutura_id', $this->getCentroCustoLogado()->infraestrutura_id)
->get();
return response()->json($temposEspera, Response::HTTP_OK);
}
public function create()
{
$this->auth(__FUNCTION__);
return response()->json(
[
'model' => [
'id' => null,
'cor' => null,
'tempo' => null,
],
],
Response::HTTP_OK
);
}
public function store(TempoEsperaRequest $request)
{
$this->auth(__FUNCTION__);
return response()->json(TempoEspera::create($request->all())->fresh(), Response::HTTP_CREATED);
}
public function show($id)
{
$this->auth(__FUNCTION__);
return response()->json($this->get(TempoEspera::class, $id), Response::HTTP_OK);
}
public function edit($id)
{
$this->auth(__FUNCTION__);
return response()->json(
[
'model' => TempoEspera::findOrFail($id),
],
Response::HTTP_OK
);
}
public function update(TempoEsperaRequest $request, $id)
{
$this->auth(__FUNCTION__);
return response()->json(tap(TempoEspera::findOrFail($id))->update($request->all()), Response::HTTP_OK);
}
public function destroy($id)
{
$this->auth(__FUNCTION__);
return response()->json(TempoEspera::findOrFail($id)->delete(), Response::HTTP_NO_CONTENT);
}
private function getCentroCustoLogado()
{
return CentroCusto::findOrFail(auth()->payload()->get('centro_custo_id'));
}
}