{# Partial: Series Findings for a Case #}
<div>
    <details open>
        <summary><b>Findings</b></summary>

        {% if can_edit %}
            <details class="help-text">
                <summary><i class="bi bi-info-circle"></i> Help</summary>
                <p>Findings are display sets that can be added to series. Once added they will appear here on linked cases.</p>
                <p>To add a finding to a series, select the series and then click the "Add finding" button.</p>
            </details>
        {% endif %}

        <!-- Series Findings -->
        <h5>Series Findings</h5>
        {% for series in case.get_ordered_series %}
            {% for finding in series.findings.all %}
                <div class="finding-box" id="finding-box-{{ finding.pk }}" data-series="{{ series.pk }}">
                    <span>
                        <a href="{{series.get_absolute_url}}?show_finding={{finding.pk}}">
                            <button class="btn btn-primary btn-sm">View</button>
                        </a>
                        <button class="btn btn-secondary btn-sm view-finding-modal" data-finding-id="{{ finding.pk }}" data-series-id="{{ series.pk }}">
                            View in Modal
                        </button>
                    </span>
                    {% if finding.findings %}
                        <span>
                            Findings: {% for f in finding.findings.all %}
                                {{f.get_link}},&nbsp;
                            {% endfor %}
                        </span>
                    {% endif %}
                    {% if finding.conditions %}
                        <span>
                            Conditions: {% for c in finding.conditions.all %}
                                {{c.get_link}},&nbsp;
                            {% endfor %}
                        </span>
                    {% endif %}
                    {% if finding.structures %}
                        <span>
                            Structure: {% for s in finding.structures.all %}
                                {{s.get_link}},&nbsp;
                            {% endfor %}
                        </span>
                    {% endif %}
                    {% if finding.description %}
                        <span>
                            Description: {{finding.description}}
                        </span>
                    {% endif %}
                </div>
            {% endfor %}
        {% empty %}
            No series associated with case.
        {% endfor %}
    </details>
</div>
