{% extends "layouts/base.html" %} {% load i18n %} {% load static %} {% load survey_filters %} {% block title %}{% trans "Survey" %} #{{ survey.id|slice:":8" }} - PX360{% endblock %} {% block extra_css %} {% endblock %} {% block content %}
{% trans "Back to Surveys" %}
{% trans "Surveys" %} #{{ survey.id|slice:":8" }} {{ survey.get_status_display }}

{{ survey.survey_template.name }}

{{ survey.survey_template.get_survey_type_display }}
{% if survey.status == 'completed' and survey.total_score %}
{% trans "Patient Score" %}
{{ survey.total_score|floatformat:1 }}
/ 5.0
{% trans "Template Average" %}
{{ template_average|floatformat:1 }}
/ 5.0
{% if survey.total_score >= template_average %} {% trans "Above average" %} {% else %} {% trans "Below average" %} {% endif %} {% if survey.is_negative %} {% trans "Negative feedback" %} {% endif %}
{% endif %}

{% trans "Survey Responses" %}

{% for response in responses %}
Q{{ forloop.counter }} {{ response.question.text }}
{% trans "Type" %}: {{ response.question.get_question_type_display }}
{% if response.numeric_value %}
{{ response.numeric_value }}
{% trans "out of" %} 5
{% endif %}
{% if response.question.question_type == 'rating' %}
{% trans "Rating" %}: {% for i in "12345" %} {% if forloop.counter <= response.numeric_value|floatformat:0 %} {% else %} {% endif %} {% endfor %}
{% if response.question.id in question_stats %} {% with question_stat=question_stats|get_item:response.question.id %}
{% trans "Average" %}: {{ question_stat.average }} {{ question_stat.total_responses }} {% trans "responses" %}
{% endwith %} {% endif %}
{% endif %} {% if response.question.question_type in 'multiple_choice,single_choice' %}
{% trans "Response" %}: {{ response.choice_value }}
{% if response.question.id in question_stats and question_stats|get_item:response.question.id.type == 'choice' %}
{% trans "Response Distribution" %}: {% for option in question_stats|get_item:response.question.id.options %}
{{ option.value }} {{ option.count }} ({{ option.percentage }}%)
{% endfor %}
{% endif %}
{% endif %} {% if response.text_value %}
{% trans "Comment" %} {{ response.text_value|length }} {% trans "characters" %}

{{ response.text_value|linebreaks }}

{% endif %}
{% empty %}

{% trans "No responses yet" %}

{% endfor %}
{% if survey.status == 'completed' %}

{% trans "Patient Comment" %}

{% if survey.comment %}

{{ survey.comment|linebreaks }}

{% trans "Submitted" %}: {{ survey.completed_at|date:"M d, Y H:i" }}
{% if survey.comment_analyzed and survey.comment_analysis %}

{% trans "AI Analysis" %}

{% trans "Sentiment" %}: {{ survey.comment_analysis.sentiment|title }} {% if survey.comment_analysis.sentiment_score %} (Score: {{ survey.comment_analysis.sentiment_score|floatformat:2 }}) {% endif %}
{% if survey.comment_analysis.emotion %}
{% trans "Emotion" %}: {{ survey.comment_analysis.emotion|title }}
{% endif %} {% if survey.comment_analysis.summary_en %}
{% trans "Summary" %}:

{{ survey.comment_analysis.summary_en }}

{% endif %} {% if survey.comment_analysis.topics_en %}
{% trans "Key Topics" %}:
{% for topic in survey.comment_analysis.topics_en %} {{ topic }} {% endfor %}
{% endif %}
{% elif survey.comment_analyzed %}
{% trans "Comment analysis failed. Check system logs for details." %}
{% else %}
{% trans "Comment is being analyzed by AI..." %}
{% endif %} {% else %}

{% trans "No comment provided by patient" %}

{% endif %}
{% endif %} {% if related_surveys %}

{% trans "Related Surveys from Patient" %}

{% for related in related_surveys %} {% endfor %}
{% trans "Survey" %} {% trans "Type" %} {% trans "Score" %} {% trans "Date" %} {% trans "Actions" %}
{{ related.survey_template.name }} {{ related.survey_template.get_survey_type_display }} {{ related.total_score|floatformat:1 }} {{ related.completed_at|date:"M d, Y" }}
{% endif %}

{% trans "Survey Information" %}

  • {% trans "Status" %} {% if survey.status == 'completed' %} {{ survey.get_status_display }} {% elif survey.status == 'sent' %} {{ survey.get_status_display }} {% elif survey.status == 'active' %} {{ survey.get_status_display }} {% else %} {{ survey.get_status_display }} {% endif %}
  • {% if survey.total_score %}
  • {% trans "Total Score" %} {{ survey.total_score|floatformat:1 }}/5.0
  • {% endif %} {% if survey.sent_at %}
  • {% trans "Sent" %} {{ survey.sent_at|date:"M d, Y H:i" }}
  • {% endif %} {% if survey.completed_at %}
  • {% trans "Completed" %} {{ survey.completed_at|date:"M d, Y H:i" }}
  • {% endif %}
  • {% trans "Type" %} {{ survey.survey_template.get_survey_type_display }}
  • {% if survey.survey_template.hospital %}
  • {% trans "Hospital" %} {{ survey.survey_template.hospital.name }}
  • {% endif %}

{% trans "Patient Information" %}

  • {% trans "Name" %} {{ survey.patient.get_full_name }}
  • {% trans "Phone" %} {{ survey.patient.phone }}
  • {% trans "MRN" %} {{ survey.patient.mrn }}
  • {% if survey.patient.email %}
  • {% trans "Email" %} {{ survey.patient.email }}
  • {% endif %}
{% if survey.journey_instance %}

{% trans "Journey Information" %}

  • {% trans "Journey" %} {{ survey.journey_instance.journey_template.name }}
  • {% if survey.journey_stage_instance %}
  • {% trans "Stage" %} {{ survey.journey_stage_instance.stage_template.name }}
  • {% endif %}
{% trans "View Journey" %}
{% endif %} {% if survey.is_negative %}

{% trans "Follow-up Actions" %}

{% if not survey.patient_contacted %}
{% trans "Action Required" %} {% trans "Contact patient to discuss negative feedback" %}
{% csrf_token %}
{% else %}
{% trans "Patient Contacted" %} {{ survey.patient_contacted_by.get_full_name }} • {{ survey.patient_contacted_at|date:"M d, Y" }}
{% trans "Notes" %}

{{ survey.contact_notes }}

{% if not survey.satisfaction_feedback_sent %}
{% csrf_token %}
{% else %}
{% trans "Feedback Sent" %} {{ survey.satisfaction_feedback_sent_at|date:"M d, Y" }}
{% endif %} {% endif %}
{% endif %}
{% endblock %} {% block extra_js %} {% endblock %}