wip
This commit is contained in:
parent
5b412be4f8
commit
b460b048e7
@ -19,8 +19,8 @@ abstract protected function handle(): string;
|
|||||||
|
|
||||||
abstract protected function getExtension(): string;
|
abstract protected function getExtension(): string;
|
||||||
|
|
||||||
protected function filename(): string
|
protected function filename(?string $ext = null): string
|
||||||
{
|
{
|
||||||
return sprintf('exp_%s.%s', Str::slug($this->report->accession_number), $this->getExtension());
|
return sprintf('exp_%s.%s', Str::slug($this->report->accession_number), $ext ?? $this->getExtension());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
use App\Models\StudyReport;
|
use App\Models\StudyReport;
|
||||||
use app\Services\Export\Formats\HtmlExport;
|
use app\Services\Export\Formats\HtmlExport;
|
||||||
use app\Services\Export\Formats\PdfExport;
|
use app\Services\Export\Formats\PdfExport;
|
||||||
use app\Services\Export\Formats\Word2003Export;
|
|
||||||
use app\Services\Export\Formats\Word2007Export;
|
use app\Services\Export\Formats\Word2007Export;
|
||||||
|
use app\Services\Export\Formats\Word2003Export;
|
||||||
|
|
||||||
final readonly class Exporters
|
final readonly class Exporters
|
||||||
{
|
{
|
||||||
|
@ -3,28 +3,37 @@
|
|||||||
namespace app\Services\Export\Formats;
|
namespace app\Services\Export\Formats;
|
||||||
|
|
||||||
use App\Domain\Report\ExportFormat;
|
use App\Domain\Report\ExportFormat;
|
||||||
use App\Services\Export\ExportDocumentBase;
|
|
||||||
use App\Services\Report\ReportStorage;
|
use App\Services\Report\ReportStorage;
|
||||||
use Barryvdh\DomPDF\Facade\Pdf;
|
|
||||||
|
|
||||||
final class PdfExport extends ExportDocumentBase
|
final class PdfExport extends TemplatedDocExportBase
|
||||||
{
|
{
|
||||||
protected function handle(): string
|
protected function handle(): string
|
||||||
{
|
{
|
||||||
$filename = $this->filename();
|
$filename = $this->filename();
|
||||||
$filepath = ReportStorage::customFilepath($this->study, $filename);
|
$pdf_path = ReportStorage::customFilepath($this->study, $filename);
|
||||||
if (ReportStorage::exists($this->study, $filename)) {
|
if (ReportStorage::exists($this->study, $filename)) {
|
||||||
return $filepath;
|
return $pdf_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$docx_path = ReportStorage::customFilepath($this->study, $this->filename('docx'));
|
||||||
|
$docx = $this->renderDocument();
|
||||||
|
$docx->createDocx(ReportStorage::abspath($docx_path));
|
||||||
|
$docx->transformDocument(ReportStorage::abspath($docx_path), ReportStorage::abspath($pdf_path));
|
||||||
|
|
||||||
|
return $pdf_path;
|
||||||
|
|
||||||
|
/*
|
||||||
|
$dompdf = new Dompdf\Dompdf;
|
||||||
|
$transform = new TransformDocAdvNative;
|
||||||
|
$transform->transformDocument('document.docx', 'document.pdf', ['dompdf' => $dompdf]);
|
||||||
|
|
||||||
$data = ['report' => $this->report, 'title' => 'PDF VIEW'];
|
$data = ['report' => $this->report, 'title' => 'PDF VIEW'];
|
||||||
Pdf::loadView('staff.reports.viewer.html-report', $data)
|
Pdf::loadView('staff.reports.viewer.html-report', $data)
|
||||||
->setPaper('a4', 'landscape')
|
->setPaper('a4', 'landscape')
|
||||||
->setWarnings(false)
|
->setWarnings(false)
|
||||||
->setOption('defaultFont', 'Courier')
|
->setOption('defaultFont', 'Courier')
|
||||||
->save(ReportStorage::abspath($filepath));
|
->save(ReportStorage::abspath($pdf_path));
|
||||||
|
*/
|
||||||
return $filepath;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getExtension(): string
|
protected function getExtension(): string
|
||||||
|
@ -3,13 +3,9 @@
|
|||||||
namespace app\Services\Export\Formats;
|
namespace app\Services\Export\Formats;
|
||||||
|
|
||||||
use App\Domain\Report\ExportFormat;
|
use App\Domain\Report\ExportFormat;
|
||||||
use App\Services\Export\ExportDocumentBase;
|
|
||||||
use App\Services\Report\ReportStorage;
|
use App\Services\Report\ReportStorage;
|
||||||
use App\Services\Report\StampService;
|
|
||||||
use CreateDocxFromTemplate;
|
|
||||||
use Illuminate\Support\Facades\Storage;
|
|
||||||
|
|
||||||
final class Word2007Export extends ExportDocumentBase
|
final class Word2007Export extends TemplatedDocExportBase
|
||||||
{
|
{
|
||||||
protected function handle(): string
|
protected function handle(): string
|
||||||
{
|
{
|
||||||
@ -19,28 +15,7 @@ protected function handle(): string
|
|||||||
return $filepath;
|
return $filepath;
|
||||||
}
|
}
|
||||||
|
|
||||||
$docx = new CreateDocxFromTemplate(Storage::disk('local')->path(config('services.report.word2007.template')));
|
$docx = $this->renderDocument();
|
||||||
$variables = [
|
|
||||||
'PAT_NAME' => $this->report->study->patient_name,
|
|
||||||
'PAT_ID' => $this->report->study->patient_id,
|
|
||||||
'PAT_AGE' => $this->report->study->sexAge(),
|
|
||||||
'ACC_NUM' => $this->report->study->accession_number,
|
|
||||||
'REF_DOC' => $this->report->study->referring_physician_name,
|
|
||||||
'STUDY_DATE' => $this->report->created_at->toDateString(),
|
|
||||||
];
|
|
||||||
$img = ['parseLineBreaks' => true, 'target' => 'header'];
|
|
||||||
$docx->replaceVariableByText($variables, $img);
|
|
||||||
$docx->embedHTML($this->report->getContent());
|
|
||||||
|
|
||||||
$stamper = new StampService($this->report->read_by_id);
|
|
||||||
if ($stamper->hasSignatureImage()) {
|
|
||||||
$img = [
|
|
||||||
'src' => $stamper->signatureImagePath(),
|
|
||||||
'textWrap' => 0,
|
|
||||||
];
|
|
||||||
$docx->addImage($img);
|
|
||||||
}
|
|
||||||
|
|
||||||
$docx->createDocx(ReportStorage::abspath($filepath));
|
$docx->createDocx(ReportStorage::abspath($filepath));
|
||||||
|
|
||||||
return $filepath;
|
return $filepath;
|
||||||
|
@ -18,11 +18,11 @@ public function hasSignatureImage(): bool
|
|||||||
{
|
{
|
||||||
$path = $this->user->radiologistProfile?->signature_image_path;
|
$path = $this->user->radiologistProfile?->signature_image_path;
|
||||||
|
|
||||||
return $path !== null && Storage::disk('local')->exists($path);
|
return $path !== null && Storage::disk('public')->exists($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function signatureImagePath(): string
|
public function signatureImagePath(): string
|
||||||
{
|
{
|
||||||
return Storage::disk('local')->path($this->user->radiologistProfile?->signature_image_path);
|
return Storage::disk('public')->path($this->user->radiologistProfile?->signature_image_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user