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

{% block content %}

            <!-- ============================================================== -->
            <!-- Start right Content here -->
            <!-- ============================================================== -->
            <div class="content-page">
                <!-- Start content -->
                <div class="content">
                    <div class="container">
                        <div class="row">

                            <div class="col-lg-12">
                                 <!-- Basic Form Wizard -->

                            	<div class="card-box">

                                <div class="panel">
                                        {% if Entries %}

                                        <div class="panel-body">

                                             <div class="row">
                                                    <div class="col-sm-12">
                                                        <div class="card-box table-responsive">

                                                            <h4 class="m-t-0 header-title"><b>All Exams</b></h4>

                                                            <table id="datatable-responsive" class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%">
                                                                <thead>
                                                                    <tr>
                                                                        <th>Accession ID</th>
                                                                        <th>Exam Type</th>
                                                                        <th>Lab-ID</th>
                                                                        <th>Patient</th>
                                                                        <th>Client</th>
                                                                        <th>Collected date</th>
                                                                        <th>Created date</th>
                                                                        <th>Actions</th>
                                                                    </tr>
                                                                </thead>
                                                                <tbody>
                                                                {% if Entries %}
                                                                    {% for Entry in Entries %}
                                                                        {% if Entry.accession_number.all %}
                                                                            {% for accesion in Entry.accession_number.all %}
                                                                                {% if accesion.exam_in.exam_casetype.case_type_id == 1 %}
                                                                                        <tr>
                                                                                            {% if accesion.GYN_completed == 0 %}
                                                                                               <td><span class="label label-warning">{{ accesion.accession_number }}</span></td>
                                                                                            {% elif accesion.pathology_queve and not accesion.pathology_aproved %}
                                                                                                 <td><span class="label label-danger">{{ accesion.accession_number }}</span></td>
                                                                                            {% else %}
                                                                                                <td><span class="label label-success">{{ accesion.accession_number }}</span></td>
                                                                                            {% endif %}
                                                                                            <td>{{ accesion.exam_in.exam_casetype.case_type_name |upper}}</td>
                                                                                            <td>{{ Entry.lab_id }}</td>
                                                                                            <td>{{ Entry.patient.full_name }}</td>
                                                                                            <td>{{ Entry.patient.patient_client.get_full_name }}</td>
                                                                                            <td>{{ Entry.collection_date |date:"m/d/Y" }}</td>
                                                                                            <td>{{ Entry.created_date |date:"m/d/Y"}}</td>
                                                                                            <td>
                                                                                                {% if accesion.GYN_completed == 0 %}
                                                                                                    <a href="/dashboard/enter_result/{{ Entry.entry_id }}/">
                                                                                                        <button type="link" name="enter_result" class="btn btn-default btn-custom waves-effect waves-light">Enter Result</button>
                                                                                                    </a>
                                                                                                {% else %}
                                                                                                    <form  id="id_ajax_form_3_pdf" action="/dashboard/all_requisitions/" class="form-horizontal" method="post" enctype="multipart/form-data">
                                                                                                       {% csrf_token %}
                                                                                                       <input type="hidden"  name="entry_id" value="{{ Entry.entry_id }}"/>
                                                                                                       <input type="hidden"  name="accesion_id" value="{{ accesion.id }}"/>
                                                                                                       <button type="submit" name="export" class="btn btn-default btn-custom waves-effect waves-light">Export PDF</button>
                                                                                                    </form>
                                                                                                {% endif %}


                                                                                            </td>
                                                                                        </tr>
                                                                                {% elif accesion.exam_in.exam_casetype.case_type_id == 2 %}
                                                                                    <tr>
                                                                                        {% if accesion.Non_gyn_completed == 0 %}
                                                                                           <td><span class="label label-warning">{{ accesion.accession_number }}</span></td>
                                                                                        {% else %}
                                                                                            <td><span class="label label-success">{{ accesion.accession_number }}</span></td>
                                                                                        {% endif %}
                                                                                        <td>{{ accesion.exam_in.exam_casetype.case_type_name |upper}}</td>
                                                                                        <td>{{ Entry.lab_id }}</td>
                                                                                        <td>{{ Entry.patient.full_name }}</td>
                                                                                        <td>{{ Entry.patient.patient_client.get_full_name }}</td>
                                                                                        <td>{{ Entry.collection_date |date:"m/d/Y" }}</td>
                                                                                        <td>{{ Entry.created_date |date:"m/d/Y"}}</td>
                                                                                        <td>
                                                                                                {% if accesion.Non_gyn_completed == 0 %}
                                                                                                    <a href="/dashboard/enter_result/{{ Entry.entry_id }}/">
                                                                                                        <button type="link" name="enter_result" class="btn btn-default btn-custom waves-effect waves-light">Enter Result</button>
                                                                                                    </a>
                                                                                                {% else %}
                                                                                                    <form  id="id_ajax_form_3_pdf" action="/dashboard/all_requisitions/" class="form-horizontal" method="post" enctype="multipart/form-data">
                                                                                                       {% csrf_token %}
                                                                                                       <input type="hidden"  name="entry_id" value="{{ Entry.entry_id }}"/>
                                                                                                       <input type="hidden"  name="accesion_id" value="{{ accesion.id }}"/>
                                                                                                       <button type="submit" name="export" class="btn btn-default btn-custom waves-effect waves-light">Export PDF</button>
                                                                                                    </form>
                                                                                                {% endif %}
                                                                                        </td>
                                                                                    </tr>

                                                                                {% elif accesion.exam_in.exam_casetype.case_type_id == 3 %}
                                                                                    <tr>
                                                                                        {% if accesion.MP_completed == 0 %}
                                                                                           <td><span class="label label-warning">{{ accesion.accession_number }}</span></td>
                                                                                        {% else %}
                                                                                            <td><span class="label label-success">{{ accesion.accession_number }}</span></td>
                                                                                        {% endif %}
                                                                                        <td>{{ accesion.exam_in.exam_casetype.case_type_name |upper}}</td>
                                                                                        <td>{{ Entry.lab_id }}</td>
                                                                                        <td>{{ Entry.patient.full_name }}</td>
                                                                                        <td>{{ Entry.patient.patient_client.get_full_name }}</td>
                                                                                        <td>{{ Entry.collection_date |date:"m/d/Y" }}</td>
                                                                                        <td>{{ Entry.created_date |date:"m/d/Y"}}</td>
                                                                                        <td>
                                                                                                {% if accesion.MP_completed == 0 %}
                                                                                                    <a href="/dashboard/enter_result/{{ Entry.entry_id }}/">
                                                                                                        <button type="link" name="enter_result" class="btn btn-default btn-custom waves-effect waves-light">Enter Result</button>
                                                                                                    </a>
                                                                                                {% else %}
                                                                                                    <form  id="id_ajax_form_3_pdf" action="/dashboard/all_requisitions/" class="form-horizontal" method="post" enctype="multipart/form-data">
                                                                                                       {% csrf_token %}
                                                                                                       <input type="hidden"  name="entry_id" value="{{ Entry.entry_id }}"/>
                                                                                                       <input type="hidden"  name="accesion_id" value="{{ accesion.id }}"/>
                                                                                                       <button type="submit" name="export" class="btn btn-default btn-custom waves-effect waves-light">Export PDF</button>
                                                                                                    </form>
                                                                                                {% endif %}
                                                                                        </td>
                                                                                    </tr>

                                                                                {% elif accesion.exam_in.exam_casetype.case_type_id == 4 %}
                                                                                   <tr>
                                                                                        {% if accesion.SP_completed == 0 %}
                                                                                           <td><span class="label label-warning">{{ accesion.accession_number }}</span></td>
                                                                                        {% else %}
                                                                                            <td><span class="label label-success">{{ accesion.accession_number }}</span></td>
                                                                                        {% endif %}
                                                                                        <td>{{ accesion.exam_in.exam_casetype.case_type_name |upper}}</td>
                                                                                        <td>{{ Entry.lab_id }}</td>
                                                                                        <td>{{ Entry.patient.full_name }}</td>
                                                                                        <td>{{ Entry.patient.patient_client.get_full_name }}</td>
                                                                                        <td>{{ Entry.collection_date |date:"m/d/Y" }}</td>
                                                                                        <td>{{ Entry.created_date |date:"m/d/Y"}}</td>
                                                                                        <td>
                                                                                                {% if accesion.SP_completed == 0 %}
                                                                                                    <a href="/dashboard/enter_result/{{ Entry.entry_id }}/">
                                                                                                        <button type="link" name="enter_result" class="btn btn-default btn-custom waves-effect waves-light">Enter Result</button>
                                                                                                    </a>
                                                                                                {% else %}
                                                                                                    <form  id="id_ajax_form_3_pdf" action="/dashboard/all_requisitions/" class="form-horizontal" method="post" enctype="multipart/form-data">
                                                                                                       {% csrf_token %}
                                                                                                       <input type="hidden"  name="entry_id" value="{{ Entry.entry_id }}"/>
                                                                                                       <input type="hidden"  name="accesion_id" value="{{ accesion.id }}"/>
                                                                                                       <button type="submit" name="export" class="btn btn-default btn-custom waves-effect waves-light">Export PDF</button>
                                                                                                    </form>
                                                                                                {% endif %}
                                                                                        </td>
                                                                                    </tr>
                                                                                {% endif %}
                                                                            {% endfor %}
                                                                        {% endif %}


                                                                    {% endfor %}
                                                                {% endif %}


                                                                </tbody>
                                                            </table>
                                                        </div>
                                                    </div>
                                                </div>
                                        </div>
                                        <!-- end: page -->
                                        {% endif %}

                                    </div> <!-- end Panel -->



                            	</div>


                            <!-- End row -->

                            </div> <!-- end col -->
                        </div>

						<!-- end row -->



                    </div> <!-- container -->

                </div> <!-- content -->


{% endblock %}