@php $reservationId = $AnalysisPackage->END_USER_LAB_ORDER_ID; $identification = $AnalysisPackage->IDENTIFICATION; $labCategoryId = $AnalysisPackage->LAB_CATEGORY_PACKAGE_ID; $questionsWithAnswers = App\Models\ENDUSERPACKAGEQUESTIONNAIREANSWERS::where('END_USER_LAB_ORDER_ID', $reservationId) ->where('IDENTIFICATION', $identification) ->where('LAB_CATEGORY_PACKAGE_ID', $labCategoryId) ->with(['question']) ->whereDoesntHave('question', function ($query) { $query->where('HIDE_FROM_REPORT', 1); }) ->get(); foreach ($questionsWithAnswers as $item) { if (!empty($item->OPTION_ID)) { $item->SELECTED_OPTIONS = $item->options()->pluck('NAME_EN'); } } $LabCategoryPackageResults = App\Models\ENDUSERLABORDERPACKAGERESULT::where('END_USER_PACKAGE_ID',$Package->ID)->with('Option','Result')->get(); $chromosomes = []; $fetalFraction = null; $sex = null; $gender = 0; $resultDate = []; $sex_chromosomes = []; $syndrome = []; foreach ($LabCategoryPackageResults as $key => $LabCategoryPackageResult) { if($LabCategoryPackageResult->Result->CODE == 'FF' && !empty($LabCategoryPackageResult->RESULT)) { $fetalFraction = $LabCategoryPackageResult->RESULT.'%'; } if($LabCategoryPackageResult->Result->CODE == 'SC' && $LabCategoryPackageResult->OPTION_ID) { $sex = $LabCategoryPackageResult->Option->NAME_EN; if ($sex == "Male, XY") $gender = 1; if ($sex == "Female, XX") $gender = 2; if ($sex == "Female, XX" || $sex == "Both Female") $gender = 2; } if($LabCategoryPackageResult->Result->CODE == 'Result' && !empty($LabCategoryPackageResult->OPTION_ID)) { $resultDate['result'] = $LabCategoryPackageResult->Option->NAME_EN; $resultDate['isNormal'] = $LabCategoryPackageResult->Option->IS_NORMAL; $resultDate['code'] = strtolower($LabCategoryPackageResult->Option->CODE ?? ''); } if($LabCategoryPackageResult->Result->CODE == '45X' && !empty($LabCategoryPackageResult->OPTION_ID)) { $sex_chromosomes['45X'] = $LabCategoryPackageResult->Option->CODE; } if($LabCategoryPackageResult->Result->CODE == '47XXX' && !empty($LabCategoryPackageResult->OPTION_ID)) { $sex_chromosomes['47XXX'] = $LabCategoryPackageResult->Option->CODE; } if($LabCategoryPackageResult->Result->CODE == '47XXY' && !empty($LabCategoryPackageResult->OPTION_ID)) { $sex_chromosomes['47XXY'] = $LabCategoryPackageResult->Option->CODE; } if($LabCategoryPackageResult->Result->CODE == '47XYY' && !empty($LabCategoryPackageResult->OPTION_ID)) { $sex_chromosomes['47XYY'] = $LabCategoryPackageResult->Option->CODE; } if($LabCategoryPackageResult->Result->CODE == 'T21' && !empty($LabCategoryPackageResult->OPTION_ID)) { $syndrome['T21'] = $LabCategoryPackageResult->Option->CODE; } if($LabCategoryPackageResult->Result->CODE == 'T18' && !empty($LabCategoryPackageResult->OPTION_ID)) { $syndrome['T18'] = $LabCategoryPackageResult->Option->CODE; } if($LabCategoryPackageResult->Result->CODE == 'T13' && !empty($LabCategoryPackageResult->OPTION_ID)) { $syndrome['T13'] = $LabCategoryPackageResult->Option->CODE; } if(str_contains($LabCategoryPackageResult->Result->CODE,'Chromosome')) { for ($i = 1; $i <= 22; $i++) { $code = 'Chromosome'.$i; if($LabCategoryPackageResult->Result->CODE == $code && !empty($LabCategoryPackageResult->OPTION_ID)) { $chromosomes[$code] = $LabCategoryPackageResult->Option->CODE; } } } } if ($gender == 1) { $color = "#D3EAFD"; $section_color = hexToRgb($Profile->COLOR,0.2) ?? 'rgba(244, 248, 255, 1)'; $img = url('/img/boy-2.png'); } elseif($gender == 2) { $color = "#FCECF6"; $section_color = hexToRgb($Profile->COLOR,0.2) ?? 'rgba(252, 236, 246, 0.5)'; $img = url('/img/girl-2.png'); } else{ $color = "#E5E2E2"; $section_color = hexToRgb($Profile->COLOR,0.2) ?? 'rgba(128, 128, 128, 0.1)'; $img = url('/img/gender_symbol.png'); } @endphp @if($questionsWithAnswers->count() > 0)
PATIENT CLINICAL DATA
@endif @foreach($questionsWithAnswers->chunk(4) as $chunk)
@foreach($chunk as $questionAnswer)
{{$questionAnswer->question->NAME_EN}}: @if(!empty($questionAnswer->SELECTED_OPTIONS)) @foreach($questionAnswer->SELECTED_OPTIONS as $selectedOption) {{$selectedOption}} @if(!empty($questionAnswer->DESCRIPTION)) {{$questionAnswer->DESCRIPTION}} @endif @endforeach @else {{$questionAnswer->ANSWER}} @endif
@endforeach
@endforeach
REPORT SUMMARY
Result
{{$resultDate['result']}}
@if(($resultDate['code'] ?? '') == 'na')
NA
@elseif(($resultDate['isNormal'] ?? null) != 1)
D
@else
N
@endif
Fetal Sex
{{$sex ?? 'Unknown'}}
@if($gender == 1) @elseif($gender == 2) @else @endif
Fetal Fraction
{{$fetalFraction}}
@php // The four sex chromosome findings used to have a section of their own, with // a chromosome icon each. They are one line in this table now, so the four // collapse into a single verdict: high if any of them is high. $sexAneuploidy = null; $sexFindings = array_filter($sex_chromosomes); if (!empty($sexFindings)) { if (in_array('high', $sexFindings, true)) $sexAneuploidy = 'high'; elseif (in_array('low', $sexFindings, true)) $sexAneuploidy = 'low'; else $sexAneuploidy = 'na'; } @endphp @if(!empty($syndrome['T21']) || !empty($syndrome['T18']) || !empty($syndrome['T13']) || !empty($sexAneuploidy))

