91 lines
3.1 KiB
PHP
91 lines
3.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Impressao\Ambulatorio;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Enums\Ambulatorio\FeridaStatus;
|
|
use App\Models\Cadastro\Especialidade;
|
|
use App\Models\Cadastro\Estabelecimento\Infraestrutura;
|
|
use App\Models\Cadastro\Estabelecimento\Unidade;
|
|
use App\Models\Cadastro\SujeitoAtencao\Usuario;
|
|
use App\Models\Sigtap\Ocupacao;
|
|
use App\Services\Ambulatorio\RelatorioRastreioFeridaService;
|
|
use App\Utils\Exports\Pdf1;
|
|
use Carbon\Carbon;
|
|
|
|
class RelatorioRastreioFeridasController extends Controller
|
|
{
|
|
private const TITLE = 'RELATÓRIO DE RASTREIO DE FERIDAS';
|
|
private const TEMPLATE = 'ambulatorio.relatorio-rastreio-feridas';
|
|
|
|
public static function getTemplate()
|
|
{
|
|
$itens = RelatorioRastreioFeridaService::index();
|
|
$unidade = Unidade::find(request()->unidade_id);
|
|
$infraestrutura = Infraestrutura::find(request()->infraestrutura_id);
|
|
$especialidade = Especialidade::find(request()->especialidade_id);
|
|
$usuario = Usuario::find(request()->usuario_id);
|
|
$ocupacao = Ocupacao::find(request()->ocupacao_id);
|
|
$status = request()->status_id;
|
|
|
|
if (!is_null($status)) {
|
|
switch ($status) {
|
|
case FeridaStatus::ATIVO:
|
|
$status = (object) ['nome' => 'Ativo'];
|
|
break;
|
|
|
|
case FeridaStatus::CICATRIZADA:
|
|
$status = (object) ['nome' => 'Cicatrizada'];
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
}else{
|
|
|
|
$status = (object) ['nome' => 'Todos'];
|
|
}
|
|
|
|
if (isset($itens['atendimentos']) && is_array($itens['atendimentos'])) {
|
|
$itens['atendimentos'] = collect($itens['atendimentos'])->map(function ($atendimento) {
|
|
switch ((int) ($atendimento['cicatrizada'] ?? -1)) {
|
|
case FeridaStatus::ATIVO:
|
|
$atendimento['cicatrizada'] = 'Ativo';
|
|
break;
|
|
|
|
case FeridaStatus::CICATRIZADA:
|
|
$atendimento['cicatrizada'] = 'Cicatrizada';
|
|
break;
|
|
|
|
default:
|
|
$atendimento['cicatrizada'] = '-';
|
|
break;
|
|
}
|
|
|
|
return $atendimento;
|
|
})->toArray();
|
|
}
|
|
|
|
return [
|
|
'periodo' => [
|
|
'inicio' => request()->periodo['start'],
|
|
'fim' => request()->periodo['end'],
|
|
],
|
|
'unidade' => $unidade->nome_fantasia ?? 'Todas',
|
|
'infraestrutura' => $infraestrutura->nome ?? 'Todas',
|
|
'especialidade' => $especialidade->nome ?? 'Todas',
|
|
'usuario' => $usuario->nome ?? 'Todos',
|
|
'cbo' => $ocupacao->codigo ?? 'Todos',
|
|
'status' => $status->nome,
|
|
'colunas' => collect(request()->columns),
|
|
'itens' => $itens,
|
|
];
|
|
|
|
}
|
|
|
|
public function __invoke()
|
|
{
|
|
return Pdf1::generate(self::TITLE, self::TEMPLATE, self::getTemplate(), $orientation = 'landscape');
|
|
}
|
|
}
|