{% extends "remapp/filteredbase.html" %}

{% block navbar %}
            <li class="active"><a href="/openrem/ct">CT</a></li>
            <li><a href="/openrem/rf">Fluoroscopy</a></li>
            <li><a href="/openrem/mg">Mammography</a></li>
{% endblock %}

{% block toprow %}
      {% load pagination_tags %}    
    
      <p>
        There are {{ filter.count }} studies in this list.
      </p>
        {% if admin.exportperm or admin.adminperm %}
        <ul>
          <li><strong>Note:</strong> Apply the filter first to refine what is exported.</li>
          <li><a href="/openrem/exportctcsv1/?{{ request.GET.urlencode }}">Export to CSV</a> </li>
          <li><a href="/openrem/exportctxlsx1/?{{ request.GET.urlencode }}">Export to XLSX</a></li>
        </ul>

        {% else %}
        <p>
          Sorry, you don't have enough permissions to enable study export.
        </p>
        {% endif %}
        
{% endblock %}


{% block col2 %}


    {{ studyfilter }}






          <div class="panel panel-info">
            <div class="panel-heading">
              <h3 class="panel-title">Exam filter</h3>
            </div>
            <div class="panel-body">
                <i>Date format yyyy-mm-dd</i>
                <form action="" method="get" class="form-horizontal" role="form">
                        {% for field in filter.form %}
                            <div class="form-group">
                                <div class="col-xs-4">
                                    <label>{{ field.label_tag }}</label>
                                </div>
                                <div class="col-xs-8">
                                  {{ field.errors }}
                                  {{ field }}
                                </div>
                            </div>
                        {% endfor %}
                    </table>
                    <input type="submit" />
                </form> 
            </div>
          </div>


<script>
$('.datepicker').datepicker({
    format: "yyyy-mm-dd",
    autoclose: true,
    todayHighlight: true
    });
</script>

{% endblock %}

{% block col1 %}


      {% autopaginate filter.qs 25 as filter_list %}
      {% paginate %}
    <table class="table table-striped">
        <th>Institution</th><th>Make | Model | Station name</th><th>Date</th><th>Study description | Accession number</th><th>Number of events</th><th>Dose Length Product Total mGy.cm</th>
        {% if admin.adminperm %}
        <th>Delete?</th>
        {% endif %}
        {% for exam in filter_list %}
        <tr>
            <td>{{ exam.general_equipment_module_attributes_set.get.institution_name }}</td>
            <td>
                {{ exam.general_equipment_module_attributes_set.get.manufacturer }} |
                {{ exam.general_equipment_module_attributes_set.get.manufacturer_model_name }} |
                {{ exam.general_equipment_module_attributes_set.get.station_name }}        
            </td>
            <td>{{ exam.study_date|date:"Y-m-d" }} {{ exam.study_time|date:"H:i" }}</td>
            <td>
                <a href="/openrem/ct/{{ exam.id }}/">{{ exam.study_description }}</a> |
                {{ exam.accession_number }} |
                {{ exam.patient_study_module_attributes_set.get.patient_size|floatformat:0 }} cm |
                {{ exam.patient_study_module_attributes_set.get.patient_weight|floatformat:0 }} kg
            </td>
            <td>{{ exam.ct_radiation_dose_set.get.ct_accumulated_dose_data_set.get.total_number_of_irradiation_events }}</td>
            <td>{{ exam.ct_radiation_dose_set.get.ct_accumulated_dose_data_set.get.ct_dose_length_product_total|floatformat:2 }}</td>
            {% if admin.adminperm %}
            <td>
              <a href="{% url 'study_delete' exam.id %}">Delete</a>
            </td>
            {% endif %}
        </tr>
        {% endfor %}
    </table>

    {% paginate %}

{% endblock %}

{% block jsblock %}
{% endblock %}
