{% extends 'layouts/base.html' %} {% load i18n %} {% load rca_filters %} {% block title %}{{ rca.title }} - {% trans "RCA" %} - PX360{% endblock %} {% block extra_css %} {% endblock %} {% block content %}
{% trans "RCA" %} {{ rca.title|truncatechars:40 }} {{ rca.get_status_display }}

{{ rca.title }}

{% if related_item %} {% trans "Linked to" %} {{ related_item_type|title }}: {{ related_item }} {% endif %}
{% if rca.status != 'closed' %} {% trans "Edit" %} {% endif %} {% if rca.status == 'review' %}
{% csrf_token %}
{% endif %} {% if rca.status == 'approved' or rca.status == 'in_progress' %}
{% csrf_token %}
{% endif %} {% if rca.status != 'closed' %}
{% csrf_token %}
{% endif %}

{% trans "Incident Details" %}

{{ rca.get_status_display }}

{{ rca.get_severity_display }}

{{ rca.get_priority_display }}

{{ rca.assigned_to.get_full_name|default:"—" }}

{{ rca.hospital }}

{{ rca.department|default:"—" }}

{{ rca.created_at|date:"M d, Y" }}

{{ rca.target_completion_date|default:"—" }}

{{ rca.description|linebreaks }}
{% if rca.background %}
{{ rca.background|linebreaks }}
{% endif %} {% if rca.root_cause_summary %}
{{ rca.root_cause_summary|linebreaks }}
{% endif %}

{% trans "Status Timeline" %}

{% if rca.status != 'closed' %}
{% csrf_token %}
{% endif %}
{% if rca.status_logs.all %}
{% for log in rca.status_logs.all %}
{{ log.get_new_status_display }} {{ log.created_at|date:"M d, Y H:i" }} {% if log.changed_by %} by {{ log.changed_by }} {% endif %}
{% if log.notes %}

{{ log.notes }}

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

{% trans "No status changes recorded." %}

{% endif %}

{% trans "Root Causes" %}

{{ rca.root_causes.all|length }}
{% if rca.status != 'closed' %} {% endif %}
{% if rca.root_causes.all %}
{% for rc in rca.root_causes.all %}
{{ rc.get_category_display }}
{% if rc.risk_score %} Risk: {{ rc.risk_score }} {% endif %} {% if rca.status != 'closed' %}
{% csrf_token %}
{% endif %}

{{ rc.description }}

{% endfor %}
{% else %}

{% trans "No root causes added." %}

{% endif %}

{% trans "Corrective Actions" %}

{{ rca.corrective_actions.all|length }}
{% if rca.status != 'closed' %} {% endif %}
{% if rca.corrective_actions.all %}
{% for action in rca.corrective_actions.all %}
{{ action.get_status_display }}
{% if rca.status != 'closed' %}
{% csrf_token %}
{% endif %}

{{ action.description }}

{{ action.get_action_type_display }} {% if action.responsible_person %} {{ action.responsible_person }} {% endif %} {% if action.target_date %} {{ action.target_date|date:"M d, Y" }} {% endif %}
{% endfor %}
{% else %}

{% trans "No corrective actions added." %}

{% endif %}

{% trans "Notes" %}

{{ rca.notes.all|length }}
{% if rca.status != 'closed' %} {% endif %}
{% if rca.notes.all %}
{% for note in rca.notes.all %}

{{ note.note }}

{{ note.created_by }} — {{ note.created_at|date:"M d, Y H:i" }} {% if note.is_internal %}Internal{% endif %}
{% endfor %}
{% else %}

{% trans "No notes added." %}

{% endif %}
{% if rca.status != 'closed' %} {% endif %} {% endblock %}