{{-- Medication Competency Pack workspace. Full pack, grouped by visit: Visit 1 – assessment 1, knowledge, chosen competencies → sign off visit 1 Visit 2 – assessment 2 → sign off; Visit 3 – assessment 3 → sign off → mark complete. Competencies added later are done and signed on their own. A part is editable only while its visit is the current one (see MedicationCompetency::editable). Refresher: one form. From MedicationCompetencyController@show: $mc, $step --}} @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); $worker = $mc->user; $first = $worker->first_name ?: $worker->name; $locked = ! $mc->isOpen(); $resp = $mc->responses ?? []; $inputCls = 'w-full px-3 py-2 bg-surface-container rounded-lg border-none focus:ring-2 focus:ring-primary/20 text-body-md outline-none disabled:opacity-70'; $statusBadge = match ($mc->status) { 'competent' => ['bg-primary/10 text-primary', 'verified', 'Competent'.($mc->expires_at ? ' until '.$mc->expires_at->format('j M Y') : '')], 'not_competent' => ['bg-error-container text-error', 'block', 'Not yet competent'], default => ['bg-gold/20 text-[#8a6d3b]', 'pending', 'In progress'], }; // Full pack steps grouped by visit: group => [state, [key => [label, icon, done?, sub-label]]] $fmt = fn ($d) => \Carbon\Carbon::parse($d)->format('j M Y'); $groups = []; if ($mc->type === 'full') { $current = $mc->currentVisit(); foreach (range(1, Pack::VISITS) as $n) { $v = $mc->visit($n); $items = ["visit{$n}" => ["Assessment {$n}", 'visibility', $mc->visitPassed($n), $v ? $fmt($v['date']).($mc->visitNotMetCount($n) ? ' · '.$mc->visitNotMetCount($n).' not met' : '') : 'Observed medication round']]; if ($n === 1) { $items['knowledge'] = ['Underpinning knowledge', 'quiz', $mc->knowledgeDone(), isset($resp['knowledge']) ? 'Saved '.$fmt($resp['knowledge']['date']) : 'One-to-one questions']; foreach ($mc->visitOneLetters() as $l) { $items["section{$l}"] = [Pack::sectionLabel($l), 'medication', $mc->sectionDone($l), isset($resp['sections'][$l]) ? 'Saved '.$fmt($resp['sections'][$l]['date']) : 'Additional competency']; } } $so = $mc->visitSignoff($n); $items["signoff{$n}"] = ["Sign off visit {$n}", 'how_to_reg', (bool) $so, $so ? 'Signed '.$fmt($so['date']).' · '.$so['by'] : ($current === $n ? 'When this visit is met' : 'After visit '.($n - 1))]; $groups["Visit {$n}"] = [$so ? 'done' : ($current === $n && ! $locked ? 'current' : 'later'), $items]; } if ($added = $mc->addedLetters()) { $items = []; foreach ($added as $l) { $a = $mc->addition($l); $items["section{$l}"] = [Pack::sectionLabel($l), 'medication', $mc->additionSignedOff($l), $mc->additionSignedOff($l) ? 'Signed '.$fmt($a['signed_at']).' · '.$a['signed_by'] : 'Added '.$fmt($a['added_at']).' · to do']; } $groups['Added competencies'] = [$mc->pendingAdditions() ? 'current' : 'done', $items]; } $groups['Complete'] = [$locked ? 'done' : 'later', ['complete' => [$locked ? 'Outcome' : 'Mark complete', 'workspace_premium', $locked, $locked ? $statusBadge[2] : 'After all three visits']]]; $steps = collect($groups)->flatMap(fn ($g) => $g[1])->all(); $firstOpen = collect($steps)->keys()->first(fn ($k) => ! $steps[$k][2]) ?? 'complete'; $validStep = array_key_exists((string) $step, $steps) || ($step === 'add' && $mc->canAddCompetency()); $active = $validStep ? $step : ($locked ? ($mc->pendingAdditions() ? 'section'.$mc->pendingAdditions()[0] : 'complete') : $firstOpen); [$done, $total] = $mc->progress(); } @endphp arrow_back {{ $worker->name }}’s competency {{-- Header --}}
{{ $worker->name }} · {{ $mc->typeLabel() }}
{{ $worker->location?->name ?? '—' }} @if($mc->details['designation'] ?? null) · {{ $mc->details['designation'] }} @endif @if($mc->details['elearning_completed_at'] ?? null) · {{ $mc->details['training']['title'] ?? 'Medication training' }} completed {{ \Carbon\Carbon::parse($mc->details['elearning_completed_at'])->format('j M Y') }} @endif @if($mc->details['reason'] ?? null) · Reason: {{ $mc->details['reason'] }} @endif
Visit {{ $n }} covers {{ $n === 1 ? 'assessment 1, the underpinning knowledge questions and '.implode(', ', $mc->visitOneLetters()) : 'assessment '.$n }}. @if($n < Pack::VISITS) Signing it off locks these parts and opens visit {{ $n + 1 }}. @else Signing it off lets you mark the pack complete. @endif
@if($so)task_alt Signed off by {{ $so['by'] }} ({{ $so['designation'] }}) — visit date {{ $fmt($so['date']) }}
@if($so['notes']){{ $so['notes'] }}
@endif @elseif(! $canSign)lock {{ $locked ? 'This assessment is closed.' : 'Available once visit '.($n - 1).' is signed off.' }}
@else @if($vTodo)Still to do on this visit:
task_alt Everything on visit {{ $n }} is complete and met.
@endif @endif{{ $mc->signer?->name ? 'Signed off by '.$mc->signer->name : '' }} {{ $mc->signed_off_at ? 'on '.$mc->signed_off_at->format('j M Y') : '' }} @if($mc->expires_at) · valid until {{ $mc->expires_at->format('j M Y') }} @endif
{{ $mc->outcome_notes }}
@endifStill to do before completing:
task_alt All three visits are signed off.
@endifIf {{ $first }} needs further supervision or training before administering medication unsupervised, record it here. Start a new full assessment when they’re ready.