feat: add lab tests, patient file management, and prescription improvements
This commit is contained in:
@@ -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,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user