{{-- resources/views/probation/cases/_treatment_plan.blade.php Tool C โ€” Individual Treatment Plan (Sentence plan, from Tool A = RNR). Areas flagged in the latest RNR come first, open, with the RNR comments as a starting point for "Needs". Every area filled in is mirrored in the Interventions tab automatically when saved. --}} @php $areas = config('probation_supervision.treatment_areas'); $instAreas = config('probation_supervision.treatment_areas_institution'); $statuses = config('probation_supervision.intervention_statuses'); $items = $case->treatmentPlan->keyBy('area'); $others = $case->treatmentPlan->where('area', 'other')->values(); $rnr = $case->assessments->where('tool', 'RNR')->sortByDesc('id')->first(); $rr = optional($rnr)->responses ?? []; $flagged = function ($a) use ($rr) { return $a['rnr'] && (($rr['summary'][$a['rnr']] ?? 'N') === 'Y'); }; // flagged areas first, keep config order otherwise $ordered = collect($areas)->sortBy(fn ($a, $k) => ($flagged($a) ? 0 : 1) . str_pad(array_search($k, array_keys($areas)), 3, '0', STR_PAD_LEFT)); $nFlagged = collect($areas)->filter($flagged)->count(); $instOpen = $case->treatmentPlan->whereIn('area', array_keys($instAreas))->count() > 0 || $case->case_type === 'aftercare_borstal'; $officer = optional($case->officer)->name; $ivBadge = function ($item) use ($statuses) { $iv = optional($item)->intervention; if (!$iv) return ''; $cls = ['planned' => 'bg-secondary', 'ongoing' => 'bg-primary', 'completed' => 'bg-success'][$iv->status] ?? 'bg-secondary'; return 'Intervention ยท ' . e($statuses[$iv->status] ?? $iv->status) . ''; }; @endphp
Individual Treatment Plan โ€” Tool C
Every area you fill in is added to Interventions automatically when you save. Clear an area to remove it.
@if($rnr) {{ $nFlagged }} area(s) flagged from RNR of {{ optional($rnr->assessed_on)->format('d M Y') }} @else No RNR yet โ€” complete it in Assessments to see flagged areas. @endif
@if(optional($rnr)->needs_identified)
Needs identified (RNR): {{ $rnr->needs_identified }}
@endif
@csrf
@foreach($ordered as $key => $a) @php $it = $items->get($key); $flag = $flagged($a); $open = $flag || $it; $pre = $it ? $it->needs : ($flag ? ($rr['domain_comments'][$a['rnr']] ?? '') : ''); @endphp

@include('probation.cases._treatment_plan_fields', ['name' => "plan[$key]", 'it' => $it, 'pre' => $pre, 'officer' => $officer])
@endforeach
{{-- For prisons only (from Tool B) --}}
Institution-related areas (from Tool B)
@foreach($instAreas as $key => $title) @php $it = $items->get($key); @endphp

@include('probation.cases._treatment_plan_fields', ['name' => "plan[$key]", 'it' => $it, 'pre' => optional($it)->needs, 'officer' => $officer])
@endforeach
{{-- Other? --}}
Other
@foreach($others as $i => $it)
{!! $ivBadge($it) !!}
@include('probation.cases._treatment_plan_fields', ['name' => "other[$i]", 'it' => $it, 'pre' => $it->needs, 'officer' => $officer])
@endforeach
Saved areas appear under Interventions; progress (planned / ongoing / completed) is updated there.