{% extends 'layouts/base.html' %} {% load i18n %} {% block title %}{% trans "Inquiry" %} #{{ inquiry.reference_number|truncatechars:15 }} - PX360{% endblock %} {% block extra_css %} {% endblock %} {% block content %}
{% if source_user %} {% trans "My Inquiries" %} {% else %} {% trans "Inquiries" %} {% endif %} {% trans "Detail" %}

{{ inquiry.subject }}

{{ inquiry.get_status_display }} {% if inquiry.priority %} {{ inquiry.get_priority_display }} {% endif %}
{{ inquiry.reference_number|truncatechars:15 }} | {{ inquiry.created_at|date:"Y-m-d" }} {% if can_respond %} {% endif %}
{% trans "Inquiry Details" %}

{{ inquiry.message|linebreaks }}

{% trans "AI Analysis" %}
{% if can_respond and not inquiry.short_description_en %}
{% endif %}
{% if inquiry.short_description_en %} {% if inquiry.emotion and inquiry.emotion != 'neutral' %}

{% trans "Emotion Analysis" %}

{{ inquiry.get_emotion_display }} {% trans "Confidence" %}: {{ inquiry.emotion_confidence_percent|floatformat:0 }}%
{% trans "Intensity" %} {{ inquiry.emotion_intensity|floatformat:2 }} / 1.0
{% endif %} {% if inquiry.short_description_en %}

{% trans "AI Summary (English)" %}

{{ inquiry.short_description_en }}

{% endif %} {% if inquiry.short_description_ar %}

{% trans "AI Summary (Arabic)" %}

{{ inquiry.short_description_ar }}

{% endif %} {% else %}

{% trans "AI analysis is running. Please refresh the page shortly." %}

{% endif %}
{% if inquiry.outgoing_department %}
{% blocktrans with dept=inquiry.outgoing_department.get_localized_name %}Response from {{ dept }}{% endblocktrans %} {% if inquiry.department_responded_at %} {% trans "Received" %} {% elif inquiry.dept_response_is_overdue %} {% trans "OVERDUE" %} {% else %} {% trans "Awaiting Response" %} {% endif %}
{% if inquiry.transferred_at %}
{% trans "Sent:" %} {{ inquiry.transferred_at|date:"Y-m-d H:i" }} {% if inquiry.dept_response_sla_due_at and not inquiry.department_responded_at %} {% trans "Deadline:" %} {{ inquiry.dept_response_sla_due_at|date:"Y-m-d H:i" }} {% endif %}
{% endif %} {% if inquiry.department_responded_at %}
{{ inquiry.department_responded_by.get_full_name|default:"-" }} {{ inquiry.department_responded_at|date:"Y-m-d H:i" }}
{% if inquiry.department_response_en %}

English

{{ inquiry.department_response_en|linebreaks }}

{% endif %} {% if inquiry.department_response_ar %}

العربية

{{ inquiry.department_response_ar|linebreaks }}

{% endif %} {% if inquiry.department_response_summary_en %}
{% trans "AI Summary" %}

{{ inquiry.department_response_summary_en }}

{% if inquiry.department_response_summary_ar %}

{{ inquiry.department_response_summary_ar }}

{% endif %}
{% endif %}
{% if inquiry.dept_response_acceptance_status == 'acceptable' %} {% trans "Accepted" %} {% elif inquiry.dept_response_acceptance_status == 'not_acceptable' %} {% trans "Not Acceptable" %} {% else %} {% trans "Pending Review" %} {% endif %} {% if inquiry.dept_response_accepted_by %} by {{ inquiry.dept_response_accepted_by.get_full_name }} {% endif %}
{% if can_review_dept_response and inquiry.dept_response_acceptance_status == 'pending' %}
{% csrf_token %}
{% csrf_token %}
{% endif %}
{% if inquiry.dept_response_acceptance_notes %}

{{ inquiry.dept_response_acceptance_notes }}

{% endif %}
{% else %}

{% trans "Waiting for department response..." %}

{% if inquiry.dept_response_sla_due_at %}

{% trans "Deadline:" %} {{ inquiry.dept_response_sla_due_at|date:"Y-m-d H:i" }}

{% endif %}
{% if can_send_reminder %}
{% csrf_token %}
{% if inquiry.dept_response_reminder_sent_at %}
{% csrf_token %}
{% endif %}
{% endif %} {% endif %}
{% endif %} {% if inquiry.response %}
{% trans "Response" %} {% if inquiry.response_sent_at %} {% trans "Sent to inquirer" %} {% endif %}
{% if inquiry.responded_by %}{{ inquiry.responded_by.get_full_name|default:inquiry.responded_by.email }}{% endif %} {% if inquiry.response_sent_at %}{{ inquiry.response_sent_at|date:"Y-m-d H:i" }}{% else %}{{ inquiry.responded_at|date:"Y-m-d H:i" }}{% endif %}
{% if inquiry.response_en %}

English

{{ inquiry.response_en|linebreaks }}

