{% extends 'layouts/base.html' %} {% load i18n %} {% load static %} {% block title %}{{ complaint.reference_number }} - PX360{% endblock %} {% block extra_css %} {% endblock %} {% block content %}
{% trans "Cases" %} {{ complaint.reference_number }} {{ complaint.get_status_display }}
{% if complaint.source_complaint.exists %} {% with sc=complaint.source_complaint.first %}

{% trans "Converted from source complaint" %} {{ sc.reference_number }} {% if sc.px_source %}({{ sc.px_source.get_localized_name }}){% endif %}

{% endwith %} {% endif %} {% if complaint.reopened_from %}

{% trans "Reopened from complaint" %} {{ complaint.reopened_from.reference_number|default:complaint.reopened_from.pk }}

{% endif %} {% if complaint.reopenings.exists %}

{% trans "This complaint has been reopened as" %}: {% for r in complaint.reopenings.all %} {{ r.reference_number|default:r.pk }}{% if not forloop.last %}, {% endif %} {% endfor %}

{% endif %}

{{ complaint.title }}

{% if complaint.ai_brief_en %}
{{ complaint.ai_brief_en }} {% if complaint.ai_brief_ar %} {{ complaint.ai_brief_ar }} {% endif %}
{% endif %}
{% comment %} {% trans "PDF View" %} {% endcomment %} {% if can_edit and complaint.is_active_status and complaint.assigned_to == current_user %} {% endif %}

{% trans "Complaint Details" %}

{% if complaint.source %} {% trans "Source:" %} {{ complaint.source.get_localized_name }} {% endif %}
{% if complaint.description %}

"{{ complaint.description }}"

{% endif %}

{% trans "Location" %}

{% if complaint.location %}{{ complaint.location.name_en }}{% else %}-{% endif %}

{% if complaint.main_section %}

{{ complaint.main_section.name_en }}{% if complaint.subsection %} > {{ complaint.subsection.name_en }}{% endif %}

{% endif %}

{% trans "Severity" %}

{{ complaint.get_severity_display }}

{% trans "Date Created" %}

{{ complaint.created_at|date:"d M Y, h:i A" }}

{% trans "Response Deadline" %}

{{ complaint.due_at|date:"d M Y, h:i A" }} {% if complaint.is_overdue %} {% trans "Overdue" %} {% endif %}

{% if complaint.due_at and complaint.status != 'resolved' and complaint.status != 'closed' and complaint.status != 'cancelled' %}

{% elif complaint.sla_is_overdue_display %}

{{ complaint.sla_is_overdue_display }}

{% endif %}
{% if complaint.escalated_at %}

{% trans "Escalated" %}

{% trans "Escalated on" %} {{ complaint.escalated_at|date:"d M Y, h:i A" }}

{% endif %} {# OVR Section - show when activated or has pending OVR request #} {% if complaint.status != 'closed' and complaint.status != 'cancelled' %} {% if can_edit %}
{% csrf_token %}
{% endif %} {% endif %} {# OVR Pending Approval - Show Approve/Reject buttons for admins #} {% if complaint.status == 'ovr_pending' %}
OVR {% trans "Pending Approval" %}

{% trans "OVR escalation requested. Please review and approve or reject." %}

{% if request.user.is_px_admin or request.user.is_hospital_admin or request.user.is_px_management %}
{% csrf_token %}
{% csrf_token %}
{% else %}

{% trans "Waiting for admin approval." %}

{% endif %}
{% endif %} {% if complaint.expected_result %}

{% trans "Expected Result" %}

{{ complaint.expected_result }}

{% endif %}

{% trans "Classification" %}

{% if complaint.domain %}

{% trans "Domain" %}

{{ complaint.domain.get_localized_name }}

{% endif %} {% if complaint.category %}

{% trans "Category" %}

{{ complaint.category.get_localized_name }}

{% endif %} {% if complaint.subcategory_obj %}

{% trans "Subcategory" %}

{{ complaint.subcategory_obj.get_localized_name }}

{% endif %} {% if complaint.classification_obj %}

{% trans "Classification" %}

{{ complaint.classification_obj.get_localized_name }}

{% endif %}
{% if complaint.patient %}

{% trans "Patient Information" %}

{% trans "Name" %}

{{ complaint.patient.get_full_name }}

{% trans "MRN" %}

{{ complaint.patient.mrn|default:"-" }}

{% trans "Phone" %}

{{ complaint.patient.phone|default:"-" }}

{% endif %}

{% trans "Quick Actions" %}

{% if can_edit and complaint.is_active_status %} {% if current_user.is_px_admin or current_user.is_hospital_admin or complaint.assigned_to == current_user %} {% endif %}
{% csrf_token %}
{% if complaint.assigned_to == current_user %} {% else %}

{% trans "Activate this complaint to perform actions" %}

{% endif %} {% elif complaint.status == 'resolved' or complaint.status == 'closed' %} {% if can_edit %}
{% csrf_token %}
{% if current_user.is_px_admin or current_user.is_hospital_admin or complaint.assigned_to == current_user %} {% endif %} {% endif %} {% else %}
{% trans "No actions available for this status" %}
{% endif %} {% if current_user.is_px_admin or current_user.is_hospital_admin %}
{% csrf_token %}
{% endif %}
{% if can_edit and available_transitions %} {% if current_user.is_px_admin or current_user.is_hospital_admin %}

{% trans "Update Status" %}

{% csrf_token %}
{% endif %} {% endif %} {% include "partials/stage_timeline.html" with stage_timeline=stage_timeline %} {% if show_delay_reason_closure or complaint.delay_reason_closure %}

{% trans "72h Closure Delay Reason" %}

{% if complaint.delay_reason_closure %}

{{ complaint.get_delay_reason_closure_display }}

{% endif %} {% if can_edit and complaint.status != "closed" and complaint.status != "resolved" %}
{% csrf_token %}
{% endif %}
{% endif %} {% if complaint.is_activated %}

{% trans "Staff Assignment" %} ({{ complaint.involved_staff_count }})

{% if complaint.involved_staff.exists %}
{% for staff_inv in complaint.involved_staff.all|slice:":3" %}
{{ staff_inv.staff.first_name|first }}{{ staff_inv.staff.last_name|first }}

{{ staff_inv.staff }}

{{ staff_inv.get_role_display }}

{% endfor %} {% if complaint.involved_staff_count > 3 %} {% endif %}
{% else %}

{% trans "No staff assigned to this case yet." %}

{% if can_edit %} {% trans "Select Staff" %} {% endif %}
{% endif %}
{% endif %} {% if complaint.is_activated %}

{% trans "Assignment Info" %}

  • {% trans "Main Dept:" %} {{ complaint.department.name|default:"-" }}
  • {% trans "Assigned To:" %} {{ complaint.assigned_to.get_full_name|default:"Unassigned" }}
  • {% trans "TAT Goal:" %} {{ complaint.due_at|timeuntil }}
  • {% trans "Status:" %} {{ complaint.get_status_display }}
{%endif%} {% if complaint.involved_departments_count > 0 %}

{% trans "Involved Departments" %} ({{ complaint.involved_departments_count }})

{% for dept in complaint.involved_departments.all %}
{{ dept.department.name }} {% if dept.is_primary %} {% trans "PRIMARY" %} {% endif %}
{% endfor %}
{% endif %}
{% include "components/send_to_modal.html" with users=assignable_users departments=hospital_departments %} {% endblock %}