RESULTS

Syndrome
Clinical Interpretation
@if(!empty($syndrome['T21']))
Trisomy 21
 ( Down’s Syndrome)
@if($syndrome['T21'] == 'low') Low Risk @elseif($syndrome['T21'] == 'na') N/A @else High Risk @endif
@endif @if(!empty($syndrome['T18']))
Trisomy 18
 ( Edward’s Syndrome)
@if($syndrome['T18'] == 'low') Low Risk @elseif($syndrome['T18'] == 'na') N/A @else High Risk @endif
@endif @if(!empty($syndrome['T13']))
Trisomy 13
 ( Patau’s Syndrome)
@if($syndrome['T13'] == 'low') Low Risk @elseif($syndrome['T13'] == 'na') N/A @else High Risk @endif
@endif @if(!empty($sexAneuploidy))
Sex Chromosomes Aneuploidies
@if($sexAneuploidy == 'low') Low Risk @elseif($sexAneuploidy == 'na') N/A @else High Risk @endif
@endif
@endif
Fetal Sex
@if($gender == 1) Male @elseif($gender == 2) Female @else Unknown @endif
Sex Chromosomes
{{explode(',', $sex)[1]??null}}
Estimated Fetal Fraction
{{$fetalFraction}}
@if($Profile->ID == 66)

Note:
Detected -high risk of Aneuploidy identified
Not Detected- Low risk of Aneuploidy identified

@endif
@if(!empty($chromosomes))
Autosomal Aneuploidies Result
Autosomal Aneuploidies
Result
Autosomal Aneuploidies
Result
@php $chromosomeArray = []; foreach ($chromosomes as $chromosome => $value) { $riskText = $value == 'high' ? 'HIGH RISK' : 'LOW RISK'; $riskColor = $value == 'high' ? '#E9473A' : '#29B637'; $chromosomeArray[] = ['name' => $chromosome, 'risk' => $riskText, 'color' => $riskColor]; } $chunkedChromosomes = array_chunk($chromosomeArray, 2); @endphp @foreach ($chunkedChromosomes as $chunk)
{{ $chunk[0]['name'] ?? '' }}
{{ $chunk[0]['risk'] ?? '' }}
{{ $chunk[1]['name'] ?? '' }}
{{ $chunk[1]['risk'] ?? '' }}
@endforeach
Risk Description: LOW RISK | HIGH RISK
@endif
@include('pdf.normal_report.components.analysis_tests.layout.comment')