feat: add lab tests, patient file management, and prescription improvements

This commit is contained in:
SajjadMahmoody
2026-04-17 20:15:38 +03:30
parent 6a301c5529
commit bf0ada051f
53 changed files with 3201 additions and 387 deletions
@@ -4,6 +4,7 @@
namespace App\Http\Controllers;
use App\Models\LabTest;
use App\Models\Patient;
use App\Models\Prescription;
use Illuminate\Http\Request;
@@ -16,9 +17,24 @@ public function print(Request $request, Prescription $prescription)
$prescription->load('patientRecord');
$type = $request->query('type', 'prescription');
$labContent = $prescription->lab_content ?? '';
$labLines = [];
if ($labContent) {
preg_match_all('/<li[^>]*>(.*?)<\/li>/s', $labContent, $m);
$labLines = $m[1] ?? [];
if (empty($labLines)) {
$cleaned = preg_replace('/<br\s*\/?>/i', "\n", $labContent);
$labLines = explode("\n", strip_tags($cleaned));
}
$labLines = array_values(array_filter(
array_map(fn ($l) => html_entity_decode(trim(strip_tags($l)), ENT_QUOTES, 'UTF-8'), $labLines)
));
}
return view('prints.prescription', [
'prescription' => $prescription,
'type' => $type,
'labLines' => $labLines,
]);
}