@extends('layouts.app') @section('title', __('messaging::messages.consent.title')) @section('content')

{{ __('messaging::messages.consent.title') }}

{{ __('messaging::messages.consent.subtitle') }}

{{-- The rule the whole screen exists to serve, said once at the top. A member of reception recording an opt-in is asserting that a conversation happened; they should be able to read what that means before they do it. --}}
{{ __('messaging::messages.consent.rule_title') }}

{{ __('messaging::messages.consent.rule_text') }}

@if (session('status')) @endif @can('messaging.consent') {{-- ── Record for a patient not on the list ───────────────────────── --}}

{{ __('messaging::messages.consent.record_title') }}

{{ __('messaging::messages.consent.record_hint') }}

{{-- The same type-ahead the booking and lab-order screens use, against the Patients module's published directory. No patient id is ever typed, and this module never touches a Patient model to find one. --}}
    {{-- Revealed once a patient is chosen: an opt-in button with nobody attached to it is a control that can only go wrong. --}}

    {{ __('messaging::messages.consent.recording_for') }}

    @foreach ($channels as $value => $label) @foreach (['opt_in', 'opt_out'] as $decision)
    @csrf
    @endforeach @endforeach
    @endcan {{-- ── Filters ────────────────────────────────────────────────────────── --}}
    {{-- ── What is on record ──────────────────────────────────────────────── --}}
    @if ($rows->isEmpty())

    {{ __('messaging::messages.consent.empty_title') }}

    {{ __('messaging::messages.consent.empty_text') }}

    @else
    @foreach ($rows as $consent) @php $patient = $patients[$consent->patient_id] ?? null; $allowed = $consent->isActive(); @endphp @endforeach
    {{ __('appointments::messages.appointments.patient') }} {{ __('messaging::messages.consent.channel') }} {{ __('common.status') }} {{ __('messaging::messages.consent.recorded') }} {{ __('common.actions') }}
    @if ($patient === null) {{ __('appointments::messages.appointments.unknown_patient') }} @else {{ $patient->name }} {{ $patient->mrn }} @endif {{ $consent->channel->label() }} {{ $allowed ? __('messaging::messages.consent.allowed') : __('messaging::messages.consent.withdrawn') }} {{ $consent->recordedBy?->name ?? __('messaging::messages.consent.by_patient') }} @php($at = $allowed ? $consent->opted_in_at : $consent->opted_out_at) @if ($at) · {{ $at->format('d M Y') }} @endif @if ($consent->note) {{ $consent->note }} @endif @can('messaging.consent') {{-- Only the opposite of what is on record: a button that re-asserts the current state does nothing and invites a click that means nothing. --}} @if ($patient !== null)
    @csrf
    @endif @endcan
    @endif
    @if ($consents->hasPages())
    {{ $consents->links() }}
    @endif
    @endsection