@if(session('success_message')) @endif
@include('head_office.case_manager.notes.view_tasks',['case' => $case])
@include('head_office.case_manager.notes.interested_parties',['case' => $case])
{{ isset($case->link_case_with_form->form->name) ? $case->link_case_with_form->form->name : 'Unknown' }}
#{{$case->id}}
@if($case->isArchived) Archived @elseif($case->status == 'waiting' && $case->requires_final_approval == true) Final Approval @elseif($case->status == 'open') New @elseif($case->status == 'closed') Completed @else {{ $case->status() }} @endif
@if (isset($case->getReporter()->id) && $case->getReporter()->email != 'external@qitech.com') Reported by

{{$case->getReporter()->name ?? 'External User'}}

from @else Reported from @endif

getReporter()->id) && $case->getReporter()->email != 'external@qitech.com') title="{{$case->location_full_address}}"@endif> @if (isset($case->saved_loc)) {{ isset($case->saved_loc->location_id) ? $case->saved_loc->location_id : $case->saved_loc->trading_name}} @else {{ isset($case->location->location_id) ? $case->location->location_id : $case->location_name}} @endif

Created

{{$case->created_at->format('d M Y, h:i a')}} ({{$case->created_at->diffForHumans() }})

@if(isset($case->saved_loc) && $case->link_case_with_form->hide == 0)
Site Involved

{{ isset($case->location->location_id) ? $case->location->location_id : $case->location_name}}

@php $all_involved_sites = $case->link_case_with_form->latest_linked_record()->getAllInvolvedSites(); @endphp @if ($all_involved_sites != null && $all_involved_sites->count() > 0)
@foreach ( $all_involved_sites as $l_sites ) @if ($l_sites->id == $case->location->id) @continue @endif

email != 'external@qitech.com') title="{{$l_sites->location_full_address}}"@endif> @if (isset($l_sites)) {{ isset($l_sites->location_id) ? $l_sites->location_id : $l_sites->trading_name}} @else {{ isset($case->location->location_id) ? $case->location->location_id : $case->location_name}} @endif @if (!$loop->last) , @endif

@endforeach
@endif
@endif

Linked Cases @if ($case->isArchived == false) @endif
@if (count($case->allLinkedCases()) != 0) @foreach ($case->allLinkedCases() as $link_case ) @php $link_case_other = $link_case->otherCase($case->id)->first(); $userName = $link_case && $link_case->user_id ? DB::table('users')->where('id', $link_case->user_id)->value('first_name') : 'Unknown User'; $timeAgo = $link_case ? \Carbon\Carbon::parse($link_case->created_at)->diffForHumans() : ''; @endphp @if ($case->isArchive == true) @else @endif @endforeach
Case Type Status Action
#{{$link_case_other->id}} {{$link_case_other->link_case_with_form->form->name ?? ' '}} @if ($link_case->linked_manually == null) Form-Automation triggered @else Manually linked by {{ $userName }} , {{ $timeAgo }} @endif
@else

There are no linked cases

@endif
{{-- Incomplete forms --}} @if (count($case->link_case_with_form->get_pending_forms()) != 0)
Incomplete Forms
@foreach ($case->link_case_with_form->get_pending_forms() as $pending_form ) @endforeach
Type Status
{{$pending_form['form']}}

{{$pending_form['status']}}

{{isset($pending_form['form_draft']) ? $pending_form['form_draft'] : '-'}} @if (isset($pending_form['reason']))
Reason

{{$pending_form['reason']}}

@endif @if (isset($pending_form['remind_at']))
Last Reminder sent {{ \Carbon\Carbon::parse($pending_form['remind_at'])->diffForHumans() }}
@endif
{{--
--}}
Not required @if ($case->link_case_with_form->created_by->email != 'external@qitech.com' || $pending_form['type'] == 0) Remind @if ($pending_form['type'] == 0) @endif @elseif ($case->link_case_with_form->created_by->email == 'external@qitech.com' || $pending_form['type'] == 1) Submit @endif
@endif
Tags
@livewire('case-tags-manager', ['case_id' => $case->id])
@include('head_office.case_manager.notes.view_documents',['documents' => $case->case_documents,'case' => $case,'permissions' => $permissions])
{{-- Note: Currently related to Record (Not Case) This should be review --}} @if ($case->submitable_to_nhs_lfpse == 1) @php $record = $case->link_case_with_form()->withoutGlobalScope('lean')->first(); if ($record && $record->json_submission) { $submission_array = json_decode($record->json_submission, true); if ($submission_array && isset($submission_array['mandatory_questions']) && is_array($submission_array['mandatory_questions'])) { $submission_questions = array_values($submission_array['mandatory_questions']); $labelsToMatch = [ 'To what extent was the patient physically harmed (including pain) in this incident?', 'To what extent was the patient psychologically harmed in this incident?' ]; $selected_answer = []; foreach ($submission_questions as $val) { if (is_array($val) && isset($val['label']) && in_array($val['label'], $labelsToMatch)) { $selected_answer[] = $val; } } } else { $selected_answer = []; } } else { $selected_answer = []; } @endphp
@if(count($record->LfpseSubmissions) == 0)
Submission Status: Not Submitted
Submit Now @else
@if (isset($record->lfpse_deletes))
Submission Status: Deleted
@if(isset($record->lfpse_deletes->message))

Deletion Message:

