1145 lines
44 KiB
PHP
1145 lines
44 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\ProntoAtendimento\PedidoExame;
|
|
|
|
use App\Enums\Cadastro\Estabelecimento\Servico;
|
|
use App\Enums\Cadastro\Estabelecimento\SetorTipo;
|
|
use App\Enums\Cadastro\SujeitoAtencao\Deficiencia;
|
|
use App\Enums\Cadastro\SujeitoAtencao\FatorRisco as FatorRiscoEnum;
|
|
use App\Enums\Cadastro\SujeitoAtencao\Sexo;
|
|
use App\Enums\Cadastro\UnidadeMedida as UnidadeMedidaEnum;
|
|
use App\Enums\Parametrizacao\Exame\Status as ExameStatusEnum;
|
|
use App\Enums\Parametrizacao\Exame\Tipo as ExameTipo;
|
|
use App\Enums\ProntoAtendimento\Atendimento\DorToracica as DorToracicaEnum;
|
|
use App\Enums\ProntoAtendimento\OrigemUnidadeEncaminhamento;
|
|
use App\Enums\ProntoAtendimento\Plantao\Status;
|
|
use App\Exceptions\ProntoAtendimento\Atendimento\Enfermagem\PedidoExameCannotChangeStatusException;
|
|
use App\Exceptions\ProntoAtendimento\Atendimento\Enfermagem\PedidoExameItemCannotChangeStatusException;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Requests\ProntoAtendimento\PedidoExame\PedidoExameRequest;
|
|
use App\Models\Cadastro\Estabelecimento\CentroCusto;
|
|
use App\Models\Cadastro\Estabelecimento\Unidade;
|
|
use App\Models\Cadastro\SujeitoAtencao\AlergiaCriticidade;
|
|
use App\Models\Cadastro\SujeitoAtencao\AlergiaTipo;
|
|
use App\Models\Cadastro\SujeitoAtencao\FatorRisco;
|
|
use App\Models\Cadastro\SujeitoAtencao\Lotacao;
|
|
use App\Models\Cadastro\UnidadeExterna;
|
|
use App\Models\Cadastro\UnidadeMedida;
|
|
use App\Models\PainelSenha\Encaminhamento;
|
|
use App\Models\Parametrizacao\Exame\ExameStatus;
|
|
use App\Models\ProntoAtendimento\Atendimento\Atendimento;
|
|
use App\Models\ProntoAtendimento\Atendimento\Triagem\FormularioDorToracica;
|
|
use App\Models\ProntoAtendimento\Atendimento\Triagem\OrigemDorToracica;
|
|
use App\Models\ProntoAtendimento\Atendimento\Triagem\RelacionadoFormularioDorToracica;
|
|
use App\Models\ProntoAtendimento\ClassificacaoRisco\ClassificacaoRisco;
|
|
use App\Models\ProntoAtendimento\PedidoExame\PedidoExame;
|
|
use App\Models\Sigtap\Competencia;
|
|
use App\Models\Sigtap\Procedimento;
|
|
use App\Services\ProntoAtendimento\AcidenteTrabalhoService;
|
|
use App\Services\ProntoAtendimento\Atendimento\AtendimentoService;
|
|
use App\Services\ProntoAtendimento\Atendimento\RaatService;
|
|
use App\Services\ProntoAtendimento\Fila\FilaService;
|
|
use App\Services\ProntoAtendimento\PedidoExame\LaudoService;
|
|
use App\Services\ProntoAtendimento\PlantaoService;
|
|
use App\Services\Sigtap\ProcedimentoValidationService;
|
|
use Carbon\Carbon;
|
|
use Illuminate\Http\Response;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class ExameImagemController extends Controller
|
|
{
|
|
protected $modulo = 'pronto-atendimento';
|
|
protected $funcionalidade = 'exame-imagem';
|
|
|
|
public function index()
|
|
{
|
|
$plantao = PlantaoService::getCurrentPlantao();
|
|
|
|
return response()->json(
|
|
[
|
|
'additionals' => [
|
|
'plantao_id' => $plantao->id ?? null,
|
|
'plantao_faixa_etaria_id' => $plantao->faixa_etaria_id ?? null,
|
|
],
|
|
],
|
|
Response::HTTP_OK
|
|
);
|
|
}
|
|
|
|
public function create($id)
|
|
{
|
|
$this->auth(__FUNCTION__);
|
|
|
|
$atendimento = Atendimento::where('fila_id', $id)
|
|
->orderBy('created_at', 'desc')
|
|
->firstOrFail();
|
|
|
|
$classificacaoRisco = $atendimento->classificacoesRisco->sortByDesc('created_at')->first();
|
|
$faa = $atendimento->faa;
|
|
$parecerMedico = $faa->raat && $faa->raat->pareceresMedico ? $faa->raat->pareceresMedico()->orderByDesc('created_at')->first() : [];
|
|
|
|
$classificacaoRisco = $this->getClassificacaoRisco($atendimento);
|
|
|
|
if($atendimento->faa->paciente->cidadao->sexo_id === Sexo::FEMININO && $atendimento->faa->paciente->cidadao->idade
|
|
&& $atendimento->faa->paciente->cidadao->idade['anos'] >= 9
|
|
&& $atendimento->faa->paciente->cidadao->idade['anos'] <= 60){
|
|
|
|
$exibirFatorRiscoGestante = true;
|
|
|
|
} else {
|
|
|
|
$exibirFatorRiscoGestante = false;
|
|
}
|
|
|
|
if ($atendimento->dor_toracica == true) {
|
|
|
|
$formulario = FormularioDorToracica::where('atendimento_id', $atendimento->id)->get();
|
|
|
|
foreach ($formulario as $registro) {
|
|
|
|
$formulario_id = $registro->id;
|
|
$data_sintoma = $registro->data_sintoma;
|
|
$hora_sintoma = $registro->hora_sintoma;
|
|
$data_ecg_admissao = $registro->data_ecg_admissao;
|
|
$hora_ecg_admissao = $registro->hora_ecg_admissao;
|
|
$dispneia = $registro->dispneia;
|
|
}
|
|
|
|
$formularioRelacionadoDor = RelacionadoFormularioDorToracica::where('formulario_id', $formulario_id)->get();
|
|
|
|
$dorToracicaRelacionada = [];
|
|
|
|
foreach ($formularioRelacionadoDor as $registroRelacionado) {
|
|
|
|
$dorToracicaRelacionada[] = $registroRelacionado->dor_toracica_id;
|
|
}
|
|
}
|
|
|
|
return response()->json(
|
|
[
|
|
'form' => [
|
|
'atendimento_medico' => $this->hasAtendimentoMedico($atendimento),
|
|
'encaminhamento_setores' => $this->getSetoresEncaminhamento(),
|
|
'alergia_tipos' => $this->getAlergiaTipos(),
|
|
'alergia_criticidades' => $this->getAlergiaCriticidades(),
|
|
'dataAtual' => Carbon::now()->format('d/m/Y'),
|
|
'atendimento_id' => $atendimento->id ?? null,
|
|
'statusExame' => ExameStatus::orderBy('nome')->get(),
|
|
'lotacao' => $this->getLotacao(),
|
|
'classificacoes_risco' => $this->getClassificacoesRisco(),
|
|
'paciente' => $this->getPaciente($atendimento),
|
|
'recepcao' => [
|
|
'motivo_atendimento' => $atendimento->recepcao->motivo_atendimento ?? null,
|
|
'is_encaminhamento' => $atendimento->recepcao->is_encaminhamento,
|
|
'origem_unidade_encaminhamento' => $atendimento->recepcao->origem_unidade_encaminhamento,
|
|
'unidade_encaminhamento' => Unidade::find($atendimento->recepcao->unidade_encaminhamento_id),
|
|
'unidade_externa_encaminhamento' => UnidadeExterna::find($atendimento->recepcao->unidade_externa_encaminhamento_id),
|
|
'medico_solicitante_encaminhamento' => $atendimento->recepcao->medico_solicitante_encaminhamento,
|
|
],
|
|
'origens_unidade' => [
|
|
[ 'id' => OrigemUnidadeEncaminhamento::INTERNA, 'nome' => 'INTERNA' ],
|
|
[ 'id' => OrigemUnidadeEncaminhamento::EXTERNA, 'nome' => 'EXTERNA' ],
|
|
],
|
|
'raat' => RaatService::getOptionsParecerMedico(),
|
|
'observacoes' => $this->getObservacoes($atendimento),
|
|
'pedidos_exames' => $this->getPedidosExames($atendimento, true),
|
|
'fatores_risco' => $this->getFatoresRisco(),
|
|
'fatores_risco_gestante' => $this->getFatoresRiscoGestante(),
|
|
'sinais_vitais' => $this->getSinaisVitais($atendimento, Carbon::now()),
|
|
'unidades_medida' => $this->getUnidadesMedida(),
|
|
'medicos_com_plantao' => $this->getMedicosComPlantao(),
|
|
'formulario_dor_toracica' => [
|
|
'dor_toracica_data_sintoma' => null,
|
|
'dor_toracica_hora_ecg_admissao' => null,
|
|
'hora_sintoma' => null,
|
|
'hora_ecg_admissao' => null,
|
|
'dispneia' => null,
|
|
'caracteristica_dor' => $this->getCaracteristicaDor(),
|
|
'localizacao_dor' => $this->getLocalizacaoDor(),
|
|
'fator_desencadeante' => $this->getFatorDesencadeante(),
|
|
'fatores_risco_toracica' => $this->getFatoresRiscoToracica(),
|
|
'duracao_dor' => $this->getDuracaoDor(),
|
|
],
|
|
],
|
|
'model' => [
|
|
'dor_toracica' => $atendimento->dor_toracica,
|
|
'centro_custo_id_para' => null,
|
|
'alergias' => $this->getAlergiasCidadao($atendimento),
|
|
'medicamentos_uso_continuo' => $this->getMedicamentosUsoContinuo($atendimento, Carbon::now()),
|
|
'pedidos_exames' => $this->getPedidosExames($atendimento),
|
|
'observacoes' => null,
|
|
'fatores_risco' => $this->getCidadaoFatoresRisco($atendimento),
|
|
'fator_risco_outro' => optional(optional(optional($atendimento->faa)->paciente)->cidadao)->fator_risco_outro,
|
|
'sinais_vitais' => [],
|
|
'exibirFatorRiscoGestante' => $exibirFatorRiscoGestante,
|
|
'acidente_trabalho' => AcidenteTrabalhoService::getAcidenteTrabalho($atendimento->faa),
|
|
'classificacao_risco_id' => $classificacaoRisco['classificacao_risco_id'] ?? null,
|
|
'dor_toracica_data_sintoma' => $data_sintoma ?? null,
|
|
'dor_toracica_hora_sintoma' => $hora_sintoma ?? null,
|
|
'dor_toracica_data_ecg_admissao' => $data_ecg_admissao ?? null,
|
|
'dor_toracica_hora_ecg_admissao' => $hora_ecg_admissao ?? null,
|
|
'dor_toracica_caracteristica_dor' => $dorToracicaRelacionada ?? null,
|
|
'dor_toracica_localizacao_dor' => $dorToracicaRelacionada ?? null,
|
|
'dor_toracica_fator_descadeante' => $dorToracicaRelacionada ?? null,
|
|
'dor_toracica_duracao_dor' => $dorToracicaRelacionada ?? null,
|
|
'dor_toracica_fatores_riscos' => $dorToracicaRelacionada ?? null,
|
|
'dor_toracica_dispneia' => $dispneia ?? null,
|
|
],
|
|
'additionals' => [
|
|
'has_atendimento_medico' => $this->hasAtendimentoMedico($atendimento),
|
|
'is_paciente_em_observacao' => $this->isPacienteEmObservacao($atendimento),
|
|
'timeline' => AtendimentoService::getTimelineItems($id),
|
|
]
|
|
],
|
|
Response::HTTP_OK
|
|
);
|
|
}
|
|
|
|
private function getObservacoes($atendimento)
|
|
{
|
|
return $atendimento->observacoes->map(function ($observacao) {
|
|
|
|
return [
|
|
'descricao' => $observacao->descricao,
|
|
'lotacao' => [
|
|
'ocupacao' => [
|
|
'id' => $observacao->createdLotacao->ocupacao->id ?? null,
|
|
'codigo' => $observacao->createdLotacao->ocupacao->codigo ?? null,
|
|
'nome' => $observacao->createdLotacao->ocupacao->nome ?? null,
|
|
],
|
|
'profissional' => [
|
|
'nome' => $observacao->createdLotacao->usuario->cidadao->nome ?? null,
|
|
],
|
|
],
|
|
'centro_custo' => [
|
|
'setor' => [
|
|
'nome' => $observacao->createdCentroCusto->setor->nome ?? null,
|
|
],
|
|
],
|
|
'data_hora' => $observacao->created_at->format('d/m/Y H:i:s') ?? null,
|
|
];
|
|
});
|
|
}
|
|
|
|
private function getMedicamentosUsoContinuo($atendimento, $datetime)
|
|
{
|
|
$medicamentos = $atendimento->faa->paciente->cidadao->medicamentosUsoContinuo()->wherePivot('created_at', '<=', $datetime)->get();
|
|
$result = [];
|
|
|
|
foreach ($medicamentos as $medicamento) {
|
|
$result[] = [
|
|
'medicamento' => [
|
|
'nome' => $medicamento->nome,
|
|
'id' => $medicamento->CidadaoMedicamentoUsoContinuo->medicamento_id,
|
|
],
|
|
'lotacao' => [
|
|
'ocupacao' => [
|
|
'id' => $medicamento->CidadaoMedicamentoUsoContinuo->createdLotacao->ocupacao->id ?? null,
|
|
'codigo' => $medicamento->CidadaoMedicamentoUsoContinuo->createdLotacao->ocupacao->codigo ?? null,
|
|
'nome' => $medicamento->CidadaoMedicamentoUsoContinuo->createdLotacao->ocupacao->nome ?? null,
|
|
],
|
|
'profissional' => [
|
|
'nome' => $medicamento->CidadaoMedicamentoUsoContinuo->createdLotacao->usuario->cidadao->nome ?? null,
|
|
],
|
|
],
|
|
'centro_custo' => [
|
|
'setor' => [
|
|
'nome' => $medicamento->CidadaoMedicamentoUsoContinuo->createdCentroCusto->setor->nome ?? null,
|
|
],
|
|
],
|
|
'data_hora' => $medicamento->CidadaoMedicamentoUsoContinuo->created_at->format('d/m/Y H:i:s') ?? null,
|
|
];
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
|
|
private function hasAtendimentoMedico($atendimento)
|
|
{
|
|
return $atendimento->atendimentosMedico->count() > 0;
|
|
}
|
|
|
|
private function isPacienteEmObservacao($atendimento)
|
|
{
|
|
return ($atendimento->fila->centroCusto->setor->tipo_id ?? null) === SetorTipo::OBSERVACAO;
|
|
}
|
|
|
|
private function getSetoresEncaminhamento()
|
|
{
|
|
return Encaminhamento::where('centro_custo_id_de', $this->getCentroCustoLogado()->id)
|
|
->whereHas('centroCustoPara', function ($query) {
|
|
|
|
$query->whereHas('setor', function ($query) {
|
|
|
|
$query->whereNotIn('tipo_id', [SetorTipo::RECEPCAO, SetorTipo::TRIAGEM]);
|
|
});
|
|
})
|
|
->get()
|
|
|
|
->map(function($query) {
|
|
return [
|
|
'id' => $query->centroCustoPara->id,
|
|
'nome' => $query->centroCustoPara->setor->nome,
|
|
];
|
|
});
|
|
}
|
|
|
|
private function getCentroCustoLogado() : CentroCusto
|
|
{
|
|
return CentroCusto::findOrFail(auth()->payload()->get('centro_custo_id'));
|
|
}
|
|
|
|
private function getAlergiaTipos()
|
|
{
|
|
return AlergiaTipo::all()->map(function($query) {
|
|
return [
|
|
'id' => $query->id,
|
|
'descricao' => $query->descricao,
|
|
];
|
|
});
|
|
}
|
|
|
|
private function getAlergiaCriticidades()
|
|
{
|
|
return AlergiaCriticidade::all()->map(function($query) {
|
|
return [
|
|
'id' => $query->id,
|
|
'nome' => $query->nome,
|
|
];
|
|
});
|
|
}
|
|
|
|
private function getAlergiasCidadao($atendimento)
|
|
{
|
|
return $atendimento->faa->paciente->cidadao->alergias
|
|
->map(function($query, $i) {
|
|
return [
|
|
'index' => $i,
|
|
'alergia' => [
|
|
'id' => $query->cidadaoAlergia->alergia_id,
|
|
'agente_substancia_especifica' => $query->agente_substancia_especifica,
|
|
'criticidade' => [
|
|
'id' => $query->cidadaoAlergia->criticidade->id,
|
|
'nome' => $query->cidadaoAlergia->criticidade->nome,
|
|
],
|
|
'reacoes_observacoes' => $query->cidadaoAlergia->reacoes_observacoes,
|
|
'tipo' => [
|
|
'id' => $query->tipo->id,
|
|
'descricao' => $query->tipo->descricao,
|
|
]
|
|
],
|
|
'lotacao' => [
|
|
'ocupacao' => [
|
|
'id' => $query->cidadaoAlergia->createdLotacao->ocupacao->id ?? null,
|
|
'codigo' => $query->cidadaoAlergia->createdLotacao->ocupacao->codigo ?? null,
|
|
'nome' => $query->cidadaoAlergia->createdLotacao->ocupacao->nome ?? null,
|
|
],
|
|
'profissional' => [
|
|
'nome' => $query->cidadaoAlergia->createdLotacao->usuario->cidadao->nome ?? null,
|
|
],
|
|
],
|
|
'centro_custo' => [
|
|
'setor' => [
|
|
'nome' => $query->cidadaoAlergia->createdCentroCusto->setor->nome ?? null,
|
|
],
|
|
],
|
|
'data_hora' => $query->cidadaoAlergia->created_at->format('d/m/Y H:i:s') ?? null,
|
|
];
|
|
});
|
|
}
|
|
|
|
public function store(PedidoExameRequest $request)
|
|
{
|
|
$this->auth(__FUNCTION__);
|
|
|
|
$pedidoExameImagem = new PedidoExame;
|
|
|
|
DB::transaction(function() use ($pedidoExameImagem, $request) {
|
|
|
|
PlantaoService::setStatusComAtendimento($request->plantao_id);
|
|
|
|
$atendimento = Atendimento::findOrFail($request['atendimento_id']);
|
|
|
|
$atendimentoExameImagem = $atendimento->atendimentosExameImagem()
|
|
->create(['is_observacao' => $this->isPacienteEmObservacao($atendimento)]);
|
|
|
|
$this->handlePedidosExames($atendimentoExameImagem, $request->pedidos_exames, $request->plantao_id);
|
|
$params = $request->all();
|
|
|
|
if ($params['fatores_risco'] ?? null) {
|
|
|
|
$atendimento->faa->paciente->cidadao->fatoresRisco()->sync($request->fatores_risco);
|
|
|
|
$this->handleFatorRiscoOutro($atendimento, $request);
|
|
}
|
|
|
|
$sinaisVitaisData = $this->prepareSinaisVitaisData($params, $atendimentoExameImagem);
|
|
if (!empty($sinaisVitaisData)) {
|
|
|
|
$atendimento->sinaisVitais()->createMany($sinaisVitaisData);
|
|
}
|
|
|
|
$atendimento->faa->paciente->cidadao->medicamentosUsoContinuo()->sync($this->prepareMedicamentosUsoContinuoData($params));
|
|
|
|
if (isset($params['observacoes'])) {
|
|
|
|
$atendimento->observacoes()->create([
|
|
'exame_imagem_id' => $atendimentoExameImagem->id,
|
|
'descricao' => $params['observacoes']
|
|
]);
|
|
}
|
|
|
|
if (isset($params['finalizacao'])) {
|
|
|
|
$atendimento->faa->update([
|
|
'desfecho_id' => $params['finalizacao']['desfecho_id'],
|
|
'finalizado' => true,
|
|
'usuario_id' => $atendimentoExameImagem->createdLotacao->usuario_id,
|
|
'lotacao_id' => $atendimentoExameImagem->createdLotacao->id,
|
|
'data_hora_desfecho' => $atendimentoExameImagem->created_at
|
|
]);
|
|
|
|
FilaService::dispatch($atendimento->fila->centroCusto);
|
|
|
|
} else {
|
|
|
|
if (!$atendimento->recepcao->is_encaminhamento
|
|
|| $atendimento->recepcao->is_encaminhamento && $atendimento->atendimentosMedico->count() > 0) {
|
|
|
|
if (isset($params['centro_custo_id_para'])) {
|
|
|
|
FilaService::forward([
|
|
'centro_custo_id_para' => $params['centro_custo_id_para']
|
|
], $atendimento->fila_id);
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
return response()->json($pedidoExameImagem->fresh(), Response::HTTP_CREATED);
|
|
}
|
|
|
|
private function handlePedidosExames($atendimentoExameImagem, $pedidosExamesRequested, $plantaoId)
|
|
{
|
|
$pedidoExamesAllowedChange = collect(
|
|
$this->getPedidosExames($atendimentoExameImagem->atendimento)
|
|
);
|
|
|
|
foreach (($pedidosExamesRequested ?? []) as $pedidoExamesRequested) {
|
|
|
|
$isForm = $pedidoExamesRequested['is_form'];
|
|
$pedidoExameRequestedId = $pedidoExamesRequested['id'] ?? null;
|
|
|
|
if (is_null($pedidoExameRequestedId)) {
|
|
|
|
$pedidoExamesData = $this->preparePedidoExamesData($atendimentoExameImagem, $pedidoExamesRequested, $plantaoId);
|
|
|
|
if (!empty($pedidoExamesData)) {
|
|
|
|
$pedidoExames = $atendimentoExameImagem->pedidosExames()->create($pedidoExamesData);
|
|
$this->storePedidoExamesItens($pedidoExames, $pedidoExamesData['exames'], $atendimentoExameImagem);
|
|
|
|
if(count($pedidoExamesData['files'] ?? []) > 0) {
|
|
|
|
$this->storeFiles($pedidoExames, $pedidoExamesData['files'], $atendimentoExameImagem);
|
|
}
|
|
}
|
|
|
|
continue;
|
|
}
|
|
|
|
if (!is_numeric($pedidoExameRequestedId)) {
|
|
|
|
continue;
|
|
}
|
|
|
|
if (!$isForm && !$pedidoExamesAllowedChange->pluck('id')->contains($pedidoExameRequestedId)) {
|
|
|
|
throw new PedidoExameCannotChangeStatusException;
|
|
}
|
|
|
|
if (!$isForm) {
|
|
|
|
$this->requestedPedidoExamesAllowChangeStatus($pedidoExamesRequested, $pedidoExamesAllowedChange);
|
|
}
|
|
|
|
$pedidoExames = PedidoExame::findOrFail($pedidoExameRequestedId);
|
|
|
|
$pedidoExames->plantao_id = $pedidoExames->plantao_id ?? $plantaoId;
|
|
|
|
if (!$isForm) {
|
|
|
|
foreach (($pedidoExamesRequested['exames']) as $item) {
|
|
|
|
if ($item['disabled']) {
|
|
|
|
continue;
|
|
}
|
|
|
|
$pedidoItem = $pedidoExames->exames->firstWhere('id', $item['id']);
|
|
|
|
if ($pedidoItem->status_id != ($item['status_id'] ?? ExameStatusEnum::SOLICITADO)) {
|
|
|
|
$pedidoItem->exame_imagem_id = $atendimentoExameImagem->id;
|
|
$pedidoItem->status_id = $item['status_id'] ?? ExameStatusEnum::SOLICITADO;
|
|
$pedidoItem->horario_realizacao = $item['horario_realizacao'] ?? null;
|
|
|
|
$pedidoItem->save();
|
|
|
|
if ($item['status_id'] == ExameStatusEnum::REALIZADO) {
|
|
|
|
$this->addProcedimento($pedidoItem->fresh(), $atendimentoExameImagem);
|
|
}
|
|
|
|
$this->storeItemObservacao($pedidoItem, $item['observacao'] ?? null);
|
|
}
|
|
}
|
|
}
|
|
|
|
if(count($pedidoExamesRequested['files'] ?? []) > 0) {
|
|
|
|
$this->storeFiles($pedidoExames, $pedidoExamesRequested['files'], $atendimentoExameImagem);
|
|
}
|
|
|
|
$pedidoExames->save();
|
|
}
|
|
}
|
|
|
|
private function handleFatorRiscoOutro($atendimento, $params)
|
|
{
|
|
$atendimento->faa->paciente->cidadao->fator_risco_outro = null;
|
|
|
|
if (in_array(FatorRiscoEnum::OUTRO, $params['fatores_risco'] ?? [])) {
|
|
|
|
$atendimento->faa->paciente->cidadao->fator_risco_outro = $params['fator_risco_outro'] ?? null;
|
|
}
|
|
|
|
$atendimento->faa->paciente->cidadao->save();
|
|
}
|
|
|
|
private function prepareSinaisVitaisData($params, $atendimentoExameImagem)
|
|
{
|
|
$sinaisVitaisData = [];
|
|
|
|
foreach (($params['sinais_vitais'] ?? []) as $sinaisVitais) {
|
|
|
|
$sinaisVitaisData[] = [
|
|
'atendimento_exame_imagem_id' => $atendimentoExameImagem->id,
|
|
'pa' => $sinaisVitais['pa'] ?? null,
|
|
'pa_unidade_medida_id' => isset($sinaisVitais['pa'])
|
|
? $sinaisVitais['pa_unidade_medida_id']
|
|
: null,
|
|
'glicemia' => $sinaisVitais['glicemia'] ?? null,
|
|
'temperatura' => $sinaisVitais['temperatura'] ?? null,
|
|
'pulso' => $sinaisVitais['pulso'] ?? null,
|
|
'respiracao' => $sinaisVitais['respiracao'] ?? null,
|
|
'saturacao' => $sinaisVitais['saturacao'] ?? null,
|
|
'intensidade_dor' => $sinaisVitais['intensidade_dor'] ?? null,
|
|
'cintura' => $sinaisVitais['cintura'] ?? null,
|
|
];
|
|
}
|
|
|
|
return $sinaisVitaisData;
|
|
}
|
|
|
|
private function prepareMedicamentosUsoContinuoData(array $params) : array
|
|
{
|
|
$medicamentos = [];
|
|
|
|
foreach (($params['medicamentos_uso_continuo'] ?? []) as $medicamento) {
|
|
|
|
$medicamentos[] = $medicamento['medicamento_id'];
|
|
}
|
|
|
|
return $medicamentos;
|
|
}
|
|
|
|
private function addProcedimento($pedidoItem, $atendimentoExameImagem, $lotacaoExecutanteId = null)
|
|
{
|
|
$procedimento = $atendimentoExameImagem->atendimento->procedimentos()
|
|
->where('procedimento_id', $pedidoItem->exame->procedimento->id)
|
|
->first();
|
|
|
|
if (is_null($procedimento)) {
|
|
|
|
$lotacaoId = null;
|
|
|
|
if ($pedidoItem->pedidoExame->atendimentoMedico) {
|
|
|
|
$lotacaoId = $pedidoItem->pedidoExame->atendimentoMedico->created_lotacao_id;
|
|
}
|
|
else {
|
|
|
|
$lotacaoId = $lotacaoExecutanteId;
|
|
}
|
|
|
|
$atendimentoExameImagem->atendimento->procedimentos()->create([
|
|
'lotacao_id' => $lotacaoId,
|
|
'exame_imagem_id' => $atendimentoExameImagem->id,
|
|
'procedimento_id' => $pedidoItem->exame->procedimento->id,
|
|
'quantidade' => 1,
|
|
]);
|
|
}
|
|
else {
|
|
|
|
$procedimento->quantidade += 1;
|
|
|
|
$procedimento->save();
|
|
}
|
|
}
|
|
|
|
private function getPedidosExames($atendimento, $isForm = false)
|
|
{
|
|
$result = [];
|
|
|
|
foreach ($atendimento->pedidosExames as $pedidoExames) {
|
|
|
|
$exames = $this->getExamesPedidoExames($pedidoExames, $isForm);
|
|
|
|
$dataPedido = [
|
|
'id' => $pedidoExames->id,
|
|
'urgente' => $pedidoExames->urgente,
|
|
'data_solicitacao' => $pedidoExames->data_solicitacao
|
|
? $pedidoExames->data_solicitacao->format('d/m/Y')
|
|
: $pedidoExames->created_at->format('d/m/Y H:i'),
|
|
'medico_solicitante_encaminhamento' => $pedidoExames->medico_solicitante_encaminhamento,
|
|
'unidade_encaminhamento' => Unidade::find($pedidoExames->unidade_encaminhamento_id)
|
|
?? UnidadeExterna::find($pedidoExames->unidade_externa_encaminhamento_id)
|
|
?? null,
|
|
"centro_custo" => [
|
|
"infraestrutura" => $pedidoExames->createdLotacao->infraestrutura->unidade->nome_fantasia,
|
|
"setor" => $pedidoExames->createdCentroCusto->setor->nome
|
|
],
|
|
'lotacao' => [
|
|
'ocupacao' => [
|
|
'codigo' => $pedidoExames->createdLotacao->ocupacao->codigo,
|
|
'nome' => $pedidoExames->createdLotacao->ocupacao->nome
|
|
],
|
|
'profissional' => [
|
|
'nome' => $pedidoExames->createdLotacao->usuario->cidadao->nome,
|
|
]
|
|
],
|
|
'justificativa' => $pedidoExames->justificativa,
|
|
'exames' => $exames,
|
|
'files' => $pedidoExames->laudos
|
|
->where('created_at', '>=', $pedidoExames->created_at)
|
|
->map(fn($laudo) => [
|
|
'id' => $laudo->id,
|
|
'name' => $laudo->nome,
|
|
'hash' => $laudo->hash
|
|
])
|
|
];
|
|
|
|
if ($isForm && !$this->hasExamesImagemSolicitadosOrAguardandoResultado($pedidoExames)) {
|
|
|
|
$result[] = $dataPedido;
|
|
}
|
|
|
|
if (!$isForm && $this->hasExamesImagemSolicitadosOrAguardandoResultado($pedidoExames)) {
|
|
|
|
$result[] = $dataPedido;
|
|
}
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
|
|
private static function getFatoresRisco()
|
|
{
|
|
$result = FatorRisco::orderBy('id')
|
|
->whereIn('id', [
|
|
FatorRiscoEnum::CANCERO,
|
|
FatorRiscoEnum::DIABETES,
|
|
FatorRiscoEnum::ETILISMO,
|
|
FatorRiscoEnum::HIPERTENSAO,
|
|
FatorRiscoEnum::OBESIDADE,
|
|
FatorRiscoEnum::PERFIL_SANGUINEO_ALTERADO,
|
|
FatorRiscoEnum::RADIOTERAPIA,
|
|
FatorRiscoEnum::TABAGISMO,
|
|
FatorRiscoEnum::USO_DE_MEDICAMENTOS_ANTINEOPLASICOS_OU_IMUNOSSUPRESSORES,
|
|
FatorRiscoEnum::OUTRO,
|
|
])
|
|
->get()
|
|
->map(fn ($fatorRisco) => [
|
|
'id' => $fatorRisco->id,
|
|
'nome' => $fatorRisco->nome,
|
|
]);
|
|
|
|
return $result;
|
|
}
|
|
|
|
private static function getFatoresRiscoGestante()
|
|
{
|
|
$result = FatorRisco::orderBy('nome')
|
|
->whereIn('id', [
|
|
FatorRiscoEnum::CANCERO,
|
|
FatorRiscoEnum::DIABETES,
|
|
FatorRiscoEnum::ETILISMO,
|
|
FatorRiscoEnum::HIPERTENSAO,
|
|
FatorRiscoEnum::OBESIDADE,
|
|
FatorRiscoEnum::PERFIL_SANGUINEO_ALTERADO,
|
|
FatorRiscoEnum::RADIOTERAPIA,
|
|
FatorRiscoEnum::TABAGISMO,
|
|
FatorRiscoEnum::USO_DE_MEDICAMENTOS_ANTINEOPLASICOS_OU_IMUNOSSUPRESSORES,
|
|
FatorRiscoEnum::OUTRO,
|
|
FatorRiscoEnum::GESTANTE,
|
|
])
|
|
->get()
|
|
->map(fn ($fatorRisco) => [
|
|
'id' => $fatorRisco->id,
|
|
'nome' => $fatorRisco->nome,
|
|
]);
|
|
|
|
return $result;
|
|
}
|
|
|
|
private function getSinaisVitais($atendimento, $datetime)
|
|
{
|
|
$sinaisVitais = $atendimento->sinaisVitais()->where('created_at', '<=', $datetime)->get();
|
|
$result = [];
|
|
|
|
foreach ($sinaisVitais as $sinalVital) {
|
|
|
|
$result[] = [
|
|
'id' => $sinalVital->id,
|
|
'pa' => $sinalVital->pa,
|
|
'pa_unidade_medida_id' => $sinalVital->pa_unidade_medida_id,
|
|
'glicemia' => $sinalVital->glicemia,
|
|
'glicemia_unidade_medida_id' => UnidadeMedidaEnum::MILIGRAMAS_POR_DECILITRO,
|
|
'temperatura' => $sinalVital->temperatura,
|
|
'temperatura_unidade_medida_id' => UnidadeMedidaEnum::CELSIUS,
|
|
'pulso' => $sinalVital->pulso,
|
|
'pulso_unidade_medida_id' => UnidadeMedidaEnum::BATIMENTOS_POR_MINUTO,
|
|
'respiracao' => $sinalVital->respiracao,
|
|
'respiracao_unidade_medida_id' => UnidadeMedidaEnum::MOVIMENTOS_POR_MINUTO,
|
|
'saturacao' => $sinalVital->saturacao,
|
|
'saturacao_unidade_medida_id' => UnidadeMedidaEnum::PORCENTAGEM,
|
|
'intensidade_dor' => $sinalVital->intensidade_dor,
|
|
'intensidade_dor_unidade_medida_id' => UnidadeMedidaEnum::NIVEL_DE_DOR,
|
|
'cintura' => $sinalVital->cintura,
|
|
'cintura_unidade_medida_id' => UnidadeMedidaEnum::CENTIMETROS,
|
|
'lotacao' => [
|
|
'ocupacao' => [
|
|
'id' => $sinalVital->createdLotacao->ocupacao->id ?? null,
|
|
'codigo' => $sinalVital->createdLotacao->ocupacao->codigo ?? null,
|
|
'nome' => $sinalVital->createdLotacao->ocupacao->nome ?? null,
|
|
],
|
|
'profissional' => [
|
|
'nome' => $sinalVital->createdLotacao->usuario->cidadao->nome ?? null,
|
|
],
|
|
],
|
|
'centro_custo' => [
|
|
'setor' => [
|
|
'nome' => $sinalVital->createdCentroCusto->setor->nome ?? null,
|
|
],
|
|
],
|
|
'classificacao_risco' => [
|
|
'nome' => (
|
|
$sinalVital->atendimentoMedico
|
|
?? $sinalVital->atendimentoTriagem
|
|
?? $sinalVital->atendimentoEnfermagem
|
|
?? $sinalVital->pacienteObservacao
|
|
)->classificacaoRisco->classificacaoRisco->nome ?? null,
|
|
],
|
|
'data_hora' => $sinalVital->created_at->format('d/m/Y H:i:s'),
|
|
];
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
|
|
private function getUnidadesMedida()
|
|
{
|
|
return UnidadeMedida::all()->map(function($query) {
|
|
return [
|
|
'id' => $query->id,
|
|
'nome' => $query->nome,
|
|
'sigla' => $query->sigla,
|
|
];
|
|
});
|
|
}
|
|
|
|
private function getCidadaoFatoresRisco($atendimento)
|
|
{
|
|
$cidadao = $atendimento->faa->paciente->cidadao;
|
|
$fatoresRisco = $cidadao->fatoresRisco;
|
|
$result = [];
|
|
|
|
foreach ($fatoresRisco as $fatorRisco) {
|
|
$result[] = $fatorRisco->cidadaoFatorRisco->fator_risco_id;
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
|
|
private function requestedPedidoExamesAllowChangeStatus($pedidoExamesRequested, $pedidoExamesAllowedChange)
|
|
{
|
|
$pedidoExamesAllowedIds = $pedidoExamesAllowedChange
|
|
->firstWhere('id', $pedidoExamesRequested['id'])['exames']->pluck('exame.id', 'id');
|
|
|
|
foreach ($pedidoExamesRequested['exames'] as $item) {
|
|
|
|
$exameIdAllowed = $pedidoExamesAllowedIds[$item['id']];
|
|
|
|
if ($exameIdAllowed != $item['exame_id']) {
|
|
|
|
throw new PedidoExameItemCannotChangeStatusException;
|
|
}
|
|
}
|
|
}
|
|
|
|
private function preparePedidoExamesData($atendimentoExameImagem, $pedidoExames, $plantaoId)
|
|
{
|
|
$result = [
|
|
'atendimento_id' => $atendimentoExameImagem->atendimento->id,
|
|
'data_solicitacao' => Carbon::createFromFormat('d/m/Y', $pedidoExames['data_solicitacao']) ?? null,
|
|
'unidade_encaminhamento_id' => $pedidoExames['unidade_encaminhamento_id'] ?? null,
|
|
'unidade_externa_encaminhamento_id' => $pedidoExames['unidade_externa_encaminhamento_id'] ?? null,
|
|
'medico_solicitante_encaminhamento' => $pedidoExames['medico_solicitante_encaminhamento'] ?? null,
|
|
'plantao_id' => $plantaoId,
|
|
'urgente' => $pedidoExames['urgente'],
|
|
'justificativa' => $pedidoExames['justificativa'],
|
|
'files' => $pedidoExames['files'] ?? [],
|
|
'exames' => [],
|
|
];
|
|
|
|
foreach ($pedidoExames['exames'] as $item) {
|
|
|
|
$result['exames'][] = [
|
|
'exame_imagem_id' => $atendimentoExameImagem->id,
|
|
'disabled' => $item['disabled'],
|
|
'exame_id' => $item['exame_id'],
|
|
'status_id' => $item['status_id'] ?? ExameStatusEnum::SOLICITADO,
|
|
'observacao' => $item['observacao'] ?? null,
|
|
'horario_realizacao' => $item['horario_realizacao'] ?? null,
|
|
'lotacao_executante_id' => $pedidoExames['lotacao_executante_id'] ?? null,
|
|
];
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
|
|
private function storePedidoExamesItens($pedidoExames, $itens, $atendimentoExameImagem)
|
|
{
|
|
foreach ($itens as $item) {
|
|
|
|
$pedidoItem = $pedidoExames->exames()->create($item);
|
|
|
|
if ($item['status_id'] == ExameStatusEnum::REALIZADO) {
|
|
|
|
$this->addProcedimento($pedidoItem, $atendimentoExameImagem, $item['lotacao_executante_id']);
|
|
}
|
|
|
|
$this->storeItemObservacao($pedidoItem, $item['observacao'] ?? null);
|
|
}
|
|
}
|
|
|
|
private function storeFiles($pedidoExame, $files, $atendimentoExameImagem)
|
|
{
|
|
$laudoService = new LaudoService();
|
|
$laudoService->storeFile($pedidoExame, $files, ['exame_imagem_id' => $atendimentoExameImagem->id]);
|
|
}
|
|
|
|
private function storeItemObservacao($item, $observacao)
|
|
{
|
|
if (!is_null($observacao ?? null)) {
|
|
|
|
$item->observacoes()->create([
|
|
'observacao' => $observacao
|
|
]);
|
|
}
|
|
}
|
|
|
|
private function getLotacao()
|
|
{
|
|
$lotacao = $this->getLotacaoLogado();
|
|
|
|
return [
|
|
'ocupacao' => [
|
|
'codigo' => $lotacao->ocupacao->codigo,
|
|
'nome' => $lotacao->ocupacao->nome,
|
|
],
|
|
'profissional' => [
|
|
'id' => $lotacao->usuario->id,
|
|
'nome' => $lotacao->usuario->cidadao->nome,
|
|
],
|
|
];
|
|
}
|
|
|
|
private function getLotacaoLogado()
|
|
{
|
|
return Lotacao::findOrFail(auth()->payload()->get('lotacao_id'));
|
|
}
|
|
|
|
private function getClassificacoesRisco()
|
|
{
|
|
return ClassificacaoRisco::all()->map(function($query) {
|
|
return [
|
|
'id' => $query->id,
|
|
'nome' => $query->nome,
|
|
'cor' => $query->tipo->cor,
|
|
'cor_nome' => $query->tipo->cor_nome,
|
|
];
|
|
});
|
|
}
|
|
|
|
private function getPaciente($atendimento)
|
|
{
|
|
return [
|
|
'id' => $atendimento->faa->paciente->id,
|
|
'nome' => $atendimento->faa->paciente->cidadao->nome,
|
|
'nome_social' => $atendimento->faa->paciente->cidadao->nome_social,
|
|
'preferencia_nome_id' => $atendimento->faa->paciente->cidadao->preferencia_nome_id,
|
|
'prontuario' => $atendimento->faa->paciente->prontuario,
|
|
'idade' => $atendimento->faa->paciente->cidadao->idade,
|
|
'sexo' => $atendimento->faa->paciente->cidadao->sexo,
|
|
'pcd' => $this->getPcd($atendimento->faa->paciente->cidadao)
|
|
];
|
|
}
|
|
|
|
private function getPcd($cidadao)
|
|
{
|
|
if ($cidadao->deficiencia_id === null) {
|
|
|
|
return null;
|
|
}
|
|
|
|
$deficiencia = [
|
|
'id' => $cidadao->deficiencia->id,
|
|
'deficiencia_base_id' => $cidadao->deficiencia->deficiencia_base_id,
|
|
'descricao' => $cidadao->deficiencia->descricao,
|
|
];
|
|
|
|
if ($cidadao->deficiencia->deficiencia_base_id === Deficiencia::OUTRA) {
|
|
|
|
$deficiencia['deficiencia_outro'] = $cidadao->deficiencia_outro;
|
|
|
|
return $deficiencia;
|
|
}
|
|
|
|
return $deficiencia;
|
|
}
|
|
|
|
private function getExamesPedidoExames($pedidoExames, $isForm)
|
|
{
|
|
$result = [];
|
|
$itens = $pedidoExames->exames();
|
|
|
|
return $itens->get()
|
|
->map(function ($item) {
|
|
|
|
$anoMes = $item->data_solicitacao
|
|
? $item->data_solicitacao->format('Ym')
|
|
: $item->created_at->format('Ym');
|
|
|
|
$competencias = Competencia::orderByDesc('valor')->take(4)->get();
|
|
$competencia = $competencias->firstWhere('valor', $anoMes);
|
|
|
|
if (is_null($competencia)) {
|
|
|
|
$competencia = $competencias->first();
|
|
};
|
|
|
|
if ($item->exame->procedimento)
|
|
$procedimentoServiceValidation = new ProcedimentoValidationService(
|
|
Procedimento::where('codigo', $item->exame->procedimento->codigo)
|
|
->where('competencia_id', $competencia->id)
|
|
->first()
|
|
);
|
|
|
|
$disabled =
|
|
$item->status_id === ExameStatusEnum::REALIZADO
|
|
|| $item->status_id === ExameStatusEnum::NAO_REALIZADO
|
|
|| $item->exame->tipo_id === ExameTipo::LABORATORIAL;
|
|
|
|
return [
|
|
'id' => $item->id,
|
|
'disabled' => $disabled,
|
|
'horario_realizacao' => $item->horario_realizacao,
|
|
'exame' => [
|
|
'id' => $item->exame->id,
|
|
'nome' => $item->exame->nome,
|
|
'observacao' => $item->exame->observacao,
|
|
'tipo' => [
|
|
'id' => $item->exame->tipo->id,
|
|
'nome' => $item->exame->tipo->nome,
|
|
],
|
|
'procedimento' => [
|
|
'codigo' => $item->exame->procedimento->codigo ?? null,
|
|
'nome' => $item->exame->procedimento->nome ?? null,
|
|
],
|
|
],
|
|
'status' => [
|
|
'id' => $item->status->id,
|
|
'nome' => $item->status->nome,
|
|
],
|
|
];
|
|
});
|
|
}
|
|
|
|
private function hasExamesImagemSolicitadosOrAguardandoResultado($pedidoExames)
|
|
{
|
|
foreach($pedidoExames->exames as $item) {
|
|
|
|
if($item->exame->tipo_id === ExameTipo::IMAGEM) {
|
|
|
|
if($item->status_id === ExameStatusEnum::SOLICITADO) {
|
|
return true;
|
|
}
|
|
else if($item->status_id === ExameStatusEnum::AGUARDANDO_RESULTADO) {
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
private function getClassificacaoRisco($atendimento)
|
|
{
|
|
if (is_null($atendimento)) {
|
|
|
|
return null;
|
|
}
|
|
|
|
$classificacaoRisco = $atendimento->classificacoesRisco()
|
|
->get()
|
|
->sortByDesc('created_at')
|
|
->first();
|
|
|
|
if ($classificacaoRisco == null)
|
|
return null;
|
|
|
|
return [
|
|
'id' => $classificacaoRisco->id,
|
|
'classificacao_risco_id' => $classificacaoRisco->classificacao_risco_id,
|
|
'nome' => $classificacaoRisco->classificacaoRisco->nome,
|
|
];
|
|
}
|
|
|
|
private function getMedicosComPlantao()
|
|
{
|
|
$currentCentroCusto = self::getCurrentCentroCusto();
|
|
|
|
return DB::table('cadastro_usuario')
|
|
->select([
|
|
'cadastro_lotacao.id',
|
|
DB::raw("CONCAT(cadastro_cidadao.nome, ' - ', ocupacao.nome) AS descricao"),
|
|
'ocupacao.codigo AS cbo',
|
|
])
|
|
->join('cadastro_cidadao', 'cadastro_cidadao.id', 'cadastro_usuario.cidadao_id')
|
|
->join('cadastro_lotacao', 'cadastro_lotacao.usuario_id', 'cadastro_usuario.id')
|
|
->join('sigtap.ocupacao', 'ocupacao.id', 'cadastro_lotacao.ocupacao_id')
|
|
->join('pronto_atendimento_plantao', 'pronto_atendimento_plantao.lotacao_id', 'cadastro_lotacao.id')
|
|
->whereNull('pronto_atendimento_plantao.deleted_at')
|
|
->whereIn('pronto_atendimento_plantao.status_id', [Status::CONFIRMADO, Status::COM_ATENDIMENTO_AGENDADO])
|
|
->where('pronto_atendimento_plantao.servico_id', Servico::CONSULTA_MEDICA)
|
|
->whereRaw('pronto_atendimento_plantao.inicio <= CURRENT_TIMESTAMP')
|
|
->whereRaw('pronto_atendimento_plantao.fim >= CURRENT_TIMESTAMP')
|
|
->where('cadastro_lotacao.infraestrutura_id', $currentCentroCusto->infraestrutura_id)
|
|
->get();
|
|
}
|
|
|
|
private static function getCaracteristicaDor()
|
|
{
|
|
$caracteristicasEnum = [
|
|
DorToracicaEnum::CONTRICAO,
|
|
DorToracicaEnum::QUEIMACAO,
|
|
DorToracicaEnum::COMPRESSAO,
|
|
DorToracicaEnum::PESO,
|
|
DorToracicaEnum::DOR_SURDA
|
|
];
|
|
|
|
$result = OrigemDorToracica::whereIn('id', $caracteristicasEnum)
|
|
->orderBy('id')
|
|
->get()
|
|
->map(fn ($dorToracica) => [
|
|
'id' => $dorToracica->id,
|
|
'nome' => $dorToracica->nome,
|
|
]);
|
|
|
|
return $result;
|
|
}
|
|
|
|
private static function getLocalizacaoDor()
|
|
{
|
|
$caracteristicasEnum = [
|
|
DorToracicaEnum::RETROESTERNAL,
|
|
DorToracicaEnum::MSE,
|
|
DorToracicaEnum::FACE,
|
|
DorToracicaEnum::PESCOCO,
|
|
DorToracicaEnum::DENTES,
|
|
DorToracicaEnum::INTER_ESCAPULAR,
|
|
DorToracicaEnum::EPIGASTRICA,
|
|
];
|
|
|
|
$result = OrigemDorToracica::whereIn('id', $caracteristicasEnum)
|
|
->orderBy('id')
|
|
->get()
|
|
->map(fn ($dorToracica) => [
|
|
'id' => $dorToracica->id,
|
|
'nome' => $dorToracica->nome,
|
|
]);
|
|
|
|
return $result;
|
|
}
|
|
|
|
private static function getFatorDesencadeante()
|
|
{
|
|
$caracteristicasEnum = [
|
|
DorToracicaEnum::EXERCICIO,
|
|
DorToracicaEnum::EXCITACAO,
|
|
DorToracicaEnum::ESTRESSE,
|
|
DorToracicaEnum::FRIO,
|
|
DorToracicaEnum::REFEICOES_COPIOSAS,
|
|
];
|
|
|
|
$result = OrigemDorToracica::whereIn('id', $caracteristicasEnum)
|
|
->orderBy('id')
|
|
->get()
|
|
->map(fn ($dorToracica) => [
|
|
'id' => $dorToracica->id,
|
|
'nome' => $dorToracica->nome,
|
|
]);
|
|
|
|
return $result;
|
|
}
|
|
|
|
private static function getFatoresRiscoToracica()
|
|
{
|
|
$caracteristicasEnum = [
|
|
DorToracicaEnum::HAS,
|
|
DorToracicaEnum::DM,
|
|
DorToracicaEnum::DISLIPIDEMIA,
|
|
DorToracicaEnum::HISTORIA_FAMILIAR,
|
|
DorToracicaEnum::IDADE_MAIOR_SESSENTA,
|
|
DorToracicaEnum::OBESIDADE,
|
|
DorToracicaEnum::TABAGISMO,
|
|
DorToracicaEnum::REVASCULARIZADO_PREVIO,
|
|
];
|
|
|
|
$result = OrigemDorToracica::whereIn('id', $caracteristicasEnum)
|
|
->orderBy('id')
|
|
->get()
|
|
->map(fn ($dorToracica) => [
|
|
'id' => $dorToracica->id,
|
|
'nome' => $dorToracica->nome,
|
|
]);
|
|
|
|
return $result;
|
|
}
|
|
|
|
private static function getDuracaoDor()
|
|
{
|
|
$result = OrigemDorToracica::orderBy('id')
|
|
->where('id', '=', DorToracicaEnum::DURACAO_DA_DOR)
|
|
->get()
|
|
->map(fn ($duracao) => [
|
|
'id' => $duracao->id,
|
|
'nome' => $duracao->nome,
|
|
]);
|
|
|
|
return $result;
|
|
}
|
|
}
|