This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Mobile\ConectaCidadao\Agendamento;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Mobile\ConectaCidadao\Agendamento\AgendamentoService;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class AgendamentoController extends Controller
|
||||
{
|
||||
public function especialidades()
|
||||
{
|
||||
return response()->json(AgendamentoService::especialidades(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function vagas()
|
||||
{
|
||||
return response()->json(AgendamentoService::vagas(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function store()
|
||||
{
|
||||
return response()->json(AgendamentoService::store(), Response::HTTP_CREATED);
|
||||
}
|
||||
|
||||
public function cancelar($id)
|
||||
{
|
||||
return response()->json(AgendamentoService::cancelar($id), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function historico()
|
||||
{
|
||||
return response()->json(AgendamentoService::historico(), Response::HTTP_OK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,200 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Mobile\ConectaCidadao\Autenticacao;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Mobile\ConectaCidadao\Autenticacao\AutenticacaoService;
|
||||
use App\Services\Mobile\ConectaCidadao\Autenticacao\PrimeiroAcessoService;
|
||||
use App\Services\Mobile\ConectaCidadao\Autenticacao\RecuperacaoSenhaService;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class AutenticacaoController extends Controller
|
||||
{
|
||||
private AutenticacaoService $autenticacaoService;
|
||||
private PrimeiroAcessoService $primeiroAcessoService;
|
||||
private RecuperacaoSenhaService $recuperacaoSenhaService;
|
||||
|
||||
public function __construct(
|
||||
AutenticacaoService $autenticacaoService,
|
||||
PrimeiroAcessoService $primeiroAcessoService,
|
||||
RecuperacaoSenhaService $recuperacaoSenhaService
|
||||
) {
|
||||
$this->autenticacaoService = $autenticacaoService;
|
||||
$this->primeiroAcessoService = $primeiroAcessoService;
|
||||
$this->recuperacaoSenhaService = $recuperacaoSenhaService;
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
$dadosValidados = $request->validate([
|
||||
'cpf' => ['required', 'string'],
|
||||
'senha' => ['required', 'string'],
|
||||
]);
|
||||
|
||||
try {
|
||||
$resultado = $this->autenticacaoService->login($dadosValidados);
|
||||
} catch (\InvalidArgumentException $exception) {
|
||||
return response()->json([
|
||||
'message' => $exception->getMessage(),
|
||||
], $exception->getCode() ?: Response::HTTP_UNAUTHORIZED);
|
||||
}
|
||||
|
||||
return response()->json($resultado, Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function refresh(Request $request)
|
||||
{
|
||||
try {
|
||||
$resultado = $this->autenticacaoService->refresh();
|
||||
} catch (\InvalidArgumentException $exception) {
|
||||
return response()->json([
|
||||
'message' => $exception->getMessage(),
|
||||
], $exception->getCode() ?: Response::HTTP_UNAUTHORIZED);
|
||||
}
|
||||
|
||||
return response()->json($resultado, Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function primeiroAcessoIniciar(Request $request)
|
||||
{
|
||||
$dadosValidados = $request->validate([
|
||||
'cpf' => ['required', 'string'],
|
||||
'data_nascimento' => ['required', 'date_format:Y-m-d'],
|
||||
'telefone' => ['required', 'string'],
|
||||
]);
|
||||
|
||||
try {
|
||||
$resultado = $this->primeiroAcessoService->iniciar($dadosValidados);
|
||||
} catch (\InvalidArgumentException $exception) {
|
||||
return response()->json([
|
||||
'message' => $exception->getMessage(),
|
||||
], $exception->getCode() ?: Response::HTTP_UNPROCESSABLE_ENTITY);
|
||||
}
|
||||
|
||||
return response()->json($resultado, Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function primeiroAcessoReenviarCodigo(Request $request)
|
||||
{
|
||||
$dadosValidados = $request->validate([
|
||||
'token' => ['required', 'integer'],
|
||||
]);
|
||||
|
||||
try {
|
||||
$this->primeiroAcessoService->reenviarCodigo($dadosValidados['token']);
|
||||
} catch (\InvalidArgumentException $exception) {
|
||||
return response()->json([
|
||||
'message' => $exception->getMessage(),
|
||||
], $exception->getCode() ?: Response::HTTP_UNPROCESSABLE_ENTITY);
|
||||
}
|
||||
|
||||
return response()->json([], Response::HTTP_NO_CONTENT);
|
||||
}
|
||||
|
||||
public function primeiroAcessoValidarCodigo(Request $request)
|
||||
{
|
||||
$dadosValidados = $request->validate([
|
||||
'token' => ['required', 'integer'],
|
||||
'codigo' => ['required', 'string'],
|
||||
]);
|
||||
|
||||
try {
|
||||
$this->primeiroAcessoService->validarCodigo($dadosValidados);
|
||||
} catch (\InvalidArgumentException $exception) {
|
||||
return response()->json([
|
||||
'message' => $exception->getMessage(),
|
||||
], $exception->getCode() ?: Response::HTTP_UNPROCESSABLE_ENTITY);
|
||||
}
|
||||
|
||||
return response()->json([], Response::HTTP_NO_CONTENT);
|
||||
}
|
||||
|
||||
public function primeiroAcessoDefinirSenha(Request $request)
|
||||
{
|
||||
$dadosValidados = $request->validate([
|
||||
'token' => ['required', 'integer'],
|
||||
'senha' => ['required', 'string', 'min:6'],
|
||||
]);
|
||||
|
||||
try {
|
||||
$this->primeiroAcessoService->definirSenha($dadosValidados);
|
||||
} catch (\InvalidArgumentException $exception) {
|
||||
return response()->json([
|
||||
'message' => $exception->getMessage(),
|
||||
], $exception->getCode() ?: Response::HTTP_UNPROCESSABLE_ENTITY);
|
||||
}
|
||||
|
||||
return response()->json([], Response::HTTP_NO_CONTENT);
|
||||
}
|
||||
|
||||
public function recuperacaoSenhaIniciar(Request $request)
|
||||
{
|
||||
$dadosValidados = $request->validate([
|
||||
'cpf' => ['required', 'string'],
|
||||
]);
|
||||
|
||||
try {
|
||||
$resultado = $this->recuperacaoSenhaService->iniciar($dadosValidados['cpf']);
|
||||
} catch (\InvalidArgumentException $exception) {
|
||||
return response()->json([
|
||||
'message' => $exception->getMessage(),
|
||||
], $exception->getCode() ?: Response::HTTP_UNPROCESSABLE_ENTITY);
|
||||
}
|
||||
|
||||
return response()->json($resultado, Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function recuperacaoSenhaReenviarCodigo(Request $request)
|
||||
{
|
||||
$dadosValidados = $request->validate([
|
||||
'token' => ['required', 'integer'],
|
||||
]);
|
||||
|
||||
try {
|
||||
$this->recuperacaoSenhaService->reenviarCodigo($dadosValidados['token']);
|
||||
} catch (\InvalidArgumentException $exception) {
|
||||
return response()->json([
|
||||
'message' => $exception->getMessage(),
|
||||
], $exception->getCode() ?: Response::HTTP_UNPROCESSABLE_ENTITY);
|
||||
}
|
||||
|
||||
return response()->json([], Response::HTTP_NO_CONTENT);
|
||||
}
|
||||
|
||||
public function recuperacaoSenhaValidarCodigo(Request $request)
|
||||
{
|
||||
$dadosValidados = $request->validate([
|
||||
'token' => ['required', 'integer'],
|
||||
'codigo' => ['required', 'string'],
|
||||
]);
|
||||
|
||||
try {
|
||||
$this->recuperacaoSenhaService->validarCodigo($dadosValidados);
|
||||
} catch (\InvalidArgumentException $exception) {
|
||||
return response()->json([
|
||||
'message' => $exception->getMessage(),
|
||||
], $exception->getCode() ?: Response::HTTP_UNPROCESSABLE_ENTITY);
|
||||
}
|
||||
|
||||
return response()->json([], Response::HTTP_NO_CONTENT);
|
||||
}
|
||||
|
||||
public function recuperacaoSenhaRedefinirSenha(Request $request)
|
||||
{
|
||||
$dadosValidados = $request->validate([
|
||||
'token' => ['required', 'integer'],
|
||||
'senha' => ['required', 'string', 'min:6'],
|
||||
]);
|
||||
|
||||
try {
|
||||
$this->recuperacaoSenhaService->redefinirSenha($dadosValidados);
|
||||
} catch (\InvalidArgumentException $exception) {
|
||||
return response()->json([
|
||||
'message' => $exception->getMessage(),
|
||||
], $exception->getCode() ?: Response::HTTP_UNPROCESSABLE_ENTITY);
|
||||
}
|
||||
|
||||
return response()->json([], Response::HTTP_NO_CONTENT);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Mobile\ConectaCidadao\CarteiraVacinacao;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Mobile\ConectaCidadao\CarteiraVacinacao\CarteiraVacinacaoService;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class CarteiraVacinacaoController extends Controller
|
||||
{
|
||||
public function vacinas()
|
||||
{
|
||||
return response()->json(CarteiraVacinacaoService::vacinas(), Response::HTTP_OK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Mobile\ConectaCidadao\EncaminhamentoRegulado;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Mobile\ConectaCidadao\EncaminhamentoRegulado\EncaminhamentoReguladoService;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class EncaminhamentoReguladoController extends Controller
|
||||
{
|
||||
public function meusEncaminhamentos()
|
||||
{
|
||||
return response()->json(EncaminhamentoReguladoService::meusEncaminhamentos(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function documentos(int $id)
|
||||
{
|
||||
return response()->json(EncaminhamentoReguladoService::documentos($id), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function documentoPorTipo(int $id, string $tipo)
|
||||
{
|
||||
return response()->json(EncaminhamentoReguladoService::documentoPorTipo($id, $tipo), Response::HTTP_OK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Mobile\ConectaCidadao\ExameImagem;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Mobile\ConectaCidadao\ExameImagem\AgendamentoImagemService;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class AgendamentoImagemController extends Controller
|
||||
{
|
||||
public function elegibilidade()
|
||||
{
|
||||
return response()->json(AgendamentoImagemService::elegibilidade(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function prestadores()
|
||||
{
|
||||
return response()->json(AgendamentoImagemService::prestadores(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function exames()
|
||||
{
|
||||
return response()->json(AgendamentoImagemService::exames(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function jornadas()
|
||||
{
|
||||
return response()->json(AgendamentoImagemService::jornadas(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function agendar()
|
||||
{
|
||||
return response()->json(AgendamentoImagemService::agendar(), Response::HTTP_CREATED);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Mobile\ConectaCidadao\ExameImagem;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Mobile\ConectaCidadao\ExameImagem\LaudoService;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class LaudoController extends Controller
|
||||
{
|
||||
public function laudos()
|
||||
{
|
||||
return response()->json(LaudoService::laudos(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function download(int $exameId)
|
||||
{
|
||||
$laudo = LaudoService::download($exameId);
|
||||
|
||||
return response()->download($laudo['caminho'], $laudo['nome']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Mobile\ConectaCidadao\ExameLaboratorial;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Mobile\ConectaCidadao\ExameLaboratorial\AgendamentoExameService;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class AgendamentoExameController extends Controller
|
||||
{
|
||||
public function elegibilidade()
|
||||
{
|
||||
return response()->json(AgendamentoExameService::elegibilidade(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function unidadesColeta()
|
||||
{
|
||||
return response()->json(AgendamentoExameService::unidadesColeta(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function exames()
|
||||
{
|
||||
return response()->json(AgendamentoExameService::exames(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function jornadas()
|
||||
{
|
||||
return response()->json(AgendamentoExameService::jornadas(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function agendar()
|
||||
{
|
||||
return response()->json(AgendamentoExameService::agendar(), Response::HTTP_CREATED);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Mobile\ConectaCidadao\ExameLaboratorial;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Mobile\ConectaCidadao\ExameLaboratorial\LaudoService;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class LaudoController extends Controller
|
||||
{
|
||||
public function laudos()
|
||||
{
|
||||
return response()->json(LaudoService::laudos(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function download(int $laudoId)
|
||||
{
|
||||
$laudo = LaudoService::download($laudoId);
|
||||
|
||||
return response()->download($laudo['caminho'], $laudo['nome']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Mobile\ConectaCidadao\ExclusaoConta;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Mobile\ConectaCidadao\ExclusaoConta\ExclusaoContaService;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class ExclusaoContaController extends Controller
|
||||
{
|
||||
public function destroy($id)
|
||||
{
|
||||
return response()->json(ExclusaoContaService::excluirConta((int) $id), Response::HTTP_OK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Mobile\ConectaCidadao\Farmacia;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Mobile\ConectaCidadao\Farmacia\MonitoramentoPosologiaService;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class MonitoramentoPosologiaController extends Controller
|
||||
{
|
||||
public function medicamentos()
|
||||
{
|
||||
return response()->json(MonitoramentoPosologiaService::medicamentos(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function iniciar(int $receitaItemId)
|
||||
{
|
||||
return response()->json(MonitoramentoPosologiaService::iniciar($receitaItemId), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function index(int $receitaItemId)
|
||||
{
|
||||
return response()->json(MonitoramentoPosologiaService::index($receitaItemId), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function store(int $receitaItemId)
|
||||
{
|
||||
return response()->json(MonitoramentoPosologiaService::store($receitaItemId), Response::HTTP_CREATED);
|
||||
}
|
||||
|
||||
public function destroy(int $id)
|
||||
{
|
||||
return response()->json(MonitoramentoPosologiaService::destroy($id), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function interromper(int $receitaItemId)
|
||||
{
|
||||
return response()->json(MonitoramentoPosologiaService::interromper($receitaItemId), Response::HTTP_OK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Mobile\ConectaCidadao\Farmacia;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Mobile\ConectaCidadao\Farmacia\ReceitaService;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class ReceitaController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return response()->json(ReceitaService::index(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function show(int $id)
|
||||
{
|
||||
return response()->json(ReceitaService::show($id), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Mobile\ConectaCidadao\HistoricoAtendimento;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Cadastro\SujeitoAtencao\Paciente;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use App\Services\Mobile\ConectaCidadao\HistoricoAtendimento\HistoricoAtendimentoService;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Exception;
|
||||
|
||||
class HistoricoAtendimentoController extends Controller
|
||||
{
|
||||
private HistoricoAtendimentoService $historicoAtendimentoService;
|
||||
|
||||
public function __construct(HistoricoAtendimentoService $historicoAtendimentoService)
|
||||
{
|
||||
$this->historicoAtendimentoService = $historicoAtendimentoService;
|
||||
}
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
try {
|
||||
|
||||
$pacienteId = $request->input('paciente_id');
|
||||
|
||||
if (!$pacienteId) {
|
||||
|
||||
return response()->json(
|
||||
[
|
||||
'message' => 'O parâmetro paciente_id é obrigatório.'
|
||||
],
|
||||
Response::HTTP_BAD_REQUEST
|
||||
);
|
||||
}
|
||||
|
||||
$paciente = Paciente::find($pacienteId);
|
||||
|
||||
if (!$paciente) {
|
||||
|
||||
return response()->json(
|
||||
[
|
||||
'message' => 'Paciente não encontrado.'
|
||||
],
|
||||
Response::HTTP_NOT_FOUND
|
||||
);
|
||||
}
|
||||
|
||||
$limit = $request->input('limit', 15);
|
||||
$historico = $this->historicoAtendimentoService->getHistorico($paciente, $limit);
|
||||
|
||||
} catch (Exception $exception) {
|
||||
return response()->json(
|
||||
[
|
||||
'message' => $exception->getMessage(),
|
||||
],
|
||||
Response::HTTP_INTERNAL_SERVER_ERROR
|
||||
);
|
||||
}
|
||||
|
||||
return response()->json($historico, Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function show($id, Request $request)
|
||||
{
|
||||
try {
|
||||
|
||||
$sourceType = $request->input('source_type');
|
||||
|
||||
if (!$sourceType) {
|
||||
|
||||
return response()->json(
|
||||
[
|
||||
'message' => 'O parâmetro source_type é obrigatório.'
|
||||
],
|
||||
Response::HTTP_BAD_REQUEST);
|
||||
}
|
||||
|
||||
$detalhes = $this->historicoAtendimentoService->getDetalhes($id, $sourceType);
|
||||
|
||||
return response()->json($detalhes, Response::HTTP_OK);
|
||||
|
||||
} catch (ModelNotFoundException $e) {
|
||||
|
||||
return response()->json(
|
||||
[
|
||||
'message' => 'Atendimento não encontrado.'
|
||||
],
|
||||
Response::HTTP_NOT_FOUND
|
||||
);
|
||||
} catch (\Exception $exception) {
|
||||
return response()->json(
|
||||
[
|
||||
'message' => $exception->getMessage(),
|
||||
],
|
||||
Response::HTTP_INTERNAL_SERVER_ERROR
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function avaliar($sourceType, $id, Request $request)
|
||||
{
|
||||
try {
|
||||
|
||||
$params = $request->all();
|
||||
|
||||
$this->historicoAtendimentoService->avaliar($sourceType, $id, $params);
|
||||
|
||||
return response()->json(
|
||||
[
|
||||
'message' => 'Avaliação registrada com sucesso.'
|
||||
],
|
||||
Response::HTTP_OK
|
||||
);
|
||||
|
||||
} catch (ModelNotFoundException $e) {
|
||||
|
||||
return response()->json(
|
||||
[
|
||||
'message' => 'Atendimento não encontrado.'
|
||||
],
|
||||
Response::HTTP_NOT_FOUND
|
||||
);
|
||||
} catch (\Exception $exception) {
|
||||
return response()->json(
|
||||
[
|
||||
'message' => $exception->getMessage(),
|
||||
],
|
||||
Response::HTTP_INTERNAL_SERVER_ERROR
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function avaliacao($sourceType, $id, Request $request)
|
||||
{
|
||||
try {
|
||||
|
||||
$params = $request->all();
|
||||
|
||||
$avaliacao = $this->historicoAtendimentoService->avaliacao($sourceType, $id, $params);
|
||||
|
||||
return response()->json($avaliacao, Response::HTTP_OK);
|
||||
} catch (ModelNotFoundException $e) {
|
||||
|
||||
return response()->json(
|
||||
[
|
||||
'message' => 'Avaliação não encontrada.'
|
||||
],
|
||||
Response::HTTP_NOT_FOUND
|
||||
);
|
||||
} catch (\Exception $exception) {
|
||||
return response()->json(
|
||||
[
|
||||
'message' => $exception->getMessage(),
|
||||
],
|
||||
Response::HTTP_INTERNAL_SERVER_ERROR
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Mobile\ConectaCidadao\PerfilCidadao;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Cadastro\SujeitoAtencao\Paciente;
|
||||
use App\Services\Mobile\ConectaCidadao\PerfilCidadao\PerfilCidadaoService;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Exception;
|
||||
|
||||
class PerfilCidadaoController extends Controller
|
||||
{
|
||||
private PerfilCidadaoService $perfilCidadaoService;
|
||||
|
||||
public function __construct(PerfilCidadaoService $perfilCidadaoService)
|
||||
{
|
||||
$this->perfilCidadaoService = $perfilCidadaoService;
|
||||
}
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
try {
|
||||
|
||||
$pacienteId = $request->input('paciente_id');
|
||||
|
||||
if (!$pacienteId) {
|
||||
|
||||
return response()->json(
|
||||
[
|
||||
'message' => 'O parâmetro paciente_id é obrigatório.'
|
||||
],
|
||||
Response::HTTP_BAD_REQUEST
|
||||
);
|
||||
}
|
||||
|
||||
$paciente = Paciente::find($pacienteId);
|
||||
|
||||
if (!$paciente) {
|
||||
|
||||
return response()->json(
|
||||
[
|
||||
'message' => 'Paciente não encontrado.'
|
||||
],
|
||||
Response::HTTP_NOT_FOUND
|
||||
);
|
||||
}
|
||||
|
||||
$dadosCidadao = $this->perfilCidadaoService->getDadosCidadao($paciente);
|
||||
} catch (Exception $exception) {
|
||||
return response()->json(
|
||||
[
|
||||
'message' => $exception->getMessage(),
|
||||
],
|
||||
Response::HTTP_INTERNAL_SERVER_ERROR
|
||||
);
|
||||
}
|
||||
|
||||
return response()->json($dadosCidadao, Response::HTTP_OK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Mobile\ConectaCidadao\Termos;
|
||||
|
||||
use App\Enums\Mobile\ConectaCidadao\TermoTipo;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Mobile\ConectaCidadao\Termos\TermoService;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class TermoController extends Controller
|
||||
{
|
||||
public function politicaCidadao()
|
||||
{
|
||||
$termo = TermoService::getAtivoByTipo(TermoTipo::TERMO_USO);
|
||||
|
||||
return view('conectasus-cidadao.politica-conectasus-cidadao', compact('termo'));
|
||||
}
|
||||
|
||||
public function ativo()
|
||||
{
|
||||
return response()->json(TermoService::getAtivo(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
return response()->json(TermoService::getById($id), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function pendentes()
|
||||
{
|
||||
return response()->json(TermoService::getPendentes(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function aceitar($id)
|
||||
{
|
||||
return response()->json(TermoService::aceitar($id), Response::HTTP_CREATED);
|
||||
}
|
||||
|
||||
public function aceitacoes()
|
||||
{
|
||||
return response()->json(TermoService::getAceitacoes(), Response::HTTP_OK);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user