{{$record->lfpse_deletes->message}}

@endif
@else
Submission Status: Submitted
@php $last_record = $record->all_linked_records()->last(); if(!isset($last_record)){ $last_record = $record; } @endphp Edit Delete @endif

@foreach ($record->LfpseSubmissions as $sr => $s) @endforeach @foreach ($record->LfpseSubmissions as $s) @endforeach @php $FormType = json_decode($record->json_submission,true)['mandatory_questions']['-1080']['value']; @endphp @foreach ($record->LfpseSubmissions as $s) @endforeach @foreach ($record->LfpseSubmissions as $s) @endforeach @if($FormType == '1') @endif @foreach ($record->LfpseSubmissions as $s) @endforeach @foreach ($record->LfpseSubmissions as $s) @endforeach {{-- ==================================================================================================== --}} @foreach ($record->all_linked_records() as $lfpseRec) @if (isset($lfpseRec->LfpseSubmissions) && count($lfpseRec->LfpseSubmissions) > 0) @foreach ($lfpseRec->LfpseSubmissions as $s) @endforeach {{-- @foreach ($lfpseRec->LfpseSubmissions as $s) @endforeach --}} @foreach ($lfpseRec->LfpseSubmissions as $s) @endforeach @foreach ($lfpseRec->LfpseSubmissions as $s) @endforeach @php $patients = json_decode($record->json_submission,true)['patients']; if(isset($patients) && count($patients) > 0){ $patient = $patients[0]; if(isset($patient['PhysicalHarm']) && isset($patient['PsychologicalHarm'])){ $PhysicalHarm = $patient['PhysicalHarm']['value']; $PsychologicalHarm = $patient['PsychologicalHarm']['value']; } } @endphp @if (isset($PsychologicalHarm)) @endif @if (isset($PhysicalHarm)) @endif @foreach ($lfpseRec->LfpseSubmissions as $s) @endforeach @foreach ($lfpseRec->LfpseSubmissions as $s) @endforeach @endif @endforeach
Sr#Record {{$sr + 1}}
LFPSE ID{{$s->reference_id}}
Type{{$FormType == '1' ? 'Incident' : "Good Care"}}
Version{{isset($s->version) ? $s->version : '6'}}
Outcome{{$s->outcome_type_string}}
Psychological Harm @php $psyHarmLevels = [ "4" => "No Psychological harm", "3" => "Low Psychological harm", "2" => "Moderate Psychological harm", "1" => "Severe Psychological harm" ]; if (isset($selected_answer[1]['value']) && array_key_exists($selected_answer[1]['value'], $psyHarmLevels)) { echo $psyHarmLevels[$selected_answer[1]['value']]; } @endphp
Physical Harm @php $harmLevels = [ "5" => "No physical harm", "4" => "Low physical harm", "3" => "Moderate physical harm", "2" => "Severe physical harm", "1" => "Fatal physical harm" ]; if (isset($selected_answer[0]['value']) && array_key_exists($selected_answer[0]['value'], $harmLevels)) { echo $harmLevels[$selected_answer[0]['value']]; } @endphp
Remarks{{$s->remarks}}
Date{{$s->created_at->format('d M Y (D) h:i a')}}
fsaf
fsaf
LFPSE ID{{$s->reference_id}}
Actual ID{{$s->lfpse_id}}
Version{{isset($s->version) ? $s->version : '6'}}
Outcome{{$s->outcome_type_string}}
Psychological Harm @php $psyHarmLevels = [ "4" => "No Psychological harm", "3" => "Low Psychological harm", "2" => "Moderate Psychological harm", "1" => "Severe Psychological harm" ]; if (isset($PsychologicalHarm) && array_key_exists($PsychologicalHarm, $psyHarmLevels)) { echo $psyHarmLevels[$PsychologicalHarm]; } @endphp
Physical Harm @php $harmLevels = [ "5" => "No physical harm", "4" => "Low physical harm", "3" => "Moderate physical harm", "2" => "Severe physical harm", "1" => "Fatal physical harm" ]; if (isset($PhysicalHarm) && array_key_exists($PhysicalHarm, $harmLevels)) { echo $harmLevels[$PhysicalHarm]; } @endphp
Remarks{{$s->remarks}}
Date{{$s->created_at->format('d M Y (D) h:i a')}}
@endif @if($record->errors->count() != 0)

Errors {{$record->errors->count()}}

{{-- ==================================================================================================== --}} @foreach ($record->errors as $err) @endforeach
Severity {{$err->severity}}
Remarks {{$err->message}}
Time {{$err->created_at->format('d M Y (D) h:i a')}}
asdf
@endif
@else @if ($case->form_submitable == 0)
Submission Status: Not Submitted
Submit Now @else
Submission Status: Submitted
@endif @endif
@php $caseHandlers = DB::table('case_handler_users') ->where('is_hidden',false) ->join('head_office_users', 'case_handler_users.head_office_user_id', '=', 'head_office_users.id') ->join('users', 'head_office_users.user_id', '=', 'users.id') ->whereIn('case_handler_users.case_id', $case->case_head_office->cases->pluck('id')) ->select('users.id as user_id', 'users.first_name') ->distinct() ->get(); $form_name = is_array($case->form_name) ? $case->form_name : explode(',', $case->form_name); @endphp
@if (count($case->link_case_with_form->LfpseSubmissions) != 0) @endif