This commit is contained in:
151
api/app/Http/Controllers/Ambulatorio/AtendimentoController.php
Normal file
151
api/app/Http/Controllers/Ambulatorio/AtendimentoController.php
Normal file
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Ambulatorio;
|
||||
|
||||
use App\Exceptions\Ambulatorio\NaoPodeCriarFichaAtencaoBasicaException;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Ambulatorio\AtendimentoSoap;
|
||||
use App\Services\Ambulatorio\AtendimentoService;
|
||||
use App\Utils\Crypt;
|
||||
use Exception;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class AtendimentoController extends Controller
|
||||
{
|
||||
protected $modulo = 'ambulatorio';
|
||||
protected $funcionalidade = 'atendimento';
|
||||
|
||||
public function getHistoricoPreAtendimento($id)
|
||||
{
|
||||
return response()->json(AtendimentoService::getHistoricoPreAtendimento($id), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function getHistoricoAtendimentoSoap($id)
|
||||
{
|
||||
return response()->json(AtendimentoService::getHistoricoAtendimentoSoap($id), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function getHistoricoAtendimentoHospital($id)
|
||||
{
|
||||
return response()->json(AtendimentoService::getHistoricoAtendimentoHospital($id), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function getHistoricoPosConsulta($id)
|
||||
{
|
||||
return response()->json(AtendimentoService::getHistoricoPosConsulta($id), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function getHistoricoProntoAtendimentoAtendimento($id)
|
||||
{
|
||||
return response()->json(AtendimentoService::getHistoricoProntoAtendimentoAtendimento($id), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function uploadImagem()
|
||||
{
|
||||
return response()->json(AtendimentoService::uploadImagem(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
|
||||
return response()->json(AtendimentoService::destroy($id), Response::HTTP_NO_CONTENT);
|
||||
}
|
||||
|
||||
public function destroyFeridaProcedimento($id)
|
||||
{
|
||||
return response()->json(AtendimentoService::destroyFeridaProcedimento($id), Response::HTTP_NO_CONTENT);
|
||||
}
|
||||
|
||||
public function storeFeridaProcedimento()
|
||||
{
|
||||
return response()->json(AtendimentoService::storeFeridaProcedimento(), Response::HTTP_CREATED);
|
||||
}
|
||||
|
||||
public function validarProcedimentosCbo()
|
||||
{
|
||||
return response()->json(AtendimentoService::validarProcedimentosCbo(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function getUrlHistoricoConectaSUSV1($prontuario)
|
||||
{
|
||||
if(app('config')->get('database.default') == 'pederneiras'){
|
||||
|
||||
return response()->json(['url' => env('CONECTASUS_V1_URL_PEDERNEIRAS') . '/' . app('config')->get('database.default') . '/especialidade/lista_pacientes_historico_externo.php?DATA=' . Crypt::XORCrypt("NR_PRONTUARIO=$prontuario")] , Response::HTTP_OK);
|
||||
|
||||
}else{
|
||||
|
||||
return response()->json(['url' => env('CONECTASUS_V1_URL') . '/' . app('config')->get('database.default') . '/especialidade/lista_pacientes_historico_externo.php?DATA=' . Crypt::XORCrypt("NR_PRONTUARIO=$prontuario")] , Response::HTTP_OK);
|
||||
}
|
||||
}
|
||||
|
||||
public function list()
|
||||
{
|
||||
return response()->json(AtendimentoService::list(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function create($filaId = null, $agendamentoId = null)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json(AtendimentoService::create($filaId, $agendamentoId), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function store()
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
try {
|
||||
|
||||
return response()->json(AtendimentoService::store(), Response::HTTP_CREATED);
|
||||
}
|
||||
catch (NaoPodeCriarFichaAtencaoBasicaException $e) {
|
||||
|
||||
return response()->json(['message' => $e->getMessage()], Response::HTTP_BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
|
||||
public function exameDentroPrazoValidade()
|
||||
{
|
||||
return response()->json(AtendimentoService::exameDentroPrazoValidade(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function encaminhamentoPendente()
|
||||
{
|
||||
return response()->json(AtendimentoService::encaminhamentoPendente(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function prescricaoMedicamento()
|
||||
{
|
||||
return response()->json(AtendimentoService::prescricaoMedicamento(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function storeAtendimentoAssinado($id)
|
||||
{
|
||||
$path = 'assinatura-eletronica' . DIRECTORY_SEPARATOR . app('config')->get('database.default') . DIRECTORY_SEPARATOR . 'ambulatorio' . DIRECTORY_SEPARATOR . 'atendimento';
|
||||
|
||||
$atendimento = AtendimentoSoap::findOrFail($id);
|
||||
|
||||
if (!is_null($atendimento)) {
|
||||
|
||||
foreach (request()->atendimento_assinado as $arquivoBase64) {
|
||||
|
||||
$arquivo = "{$arquivoBase64['fileName']}.PDF";
|
||||
$pdf = base64_decode($arquivoBase64['data']);
|
||||
|
||||
if (!Storage::disk('local')->put($path . DIRECTORY_SEPARATOR . $arquivo, $pdf)) {
|
||||
throw new Exception("Erro ao salvar o arquivo {$arquivo}.");
|
||||
}
|
||||
}
|
||||
|
||||
$atendimento->update(['is_atendimento_soap_assinado' => true]);
|
||||
}
|
||||
|
||||
return response($atendimento->fresh(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function getOci($id)
|
||||
{
|
||||
return response()->json(AtendimentoService::getOci($id), Response::HTTP_OK);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user