{{-- Start a Medication Competency assessment for one care worker: full pack, annual refresher, or upload a previous paper record. Also lists their history. From MedicationCompetencyController@create: $worker, $state, $course (linked e-learning or null), $elearningDate, $canRefresh, $history --}} @extends('layouts.app') @section('title', 'Medication Competency Pack') @section('content') @include('partials.flash') @php use App\Support\MedicationCompetencyPack as Pack; $role = auth()->user()->primaryRole(); $r = fn ($n, $p = []) => route($role.'.medication-competency.'.$n, $p); [$cls, $icon, $label] = \App\Models\MedicationCompetency::stateBadge($state['state']); $cur = $state['current']; $choice = old('type', request('type', $errors->hasAny(['kind', 'assessed_at', 'file']) ? 'upload' : null)); $inputCls = 'w-full px-4 py-2.5 bg-surface-container rounded-lg border-none focus:ring-2 focus:ring-primary/20 text-body-md outline-none'; @endphp arrow_back All staff {{-- Who --}}
{{ $worker->initials() }}

{{ $worker->name }}

{{ $worker->location?->name ?? '—' }} · {{ $worker->email }}

{{ $icon }} {{ $label }} @if($cur?->expires_at)

{{ $cur->status === 'competent' ? 'Valid until' : '' }} {{ $cur->expires_at->format('j M Y') }}

@endif
{{-- Choose --}}

What would you like to do?

@php $opts = [ 'full' => ['assignment', 'Full assessment', 'New staff, or anyone who has had a medication error. Three visits: visit 1 – assessment, knowledge and chosen competencies; visits 2 and 3 – an assessment each.', true], 'refresher' => ['autorenew', 'Annual refresher', $canRefresh ? 'Yearly spot check for staff already assessed as competent, with no medication error since.' : 'Available once they have a competent full assessment (or an uploaded record).', $canRefresh], 'upload' => ['upload_file', 'Upload a previous record', 'A paper competency assessment already completed — saved straight away.', true], ]; @endphp
@foreach($opts as $key => [$oIcon, $oLabel, $oHelp, $enabled]) @endforeach
{{-- Prerequisite training (Medication Level 2 / Induction — session or e-learning), newest preselected --}} @php $preChoice = old('prerequisite', $prerequisites->first()['key'] ?? 'manual'); @endphp {{-- Full / refresher form --}}
@csrf

edit_note Start the full assessment

@foreach($prerequisites as $p) @endforeach
@if($prerequisites->isNotEmpty())

The most recent training on {{ $worker->first_name }}’s record is selected.

@endif @error('prerequisite')

{{ $message }}

@enderror
@foreach(Pack::FULL_REASONS as $reason) @endforeach
@error('reason')

{{ $message }}

@enderror
{{-- Additional competencies (full only) --}}

Additional competencies — choose the ones that apply to the people {{ $worker->first_name }} supports

@foreach(Pack::sections() as $letter => $sec) @php $mandatory = $letter === Pack::MANDATORY_SECTION; @endphp @endforeach
{{-- Refresher eligibility --}}
You can save each part as you go and come back on your next visit.
{{-- Upload previous --}}
@csrf

upload_file Upload a previous competency record

The signed paper assessment. It’s saved as competent from the date assessed, valid for 12 months.

{{-- History --}}
history

Competency history

@if($errors->editRecord->any())

{{ $errors->editRecord->first() }}

@endif @forelse($history as $h) @php $hs = match ($h->status) { 'competent' => ['bg-primary/10 text-primary', 'Competent'], 'not_competent' => ['bg-error-container text-error', 'Not yet competent'], default => ['bg-gold/20 text-[#8a6d3b]', 'In progress'] }; @endphp

{{ $h->typeLabel() }} {{ $hs[1] }}

{{ $h->assessed_at ? 'Assessed '.$h->assessed_at->format('j M Y') : 'Started '.$h->created_at->format('j M Y') }} @if($h->expires_at) · valid until {{ $h->expires_at->format('j M Y') }} @endif @if($h->signer) · signed off by {{ $h->signer->name }} @endif

@php $canFix = $h->type === 'uploaded' && auth()->user()->primaryRole() === 'registered_manager'; @endphp
@if($h->file_path) download File @endif @if($canFix)
@csrf @method('DELETE')
@endif @if($h->type !== 'uploaded') {{ $h->isOpen() ? 'play_arrow' : 'visibility' }} {{ $h->isOpen() ? 'Continue' : 'View' }} @endif
@if($canFix) @endif
@empty

No competency assessments recorded yet.

@endforelse
@endsection