{% extends "layouts/base.html" %} {% load i18n %} {% load static %} {% block title %}{{ observation.tracking_code }} - {% trans "Observation Detail" %} - PX360{% endblock %} {% block extra_css %} {% endblock %} {% block content %}
{% trans "Observations" %} {{ observation.tracking_code }} {{ observation.get_status_display }} {{ observation.get_severity_display }} {% if observation.is_anonymous %} {% trans "Anonymous" %} {% endif %} {% if observation.is_overdue %} {% trans "Overdue" %} {% endif %} {% if not observation.sent_to_department %} {% trans "Not Sent to Dept" %} {% endif %}

{% if observation.title %}{{ observation.title }}{% else %}{{ observation.description|truncatewords:10 }}{% endif %}

{% comment %} {% trans "PDF" %} {% endcomment %}
{% include "core/workflow_stepper.html" %} {% if observation.status not in 'resolved,closed' and can_send_to_department and not observation.sent_to_department %}

{% trans "Send to department" %}

{% trans "Assign this observation to a department for handling." %}

{% elif observation.sent_to_department and not observation.department_responded_at %}

{% trans "Awaiting department response" %}

{% if observation.dept_response_reminder_sent_at %} {% trans "1st:" %} {{ observation.dept_response_reminder_sent_at|date:"M d, H:i" }} {% endif %} {% if observation.dept_response_second_reminder_sent_at %} {% trans "2nd:" %} {{ observation.dept_response_second_reminder_sent_at|date:"M d, H:i" }} {% endif %} {% if not observation.dept_response_reminder_sent_at %} {% trans "No reminders sent yet" %} {% endif %}
{% if can_send_reminder %}
{% if not observation.dept_response_reminder_sent_at %}
{% csrf_token %}
{% elif not observation.dept_response_second_reminder_sent_at %}
{% csrf_token %}
{% endif %}
{% endif %}
{% elif observation.department_responded_at and observation.status not in 'resolved,closed' %}

{% trans "Department has responded" %}

{% trans "Decide what to do next, then resolve and inform the reporter." %}

