{% 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 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 not workflow_steps.cancelled %}
{% trans "Created" %}
{% if workflow_steps.activated %}
{% else %}
{% endif %} {% trans "Activate" %}
{% if workflow_steps.taxonomy_reviewed %}
{% elif workflow_steps.activated %}
{% else %}
{% endif %} {% trans "Taxonomy" %}
{% if workflow_steps.sent_to_department %}
{% elif workflow_steps.taxonomy_reviewed %}
{% else %}
{% endif %} {% trans "Send to Dept" %}
{% if workflow_steps.department_responded %}
{% elif workflow_steps.sent_to_department %}
{% else %}
{% endif %} {% trans "Response" %}
{% if workflow_steps.resolved %}
{% elif workflow_steps.department_responded %}
{% else %}
{% endif %} {% trans "Resolve" %}
{% if complaint.is_active_status and can_edit %} {% if not workflow_steps.activated %}

{% trans "Activate this complaint" %}

{% trans "Assign it to yourself to start working on it" %}

{% csrf_token %}
{% elif not workflow_steps.taxonomy_reviewed %}

{% trans "Review taxonomy" %}

{% trans "Verify the AI classification before sending to the department." %}

{{ complaint.domain.get_localized_name|default:"—" }} {% 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 %}
{% csrf_token %}
{% elif not workflow_steps.sent_to_department %}

{% trans "Send to department" %}

{% trans "Notify the champion and manager to collect their response" %}

{% elif not workflow_steps.department_responded %}

{% trans "Awaiting department response" %}

{% if dept_response_progress.total > 0 %}

{% blocktrans with responded=dept_response_progress.responded total=dept_response_progress.total %}{{ responded }} of {{ total }} departments responded{% endblocktrans %}

{% else %}

{% trans "The department champion and manager have been notified." %}

{% endif %}
{% if dept_response_progress.pending %}
{% for dept_name in dept_response_progress.pending %}

{{ dept_name }}

{% endfor %}
{% endif %}
{% trans "Don't want to wait?" %}
{% elif not workflow_steps.resolved %}

{% trans "Resolve this complaint" %}

{% if dept_response_progress.total > 0 and dept_response_progress.responded < dept_response_progress.total %} {% blocktrans with responded=dept_response_progress.responded total=dept_response_progress.total %}{{ responded }} of {{ total }} departments responded.{% endblocktrans %} {% if dept_response_progress.pending %} {% trans "Still waiting for:" %} {{ dept_response_progress.pending|join:", " }}{% endif %} {% else %} {% trans "The department has responded. Review and close the complaint." %} {% endif %}

{% endif %} {% elif workflow_steps.resolved %} {% if complaint.satisfaction %}

{% trans "Complaint resolved" %}

{% trans "This complaint has been successfully resolved." %}

{% if complaint.resolution_outcome %} {% trans "Outcome:" %} {{ complaint.get_resolution_outcome_display }} {% endif %} {% if complaint.resolution_sent_at %} {% trans "Sent to patient" %} {% endif %} {% if complaint.satisfaction == 'satisfied' %} {% elif complaint.satisfaction == 'neutral' %} {% elif complaint.satisfaction == 'dissatisfied' %} {% else %}{% endif %} {% if complaint.satisfaction_locked_by_patient %}{% endif %} {% if complaint.satisfaction_locked_by_patient %}{% trans "Patient (locked):" %}{% else %}{% trans "Patient:" %}{% endif %} {{ complaint.get_satisfaction_display }} {% if complaint.satisfaction_set_at %} {{ complaint.satisfaction_set_at|date:"Y-m-d H:i" }} {% endif %}
{% else %} {% if complaint.satisfaction_window_expired %}

{% trans "Satisfaction window expired" %}

{% trans "Satisfaction can only be set within 5 days of resolution." %}

{% else %}

{% trans "Record patient satisfaction" %}

{% trans "Call the patient to confirm resolution, then capture their satisfaction level." %}

{% endif %} {% endif %} {% endif %}
{% endif %}
{% if complaint.description %}

{% trans "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 %}· {% 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 %} {% 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 %} {% if can_edit %} {% endif %} {% if complaint.taxonomy_reviewed_at %} {% trans "Reviewed" %} {% 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 %}
{% if complaint.activated_at %} {% include "complaints/partials/pdf_summary_panel.html" %} {% else %}

{% trans "PDF Report" %}

{% trans "Activate this complaint to enable PDF report generation." %}

{% endif %}

{% 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 %} {% if complaint.escalated_at %} {% else %} {% endif %}
{% 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 %}
{% endblock %}