From bfbed52332feede37e7d44abb42a44886c4a7ab7 Mon Sep 17 00:00:00 2001 From: Dr Masroor Ehsan Date: Sun, 12 Jan 2025 11:54:04 +0600 Subject: [PATCH] wip --- .../Export/Formats/TemplatedDocExportBase.php | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 app/Services/Export/Formats/TemplatedDocExportBase.php diff --git a/app/Services/Export/Formats/TemplatedDocExportBase.php b/app/Services/Export/Formats/TemplatedDocExportBase.php new file mode 100644 index 0000000..530ca8d --- /dev/null +++ b/app/Services/Export/Formats/TemplatedDocExportBase.php @@ -0,0 +1,39 @@ +path(config('services.report.word2007.template'))); + $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); + } + + return $docx; + } +}