{{ $LabCategoryPackageResult->Result->NAME_EN }}
{{ $Result }}
@if($LabCategoryPackageResult->Result->CODE != 'MXD' && $LabCategoryPackageResult->Result->CODE != 'MXD#')
{{ $MIN_NORMAL }} - {{ $MAX_NORMAL }}
{{ $LabCategoryPackageResult->RESULT_UNIT ?: $LabCategoryPackageResult->Result->UNIT }}
@endif
@endforeach
@if(!empty($DiffArray) && count($DiffArray) > 0)
{{ $LabCategoryPackageResult->Result->NAME_EN }}
REFERENCE_RANGE_TEXT) && empty($LabCategoryPackageResult->Result->REFERENCE_RANGE_TEXT)) style="color: {{ $color }}" @endif>{{ $Result }}
@if($LabCategoryPackageResult->Result->CODE != 'MXD' && $LabCategoryPackageResult->Result->CODE != 'MXD#')
@if(!empty($LabCategoryPackageResult->REFERENCE_RANGE_TEXT) || !empty($LabCategoryPackageResult->Result->REFERENCE_RANGE_TEXT))
{{$LabCategoryPackageResult->REFERENCE_RANGE_TEXT ?? $LabCategoryPackageResult->Result->REFERENCE_RANGE_TEXT}}
@else
{{ $MIN_NORMAL }} - {{ $MAX_NORMAL }}
@endif
{{ $LabCategoryPackageResult->RESULT_UNIT ?: $LabCategoryPackageResult->Result->UNIT }}
@endif
@endforeach
@endif
@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 #ba395e; padding: 12px; border-radius: 6px; margin-top: 12px;';
@endphp