304 lines
13 KiB
PHP
304 lines
13 KiB
PHP
@extends('impressoes.layout-receita-especial.impressao', [
|
|
'paraAssinar' => !$exibirAssinatura,
|
|
'receita' => collect($receitas)->first() ?? []
|
|
])
|
|
|
|
@section('conteudo')
|
|
@php
|
|
function countRecomendacoes($html)
|
|
{
|
|
$lines = 0;
|
|
|
|
if (empty($html)) {
|
|
return $lines;
|
|
}
|
|
|
|
$dom = new \DOMDocument();
|
|
|
|
libxml_use_internal_errors(true);
|
|
$dom->loadHTML($html);
|
|
libxml_clear_errors();
|
|
|
|
$tags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p'];
|
|
|
|
foreach ($tags as $tag) {
|
|
$elements = $dom->getElementsByTagName($tag);
|
|
|
|
foreach ($elements as $el) {
|
|
$lines += ceil(mb_strlen($el->textContent) / 90);
|
|
}
|
|
}
|
|
|
|
return (int) $lines;
|
|
}
|
|
@endphp
|
|
|
|
@foreach($receitas as $receita)
|
|
@php
|
|
$medicamentosSeparados = $receita['medicamentos']->filter(fn ($m) => $m['imprimirSeparado'])->values();
|
|
$medicamentosUsoContinuo = $receita['medicamentos']->filter(fn ($m) => !$m['imprimirSeparado'] && $m['usoContinuo'])->values();
|
|
$demaisMedicamentos = $receita['medicamentos']->filter(fn ($m) => !$m['imprimirSeparado'] && !$m['usoContinuo'])->values();
|
|
|
|
$hasMedicamentosSeparados = $medicamentosSeparados->isNotEmpty();
|
|
$hasMedicamentosUsoContinuo = $medicamentosUsoContinuo->isNotEmpty();
|
|
$hasDemaisMedicamentos = $demaisMedicamentos->isNotEmpty();
|
|
@endphp
|
|
|
|
@foreach($medicamentosSeparados as $medicamento)
|
|
<div class="page font-small">
|
|
<div class="row">
|
|
@for($via = 1; $via <= 2; $via++)
|
|
<div class="cell col-5" style="padding-{{ $via == 1 ? 'right' : 'left' }}: 15px;">
|
|
<div class="medicamento">
|
|
<table class="card">
|
|
<tbody>
|
|
<tr class="card-top">
|
|
<td
|
|
style="border-bottom: 1px solid #000; padding: 5px"
|
|
colspan="{{ $medicamento['usoContinuo'] || $medicamento['doseUnica'] ? 1 : 2 }}"
|
|
>
|
|
<strong>{{ sprintf('%02d', 1) }} - {{ $medicamento['nome'] }}</strong>
|
|
</td>
|
|
|
|
@if($medicamento['usoContinuo'] || $medicamento['doseUnica'])
|
|
<td class="text-right" style="border-bottom: 1px solid #000; width: 80px">
|
|
@if($medicamento['usoContinuo'])
|
|
uso contínuo
|
|
@elseif($medicamento['doseUnica'])
|
|
dose única
|
|
@endif
|
|
</td>
|
|
@endif
|
|
</tr>
|
|
|
|
<tr class="card-middle">
|
|
<td style="padding-top: 5px;">
|
|
{{ $medicamento['posologia'] }}
|
|
@if($medicamento['duracao'])
|
|
durante
|
|
{{ $medicamento['duracao'] }}
|
|
{{ $medicamento['duracaoMedida'] }}
|
|
@endif
|
|
</td>
|
|
|
|
<td class="text-right" style="padding-top: 5px;">
|
|
<strong>Via: </strong>
|
|
{{ $medicamento['viaAdministracao'] }}
|
|
</td>
|
|
</tr>
|
|
<tr class="card-bottom">
|
|
<td colspan="2">
|
|
@if(!$medicamento['livre'])
|
|
<strong>Recomendações:</strong> {!! $medicamento['recomendacoes'] !!}
|
|
@endif
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
@endfor
|
|
</div>
|
|
</div>
|
|
@endforeach
|
|
|
|
@php
|
|
$medicamentosImpressos = 0;
|
|
$quantidadesLinhasRecomendacoesAnterior = 0;
|
|
@endphp
|
|
|
|
@foreach($medicamentosUsoContinuo as $i => $medicamento)
|
|
@php
|
|
$quantidadeLinhasRecomendacoes = countRecomendacoes($medicamento['recomendacoes']);
|
|
$pageBreakBefore = false;
|
|
|
|
if ($i === 0) {
|
|
|
|
if ($hasMedicamentosSeparados) {
|
|
|
|
$pageBreakBefore = true;
|
|
}
|
|
}
|
|
else {
|
|
|
|
if ($medicamentosImpressos === 2
|
|
|| ($quantidadesLinhasRecomendacoesAnterior + $quantidadeLinhasRecomendacoes) > 5
|
|
) {
|
|
|
|
$pageBreakBefore = true;
|
|
$medicamentosImpressos = 0;
|
|
}
|
|
}
|
|
|
|
$medicamentosImpressos++;
|
|
$quantidadesLinhasRecomendacoesAnterior = $quantidadeLinhasRecomendacoes;
|
|
@endphp
|
|
|
|
<div class="row font-small" style="{{ $pageBreakBefore ? 'page-break-before: always;' : '' }}">
|
|
@for($via = 1; $via <= 2; $via++)
|
|
<div class="cell col-5" style="padding-{{ $via == 1 ? 'right' : 'left' }}: 15px;">
|
|
<div class="medicamento">
|
|
<table class="card">
|
|
<tbody>
|
|
<tr class="card-top">
|
|
<td style="border-bottom: 1px solid #000; padding: 5px">
|
|
<strong>{{ sprintf('%02d', $i + 1) }} - {{ $medicamento['nome'] }}</strong>
|
|
</td>
|
|
|
|
<td class="text-right" style="border-bottom: 1px solid #000; width: 80px">
|
|
uso contínuo
|
|
</td>
|
|
</tr>
|
|
|
|
<tr class="card-middle">
|
|
<td style="padding-top: 5px;">
|
|
{{ $medicamento['posologia'] }}
|
|
@if($medicamento['duracao'])
|
|
durante
|
|
{{ $medicamento['duracao'] }}
|
|
{{ $medicamento['duracaoMedida'] }}
|
|
@endif
|
|
</td>
|
|
|
|
<td class="text-right" style="padding-top: 5px;">
|
|
<strong>Via: </strong>
|
|
{{ $medicamento['viaAdministracao'] }}
|
|
</td>
|
|
</tr>
|
|
<tr class="card-bottom">
|
|
<td colspan="2">
|
|
@if(!$medicamento['livre'])
|
|
<strong>Recomendações:</strong> {!! $medicamento['recomendacoes'] !!}
|
|
@endif
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
@endfor
|
|
</div>
|
|
@endforeach
|
|
|
|
@php
|
|
$medicamentosImpressos = 0;
|
|
$quantidadesLinhasRecomendacoesAnterior = 0;
|
|
@endphp
|
|
|
|
@foreach($demaisMedicamentos as $i => $medicamento)
|
|
@php
|
|
$quantidadeLinhasRecomendacoes = countRecomendacoes($medicamento['recomendacoes']);
|
|
$pageBreakBefore = false;
|
|
|
|
if ($i === 0) {
|
|
|
|
if ($hasMedicamentosSeparados || $hasMedicamentosUsoContinuo) {
|
|
|
|
$pageBreakBefore = true;
|
|
}
|
|
}
|
|
else {
|
|
|
|
if ($medicamentosImpressos === 2
|
|
|| ($quantidadesLinhasRecomendacoesAnterior + $quantidadeLinhasRecomendacoes) > 5
|
|
) {
|
|
|
|
$pageBreakBefore = true;
|
|
$medicamentosImpressos = 0;
|
|
}
|
|
}
|
|
|
|
$medicamentosImpressos++;
|
|
$quantidadesLinhasRecomendacoesAnterior = $quantidadeLinhasRecomendacoes;
|
|
@endphp
|
|
|
|
<div class="row font-small" style="{{ $pageBreakBefore ? 'page-break-before: always;' : '' }}">
|
|
@for($via = 1; $via <= 2; $via++)
|
|
<div class="cell col-5" style="padding-{{ $via == 1 ? 'right' : 'left' }}: 15px;">
|
|
<div class="medicamento">
|
|
<table class="card">
|
|
<tbody>
|
|
<tr class="card-top">
|
|
<td
|
|
style="border-bottom: 1px solid #000; padding: 5px"
|
|
colspan="{{ $medicamento['doseUnica'] ? 1 : 2 }}"
|
|
>
|
|
<strong>{{ sprintf('%02d', $i + 1) }} - {{ $medicamento['nome'] }}</strong>
|
|
</td>
|
|
|
|
@if($medicamento['doseUnica'])
|
|
<td class="text-right" style="border-bottom: 1px solid #000; width: 80px">
|
|
dose única
|
|
</td>
|
|
@endif
|
|
</tr>
|
|
|
|
<tr class="card-middle">
|
|
<td style="padding-top: 5px;">
|
|
{{ $medicamento['posologia'] }}
|
|
@if($medicamento['duracao'])
|
|
durante
|
|
{{ $medicamento['duracao'] }}
|
|
{{ $medicamento['duracaoMedida'] }}
|
|
@endif
|
|
</td>
|
|
|
|
<td class="text-right" style="padding-top: 5px;">
|
|
<strong>Via: </strong>
|
|
{{ $medicamento['viaAdministracao'] }}
|
|
</td>
|
|
</tr>
|
|
<tr class="card-bottom">
|
|
<td colspan="2">
|
|
@if(!$medicamento['livre'])
|
|
<strong>Recomendações:</strong> {!! $medicamento['recomendacoes'] !!}
|
|
@endif
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
@endfor
|
|
</div>
|
|
@endforeach
|
|
@endforeach
|
|
|
|
<style>
|
|
.medicamento {
|
|
border: 1px solid #000;
|
|
border-radius: 5px;
|
|
margin-top: 3px;
|
|
font-size: 10px !important;
|
|
}
|
|
.endereco-margin {
|
|
margin-top: 15px;
|
|
|
|
}
|
|
.card td {
|
|
padding: 0px 5px;
|
|
}
|
|
.card-top td { padding-top: 0px; }
|
|
|
|
|
|
.card-bottom td {
|
|
padding-bottom: 0px;
|
|
}
|
|
.mt-8px {
|
|
margin-top: 8px;
|
|
}
|
|
.mt-12px {
|
|
margin-top: 12px;
|
|
}
|
|
.fieldset {
|
|
padding: 0px 5px 2px !important;
|
|
}
|
|
.data {
|
|
height: 22px !important;
|
|
}
|
|
.manual-line {
|
|
height: 18px !important;
|
|
border-bottom: 1px solid #000000 !important;
|
|
}
|
|
</style>
|
|
@endsection |