{% endif %} {% if inquiry.response_ar %}

العربية

{{ inquiry.response_ar|linebreaks }}

{% endif %} {% if not inquiry.response_en and not inquiry.response_ar %}

{{ inquiry.response|linebreaks }}

{% endif %}
{% endif %}
{% trans "Timeline" %}

{% trans "Inquiry Created" %}

{% trans "Created by" %} {% if inquiry.created_by %}{{ inquiry.created_by.get_full_name|default:inquiry.created_by.email }}{% endif %}

{{ inquiry.created_at|date:"Y-m-d H:i" }}

{% for update in inquiry.updates.all %}

{% if update.update_type == 'status_change' %}{% trans "Status Changed" %} {% elif update.update_type == 'response' %}{% trans "Response" %} {% elif update.update_type == 'communication' %}{% trans "Communication" %} {% else %}{% trans "Note" %}{% endif %}

{{ update.message|truncatewords:30 }}

{% if update.created_by %}

{% trans "by" %} {{ update.created_by.get_full_name|default:update.created_by.email }}

{% endif %}

{{ update.created_at|date:"Y-m-d H:i" }}

{% endfor %}
{% trans "Actions" %}
{% if can_respond %} {% endif %} {% if inquiry.status == 'resolved' or inquiry.status == 'closed' %} {% if can_respond %}
{% csrf_token %}
{% endif %} {% endif %} {% if can_respond %} {% endif %} {% if can_edit and inquiry.status != 'closed' %}
{% csrf_token %}
{% endif %} {% if can_edit and inquiry.status != 'closed' %} {% trans "Edit Inquiry" %} {% endif %} {% trans "Initiate RCA" %} {% trans "Create QI Project" %} {% if can_respond %}

{% trans "Department Actions" %}

{% if inquiry.outgoing_department %} {% if not inquiry.department_responded_at %} {% trans "Respond as Department" %} {% else %}
{% trans "Department has responded" %}
{% endif %}
{% trans "Transferred to" %} {{ inquiry.outgoing_department.get_localized_name }}
{% else %} {% endif %}
{% endif %}
{% trans "Contact Information" %}
{% trans "Name" %} {{ inquiry.contact_name|default:"-" }}
{% trans "Phone" %} {{ inquiry.contact_phone|default:"-" }}
{% trans "Email" %} {{ inquiry.contact_email|default:"-" }}
{% include "partials/stage_timeline.html" with stage_timeline=stage_timeline %}
{% trans "Organization" %}
{% trans "Hospital" %} {{ inquiry.hospital.name }}
{% if inquiry.department %}
{% trans "Department" %} {{ inquiry.department.name }}
{% endif %}
{% trans "Location" %} {% if inquiry.location %}{{ inquiry.location.name }}{% else %}-{% endif %}
{% if inquiry.main_section %}
{% trans "Section" %} {{ inquiry.main_section.name }}
{% endif %} {% if inquiry.subsection %}
{% trans "Subsection" %} {{ inquiry.subsection.name }}
{% endif %}
{% trans "Category" %} {{ inquiry.get_category_display|default:"-" }}
{% if inquiry.taxonomy_domain or inquiry.taxonomy_category or inquiry.taxonomy_subcategory or inquiry.taxonomy_classification %}
{% trans "SHCT Taxonomy" %} {{ inquiry.taxonomy_domain.name_en|default:"" }} {% if inquiry.taxonomy_category %}> {{ inquiry.taxonomy_category.name_en }}{% endif %} {% if inquiry.taxonomy_subcategory %}> {{ inquiry.taxonomy_subcategory.name_en }}{% endif %} {% if inquiry.taxonomy_classification %}> {{ inquiry.taxonomy_classification.name_en }}{% endif %}
{% endif %} {% if inquiry.priority %}
{% trans "Priority" %} {{ inquiry.get_priority_display }}
{% endif %} {% if inquiry.outgoing_department %}
{% trans "Transferred Dept" %} {{ inquiry.outgoing_department.get_localized_name }} {% if not inquiry.department_responded_at %} {% trans "Awaiting" %} {% else %} {% trans "Responded" %} {% endif %}
{% endif %} {% if inquiry.timeline_sla %}
{% trans "SLA" %} {{ inquiry.get_timeline_sla_display }}
{% endif %}
{% trans "Notes" %}
{% if can_edit or inquiry.assigned_to == request.user %}
{% csrf_token %}
{% if can_edit %}
{% endif %}
{% else %} {% if inquiry.staff_notes %}

{% trans "Staff Notes" %}

{{ inquiry.staff_notes|linebreaks }}

{% endif %} {% if inquiry.supervisor_notes %}

{% trans "Supervisor Notes" %}

{{ inquiry.supervisor_notes|linebreaks }}

{% endif %} {% endif %}
{% if linked_rcas %}
{% trans "Root Cause Analyses" %}
{% endif %}
{% include "components/send_to_modal.html" with users=assignable_users departments=hospital_departments %} {% endblock %}