{{ $LabCategoryPackageResult->Result->NAME_EN }}
@if ($LabCategoryPackageResult->Result->CODE === 'Sickle')
@if (!empty($LabCategoryPackageResult->Option->NAME_EN))
{{ $LabCategoryPackageResult->Option->NAME_EN }}
@else
@endif
@else
{{ $LabCategoryPackageResult->RESULT }}
@endif
{{-- Handle comment, normal ranges, and specific codes --}}
@if ($LabCategoryPackageResult->Result->CODE === 'INR')
{!! !empty($comment) ? nl2br(e($comment)) : "<" . $MAX_NORMAL !!}
@elseif ($LabCategoryPackageResult->Result->CODE === 'HBF' && !empty($Profile->ID) && ($Profile->ID == 18 || $Profile->ID == 60 || $Profile->ID == 46 || $Profile->ID == 62))
@if($Profile->ID == 62)
<{{ $MAX_NORMAL }}
@else
≤{{ $MAX_NORMAL }}
@endif
@elseif ($LabCategoryPackageResult->Result->CODE === 'HBA2')
@if (!empty($Profile->ID) && in_array($Profile->ID, [18, 34, 60,46,62]))
{{ $MIN_NORMAL }} - {{ $MAX_NORMAL }}
@else
≤ {{ $MAX_NORMAL }}
@endif
@elseif (in_array($LabCategoryPackageResult->Result->CODE, ['HBD', 'HBC']) && ($Profile->ID != 18 && $Profile->ID != 60 && $Profile->ID != 46))
Negative
@elseif (in_array($LabCategoryPackageResult->Result->CODE, ['HBD', 'HBC', 'HBE']) && ($Profile->ID == 18 || $Profile->ID == 60 || $Profile->ID == 46))
0.0
@elseif ($LabCategoryPackageResult->Result->CODE === 'HBS')
0
@elseif ($LabCategoryPackageResult->Result->CODE === 'Sickle')
{{ $LabCategoryPackageResult->Result->NormalOption->NAME_EN ?? '' }}
@elseif ($LabCategoryPackageResult->Result->CODE === 'PRT')
{{ $comment ?: "$MIN_NORMAL-$MAX_NORMAL" }}
@else
{{ "$MIN_NORMAL-$MAX_NORMAL" }}
@endif
{{-- Display unit --}}
{{ $LabCategoryPackageResult->RESULT_UNIT ?: $LabCategoryPackageResult->Result->UNIT }}
@endforeach
@php
$aiResultText = '';
$aiRecommendationPackage = \App\Models\ENDUSERAIRECOMMENDATIONPACKAGE::where('END_USER_LAB_ORDER_PACKAGE_ID', $Package->ID)
->whereHas('ENDUSERAIRECOMMENDATION', function($query) {
$query->where('STATUS_ID', 1);
})
->with('ENDUSERAIRECOMMENDATION')
->latest()
->first();
if (!empty($aiRecommendationPackage)) {
$isArabic = isset($language) && $language === 'ar';
$aiResult = $isArabic ? $aiRecommendationPackage->AI_RESULT_AR : $aiRecommendationPackage->AI_RESULT_EN;
if (!empty($aiResult)) {
$fullText = $aiResult;
$foundInterpretation = false;
$patterns = [
'/تفسير النتيجة[:\s]*(.+?)(?=\n\n|\n[A-Z]|\n\d+\.|\nالتوصيات|\nRecommendations|$)/s',
'/Result Interpretation[:\s]*(.+?)(?=\n\n|\n[A-Z]|\n\d+\.|\nRecommendations|\nالتوصيات|$)/s',
'/Interpretation[:\s]*(.+?)(?=\n\n|\n[A-Z]|\n\d+\.|\nRecommendations|\nالتوصيات|$)/s'
];
foreach ($patterns as $pattern) {
if (preg_match($pattern, $fullText, $matches)) {
$aiResultText = trim($matches[1]);
$foundInterpretation = true;
break;
}
}
if (!$foundInterpretation && !empty($fullText)) {
$aiResultText = $fullText;
}
}
}
@endphp
@if(!empty($aiResultText))
@php
$isArabic = isset($language) && $language === 'ar';
$interpretationLabel = $isArabic ? 'تفسير النتيجة' : 'Result Interpretation';
$textDirection = $isArabic ? 'direction: rtl; text-align: right;' : 'direction: ltr; text-align: left;';
$fontFamily = $isArabic ? "font-family: 'ArbFONTS-DINNextLTArabic-Regular-2', Arial, sans-serif;" : "font-family: Mulish, sans-serif;";
$labelFontFamily = $isArabic ? "font-family: 'ArbFONTS-DINNextLTArabic-Bold-2', Arial, sans-serif;" : "font-family: Mulish, sans-serif;";
$borderSide = $isArabic ? 'border-right' : 'border-left';
$aiResultColor = 'background-color: #f8fafc; ' . $borderSide . ': 3px solid ' . '#019CA7' . '; padding: 12px; border-radius: 6px; margin-top: 12px;';
@endphp