This commit is contained in:
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\ProntoAtendimento\Atendimento;
|
||||
|
||||
use App\Enums\ProntoAtendimento\ClassificacaoRisco;
|
||||
use App\Models\ProntoAtendimento\Atendimento\Atendimento;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class AtendimentoService
|
||||
{
|
||||
public static function getTimelineItems($filaId)
|
||||
{
|
||||
$atendimento = Atendimento::where('fila_id', $filaId)->firstOrFail();
|
||||
$items = collect();
|
||||
|
||||
$items->push([
|
||||
'date_time' => new Carbon($atendimento->recepcao->atendido_em),
|
||||
'title' => 'Recepção',
|
||||
'label' => $atendimento->fila->senha,
|
||||
'disabled' => true,
|
||||
]);
|
||||
|
||||
$atendimento->atendimentosTriagem->each(fn ($atendimento) => $items->push([
|
||||
'date_time' => $atendimento->created_at,
|
||||
'title' => 'Triagem',
|
||||
'disabled' => false,
|
||||
'list_class' => self::getClassificacaoRiscoCssClass(
|
||||
$atendimento->classificacaoRisco->classificacao_risco_id ?? null
|
||||
),
|
||||
]));
|
||||
|
||||
$atendimento->atendimentosMedico->each(fn ($atendimento) => $items->push([
|
||||
'date_time' => $atendimento->created_at,
|
||||
'title' => 'Atendimento médico',
|
||||
'disabled' => false,
|
||||
'list_class' => self::getClassificacaoRiscoCssClass(
|
||||
$atendimento->classificacaoRisco->classificacao_risco_id ?? null
|
||||
),
|
||||
]));
|
||||
|
||||
$atendimento->atendimentosEnfermagem->each(fn ($atendimento) => $items->push([
|
||||
'date_time' => $atendimento->created_at,
|
||||
'title' => 'Enfermagem',
|
||||
'disabled' => false,
|
||||
'list_class' => self::getClassificacaoRiscoCssClass(
|
||||
$atendimento->classificacaoRisco->classificacao_risco_id ?? null
|
||||
),
|
||||
]));
|
||||
|
||||
$atendimento->atendimentosExameImagem->each(fn ($atendimento) => $items->push([
|
||||
'date_time' => $atendimento->created_at,
|
||||
'title' => 'Exames de imagem',
|
||||
'disabled' => false,
|
||||
]));
|
||||
|
||||
$atendimento->pacienteObservacoes->each(fn ($atendimento) => $items->push([
|
||||
'date_time' => $atendimento->created_at,
|
||||
'title' => 'Observação',
|
||||
'disabled' => false,
|
||||
'list_class' => self::getClassificacaoRiscoCssClass(
|
||||
$atendimento->classificacaoRisco->classificacao_risco_id ?? null
|
||||
),
|
||||
]));
|
||||
|
||||
return $items
|
||||
->sortBy('date_time')
|
||||
->map(function ($item) {
|
||||
|
||||
$item['date_time'] = $item['date_time']->format('d/m/Y H:i');
|
||||
|
||||
return $item;
|
||||
})
|
||||
->values();
|
||||
}
|
||||
|
||||
private static function getClassificacaoRiscoCssClass($classificacaoRiscoId)
|
||||
{
|
||||
$class = 'pronto-atendimento-classificacao-risco-';
|
||||
|
||||
switch ($classificacaoRiscoId) {
|
||||
|
||||
case ClassificacaoRisco::NAO_URGENTE: {
|
||||
|
||||
return $class . 'NAO_URGENTE';
|
||||
}
|
||||
case ClassificacaoRisco::POUCO_URGENTE: {
|
||||
|
||||
return $class . 'POUCO_URGENTE';
|
||||
}
|
||||
case ClassificacaoRisco::URGENTE: {
|
||||
|
||||
return $class . 'URGENTE';
|
||||
}
|
||||
case ClassificacaoRisco::MUITO_URGENTE: {
|
||||
|
||||
return $class . 'MUITO_URGENTE';
|
||||
}
|
||||
case ClassificacaoRisco::EMERGENCIA: {
|
||||
|
||||
return $class . 'EMERGENCIA';
|
||||
}
|
||||
default: {
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user