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

{% block content %}

            <!-- ============================================================== -->
            <!-- Start right Content here -->
            <!-- ============================================================== -->
    <div class="content-page" xmlns="http://www.w3.org/1999/html">
                <!-- Start content -->
                <div class="content">
                    <div class="container">
                        <div class="row">

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

                            	<div class="card-box">
                            		<h4 class="m-t-0 header-title"><b>New Case</b></h4>
                                        <div>
                                            <h4> Please Select a look for a Patient or Create a New One</h4>
                                                      <div class="form-group m-b-0">
                                                         <div class="col-sm-offset-9 col-sm-9">
                                                             <a href="/dashboard/wizard/">
                                                               <!--  <button type="link" class="btn btn-default btn-custom waves-effect waves-light">New Patient</button> -->
                                                                 <form  action="/dashboard/wizard/" class="group-border-dashed" method="post" enctype="multipart/form-data">
                                                                    {% csrf_token %}
                                                                     <input type="hidden"  name="patient_first_name" value="{{ patient_first_name }}"/>
                                                                     <input type="hidden"  name="patient_last_name" value="{{ patient_last_name }}"/>
                                                                    <button type="submit" name="new_case" class="btn btn-default btn-custom waves-effect waves-light">Create New Case</button>
                                                                </form>
                                                             </a>
                                                        </div>
                                                      </div>
                                                     <form id="id_ajax_search_patient" action="/dashboard/new_entry/" class="form-horizontal" method="post" enctype="multipart/form-data">
                                                        {% csrf_token %}
                                                        <div>

                                                               <div class="col-lg-3">
                                                                    <div class="p-20">
                                                                        <h5><b>Look for Patient External-ID:</b></h5>
                                                                        <div class="input-group m-t-15">
                                                                            <input type="text" class="form-control" id="state-warning" maxlength="25" name="patient_external_id" placeholder="External ID" onKeyUp="this.value=this.value.toUpperCase();" />
                                                                            <span class="input-group-addon bg-custom b-0 text-white"><i class="fa fa-users"></i></span>
                                                                        </div>
                                                                    </div>
                                                               </div>

                                                               <div class="col-lg-4">
                                                                    <div class="p-20">
                                                                        <h5><b>First Name:</b></h5>
                                                                        <div class="input-group m-t-15">
                                                                            <input type="text" class="form-control" id="state-warning"  name="patient_first_name" placeholder="Enter First Name" value="{{ patient_first_name }}"/>
                                                                            <span class="input-group-addon bg-custom b-0 text-white"><i class="fa fa fa-user"></i></span>
                                                                        </div>
                                                                    </div>
                                                               </div>

                                                               <div class="col-lg-4">
                                                                    <div class="p-20">
                                                                        <h5><b> Last Name:</b></h5>
                                                                        <div class="input-group m-t-15">
                                                                            <input type="text" name="patient_last_name" class="form-control" id="state-warning" placeholder="Enter Last Name" value="{{ patient_last_name }}">
                                                                            <span class="input-group-addon bg-custom b-0 text-white"><i class="fa fa fa-user"></i></span>
                                                                        </div>
                                                                    </div>
                                                               </div>

                                                               <div class="form-group m-b-0">
                                                                     <div class="col-sm-offset-9 col-sm-9">
                                                                         <button type="submit" name="search" class="btn btn-default btn-custom waves-effect waves-light">Search Patient</button>
                                                                    </div>
                                                               </div>

                                                            <div class="form-group clearfix">
                                                                <h5 class="m-t-0 header-title"><b>{{ message }}</b></h5>
                                                            </div>

                                                        </div>
                                                     </form>



                                                     {% if Patients %}

                                                            <h4 class="m-t-0 header-title"><b>Result</b></h4>
                                                            <div class="row">
                                                                <table id="datatable" class="table table-striped table-bordered">
                                                                    <thead>
                                                                        <tr>
                                                                            <th>External ID</th>
                                                                            <th>Full Name</th>
                                                                            <th>DOB</th>
                                                                            <th>SSN</th>
                                                                            <th>Actions</th>
                                                                        </tr>
                                                                    </thead>
                                                                    <tbody>
                                                                    {% for patient in Patients %}

                                                                        {% if forloop.counter|divisibleby:2 %}
                                                                            <tr class="gradeX">
                                                                                <td>{{ patient.ext_id }}</td>
                                                                                <td>{{ patient.first_name }} {{ patient.last_name }}</td>
                                                                                <td>{{ patient.dob |date:"m/d/Y" }}</td>
                                                                                <td>{{ patient.show_SSN }}</td>
                                                                                <td class="actions">
                                                                                    <form  action="/dashboard/wizard/" class="group-border-dashed" method="post" enctype="multipart/form-data">
                                                                                        {% csrf_token %}
                                                                                         <input type="hidden"  name="patient_id" value="{{ patient.patient_id }}"/>
                                                                                        <button type="submit" name="new_case" class="btn btn-default btn-custom waves-effect waves-light">Create New Case</button>
                                                                                    </form>
                                                                                </td>
                                                                            </tr>
                                                                        {% else %}
                                                                            <tr class="gradeC">
                                                                                <td>{{ patient.ext_id }}</td>
                                                                                <td>{{ patient.first_name }} {{ patient.last_name }}</td>
                                                                                <td>{{ patient.dob |date:"m/d/Y" }}</td>
                                                                                <td>{{ patient.show_SSN }}</td>
                                                                                <td class="actions">
                                                                                    <form  action="/dashboard/wizard/" class="group-border-dashed" method="post" enctype="multipart/form-data">
                                                                                        {% csrf_token %}
                                                                                         <input type="hidden"  name="patient_id" value="{{ patient.patient_id }}"/>
                                                                                        <button type="submit" name="new_case" class="btn btn-default btn-custom waves-effect waves-light">Create New Case</button>
                                                                                    </form>
                                                                                </td>
                                                                            </tr>
                                                                        {% endif %}

                                                                    {% endfor %}



                                                                    </tbody>
                                                                </table>
                                                            </div>
                                                     {% endif %}

                            	</div>


                            <!-- End row -->

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

						<!-- end row -->



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

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




{% endblock %}