{% 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 %} {{ inquiry.reference_number }} {{ inquiry.get_status_display }} {% if inquiry.priority %} {{ inquiry.get_priority_display }} {% endif %} {% if not inquiry.sent_to_department %} {% trans "Not Sent to Dept" %} {% endif %} {% if inquiry.contact_status == 'contacted_no_response' %} {% trans "No Response" %} {% elif inquiry.contact_status == 'contacted' %} {% trans "Contacted" %} {% endif %}

{{ inquiry.subject }}

{% comment %} {% trans "PDF" %} {% endcomment %} {{ inquiry.created_at|date:"Y-m-d" }} {% comment %} {% if can_respond and inquiry.activated_at %} {% endif %} {% endcomment %}
{% include "core/workflow_stepper.html" %} {% if inquiry.is_active_status %} {% if inquiry.status == 'open' and not inquiry.activated_at %} {% if can_edit %}

{% trans "Activate this inquiry" %}

{% trans "Activation moves it to In Progress so actions become available." %}

{% csrf_token %}
{% csrf_token %}
{% else %}

{% trans "Activate this inquiry to perform actions." %}

{% endif %} {% elif not inquiry.sent_to_department and can_respond %}

{% trans "Send to department" %}

{% trans "Notify the department champion/manager to handle this inquiry." %}

{% elif inquiry.sent_to_department and not inquiry.department_responded_at and can_respond %}
{% if inquiry.dept_response_reminder_sent_at %} {% trans "1st:" %} {{ inquiry.dept_response_reminder_sent_at|date:"M d, H:i" }} {% endif %} {% if inquiry.dept_response_second_reminder_sent_at %} {% trans "2nd:" %} {{ inquiry.dept_response_second_reminder_sent_at|date:"M d, H:i" }} {% endif %}
{% if not inquiry.dept_response_reminder_sent_at %}
{% csrf_token %}
{% elif not inquiry.dept_response_second_reminder_sent_at %}
{% csrf_token %}
{% endif %}
{% elif inquiry.status != 'resolved' and inquiry.status != 'closed' and can_respond %}

{% trans "Department has responded" %}

{% trans "Review the response and resolve this inquiry." %}

{% comment %}
{% csrf_token %}
{% endcomment %} {% if can_respond and inquiry.activated_at %}
{% csrf_token %}
{% endif %}
{% endif %} {% elif inquiry.status == 'resolved' or inquiry.status == 'closed' %} {% if can_respond %}

{% trans "This inquiry is resolved" %}

{% trans "Reopen it if further action is needed." %}

{% csrf_token %}
{% endif %} {% endif %}
{% if inquiry.patient or inquiry.contact_name or inquiry.contact_phone %}
{% if inquiry.patient %}{{ inquiry.patient.get_full_name|default:"-" }}{% else %}{{ inquiry.contact_name }}{% endif %} {% if inquiry.patient and inquiry.patient.mrn %} · MRN: {{ inquiry.patient.mrn }} {% endif %} {% with phone=inquiry.patient.phone|default:inquiry.contact_phone %} {% if phone %} · {{ phone }} {% endif %} {% endwith %} {% if inquiry.contact_email %} · {{ inquiry.contact_email }} {% endif %}
{% endif %}

{{ inquiry.message|linebreaks }}

{% if inquiry.short_description_en or inquiry.emotion %}
{% trans "AI Analysis" %}
{% if can_respond and not inquiry.short_description_en %} {% endif %}
{% if inquiry.emotion and inquiry.emotion != 'neutral' %}
{{ 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 %}

{{ inquiry.short_description_en }}

{% if inquiry.short_description_ar %}

{{ inquiry.short_description_ar }}

{% endif %} {% else %}

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

{% endif %}
{% endif %}
{% if inquiry.outgoing_department and inquiry.department_responded_at %}

{% 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 %} {% 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_respond and not inquiry.sent_to_department %} {% 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 "Quick Actions" %}

{% if inquiry.resolved_at %}{% endif %}
{% if inquiry.status == 'open' and not inquiry.activated_at %} {% if can_edit %}
{% csrf_token %}
{% csrf_token %}
{% else %}

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

{% endif %} {% else %} {% comment %} {% if can_respond %} {% endif %} {% endcomment %} {% if inquiry.status == 'resolved' or inquiry.status == 'closed' %} {% if can_respond %}
{% csrf_token %}
{% endif %} {% endif %} {% if inquiry.is_active_status %} {% if can_respond %} {% endif %} {% if can_edit and inquiry.status != 'closed' %} {% endif %} {% if can_edit and inquiry.status != 'closed' %} {% trans "Edit" %} {% endif %} {% comment %} {% if can_admin %} {% trans "RCA" %} {% trans "QI Project" %} {% endif %} {% endcomment %} {% comment %} {% if can_edit and inquiry.status != 'closed' and inquiry.status != 'cancelled' %} {% endif %} {% endcomment %} {% if can_respond %} {% endif %} {% endif %} {% endif %}
{% if can_edit and inquiry.status != 'closed' %} {% endif %} {% if inquiry.resolved_at or inquiry.closed_at %}

{% trans "Resolution & Closure" %}

{% if inquiry.resolved_at %}

{% trans "Resolved" %}

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

{% if inquiry.resolved_by %}

{% trans "by" %} {{ inquiry.resolved_by.get_full_name }}

{% endif %}
{% endif %} {% if inquiry.closed_at %}

{% trans "Closed" %}

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

{% if inquiry.closed_by %}

{% trans "by" %} {{ inquiry.closed_by.get_full_name }}

{% endif %}
{% endif %}
{% endif %}
{% if can_edit and inquiry.status != 'closed' %} {% endif %} {% include "components/send_to_modal.html" with users=send_to_users departments=hospital_departments %} {% include "components/department_response_modal.html" %} {% endblock %}