44 lines
1.3 KiB
PHP
44 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Impressao\ProntoAtendimento;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\ProntoAtendimento\Atendimento\Atendimento;
|
|
use App\Utils\Exports\Pdf;
|
|
use App\Utils\Exports\Template;
|
|
use App\Utils\MaskUtil;
|
|
use Carbon\Carbon;
|
|
|
|
class TermoCienciaController extends Controller
|
|
{
|
|
private const TITLE = 'TERMO DE CIÊNCIA';
|
|
private const TEMPLATE = 'pronto-atendimento.termo-ciencia';
|
|
|
|
public static function getTemplate($atendimentoId)
|
|
{
|
|
$faa = Atendimento::findOrFail($atendimentoId)->faa;
|
|
$now = Carbon::now();
|
|
|
|
$data = [
|
|
'faa' => [
|
|
'numero' => $faa->numero,
|
|
'unidade' => [
|
|
'nome' => $faa->createdCentroCusto->infraestrutura->unidade->nome_fantasia
|
|
]
|
|
],
|
|
'paciente' => [
|
|
'nome' => $faa->paciente->cidadao->nome,
|
|
'cns' => $faa->paciente->cidadao->cns ? MaskUtil::getCnsMasked($faa->paciente->cidadao->cns) : '',
|
|
],
|
|
'dataHora' => $now->format('H') . ' horas e ' . $now->format('i') . ' minutos'
|
|
];
|
|
|
|
return Template::make(self::TITLE, self::TEMPLATE)->withData($data)->getHtml();
|
|
}
|
|
|
|
public function __invoke($atendimentoId)
|
|
{
|
|
return (new Pdf)->stream(self::getTemplate($atendimentoId), self::TITLE);
|
|
}
|
|
}
|