{% extends edc_listboard_template %}
{% load admin_urls %}
{% load edc_dashboard_extras %}
{% load meta_dashboard_extras %}

{% block listboard_panel %}

    <a id="subjectscreening_add"
        title="{% if perms.meta_screening.add_screeningpartone %}add screening{% else %}check your permissions{% endif %}"
        class="btn btn-sm btn-default" role="button"
        {% if not perms.meta_screening.add_screeningpartone %}disabled{% endif %}
        href="{% if perms.meta_screening.add_screeningpartone %}{{ subject_screening_add_url }}?next={{ screening_listboard_url }}{% endif %}">
            <i class="fas fa-plus fa-sm"></i> Add Subject Screening {% if meta_version == 3 %}(META3){% endif %}
    </a>

{% endblock listboard_panel %}


{% block listboard_table_header %}
    <!-- begin results header -->
    <th>#</th>
    <th></th>
    {% if meta_version == 2 %}<th>Corona</th>{% endif %}
    <th>ScreenID</th>
    <th>FBG/OGTT x 2</th>
    <th>Init</th>
    <th>Age</th>
    <th>StudyID</th>
    <th>User</th>
    <th>Modified</th>
    <!-- end results header -->
{% endblock listboard_table_header %}


{% block listboard_table_button_column %}
    <td style="white-space: nowrap">
    <div class="btn-group">
    {% screening_button result %}
    {% eligibility_button result %}
    {% if result.eligible %}
        {% if result.consent %}
            {% dashboard_button result %}
        {% else %}
            {% add_consent_button result %}
        {% endif %}
    {% endif %}
    </div>
    </td>
{% endblock listboard_table_button_column %}


{% block listboard_table_columns %}
    <td>{{ result.human_screening_identifier }} </td>
    <td nowrap>
        {% if result.repeat_glucose_performed == 'PENDING' %}
            {% if result.repeat_due_in_days < 3 %}
                <span style="color:orange">Pending</span>
            {% else %}
                <span style="color:red">Overdue ({{ result.repeat_due_in_days }}d)</span>
            {% endif %}
        {% elif result.repeat_glucose_performed == YES %}<span style="color:green">Done</span>
        {% else %}-{% endif %}
    </td>
    <td nowrap>{{ result.initials }}</td>
    <td nowrap>{{ result.age_in_years }} yrs {{ result.gender }}</td>
    <td nowrap>{% if result.consent %}{{ result.consent.subject_identifier }}{% else %} -- {% endif %}</td>
    <td nowrap>{{ result.user_created }}</td>
    <td nowrap>{{ result.object.modified|date:"SHORT_DATETIME_FORMAT" }}</td>

{% endblock listboard_table_columns %}
