@extends('layouts.location_app') @section('title', 'Be Spoke Forms dashboard') @section('subHeader') {{-- @dd(Session::has('success'), Session::has('error'), Session::get('success'), Session::get('error')) --}} @php use App\Models\HeadOffices\CaseManager\HeadOfficeCase; use App\Models\User; use App\Models\Forms\Record; if(isset($record->reported_location)){ $reported_location = $record->reported_location; }else{ $reported_location = isset($case) ? $case->saved_loc : $location; } @endphp @endsection @section('content')
Back
@if ($record->form->allow_editing_state !== 'disable' && is_null($record->id) != true && isset($case->id) && $case->status !== 'closed' && $record->canEdit()) @if ( isset($location->organization_setting_assignment->organization_setting)) Modify Report @else Modify Report @endif @endif
@csrf
@php $data_objects = []; if (isset($record)) { $data_objects = Record::withoutGlobalScope('lean')->find($record->id)->get_form_data(); } @endphp @if (count($data_objects) > 0)
@foreach ($data_objects as $data) @if (!empty($data['value']))

{{ $data['label'] }}

@if (is_array($data['value'])) @foreach ($data['value'] as $item)

{{ $item }}

@endforeach @else @if (isset($data['rating_icon']) && $data['rating_icon'] == 'stars')

@for ($i = 1; $i <= $data['total_options']; $i++) @endfor

@elseif(isset($data['rating_icon']) && $data['rating_icon'] == 'label')

@for ($i = 1; $i <= $data['total_options']; $i++) {{$i}} @endfor

@else

{{ $data['value'] }}

@endif @endif
@endif @endforeach
@else @endif
@if ($record->form->allow_responder_update && count($record->updates) != 0)
@endif
@if (count($record->get_pending_forms(true)) != 0)
Incomplete Forms These forms are generated and require completion when triggered by specific logic within the initial form
@foreach ($record->get_pending_forms(true) as $pending_form ) @endforeach
Type
{{$pending_form['form']}} {{isset($pending_form['form_draft']) ? $pending_form['form_draft'] : '-'}}
Ignore @if ($record->created_by->email != 'external@qitech.com' || $pending_form['type'] == 0) Complete Now @elseif ($record->created_by->email == 'external@qitech.com' || $pending_form['type'] == 1) Submit @endif
@endif
@if (isset($tasks) && isset($tasks) && count($tasks) != 0) @foreach ($tasks as $taskItem) @php // Check if there's an extended due date (dead_line_date or task_over_due_date) $extendedDueDate = null; if ($taskItem->dead_line_date) { $extendedDueDate = $taskItem->dead_line_date; } elseif ($taskItem->task_over_due_date) { $extendedDueDate = $taskItem->task_over_due_date; } // Use extended due date if available, otherwise use the original due date $effectiveDueDate = $extendedDueDate ? $extendedDueDate : $taskItem->due_date; // Calculate if overdue based on the effective due date $isOverdue = $effectiveDueDate && \Carbon\Carbon::parse($effectiveDueDate)->isPast() && $taskItem->status !== 'completed'; @endphp
Task #{{ $taskItem->id }}
{{ $taskItem->title ?? '[Task Name goes here]' }}
{{ $taskItem->priority ?? 'No Priority' }} @if ($isOverdue) Overdue @endif
@if (isset($taskItem->created_by) && isset($taskItem->created_by->user->logo))
Created by: {{ optional(optional($taskItem->created_by)->user)->name ?? 'Default Task' }}
@endif
Created at: {{ \Carbon\Carbon::parse($taskItem->created_at)->format('d M Y (D) h:i a') }}
Last Updated {{ $taskItem->updated_at->diffForHumans() }}
Due Date: {{ $effectiveDueDate ? \Carbon\Carbon::parse($effectiveDueDate)->format('d M Y (D) h:i a') : 'No Due Date' }}
@if (optional($taskItem->ho_allocations)->count() > 0)
Assigned To: {{ optional($taskItem->ho_allocations)->pluck('head_office_user.user.name')->filter()->implode(', ') ?? '' }}
@endif @if (optional($taskItem->loc_allocations)->count() > 0)
Assigned To: {{ optional($taskItem->loc_allocations)->load('head_office_location.location')->pluck('head_office_location.location.trading_name')->filter()->implode(', ') ?? '' }}
@endif
Site Involved: {{ optional($taskItem->task_case)->location_name ?? 'Unknown Site' }}
Description:
{!! $taskItem->description ?? 'No Description' !!}
@livewire('task-status', ['task' => $taskItem->id])
@endforeach @else
There are no tasks

All caught up! No tasks assigned at the moment.

@endif

{{ $record->form->name }}

Description:
{{ $record->form->note }}
Submitted:
{{ $record->created_at->format('d M Y (D) h:i a') }}
Completed By:
{{ $record->location->trading_name }}
,{{ isset($record->created_by) ? ($record->created_by->first_name . ' ' . $record->created_by->surname) : 'Quick login' }}
@if ($record->form->allow_responder_update)
@foreach ($record->updates as $key => $update)
{{ optional($update->user)->name }} Updated {{ $update->created_at->diffForHumans() }} {{ $update->created_at->format('d M Y (D) h:i a') }}
{!! $update->update !!}
@endforeach @if ($record->form->update_time_left($record->created_at)['allowed'] == false && $record->form->allow_update_state != 'open')

Unfortunately, the time period to submit further updates has passed. Please submit another form if you need to provide further information.

@elseif (isset($case) && $case->status == 'closed' && $record->form->allow_update_state != 'open')

Case is Closed

