@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 = collect($PackageResultsByPackage[$Package->ID] ?? []); $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($LabCategoryPackageResult->Result->CODE == 'Result' && !empty($LabCategoryPackageResult->OPTION_ID)) { $resultDate['result'] = $LabCategoryPackageResult->Option->NAME_EN; $resultDate['isNormal'] = $LabCategoryPackageResult->Option->IS_NORMAL; } 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['isNormal'] != 1)
D
@else
N
@endif
Fetal Sex
@if($gender == 1) Male @elseif($gender == 2) Female @else Unknown @endif
@if($gender == 1) @elseif($gender == 2) @else @endif
Fetal Fraction
{{$fetalFraction}}
@if(!empty($syndrome['T21']) || !empty($syndrome['T18']) || !empty($syndrome['T13']))

RESULTS

Syndrome
Clinical Interpretation
@if(!empty($syndrome['T21']))
Trisomy 21
 ( Down’s Syndrome)
@if($syndrome['T21'] == 'low') Low Risk @else High Risk @endif
@endif @if(!empty($syndrome['T18']))
Trisomy 18
 ( Edward’s Syndrome)
@if($syndrome['T18'] == 'low') Low Risk @else High Risk @endif
@endif @if(!empty($syndrome['T13']))
Trisomy 13
 ( Patau’s Syndrome)
@if($syndrome['T13'] == 'low') Low Risk @else High Risk @endif
@endif
@endif
Fetal Sex
@if($gender == 1) Male @elseif($gender == 2) Female @else Unknown @endif
Chromosome Results
{{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($sex_chromosomes['45X']) || !empty($sex_chromosomes['47XXX']) || !empty($sex_chromosomes['47XXY']) || !empty($sex_chromosomes['47XYY']))
Sex Chromosome Aneuploidies
@if(!empty($sex_chromosomes['45X']))
@if($sex_chromosomes['45X'] == 'low') @elseif($sex_chromosomes['45X'] == 'high') @else N/A @endif 45, X
(Turner Syndrome )
@endif @if(!empty($sex_chromosomes['47XXX']))
@if($sex_chromosomes['47XXX'] == 'low') @elseif($sex_chromosomes['47XXX'] == 'high') @else N/A @endif 47, XXX
(Trisomy X Syndrome)
@endif @if(!empty($sex_chromosomes['47XXY']))
@if($sex_chromosomes['47XXY'] == 'low') @elseif($sex_chromosomes['47XXY'] == 'high') @else N/A @endif 47, XXY
(Klinefelter’s Syndrome )
@endif @if(!empty($sex_chromosomes['47XYY']))
@if($sex_chromosomes['47XYY'] == 'low') @elseif($sex_chromosomes['47XYY'] == 'high') @else N/A @endif 47, XYY
(Jacob’s Syndrome )
@endif
Risk Description: Low Risk High Risk
@endif @if(!empty($chromosomes))
Autosomal Aneuploidies
@foreach ($chromosomes as $chromosome => $value) @php $image = $value == 'high' ? 'high.png' : 'low.png'; @endphp
{{ $chromosome}}
@if ($loop->iteration % 4 == 0)
@endif @endforeach
Risk Description: Low Risk High Risk
@endif
@include('pdf.integrated_report.components.analysis_tests.layout.comment')