{% extends 'generic/base.html' %}

{% block content %}



    <div class="floating-header">
        <a href="{% url 'generic:examination_update' pk=examination.pk %}" title="Edit the Examination">Edit</a>
        <a href="{% url 'generic:examination_delete' pk=examination.pk %}" title="Delete the Examination">Delete</a>
        {% if request.user.is_superuser %}
            <a href="{% url 'admin:generic_examination_change' examination.id %}"
                title="Edit the Examination using the admin interface">Admin Edit</a>
        {% endif %}
    </div>
    <div>
        <h3>Name: {{examination.examination}}</h3>
        Modality: {{examination.modality}}
    </div>
    {% if examination.atlas_series_examination.all %}
        <h4>Associated Atlas Series</h4>
        <ul>

            {% for series in examination.atlas_series_examination.all %}
                <li>{{series.get_link}}</li>
            {% endfor %}

        </ul>
    {% endif %}
    {% if examination.series_examination.all %}
        <h4>Associated Longs Series</h4>
        <ul>

            {% for series in examination.series_examination.all %}
                <li>{{series.get_link}}</li>
            {% endfor %}

        </ul>
    {% endif %}
    {% if examination.anatomyquestion_set.all %}
        <h4>Associated Anatomy Questions</h4>
        <ul>

            {% for question in examination.anatomyquestion_set.all %}
                <li>{{question.get_link}}</li>
            {% endfor %}

        </ul>
    {% endif %}

    <details><summary>Merge</summary>

        <form hx-post="{% url 'generic:examination_merge' examination.pk %}"
          hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
          hx-confirm="Are you sure?"
          hx-target="#result">
          {{merge_form}}
        <p>This will replace all occurances of the "{{examination}}" and with the selected examination and delete it.</p>
        <p>It cannot be undone</p>
      <button type="submit">
        Merge
      </button>
    </form>    

  <section>
    <p id="result"><em></em></p>
  </section>
    
    </details>


{% endblock %}

{% block js %}

{% endblock %}