{% if can_convert %}
{% if not observation.action_id %} {% trans "Create Action" %} {% trans "Minor / isolated" %} {% else %}
{% trans "Action exists" %}
{% endif %} {% trans "Start RCA" %} {% trans "Serious / pattern" %} {% if can_admin %} {% trans "QI Project" %} {% trans "Systemic trend" %} {% endif %}
{% csrf_token %}
{% else %} {# Non-admin viewers see only the simple resolve form #}
{% csrf_token %}
{% endif %}
{% elif observation.status in 'resolved,closed' %}

{% trans "This observation is resolved" %}

{% if observation.response_sent_at %}

{% trans "Reporter informed on" %} {{ observation.response_sent_at|date:"M d, Y H:i" }}

{% else %}

{% trans "Reporter has not yet been informed." %}

{% endif %}
{% if can_convert and not observation.response_sent_at and observation.status == 'resolved' %} {% endif %}
{% endif %}
{% if observation.created_by or observation.reporter_phone or observation.reporter_email %}
{% if observation.created_by %} {{ observation.created_by.get_full_name|default:observation.created_by.email }} {% endif %} {% if observation.reporter_phone %} · {{ observation.reporter_phone }} {% endif %} {% if observation.reporter_email %} · {{ observation.reporter_email }} {% endif %}
{% endif %}

{{ observation.description }}

{% if observation.description_en %}

{{ observation.description_en }}

{% endif %} {% if observation.emotion or observation.short_description_en or observation.suggested_actions or observation.suggested_action_en %}
{% trans "AI Analysis" %}
{% if observation.emotion and observation.emotion != 'neutral' %}
{{ observation.emotion|title }} {% trans "Confidence" %}: {{ observation.emotion_confidence_percent|floatformat:0 }}%
{% endif %} {% if observation.short_description_en %}

{{ observation.short_description_en }}

{% if observation.short_description_ar %}

{{ observation.short_description_ar }}

{% endif %} {% elif observation.suggested_action_en %}

{{ observation.suggested_action_en }}

{% if observation.suggested_action_ar %}

{{ observation.suggested_action_ar }}

{% endif %}
{% elif observation.suggested_actions %}
{% for action in observation.suggested_actions %}
{{ action.priority }}

{{ action.action_en }}

{% endfor %}
{% endif %}
{% endif %}

{% trans "Category" %}

{{ observation.category.get_localized_name|default:"-" }}

{% trans "Location" %}

{% if observation.legacy_location %}{{ observation.legacy_location.name_en }}{% elif observation.location_text %}{{ observation.location_text }}{% else %}-{% endif %}

{% if observation.legacy_main_section %}

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

{% endif %}

{% trans "Incident Date" %}

{{ observation.incident_datetime|date:"d M Y" }}

{% comment %}

{% trans "Deadline" %}

{% if observation.due_at %}{{ observation.due_at|date:"d M Y" }}{% else %}-{% endif %} {% if observation.is_overdue %}{% endif %}

{% endcomment %}
{% if observation.taxonomy_domain or observation.taxonomy_category or observation.taxonomy_subcategory or observation.taxonomy_classification %}
{% trans "Taxonomy" %}: {% if observation.taxonomy_domain %}{{ observation.taxonomy_domain.name_en }}{% endif %} {% if observation.taxonomy_category %}{{ observation.taxonomy_category.name_en }}{% endif %} {% if observation.taxonomy_subcategory %}{{ observation.taxonomy_subcategory.name_en }}{% endif %} {% if observation.taxonomy_classification %}{{ observation.taxonomy_classification.name_en }}{% endif %}
{% endif %}
{% if observation.is_anonymous %}
{% trans "Anonymous submission" %}
{% else %}
{% comment %} {% if observation.reporter_name %} {{ observation.reporter_name }} {% endif %} {% if observation.reporter_phone %} | {{ observation.reporter_phone }} {% endif %} {% if observation.reporter_email %} | {{ observation.reporter_email }} {% endif %} {% if not observation.reporter_name and not observation.reporter_phone and not observation.reporter_email %} {% trans "Reporter info not available" %} {% endif %} {% endcomment %}
{% endif %}
{% if observation.sent_to_department and observation.assigned_department and observation.department_responded_at %}

{% blocktrans with dept=observation.assigned_department.get_localized_name|default:observation.assigned_department.name %}Response from {{ dept }}{% endblocktrans %}

{% if observation.department_responded_at %} {% trans "Received" %} {% elif observation.dept_response_is_overdue %} {% trans "OVERDUE" %} {% else %} {% trans "Awaiting" %} {% endif %}
{% if observation.forwarded_to_dept_at %}
{% trans "Sent:" %} {{ observation.forwarded_to_dept_at|date:"Y-m-d H:i" }} {% if observation.dept_response_sla_due_at and not observation.department_responded_at %} {% trans "Deadline:" %} {{ observation.dept_response_sla_due_at|date:"Y-m-d H:i" }} {% endif %}
{% endif %} {% if observation.department_responded_at %}
{{ observation.department_responded_by.get_full_name|default:"-" }} {{ observation.department_responded_at|date:"Y-m-d H:i" }}
{% if observation.department_response_en %}

English

{{ observation.department_response_en|linebreaks }}

{% endif %} {% if observation.department_response_ar %}

العربية

{{ observation.department_response_ar|linebreaks }}

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

{{ observation.department_response_summary_en }}

{% if observation.department_response_summary_ar %}

{{ observation.department_response_summary_ar }}

{% endif %}
{% endif %} {% else %}

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

{% if observation.dept_response_sla_due_at %}

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

{% endif %}
{% if can_send_reminder %}
{% csrf_token %}
{% if observation.dept_response_reminder_sent_at %}
{% csrf_token %}
{% endif %}
{% endif %} {% if can_respond_to_department %}
{% endif %} {% endif %}
{% endif %} {% if observation.responded_at and observation.response %}

{% trans "Response to Reporter" %}

{% trans "Response Sent" %} {% if observation.responded_by %} — {{ observation.responded_by.get_full_name }} • {{ observation.responded_at|date:"M d, Y H:i" }} {% endif %}

{{ observation.response|linebreaks }}

{% endif %}
{% if observation.status not in 'resolved,closed' %}

{% trans "Quick Actions" %}

{% if observation.status == 'open' and not observation.activated_at %} {% if can_convert %}
{% csrf_token %}
{% csrf_token %}
{% else %}

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

{% endif %} {% else %} {% if can_convert and observation.status not in 'closed,cancelled' %} {% endif %} {% if can_convert %} {% endif %} {% if can_admin and not observation.action_id %} {% trans "Convert To Action" %} {% endif %} {% if can_send_to_department and not observation.sent_to_department %} {% endif %} {% if can_convert and observation.status == 'in_progress' %}
{% csrf_token %}
{% endif %} {% comment %} {% if can_triage and observation.status != 'closed' and observation.status != 'cancelled' and observation.status != 'rejected' %} {% endif %} {% endcomment %} {% if can_convert %} {% trans "RCA" %} {% endif %} {% if can_admin %} {% trans "QI Project" %} {% endif %} {% if observation.status == 'resolved' or observation.status == 'closed' %} {% if can_triage %}
{% csrf_token %}
{% endif %} {% endif %} {% if can_delete %}
{% csrf_token %}
{% endif %} {% endif %}
{% endif %} {% if can_convert %} {% endif %}

{% trans "Assignment" %}

  • {% trans "Department" %} {{ observation.assigned_department.get_localized_name|default:_("Not assigned") }}
  • {% trans "Assigned To" %} {{ observation.assigned_to.get_full_name|default:_("Not assigned") }}
{% if observation.person_noted or observation.department_noted or observation.communication_method or observation.communication_datetime or observation.patient_file_number %}

{% trans "Communication" %}

    {% if observation.patient_file_number %}
  • {% trans "File Number" %} {{ observation.patient_file_number }}
  • {% endif %} {% if observation.person_noted %}
  • {% trans "Person Noted" %} {{ observation.person_noted }}
  • {% endif %} {% if observation.department_noted %}
  • {% trans "Department Noted" %} {{ observation.department_noted.get_localized_name }}
  • {% endif %} {% if observation.communication_method %}
  • {% trans "Via" %} {{ observation.communication_method }}
  • {% endif %} {% if observation.communication_datetime %}
  • {% trans "Contacted At" %} {{ observation.communication_datetime|date:"M d, Y H:i" }}
  • {% endif %}
{% endif %} {% if px_action %}

{% trans "Linked PX Action" %}

{{ px_action.title|truncatewords:10 }}

{% trans "View Action" %}
{% endif %} {% comment %} {% if can_triage %}

{% trans "Triage" %}

{% csrf_token %}
{{ triage_form.assigned_department }}
{{ triage_form.assigned_to }}
{{ triage_form.status }}
{{ triage_form.note }}
{% endif %} {% endcomment %}
{% include "components/send_to_modal.html" with users=assignable_users departments=departments %} {% include "components/department_response_modal.html" %} {% endblock %}