stamp
This commit is contained in:
parent
40351f7a0e
commit
ec256b5225
@ -15,7 +15,7 @@ protected function handle(): string
|
|||||||
$filename = $this->filename();
|
$filename = $this->filename();
|
||||||
$filepath = ReportStorage::customFilepath($this->study, $filename);
|
$filepath = ReportStorage::customFilepath($this->study, $filename);
|
||||||
if (ReportStorage::exists($this->study, $filename)) {
|
if (ReportStorage::exists($this->study, $filename)) {
|
||||||
// return $filepath;
|
return $filepath;
|
||||||
}
|
}
|
||||||
|
|
||||||
$docx = new CreateDocxFromTemplate(Storage::disk('local')->path('report/report-template-gray.docx'));
|
$docx = new CreateDocxFromTemplate(Storage::disk('local')->path('report/report-template-gray.docx'));
|
||||||
@ -26,12 +26,20 @@ protected function handle(): string
|
|||||||
'ACC_NUM' => $this->report->study->accession_number,
|
'ACC_NUM' => $this->report->study->accession_number,
|
||||||
'REF_DOC' => $this->report->study->referring_physician_name,
|
'REF_DOC' => $this->report->study->referring_physician_name,
|
||||||
'STUDY_DATE' => $this->report->created_at->toDateString(),
|
'STUDY_DATE' => $this->report->created_at->toDateString(),
|
||||||
// 'report' => $this->report,
|
|
||||||
];
|
];
|
||||||
$options = ['parseLineBreaks' => true, 'target' => 'header'];
|
$img = ['parseLineBreaks' => true, 'target' => 'header'];
|
||||||
$docx->replaceVariableByText($variables, $options);
|
$docx->replaceVariableByText($variables, $img);
|
||||||
$docx->embedHTML($this->report->getContent());
|
$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;
|
||||||
|
27
app/Services/Report/StampService.php
Normal file
27
app/Services/Report/StampService.php
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\Report;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
|
||||||
|
final class StampService
|
||||||
|
{
|
||||||
|
private User $user;
|
||||||
|
|
||||||
|
public function __construct(User|int|null $user = null)
|
||||||
|
{
|
||||||
|
$this->user = me($user);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hasSignatureImage(): bool
|
||||||
|
{
|
||||||
|
$path = $this->user->radiologistProfile?->signature_image_path;
|
||||||
|
|
||||||
|
return $path !== null && Storage::disk('local')->exists($path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function signatureImagePath(): string
|
||||||
|
{
|
||||||
|
return Storage::disk('local')->path($this->user->radiologistProfile?->signature_image_path);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user