{% extends 'layouts/base.html' %} {% load i18n %} {% load static %} {% get_current_language as LANG %} {% block title %}{{ complaint.reference_number }} - PX360{% endblock %} {% block extra_css %} {% endblock %} {% block content %}
{% trans "Cases" %} {{ complaint.reference_number }} {{ complaint.get_status_display }} {% if complaint.patient_contact_status == 'contacted' %} {% trans "Patient Contacted" %} {% elif complaint.patient_contact_status == 'contacted_no_response' %} {% trans "No Response" %} {% endif %} {% if not complaint.sent_to_any_department %} {% trans "Not Sent to Dept" %} {% endif %}
{% 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 }}

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

{% trans "Complaint Description" %}

"{{ complaint.description }}"

{% endif %}

{% trans "Location" %}

{% if can_manage_actions and complaint.is_active_status %} {% endif %}
{% if complaint.department or complaint.location_type or complaint.area or complaint.section %}

{% if complaint.department %}{{ complaint.department.get_localized_name }}{% else %}-{% endif %}

{% if complaint.location_type %}
{{ complaint.get_location_type_display }}
{% endif %} {% if complaint.area or complaint.department.category or complaint.section or complaint.zone or complaint.floor %}
{% if complaint.area %}
{% trans "Area" %}
{% if LANG == 'ar' and complaint.area.name_ar %}{{ complaint.area.name_ar }}{% else %}{{ complaint.area.name_en }}{% endif %}
{% endif %} {% if complaint.department and complaint.department.category %}
{% trans "Category" %}
{{ complaint.department.get_category_display }}
{% endif %} {% if complaint.section %}
{% trans "Section" %}
{{ complaint.section.get_localized_name }}
{% endif %} {% if complaint.zone %}
{% trans "Zone" %}
{{ complaint.zone }}
{% endif %} {% if complaint.floor %}
{% trans "Floor" %}
{{ complaint.floor }}
{% endif %}
{% endif %} {% else %}

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

{% if complaint.legacy_main_section %}

{{ complaint.legacy_main_section.name_en }}{% if complaint.legacy_subsection %} > {{ complaint.legacy_subsection.name_en }}{% endif %}

{% endif %} {% endif %}

{% trans "Severity" %}

{{ complaint.get_severity_display }}

{% trans "Classification" %}

{% if complaint.ai_brief_en %} {% if LANG == 'ar' and complaint.ai_brief_ar %} {{ complaint.ai_brief_ar }} {% else %} {{ complaint.ai_brief_en }} {% endif %} {% else %}-{% endif %}

{% trans "Created" %}

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

{% trans "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.domain or complaint.category or complaint.subcategory_obj or complaint.classification_obj %}
{% trans "Taxonomy" %}: {% if complaint.domain %}{{ complaint.domain.get_localized_name }}{% endif %} {% if complaint.category %}{{ complaint.category.get_localized_name }}{% endif %} {% if complaint.subcategory_obj %}{{ complaint.subcategory_obj.get_localized_name }}{% endif %} {% if complaint.classification_obj %}{{ complaint.classification_obj.get_localized_name }}{% endif %}
{% endif %} {% if complaint.source %}
{% trans "Source" %}: {{ complaint.source.get_localized_name }}
{% endif %} {% if complaint.escalated_at %}

{% trans "Escalated" %}

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

{% endif %} {% 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 %} {% if complaint.patient %}
{{ complaint.patient.get_full_name }} | {% trans "MRN:" %} {{ complaint.patient.mrn|default:"-" }} {% if complaint.patient.phone %} | {{ complaint.patient.phone }} {% endif %}
{% endif %}
{% include "complaints/partials/pdf_summary_panel.html" %}

{% trans "Quick Actions" %}

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

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

{% endif %} {% 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 complaint.status != 'open' %}

{% trans "Patient Contact" %}

{% if complaint.patient_contact_status and complaint.patient_contact_status != 'not_contacted' %}
{% if complaint.patient_contact_status == 'contacted' %} {% else %} {% endif %} {{ complaint.get_patient_contact_status_display }}
{% if complaint.patient_contact_status_at %} {{ complaint.patient_contact_status_at|date:"Y-m-d H:i" }} {% endif %} {% if complaint.patient_contact_status_by %} · {% trans "by" %} {{ complaint.patient_contact_status_by.get_full_name }} {% endif %}
{% endif %} {% if can_edit %}
{% csrf_token %}
{% if complaint.patient_contact_status != 'not_contacted' %} {% endif %}
{% elif not complaint.patient_contact_status or complaint.patient_contact_status == 'not_contacted' %}

{% trans "Patient has not been contacted yet." %}

{% endif %}
{% endif %}
{% if can_manage_actions and complaint.is_active_status %} {% endif %} {% include "components/send_to_modal.html" with users=send_to_users departments=hospital_departments email_subject=send_to_email_subject email_body=send_to_email_body %} {% include "components/department_response_modal.html" %} {% endblock %}