@else
{{ $record->form->allow_responder_update == true ? 'Provide an Update' : 'Updates Not Allowed' }} You can provide any new updates to the team investigating this case
@csrf
@foreach ($record->documents ?? [] as $doc)
  •  {{$doc->document->original_file_name()}}
  • @endforeach
    Select documents/images to upload

    Drop files here
    form->allow_responder_update == true ? '' : 'disabled' }} type="file" name="file" multiple value="" class="form-control commentMultipleFiles">
    @endif
    @else

    This form does not allow updates. Please submit another form if you need to provide further information.

    @endif
    @if (isset($parent_record) && count($parent_record->get_modifications()) != 0)
    @php $modifications = collect($parent_record->get_modifications())->sortByDesc('created_at'); @endphp @foreach ($modifications as $modification) @php $json = isset($modification->modified_data) ? json_decode($modification->modified_data, true) : []; @endphp
    {{ $modification->user->name }} Modified a response {{ $modification->created_at->diffForHumans() }}
      @foreach ($json as $id => $changes) @php // Function to extract values if (!function_exists('extractValues')) { function extractValues($value) { if (is_array($value) && !empty($value)) { $flattened = []; foreach ($value as $item) { if (is_array($item)) { if (!empty($item['vtm']['vtm_string'])) { $flattened[] = $item['vtm']['vtm_string']; } if (!empty($item['other'])) { $flattened[] = $item['other']; } } else { $flattened[] = (string) $item; } } return !empty($flattened) ? implode(', ', $flattened) : null; } return !empty($value) ? (string) $value : null; } } // Extract values $original_value = extractValues($changes['original']['value'] ?? null); $modified_value = extractValues($changes['modified']['value'] ?? null); // Skip rendering if both values are empty if (empty($original_value) && empty($modified_value)) { continue; } // Get details or fallback $details = !empty($original_value) ? $record->get_question_details_by_id($id, $modification->parent_record_id, $original_value) : null; $modified_details = !empty($modified_value) ? $record->get_question_details_by_id($id, $modification->parent_record_id, $modified_value) : null; if (empty($details) && !empty($original_value)) { $details = $original_value; } if (empty($modified_details) && !empty($modified_value)) { $modified_details = $modified_value; } // Format results $result = is_array($details) && !empty($details) ? implode(', ', array_map('strval', $details)) : ($details ?? 'N/A'); $modified_result = is_array($modified_details) && !empty($modified_details) ? implode(', ', array_map('strval', $modified_details)) : ($modified_details ?? 'N/A'); @endphp
    • Question: {{ $changes['original']['label'] ?? 'Unknown' }}
      Response: {{ $result ?? 'N/A' }} {{ $modified_result ?? 'N/A' }}
    • @endforeach
    @endforeach
    @else

    No modifications!

    @endif
    root
    @if (count($record->getCaseFeedbacks()) != 0) @foreach ($record->getCaseFeedbacks() as $feedback) @php $case_ids = isset($feedback->case_ids) ? json_decode($feedback->case_ids, true) : null; @endphp
    headoffice logo

    Date

    {{ $feedback->created_at->format('d/m/Y') }}

    Reported

    @isset($case_ids) @foreach ($case_ids as $case_id) @php $feedback_case = HeadOfficeCase::find($case_id)->first(); @endphp

    {{ $feedback_case->created_at->format('d/m/Y') }}

    {{ $feedback_case->incident_type }}

    {{ $feedback_case->location_name }}

    @endforeach @endisset
    @if ($feedback->is_feedback_location)

    Feedback by {{ $feedback->HeadOffice->name() }}

    {!! isset($feedback->feedback_location) ? $feedback->feedback_location : $feedback->HeadOffice->name() . ' ' . "did'nt provided any feedback" !!}

    @endif
    @endforeach @else

    No Feedbacks at the moment 🙂!

    @endif
    @if (isset($case) && $case->submitable_to_nhs_lfpse == 1)
    @if(count($record->LfpseSubmissions) == 0)
    Submission Status: Not Submitted
    @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
    @endif

    @foreach ($record->LfpseSubmissions as $sr => $s) @endforeach @foreach ($record->LfpseSubmissions as $s) @endforeach @php $data_objects = collect($data_objects); $FormType = $data_objects->firstWhere('label', 'What kind of event do you want to record?')['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 @if (isset($data_objects->firstWhere('label', 'To what extent was the patient physically harmed (including pain) in this incident?')['value'])) @endif @if (isset($data_objects->firstWhere('label', 'To what extent was the patient physically harmed (including pain) in this incident?')['value'])) @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 == 'Incident - Something unexpected or unintended has happened, or failed to happen, that could have or did lead to patient harm for one or more person(s) receiving healthcare.' ? 'Incident' : "Good Care"}}
    Version{{isset($s->version) ? $s->version : '6'}}
    Outcome{{$s->outcome_type_string}}
    Psychological Harm {{$data_objects->firstWhere('label', 'To what extent was the patient psychologically harmed in this incident?')['value']}}
    Physical Harm {{$data_objects->firstWhere('label', 'To what extent was the patient physically harmed (including pain) in this incident?')['value']}}
    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 {{$data_objects->firstWhere('label', 'To what extent was the patient physically harmed (including pain) in this incident?')['value']}}
    Physical Harm {{ $data_objects->firstWhere('label', 'To what extent was the patient physically harmed (including pain) in this incident?')['value']}}
    Remarks{{$s->remarks}}
    Date{{$s->created_at->format('d M Y (D) h:i a')}}
    @endif
    @else @if (isset($case) && $case->form_submitable == 0)
    Submission Status: Not Submitted
    Submit Now @else
    Submission Status: Submitted
    @endif @endif
    @endsection @section('scripts') @if(Session::has('success')) @endif @if(Session::has('error')) @endif @endsection