This commit is contained in:
265
api/app/Http/Controllers/Regulacao/FilaController.php
Normal file
265
api/app/Http/Controllers/Regulacao/FilaController.php
Normal file
@@ -0,0 +1,265 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Regulacao;
|
||||
|
||||
use App\Exceptions\Regulacao\CannotUpdateSolicitacaoException;
|
||||
use App\Exceptions\Regulacao\CannotUpdateSolicitacoesException;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Geral\AgeService;
|
||||
use App\Services\Regulacao\FilaService;
|
||||
use App\Utils\MaskUtil;
|
||||
use Carbon\Carbon;
|
||||
use DateTime;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class FilaController extends Controller
|
||||
{
|
||||
protected $modulo = 'regulacao';
|
||||
protected $funcionalidade = 'fila';
|
||||
|
||||
public function autocompletePaciente()
|
||||
{
|
||||
return datatables()
|
||||
->of(FilaService::autocompletePaciente())
|
||||
->filterColumn('cidadao.data_nascimento', function ($query, $keyword) {
|
||||
|
||||
$query->whereRaw("DATE_FORMAT(cidadao.data_nascimento, '%d/%m/%Y') like ?", ["%{$keyword}%"]);
|
||||
})
|
||||
->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}%"]
|
||||
);
|
||||
})
|
||||
->editColumn('cns', fn ($paciente) => MaskUtil::getCnsMasked($paciente->cns))
|
||||
->toJson();
|
||||
}
|
||||
|
||||
public function autocompleteCid()
|
||||
{
|
||||
return datatables()
|
||||
->of(FilaService::autocompleteCid())
|
||||
->editColumn('codigo', fn ($cid) => MaskUtil::getCidMasked($cid->codigo))
|
||||
->toJson();
|
||||
}
|
||||
|
||||
public function autocompleteCiap()
|
||||
{
|
||||
return datatables()
|
||||
->of(FilaService::autocompleteCiap())
|
||||
->toJson();
|
||||
}
|
||||
|
||||
public function list()
|
||||
{
|
||||
return response()->json(FilaService::list(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function datatable()
|
||||
{
|
||||
return datatables()
|
||||
->of(FilaService::datatable())
|
||||
->addColumn('is_oci_vencida', function ($solicitacao) {
|
||||
|
||||
if (is_null($solicitacao->data_vencimento_oci) || ((bool) $solicitacao->has_alta_oci)) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return Carbon::now() > Carbon::createFromFormat('d/m/Y', $solicitacao->data_vencimento_oci)->endOfDay();
|
||||
})
|
||||
->editColumn('dias_restantes_oci', fn ($s) => is_null($s->dias_restantes_oci) || ((bool) $s->has_alta_oci)
|
||||
? null : ($s->dias_restantes_oci < 0 ? 0 : $s->dias_restantes_oci)
|
||||
)
|
||||
->editColumn('idade', fn ($s) => is_null($s->paciente_data_nascimento)
|
||||
? null : AgeService::getFormattedAge(new DateTime($s->paciente_data_nascimento))
|
||||
)
|
||||
->editColumn('cid_descricao', fn ($s) => MaskUtil::getCidMasked($s->cid_codigo) . " - {$s->cid_nome}")
|
||||
->editColumn('ciap_descricao', fn ($s) => "{$s->ciap_codigo} - {$s->ciap_descricao}")
|
||||
->editColumn('tempo_espera', function ($solicitacao) {
|
||||
|
||||
if ($solicitacao->tempo_espera === 0) {
|
||||
return 'MESMO DIA';
|
||||
}
|
||||
|
||||
$dataSolicitacao = Carbon::createFromFormat('d/m/Y', $solicitacao->data);
|
||||
$dataAtual = Carbon::now();
|
||||
|
||||
$diff = $dataSolicitacao->diff($dataAtual);
|
||||
|
||||
$anos = $diff->y;
|
||||
$meses = $diff->m;
|
||||
$dias = $diff->d;
|
||||
|
||||
$anosText = $anos > 0 ? ($anos > 1 ? "{$anos} anos" : "{$anos} ano") : null;
|
||||
$mesesText = $meses > 0 ? ($meses > 1 ? "{$meses} meses" : "{$meses} mês") : null;
|
||||
$diasText = $dias > 0 ? ($dias > 1 ? "{$dias} dias" : "{$dias} dia") : null;
|
||||
|
||||
return collect([$anosText, $mesesText, $diasText])
|
||||
->filter()
|
||||
->implode(' e ');
|
||||
})
|
||||
->editColumn('allow_update', fn ($s) => (bool) $s->allow_update)
|
||||
->editColumn('allow_update_protocolo_agendamento', fn ($s) => (bool) $s->allow_update_protocolo_agendamento)
|
||||
->editColumn('has_oci', fn ($s) => (bool) $s->has_oci)
|
||||
->editColumn('has_alta_oci', fn ($s) => (bool) $s->has_alta_oci)
|
||||
->editColumn('dentro_validade_inserir_oci', fn ($s) => (bool) $s->dentro_validade_inserir_oci)
|
||||
->editColumn('itens', fn ($s) => explode('#', $s->itens))
|
||||
->editColumn('telefones', fn ($s) => collect(explode('#', $s->telefones))
|
||||
->map(fn ($t) => MaskUtil::getPhoneMasked($t))->join(', '))
|
||||
->orderColumn('cid_descricao', fn ($q, $order) => $q
|
||||
->orderByRaw("CONCAT(cid.codigo, ' - ', cid.nome) {$order}")
|
||||
)
|
||||
->orderColumn('ciap_descricao', fn ($q, $order) => $q
|
||||
->orderByRaw("CONCAT(ciap.codigo, ' - ', ciap.descricao) {$order}")
|
||||
)
|
||||
->orderColumn('data_movimentacao', fn ($q, $order) => $q
|
||||
->orderByRaw("movimentacao.movimentado_em {$order}")
|
||||
)
|
||||
->removeColumn([
|
||||
'cid_codigo',
|
||||
'cid_nome',
|
||||
'ciap_codigo',
|
||||
])
|
||||
->skipTotalRecords()
|
||||
->toJson();
|
||||
}
|
||||
|
||||
public function getTentativasContato()
|
||||
{
|
||||
return response()->json(FilaService::getTentativasContato(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function getImpressoes()
|
||||
{
|
||||
return response()->json(FilaService::getImpressoes(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function editProtocoloAgendamento($solicitacaoId)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json(FilaService::editProtocoloAgendamento($solicitacaoId), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function updateProtocoloAgendamento($solicitacaoId)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json(FilaService::updateProtocoloAgendamento($solicitacaoId), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function editPrioridade($solicitacaoId)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json(FilaService::editPrioridade($solicitacaoId), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function updatePrioridade($solicitacaoId)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json(FilaService::updatePrioridade($solicitacaoId), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function createTentativaContato($solicitacaoId)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json(FilaService::createTentativaContato($solicitacaoId), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function storeTentativaContato()
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json(FilaService::storeTentativaContato(), Response::HTTP_CREATED);
|
||||
}
|
||||
|
||||
public function createOci($solicitacaoId)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json(FilaService::createOci($solicitacaoId), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function storeOci($solicitacaoId)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json(FilaService::storeOci($solicitacaoId), Response::HTTP_CREATED);
|
||||
}
|
||||
|
||||
public function updatePaciente($pacienteId)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json(FilaService::updatePaciente($pacienteId), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function editSolicitacao($solicitacaoId)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json(FilaService::editSolicitacao($solicitacaoId), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function updateSolicitacao($solicitacaoId)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
try {
|
||||
|
||||
return response()->json(FilaService::updateSolicitacao($solicitacaoId), Response::HTTP_OK);
|
||||
}
|
||||
catch (CannotUpdateSolicitacaoException $e) {
|
||||
|
||||
return response()->json(['message' => $e->getMessage()], Response::HTTP_BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
|
||||
public function dadosAmbulatorio($solicitacaoId)
|
||||
{
|
||||
return response()->json(FilaService::getDadosAmbulatorio($solicitacaoId), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function getDadosOci($solicitacaoId)
|
||||
{
|
||||
return response()->json(FilaService::getDadosOci($solicitacaoId), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function getAtendimentos()
|
||||
{
|
||||
return response()->json(FilaService::getAtendimentos(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function updateSolicitacoes()
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
try {
|
||||
|
||||
return response()->json(FilaService::updateSolicitacoes(), Response::HTTP_NO_CONTENT);
|
||||
}
|
||||
catch (CannotUpdateSolicitacoesException $e) {
|
||||
|
||||
return response()->json(['message' => $e->getMessage()], Response::HTTP_BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Regulacao;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Cadastro\Parametrizacao\Parametrizacao;
|
||||
use App\Services\Geral\AgeService;
|
||||
use App\Services\Regulacao\MonitoramentoProcolocoService;
|
||||
use Carbon\Carbon;
|
||||
use DateTime;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class MonitoramentoProcolocoController extends Controller
|
||||
{
|
||||
protected $modulo = 'regulacao';
|
||||
protected $funcionalidade = 'monitoramento-protocolo';
|
||||
|
||||
public function autocompletePaciente()
|
||||
{
|
||||
return datatables()
|
||||
->of(MonitoramentoProcolocoService::autocompletePaciente())
|
||||
->filterColumn('cidadao.data_nascimento', function ($query, $keyword) {
|
||||
|
||||
$query->whereRaw("DATE_FORMAT(cidadao.data_nascimento, '%d/%m/%Y') like ?", ["%{$keyword}%"]);
|
||||
})
|
||||
->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();
|
||||
}
|
||||
|
||||
public function autocompleteUsuarioResponsavel()
|
||||
{
|
||||
return datatables()
|
||||
->of(MonitoramentoProcolocoService::autocompleteUsuarioResponsavel())
|
||||
->toJson();
|
||||
}
|
||||
|
||||
public function list()
|
||||
{
|
||||
return response()->json(MonitoramentoProcolocoService::list(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function datatable()
|
||||
{
|
||||
$quantidadeDiasCadastroPaciente = Parametrizacao::first()->cadastro_paciente_desatualizado_quantidade_dias ?? 0;
|
||||
|
||||
return datatables()
|
||||
->of(MonitoramentoProcolocoService::datatable())
|
||||
->addColumn('data_ultima_atualizacao_paciente', function ($item) {
|
||||
|
||||
$updatedAt = $item->paciente_updated_at > $item->paciente_cidadao_updated_at
|
||||
? $item->paciente_updated_at
|
||||
: $item->paciente_cidadao_updated_at;
|
||||
|
||||
if ($updatedAt) {
|
||||
|
||||
return Carbon::create($updatedAt)->format('d/m/Y');
|
||||
}
|
||||
|
||||
return null;
|
||||
})
|
||||
->addColumn('dias_cadastro_paciente_desatualizado', function ($item) use ($quantidadeDiasCadastroPaciente) {
|
||||
|
||||
$updatedAt = $item->paciente_updated_at > $item->paciente_cidadao_updated_at
|
||||
? $item->paciente_updated_at
|
||||
: $item->paciente_cidadao_updated_at;
|
||||
|
||||
$diasAtrasados = 0;
|
||||
|
||||
if ($updatedAt) {
|
||||
|
||||
$updatedAtCarbon = Carbon::createFromFormat('Y-m-d H:i:s', $updatedAt);
|
||||
$updatedAtCarbon->addDays($quantidadeDiasCadastroPaciente);
|
||||
$currentDateTime = Carbon::now();
|
||||
|
||||
if ($updatedAtCarbon->lessThan($currentDateTime)) {
|
||||
|
||||
$diasAtrasados = $updatedAtCarbon->diffInDays($currentDateTime);
|
||||
$diasAtrasados = str_pad($diasAtrasados, 2, '0', STR_PAD_LEFT);
|
||||
}
|
||||
}
|
||||
|
||||
return $diasAtrasados;
|
||||
})
|
||||
->addColumn('paciente_idade', fn ($a) => is_null($a->paciente_data_nascimento)
|
||||
? null : AgeService::getFormattedAge(new DateTime($a->paciente_data_nascimento))
|
||||
)
|
||||
->editColumn('paciente_data_nascimento', fn ($a) => is_null($a->paciente_data_nascimento)
|
||||
? null : Carbon::create($a->paciente_data_nascimento)->format('d/m/Y')
|
||||
)
|
||||
->editColumn('prazo_restante', fn ($a) => (((bool) $a->is_concluido) ? null : (((bool) $a->is_vencido) ? 0 : $a->prazo_restante)))
|
||||
->editColumn('is_concluido', fn ($a) => (bool) $a->is_concluido)
|
||||
->editColumn('is_vencido', fn ($a) => (bool) $a->is_vencido)
|
||||
->editColumn('is_paciente_em_obito', fn ($a) => (bool) $a->is_paciente_em_obito)
|
||||
->editColumn('cids', fn ($a) => explode('#', $a->cids))
|
||||
->skipTotalRecords()
|
||||
->toJson();
|
||||
}
|
||||
|
||||
public function getAtendimentos($acompanhamentoOciId)
|
||||
{
|
||||
return response()->json(MonitoramentoProcolocoService::getAtendimentos($acompanhamentoOciId), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function getSolicitacoes($acompanhamentoOciId)
|
||||
{
|
||||
return response()->json(MonitoramentoProcolocoService::getSolicitacoes($acompanhamentoOciId), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function createEncerramentoOci($acompanhamentoOciId)
|
||||
{
|
||||
return response()->json(MonitoramentoProcolocoService::createEncerramentoOci($acompanhamentoOciId), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function storeEncerramentoOci($acompanhamentoOciId)
|
||||
{
|
||||
return response()->json(MonitoramentoProcolocoService::storeEncerramentoOci($acompanhamentoOciId), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function updateSolicitacoes($acompanhamentoOciId)
|
||||
{
|
||||
return response()->json(MonitoramentoProcolocoService::updateSolicitacoes($acompanhamentoOciId), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function dadosProcedimentosPreenchidos($acompanhamentoOciId)
|
||||
{
|
||||
return response()->json(MonitoramentoProcolocoService::dadosProcedimentosPreenchidos($acompanhamentoOciId), Response::HTTP_OK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Regulacao;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Regulacao\ParametrizacaoService;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class ParametrizacaoController extends Controller
|
||||
{
|
||||
protected $modulo = 'regulacao';
|
||||
protected $funcionalidade = 'parametrizacao';
|
||||
|
||||
public function autocompleteGrupoExame()
|
||||
{
|
||||
return datatables()
|
||||
->of(ParametrizacaoService::autocompleteGrupoExame())
|
||||
->toJson();
|
||||
}
|
||||
|
||||
public function autocompleteExame()
|
||||
{
|
||||
return datatables()
|
||||
->of(ParametrizacaoService::autocompleteExame())
|
||||
->editColumn('grupo_id', fn ($i) => is_null($i->grupo_id) ? null : (int) $i->grupo_id)
|
||||
->toJson();
|
||||
}
|
||||
|
||||
public function autocompleteProcedimentoCirurgico()
|
||||
{
|
||||
return datatables()
|
||||
->of(ParametrizacaoService::autocompleteProcedimentoCirurgico())
|
||||
->editColumn('grupo_id', fn ($i) => is_null($i->grupo_id) ? null : (int) $i->grupo_id)
|
||||
->toJson();
|
||||
}
|
||||
|
||||
public function autocompleteEspecialidade()
|
||||
{
|
||||
return datatables()->of(ParametrizacaoService::autocompleteEspecialidade())->toJson();
|
||||
}
|
||||
|
||||
public function list()
|
||||
{
|
||||
return response()->json(ParametrizacaoService::list(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json(ParametrizacaoService::create(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function store()
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json(ParametrizacaoService::store(), Response::HTTP_CREATED);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Regulacao;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Regulacao\RelatorioSolicitacaoService;
|
||||
use App\Utils\MaskUtil;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class RelatorioSolicitacaoController extends Controller
|
||||
{
|
||||
protected $modulo = 'regulacao';
|
||||
protected $funcionalidade = 'relatorio-solicitacao';
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json(RelatorioSolicitacaoService::index(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function list()
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json(RelatorioSolicitacaoService::list(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function autocompletePaciente()
|
||||
{
|
||||
return datatables()
|
||||
->of(RelatorioSolicitacaoService::autocompletePaciente())
|
||||
->filterColumn('cidadao.data_nascimento', function ($query, $keyword) {
|
||||
|
||||
$query->whereRaw("DATE_FORMAT(cidadao.data_nascimento, '%d/%m/%Y') like ?", ["%{$keyword}%"]);
|
||||
})
|
||||
->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}%"]
|
||||
);
|
||||
})
|
||||
->editColumn('cns', fn ($paciente) => MaskUtil::getCnsMasked($paciente->cns))
|
||||
->toJson();
|
||||
}
|
||||
|
||||
public function autocompleteCid()
|
||||
{
|
||||
return datatables()
|
||||
->of(RelatorioSolicitacaoService::autocompleteCid())
|
||||
->editColumn('codigo', fn ($cid) => MaskUtil::getCidMasked($cid->codigo))
|
||||
->toJson();
|
||||
}
|
||||
|
||||
public function autocompleteCiap()
|
||||
{
|
||||
return datatables()
|
||||
->of(RelatorioSolicitacaoService::autocompleteCiap())
|
||||
->toJson();
|
||||
}
|
||||
}
|
||||
178
api/app/Http/Controllers/Regulacao/SolicitacaoController.php
Normal file
178
api/app/Http/Controllers/Regulacao/SolicitacaoController.php
Normal file
@@ -0,0 +1,178 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Regulacao;
|
||||
|
||||
use App\Exceptions\Regulacao\CannotCancelSolicitacaoException;
|
||||
use App\Exceptions\Regulacao\CannotUpdateSolicitacaoException;
|
||||
use App\Exceptions\Regulacao\CannotCreateSolicitacaoException;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Regulacao\SolicitacaoService;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class SolicitacaoController extends Controller
|
||||
{
|
||||
protected $modulo = 'regulacao';
|
||||
protected $funcionalidade = 'solicitacao';
|
||||
|
||||
public function datatable()
|
||||
{
|
||||
return datatables()
|
||||
->of(SolicitacaoService::datatable())
|
||||
->filterColumn('cidadao.data_nascimento', function ($query, $keyword) {
|
||||
|
||||
$query->whereRaw("DATE_FORMAT(cidadao.data_nascimento, '%d/%m/%Y') like ?", ["%{$keyword}%"])
|
||||
->orWhereRaw(
|
||||
"CONCAT(
|
||||
SUBSTR(cidadao.data_nascimento,9,2),
|
||||
SUBSTR(cidadao.data_nascimento,6,2),
|
||||
SUBSTR(cidadao.data_nascimento,1,4)
|
||||
) like ?",
|
||||
["%{$keyword}%"]
|
||||
);
|
||||
})
|
||||
->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}%"]
|
||||
);
|
||||
})
|
||||
->filterColumn('cidadao.cns', function ($query, $keyword) {
|
||||
|
||||
$query
|
||||
->whereRaw("cidadao.cns like ?", ["%{$keyword}%"])
|
||||
->orWhereRaw(
|
||||
"CONCAT(
|
||||
SUBSTR(cidadao.cns, 1, 3),
|
||||
' ',
|
||||
SUBSTR(cidadao.cns, 4, 4),
|
||||
' ',
|
||||
SUBSTR(cidadao.cns, 8, 4),
|
||||
' ',
|
||||
SUBSTR(cidadao.cns, 12, 4)
|
||||
) like ?",
|
||||
["%{$keyword}%"]
|
||||
);
|
||||
})
|
||||
->skipTotalRecords()
|
||||
->toJson();
|
||||
}
|
||||
|
||||
public function autocompleteExame()
|
||||
{
|
||||
return datatables()
|
||||
->of(SolicitacaoService::autocompleteExame())
|
||||
->toJson();
|
||||
}
|
||||
|
||||
public function autocompleteProcedimentoCirurgico()
|
||||
{
|
||||
return datatables()
|
||||
->of(SolicitacaoService::autocompleteProcedimentoCirurgico())
|
||||
->toJson();
|
||||
}
|
||||
|
||||
public function autocompleteEspecialidade()
|
||||
{
|
||||
return datatables()
|
||||
->of(SolicitacaoService::autocompleteEspecialidade())
|
||||
->toJson();
|
||||
}
|
||||
|
||||
public function index($pacienteId)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json(SolicitacaoService::index($pacienteId), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function list()
|
||||
{
|
||||
return response()->json(SolicitacaoService::list(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function create($pacienteId)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json(SolicitacaoService::create($pacienteId), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json(SolicitacaoService::edit($id), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function store()
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
try {
|
||||
|
||||
return response()->json(SolicitacaoService::store(), Response::HTTP_CREATED);
|
||||
|
||||
}
|
||||
catch (CannotCreateSolicitacaoException $e) {
|
||||
|
||||
return response()->json(['message' => $e->getMessage()], Response::HTTP_BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
|
||||
public function update($id)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
try {
|
||||
|
||||
return response()->json(SolicitacaoService::update($id), Response::HTTP_OK);
|
||||
}
|
||||
catch (CannotUpdateSolicitacaoException $e) {
|
||||
|
||||
return response()->json(['message' => $e->getMessage()], Response::HTTP_BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
|
||||
public function cancel($id)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
try {
|
||||
|
||||
return response()->json(SolicitacaoService::cancel($id, request()->all()), Response::HTTP_OK);
|
||||
}
|
||||
catch (CannotCancelSolicitacaoException $e) {
|
||||
|
||||
return response()->json(['message' => $e->getMessage()], Response::HTTP_BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
|
||||
public function getInfoProfissional()
|
||||
{
|
||||
|
||||
return response()->json(SolicitacaoService::getInfoProfissional(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function getAgendamentoExameNoPrazoDeValidade($pacienteId, $exameId)
|
||||
{
|
||||
return response()->json(
|
||||
SolicitacaoService::getAgendamentoExameNoPrazoDeValidade($pacienteId, $exameId),
|
||||
Response::HTTP_OK
|
||||
);
|
||||
}
|
||||
}
|
||||
57
api/app/Http/Controllers/Regulacao/StatusController.php
Normal file
57
api/app/Http/Controllers/Regulacao/StatusController.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Regulacao;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Regulacao\StatusService;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class StatusController extends Controller
|
||||
{
|
||||
protected $modulo = 'regulacao';
|
||||
protected $funcionalidade = 'status';
|
||||
|
||||
public function datatable()
|
||||
{
|
||||
return datatables()
|
||||
->of(StatusService::datatable())
|
||||
->toJson();
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json(StatusService::create(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json(StatusService::edit($id), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function store()
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json(StatusService::store(), Response::HTTP_CREATED);
|
||||
}
|
||||
|
||||
public function update($id)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json(StatusService::update($id), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
StatusService::destroy($id);
|
||||
|
||||
return response()->noContent();
|
||||
}
|
||||
}
|
||||
18
api/app/Http/Controllers/Regulacao/SupervisorController.php
Normal file
18
api/app/Http/Controllers/Regulacao/SupervisorController.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Regulacao;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Regulacao\SupervisorService;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class SupervisorController extends Controller
|
||||
{
|
||||
protected $modulo = 'regulacao';
|
||||
protected $funcionalidade = 'supervisor';
|
||||
|
||||
public function isSupervisor($usuarioId)
|
||||
{
|
||||
return response()->json(SupervisorService::isSupervisor($usuarioId), Response::HTTP_OK);
|
||||
}
|
||||
}
|
||||
50
api/app/Http/Controllers/Regulacao/UploadController.php
Normal file
50
api/app/Http/Controllers/Regulacao/UploadController.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Regulacao;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Regulacao\UploadService;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class UploadController extends Controller
|
||||
{
|
||||
protected $modulo = 'regulacao';
|
||||
protected $funcionalidade = 'upload';
|
||||
|
||||
public function show()
|
||||
{
|
||||
return response()->json(UploadService::show(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function store()
|
||||
{
|
||||
return response()->json(UploadService::store(), Response::HTTP_CREATED);
|
||||
}
|
||||
|
||||
public function download($id)
|
||||
{
|
||||
$response = UploadService::download($id);
|
||||
|
||||
$tipoMime = mime_content_type($response['arquivo']);
|
||||
$headers = [
|
||||
'Content-Type' => $tipoMime,
|
||||
];
|
||||
|
||||
return response()->download($response['arquivo'], $response['nome'], $headers);
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
return response()->json(UploadService::destroy($id), Response::HTTP_NO_CONTENT);
|
||||
}
|
||||
|
||||
public function view($id)
|
||||
{
|
||||
$fileData = UploadService::view($id);
|
||||
|
||||
return response()->file($fileData['path'], [
|
||||
'Content-Type' => $fileData['mimeType'],
|
||||
'Cache-Control' => 'public, max-age=86400',
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user