{% 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" %}

{% if survey.completed_language %}
{% trans "Completed in" %}: {% if survey.completed_language == 'ar' %}{% trans "Arabic" %}{% else %}{% trans "English" %}{% endif %}
{% endif %}
{% if responses %}
{% for response in responses %} {% if response.question.question_type in 'text,textarea' and response.text_value and response.text_value|length > 120 %} {% endif %} {% endfor %}
# {% trans "Question" %} {% trans "Question (AR)" %} {% trans "Type" %} {% trans "Response" %} {% trans "Avg" %}
{{ forloop.counter }}
{{ response.question.text }}
{% if response.question.text_ar %}
{{ response.question.text_ar }}
{% endif %}
{{ response.question.get_question_type_display }} {% if response.question.question_type == 'rating' %} {{ response.numeric_value|floatformat:1 }} / 5 {% elif response.question.question_type == 'nps' %} {{ response.numeric_value|floatformat:0 }} {% if response.numeric_value >= 9 %}({% trans "Promoter" %}) {% elif response.numeric_value >= 7 %}({% trans "Passive" %}) {% else %}({% trans "Detractor" %}){% endif %} {% elif response.question.question_type == 'yes_no' %} {% if response.choice_value == 'yes' %} {% trans "Yes" %} {% else %} {% trans "No" %} {% endif %} {% elif response.question.question_type in 'multiple_choice,single_choice' %} {{ response.text_value }} {% elif response.question.question_type in 'text,textarea' and response.text_value %} {{ response.text_value|truncatechars:120 }} {% else %} {% endif %} {% if response.question.id in question_stats %} {% with question_stat=question_stats|get_item:response.question.id %} {{ question_stat.average|floatformat:1 }} {% endwith %} {% else %} {% endif %}
{{ response.text_value }}
{% else %}

{% trans "No responses yet" %}

{% trans "The patient hasn't submitted any answers" %}

{% endif %}
{% 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 Link" %}

{{ survey_url }}
{% if survey.token_expires_at %}
{% trans "Expires" %}: {{ survey.token_expires_at|date:"M d, Y H:i" }}
{% endif %}
{% if survey.status == 'completed' and survey.comment %} {% trans "Survey Comments" %} {% 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.completed_language %}
  • {% trans "Language" %} {% if survey.completed_language == 'ar' %} العربية {% else %} English {% endif %}
  • {% endif %} {% 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 visit_timeline %}

{% trans "Visit Timeline" %}

{% for visit in visit_timeline %}
{{ visit.bill_date }}
{{ visit.type }}
{{ visit.patient_type }}
{% endfor %}
{% endif %} {% if survey.journey_instance %}

{% trans "Journey Information" %}

  • {% trans "Journey" %} {{ survey.journey_instance.journey_template.name }}
  • {% if survey.journey_instance %}
  • {% trans "Stage" %} {{ survey.journey_instance.journey_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 %}